/** Every value `workflow.run.status` can hold — scheduler outcomes plus the * transitional control states (`pausing` / `cancelling`). */ type WorkflowRunStatus = "awaiting_input" | "cancelled" | "cancelling" | "completed" | "errored" | "failed" | "interrupted" | "paused" | "pausing" | "pending" | "running"; /** Finished forever — no resume, no recovery. */ declare const TERMINAL_RUN_STATUSES: ReadonlySet; /** The scheduler is (or is about to be) making progress. */ declare const ACTIVE_RUN_STATUSES: ReadonlySet; /** What an agent-family step is DOING right now, carried as the `delta` * of a `node_stream` frame with `kind: "phase"`. CLOSED: the server folds * every label onto this set before it reaches the wire, so a renderer may * switch exhaustively. An unrecognised string is still possible (the server * passes an unmapped label through and logs it) — render it verbatim. */ type AgentStepPhase = "complete" | "finalizing" | "preparing" | "reasoning" | "retrying" | "streaming" | "tool"; /** The same set, ordered as a healthy step walks it. */ declare const AGENT_STEP_PHASES: readonly AgentStepPhase[]; interface RunStartedEvent { ts: string; event: "run_started"; run_id: string; thread_id: string; definition_id: string; definition_hash: string; reason: "server_restart" | null; restarted_node_ids: string[]; } interface NodeStartedEvent { ts: string; event: "node_started"; run_id: string; step: number; node_id: string; spec_type: string; attempt: number; dispatch_id?: string; item_index?: number; invocation_count?: number; inputs: Record; output_kind: null | string; } interface WithheldValue { path: (number | string)[]; value_type: "boolean" | "list" | "null" | "number" | "object" | "text" | "unknown"; bytes: number; items?: null | number; chars?: null | number; ref?: null | string; } interface NodeCompletedEvent { ts: string; event: "node_completed"; run_id: string; step: number; node_id: string; spec_type: string; attempt: number; dispatch_id?: string; item_index?: number; invocation_count?: number; duration_ms: number; output: Record; output_kind: null | string; output_kind_ok: boolean | null; output_kind_errors: null | string[]; output_kind_version: null | number; output_kind_degraded: null | string; metadata: Record | null; wrapper: Record | null; source: "executor" | "reused" | null; reused_from: Record | null; withheld: WithheldValue[] | null; withheld_more: null | number; } interface NodeSkippedEvent { ts: string; event: "node_skipped"; run_id: string; step: number; node_id: string; spec_type: string; attempt: number; dispatch_id?: string; item_index?: number; invocation_count?: number; output: Record; source: "executor" | "mocked" | "retry" | "reused" | "user_manual" | "user_skip" | null; reason: null | string; sampled: boolean; } interface NodeFailedEvent { ts: string; event: "node_failed"; run_id: string; step: number; node_id: string; spec_type: string; attempt: number; dispatch_id?: string; item_index?: number; invocation_count?: number; error_type: string; error_message: string; error: Record | null; wrapper: Record | null; } interface NodeRetryScheduledEvent { ts: string; event: "node_retry_scheduled"; run_id: string; step: number; node_id: string; spec_type: string; attempt: number; dispatch_id?: string; item_index?: number; invocation_count?: number; next_attempt: number; delay_ms: number; error_type: string; error_message: string; } interface NodeProgressEvent { ts: string; event: "node_progress"; run_id: string; step: number; node_id: string; attempt: number; dispatch_id?: string; item_index?: number; message: string; fraction: null | number; current: null | number; total: null | number; } interface CheckpointSavedEvent { ts: string; event: "checkpoint_saved"; run_id: string; checkpoint_id: string; step: number; parent_checkpoint_id: null | string; } interface RunInterruptedEvent { ts: string; event: "run_interrupted"; run_id: string; node_id: string; payload: Record; checkpoint_id: null | string; } type RunStatus = "awaiting_input" | "cancelled" | "completed" | "errored" | "failed" | "interrupted" | "paused" | "pending" | "running"; interface RunCompletedEvent { ts: string; event: "run_completed"; run_id: string; status: RunStatus; steps_executed: number; last_outputs: Record; channel_values: Record; stopped: Record | null; } interface RunFailedEvent { ts: string; event: "run_failed"; run_id: string; status: RunStatus; steps_executed: number; error_type: string; error_message: string; } interface RunCancelledEvent { ts: string; event: "run_cancelled"; run_id: string; status: RunStatus; steps_executed: number; reason: "candidate_stopped" | "graceful" | "immediate"; } interface RunPausedEvent { ts: string; event: "run_paused"; run_id: string; status: RunStatus; steps_executed: number; checkpoint_id: null | string; } interface RunResumedEvent { ts: string; event: "run_resumed"; run_id: string; from_checkpoint_id: string; mode: "interrupt" | "pause" | "retry" | "user_manual" | "user_skip"; reason: "server_restart" | null; restarted_node_ids: string[]; } interface RunErroredEvent { ts: string; event: "run_errored"; run_id: string; status: RunStatus; steps_executed: number; node_id: string; step: number; attempt: number; error_type: string; error_message: string; checkpoint_id: null | string; } interface NodeEmittedEvent { ts: string; event: "node_emitted"; run_id: string; step: number; node_id: string; dispatch_id?: string; item_index?: number; attempt: number; mode: "confirmation" | "full" | "restructured" | "summary"; payload: Record; withheld: WithheldValue[] | null; withheld_more: null | number; component_ref: null | string; surface: string; title: null | string; presentation: "panel" | "showcase"; kind: null | string; kind_ok: boolean | null; metadata: Record | null; empty_values: string[]; empty_notice: null | string; } interface NodeCostEvent { ts: string; event: "node_cost"; run_id: string; step: number; node_id: string; spec_type: null | string; attempt: number; dispatch_id?: string; item_index?: number; cost_usd: number; input_tokens: number; output_tokens: number; total_tokens: number; cached_input_tokens: number; cache_write_tokens: number; model: null | string; models: string[]; conversation_id: null | string; request_id: null | string; interrupted: boolean; } interface WorkSetProgressEvent { ts: string; event: "work_set_progress"; run_id: string; step: number; node_id: string; set_name: string; wave: number; dispatched: number; pending: number; in_progress: number; succeeded: number; failed: number; dead_letter: number; discovered: number; done: boolean; } interface SubgraphRunLinkedEvent { ts: string; event: "subgraph_run_linked"; run_id: string; step: number; node_id: string; dispatch_id?: string; item_index?: number; child_run_id: string; child_definition_id: string; child_definition_name: null | string; reattached: boolean; child_status: string; } /** The durable scheduler events — recorded in wf_node_events and replayed * on reconnect via the per-run `seq` cursor. */ type WorkflowRunEvent = CheckpointSavedEvent | NodeCompletedEvent | NodeCostEvent | NodeEmittedEvent | NodeFailedEvent | NodeProgressEvent | NodeRetryScheduledEvent | NodeSkippedEvent | NodeStartedEvent | RunCancelledEvent | RunCompletedEvent | RunErroredEvent | RunFailedEvent | RunInterruptedEvent | RunPausedEvent | RunResumedEvent | RunStartedEvent | SubgraphRunLinkedEvent | WorkSetProgressEvent; declare function isWorkflowRunEvent(value: unknown): value is WorkflowRunEvent; interface NodeStreamEvent { event: "node_stream"; run_id: string; node_id: null | string; dispatch_id?: string; item_index?: number; kind: "chunk" | "context_analysis" | "media" | "phase" | "reasoning" | "record_update" | "render_block" | "resource_changed" | "tool" | "warning"; delta: string; stream_seq: number; ts: string; chunks_received: number; chars_streamed: number; frame_id?: null | string; frame_index?: number; frame_count?: number; block_shadowed?: boolean; } declare function isNodeStreamEvent(value: unknown): value is NodeStreamEvent; interface WorkflowRunStartedEvent { [key: string]: unknown; event: "workflow_run_started"; run_id: string; } interface WorkflowRunResumedEvent { [key: string]: unknown; event: "workflow_run_resumed"; run_id: string; checkpoint_id: string; } interface WorkflowRunDetachedEvent { [key: string]: unknown; event: "workflow_run_detached"; run_id: string; message: string; } type WorkflowRouterEvent = WorkflowRunDetachedEvent | WorkflowRunResumedEvent | WorkflowRunStartedEvent; /** Every frame a client can see on a run's stream. */ type WorkflowStreamEvent = NodeStreamEvent | WorkflowRouterEvent | WorkflowRunEvent; interface RunAnnounceEvent { event: "run_announce"; run_id: string; workflow_id: string; status: string; kind: "inserted" | "status"; ts: string; } declare function isRunAnnounceEvent(value: unknown): value is RunAnnounceEvent; export { ACTIVE_RUN_STATUSES, AGENT_STEP_PHASES, TERMINAL_RUN_STATUSES, isNodeStreamEvent, isRunAnnounceEvent, isWorkflowRunEvent }; export type { AgentStepPhase, CheckpointSavedEvent, NodeCompletedEvent, NodeCostEvent, NodeEmittedEvent, NodeFailedEvent, NodeProgressEvent, NodeRetryScheduledEvent, NodeSkippedEvent, NodeStartedEvent, NodeStreamEvent, RunAnnounceEvent, RunCancelledEvent, RunCompletedEvent, RunErroredEvent, RunFailedEvent, RunInterruptedEvent, RunPausedEvent, RunResumedEvent, RunStartedEvent, RunStatus, SubgraphRunLinkedEvent, WithheldValue, WorkSetProgressEvent, WorkflowRouterEvent, WorkflowRunDetachedEvent, WorkflowRunEvent, WorkflowRunResumedEvent, WorkflowRunStartedEvent, WorkflowRunStatus, WorkflowStreamEvent };