/** * ModelRouter — intelligent model selection for subagent delegation. * * Combines: * 1. User-configured model matrix (/setmodel overrides) * 2. Model intelligence profiles (strengths/weaknesses per model family) * 3. Provider availability (which models have API keys configured) * 4. Per-model cost tracking * * Usage: * const router = new ModelRouter({ matrix, config, profiles: MODEL_PROFILES }); * const pick = router.pickForTask('security-scanner', 'Audit the auth module'); * // → { provider: 'anthropic', model: 'matched-model', reason: 'best-for security' } */ import type { ModelMatrixEntry, ProviderConfig } from '../types/config.js'; export interface ModelIntelligenceEntry { provider: string; pattern: RegExp; family: string; strengths: string[]; weaknesses?: string[]; bestFor: string[]; avoidFor?: string[]; costTier: 'budget' | 'standard' | 'premium'; speedTier: 'fast' | 'normal' | 'slow'; minContext?: number; } export interface RouterConfig { /** User-configured model matrix (from /setmodel). */ matrix?: Record | undefined; /** Provider configurations (to check API key availability). */ config: { provider: string; model: string; providers?: Record; }; /** Known model intelligence profiles. */ profiles?: ModelIntelligenceEntry[] | undefined; } export interface ModelPick { provider: string; model: string; /** Why this model was chosen. */ reason: string; /** Whether this came from the user's matrix (true) or auto-detected (false). */ fromMatrix: boolean; } export interface RouterCosts { /** Cumulative cost per provider/model key. */ byModel: Record; /** Grand total. */ totalCost: number; } export declare class ModelRouter { private profiles; private matrix; private config; private costs; constructor(opts: RouterConfig); /** Look up the model matrix resolution for a role (role → phase → * → leader). */ private resolveMatrix; /** Simplified phase lookup for common roles. */ private roleToPhase; /** * Pick the best model for a task. * * Priority: * 1. User's /setmodel matrix entry for this role (explicit override) * 2. Best-matching model from intelligence profiles * 3. Leader model (fallback) */ pickForTask(role: string, description: string): ModelPick; /** Infer task category from description keywords + role. */ private inferCategory; /** Find the best available model for a task category. */ private findBestModel; /** Check if a provider has an API key configured. */ private hasKey; /** Get the configured model list for a provider. */ private getProviderModels; /** Record cost for a model. */ recordCost(provider: string, model: string, cost: number, tokens?: { input: number; output: number; }): void; /** Get cumulative costs. */ getCosts(): RouterCosts; /** Reset cost tracking. */ resetCosts(): void; /** List all available providers with their best model for each task category. */ suggestMatrix(): Record; } //# sourceMappingURL=model-router.d.ts.map