/** * Routing table — exact port of cortiq-gateway/src/routing.rs (Rust → TypeScript). * * Model selection: (task_label, complexity_tier) → ordered list of provider model IDs. * The list serves as both a priority order and a fallback chain. * * Order of preference: * 1. the task's models FOR THIS TIER (the user said exactly which model * serves this task at this complexity); * 2. at tier=high — the global high chain (escalation: any-tier task * models must not undercut it), then the task's any-tier models; * otherwise the task's any-tier models, then the global tier chain; * 3. `defaultModel` as the last resort. Deduplicated, empties dropped. */ /** Per-task rule: per-tier model lists + any-tier models that lead regardless. */ export interface TaskRule { /** Models that lead at ANY tier (after the tier-specific list). */ any: string[]; /** Models keyed by complexity tier: `{ low: [...], medium: [...], high: [...] }` */ per: Record; } /** * Parse a user-supplied task value into a TaskRule. * Accepts: * - a plain array: `["model-a", "model-b"]` → `{ any: [...], per: {} }` * - a single string: `"model-a"` → `{ any: ["model-a"], per: {} }` * - a map: `{ low: [...], high: [...], any: [...] }` → `{ per: { low: [...], high: [...] }, any: [...] }` */ export declare function parseTaskRule(val: unknown): TaskRule; /** Complexity band boundaries — override the router's default low/medium/high. */ export interface ComplexityBands { /** Score ≤ low → "low" */ low: number; /** Score ≤ medium → "medium"; else → "high" */ medium: number; } /** * Resolve the effective tier from a complexity score using optional custom bands. * If bands is null, return the router's tier as-is. */ export declare function resolveTier(score: number, routerTier: string, bands?: ComplexityBands | null): string; /** The full routing table. */ export declare class RoutingTable { private globalTiers; private taskRules; private defaultModel; private bands?; /** * @param globalTiers Ordered model lists per complexity tier. * `{ low: ["model-c"], medium: ["model-b", "model-c"], high: ["model-a"] }` * @param taskRules Per-task rules. * @param defaultModel Fallback when the router is unavailable. * @param bands Optional custom complexity bands (override router's tier). */ constructor(globalTiers: Record, taskRules: Record, defaultModel: string, bands?: (ComplexityBands | null) | undefined); /** * Recompute the effective complexity tier — the router's tier stands unless * custom bands override it. */ tierOf(score: number, routerTier: string): string; /** * Build the candidate chain for (task, tier). * Returns the ordered list of model provider IDs and whether a task rule * shaped the head of the chain. */ candidatesFor(task: string, tier: string): { models: string[]; taskRuleMatched: boolean; }; /** * Build candidate chain without a task context (pure complexity routing). * If the tier is not defined, the sole candidate is `defaultModel`. */ candidates(tier: string): string[]; } /** * Create a RoutingTable from a user-friendly config shape. */ export declare function createRoutingTable(config: { globalTiers?: Record; taskRules?: Record; defaultModel?: string; complexityBands?: ComplexityBands | null; }): RoutingTable;