/** * Continuation dispatch for stored agent handles. * * Owns the `agentId` leg of the runtime-action dispatch step: resolving a * model-supplied agentId against the session's handle store via * `prepareAgentContinuation`, delivering the follow-up message to the * address the running handle records, and resolving delivery failures as * dead (handle deleted) or retryable (handle restored to `parked`). */ import type { AgentAddress } from "#harness/handles/store.js"; import type { RuntimeActionRequest, RuntimeRemoteAgentCallActionRequest, RuntimeSubagentCallActionRequest, RuntimeSubagentDispatchFailure } from "#runtime/actions/types.js"; import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js"; import type { hydrateDurableSession } from "#execution/session.js"; /** Runtime action kinds that may address an agent handle via `agentId`. */ export type RuntimeAgentHandleAction = RuntimeRemoteAgentCallActionRequest | RuntimeSubagentCallActionRequest; /** Narrows an action to the kinds that may carry an `agentId` continuation. */ export declare function isAgentHandleAction(action: RuntimeActionRequest): action is RuntimeAgentHandleAction; /** Hydrated parent session snapshot threaded through dispatch. */ export type RuntimeSession = ReturnType; /** * Outcome of dispatching one planned runtime action: an adopted child ready * for the `subagent.called` emission tail, or a per-action error result. * Either way the (possibly updated) session snapshot rides along. * * `address` is the same confirmed {@link AgentAddress} recorded on the * child's running handle; consumers project it into wire shapes (e.g. the * flat `childSessionId` / `remote` fields of `subagent.called`) at the * emission site instead of this type re-encoding them. */ export type DispatchOutcome = { readonly address: AgentAddress; readonly callId: string; readonly kind: "called"; readonly name: string; readonly session: RuntimeSession; readonly toolName: string; } | { readonly kind: "error"; readonly result: RuntimeSubagentDispatchFailure; readonly session: RuntimeSession; }; /** * Delivers one `agentId` continuation to the child the handle names. * * Planning converts initially unknown ids into fresh starts, so an id that * matches no handle here disappeared mid-batch and reports * `AGENT_UNREACHABLE`. Name mismatches and busy handles report * `AGENT_MISMATCH` / `AGENT_BUSY` without touching the store. Delivery * failures report `AGENT_UNREACHABLE`: permanent ones resolve the handle as * dead, transient ones restore it to `parked` so the model can retry the * same agentId. */ export declare function dispatchToAgentHandle(input: { readonly action: RuntimeAgentHandleAction; readonly agentId: string; readonly bundle: CompiledBundle; readonly currentSession: RuntimeSession; readonly parentToken: string; readonly parentTurnId: string; }): Promise;