/** * Linear Workflow Orchestrator Implementation * * Executes workflow steps sequentially with state management and checkpointing. * * @module execution/workflow/linear-orchestrator */ import type { IWorkflowOrchestrator, IWorkflowStorage } from "./orchestrator.js"; import type { IResilientExecutor } from "../resilience/executor.js"; import type { WorkflowDefinition, WorkflowExecution, WorkflowCheckpoint, StepStatus, WorkflowStartHandler, WorkflowCompleteHandler, WorkflowFailedHandler, StepStartHandler, StepCompleteHandler, StepFailedHandler, WorkflowCheckpointHandler, WorkflowResumeHandler, WorkflowPauseHandler, WorkflowCancelHandler } from "./types.js"; /** * LinearOrchestrator - Sequential workflow execution with state management * * Implements the IWorkflowOrchestrator interface to provide: * - Sequential step execution * - State persistence via checkpoints * - Crash recovery and resumption * - Event-driven monitoring */ export declare class LinearOrchestrator implements IWorkflowOrchestrator { private _executions; private _cleanedUpExecutions; private _storage?; private _executor; private _agUiAdapter?; private _lifecycleService?; private _workflowStartHandlers; private _workflowCompleteHandlers; private _workflowFailedHandlers; private _stepStartHandlers; private _stepCompleteHandlers; private _stepFailedHandlers; private _checkpointHandlers; private _resumeHandlers; private _pauseHandlers; private _cancelHandlers; /** * Create a new LinearOrchestrator * * @param executor - Resilient executor for running tasks * @param storage - Optional storage for checkpoints * @param agUiAdapter - Optional AG-UI event adapter for real-time event streaming * @param lifecycleService - Optional execution lifecycle service for worktree management */ constructor(executor: IResilientExecutor, storage?: IWorkflowStorage, agUiAdapter?: any, // AgUiEventAdapter from server (optional) lifecycleService?: any); /** * Start a new workflow execution * * @param workflow - Workflow definition to execute * @param workDir - Working directory for task execution * @param options - Execution options (executionId is required) * @returns Promise resolving to execution ID */ startWorkflow(workflow: WorkflowDefinition, workDir: string, options: { executionId: string; checkpointInterval?: number; initialContext?: Record; }): Promise; /** * Resume a workflow from a checkpoint * * @param executionId - Execution ID to resume * @param options - Resume options * @returns Promise resolving to execution ID */ resumeWorkflow(executionId: string, options?: { checkpointInterval?: number; }): Promise; /** * Pause a running workflow * * @param executionId - Execution ID to pause */ pauseWorkflow(executionId: string): Promise; /** * Cancel a running workflow * * @param executionId - Execution ID to cancel */ cancelWorkflow(executionId: string): Promise; /** * Get current execution state * * @param executionId - Execution ID to query * @returns Execution state or null if not found */ getExecution(executionId: string): WorkflowExecution | null; /** * Get status of a specific step * * @param executionId - Execution ID * @param stepId - Step ID to query * @returns Step status or null if not found */ getStepStatus(executionId: string, stepId: string): StepStatus | null; /** * Wait for workflow to complete * * @param executionId - Execution ID to wait for * @returns Promise resolving to workflow execution */ waitForWorkflow(executionId: string): Promise; /** * List all checkpoints for a workflow * * @param workflowId - Optional workflow ID to filter by * @returns Promise resolving to list of checkpoints */ listCheckpoints(workflowId?: string): Promise; /** * Register handler for workflow start events */ onWorkflowStart(handler: WorkflowStartHandler): void; /** * Register handler for workflow completion events */ onWorkflowComplete(handler: WorkflowCompleteHandler): void; /** * Register handler for workflow failure events */ onWorkflowFailed(handler: WorkflowFailedHandler): void; /** * Register handler for step start events */ onStepStart(handler: StepStartHandler): void; /** * Register handler for step completion events */ onStepComplete(handler: StepCompleteHandler): void; /** * Register handler for step failure events */ onStepFailed(handler: StepFailedHandler): void; /** * Register handler for checkpoint events */ onCheckpoint(handler: WorkflowCheckpointHandler): void; /** * Register handler for resume events */ onResume(handler: WorkflowResumeHandler): void; /** * Register handler for pause events */ onPause(handler: WorkflowPauseHandler): void; /** * Register handler for cancel events */ onCancel(handler: WorkflowCancelHandler): void; /** * Execute workflow (main execution loop) * * @param workflow - Workflow definition * @param execution - Workflow execution state * @param workDir - Working directory for task execution * @param checkpointInterval - Optional checkpoint interval (in steps) * @returns Promise that resolves when workflow completes * @private */ private _executeWorkflow; /** * Save checkpoint to storage * * @param execution - Workflow execution to checkpoint * @private */ private _saveCheckpoint; /** * Clean up execution resources (worktree) * Ensures cleanup is called only once per execution * * @param execution - Workflow execution to cleanup * @private */ private _cleanupExecution; /** * Execute a single workflow step * * @param step - Workflow step to execute * @param execution - Current workflow execution state * @param workDir - Working directory for task execution * @returns Promise resolving to execution result * @private */ private _executeStep; /** * Apply output mapping from step result to workflow context * * @param step - Workflow step with output mapping * @param result - Execution result from step * @param context - Workflow context to update * @private */ private _applyOutputMapping; /** * Check if all step dependencies are met * * @param step - Workflow step to check * @param execution - Current workflow execution state * @returns True if all dependencies are met, false otherwise * @private */ private _areDependenciesMet; /** * Evaluate a step condition * * @param step - Workflow step with condition * @param context - Workflow context * @returns True if condition evaluates to true or no condition exists * @private */ private _shouldExecuteStep; } //# sourceMappingURL=linear-orchestrator.d.ts.map