Expand description
ProcessSpawner — a general-purpose SpawnerAdapter implementation
that spawns an arbitrary binary (or a one-line shell command) and
runs it as a worker. The thin path for wrapping an agent-block CLI,
an LLM CLI, a random binary, or a shell script as a worker.
Direct library integration with the agent-block-core SDK lives on
a separate axis, in
crate::worker::agent_block::AgentBlockInProcessSpawnerFactory: the SDK
is embedded in-process, and bus.emit("worker_result", ...) is
captured host-side. This spawner’s selling point is “call anything
over a shell”; it is not agent-block-specific, and the two paths
have fully separated responsibilities.
Naming convention: ProcessSpawner starts a shell process, and
AgentBlockInProcessSpawnerFactory provides direct integration
with the agent-block SDK. Older commits still reference an
“AgentBlockSpawner” — that was renamed to ProcessSpawner in the current design
(commit 8d1058f). See mini-app issue 96821965 for the full
rationale.
§Modes (two flavours)
plain mode (default):
- On
spawn, launch a child process withCommand::new(self.program)+args. - Write the directive to the child’s stdin (used as the prompt).
- Buffer the child’s stdout in full.
- Try to parse stdout as JSON; on failure wrap it as
{"raw": "<text>"}. ok = trueon exit code 0, otherwiseok = false.- Emit the
WorkerResultin parallel viaengine.submit_output(Final)(design intent).
streaming mode (.stream_mode(StreamMode::...)):
1-2. Same as plain mode.
3. Read the child’s stdout line by line through a BufReader
for NDJSON — or via a different protocol later.
4. Parse each chunk as an OutputEvent; skip failures.
5. engine.submit_output each successfully-parsed event
incrementally.
6. When OutputEvent::Final arrives, fold its {content, ok}
into the WorkerResult.
7. If EOF is hit without a Final, mark the outcome ok = false
(Blocked).
Only StreamMode::NdjsonLines ships today; SSE, length-prefixed,
and friends are carries for future turns.
Token metadata is also handed to the child as environment variables
so a worker can re-pull if it needs to. sig_hex is deliberately
not exported, to keep exposure minimal.
Structs§
- Process
Spawner - A
SpawnerAdapterthat runs a worker as an external OS process (a binary or ash -cone-liner). Configured with the builder methods below, then registered like any other spawner. - Process
Worker - Concrete Worker type for the Subprocess kind — the handle to a
child OS process’s
wait_with_output/ stream wait. Embeds aWorkerJoinHandlerto carry the async signal.
Enums§
- Stream
Mode - Wire protocol used to receive
OutputEvents from the child’s stdout.Nonemeans plain mode — the default — which buffers stdout in full and folds it into a singleFinal.