import { HookableEvent, StreamEvent } from '../hooks/events.js'; import type { AgentStreamEvent, InvocationState } from '../types/agent.js'; import type { MultiAgentResult, MultiAgentState, NodeResult } from './state.js'; import type { MultiAgent } from './multiagent.js'; import type { NodeType } from './nodes.js'; import type { Interruptible } from '../interrupt.js'; import type { InterruptParams } from '../types/interrupt.js'; import type { JSONValue } from '../types/json.js'; /** * Event triggered when a multi-agent orchestrator has finished initialization. */ export declare class MultiAgentInitializedEvent extends HookableEvent { readonly type: "multiAgentInitializedEvent"; readonly orchestrator: MultiAgent; constructor(data: { orchestrator: MultiAgent; }); toJSON(): Pick; } /** * Event triggered before orchestrator execution starts. */ export declare class BeforeMultiAgentInvocationEvent extends HookableEvent { readonly type: "beforeMultiAgentInvocationEvent"; readonly orchestrator: MultiAgent; readonly state: MultiAgentState; readonly invocationState: InvocationState; constructor(data: { orchestrator: MultiAgent; state: MultiAgentState; invocationState: InvocationState; }); toJSON(): Pick; } /** * Event triggered after orchestrator execution completes. */ export declare class AfterMultiAgentInvocationEvent extends HookableEvent { readonly type: "afterMultiAgentInvocationEvent"; readonly orchestrator: MultiAgent; readonly state: MultiAgentState; readonly invocationState: InvocationState; constructor(data: { orchestrator: MultiAgent; state: MultiAgentState; invocationState: InvocationState; }); _shouldReverseCallbacks(): boolean; toJSON(): Pick; } /** * Event triggered before a node begins execution. * Hook callbacks can set {@link cancel} to prevent the node from executing. */ export declare class BeforeNodeCallEvent extends HookableEvent implements Interruptible { readonly type: "beforeNodeCallEvent"; readonly orchestrator: MultiAgent; readonly state: MultiAgentState; readonly nodeId: string; readonly invocationState: InvocationState; /** * Set by hook callbacks to cancel node execution. * When set to `true`, a default cancel message is used. * When set to a string, that string is used as the cancel message. */ cancel: boolean | string; constructor(data: { orchestrator: MultiAgent; state: MultiAgentState; nodeId: string; invocationState: InvocationState; }); /** * Raises an orchestrator-level interrupt that pauses the run before this node * executes. If a prior resume has answered the interrupt, returns the response; * otherwise throws an `InterruptError` and the orchestrator produces an * INTERRUPTED result with the pending interrupt. * * The interrupt is stored on the target node's `NodeState.interrupts`, so resume * via `InterruptResponseContent[]` routes through the same machinery as child- * agent interrupts. */ interrupt(params: InterruptParams): T; toJSON(): Pick; } /** * Event triggered after a node completes execution. */ export declare class AfterNodeCallEvent extends HookableEvent { readonly type: "afterNodeCallEvent"; readonly orchestrator: MultiAgent; readonly state: MultiAgentState; readonly nodeId: string; readonly invocationState: InvocationState; readonly error?: Error; constructor(data: { orchestrator: MultiAgent; state: MultiAgentState; nodeId: string; invocationState: InvocationState; error?: Error; }); _shouldReverseCallbacks(): boolean; toJSON(): Pick & { error?: { message?: string; }; }; } /** * Tagged inner event from a node, discriminated by {@link source}. * * Use `inner.source` to determine the event origin, then `inner.event` * to access the underlying event and switch on its `type`. * * Sources: * - `'agent'` — the node wraps an {@link Agent} instance. The event is an * {@link AgentStreamEvent} and can be narrowed via `event.type`. * - `'multiAgent'` — the node wraps a nested orchestrator (e.g. {@link Graph} * or {@link Swarm}). The event is a {@link MultiAgentStreamEvent} (excluding * {@link NodeStreamUpdateEvent}, which passes through directly). * - `'custom'` — the node wraps an {@link InvokableAgent} that is not an * {@link Agent} instance (e.g. {@link A2AAgent} or a third-party implementation). * The event is a {@link StreamEvent} with no further type narrowing available. */ export type NodeStreamUpdateInnerEvent = { readonly source: 'agent'; readonly event: AgentStreamEvent; } | { readonly source: 'multiAgent'; readonly event: Exclude; } | { readonly source: 'custom'; readonly event: StreamEvent; }; /** * Wraps an inner streaming event from a node with the node's identity. * Emitted during node execution to propagate agent-level or nested * multi-agent events up to the orchestration layer. */ export declare class NodeStreamUpdateEvent extends HookableEvent { readonly type: "nodeStreamUpdateEvent"; readonly nodeId: string; readonly nodeType: NodeType; readonly state: MultiAgentState; readonly inner: NodeStreamUpdateInnerEvent; readonly invocationState: InvocationState; constructor(data: { nodeId: string; nodeType: NodeType; state: MultiAgentState; inner: NodeStreamUpdateInnerEvent; invocationState: InvocationState; }); toJSON(): Pick; } /** * Event triggered when a node finishes execution. * Wraps the {@link NodeResult} for the completed node. */ export declare class NodeResultEvent extends HookableEvent { readonly type: "nodeResultEvent"; readonly nodeId: string; readonly nodeType: NodeType; readonly state: MultiAgentState; readonly result: NodeResult; readonly invocationState: InvocationState; constructor(data: { nodeId: string; nodeType: NodeType; state: MultiAgentState; result: NodeResult; invocationState: InvocationState; }); toJSON(): Pick; } /** * Event triggered when execution transitions between nodes. */ export declare class MultiAgentHandoffEvent extends HookableEvent { readonly type: "multiAgentHandoffEvent"; readonly source: string; readonly targets: string[]; readonly state: MultiAgentState; readonly invocationState: InvocationState; constructor(data: { source: string; targets: string[]; state: MultiAgentState; invocationState: InvocationState; }); toJSON(): Pick; } /** * Event triggered when a node is cancelled via {@link BeforeNodeCallEvent.cancel}. */ export declare class NodeCancelEvent extends HookableEvent { readonly type: "nodeCancelEvent"; readonly nodeId: string; readonly state: MultiAgentState; readonly message: string; readonly invocationState: InvocationState; constructor(data: { nodeId: string; state: MultiAgentState; message: string; invocationState: InvocationState; }); toJSON(): Pick; } /** * Event triggered as the final event in the multi-agent stream. * Wraps the {@link MultiAgentResult} containing the aggregate outcome. */ export declare class MultiAgentResultEvent extends HookableEvent { readonly type: "multiAgentResultEvent"; readonly result: MultiAgentResult; readonly invocationState: InvocationState; constructor(data: { result: MultiAgentResult; invocationState: InvocationState; }); toJSON(): Pick; } /** * Union of all multi-agent streaming events. */ export type MultiAgentStreamEvent = BeforeMultiAgentInvocationEvent | AfterMultiAgentInvocationEvent | BeforeNodeCallEvent | AfterNodeCallEvent | NodeStreamUpdateEvent | NodeResultEvent | NodeCancelEvent | MultiAgentHandoffEvent | MultiAgentResultEvent; //# sourceMappingURL=events.d.ts.map