/** * Shared workflow types. */ export type WorkflowJsonValue = | string | number | boolean | null | WorkflowJsonValue[] | { [key: string]: WorkflowJsonValue }; export interface WorkflowMeta { name: string; description: string; version?: string; [key: string]: WorkflowJsonValue | undefined; } export interface ParsedWorkflow { source: string; body: string; meta: WorkflowMeta; metaRange: { start: number; end: number; }; } export interface WorkflowBudgetOptions { maxAgentCalls?: number; maxLogEntries?: number; maxLogDataBytes?: number; maxResultBytes?: number; } export interface WorkflowBudgetState { readonly maxAgentCalls?: number; readonly maxLogEntries?: number; readonly maxLogDataBytes?: number; readonly maxResultBytes?: number; readonly agentCalls: number; readonly logEntries: number; readonly remainingAgentCalls: number | undefined; } export interface WorkflowAgentRequest { agent?: string; type?: string; subagent_type?: string; prompt: string; description?: string; context?: "fresh" | "fork"; isolation?: "worktree"; schema?: unknown; output?: unknown; [key: string]: unknown; } export interface WorkflowAgentRunContext { args: Record; cwd: string; phase?: string; budget: WorkflowBudgetState; signal?: AbortSignal; } export interface WorkflowAgentResult { id: string; type: string; status: string; result?: string; error?: string; structuredOutput?: unknown; warnings?: string[]; toolUses: number; } export interface WorkflowAgentChild { id: string; type: string; status: string; description: string; } export type WorkflowAgentRunner = ( request: WorkflowAgentRequest, context: WorkflowAgentRunContext ) => unknown | Promise; export interface WorkflowLogEntry { phase?: string; message: string; data?: unknown; index: number; } export interface WorkflowPhaseEntry { name: string; index: number; startedAt?: number; completedAt?: number; } export type WorkflowAgentCallStatus = | "queued" | "running" | "done" | "error" | "skipped" | (string & {}); export type WorkflowAgentCallLabelSource = "description" | "prompt"; export interface WorkflowAgentCall { request: WorkflowAgentRequest; phase?: string; index: number; startedAt?: number; completedAt?: number; label?: string; labelSource?: WorkflowAgentCallLabelSource; agentId?: string; status?: WorkflowAgentCallStatus; result?: unknown; error?: string; } export type WorkflowProgressKind = | "started" | "phase" | "log" | "agent_start" | "agent_update" | "agent_end" | "agent_error" | "completed"; export interface WorkflowProgressState { meta: WorkflowMeta; currentPhase?: string; currentTask?: string; phases: WorkflowPhaseEntry[]; logs: WorkflowLogEntry[]; agents: WorkflowAgentChild[]; agentCalls?: WorkflowAgentCall[]; duration?: number; } export interface WorkflowProgressEvent extends Omit { kind: WorkflowProgressKind; agentCalls?: WorkflowAgentCall[]; } export interface WorkflowRunResult { meta: WorkflowMeta; value: unknown; logs: WorkflowLogEntry[]; phases: WorkflowPhaseEntry[]; agentCalls: WorkflowAgentCall[]; agentChildren: WorkflowAgentChild[]; budget: WorkflowBudgetState; }