/**
 * Unified Routing Service
 *
 * Bridges the two independent routing systems:
 * 1. Rule-based ModelRouter (src/models/router.ts) - uses task complexity/type keywords, routing rules, role assignments
 * 2. Benchmark-data ModelRouter (src/memory/model-router.ts) - uses MODEL_FINGERPRINTS with per-category success rates, SQLite persistence
 *
 * Combines both signals to produce a single routing decision with higher accuracy
 * than either system alone. The benchmark-data router is weighted higher when it
 * has sufficient data points (>=5) for the relevant category.
 */
import { ModelRouter as RuleBasedRouter } from './router.js';
import { type ModelId, type RoutingDecision, type RoutingConfig } from '../memory/model-router.js';
import type { MultiModelConfig, TaskClassificationResult, TaskComplexity } from './types.js';
/**
 * Result from the unified routing system.
 */
export interface UnifiedRoutingResult {
    /** The selected model ID (using rule-based router's naming convention) */
    selectedModel: string;
    /** Fallback model ID if the primary fails */
    fallbackModel: string;
    /** Which system's recommendation was used: 'rule-based', 'benchmark-data', or 'consensus' */
    source: 'rule-based' | 'benchmark-data' | 'consensus';
    /** Confidence score 0-1 reflecting how confident the unified system is */
    confidence: number;
    /** Human-readable reasoning explaining the decision */
    reasoning: string;
    /** The rule-based router's classification */
    ruleBasedClassification: TaskClassificationResult;
    /** The benchmark-data router's decision */
    benchmarkDecision: RoutingDecision;
    /** Whether the two systems agreed on the model */
    systemsAgreed: boolean;
    /** Number of benchmark data points for the relevant category */
    benchmarkDataPoints: number;
}
/**
 * Options for recording outcomes back to the benchmark-data router.
 */
export interface OutcomeRecord {
    /** The model that was actually used (rule-based router naming) */
    modelUsed: string;
    /** Whether the task succeeded */
    success: boolean;
    /** Latency in milliseconds */
    latencyMs: number;
    /** Optional task category for category-specific tracking */
    taskCategory?: string;
}
/**
 * Side-by-side analysis of both routing systems.
 */
export interface RoutingAnalysis {
    taskDescription: string;
    ruleBasedResult: {
        suggestedModel: string;
        complexity: TaskComplexity;
        taskType: string;
        reasoning: string;
    };
    benchmarkResult: {
        primaryModel: ModelId;
        score: string;
        estimatedSuccessRate: number;
        estimatedLatencyMs: number;
        estimatedCost: number;
        reasoning: string;
    };
    unifiedResult: UnifiedRoutingResult;
    modelComparison: Array<{
        modelId: string;
        benchmarkModelId: ModelId | null;
        ruleBasedRole: string | null;
        benchmarkSuccessRate: number | null;
        benchmarkCategoryDataPoints: number | null;
    }>;
}
/**
 * Unified Routing Service that combines rule-based and benchmark-data routing.
 */
export declare class UnifiedRoutingService {
    private ruleRouter;
    private benchmarkConfig;
    /**
     * @param config - MultiModelConfig for the rule-based router
     * @param benchmarkConfig - Optional overrides for the benchmark-data router's RoutingConfig
     */
    constructor(config: MultiModelConfig, benchmarkConfig?: Partial<RoutingConfig>);
    /**
     * Route a task using both systems and combine their signals.
     *
     * Decision logic:
     * - If both systems agree on the model → use that model (source: 'consensus')
     * - If they disagree and benchmark has >=5 data points for the category → use benchmark (source: 'benchmark-data')
     * - If they disagree and benchmark has <5 data points → use rule-based (source: 'rule-based')
     */
    route(taskDescription: string): UnifiedRoutingResult;
    /**
     * Record a task outcome, feeding back to the benchmark-data router for learning.
     */
    recordOutcome(outcome: OutcomeRecord): void;
    /**
     * Show both systems' recommendations side by side for analysis/debugging.
     */
    analyzeRouting(taskDescription: string): RoutingAnalysis;
    /**
     * Get the underlying rule-based router for advanced usage.
     */
    getRuleRouter(): RuleBasedRouter;
    /**
     * Get the number of benchmark data points for the most relevant category
     * for a given task description, using the benchmark model's fingerprint.
     */
    private getCategoryDataPoints;
    /**
     * Same as getCategoryDataPoints but takes a fingerprint directly (no model lookup).
     */
    private getCategoryDataPointsFromFingerprint;
    /**
     * Get the maximum number of attempts across all categories for a fingerprint.
     * This represents the most-exercised category and serves as a proxy for
     * how much data we have for this model.
     */
    private getMaxCategoryAttempts;
    /**
     * Compute confidence when both systems agree.
     * Higher confidence because consensus is a strong signal.
     */
    private computeConsensusConfidence;
    /**
     * Compute confidence when using the benchmark-data router (disagreement case).
     */
    private computeBenchmarkConfidence;
    /**
     * Compute confidence when using the rule-based router (disagreement, low benchmark data).
     */
    private computeRuleBasedConfidence;
    /**
     * Select the best fallback model from the two systems' recommendations.
     */
    private selectFallback;
    /**
     * Get the role assigned to a model in the rule-based router.
     */
    private getRoleForModel;
}
/**
 * Create a UnifiedRoutingService with the given configuration.
 */
export declare function createUnifiedRouter(config: MultiModelConfig, benchmarkConfig?: Partial<RoutingConfig>): UnifiedRoutingService;
//# sourceMappingURL=unified-router.d.ts.map