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/lifecycle.rs; that path is NOT routed
through this runner’s spawn — what’s shared is the translator +
event shape, not the spawn function. (This used to cite a
SPEC_UNIFIED_AGENT_TYPES spec that no longer exists anywhere in
docs/; the pointer was dropped rather than replaced — see
scripts/check-spec-citations.sh.)
It DOES reuse this module’s commit-aware admission gate
(admit_spawn / agent_commit_reserve_gb, pub(crate)) — see
blockcontroller::shell::lifecycle::ShellController::start,
which calls them right before spawning a claude/codex/
gemini/qwen interactive pane, mirroring this file’s
run_agent gate.
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).
Enums§
- Agent
Error - Error returned by the runner.
Functions§
- 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.