/** * Prediction Engine - Speculative Execution v2.0 * * Analyzes historical request patterns and predicts the next 3 most probable * agent requests using lightweight local models (Llama 3.2 1B/3B). * * Features: * - Pattern analysis from request history * - Confidence scoring (0.0-1.0) * - Lightweight model inference * - Real-time prediction updates */ import { EventEmitter } from 'events'; export interface PredictionRequest { taskType: string; context: string; agentId?: string; timestamp: number; } export interface Prediction { id: string; taskType: string; context: string; confidence: number; reasoning: string; timestamp: number; expiresAt: number; } export interface PredictionEngineConfig { ollamaUrl?: string; modelName?: string; maxPredictions?: number; minConfidence?: number; historySize?: number; predictionTTL?: number; } export interface PredictionMetrics { totalPredictions: number; accuratePredictions: number; accuracy: number; averageConfidence: number; predictionTime: number; } export declare class PredictionEngine extends EventEmitter { private config; private requestHistory; private activePredictions; private metrics; constructor(config?: PredictionEngineConfig); /** * Record a new request in the history */ recordRequest(request: PredictionRequest): void; /** * Generate predictions based on current history */ generatePredictions(): Promise; /** * Check if a request matches any active prediction */ matchPrediction(request: PredictionRequest): Prediction | null; /** * Analyze patterns in request history */ private analyzePatterns; /** * Use lightweight model to predict next requests */ private predictNextRequests; /** * Build prompt for prediction model */ private buildPredictionPrompt; /** * Parse predictions from model response */ private parsePredictions; /** * Calculate similarity score between request and prediction */ private calculateMatchScore; /** * Simple text similarity using word overlap */ private calculateTextSimilarity; /** * Get current metrics */ getMetrics(): PredictionMetrics; /** * Get active predictions */ getActivePredictions(): Prediction[]; /** * Clear all predictions and history */ clear(): void; } //# sourceMappingURL=PredictionEngine.d.ts.map