Skip to content

feat(daemon): wire agent.run/stop/send/attach RPCs with process spawn + event stream#34

Open
Codename-11 wants to merge 1 commit into
feature/v3-foundationfrom
feature/daemon-agent-lifecycle
Open

feat(daemon): wire agent.run/stop/send/attach RPCs with process spawn + event stream#34
Codename-11 wants to merge 1 commit into
feature/v3-foundationfrom
feature/daemon-agent-lifecycle

Conversation

@Codename-11
Copy link
Copy Markdown
Owner

Summary

  • Implements AgentRuntime in packages/daemon/src/agent-runtime.ts that spawns child processes, tracks status (startingrunningcompleted/failed/stopped), publishes events via the Hub on topic agent:<id>, and persists them to the agent_events table with (epoch, seq) cursor.
  • Replaces stubbed agent.run / agent.stop / agent.send handlers with real runtime calls, and adds a new agent.attach RPC that returns persisted events (supports sinceEpoch / sinceSeq / limit for replay).
  • Frames channel-1 terminal bytes with a 36-byte agent UUID prefix so the client can route multiplexed streams. Codec is shared via packages/daemon/src/terminal-frame.ts.
  • Extends the client SDK with client.agents.attach(agentId, { onEvent, onTerminal }), per-agent terminal handler map, AgentAttachParams / AgentAttachResult / AgentEventPayload schemas, and Methods.agent_attach.
  • Ships a minimal internal _echo profile that spawns a Node one-liner echoing stdin → stdout so tests + smoke scripts can exercise the pipe without a real adapter wired yet.

Test plan

  • npx tsc --noEmit passes for both packages/daemon and packages/client (pre-existing rootDir noise from @axiom-labs/arc-core imports is unrelated to this change).
  • npx vitest run packages/daemon/tests/agent-lifecycle.test.ts packages/daemon/tests/daemon.test.ts — 7/7 pass:
    • runs, streams terminal bytes, persists events, and exits cleanly
    • agent.attach replays persisted events after exit
    • agent.stop terminates a long-running process
    • plus the 4 pre-existing daemon/client tests.
  • E2E smoke: started daemon in tmp ARC_DIR, spawned _echo agent via agent.run({ profile: "_echo", prompt: "hello" }), subscribed via agent.attach, waited for exit event, confirmed terminal bytes carry the echoed prompt and final DB status is completed.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Generated with Claude Code

…ent stream

- Add AgentRuntime (packages/daemon/src/agent-runtime.ts): spawns child
  processes, tracks status transitions (starting -> running -> completed/
  failed/stopped), emits events into the Hub (topic agent:<id>) and
  persists them to the agent_events table with (epoch, seq) cursor.
- Replace stub agent.run/stop/send handlers with real AgentRuntime calls
  and add new agent.attach RPC that returns the persisted event history
  (with optional sinceEpoch/sinceSeq/limit cursor).
- Frame terminal bytes on channel 1 with a 36-byte agent UUID prefix
  so multiplexed terminal streams are routable client-side. Shared
  codec lives in packages/daemon/src/terminal-frame.ts.
- Extend the client SDK with client.agents.attach(agentId, handlers),
  per-agent terminal routing, AgentAttachParams / AgentAttachResult /
  AgentEventPayload schemas, and Methods.agent_attach.
- Internal "_echo" test profile spawns a node one-liner that echoes
  stdin so tests + smoke scripts can exercise the pipe without a real
  adapter wired yet.
- New tests/agent-lifecycle.test.ts covers spawn + terminal bytes +
  event replay + agent.stop. Existing daemon.test.ts still passes.

Co-Authored-By: Claude Opus 4.7 (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