/** * The AWAY lane — one unattended turn, in two faces. * * `run()` is the one a host calls: a task in, a {@link Turn} out (the id to hand * a person, the events to watch, and the same `TurnResult` a chat turn answers * with). {@link awayRunner} is the same turn behind core's `AgentRunner` seam * (01-core §13), for the automations engine and the delegation tool that already * speak `AgentRunReport`. ONE implementation — `runTurn` in ./turn.ts, shared * with the chat lane; the faces differ only in the ctx they name and the shape * they answer in. * * An away turn is a `RunContext` at venue "automation" and presence "away" (an * engine firing carries its trigger's id too — the guard's away-grant lookup * matches on it), the sponsor's durable workspace mounted, and the caller's * guard-bound registry as the whole tool surface. Everything else — the audit * row, the transcript, the view channel — is the runtime's and the guard's, * inherited rather than rebuilt. * * `AgentRunReport`'s `summary` is the one narrowing left in this file: it is * rendered VERBATIM in the automations panel's run row, so it is a reading * budget. `TurnResult.text` — what `run()` answers with — is the whole reply. */ import { type AgentRunner, type Json } from "../core/index.js"; import type { FlexibleSchema } from "ai"; import { type AgentDeps, type TurnDeps, type Turn } from "./turn.js"; /** The composition an away turn runs on — a turn's composition, under the name * the `AgentRunner` seam already exports. */ export type AwayRunnerDeps = TurnDeps; export interface RunOptions { /** Whose run this is — the subject every grant, workspace and audit row is * scoped to. Unset, the agent runs as itself. * @deprecated Name the person ONCE — `agent.forUser(subject)` — rather than * on every call, and their turns, conversations and memories come with them. * Still honored: a run that passes it behaves exactly as it always has. */ as?: string; /** Server-trust identity facts, model-visible (`[User]`). */ user?: Record; /** Guard/tools context. */ context?: Record; /** A schema for the answer. The run gets one extra tool to report through, so * the typed result costs no second model call. */ output?: FlexibleSchema; maxToolCalls?: number; signal?: AbortSignal; /** Continue a conversation this subject already owns, instead of a fresh one. */ threadId?: string; } /** * `agent.run(task)` — one unattended turn, for code rather than a screen. * * Returned rather than awaited so the ids are readable immediately (show the * thread, or hand it back as `run({ threadId })`) and `events` can be read while * the run is still going. Cancellation is the `signal` the caller passes. * * Every ask PARKS — nobody is there to tap — so a run that needed consent * answers `interrupted`, with the cards on it and `resume()` to carry on. */ export declare function startRun(deps: AgentDeps, task: string, options?: RunOptions): Turn; /** * The same turn behind core's `AgentRunner` seam (01-core §13) — the shape the * automations engine and the delegation tool already speak. Prefer * {@link startRun} (`agent.run`) for anything new: it is this turn with the ids, * the live events, the usage, the typed output and the interruptions attached. * * `AgentComposition` (what `agentComposition(agent)` returns) satisfies these deps * structurally, so a host that already built an `agent()` can hand its composition * straight in. */ export declare function awayRunner(deps: AwayRunnerDeps): AgentRunner;