import type { SessionAuthContext } from "#channel/types.js"; import { type ChannelAdapter, type ChannelAdapterContext } from "#channel/adapter.js"; import { type LocalDevRequestProvenance } from "#context/keys.js"; import { ContextContainer } from "#context/container.js"; import { type CompiledBundle } from "#runtime/sessions/runtime-context-keys.js"; import type { HarnessSessionBase } from "#harness/types.js"; import type { RuntimeActionResult, RuntimeWorkflowTaskRequest } from "#shared/action-types.js"; import type { SessionParent, SessionTraceRoot } from "#channel/types.js"; import { type DurableSessionState, readDurableSession } from "#execution/durable-session-store.js"; import { buildSubagentRunInput } from "#subagents/tool.js"; import type { WorkflowToolRunOwner } from "#execution/tools/workflow/messages.js"; import type { DynamicSubagentSelections } from "#execution/agent-sessions/target.js"; import type { WorkflowAgentMetadata } from "#tools/workflow-definition.js"; /** Input shared by direct and Workflow-originated owner-side dispatch. */ export interface CoordinationDispatchInput { readonly workflowToolRunOwner: WorkflowToolRunOwner; readonly sessionWritable: WritableStream; readonly serializedContext: Record; readonly sessionState: DurableSessionState; } /** Owner-side results and the updated context and session. */ export interface CoordinationDispatchResult { readonly results: readonly RuntimeActionResult[]; readonly serializedContext: Record; readonly sessionState: DurableSessionState; } /** Everything preflight produces before either step's dispatch loop runs. */ export interface PreparedCoordinationDispatch { readonly adapter: ChannelAdapter; readonly adapterCtx: ChannelAdapterContext; readonly auth: Parameters[0]["auth"]; readonly batch: DispatchBatch; readonly bundle: CompiledBundle; readonly capabilities: Parameters[0]["capabilities"]; readonly channelMetadata: Parameters[0]["channelMetadata"]; readonly dynamicSubagentSelections: DynamicSubagentSelections; readonly inheritedConversation: Parameters[0]["inheritedConversation"]; readonly initiatorAuth: Parameters[0]["initiatorAuth"]; /** Inherited originating-client metadata for the dev-TUI hint. */ readonly localDevRequest?: LocalDevRequestProvenance; /** Lineage of the session running this dispatch, when it is itself a delegated child. */ readonly parentSession: SessionParent | undefined; readonly sandboxSessionId: string; readonly serializedContext: Record; readonly plan: readonly PlanEntry[]; readonly session: HarnessSessionBase; readonly sessionState: DurableSessionState; /** Trace root that this session's local children inherit, when it isn't the lineage root. */ readonly traceRoot?: SessionTraceRoot; readonly workflowAgents: Readonly>; } /** * Runs every dispatch precondition that may throw — durable reads, context * deserialization, handle-store validation, and batch planning — before * the caller acquires the parent stream writer, so a preflight failure * never leaks the writer lock. Returns undefined when no actions are * pending. */ export declare function prepareCoordinationDispatch(input: { readonly serializedContext: Record; readonly sessionState: DurableSessionState; }): Promise; interface DispatchBatch { readonly approvers?: Readonly>; readonly event: { readonly sequence: number; readonly stepIndex: number; readonly turnId: string; }; readonly requests: readonly { readonly callId: string; }[]; } export declare function prepareActionDispatch(input: { readonly batch: DispatchBatch; readonly ctx: ContextContainer; readonly durableSession: Awaited>; readonly plan: (input: { readonly bundle: CompiledBundle; readonly ctx: ContextContainer; readonly requests: DispatchBatch["requests"]; readonly session: HarnessSessionBase; }) => readonly PlanEntry[]; readonly serializedContext: Record; }): Promise, "sessionState">>; export {};