UNPKG

codecrucible-synth

Version:

Production-Ready AI Development Platform with Multi-Voice Synthesis, Smithery MCP Integration, Enterprise Security, and Zero-Timeout Reliability

205 lines 6.62 kB
/** * Advanced Workflow Orchestrator implementing 9 industry-standard agentic patterns * Based on research from Amazon Q CLI, ZCF, and emerging AI agent architectures */ import { EventEmitter } from 'events'; import { UnifiedModelClient } from '../../refactor/unified-model-client.js'; import { JsonValue, ConfigurationObject, TransformFunction, PredicateFunction, WorkflowContext } from '../types.js'; export interface ExecutionRequest { id?: string; prompt: string; voice?: string; model?: string; maxTokens?: number; temperature?: number; stream?: boolean; metadata?: Record<string, unknown>; } export interface ExecutionResponse { success: boolean; result?: unknown; error?: string; executionTime: number; metadata?: Record<string, unknown>; } export interface ExecutionResult { success: boolean; content: unknown; metadata?: Record<string, unknown>; } export declare enum WorkflowPatternType { SEQUENTIAL = "sequential", PARALLEL = "parallel", HIERARCHICAL = "hierarchical", ADAPTIVE = "adaptive", FEEDBACK = "feedback", ITERATIVE = "iterative", BRANCHING = "branching", STREAMING = "streaming", MEMORY = "memory" } export interface PromptChaining { steps: ChainStep[]; context: Map<string, unknown>; } export interface ChainStep { id: string; prompt: string; voice?: string; dependencies?: string[]; transform?: TransformFunction<JsonValue, JsonValue>; } export interface ParallelProcessing { tasks: ParallelTask[]; concurrency: number; aggregation: 'merge' | 'reduce' | 'select'; } export interface ParallelTask { id: string; request: ExecutionRequest; weight: number; timeout?: number; } export interface MultiAgentOrchestration { agents: AgentRole[]; coordinator: string; communicationProtocol: 'direct' | 'broadcast' | 'pubsub'; } export interface AgentRole { id: string; type: string; capabilities: string[]; priority: number; } export interface DynamicWorkflow { initialPlan: WorkflowNode[]; adaptationRules: AdaptationRule[]; learningRate: number; } export interface WorkflowNode { id: string; type: WorkflowPatternType; config: ConfigurationObject; transitions: Transition[]; } export interface Transition { to: string; condition: PredicateFunction<WorkflowContext>; probability?: number; } export interface AdaptationRule { trigger: (context: WorkflowContext, history: JsonValue[]) => boolean; action: (workflow: DynamicWorkflow) => void; } export interface HumanInTheLoop { checkpoints: Checkpoint[]; escalationPolicy: EscalationPolicy; feedbackLoop: FeedbackConfig; } export interface Checkpoint { id: string; condition: PredicateFunction<JsonValue>; prompt: string; timeout: number; } export interface EscalationPolicy { maxRetries: number; escalationPath: string[]; fallbackBehavior: 'skip' | 'default' | 'abort'; } export interface FeedbackConfig { collectMetrics: boolean; learningEnabled: boolean; persistFeedback: boolean; } export interface ReflectiveRefinement { maxIterations: number; qualityThreshold: number; refinementStrategy: 'critique' | 'improve' | 'regenerate'; evaluationCriteria: EvaluationCriteria[]; } export interface EvaluationCriteria { name: string; weight: number; evaluate: (result: any) => number; } export interface ConditionalExecution { branches: Branch[]; defaultBranch?: string; evaluationOrder: 'sequential' | 'parallel'; } export interface Branch { id: string; condition: (context: any) => boolean; workflow: WorkflowNode; priority: number; } export interface RealTimeProcessing { streamingEnabled: boolean; chunkSize: number; bufferStrategy: 'window' | 'sliding' | 'circular'; onChunk: (chunk: any) => void; transform?: (content: string) => string; } export interface ContextualContinuation { memoryType: 'short' | 'long' | 'episodic' | 'semantic'; retentionPolicy: RetentionPolicy; contextWindow: number; } export interface RetentionPolicy { maxItems: number; ttl: number; importance: (item: any) => number; } export declare class WorkflowOrchestrator extends EventEmitter { private modelClient; private logger; private executionHistory; private activeWorkflows; private patternHandlers; private cleanupInterval; private isDisposed; private readonly MAX_HISTORY_SIZE; private readonly MAX_ACTIVE_WORKFLOWS; constructor(modelClient: UnifiedModelClient); /** * Initialize the workflow orchestrator */ initialize(): Promise<void>; private setupCleanupInterval; private performCleanup; private initializeHandlers; executePattern(pattern: WorkflowPatternType, request: ExecutionRequest, config?: any): Promise<ExecutionResponse>; executeSequentialChain(request: ExecutionRequest): Promise<ExecutionResponse>; executeParallelAgents(request: ExecutionRequest): Promise<ExecutionResponse>; executeAdaptiveWorkflow(request: ExecutionRequest): Promise<ExecutionResponse>; executeHierarchicalOrchestration(request: ExecutionRequest): Promise<ExecutionResponse>; executeWithFeedback(request: ExecutionRequest): Promise<ExecutionResponse>; executeIterativeRefinement(request: ExecutionRequest): Promise<ExecutionResponse>; executeBranchingLogic(request: ExecutionRequest): Promise<ExecutionResponse>; executeStreamingWorkflow(request: ExecutionRequest): Promise<ExecutionResponse>; executeWithMemory(request: ExecutionRequest): Promise<ExecutionResponse>; private generateExecutionId; private recordExecution; getExecutionHistory(executionId: string): ExecutionResult[] | undefined; getActiveWorkflows(): WorkflowExecution[]; cancelWorkflow(executionId: string): boolean; } declare class WorkflowExecution { id: string; pattern: WorkflowPatternType; request: ExecutionRequest; config: any; startTime: number; status: 'running' | 'completed' | 'failed' | 'cancelled'; progress: number; constructor(id: string, pattern: WorkflowPatternType, request: ExecutionRequest, config: any, startTime?: number, status?: 'running' | 'completed' | 'failed' | 'cancelled', progress?: number); updateProgress(progress: number): void; cancel(): void; } /** * Memory types for different retention strategies */ export type MemoryType = 'short' | 'long' | 'episodic' | 'semantic'; export {}; //# sourceMappingURL=workflow-orchestrator.d.ts.map