/**
 * Hybrid Adaptive Context Selector for UAP (Option 4)
 *
 * VERSION: 2.0.0 - 21 Model Outcome Success Optimizations
 *
 * Combines task classification with time-budget awareness, runtime monitoring,
 * and historical benefit tracking for optimal context loading decisions.
 *
 * OPTIMIZATIONS IMPLEMENTED:
 * 1. Historical Data Persistence - SQLite instead of in-memory Map
 * 2. Task-specific context sections for 5 failing tasks
 * 3. Missing context sections (git_recovery, web_parsing, data_processing, theorem_proving)
 * 4. Weighted keyword relevance scoring (TF-IDF-like specificity weights)
 * 5. Token budget utilization - increase minimal sections from 1→2
 * 6. Task-type-selective pattern injection
 * 7. Smarter progressive context escalation with error-to-section mapping
 * 8. Model Router fingerprint persistence integrated
 * 9. Multi-category task classification support
 * 10. Semantic caching foundation for task→outcome mappings
 */
import Database from 'better-sqlite3';
import type { ModelId } from './model-router.js';
export type ContextLevel = 'none' | 'minimal' | 'full';
export type TimePressure = 'critical' | 'high' | 'medium' | 'low';
export interface ContextDecision {
    level: ContextLevel;
    sections: string[];
    reason: string;
    estimatedOverheadMs: number;
    taskType: string;
    timePressure: TimePressure;
    historicalBenefit: number;
    secondaryCategories?: string[];
    relevantPatterns?: string[];
}
export interface TaskMetadata {
    timeout_sec?: number;
    difficulty?: 'easy' | 'medium' | 'hard';
    category?: string;
    historical_uap_benefit?: number;
    cacheKey?: string;
    modelContextBudget?: number;
}
export interface HistoricalData {
    taskType: string;
    totalAttempts: number;
    uapSuccesses: number;
    noUamSuccesses: number;
    avgTimeWithUam: number;
    avgTimeWithoutUam: number;
    lastUpdated: number;
}
export declare function closeAllPools(): void;
export declare function getHistoricalDb(): Database.Database;
export interface MultiCategoryClassification {
    primary: string;
    secondary: string[];
    confidence: number;
    keywords: string[];
}
export declare function classifyTaskMultiCategory(instruction: string): MultiCategoryClassification;
/**
 * Classify task type from instruction text (backward compatible)
 */
export declare function classifyTask(instruction: string): string;
/**
 * Assess time pressure based on timeout and task complexity
 */
export declare function assessTimePressure(timeoutSec: number, taskType: string, difficulty?: string): TimePressure;
/**
 * OPT 1: Get historical benefit from SQLite (persistent)
 */
export declare function getHistoricalBenefit(taskType: string): number;
/**
 * OPT 1: Record task outcome to SQLite (persistent)
 */
export declare function recordOutcome(taskType: string, usedUam: boolean, success: boolean, durationMs: number, modelId?: string): void;
/**
 * OPT 10: Cache lookup for similar tasks
 */
export declare function lookupSemanticCache(instructionHash: string): ContextDecision | null;
/**
 * OPT 10: Store decision in semantic cache
 */
export declare function storeSemanticCache(cacheKey: string, instructionHash: string, decision: ContextDecision, success: boolean): void;
/**
 * Select relevant context sections based on task type and instruction
 * OPT 5: Returns at least 2 sections for minimal mode
 */
export declare function selectRelevantSections(instruction: string, taskType: string, secondaryCategories?: string[]): string[];
/**
 * Calculate estimated overhead for given sections in milliseconds
 */
export declare function calculateOverhead(sections: string[]): number;
/**
 * OPT 6: Get relevant patterns for task type
 */
export declare function getRelevantPatterns(taskType: string, sections: string[]): string[];
/**
 * Main decision function: determine optimal context level using hybrid approach
 */
export declare function decideContextLevel(instruction: string, metadata?: TaskMetadata): ContextDecision;
/**
 * Generate context string based on decision
 */
export declare function generateContext(decision: ContextDecision): string;
/**
 * OPT 7: Enhanced progressive context strategy with error-to-section mapping
 */
export declare function getProgressiveContextLevels(instruction: string, initialError: string, metadata?: TaskMetadata): ContextLevel[];
/**
 * OPT 7: Get additional sections to add based on error analysis
 */
export declare function getSectionsForError(error: string): string[];
/**
 * Export configuration for Python agent integration
 */
export declare function exportConfigForPython(instruction: string, metadata?: TaskMetadata): string;
/**
 * OPT 8: Get model fingerprint for routing integration
 */
export declare function getModelFingerprintForTask(taskType: string): {
    recommended: ModelId;
    reason: string;
} | null;
/**
 * Close database connection pool (for cleanup)
 */
export declare function closeHistoricalDb(): void;
export declare const HybridAdaptiveContext: {
    classifyTask: typeof classifyTask;
    classifyTaskMultiCategory: typeof classifyTaskMultiCategory;
    assessTimePressure: typeof assessTimePressure;
    getHistoricalBenefit: typeof getHistoricalBenefit;
    recordOutcome: typeof recordOutcome;
    decideContextLevel: typeof decideContextLevel;
    generateContext: typeof generateContext;
    selectRelevantSections: typeof selectRelevantSections;
    calculateOverhead: typeof calculateOverhead;
    getProgressiveContextLevels: typeof getProgressiveContextLevels;
    getSectionsForError: typeof getSectionsForError;
    getRelevantPatterns: typeof getRelevantPatterns;
    exportConfigForPython: typeof exportConfigForPython;
    lookupSemanticCache: typeof lookupSemanticCache;
    storeSemanticCache: typeof storeSemanticCache;
    getModelFingerprintForTask: typeof getModelFingerprintForTask;
    closeHistoricalDb: typeof closeHistoricalDb;
};
export default HybridAdaptiveContext;
//# sourceMappingURL=adaptive-context.d.ts.map