import { UiInterrupt } from '../hitl/types'; /** * Events emitted by the Orchestrator during a chat run. * * - `"trace"`: intermediate model output to display. * - `"interrupt"`: human-in-the-loop input required; UI should call `resumeInterrupt()`. * - `"completed"`: run finished successfully; includes final chat history and optional smart-mapping result. * - `"cancelled"`: run aborted by the user. * - `"ux-suggestion"`: optional suggestion for the UX to display (e.g., show legend). * - `"error"`: an error occurred during orchestration. * Consumers should handle all cases when iterating the async generator from `ask()`. */ export type OrchestratorEvent = (OrchestratorEventBase & { type: "cancelled"; reason?: CancelReason; }) | (OrchestratorEventBase & { type: "completed"; result: CompletedEventResult; }) | (OrchestratorEventBase & { type: "error"; error: OrchestratorError; }) | (OrchestratorEventBase & { type: "interrupt"; interrupt: UiInterrupt; }) | (OrchestratorEventBase & { type: "trace"; data: TraceEventData; }) | (OrchestratorEventBase & { type: "ux-suggestion"; suggestion: UXSuggestion; }); /** Base properties for all orchestrator events */ type OrchestratorEventBase = { runId: string; timestamp: number; }; export interface CompletedEventResult { content: string; } /** Data for a trace event emitted during graph execution */ export interface TraceEventData { text: string; agentName?: string; toolName?: string; } /** Optional suggestion event the UX can choose to display or ignore */ export type UXSuggestion = { id: string; description?: string; payload?: Record; }; /** Cancel reasons for orchestrator events: * - "user": the user explicitly cancelled the run. */ export type CancelReason = "user"; /** Error information for orchestrator events */ export type OrchestratorError = { message: string; }; export {};