/**
 * Optimization Module
 *
 * Research-based optimizations for LLM-powered CLI applications.
 * Implements findings from 2024-2025 scientific publications.
 *
 * Key Optimizations:
 * - Dynamic Tool Filtering (Less-is-More): 70% execution time reduction
 * - Model Tier Routing (FrugalGPT): 30-70% cost reduction
 * - Parallel Tool Execution (LLMCompiler): 2.5-4.6x speedup
 * - Latency Optimization: Sub-500ms for flow state preservation
 */
// Tool Filtering
export { filterTools, buildTaskContext, classifyTaskType, extractKeywords, getFilteringStats, } from "./tool-filtering.js";
// Model Routing
export { ModelRouter, getModelRouter, initializeModelRouter, classifyTaskComplexity, selectModel, calculateCost, getCostComparison, GROK_MODELS, DEFAULT_ROUTING_CONFIG, } from "./model-routing.js";
// Parallel Execution
export { ParallelExecutor, groupByDependency, analyzeDependencies, estimateSpeedup, createParallelExecutor, DEFAULT_EXECUTION_OPTIONS, } from "./parallel-executor.js";
// Latency Optimization
export { LatencyOptimizer, StreamingOptimizer, getLatencyOptimizer, getStreamingOptimizer, measureLatency, precompute, LATENCY_THRESHOLDS, OPERATION_TARGETS, } from "./latency-optimizer.js";
// Prompt Caching
export { PromptCacheManager, getPromptCacheManager, initializePromptCache, DEFAULT_CACHE_CONFIG, } from "./prompt-cache.js";
/**
 * Initialize all optimizations with default settings
 */
export function initializeOptimizations(config) {
    // Import model-routing and latency-optimizer modules
    // Note: These are already exported above, using dynamic import to avoid TypeScript circular reference issues
    const { initializeModelRouter: initRouter } = require("./model-routing.js");
    const { getLatencyOptimizer: getOptimizer } = require("./latency-optimizer.js");
    const modelRouter = initRouter(config?.modelRoutingConfig || {});
    const latencyOptimizer = getOptimizer();
    return { modelRouter, latencyOptimizer };
}
/**
 * Get optimization summary/report
 */
export async function getOptimizationReport() {
    const { getModelRouter } = await import("./model-routing.js");
    const { getLatencyOptimizer } = await import("./latency-optimizer.js");
    const modelRouter = getModelRouter();
    const latencyOptimizer = getLatencyOptimizer();
    const routerConfig = modelRouter.getConfig();
    const latencyStats = latencyOptimizer.getStats();
    return {
        toolFiltering: {
            enabled: true, // Always enabled when used
        },
        modelRouting: {
            enabled: routerConfig.enabled,
            totalCost: modelRouter.getTotalCost(),
            savings: modelRouter.getEstimatedSavings(),
        },
        latency: {
            totalOperations: latencyStats.totalOperations,
            metTarget: latencyStats.metTarget,
            p50: latencyStats.p50,
            p95: latencyStats.p95,
        },
        parallelExecution: {
            estimatedSpeedup: 2.5, // Average from research
        },
    };
}
//# sourceMappingURL=index.js.map