/** * Agentic QE v3 - Workflow Orchestrator * Coordinates complete QE workflows across all 12 domains */ import { Result, DomainName } from '../shared/types/index.js'; import { EventBus, MemoryBackend, AgentCoordinator } from '../kernel/interfaces.js'; /** * Step execution mode */ export type StepExecutionMode = 'sequential' | 'parallel'; /** * Step status */ export type StepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped'; /** * Workflow status */ export type WorkflowStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused'; /** * Condition operator */ export type ConditionOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'exists'; /** * Step condition for conditional branching */ export interface StepCondition { /** Path to the value in context (e.g., 'results.coverage.line') */ path: string; /** Comparison operator */ operator: ConditionOperator; /** Value to compare against */ value: unknown; } /** * Workflow step definition */ export interface WorkflowStepDefinition { /** Unique step identifier */ id: string; /** Human-readable name */ name: string; /** Target domain for execution */ domain: DomainName; /** Action to invoke on the domain */ action: string; /** Input mapping from context */ inputMapping?: Record; /** Output mapping to context */ outputMapping?: Record; /** Step dependencies (step IDs that must complete first) */ dependsOn?: string[]; /** Condition to execute this step */ condition?: StepCondition; /** Skip condition (if true, step is skipped) */ skipCondition?: StepCondition; /** Timeout in milliseconds */ timeout?: number; /** Retry configuration */ retry?: { maxAttempts: number; backoffMs: number; backoffMultiplier?: number; }; /** Rollback action if step fails */ rollback?: { domain: DomainName; action: string; input?: Record; }; /** Continue workflow on failure */ continueOnFailure?: boolean; } /** * Workflow definition */ export interface WorkflowDefinition { /** Unique workflow identifier */ id: string; /** Human-readable name */ name: string; /** Description */ description: string; /** Workflow version */ version: string; /** Workflow steps */ steps: WorkflowStepDefinition[]; /** Default execution mode for steps without dependencies */ defaultMode?: StepExecutionMode; /** Global timeout in milliseconds */ timeout?: number; /** Event triggers */ triggers?: WorkflowTrigger[]; /** Tags for categorization */ tags?: string[]; } /** * Workflow trigger definition */ export interface WorkflowTrigger { /** Event type to trigger on */ eventType: string; /** Optional source domain filter */ sourceDomain?: DomainName; /** Condition to evaluate on event payload */ condition?: StepCondition; /** Input mapping from event payload to workflow context */ inputMapping?: Record; } /** * Step execution result */ export interface StepExecutionResult { stepId: string; status: StepStatus; startedAt: Date; completedAt?: Date; duration?: number; output?: unknown; error?: string; retryCount?: number; } /** * Workflow execution context */ export interface WorkflowContext { /** Input parameters */ input: Record; /** Accumulated results from steps */ results: Record; /** Metadata */ metadata: { executionId: string; workflowId: string; correlationId?: string; startedAt: Date; triggeredBy?: string; }; } /** * Workflow execution status */ export interface WorkflowExecutionStatus { executionId: string; workflowId: string; workflowName: string; status: WorkflowStatus; startedAt: Date; completedAt?: Date; duration?: number; progress: number; currentSteps: string[]; completedSteps: string[]; failedSteps: string[]; skippedSteps: string[]; context: WorkflowContext; stepResults: Map; error?: string; } /** * Workflow list item */ export interface WorkflowListItem { id: string; name: string; description: string; version: string; stepCount: number; tags?: string[]; triggers?: string[]; } export declare const WorkflowEvents: { readonly WorkflowStarted: "workflow.WorkflowStarted"; readonly WorkflowCompleted: "workflow.WorkflowCompleted"; readonly WorkflowFailed: "workflow.WorkflowFailed"; readonly WorkflowCancelled: "workflow.WorkflowCancelled"; readonly StepStarted: "workflow.StepStarted"; readonly StepCompleted: "workflow.StepCompleted"; readonly StepFailed: "workflow.StepFailed"; readonly StepSkipped: "workflow.StepSkipped"; }; export interface WorkflowStartedPayload { executionId: string; workflowId: string; workflowName: string; stepCount: number; } export interface WorkflowCompletedPayload { executionId: string; workflowId: string; workflowName: string; duration: number; completedSteps: number; skippedSteps: number; } export interface WorkflowFailedPayload { executionId: string; workflowId: string; workflowName: string; failedStep: string; error: string; } export interface StepEventPayload { executionId: string; workflowId: string; stepId: string; stepName: string; domain: DomainName; } export interface IWorkflowOrchestrator { /** Initialize the orchestrator */ initialize(): Promise; /** Dispose resources */ dispose(): Promise; /** Register a workflow definition */ registerWorkflow(definition: WorkflowDefinition): Result; /** Unregister a workflow */ unregisterWorkflow(workflowId: string): Result; /** Execute a workflow */ executeWorkflow(workflowId: string, input?: Record, correlationId?: string): Promise>; /** Get workflow execution status */ getWorkflowStatus(executionId: string): WorkflowExecutionStatus | undefined; /** Cancel a running workflow */ cancelWorkflow(executionId: string): Promise>; /** Pause a running workflow */ pauseWorkflow(executionId: string): Promise>; /** Resume a paused workflow */ resumeWorkflow(executionId: string): Promise>; /** List registered workflows */ listWorkflows(): WorkflowListItem[]; /** Get active executions */ getActiveExecutions(): WorkflowExecutionStatus[]; /** Get workflow definition */ getWorkflow(workflowId: string): WorkflowDefinition | undefined; } type DomainAction = (input: Record, context: WorkflowContext) => Promise>; export interface WorkflowOrchestratorConfig { maxConcurrentWorkflows: number; defaultStepTimeout: number; defaultWorkflowTimeout: number; enableEventTriggers: boolean; persistExecutions: boolean; } export declare class WorkflowOrchestrator implements IWorkflowOrchestrator { private readonly eventBus; private readonly memory; private readonly agentCoordinator; private readonly config; private readonly workflows; private readonly executions; private readonly actionRegistry; private readonly eventSubscriptions; private initialized; constructor(eventBus: EventBus, memory: MemoryBackend, agentCoordinator: AgentCoordinator, config?: Partial); /** * Initialize the orchestrator */ initialize(): Promise; /** * Dispose resources */ dispose(): Promise; /** * Register a workflow definition */ registerWorkflow(definition: WorkflowDefinition): Result; /** * Unregister a workflow */ unregisterWorkflow(workflowId: string): Result; /** * Execute a workflow */ executeWorkflow(workflowId: string, input?: Record, correlationId?: string): Promise>; /** * Get workflow execution status */ getWorkflowStatus(executionId: string): WorkflowExecutionStatus | undefined; /** * Cancel a running workflow */ cancelWorkflow(executionId: string): Promise>; /** * Pause a running workflow */ pauseWorkflow(executionId: string): Promise>; /** * Resume a paused workflow */ resumeWorkflow(executionId: string): Promise>; /** * List registered workflows */ listWorkflows(): WorkflowListItem[]; /** * Get active executions */ getActiveExecutions(): WorkflowExecutionStatus[]; /** * Get workflow definition */ getWorkflow(workflowId: string): WorkflowDefinition | undefined; private runWorkflow; private executeSteps; private executeStep; private executeStepAction; /** * Check if an action is registered for a domain */ isActionRegistered(domain: DomainName, action: string): boolean; /** * Get all registered actions for a domain */ getRegisteredActions(domain: DomainName): string[]; /** * Get all domains with registered actions */ getDomainsWithActions(): DomainName[]; /** * Spawn a workflow agent for complex step execution * Used when steps require dedicated agent resources */ spawnWorkflowAgent(workflowId: string, stepId: string, domain: DomainName): Promise>; /** * Stop a workflow agent after step completion */ stopWorkflowAgent(agentId: string): Promise>; /** * Get the number of agents available for workflow execution */ getAvailableAgentCapacity(): number; private executeRollback; private buildStepInput; private mapStepOutput; private getValueByPath; private setValueByPath; private evaluateCondition; private publishEvent; private publishWorkflowStarted; private publishWorkflowCompleted; private publishWorkflowFailed; private publishStepStarted; private publishStepCompleted; private publishStepFailed; private publishStepSkipped; private validateWorkflowDefinition; private detectCircularDependencies; private setupEventTriggers; private registerWorkflowTriggers; private handleEventForTriggers; private registerBuiltInWorkflows; private loadPersistedWorkflows; private persistWorkflows; private persistExecution; private delay; /** * Register a domain action handler */ registerAction(domain: DomainName, action: string, handler: DomainAction): void; } export declare function createWorkflowOrchestrator(eventBus: EventBus, memory: MemoryBackend, agentCoordinator: AgentCoordinator, config?: Partial): IWorkflowOrchestrator; export {}; //# sourceMappingURL=workflow-orchestrator.d.ts.map