Skip to main content

Module claude_code_executor

Module claude_code_executor 

Source
Expand description

ClaudeCodeExecutor: drives the official Claude Code CLI as a ChildExecutor (ExecutorSpec::ClaudeCode), sibling of subagent_worker. ClaudeCodeExecutor: a [ChildExecutor] that drives the official Claude Code CLI (claude) as an external sub-agent engine over its stream-json wire protocol. See docs/claude-code-executor.md for the full protocol reference (spawn flags, NDJSON frame table, permission relay, shutdown) this implementation follows.

MVP scope (issue #441): spawn a fresh claude process per run() call (one activation = one turn), map its stdout frames onto the same AgentEvents the real bamboo runtime emits (so the parent’s child preview renders identically — see BambooRuntimeExecutor), and relay can_use_tool permission asks through [EventSink::host] when a host bridge is wired. Mid-turn steering remains out of scope — see the doc comment on [ChildExecutor::run]’s steer parameter below.

Session resume (issue #444): RunSpec.messages empty/non-empty is the discriminant a reactivation ships (proto.rs:28). A non-empty shipment means this activation has prior context, resolved by [ClaudeCodeExecutor::run] in four steps — see its doc comment for the full state-machine and docs/claude-code-executor.md §4 for the on-disk state file shape.

Structs§

ClaudeCodeExecutor
Drives claude --output-format stream-json --input-format stream-json ... as the engine behind one sub-agent run.

Functions§

resolve_claude_code_state_dir
Resolve this actor’s stable per-child storage dir, exactly like BambooRuntimeExecutor::build (subagent_worker.rs:194-202): spec.storage_dir when the parent already isolated it, else a temp dir keyed by child_id — stable across activations of the SAME child. Both ExecutorSpec::ClaudeCode factory arms (subagent_worker.rs, broker_agent.rs) call this to give ClaudeCodeExecutor::new’s state_dir a location the resumed-session state file (issue #444) survives in.