/** * Workflow Engine * * Parses workflow plans from Conductor responses, validates DAGs, * executes steps in topological order with parallel execution per level, * and emits progress events for platform handlers. */ import { EventEmitter } from 'events'; import type { WorkflowPlan, WorkflowStep, WorkflowConfig, WorkflowExecution, EphemeralAgentDef } from './workflow-types.js'; export declare class StepExecutionError extends Error { duration_ms: number; stepId: string; agentId: string; constructor(message: string, stepId: string, agentId: string, duration_ms: number); } export type StepExecutor = (agent: EphemeralAgentDef, prompt: string, timeoutMs: number) => Promise; /** * WorkflowEngine * * Events: * - 'progress': WorkflowProgressEvent */ export declare class WorkflowEngine extends EventEmitter { private config; private activeExecutions; constructor(config: WorkflowConfig); /** * Parse a workflow_plan JSON block from Conductor's response. * Returns null if no valid plan is found. */ parseWorkflowPlan(response: string): WorkflowPlan | null; private extractWorkflowPlanBlock; private extractWorkflowPlanCandidates; private stripWorkflowFence; private parseWorkflowPlanContent; private extractFirstJsonObject; /** * Extract text content outside the workflow_plan block (for display as Conductor's direct message). */ extractNonPlanContent(response: string): string; /** * Validate DAG structure: no cycles, valid dependencies, agent limits. * Returns error message or null if valid. */ validatePlan(plan: WorkflowPlan): string | null; /** * Topological sort of workflow steps. * Returns sorted steps or null if a cycle exists. */ topologicalSort(steps: WorkflowStep[]): WorkflowStep[] | null; /** * Group steps into execution levels (steps at same level run in parallel). */ buildExecutionLevels(steps: WorkflowStep[]): WorkflowStep[][]; /** * Execute a workflow plan. * * @param plan - Validated workflow plan * @param executeStep - Callback to execute a single step (provided by platform handler) * @returns Execution result with all step outputs */ execute(plan: WorkflowPlan, executeStep: StepExecutor): Promise<{ result: string; execution: WorkflowExecution; }>; /** * Cancel a running workflow execution. */ cancel(executionId: string): boolean; /** * Check if workflow orchestration is enabled. */ isEnabled(): boolean; private executeStep; /** * Replace {{step_id.result}} placeholders with actual step results. */ private interpolatePrompt; /** * Build the final combined result from all step outputs. */ private buildFinalResult; private runWithConcurrencyLimit; private balanceBackends; private emitProgress; } //# sourceMappingURL=workflow-engine.d.ts.map