Skip to content

feat: daemon + agent presence/control (P1-P5 Chorus borrow)#54

Open
Vincentwei1021 wants to merge 48 commits into
mainfrom
feat/agent-connection-registry
Open

feat: daemon + agent presence/control (P1-P5 Chorus borrow)#54
Vincentwei1021 wants to merge 48 commits into
mainfrom
feat/agent-connection-registry

Conversation

@Vincentwei1021

Copy link
Copy Markdown
Owner

Summary

Borrows Chorus's daemon + agent-presence/control features into Synapse, mapped onto Synapse's experiment-centric model. Five phases, all on this branch (47 commits). Lets the frontend wake a local Claude Code, observe live agent connections, and control running turns — all over the existing notification/SSE infrastructure (no new realtime channel).

Phases

P1 — Connection registry & presence data layer. In-memory (agentUuid, host, cwd) registry with online/offline liveness; POST /api/agent-connections/heartbeat (agent) + GET /api/agent-connections (owner-scoped, user); "current executions" reuse Experiment.liveStatus; OpenClaw plugin reports heartbeats.

P2 — synapse daemon. New @synapse-research/synapse-daemon package, bundled into the @synapse-research/synapse CLI as synapse daemon (one-step install). Connects over SSE, and on experiment assignment drives a persistent per-experiment Claude Code conversation (per-turn claude -p --session-id/--resume; conversation persists in claude's own session). Safe-by-default tool posture (--allowedTools mcp__synapse --permission-mode dontAsk; --yolo opt-in). A connected claude_code agent is treated as realtime (dynamic, connection-aware).

P3 — Presence & execution observation UI. @mention online dot + active/idle count; shell-level AgentPresenceProvider (single 15s poll); sidebar "N agents online" pill + popover; ExecutionRow deep-linking to the experiment panel; a Connections section in the /agents detail panel.

P4 — Reverse control + in-experiment instruction injection. From the experiment panel: inject a free-text instruction (writes an audit comment + sends an experiment_instruction notification → daemon resumes the session) and interrupt a running turn (experiment_interrupt → daemon kills the in-flight child via a per-experiment ChildRegistry). User-only routes; recipient derived server-side from the experiment's assignee.

P5 — Session anchoring & human takeover. Session id = experimentUuid (already anchored in P2); panel "Copy session ID" so a human can claude --resume <uuid> in the origin cwd.

Verification

  • Unit tests across all phases pass (services, routes, daemon package); daemon pnpm build clean.
  • Lint: 0 errors in changed files. i18n: en/zh parity for new presence + control sections.
  • End-to-end smoke against a real DB-backed server + real daemon (PGlite-backed branch dev server, real synapse daemon over real SSE): instruction injection → resume turn, second instruction → --resume, audit comment + notifications persisted, interrupt → in-flight child SIGTERM-killed (exit 143) with the daemon surviving.

Release surface (do NOT release yet — this PR is for review)

When released: publish new pkg @synapse-research/synapse-daemon, bump @synapse-research/synapse CLI, rebuild Docker :latest. OpenClaw plugin: only the P1 heartbeat reporter changed. (Holding per request — not releasing.)

🤖 Generated with Claude Code

Wei Yihao and others added 30 commits June 28, 2026 15:42
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The listConnections function was pruning offline records before applying
the agentUuids filter, causing offline records belonging to agents
outside the filter to be deleted from the shared store. Reordered the
guards so agentUuids filter is checked first, ensuring pruning only
affects records that would actually be returned.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-turn race

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…p-dir cleanup

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wei Yihao and others added 18 commits June 28, 2026 18:28
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…per, color cleanup

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant