/** Every value `workflow.run.status` can hold — scheduler outcomes plus the * transitional control states (`pausing` / `cancelling`). */ type WorkflowRunStatus = "pending" | "running" | "paused" | "interrupted" | "awaiting_input" | "errored" | "completed" | "failed" | "cancelled" | "pausing" | "cancelling"; /** 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 = "preparing" | "streaming" | "tool" | "reasoning" | "finalizing" | "retrying" | "complete"; /** 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; } 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: string | null; } 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: string | null; output_kind_ok: boolean | null; output_kind_errors: string[] | null; output_kind_version: number | null; output_kind_degraded: string | null; metadata: Record | null; wrapper: Record | null; source: "executor" | "reused" | null; reused_from: Record | null; } 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" | "user_skip" | "user_manual" | "retry" | "mocked" | "reused" | null; reason: string | null; } 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: number | null; current: number | null; total: number | null; } interface CheckpointSavedEvent { ts: string; event: "checkpoint_saved"; run_id: string; checkpoint_id: string; step: number; parent_checkpoint_id: string | null; } interface RunInterruptedEvent { ts: string; event: "run_interrupted"; run_id: string; node_id: string; payload: Record; checkpoint_id: string | null; } type RunStatus = "pending" | "running" | "paused" | "interrupted" | "awaiting_input" | "errored" | "completed" | "failed" | "cancelled"; interface RunCompletedEvent { ts: string; event: "run_completed"; run_id: string; status: RunStatus; steps_executed: number; last_outputs: Record; channel_values: Record; } 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: "graceful" | "immediate" | "candidate_stopped"; } interface RunPausedEvent { ts: string; event: "run_paused"; run_id: string; status: RunStatus; steps_executed: number; checkpoint_id: string | null; } interface RunResumedEvent { ts: string; event: "run_resumed"; run_id: string; from_checkpoint_id: string; mode: "pause" | "interrupt" | "user_skip" | "user_manual" | "retry"; } 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: string | null; } 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" | "summary" | "full" | "restructured"; payload: Record; component_ref: string | null; surface: string; title: string | null; presentation: "panel" | "showcase"; kind: string | null; kind_ok: boolean | null; metadata: Record | null; empty_values: string[]; empty_notice: string | null; } interface NodeCostEvent { ts: string; event: "node_cost"; run_id: string; step: number; node_id: string; spec_type: string | null; attempt: number; dispatch_id?: string; item_index?: number; cost_usd: number; input_tokens: number; output_tokens: number; total_tokens: number; model: string | null; models: string[]; conversation_id: string | null; request_id: string | null; } 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: string | null; 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 = RunStartedEvent | NodeStartedEvent | NodeCompletedEvent | NodeSkippedEvent | NodeFailedEvent | NodeRetryScheduledEvent | NodeProgressEvent | CheckpointSavedEvent | RunInterruptedEvent | RunCompletedEvent | RunFailedEvent | RunCancelledEvent | RunPausedEvent | RunResumedEvent | RunErroredEvent | NodeEmittedEvent | NodeCostEvent | WorkSetProgressEvent | SubgraphRunLinkedEvent; declare function isWorkflowRunEvent(value: unknown): value is WorkflowRunEvent; interface NodeStreamEvent { event: "node_stream"; run_id: string; node_id: string | null; dispatch_id?: string; item_index?: number; kind: "chunk" | "reasoning" | "phase" | "tool" | "warning" | "record_update" | "resource_changed" | "render_block" | "media" | "context_analysis"; delta: string; stream_seq: number; ts: string; chunks_received: number; chars_streamed: number; frame_id?: string | null; 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 = WorkflowRunStartedEvent | WorkflowRunResumedEvent | WorkflowRunDetachedEvent; /** Every frame a client can see on a run's stream. */ type WorkflowStreamEvent = WorkflowRunEvent | NodeStreamEvent | WorkflowRouterEvent; 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, WorkSetProgressEvent, WorkflowRouterEvent, WorkflowRunDetachedEvent, WorkflowRunEvent, WorkflowRunResumedEvent, WorkflowRunStartedEvent, WorkflowRunStatus, WorkflowStreamEvent };