Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
f867e90
docs: add Phase 0 CC architecture extraction + core agent refactor
nmhjklnm Apr 1, 2026
06d4277
feat(state): add three-layer state models
nmhjklnm Apr 1, 2026
7ee412e
feat(cleanup): add CleanupRegistry with priority ordering
nmhjklnm Apr 1, 2026
87931a9
feat(registry): add context_schema to ToolEntry
nmhjklnm Apr 1, 2026
4e2e25f
feat(loop): implement QueryLoop replacing create_agent
nmhjklnm Apr 1, 2026
b0b74a4
feat(fork): add context fork for sub-agents
nmhjklnm Apr 1, 2026
e27aeb8
refactor(agent): replace create_agent with QueryLoop
nmhjklnm Apr 1, 2026
3b962d4
feat(agent-service): use context fork for sub-agent spawn
nmhjklnm Apr 1, 2026
d289d86
fix(compactor): align with CC L4b Legacy Compact design
nmhjklnm Apr 1, 2026
914cd3d
test: add unit tests for state/cleanup/fork/loop
nmhjklnm Apr 1, 2026
c0d5362
test: add integration test for LeonAgent astream
nmhjklnm Apr 1, 2026
eeafaf3
refactor: align tool system with Claude Code design patterns
nmhjklnm Apr 2, 2026
5c001d7
fix(search): align Grep/Glob with CC ripgrep behavior
nmhjklnm Apr 2, 2026
fe19e37
feat(lsp): add LSP tool via multilspy (5 operations)
nmhjklnm Apr 2, 2026
9a93068
refactor(lsp): promote multilspy to core dep + CC alignment fixes
nmhjklnm Apr 2, 2026
c33b35a
feat(lsp): add goToImplementation and call hierarchy operations
nmhjklnm Apr 2, 2026
a6c77da
fix(lsp): correct symbol formatters and handle multilspy AssertionError
nmhjklnm Apr 2, 2026
ed27985
feat(lsp): add _PyrightSession for Python call hierarchy via pyright-…
nmhjklnm Apr 2, 2026
ddca1f9
fix: remove dead code, add lsp package to pyproject, update plan doc
nmhjklnm Apr 2, 2026
23725b6
refactor(lsp): promote language servers to process-level singletons
nmhjklnm Apr 2, 2026
96b6ca8
Refactor agent core through sa-04 subagent boundaries
shuxueshuxue Apr 2, 2026
7aaf990
Refine subagent policy through sa-05
shuxueshuxue Apr 2, 2026
bdb0628
Refine sa-06 orchestration mailbox cleanup
shuxueshuxue Apr 2, 2026
decd8c0
Refine pt-02 tool system aggregate semantics
shuxueshuxue Apr 2, 2026
38d7451
Refine pt-03 three-layer state rollup semantics
shuxueshuxue Apr 2, 2026
6f647fa
Refine pt-04 subagent orchestration context sourcing
shuxueshuxue Apr 2, 2026
a2f4f55
Refine pt-05 lifecycle cleanup semantics
shuxueshuxue Apr 2, 2026
2dec577
Refine pt-06 hook fan-out and prompt caching
shuxueshuxue Apr 2, 2026
03c9d3b
Tighten pt-08 framework-credit wording
shuxueshuxue Apr 2, 2026
c2c27d4
Refine api-01 retry and overflow recovery
shuxueshuxue Apr 3, 2026
34e22e9
Refine api-02 streaming failure semantics
shuxueshuxue Apr 3, 2026
b0edcd1
Refine api-04 MCP transport and result conversion
shuxueshuxue Apr 3, 2026
8319d95
Refine api-05 compaction and resume honesty
shuxueshuxue Apr 3, 2026
5a0eb4c
Refine dt-01 file edit critical section
shuxueshuxue Apr 3, 2026
ede2cdb
Refine dt-02 file read path and read state
shuxueshuxue Apr 3, 2026
020be21
Refine dt-03 deferred tool discovery
shuxueshuxue Apr 3, 2026
5bbaf27
Refine dt-04 tool family policies
shuxueshuxue Apr 3, 2026
4cea58d
Refine sp-01 bash command security slice
shuxueshuxue Apr 3, 2026
86af0f8
Refine sp-02 permission resolution slice
shuxueshuxue Apr 3, 2026
b94a0aa
Implement sp-02 permission resolution surface
shuxueshuxue Apr 3, 2026
ff7e19a
Implement sp-03 tool hook timeout and permission request surfaces
shuxueshuxue Apr 3, 2026
935b70f
Reuse parent lease for subagent sandbox threads
shuxueshuxue Apr 3, 2026
f92198e
Repair ql-06 backend state bridge
shuxueshuxue Apr 3, 2026
07b7cbf
Repair ql-06 resumed-thread null input handling
shuxueshuxue Apr 3, 2026
bad9d44
Repair pt-04 subagent sandbox inheritance and thread metadata
shuxueshuxue Apr 3, 2026
72f5c52
Repair pt-04 agent pool wiring coverage
shuxueshuxue Apr 3, 2026
d67fc1b
Repair sa-06 followup queue transition ordering
shuxueshuxue Apr 3, 2026
40e6ae7
Repair ql-06 caller notices and pt-04 child isolation
shuxueshuxue Apr 3, 2026
98c0660
Implement sp-05 session lifecycle hooks
shuxueshuxue Apr 3, 2026
bd9ce75
Align subagent delivery queue naming
shuxueshuxue Apr 3, 2026
83484f0
Align agent and task tool contracts
shuxueshuxue Apr 3, 2026
d32b6cb
Repair background followup notifications and history tails
shuxueshuxue Apr 3, 2026
e314215
Slim prompt rules to cross-tool guidance
shuxueshuxue Apr 3, 2026
bbccd75
Repair pt-04 Daytona interleave boundaries
shuxueshuxue Apr 3, 2026
f1d4aed
Repair thread creation sandbox_type contract
shuxueshuxue Apr 3, 2026
0a178b1
Defer terminal background notices across active runs
shuxueshuxue Apr 3, 2026
44e7506
Make LeonAgent close idempotent
shuxueshuxue Apr 3, 2026
c7a1bf8
Persist terminal followup notices for caller rebuilds
shuxueshuxue Apr 3, 2026
143c48b
Tighten auth and discovery caller contracts
shuxueshuxue Apr 3, 2026
c9c38a7
Guard tool_search exact select loop contract
shuxueshuxue Apr 3, 2026
0537912
Guard tool search caller history contract
shuxueshuxue Apr 3, 2026
10f10bd
Guard legacy sandbox_type thread creation path
shuxueshuxue Apr 3, 2026
8ac9712
Fix steer phase boundary runtime wiring
shuxueshuxue Apr 3, 2026
d14151c
Persist steer injections in query loop state
shuxueshuxue Apr 3, 2026
6f68acd
Remove dev auth bypass runtime path
shuxueshuxue Apr 3, 2026
75cfa16
Persist cancelled steer inputs honestly
shuxueshuxue Apr 3, 2026
3f581ee
Make steer stop semantics non-preemptive and honest
shuxueshuxue Apr 3, 2026
5072d2c
Expose thread permission resolution flow
shuxueshuxue Apr 3, 2026
fb96340
Surface compaction boundaries in caller history
shuxueshuxue Apr 3, 2026
150cca4
Make permission ask fail loud without resolver
shuxueshuxue Apr 3, 2026
f7ed37c
Add thread clear route and owner action
shuxueshuxue Apr 3, 2026
a57286a
Persist prompt-too-long recovery notices
shuxueshuxue Apr 3, 2026
ea3fa26
Add thread-scoped session permission rules
shuxueshuxue Apr 3, 2026
4737569
Guard compaction lifecycle caller contract
shuxueshuxue Apr 3, 2026
4612849
Fail loud when ask cannot request
shuxueshuxue Apr 3, 2026
e052f3d
Add thread-scoped compaction breaker
shuxueshuxue Apr 3, 2026
52b1c0e
Narrow compaction breaker to automatic retries
shuxueshuxue Apr 3, 2026
f03cb54
Guard direct agent compaction persistence
shuxueshuxue Apr 3, 2026
f311ad7
Preserve live permission state during active reads
shuxueshuxue Apr 3, 2026
4139306
Fix thread switch routing and dedupe resource sessions
shuxueshuxue Apr 4, 2026
e99afee
Tighten thread switch hot path and deep links
shuxueshuxue Apr 4, 2026
1545eea
Dedup thread bootstrap fetches in dev
shuxueshuxue Apr 4, 2026
ecdaa6d
Trim PR-only planning docs and empty test packages
shuxueshuxue Apr 4, 2026
3d261d8
Flatten test layout and drop repo-local auth helper
shuxueshuxue Apr 4, 2026
f21942b
Reorganize test suite by scope
shuxueshuxue Apr 4, 2026
9fe4c1e
Fix directory owner lookup field
shuxueshuxue Apr 4, 2026
75a16ec
Resume terminal background followthrough runs
shuxueshuxue Apr 4, 2026
0e33575
Strengthen background followthrough route coverage
shuxueshuxue Apr 4, 2026
0df9db0
Prevent silent terminal followthrough collapse
shuxueshuxue Apr 4, 2026
496ba39
Merge origin/main after background followthrough fixes
shuxueshuxue Apr 4, 2026
370139f
Align auth shell with Supabase-backed members
shuxueshuxue Apr 4, 2026
265481a
Fix local background shell bootstrap and trim thread header
shuxueshuxue Apr 4, 2026
a8ab452
Bridge child threads through live web runs
shuxueshuxue Apr 4, 2026
d683e07
Rebind child thread handlers from stale parent sinks
shuxueshuxue Apr 4, 2026
9f9f2ce
Restore child stream metadata on live tool results
shuxueshuxue Apr 4, 2026
5e018b3
Patch late child stream task-start race
shuxueshuxue Apr 4, 2026
9f21e80
Keep web child threads alive after completion
shuxueshuxue Apr 4, 2026
3a8120a
Reconcile parent child-task status on checkpoint rebuild
shuxueshuxue Apr 4, 2026
5e20df8
Filter stale display deltas on reconnect
shuxueshuxue Apr 4, 2026
25de60c
Split Supabase auth and storage clients
shuxueshuxue Apr 4, 2026
a441c26
Lock idle child status rebuild contract
shuxueshuxue Apr 4, 2026
f4fac97
Cover terminal child statuses on idle rebuild
shuxueshuxue Apr 4, 2026
9276518
Reconcile live child notices immediately
shuxueshuxue Apr 4, 2026
942d1e5
Trim login thread bounce
shuxueshuxue Apr 4, 2026
04fcb6e
Dedup threads root redirect fetch
shuxueshuxue Apr 4, 2026
c8fcc90
Fix thread display delta dedupe
shuxueshuxue Apr 4, 2026
5969dc7
Refresh stale sandbox capability sessions
shuxueshuxue Apr 4, 2026
c7995f1
Add unread mention support to Supabase chats
shuxueshuxue Apr 4, 2026
a4f8878
Align Supabase unread mention semantics
shuxueshuxue Apr 4, 2026
a173549
Expose chat tools in member catalog
shuxueshuxue Apr 4, 2026
78fb4a7
Align chat tool streaming arg readiness
shuxueshuxue Apr 4, 2026
774d5af
Harden chat notification reply contract
shuxueshuxue Apr 4, 2026
7fdcad5
Stabilize external chat notification flow
shuxueshuxue Apr 4, 2026
840914c
Prefer direct chat_id handling in chat notifications
shuxueshuxue Apr 4, 2026
c3e865f
Remove shared middleware tool default
shuxueshuxue Apr 4, 2026
b194c75
Align default filesystem edit cap with read cap
shuxueshuxue Apr 4, 2026
0c8810b
Offload LSP gitignore filtering from event loop
shuxueshuxue Apr 4, 2026
7fbc0c6
Deduplicate terminal notification detection
shuxueshuxue Apr 4, 2026
7c85cdd
Encapsulate child fork wiring in LeonAgent
shuxueshuxue Apr 4, 2026
81d5aa4
Inject child agent factory into AgentService
shuxueshuxue Apr 4, 2026
ec5c5a6
Type ToolUseContext core callable fields
shuxueshuxue Apr 4, 2026
fb057df
Reuse canonical lease binding helper
shuxueshuxue Apr 4, 2026
9d2d7bb
Type recovery results and defer split tool args
shuxueshuxue Apr 4, 2026
d921206
Merge origin/main after auth dependency sync
shuxueshuxue Apr 4, 2026
8cc2804
Add dedicated LeonAgent unit seams
shuxueshuxue Apr 4, 2026
2b01252
Fix CI auth-router drift and test lint
shuxueshuxue Apr 4, 2026
01f452f
Close Python CI lint and drift debt
shuxueshuxue Apr 4, 2026
43b45c2
Fix Windows remote path semantics and WAL cleanup
shuxueshuxue Apr 4, 2026
950f3e5
Format Windows path handling fixes
shuxueshuxue Apr 4, 2026
99616f4
Stream child agent pane live updates
shuxueshuxue Apr 4, 2026
53acfdd
Merge remote-tracking branch 'origin/main' into pr188-agent-optimize
shuxueshuxue Apr 4, 2026
59c0852
Fix local sandbox runtime store seams
shuxueshuxue Apr 4, 2026
5a065d3
Resolve resource owner metadata via runtime storage
shuxueshuxue Apr 4, 2026
c47a8b5
Wait for reused Daytona volumes to become ready
shuxueshuxue Apr 4, 2026
54fc575
Suppress stale thread permission fetch noise
shuxueshuxue Apr 4, 2026
a8025eb
Fix staging deploy workflow contract
shuxueshuxue Apr 4, 2026
6f3e991
Ignore unavailable local thread cwd on agent boot
shuxueshuxue Apr 4, 2026
022c146
Fail loudly on unavailable sandbox providers
shuxueshuxue Apr 4, 2026
888fed6
Persist staging Leon home volume
shuxueshuxue Apr 4, 2026
bd1d998
Fail loudly when E2B SDK is unavailable
shuxueshuxue Apr 4, 2026
826ab9b
Install sandbox provider SDKs in backend image
shuxueshuxue Apr 4, 2026
18ade7a
Bootstrap E2B workspace root on session create
shuxueshuxue Apr 4, 2026
400a513
Hydrate AgentBay sessions for direct shell calls
shuxueshuxue Apr 4, 2026
9dd36a2
Force AgentBay shell through LinkUrl when available
shuxueshuxue Apr 4, 2026
d998049
Rehydrate AgentBay direct-call metadata from raw session response
shuxueshuxue Apr 4, 2026
4c21365
Guard AgentBay shell resolver exceptions
shuxueshuxue Apr 4, 2026
b310fb8
Own AgentBay LinkUrl shell calls
shuxueshuxue Apr 4, 2026
0f5d7ab
Fail loudly on blank command exceptions
shuxueshuxue Apr 4, 2026
c3cc05e
Instrument AgentBay execute path
shuxueshuxue Apr 4, 2026
325d8af
Instrument sandbox command binding chain
shuxueshuxue Apr 4, 2026
b8cb3e1
Flush AgentBay instrumentation logs
shuxueshuxue Apr 4, 2026
466976d
Avoid same-loop init command deadlock
shuxueshuxue Apr 4, 2026
40fd358
Self-heal missing remote thread volumes
shuxueshuxue Apr 4, 2026
8bf62b7
Respect AgentBay pause capability in idle reaper
shuxueshuxue Apr 4, 2026
b3035ae
Skip AgentBay sync destroy when pause is unsupported
shuxueshuxue Apr 4, 2026
559a9d6
Tighten threads entry bootstrap
shuxueshuxue Apr 4, 2026
cf59946
Fail loudly for silent child thread failures
shuxueshuxue Apr 4, 2026
b14aa00
Make thread entry points honest
shuxueshuxue Apr 4, 2026
304a95c
Fix task thread deep links
shuxueshuxue Apr 4, 2026
859ae5f
Remove header pause button
shuxueshuxue Apr 5, 2026
5290ddf
Fix TaskOutput command running message
shuxueshuxue Apr 5, 2026
9dff9e4
Land verified auth and runtime fixes
shuxueshuxue Apr 5, 2026
acb43cb
Fix resource overview CI test isolation
shuxueshuxue Apr 5, 2026
02ae7f5
Keep thread detail honest after run errors
shuxueshuxue Apr 5, 2026
5de2f9c
Format idle rebuild regression test
shuxueshuxue Apr 5, 2026
198f935
Fix subagent task surfacing and local volume teardown
shuxueshuxue Apr 5, 2026
4d89210
Hide subagent threads from routing targets
shuxueshuxue Apr 5, 2026
c789419
Rebuild stale idle thread detail from checkpoint
shuxueshuxue Apr 5, 2026
37c838d
Fix OTP auth flow for direct GoTrue clients
shuxueshuxue Apr 5, 2026
6f864f0
Fix blocking subagent status honesty
shuxueshuxue Apr 5, 2026
c9d49ad
Fix frontend auth session reset
shuxueshuxue Apr 5, 2026
c00f419
Normalize blocking subagent cwd prompts
shuxueshuxue Apr 5, 2026
54e2e1d
Merge origin/main and absorb PR198 runtime changes
shuxueshuxue Apr 5, 2026
45f35ff
Close brutal subagent verification gaps
shuxueshuxue Apr 5, 2026
ed99964
Unblock no-main-thread bootstrap entry
shuxueshuxue Apr 5, 2026
297931f
Simplify frontend bootstrap state helpers
shuxueshuxue Apr 5, 2026
eddd47c
Simplify background task projection helpers
shuxueshuxue Apr 5, 2026
833169d
Simplify streaming display helpers
shuxueshuxue Apr 5, 2026
e88d7e6
Prune dead helpers and slim test fixtures
shuxueshuxue Apr 5, 2026
19576f8
Prune dead frontend exports
shuxueshuxue Apr 5, 2026
2fb18be
Simplify query loop followthrough fixtures
shuxueshuxue Apr 5, 2026
3f80f1d
Trim more query loop test boilerplate
shuxueshuxue Apr 5, 2026
a57168d
Simplify query loop followthrough matrix
shuxueshuxue Apr 5, 2026
63a7bba
Simplify agent service tests
shuxueshuxue Apr 5, 2026
5679e92
Simplify threads router tests
shuxueshuxue Apr 5, 2026
4c235c1
Trim more threads router test scaffolding
shuxueshuxue Apr 5, 2026
014bcab
Simplify more threads router tests
shuxueshuxue Apr 5, 2026
3a5a333
Simplify loop tests
shuxueshuxue Apr 5, 2026
bd27ac8
Simplify threads router patch groups
shuxueshuxue Apr 5, 2026
b51fd53
Simplify loop tool fixtures
shuxueshuxue Apr 5, 2026
490a598
Persist visible model errors in history
shuxueshuxue Apr 5, 2026
a9bb1d1
Fix parent Agent completion after subagent finish
shuxueshuxue Apr 5, 2026
4d0f535
Fix footer close after subagent completion
shuxueshuxue Apr 5, 2026
b095938
Fix prompt-too-long detail assertions
shuxueshuxue Apr 5, 2026
5627d57
Format prompt-too-long bridge tests
shuxueshuxue Apr 5, 2026
4974c12
Hide subagent identities from lease resources
shuxueshuxue Apr 5, 2026
07bf18f
Harden staging deploy verification
shuxueshuxue Apr 5, 2026
9d2b947
Rename message tools and remove connections
shuxueshuxue Apr 5, 2026
c0fed15
Fix paused lease rehydration and drop resume button
shuxueshuxue Apr 5, 2026
3d8e013
Refresh live lease binding after resume
shuxueshuxue Apr 5, 2026
369d933
Rename Mycel chat tools and remove social extras
shuxueshuxue Apr 5, 2026
f117c41
Tighten task output and tool parameter contracts
shuxueshuxue Apr 5, 2026
b6d7775
Harden paused Daytona runtime recovery
shuxueshuxue Apr 5, 2026
1119cc4
Fix Daytona resumed lease file roundtrip
shuxueshuxue Apr 5, 2026
1d78e15
Tighten core tool typing contracts
shuxueshuxue Apr 5, 2026
dca2107
Type build_tool contracts explicitly
shuxueshuxue Apr 5, 2026
1f2227e
Share typed tool schema builder
shuxueshuxue Apr 5, 2026
f65757a
Unify typed tool schema definitions
shuxueshuxue Apr 5, 2026
464272b
Tighten remaining typed tool boundaries
shuxueshuxue Apr 5, 2026
2bb468a
Share typed builder across remaining tool services
shuxueshuxue Apr 5, 2026
b919869
Unify agent service tool schemas
shuxueshuxue Apr 5, 2026
17ca005
Fix chat tool names in intro docs
shuxueshuxue Apr 5, 2026
c4958c9
Unify prompt rules first tranche
shuxueshuxue Apr 5, 2026
639d6f2
Harden validation pipeline first slice
shuxueshuxue Apr 5, 2026
945392b
Tighten web and command schema constraints
shuxueshuxue Apr 5, 2026
f9ec17a
Unify filesystem preflight validation
shuxueshuxue Apr 5, 2026
47e0ea7
Structure input validation errors
shuxueshuxue Apr 5, 2026
6351da7
Preflight remote file sizes before download
shuxueshuxue Apr 5, 2026
ad0107d
Unify prompt rule construction
shuxueshuxue Apr 5, 2026
1b301fe
Expose cron tools to agents
shuxueshuxue Apr 5, 2026
ac6e6f9
Add MCP resource tools for member agents
shuxueshuxue Apr 5, 2026
80bb966
Auto-deploy staging on branch pushes
shuxueshuxue Apr 5, 2026
4327e8d
Handle push refs in staging deploy
shuxueshuxue Apr 5, 2026
1c4870b
Add AskUserQuestion core interaction flow
shuxueshuxue Apr 5, 2026
1ebcc94
Add MCP instruction delta middleware
shuxueshuxue Apr 5, 2026
84ac3e0
Add function-result-clearing prompt contract
shuxueshuxue Apr 5, 2026
3466d6a
Remove frontend sandbox pause resume controls
shuxueshuxue Apr 5, 2026
4f43040
Stabilize agent pool sync contract
shuxueshuxue Apr 5, 2026
847f1ae
Remove debug backdoors and fix path schemas
shuxueshuxue Apr 5, 2026
90415ff
Fix ask-user question prompt identity
shuxueshuxue Apr 5, 2026
5a6630c
Prefer visible lease threads in resource monitor
shuxueshuxue Apr 6, 2026
1aef5b8
Keep raw monitor truth out of resource projection
shuxueshuxue Apr 6, 2026
b557594
Refresh resource cache on local run start
shuxueshuxue Apr 6, 2026
c23fb16
Fix Windows local metrics test patching
shuxueshuxue Apr 6, 2026
0385da0
Refresh stale resource snapshots on live drift
shuxueshuxue Apr 6, 2026
ec0b2a2
Abort stale thread permission fetches
shuxueshuxue Apr 6, 2026
dff431d
Retry staging health checks during deploy
shuxueshuxue Apr 6, 2026
05d12b1
Ignore stale permission fetches after navigation
shuxueshuxue Apr 6, 2026
984236e
Invalidate empty cached pricing payloads
shuxueshuxue Apr 6, 2026
cb9262b
Fix ask-user state clearing and Windows pricing cache
shuxueshuxue Apr 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 87 additions & 15 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ name: Deploy Staging
# Both update the staging apps to the target branch, then deploy.

on:
push:
branches:
- pr188-agent-optimize
pull_request:
types: [labeled]
workflow_dispatch:
Expand All @@ -23,43 +26,112 @@ jobs:
deploy-staging:
# For label trigger: only run when the label is exactly "deploy-staging"
if: >
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.label.name == 'deploy-staging')
runs-on: ubuntu-latest
env:
STAGING_STACK_UUID: fasbsube26s75ag6qus5bpi2

steps:
- name: Resolve target ref
id: ref
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "ref=${{ github.head_ref }}" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "push" ]; then
echo "ref=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
else
echo "ref=${{ inputs.ref }}" >> "$GITHUB_OUTPUT"
fi

- name: Update staging backend branch
- name: Check out target ref
uses: actions/checkout@v4
with:
ref: ${{ steps.ref.outputs.ref }}

- name: Resolve target commit
id: target
run: |
curl -s -X PATCH "${{ secrets.COOLIFY_URL }}/api/v1/applications/${{ secrets.COOLIFY_BACKEND_STAGING_UUID }}" \
-H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"git_branch": "${{ steps.ref.outputs.ref }}"}'
set -euo pipefail
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

- name: Assert repo staging compose contract
run: |
set -euo pipefail
grep -F "leon-home:/root/.leon" docker-compose.yml >/dev/null
grep -F "volumes:" docker-compose.yml >/dev/null

- name: Update staging frontend branch
- name: Update staging stack branch
run: |
curl -s -X PATCH "${{ secrets.COOLIFY_URL }}/api/v1/applications/${{ secrets.COOLIFY_FRONTEND_STAGING_UUID }}" \
set -euo pipefail
body="$(curl -sS --fail-with-body -X PATCH "${{ secrets.COOLIFY_URL }}/api/v1/applications/${STAGING_STACK_UUID}" \
-H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"git_branch": "${{ steps.ref.outputs.ref }}"}'
-d "{\"git_branch\": \"${{ steps.ref.outputs.ref }}\"}")"
echo "$body"
printf '%s' "$body" | jq -e --arg uuid "$STAGING_STACK_UUID" '.uuid == $uuid' >/dev/null

- name: Deploy staging stack
id: deploy
run: |
set -euo pipefail
body="$(curl -sS --fail-with-body "${{ secrets.COOLIFY_URL }}/api/v1/deploy?uuid=${STAGING_STACK_UUID}&force=false" \
-H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}")"
echo "$body"
printf '%s' "$body" | jq -e --arg uuid "$STAGING_STACK_UUID" '.deployments[0].resource_uuid == $uuid' >/dev/null
echo "deployment_uuid=$(printf '%s' "$body" | jq -r '.deployments[0].deployment_uuid')" >> "$GITHUB_OUTPUT"

- name: Wait for staging deployment
run: |
set -euo pipefail
deployment_uuid="${{ steps.deploy.outputs.deployment_uuid }}"
for _ in $(seq 1 60); do
body="$(curl -sS --fail-with-body "${{ secrets.COOLIFY_URL }}/api/v1/deployments/${deployment_uuid}" \
-H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}")"
status="$(printf '%s' "$body" | jq -r '.status')"
echo "deployment status: $status"
if [ "$status" = "finished" ]; then
exit 0
fi
if [ "$status" != "queued" ] && [ "$status" != "in_progress" ]; then
echo "$body"
exit 1
fi
sleep 10
done
echo "Timed out waiting for staging deployment ${deployment_uuid}"
exit 1

- name: Deploy backend to staging
- name: Verify Coolify staging contract
run: |
curl -sX GET "${{ secrets.COOLIFY_URL }}/api/v1/deploy?uuid=${{ secrets.COOLIFY_BACKEND_STAGING_UUID }}&force=false" \
-H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}"
set -euo pipefail
body="$(curl -sS --fail-with-body "${{ secrets.COOLIFY_URL }}/api/v1/applications/${STAGING_STACK_UUID}" \
-H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}")"
echo "$body" | jq '{uuid,git_branch,docker_compose_location}'
printf '%s' "$body" | jq -e --arg ref "${{ steps.ref.outputs.ref }}" '.git_branch == $ref' >/dev/null
printf '%s' "$body" | jq -e '.docker_compose_raw | contains("leon-home:/root/.leon")' >/dev/null
printf '%s' "$body" | jq -e --arg volume "${STAGING_STACK_UUID}_leon-home:/root/.leon" '.docker_compose | contains($volume)' >/dev/null
printf '%s' "$body" | jq -e --arg sha "${{ steps.target.outputs.sha }}" '.docker_compose | contains($sha)' >/dev/null

- name: Deploy frontend to staging
- name: Verify staging health contract
run: |
curl -sX GET "${{ secrets.COOLIFY_URL }}/api/v1/deploy?uuid=${{ secrets.COOLIFY_FRONTEND_STAGING_UUID }}&force=false" \
-H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}"
set -euo pipefail
for attempt in $(seq 1 18); do
status="$(curl -sS -o /tmp/staging-health.json -w '%{http_code}' "https://app.staging.mycel.nextmind.space/api/monitor/health")"
echo "health attempt ${attempt}: status=${status}"
if [ "$status" = "200" ]; then
body="$(cat /tmp/staging-health.json)"
echo "$body"
printf '%s' "$body" | jq -e '.db.path == "/root/.leon/sandbox.db"' >/dev/null
printf '%s' "$body" | jq -e '.db.exists == true' >/dev/null
exit 0
fi
cat /tmp/staging-health.json || true
sleep 10
done
echo "Staging health contract did not become ready in time"
exit 1

- name: Comment on PR with staging URL
if: github.event_name == 'pull_request'
Expand All @@ -70,5 +142,5 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 **预发部署已触发**\n\n- 前端: https://app.staging.mycel.nextmind.space\n- 后端: https://api.staging.mycel.nextmind.space\n\n分支: \`${{ steps.ref.outputs.ref }}\``
body: `🚀 **预发部署已触发**\n\n- 共享 Staging: https://app.staging.mycel.nextmind.space\n- API(同域反代): https://app.staging.mycel.nextmind.space/api\n\n分支: \`${{ steps.ref.outputs.ref }}\``
})
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Install dependencies (cached layer before source copy)
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project
# @@@sandbox-sdk-image-parity - shared staging/provider inventory should reflect runtime truth,
# not "SDK missing from image" accidents while config files are present.
RUN uv sync --frozen --no-dev --extra sandbox --extra e2b --extra daytona --no-install-project

# Copy source and install project
COPY . .
RUN uv sync --frozen --no-dev
RUN uv sync --frozen --no-dev --extra sandbox --extra e2b --extra daytona

ENV PATH="/app/.venv/bin:$PATH"

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,18 @@ Full-featured web platform for managing and interacting with agents:

### Multi-Agent Communication

Agents are first-class social entities. They can discover each other, send messages, and collaborate autonomously:
Agents are first-class social entities. They can list chats, read messages, send messages, and collaborate autonomously:

```
Member (template)
└→ Entity (social identity — agents and humans both get one)
└→ Thread (agent brain / conversation)
```

- **`chat_send`**: Agent A messages Agent B; B responds autonomously
- **`directory`**: Agents browse and discover other entities
- **`list_chats`**: List active conversations with unread counts and participants
- **`read_messages`**: Read message history before responding
- **`send_message`**: Agent A messages Agent B; B responds autonomously
- **`search_messages`**: Search message history across chats
- **Real-time delivery**: SSE-based chat with typing indicators and read receipts

Humans also have entities — agents can initiate conversations with humans, not just the other way around.
Expand Down
8 changes: 5 additions & 3 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,18 @@ cd frontend/app && npm run dev

### 多 Agent 通讯

Agent 是一等公民的社交实体,可以互相发现、发送消息、自主协作:
Agent 是一等公民的社交实体,可以列出对话、读取消息、发送消息、自主协作:

```
Member(模板)
└→ Entity(社交身份——Agent 和人类都有)
└→ Thread(Agent 大脑 / 对话)
```

- **`chat_send`**:Agent A 给 Agent B 发消息,B 自主回复
- **`directory`**:Agent 浏览和发现其他实体
- **`list_chats`**:列出活跃对话、未读数和参与者
- **`read_messages`**:先读取消息历史,再决定如何回复
- **`send_message`**:Agent A 给 Agent B 发消息,B 自主回复
- **`search_messages`**:跨对话搜索消息历史
- **实时投递**:基于 SSE 的聊天,支持输入提示和已读回执

人类也有 Entity——Agent 可以主动找人类对话,而不只是被动响应。
Expand Down
36 changes: 18 additions & 18 deletions backend/web/core/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
"""FastAPI dependency injection functions."""

import asyncio
import os
from typing import Annotated, Any

from fastapi import Depends, FastAPI, HTTPException, Request

from backend.web.services.agent_pool import get_or_create_agent, resolve_thread_sandbox
from sandbox.thread_context import set_current_thread_id

# Dev bypass: set LEON_DEV_SKIP_AUTH=1 to skip JWT verification and inject a mock identity.
# WARNING: this bypasses ALL auth — never set in production.
_DEV_SKIP_AUTH = os.environ.get("LEON_DEV_SKIP_AUTH", "").lower() in ("1", "true", "yes")
_DEV_PAYLOAD = {"user_id": "dev-user"}

if _DEV_SKIP_AUTH:
import logging as _logging

_logging.getLogger(__name__).warning(
"LEON_DEV_SKIP_AUTH is active — JWT auth is BYPASSED for all requests. This must never be enabled in production."
)


async def get_app(request: Request) -> FastAPI:
"""Get FastAPI app instance from request."""
Expand All @@ -36,9 +23,7 @@ def _get_auth_service(app: FastAPI):


def _extract_jwt_payload(request: Request) -> dict:
"""Extract and verify JWT payload from Bearer token. Returns {user_id}."""
if _DEV_SKIP_AUTH:
return _DEV_PAYLOAD
"""Extract and verify JWT payload from Bearer token. Returns {user_id, entity_id}."""
auth_header = request.headers.get("Authorization", "")
if not auth_header.startswith("Bearer "):
raise HTTPException(401, "Missing or invalid Authorization header")
Expand All @@ -52,14 +37,29 @@ def _extract_jwt_payload(request: Request) -> dict:
async def get_current_user_id(request: Request) -> str:
"""Extract user_id from JWT and verify user exists. Returns 401 if user was deleted (e.g. DB reset)."""
user_id = _extract_jwt_payload(request)["user_id"]
if _DEV_SKIP_AUTH:
return user_id
member_repo = getattr(request.app.state, "member_repo", None)
if member_repo and member_repo.get_by_id(user_id) is None:
raise HTTPException(401, "User no longer exists — please re-login")
return user_id


async def get_current_entity_id(request: Request) -> str:
"""Derive entity_id for the authenticated human user.

Supabase JWTs may omit custom entity claims, so keep the older
direct-claim path when present and otherwise derive the stable
human entity convention: f"{user_id}-1".
"""
payload = _extract_jwt_payload(request)
entity_id = payload.get("entity_id")
if entity_id:
return entity_id
user_id = payload.get("user_id")
if not user_id:
raise HTTPException(401, "Token missing user_id")
return f"{user_id}-1"


async def verify_thread_owner(
thread_id: str,
user_id: Annotated[str, Depends(get_current_user_id)],
Expand Down
Loading
Loading