feat(daemon): wire agent.run/stop/send/attach RPCs with process spawn + event stream#34
Open
Codename-11 wants to merge 1 commit into
Open
feat(daemon): wire agent.run/stop/send/attach RPCs with process spawn + event stream#34Codename-11 wants to merge 1 commit into
Codename-11 wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentRuntimeinpackages/daemon/src/agent-runtime.tsthat spawns child processes, tracks status (starting→running→completed/failed/stopped), publishes events via theHubon topicagent:<id>, and persists them to theagent_eventstable with(epoch, seq)cursor.agent.run/agent.stop/agent.sendhandlers with real runtime calls, and adds a newagent.attachRPC that returns persisted events (supportssinceEpoch/sinceSeq/limitfor replay).packages/daemon/src/terminal-frame.ts.client.agents.attach(agentId, { onEvent, onTerminal }), per-agent terminal handler map,AgentAttachParams/AgentAttachResult/AgentEventPayloadschemas, andMethods.agent_attach._echoprofile 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 --noEmitpasses for bothpackages/daemonandpackages/client(pre-existingrootDirnoise from@axiom-labs/arc-coreimports 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 cleanlyagent.attach replays persisted events after exitagent.stop terminates a long-running processARC_DIR, spawned_echoagent viaagent.run({ profile: "_echo", prompt: "hello" }), subscribed viaagent.attach, waited forexitevent, confirmed terminal bytes carry the echoed prompt and final DB status iscompleted.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Generated with Claude Code