/** * Speculative Engine - Speculative Execution v2.0 * * Main orchestrator for speculative execution. Coordinates prediction, * worker pool, and speculative cache to achieve negative latency. * * Features: * - Automatic prediction generation * - Background pre-computation * - Instant cache lookups (<10ms) * - Graceful fallback to standard routing */ import { EventEmitter } from 'events'; import { Prediction } from './PredictionEngine'; import { CacheEntry } from './SpeculativeCache'; export interface SpeculativeEngineConfig { enabled?: boolean; predictionEngine?: any; workerPool?: any; speculativeCache?: any; } export interface SpeculativeResult { hit: boolean; result: any; latency: number; source: 'speculative-cache' | 'semantic-cache' | 'agent'; confidence?: number; } export interface SpeculativeMetrics { enabled: boolean; predictions: { total: number; accurate: number; accuracy: number; averageConfidence: number; }; cache: { size: number; hits: number; misses: number; hitRate: number; averageLatency: number; }; workers: { active: number; idle: number; queued: number; completed: number; failed: number; }; performance: { averageSpeculativeLatency: number; averageFallbackLatency: number; latencyImprovement: number; }; } export declare class SpeculativeEngine extends EventEmitter { private config; private predictionEngine; private workerPool; private speculativeCache; private enabled; private performanceMetrics; constructor(config?: SpeculativeEngineConfig); /** * Setup event handlers between components */ private setupEventHandlers; /** * Initialize the speculative engine */ initialize(): Promise; /** * Process a request with speculative execution */ processRequest(taskType: string, context: string, agentId?: string): Promise; /** * Trim performance metrics to keep memory bounded */ private trimMetrics; /** * Get comprehensive metrics */ getMetrics(): SpeculativeMetrics; /** * Get active predictions */ getActivePredictions(): Prediction[]; /** * Get cached entries */ getCachedEntries(): CacheEntry[]; /** * Enable speculative execution */ enable(): void; /** * Disable speculative execution */ disable(): void; /** * Check if enabled */ isEnabled(): boolean; /** * Clear all caches and predictions */ clear(): void; /** * Shutdown the speculative engine */ shutdown(): Promise; } //# sourceMappingURL=SpeculativeEngine.d.ts.map