pub async fn build(
resolved: &ResolvedModel,
args: &Args,
cwd: &Path,
project_trusted: bool,
) -> Result<(AgentHarness, Receiver<AgentEvent>, ReloadContext), BuildError>Expand description
Build the AgentHarness from the resolved model + parsed args + cwd.
This is the v1 equivalent of TS createAgentSession. It:
- Builds the
OsExecutionEnvrooted atcwd. - Constructs the built-in tools (optionally filtered by
--tools/--exclude-tools/--no-tools/--no-builtin-tools). - Resolves the session storage (ephemeral vs fresh JSONL vs restore-error).
- Assembles
AgentHarnessOptionsand callsAgentHarness::create.
Returns the harness plus a broadcast::Receiver<AgentEvent> carrying the
live AgentEvent stream from every run (backed by a BroadcastEmitter
installed on the harness). Interactive mode drains this to render streaming
responses; the non-interactive modes simply drop it.
Returns the harness, the live AgentEvent broadcast receiver, and a
ReloadContext the interactive TUI holds to drive /reload (and a
plugin’s runtime_action(Reload) via the mailbox). Non-interactive modes
drop the context (no /reload surface in print/json mode).