Skip to main content

Module adapter

Module adapter 

Source
Expand description

The second stage of the two-stage pipeline: SpawnerAdapter.

From the engine’s viewpoint there is only one trait, SpawnerAdapter; its spawn returns Box<dyn Worker> (see crate::worker::Worker). Worker shape is an implementation detail of each spawner; the engine only touches Workers through three operations — id() / cancel_token() / join().

The old WorkerAdapter trait and InProcWorker struct — which assumed a three-stage Spawner.spawn → WorkerAdapter → invoke pipeline — were removed on this turn. Nothing instantiated or dispatched them (dead code), and the multi-invocation path from was collapsed in the implementation anyway. The interface is now consolidated into the new trait Worker in src/worker.rs.

Structs§

InProcSpawner
agent-string → WorkerFn registry. The generic parameter W pins the per-kind Worker concrete type at the type level, so AgentBlock / Lua / RustFn each produce their own Worker type through InProcSpawner<W> and the type binding is preserved right up until SpawnerAdapter::spawn() erases the return as Box<dyn Worker>. W must be constructible from WorkerJoinHandler via From — i.e. a newtype that embeds the async-signal handle.
WorkerInvocation
Invocation context handed to a Worker fn. Bundles token + task_id + prompt + sink.
WorkerResult
The value a WorkerFn hands back on success, folded into an OutputEvent::Final by the spawner.

Enums§

SpawnError
Errors that can occur while SpawnerAdapter::spawn is setting up a worker, before the worker itself starts running.
WorkerError
Errors surfaced once a worker is running, via Worker::join.

Traits§

SpawnerAdapter
First stage of the two-stage pipeline: builds a Box<dyn Worker> for one attempt. Every concrete spawner (InProcSpawner, ProcessSpawner, the Operator spawner) implements this; the engine only ever holds a Arc<dyn SpawnerAdapter> and knows nothing about the Worker shape behind it.

Type Aliases§

WorkerFn
A registered agent implementation: takes a WorkerInvocation and resolves to a WorkerResult (or a WorkerError). Boxed as a type-erased Future so heterogeneous agent implementations (async fns, closures capturing state, etc.) can share one registry entry type.