Skip to main content

Module task

Module task 

Source
Expand description

Daemon-owned task execution: task.run + background agent-loop orchestration (#2056, M1 control-plane cut line).

Why: wires the session/event layer to the existing engine (agent_loop/runner/tools/llm) so a task actually EXECUTES through the daemon and streams live tool/lifecycle events to attached clients — the keystone that closes the M1 control-plane cut line. What: task.run JSON-RPC method, background execution orchestration, the concrete SessionToolEventSink, and the offline “echo” mock LLM (TCODE_MOCK_LLM=echo) that makes the whole flow black-box testable without a live model. Test: task::executor::tests::*, task::protocol::tests::*, task::sink::tests::*, task::mock_llm::tests::*; API-driven end-to-end coverage in tests/task_e2e.rs. Daemon-owned task execution: task.run + background agent-loop orchestration (#2056, M1 control-plane cut line).

Why: this module is where a task.run (or a future session.send auto-trigger) call actually turns into a running PM -> engineer agent loop, streaming live tool_started/tool_finished/tool_error and session-lifecycle events (#2055) to any session.attached client (#2054), without blocking the triggering RPC. It is glue, not a fork: the engine itself (crate::agent_loop, crate::runner, crate::tools, crate::llm) is reused verbatim, extended (in #2056) with an optional tool-event sink and cancellation flag rather than duplicated. What: protocol::register wires the task.run JSON-RPC method; executor::spawn_task_run is the orchestration entry point it calls; sink::SessionToolEventSink is the concrete agent_loop::ToolEventSink forwarding to session::SessionRegistry::record_tool_*; mock_llm provides the offline-testable “echo” InferenceAdapter selected via TCODE_MOCK_LLM=echo so the whole flow is black-box testable without a live model. Test: task::executor::tests::*, task::protocol::tests::*, task::sink::tests::*, task::mock_llm::tests::*; the full flow end-to-end (a real subprocess) in tests/task_e2e.rs.

Re-exports§

pub use executor::TaskRunParams;
pub use executor::spawn_task_run;
pub use sink::SessionToolEventSink;
pub use todo_store::SessionTodoStore;

Modules§

executor
Daemon-owned background task execution (#2056): wires the session/event layer (#2054/#2055) to the existing engine (agent_loop/runner/tools/ llm) — the M1 control-plane cut line.
mock_llm
Deterministic, offline “echo” LLM client for #2056’s mandatory offline testability (no live model, no API key).
protocol
task.run JSON-RPC method (#2056, vision spec §4.3): start a session-driven task execution.
sink
Concrete ToolEventSink forwarding tool-dispatch hooks to SessionRegistry::record_tool_* (#2056).
todo_store
(#8235) The todo_write tool’s concrete TodoStore — writes a validated checklist onto one session’s roster row. Concrete TodoStore writing the todo_write tool’s list onto one session’s roster row (#8235).