Expand description
Unified agent runner — one-shot Claude Code spawn for the drone Agent block.
Spawns claude --print --output-format=stream-json as a non-
interactive subprocess, drains its stdout through
ClaudeTranslator, forwards each AgentEvent on the caller’s
tx, and resolves the handle’s final_result with the
structured AgentRunResult once the stream emits Done.
Headless and one-shot by design — the drone Agent block’s
contract is “send task, wait for done, return result.” The
interactive agent pane has its own PTY-based controller in
blockcontroller/shell.rs; that path is NOT routed through
this runner (see docs/specs/SPEC_UNIFIED_AGENT_TYPES_2026_05_13.md
§4.2 — what’s shared is the translator + event shape, not the
spawn function).
Structs§
- Agent
RunHandle - Handle returned by
run_agent. The caller already holds thempsc::UnboundedReceiver<AgentEvent>they paired with thetxpassed intorun_agent; this handle adds the structured terminal value viafinal_result(drone Agent block’s downstream output) and theinstance_idof the backingdb_agent_instancesrow.
Enums§
- Agent
Error - Error returned by the runner.
Constants§
- DEFAULT_
CLAUDE_ 🔒BIN - ENV_
CLAUDE_ 🔒BIN - Override the default
claudebinary name. Set to a full path (or a different binary) for testing or non-PATH installs.
Functions§
- drain_
and_ 🔒collect - Drain
stdoutline-by-line throughClaudeTranslator, forward every emitted event ontx, accumulate the terminalCost/Doneevent payloads into anAgentRunResult, wait for the child to exit, and return the result. - drain_
async_ 🔒reader - Drain an arbitrary async reader of newline-delimited stream-json
frames, forward every emitted
AgentEventontx, and return an accumulator capturing the terminalCostandDonevalues. - run_
agent - Spawn
claude --print --output-format=stream-jsonper the givenAgentTaskandAgentRef, drain its stdout through the sharedClaudeTranslator, forward eachAgentEventontx, and resolve the returned handle’sfinal_resultwith anAgentRunResultconstructed from the terminal Cost + Done events. - run_
agent_ 🔒with_ bin - Internal entry point — same as
run_agentbut takes theclaudebinary path explicitly. Lets tests inject a known-nonexistent path to exercise the spawn-failure path without touching env vars (Rust 1.81+ flagsstd::env::set_varas unsound under concurrent test execution). The publicrun_agentis a thin shim that resolves the binary from$AGENTMUX_CLAUDE_BINor the default.