export type WorkflowJSONPrimitive = string | number | boolean | null; export type WorkflowJSONValue = | WorkflowJSONPrimitive | { readonly [key: string]: WorkflowJSONValue } | readonly WorkflowJSONValue[]; export type WorkflowJSONSchemaType = "object" | "array" | "string" | "number" | "integer" | "boolean" | "null"; /** Plain JSON Schema subset validated by the workflow runtime. */ export interface WorkflowJSONSchema { readonly type?: WorkflowJSONSchemaType | readonly WorkflowJSONSchemaType[]; readonly enum?: readonly WorkflowJSONValue[]; readonly properties?: Readonly>; readonly required?: readonly string[]; readonly additionalProperties?: boolean; readonly items?: WorkflowJSONSchema; readonly minItems?: number; readonly maxItems?: number; } export interface WorkflowPhase { readonly title: string; readonly detail?: string; readonly [key: string]: WorkflowJSONValue | undefined; } export interface WorkflowMeta { readonly name: string; readonly description: string; readonly whenToUse?: string; readonly phases?: readonly WorkflowPhase[]; readonly [key: string]: WorkflowJSONValue | readonly WorkflowPhase[] | undefined; } export type WorkflowThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"; export interface WorkflowAgentOptions { readonly schema?: WorkflowJSONSchema; readonly label?: string; readonly phase?: string; readonly model?: string; readonly persona?: string; readonly isolation?: "process" | "in-process"; readonly agentType?: string; readonly thinkingLevel?: WorkflowThinkingLevel; } export type WorkflowThunk = () => T | PromiseLike; export type WorkflowPipelineStage = ( previous: TPrevious, item: TItem, index: number, ) => TResult | PromiseLike; export interface WorkflowBudget { readonly total: number | null; spent(): number; remaining(): number; } declare global { function agent( prompt: string, options?: WorkflowAgentOptions & { readonly schema?: undefined }, ): Promise; function agent( prompt: string, options: WorkflowAgentOptions & { readonly schema: WorkflowJSONSchema }, ): Promise; function parallel( thunks: readonly WorkflowThunk[], ): Promise | null>>; function pipeline( items: readonly TItem[], stage: WorkflowPipelineStage, ): Promise | null>>; function pipeline( items: readonly TItem[], stage1: WorkflowPipelineStage, stage2: WorkflowPipelineStage, TResult2>, ): Promise | null>>; function pipeline( items: readonly TItem[], stage1: WorkflowPipelineStage, stage2: WorkflowPipelineStage, TResult2>, stage3: WorkflowPipelineStage, TResult3>, ): Promise | null>>; function pipeline( items: readonly TItem[], ...stages: Array> ): Promise>; function workflow( name: string, childArgs?: WorkflowJSONValue, ): Promise; function phase(title: string): void; function log(message: unknown): void; const args: WorkflowJSONValue | undefined; const cwd: string; const budget: WorkflowBudget; }