import { EventEmitter } from 'events'; export type WorkflowId = string & { readonly __brand: 'WorkflowId'; }; export type SessionId = string & { readonly __brand: 'SessionId'; }; export type TaskId = string & { readonly __brand: 'TaskId'; }; export type ProjectId = string & { readonly __brand: 'ProjectId'; }; export declare function createWorkflowId(id: string): WorkflowId; export declare function createSessionId(id: string): SessionId; export declare function createTaskId(id: string): TaskId; export declare function createProjectId(id: string): ProjectId; export type Result = { readonly success: true; readonly data: T; } | { readonly success: false; readonly error: E; }; export declare function createSuccess(data: T): Result; export declare function createFailure(error: E): Result; export interface IdResolutionResult { readonly workflowId: WorkflowId | null; readonly sessionId: SessionId | null; readonly taskId: TaskId | null; readonly source: 'workflowId' | 'sessionId' | 'taskId' | 'none'; } export interface IdResolvable { readonly taskId?: string; readonly metadata?: Record; readonly [key: string]: unknown; } export declare function resolveWorkflowId(data: IdResolvable): Result; export declare function mapSubtaskToParentWorkflowId(taskId: string): string; export declare function resolveWorkflowIdWithMapping(data: IdResolvable): Result; export declare enum WorkflowPhase { INITIALIZATION = "initialization", DECOMPOSITION = "decomposition", ORCHESTRATION = "orchestration", EXECUTION = "execution", COMPLETED = "completed", FAILED = "failed", CANCELLED = "cancelled" } export declare enum WorkflowState { PENDING = "pending", IN_PROGRESS = "in_progress", COMPLETED = "completed", FAILED = "failed", CANCELLED = "cancelled", BLOCKED = "blocked", RETRYING = "retrying" } export interface WorkflowTransition { fromPhase: WorkflowPhase; fromState: WorkflowState; toPhase: WorkflowPhase; toState: WorkflowState; timestamp: Date; reason?: string; metadata?: Record; triggeredBy?: string; } export interface PhaseExecution { phase: WorkflowPhase; state: WorkflowState; startTime: Date; endTime?: Date; duration?: number; progress: number; error?: string; metadata: Record; retryCount: number; maxRetries: number; subPhases?: Map; } export interface SubPhaseExecution { subPhase: string; parentPhase: WorkflowPhase; state: WorkflowState; startTime: Date; endTime?: Date; duration?: number; progress: number; weight: number; order: number; metadata: Record; error?: string; } export declare const SUB_PHASES: Record>; export interface WorkflowStateSnapshot { workflowId: string; sessionId: string; projectId: string; currentPhase: WorkflowPhase; currentState: WorkflowState; overallProgress: number; startTime: Date; endTime?: Date; totalDuration?: number; phases: Map; transitions: WorkflowTransition[]; metadata: { taskCount?: number; epicCount?: number; agentCount?: number; dependencyCount?: number; [key: string]: unknown; }; persistedAt: Date; version: string; } export interface WorkflowStateChangeEvent { workflowId: string; sessionId: string; projectId: string; transition: WorkflowTransition; snapshot: WorkflowStateSnapshot; } export declare class WorkflowStateManager extends EventEmitter { private static instance; private workflows; private persistenceEnabled; private persistenceDirectory; private readonly version; constructor(persistenceDirectory?: string); static getInstance(persistenceDirectory?: string): WorkflowStateManager; initializeWorkflow(workflowId: string, sessionId: string, projectId: string, metadata?: Record): Promise; transitionWorkflow(workflowId: string, toPhase: WorkflowPhase, toState: WorkflowState, options?: { reason?: string; metadata?: Record; triggeredBy?: string; progress?: number; }): Promise; updatePhaseProgress(workflowId: string, phase: WorkflowPhase, progress: number, metadata?: Record): Promise; initializeSubPhases(workflowId: string, phase: WorkflowPhase): void; updateSubPhaseProgress(workflowId: string, phase: WorkflowPhase, subPhase: string, progress: number, state?: WorkflowState, metadata?: Record): Promise>; private calculatePhaseProgressFromSubPhases; getSubPhaseStatus(workflowId: string, phase: WorkflowPhase): Map | null; startSubPhase(workflowId: string, phase: WorkflowPhase, subPhase: string, metadata?: Record): Promise; completeSubPhase(workflowId: string, phase: WorkflowPhase, subPhase: string, metadata?: Record): Promise; getWorkflow(workflowId: string): WorkflowStateSnapshot | undefined; getProjectWorkflows(projectId: string): WorkflowStateSnapshot[]; getSessionWorkflows(sessionId: string): WorkflowStateSnapshot[]; hasWorkflow(workflowId: string): boolean; hasPhase(workflowId: string, phase: WorkflowPhase): boolean; private validateTransition; private calculateOverallProgress; private persistWorkflow; loadWorkflow(workflowId: string): Promise; cleanupOldWorkflows(olderThanDays?: number): Promise; getWorkflowStats(): { total: number; byPhase: Record; byState: Record; averageDuration: number; completionRate: number; }; } //# sourceMappingURL=workflow-state-manager.d.ts.map