/** * Execution Engine * Orchestrates model invocations based on execution plans * Handles parallel/sequential calls, aggregation, fallbacks, and circuit breaking */ import type { ChatCompletionRequest, ChatCompletionResponse, StreamChunk } from '../types.js'; import type { ExecutionPlan } from './routing-engine.js'; /** * Execution result with metadata */ export interface ExecutionResult { response: ChatCompletionResponse; execution_metadata: { models_called: string[]; total_latency_ms: number; total_cost_usd: number; fallback_used: boolean; aggregation_method?: string; }; } /** * Execution Engine - executes plans and handles model orchestration */ export declare class ExecutionEngine { private adapters; private circuitBreakers; private concurrencyQueue; constructor(maxConcurrency?: number); /** * Execute a plan and return aggregated response */ execute(plan: ExecutionPlan, request: ChatCompletionRequest): Promise; /** * Execute models in parallel */ private executeParallel; /** * Execute models sequentially (stop at first success) */ private executeSequential; /** * Execute cascade (confidence-based escalation) */ private executeCascade; /** * Execute fallback models */ private executeFallback; /** * Invoke a single model with circuit breaker and timeout */ private invokeModel; /** * Aggregate results from multiple models */ private aggregateResults; /** * Voting aggregation - most common response wins */ private aggregateByVoting; /** * Confidence-weighted aggregation */ private aggregateByConfidence; /** * Ranking aggregation - score by multiple factors */ private aggregateByRanking; /** * Synthesizer aggregation - use another model to combine responses */ private aggregateBySynthesizer; /** * Extract confidence score from response */ private extractConfidence; /** * Normalize text for comparison */ private normalizeText; /** * Calculate cost for a model call */ private calculateCost; /** * Execute promise with timeout */ private withTimeout; /** * Execute streaming request */ executeStream(plan: ExecutionPlan, request: ChatCompletionRequest): Promise>; /** * Get circuit breaker state for a model */ getCircuitBreakerState(modelId: string): { state: 'closed' | 'open' | 'half-open'; failures: number; } | null; /** * Reset circuit breaker for a model */ resetCircuitBreaker(modelId: string): void; /** * Map internal ModelProvider enum to vendor ModelProvider enum */ private mapProvider; /** * Transform vendor response to ChatCompletionResponse */ private transformToChatCompletion; /** * Transform vendor choices to standard format */ private transformChoices; /** * Transform vendor stream chunk to StreamChunk */ private transformStream; } //# sourceMappingURL=execution-engine.d.ts.map