import { StateStore } from '../state-store.js'; import { type ContentBlock } from '../types/messages.js'; import type { Usage } from '../models/streaming.js'; import type { z } from 'zod'; import type { JSONValue } from '../types/json.js'; import { Interrupt } from '../interrupt.js'; import type { MultiAgentInput } from './multiagent.js'; import type { Snapshot } from '../types/snapshot.js'; import { loadStateFromJSONSymbol, stateToJSONSymbol, type StateSerializable } from '../types/serializable.js'; /** * Execution lifecycle status shared across all multi-agent patterns. */ export declare const Status: { /** Execution has not yet started. */ readonly PENDING: "PENDING"; /** Execution is currently in progress. */ readonly EXECUTING: "EXECUTING"; /** Execution finished successfully. */ readonly COMPLETED: "COMPLETED"; /** Execution encountered an error. */ readonly FAILED: "FAILED"; /** Execution was cancelled before or during processing. */ readonly CANCELLED: "CANCELLED"; /** Execution paused awaiting an interrupt response; can be resumed. */ readonly INTERRUPTED: "INTERRUPTED"; }; /** * Union of all valid status values. */ export type Status = (typeof Status)[keyof typeof Status]; /** * Subset of {@link Status} valid for a {@link NodeResult}. */ export type ResultStatus = typeof Status.COMPLETED | typeof Status.FAILED | typeof Status.CANCELLED | typeof Status.INTERRUPTED; /** * Result of executing a single node. */ export declare class NodeResult { readonly type: "nodeResult"; readonly nodeId: string; readonly status: ResultStatus; /** Execution time in milliseconds. */ readonly duration: number; readonly content: ContentBlock[]; readonly error?: Error; /** Validated structured output, if a schema was provided. */ readonly structuredOutput?: z.output; /** Token usage from the node execution. */ readonly usage?: Usage; /** Interrupts raised by the underlying agent/orchestrator. Present iff `status === 'INTERRUPTED'`. */ readonly interrupts?: Interrupt[]; constructor(data: { nodeId: string; status: ResultStatus; duration: number; content?: ContentBlock[]; error?: Error; structuredOutput?: z.output; usage?: Usage; interrupts?: Interrupt[]; }); /** Serializes this result to a JSON-compatible value. */ toJSON(): JSONValue; /** Creates a NodeResult from a previously serialized JSON value. */ static fromJSON(data: JSONValue): NodeResult; } /** * Partial result returned by {@link Node.handle} implementations. * * Contains implementer-controlled fields that are merged with * framework-managed defaults (nodeId, status, duration, content) to * produce the final {@link NodeResult}. */ export type NodeResultUpdate = Partial>; /** * Execution state of a single node within a multi-agent orchestration. */ export declare class NodeState implements StateSerializable { readonly type: "nodeState"; status: Status; /** Whether this node is a terminal node — one where an execution path ended. */ terminus: boolean; /** Node execution start time in milliseconds since epoch. */ startTime: number; readonly results: NodeResult[]; /** Unanswered interrupts raised during this node's most recent run. Populated when `status === 'INTERRUPTED'`. */ interrupts: Interrupt[]; /** * Snapshot of the node's underlying runnable (Agent or nested orchestrator) captured * when the node returned INTERRUPTED. Loaded back into the runnable on resume so it * can pick up mid-execution without losing its interrupt bookkeeping. Cleared when * the node completes. */ interruptedSnapshot?: Snapshot; constructor(); /** Content from the most recent result, or empty array if none. */ get content(): readonly ContentBlock[]; /** Returns the serialized state as a JSON value. */ [stateToJSONSymbol](): JSONValue; /** Loads state from a previously serialized JSON value. */ [loadStateFromJSONSymbol](json: JSONValue): void; } /** * Aggregate result from a multi-agent execution. */ export declare class MultiAgentResult { readonly type: "multiAgentResult"; readonly status: ResultStatus; readonly results: NodeResult[]; /** Combined content from terminus nodes, in completion order. */ readonly content: ContentBlock[]; readonly duration: number; readonly error?: Error; /** Aggregated token usage across all node results. */ readonly usage: Usage; /** Interrupts aggregated across all node results. Present when any node ended INTERRUPTED. */ readonly interrupts?: Interrupt[]; constructor(data: { status?: ResultStatus; results: NodeResult[]; content?: ContentBlock[]; duration: number; error?: Error; interrupts?: Interrupt[]; }); /** Serializes this result to a JSON-compatible value. */ toJSON(): JSONValue; /** Creates a MultiAgentResult from a previously serialized JSON value. */ static fromJSON(data: JSONValue): MultiAgentResult; /** * Derives the aggregate status from individual node results. * * Precedence: FAILED \> INTERRUPTED \> CANCELLED \> COMPLETED. INTERRUPTED outranks * CANCELLED because parallel-graph short-circuit aborts siblings as CANCELLED when * one node interrupts — the actionable "resume me" signal should surface over the * collateral cancellations. */ private _resolveStatus; /** Sums token usage across all node results. */ private _aggregateNodeUsage; } /** * Per-execution state for multi-agent orchestration, created fresh each invocation. */ export declare class MultiAgentState implements StateSerializable { /** Execution start time in milliseconds since epoch. */ readonly startTime: number; /** Number of node executions started so far. */ steps: number; /** All node results in completion order. */ readonly results: NodeResult[]; /** App-level key-value state accessible from hooks, edge handlers, and custom nodes. */ readonly app: StateStore; /** * The invocation's input, carried through an interrupt pause so that resuming a * run (on the same instance, or via a SessionManager) can re-enter nodes that * never ran (hook-gated source/start nodes) with the original content. Cleared * when the invocation terminates in any non-INTERRUPTED state. * * @internal — not part of the public state shape; orchestrator-owned. */ _pendingInput?: MultiAgentInput; private readonly _nodes; constructor(data?: { nodeIds?: string[]; }); /** * Get the state of a specific node by ID. * * @param id - The node identifier * @returns The node's state, or undefined if the node is not tracked */ node(id: string): NodeState | undefined; /** * All tracked node states. */ get nodes(): ReadonlyMap; /** Returns the serialized state as a JSON value. */ [stateToJSONSymbol](): JSONValue; /** Loads state from a previously serialized JSON value. */ [loadStateFromJSONSymbol](json: JSONValue): void; } //# sourceMappingURL=state.d.ts.map