From 6c0216f57b6ea8ecb94386bf2c20b4b6b01c664c Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Tue, 24 Nov 2026 14:18:21 -0600 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20o3,=20gpt-5-mini=20and=20gpt-5-nano?= =?UTF-8?q?=20retire=2012-11=20=E2=80=94=20gpt-5.4-mini=20and=20gpt-5.6-lu?= =?UTF-8?q?na=20take=20their=20rungs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge on 2026-12-11, not before. OpenAI shuts down o3, gpt-5-mini and gpt-5-nano that day (developers.openai.com/api/docs/deprecations, notice 2026-06-11) and the gateways redirect o3 -> gpt-5.4-mini ($0.75/$4.50), gpt-5-mini -> gpt-5.6-luna ($0.20/$1.20) and gpt-5-nano -> gpt-6-luna. Chains: both o3 rungs (auto and premium REASONING) sat directly behind gpt-5.4-mini, so the dedupe rule drops them. The agentic MEDIUM primary gpt-5-mini becomes gpt-5.6-luna in place; luna was not already in that chain. gpt-5-nano was in no chain. Affinity: the sixteen "gpt-5-mini" band values move to "gpt-5.6-luna" unchanged, and so do its places in the code_agent, tool_agent and tool_agent_parallel evidence pools and the web-research order. They are CARRIED, not measured. gpt-5-mini is a reasoning model and luna runs without reasoning, so the comment above the bands calls them a placeholder until a Terminal-Bench/tau2 run on luna. Decision snapshot: 0 of 88 primaries move, 0 tiers. 29 rows change only their candidate lists: 20 rename gpt-5-mini -> gpt-5.6-luna and 9 drop o3. 26 are exactly the rename plus the dedupe. In 3 eco rows luna sits three places lower, and 4 eco rows' candidateScores change. Both are the name-hash price artifact: the snapshot prices gpt-5-mini at $2.20/$2.50 and luna at $3.60/$6.70. Re-routing the corpus with the live catalog's real prices moves 4 of 88, all gpt-5-mini -> gpt-5.6-luna on eco tool_agent turns, 35% cheaper. README carries the carry-over note and the test count. dist/ rebuilt. Tests: retired-models.test.ts covers the three ids plus a web-research turn. Fixtures rename gpt-5-mini -> gpt-5.6-luna (synthetic price in portfolio.test, luna's real price in hardening.test). Mutation check: o3 back in auto REASONING fails 2 of 5; gpt-5-mini back as the agentic MEDIUM primary fails 2; gpt-5-mini back in the tool_agent pool fails 1; gpt-5-mini back in the web-research order fails the portfolio.test slot assertion. --- README.md | 4 +- dist/index.js | 75 ++++++++------ dist/index.js.map | 2 +- src/config.ts | 27 +++-- src/decisions.snapshot.json | 196 ++++++++++++++++-------------------- src/hardening.test.ts | 2 +- src/portfolio.test.ts | 26 ++--- src/portfolio.ts | 48 +++++---- src/retired-models.test.ts | 29 ++++++ 9 files changed, 226 insertions(+), 183 deletions(-) diff --git a/README.md b/README.md index 7861ed8..f9352be 100644 --- a/README.md +++ b/README.md @@ -268,7 +268,7 @@ Two rules govern this file, and both are load-bearing: 1. **These are weak priors, never task-quality labels.** They inform the `speed` and `reliability` terms only. A model is not "better" because it is fast. 2. **Historical numbers are never presented as a current provider SLA.** Hosts are expected to inject fresher observations (see below); the committed snapshot exists so the engine is safe and useful when a catalog is temporarily unavailable. -The repository ships 69 live performance profiles (three samples per model), 9 auditable historical seeds, 84 function-calling probe results, and a built-in snapshot of the 97 text models in the public catalog (2026-11-24 sync). Eleven newly listed models passed a real structured tool-call probe and are admitted as availability fallbacks for tool-required turns. DeepSeek V4 Flash Vision Experimental and Qwen 3.8 Flash did not return a valid tool call and remain fail-closed. GPT-6.1 Sol and DeepSeek V4.1 Flash also passed a structured tool-call probe in the subsequent capability refresh. Gemini 4 Carbon, added 2026-11-11 ahead of its gateway listing, returned its own next tool call through a two-round tool history on both the streaming and non-streaming gateway paths, so it is admitted as a tool fallback too. Kimi K3.1 Pro, which replaced Kimi K3 in every chain and affinity band on 2026-11-23, passed the live profile probe (three completions, no errors, a well-formed tool call); its reasoningMath affinity is measured on K3.1 Pro (paired against K3 on 50 MGSM rows on 2026-11-23: 41/50 vs 44/50 at a 512-token budget, every gap a truncation, 46/50 each when the truncated rows were rerun at 2,048 tokens), and it moves from 0.9 to 0.88. Its other affinity values are still carried over from K3, not measured on K3.1 Pro. On 2026-11-24 Gemini 3.6 Flash replaced Gemini 3.5 Flash, and GPT-5.4 Mini replaced o4-mini, in every chain and affinity band, when the gateways began redirecting the retired ids to them; 3.6 Flash's affinity values are carried over from 3.5 Flash (which Google had been answering with 3.6 since October), not measured on 3.6. On 2026-12-01 Gemini 3.5 Flash-Lite replaces Gemini 2.5 Flash, and Gemini 3.8 Flash replaces Gemini 2.5 Pro, the same way; 3.5 Flash-Lite's extraction and chat affinity is carried over from 2.5 Flash. Mistral Large 4, Gemini 4 Argon, Hydrogen and Neon, Claude Fable 5.2, and GPT-6.2 Astra and Sol have no probe evidence yet. A model with no probe evidence can serve plain chat but never a tool-required turn. +The repository ships 69 live performance profiles (three samples per model), 9 auditable historical seeds, 84 function-calling probe results, and a built-in snapshot of the 97 text models in the public catalog (2026-11-24 sync). Eleven newly listed models passed a real structured tool-call probe and are admitted as availability fallbacks for tool-required turns. DeepSeek V4 Flash Vision Experimental and Qwen 3.8 Flash did not return a valid tool call and remain fail-closed. GPT-6.1 Sol and DeepSeek V4.1 Flash also passed a structured tool-call probe in the subsequent capability refresh. Gemini 4 Carbon, added 2026-11-11 ahead of its gateway listing, returned its own next tool call through a two-round tool history on both the streaming and non-streaming gateway paths, so it is admitted as a tool fallback too. Kimi K3.1 Pro, which replaced Kimi K3 in every chain and affinity band on 2026-11-23, passed the live profile probe (three completions, no errors, a well-formed tool call); its reasoningMath affinity is measured on K3.1 Pro (paired against K3 on 50 MGSM rows on 2026-11-23: 41/50 vs 44/50 at a 512-token budget, every gap a truncation, 46/50 each when the truncated rows were rerun at 2,048 tokens), and it moves from 0.9 to 0.88. Its other affinity values are still carried over from K3, not measured on K3.1 Pro. On 2026-11-24 Gemini 3.6 Flash replaced Gemini 3.5 Flash, and GPT-5.4 Mini replaced o4-mini, in every chain and affinity band, when the gateways began redirecting the retired ids to them; 3.6 Flash's affinity values are carried over from 3.5 Flash (which Google had been answering with 3.6 since October), not measured on 3.6. On 2026-12-01 Gemini 3.5 Flash-Lite replaces Gemini 2.5 Flash, and Gemini 3.8 Flash replaces Gemini 2.5 Pro, the same way; 3.5 Flash-Lite's extraction and chat affinity is carried over from 2.5 Flash. On 2026-12-11, when OpenAI shuts down o3, GPT-5 Mini and GPT-5 Nano, GPT-5.4 Mini replaces o3 (whose two rungs sat directly behind it and are dropped) and GPT-5.6 Luna replaces GPT-5 Mini, including as the agentic MEDIUM primary; Luna's terminal, tool-agent and web-research affinity is carried over from GPT-5 Mini, a reasoning model, not measured on Luna, which runs without reasoning. Mistral Large 4, Gemini 4 Argon, Hydrogen and Neon, Claude Fable 5.2, and GPT-6.2 Astra and Sol have no probe evidence yet. A model with no probe evidence can serve plain chat but never a tool-required turn. Passing the function-call probe does **not** promote a model to primary. New tool-capable models are appended after the configured and trajectory-benchmarked candidate chains with neutral task affinity; they can recover an unavailable route immediately (cheapest first outside Premium), while primary promotion still requires an end-to-end agent evaluation. @@ -431,7 +431,7 @@ Omitted entries fall back to a weak historical prior rather than disqualifying a ```bash npm ci npm run typecheck # tsc --noEmit -npm test # vitest — 196 tests across 12 files +npm test # vitest — 197 tests across 12 files npm run build # tsup → dist/ npm run check # all three, and what CI runs diff --git a/dist/index.js b/dist/index.js index 97136a1..2b248e2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1669,6 +1669,19 @@ var DEFAULT_ROUTING_CONFIG = { // redirected model that would drop the image. // - google/gemini-2.5-pro -> google/gemini-3.8-flash ($0.75/$3.75), in // place. + // + // Retirements 2026-12-11 (OpenAI shuts down o3, gpt-5-mini and gpt-5-nano — + // developers.openai.com/api/docs/deprecations, notice 2026-06-11; the + // gateways redirect each and quote the successor): + // - openai/o3 -> openai/gpt-5.4-mini ($2/$8 -> $0.75/$4.50). Both o3 rungs + // (auto and premium REASONING) sat directly behind gpt-5.4-mini, so they + // are dropped by the dedupe rule; the order actually served is unchanged. + // - openai/gpt-5-mini -> openai/gpt-5.6-luna ($0.25/$2 -> $0.20/$1.20), in + // place as the agentic MEDIUM primary. Luna inherits gpt-5-mini's + // affinity values, CARRIED, not measured (portfolio.ts) — gpt-5-mini is a + // reasoning model and luna runs without reasoning, so those values are a + // placeholder until a Terminal-Bench/tau2 run on luna. + // - openai/gpt-5-nano -> openai/gpt-6-luna. In no chain. // Auto (balanced) tier configs - current default smart routing tiers: { SIMPLE: { @@ -1769,10 +1782,8 @@ var DEFAULT_ROUTING_CONFIG = { // $0.32/$1.28, 1M ctx — reasoning; needs a generous max_tokens (thinking is billed) "google/gemini-3.6-flash", // $0.75/$3.75 — 3.5 Flash's successor (MGSM 5/5 on 3.5, carried) - "openai/gpt-5.4-mini", - // $0.75/$4.50 — o4-mini's successor (o4-mini retired 2026-11-24) - "openai/o3" - // $2/$8 + "openai/gpt-5.4-mini" + // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung) ] } }, @@ -1960,10 +1971,8 @@ var DEFAULT_ROUTING_CONFIG = { // reasoning band 0.95 "xai/grok-4.3", // $1.50/$4 — xAI reasoning model - "openai/gpt-5.4-mini", - // $0.75/$4.50 — o4-mini's successor (o4-mini retired 2026-11-24) - "openai/o3" - // $2/$8 + "openai/gpt-5.4-mini" + // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung) ] } }, @@ -1984,10 +1993,12 @@ var DEFAULT_ROUTING_CONFIG = { ] }, MEDIUM: { - // Was moonshot/kimi-k2.7 (hidden 2026-08). GPT-5 Mini carries the - // Terminal-Bench and tau2 trajectory evidence in portfolio.ts. - primary: "openai/gpt-5-mini", - // $0.25/$2 — 4/7 Terminal-Bench, 5/6 tau2 airline + // Was moonshot/kimi-k2.7 (hidden 2026-08), then GPT-5 Mini — which + // carries the Terminal-Bench and tau2 trajectory evidence in + // portfolio.ts — until its 2026-12-11 retirement. GPT-5.6 Luna is what + // the gateways serve under that name from then on. + primary: "openai/gpt-5.6-luna", + // $0.20/$1.20, 1M ctx, vision + tools — gpt-5-mini's affinity (4/7 Terminal-Bench, 5/6 tau2 airline), carried fallback: [ "google/gemini-3.6-flash", // $0.75/$3.75 — tool_agent band 0.88 (3.5's, carried) @@ -3555,19 +3566,19 @@ var NEUTRAL_AFFINITY = 0.68; var TERMINAL_COMPLEX_HIGH = { "claude-sonnet-5": 1, "gpt-5.3-codex": 0.87, - "gpt-5-mini": 0.78, + "gpt-5.6-luna": 0.78, "gemini-3.6-flash": 0.76 }; var WEB_RESEARCH_DEEP = { "claude-sonnet-5": 1, - "gpt-5-mini": 0.88, + "gpt-5.6-luna": 0.88, "gemini-3.6-flash": 0.84, "claude-opus-5": 0.8, "claude-opus-4.8": 0.78 }; var WEB_RESEARCH = { "claude-sonnet-5": 1, - "gpt-5-mini": 0.88, + "gpt-5.6-luna": 0.88, "gemini-3.6-flash": 0.86, "claude-opus-5": 0.84, "claude-opus-4.8": 0.82 @@ -3576,11 +3587,11 @@ var RETAIL_POLICY_EXCEPTION = { "gpt-4.1": 1, "claude-sonnet-5": 0.9, "deepseek-v4-pro": 0.82, - "gpt-5-mini": 0.8, + "gpt-5.6-luna": 0.8, "gpt-4o-mini": 0.76 }; var RETAIL_POLICY_EXCEPTION_SIMPLE = { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "gpt-4.1": 0.86, "deepseek-v4-pro": 0.82, "gpt-4o-mini": 0.8 @@ -3597,7 +3608,7 @@ var AFFINITY = { codeAgent: { "gpt-5.3-codex": 1, "claude-sonnet-5": 0.98, - "gpt-5-mini": 0.96, + "gpt-5.6-luna": 0.96, "gemini-3.6-flash": 0.92, "kimi-k3.1-pro": 0.9, "deepseek-v4-pro": 0.88, @@ -3607,7 +3618,7 @@ var AFFINITY = { // over the prior dynamic choice. Codex/Sonnet are close fallbacks; actual // request cost breaks the tie. terminalTool: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "gpt-5.3-codex": 0.98, "claude-sonnet-5": 0.9, "gemini-3.6-flash": 0.89 @@ -3629,7 +3640,7 @@ var AFFINITY = { // arguments. DeepSeek V4 Pro completed all three high-risk retail calibration // trajectories (global-choice, cross-record, multi-write); Sonnet one. retailStandard: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "claude-sonnet-5": 0.88, "gemini-3.6-flash": 0.82, "gpt-5.3-codex": 0.81, @@ -3642,7 +3653,7 @@ var AFFINITY = { "gemini-3.6-flash": 0.82, "gpt-5.3-codex": 0.81, "kimi-k3.1-pro": 0.78, - "gpt-5-mini": 0.76 + "gpt-5.6-luna": 0.76 }, // Standard airline workflows stay on GPT-5 Mini: six full-session // development trajectories gave it the same 5/6 success as Sonnet at roughly @@ -3656,12 +3667,12 @@ var AFFINITY = { // roughly two orders of magnitude more on the long-tail case. airlineComplex: { "claude-sonnet-5": 1, - "gpt-5-mini": 0.78, + "gpt-5.6-luna": 0.78, "gemini-3.6-flash": 0.76, "deepseek-v4-pro": 0.74 }, airlineStandard: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "claude-sonnet-5": 0.9, "gemini-3.6-flash": 0.8, "deepseek-v4-pro": 0.76 @@ -3676,7 +3687,7 @@ var AFFINITY = { "gemini-3.6-flash": 0.88, "gpt-5.3-codex": 0.87, "kimi-k3.1-pro": 0.85, - "gpt-5-mini": 0.84, + "gpt-5.6-luna": 0.84, "deepseek-v4-pro": 0.82 }, // Multi-file Terminal work is not equivalent to a one-turn parallel @@ -3688,7 +3699,7 @@ var AFFINITY = { "gpt-5.3-codex": 0.86 }, parallelTerminal: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "gpt-5.3-codex": 0.98, "claude-sonnet-5": 0.92, "gemini-3.6-flash": 0.88 @@ -3697,17 +3708,17 @@ var AFFINITY = { "deepseek-v4-pro": 1, "claude-sonnet-5": 0.88, "claude-opus-4.8": 0.84, - "gpt-5-mini": 0.78, + "gpt-5.6-luna": 0.78, "gemini-3.6-flash": 0.76 }, parallelAirlineComplex: { "claude-sonnet-5": 1, - "gpt-5-mini": 0.78, + "gpt-5.6-luna": 0.78, "claude-opus-4.8": 0.76, "gemini-3.6-flash": 0.74 }, parallelAirline: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "claude-sonnet-5": 0.9, "gemini-3.6-flash": 0.8 }, @@ -3893,7 +3904,7 @@ function evidenceCandidates(task) { return [ "openai/gpt-5.3-codex", "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "moonshot/kimi-k3.1-pro", "deepseek/deepseek-v4-pro" @@ -3903,7 +3914,7 @@ function evidenceCandidates(task) { return [ "anthropic/claude-sonnet-5", "anthropic/claude-opus-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "google/gemini-3.6-flash", @@ -3917,7 +3928,7 @@ function evidenceCandidates(task) { "anthropic/claude-opus-5", "anthropic/claude-opus-4.8", "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "xai/grok-4.5", @@ -4101,7 +4112,7 @@ var PortfolioStrategy = class { const scoredModels = rankedEntries.map((item) => item.model); const webResearchFallbackOrder = [ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "anthropic/claude-opus-5", "anthropic/claude-opus-4.8", diff --git a/dist/index.js.map b/dist/index.js.map index d54ea60..e7e4d34 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/rules.ts","../src/selector.ts","../src/tokens.ts","../src/strategy.ts","../src/config.ts","../src/model-capabilities.ts","../src/model-profiles.generated.json","../src/model-profiles.ts","../src/tool-intent.ts","../src/portfolio.ts","../src/catalog.ts","../src/index.ts"],"sourcesContent":["/**\n * Rule-Based Classifier (v2 — Weighted Scoring)\n *\n * Scores a request across 15 weighted dimensions and maps the aggregate\n * score to a tier using configurable boundaries. Confidence is calibrated\n * via sigmoid — low confidence triggers the fallback classifier.\n *\n * Handles 70-80% of requests in < 1ms with zero cost.\n */\n\nimport type { Tier, ScoringResult, ScoringConfig } from \"./types.js\";\n\ntype DimensionScore = { name: string; score: number; signal: string | null };\n\n// ─── Keyword Matching ───\n//\n// A plain substring test counted `class` in \"classic\", `story` in \"history\",\n// `edit` in \"credit\" and `fix` in \"prefix\", so everyday prose picked up code,\n// creative and agentic signals it did not carry. Alphabetic keywords now have\n// to start at a word boundary. Short ASCII keywords additionally have to end\n// at one, after an optional inflection, graded by how much a stray suffix can\n// change the word: a three-letter keyword takes only the English endings that\n// cannot spell another word (fix → fixes, never pip → pipe or def → defer); a\n// four-to-six-letter keyword also takes the common German and Romance endings,\n// because the lists spell those languages in ASCII too (beweis → beweise,\n// klasse → klassen); anything longer stays trailing-open like the substring\n// test it replaces, since its false-positive surface is small and its\n// inflection surface is large. Non-ASCII alphabetic keywords keep a\n// trailing-open match because several are deliberate stems (`оптимизаци`,\n// `рассуждени`). CJK, Hangul and Arabic keywords keep the substring test:\n// those scripts have no word boundaries, or attach particles and articles\n// directly to the word.\n\nconst UNSEGMENTED_SCRIPT =\n /[؀-ۿ -ヿ㐀-䶿一-鿿가-힯豈-﫿＀-￯]/;\nconst WORD_CHAR = /[\\p{L}\\p{N}]/u;\nconst ASCII_PHRASE = /^[a-z0-9' -]+$/;\n// A word boundary is a transition out of the segmented scripts. A CJK\n// character next to a Latin keyword (\"请step by step证明\") is a boundary, not\n// part of the word: mixed-script prompts carry no spaces between scripts.\nconst SEGMENTED_WORD_CHAR = \"\\\\p{Script=Latin}\\\\p{Script=Cyrillic}\\\\p{Script=Greek}\\\\p{N}\";\nconst BOUNDARY_BEFORE = `(?();\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction keywordMatcher(keyword: string): KeywordMatcher {\n const cached = matcherCache.get(keyword);\n if (cached) return cached;\n\n const kw = keyword.toLowerCase();\n let matcher: KeywordMatcher;\n if (UNSEGMENTED_SCRIPT.test(kw) || kw.length === 0) {\n matcher = { needle: kw, pattern: null };\n } else {\n const lead = WORD_CHAR.test(kw[0]) ? BOUNDARY_BEFORE : \"\";\n const escaped = escapeRegExp(kw);\n let body = escaped;\n let trail = \"\";\n let needle = kw;\n const lastWord = kw.slice(kw.lastIndexOf(\" \") + 1);\n if (\n WORD_CHAR.test(kw[kw.length - 1]) &&\n ASCII_PHRASE.test(kw) &&\n lastWord.length <= BOUNDED_LAST_WORD_LENGTH\n ) {\n // ASCII phrases contain no regex metacharacters, so `escaped` slices\n // align with `kw` slices below.\n const forms: string[] = [];\n if (/\\d$/.test(kw)) {\n // \"step 1\" must not absorb \"step 10\".\n forms.push(escaped);\n } else if (lastWord.length <= 3) {\n forms.push(`${escaped}${SHORT_SUFFIXES}`);\n if (/(?:x|s|z|ch|sh)$/.test(kw)) forms.push(`${escaped}${SIBILANT_PLURAL}`);\n } else {\n forms.push(`${escaped}${MID_SUFFIXES}`);\n if (kw.endsWith(\"e\")) {\n forms.push(`${escaped.slice(0, -1)}${DROPPED_E_SUFFIXES}`);\n needle = kw.slice(0, -1);\n } else if (kw.endsWith(\"y\")) {\n forms.push(`${escaped.slice(0, -1)}(?:ies|ied)`);\n needle = kw.slice(0, -1);\n } else if (/[aeiou][bdgmnprt]$/.test(kw)) {\n // debug → debugging, plan → planned\n forms.push(`${escaped}${kw[kw.length - 1]}${DOUBLED_CONSONANT_SUFFIXES}`);\n }\n }\n body = `(?:${forms.join(\"|\")})`;\n trail = BOUNDARY_AFTER;\n }\n matcher = { needle, pattern: new RegExp(`${lead}${body}${trail}`, \"u\") };\n }\n matcherCache.set(keyword, matcher);\n return matcher;\n}\n\n/** Whether lower-cased `text` contains `keyword` as a word (or as a substring for CJK). */\nfunction matchesKeyword(text: string, keyword: string): boolean {\n const { needle, pattern } = keywordMatcher(keyword);\n if (!text.includes(needle)) return false;\n return pattern === null ? true : pattern.test(text);\n}\n\n// ─── Dimension Scorers ───\n// Each returns a score in [-1, 1] and an optional signal string.\n\nfunction scoreTokenCount(\n estimatedTokens: number,\n thresholds: { simple: number; complex: number },\n): DimensionScore {\n if (estimatedTokens < thresholds.simple) {\n return { name: \"tokenCount\", score: -1.0, signal: `short (${estimatedTokens} tokens)` };\n }\n if (estimatedTokens > thresholds.complex) {\n return { name: \"tokenCount\", score: 1.0, signal: `long (${estimatedTokens} tokens)` };\n }\n return { name: \"tokenCount\", score: 0, signal: null };\n}\n\nfunction scoreKeywordMatch(\n text: string,\n keywords: string[],\n name: string,\n signalLabel: string,\n thresholds: { low: number; high: number },\n scores: { none: number; low: number; high: number },\n): DimensionScore {\n const matches = keywords.filter((kw) => matchesKeyword(text, kw));\n if (matches.length >= thresholds.high) {\n return {\n name,\n score: scores.high,\n signal: `${signalLabel} (${matches.slice(0, 3).join(\", \")})`,\n };\n }\n if (matches.length >= thresholds.low) {\n return {\n name,\n score: scores.low,\n signal: `${signalLabel} (${matches.slice(0, 3).join(\", \")})`,\n };\n }\n return { name, score: scores.none, signal: null };\n}\n\nfunction scoreMultiStep(text: string): DimensionScore {\n // A numbered list item must start a line: a bare \"\\d\\.\\s\" also matched\n // every sentence that ends in a number (\"born in 1990. How old…\").\n const patterns = [/first.*then/i, /step \\d/i, /(?:^|\\n)\\s*\\d+[.)]\\s/];\n const hits = patterns.filter((p) => p.test(text));\n if (hits.length > 0) {\n return { name: \"multiStepPatterns\", score: 0.5, signal: \"multi-step\" };\n }\n return { name: \"multiStepPatterns\", score: 0, signal: null };\n}\n\nfunction scoreQuestionComplexity(prompt: string): DimensionScore {\n const count = (prompt.match(/[??]/g) || []).length;\n if (count > 3) {\n return { name: \"questionComplexity\", score: 0.5, signal: `${count} questions` };\n }\n return { name: \"questionComplexity\", score: 0, signal: null };\n}\n\n/**\n * Score agentic task indicators.\n * Returns agenticScore (0-1) based on keyword matches:\n * - 4+ matches = 1.0 (high agentic)\n * - 3 matches = 0.6 (moderate agentic, triggers auto-agentic mode)\n * - 1-2 matches = 0.2 (low agentic)\n *\n * Thresholds raised because common keywords were pruned from the list.\n */\nfunction scoreAgenticTask(\n text: string,\n keywords: string[],\n): { dimensionScore: DimensionScore; agenticScore: number } {\n let matchCount = 0;\n const signals: string[] = [];\n\n for (const keyword of keywords) {\n if (matchesKeyword(text, keyword)) {\n matchCount++;\n if (signals.length < 3) {\n signals.push(keyword);\n }\n }\n }\n\n // Threshold-based scoring (raised thresholds after keyword pruning)\n if (matchCount >= 4) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 1.0,\n signal: `agentic (${signals.join(\", \")})`,\n },\n agenticScore: 1.0,\n };\n } else if (matchCount >= 3) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 0.6,\n signal: `agentic (${signals.join(\", \")})`,\n },\n agenticScore: 0.6,\n };\n } else if (matchCount >= 1) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 0.2,\n signal: `agentic-light (${signals.join(\", \")})`,\n },\n agenticScore: 0.2,\n };\n }\n\n return {\n dimensionScore: { name: \"agenticTask\", score: 0, signal: null },\n agenticScore: 0,\n };\n}\n\n// ─── Main Classifier ───\n\nexport function classifyByRules(\n prompt: string,\n systemPrompt: string | undefined,\n estimatedTokens: number,\n config: ScoringConfig,\n): ScoringResult {\n // Score against user prompt only — system prompts contain boilerplate keywords\n // (tool definitions, skill descriptions, behavioral rules) that dominate scoring\n // and make every request score identically. See GitHub issue #50.\n const userText = prompt.toLowerCase();\n\n const reasoningDimension = scoreKeywordMatch(\n userText,\n config.reasoningKeywords,\n \"reasoningMarkers\",\n \"reasoning\",\n { low: 1, high: 2 },\n { none: 0, low: 0.7, high: 1.0 },\n );\n\n // Score the base dimensions against user text only; the agentic dimension is\n // appended below, so the scored total is one more than this list.\n const dimensions: DimensionScore[] = [\n // Token count uses total estimated tokens (system + user) — context size matters for model selection\n scoreTokenCount(estimatedTokens, config.tokenCountThresholds),\n scoreKeywordMatch(\n userText,\n config.codeKeywords,\n \"codePresence\",\n \"code\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 1.0 },\n ),\n reasoningDimension,\n scoreKeywordMatch(\n userText,\n config.technicalKeywords,\n \"technicalTerms\",\n \"technical\",\n { low: 2, high: 4 },\n { none: 0, low: 0.5, high: 1.0 },\n ),\n scoreKeywordMatch(\n userText,\n config.creativeKeywords,\n \"creativeMarkers\",\n \"creative\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.simpleKeywords,\n \"simpleIndicators\",\n \"simple\",\n { low: 1, high: 2 },\n { none: 0, low: -1.0, high: -1.0 },\n ),\n scoreMultiStep(userText),\n scoreQuestionComplexity(prompt),\n\n // 6 new dimensions\n scoreKeywordMatch(\n userText,\n config.imperativeVerbs,\n \"imperativeVerbs\",\n \"imperative\",\n { low: 1, high: 2 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.constraintIndicators,\n \"constraintCount\",\n \"constraints\",\n { low: 1, high: 3 },\n { none: 0, low: 0.3, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.outputFormatKeywords,\n \"outputFormat\",\n \"format\",\n { low: 1, high: 2 },\n { none: 0, low: 0.4, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.referenceKeywords,\n \"referenceComplexity\",\n \"references\",\n { low: 1, high: 2 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.negationKeywords,\n \"negationComplexity\",\n \"negation\",\n { low: 2, high: 3 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.domainSpecificKeywords,\n \"domainSpecificity\",\n \"domain-specific\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 0.8 },\n ),\n ];\n\n // Score agentic task indicators — user prompt only\n // System prompt describes assistant behavior, not user's intent.\n // e.g. a coding assistant system prompt with \"edit files\" / \"fix bugs\" should NOT\n // force every request into agentic mode.\n const agenticResult = scoreAgenticTask(userText, config.agenticTaskKeywords);\n dimensions.push(agenticResult.dimensionScore);\n const agenticScore = agenticResult.agenticScore;\n\n // Collect signals\n const signals = dimensions.filter((d) => d.signal !== null).map((d) => d.signal!);\n\n // Compute weighted score\n const weights = config.dimensionWeights;\n let weightedScore = 0;\n for (const d of dimensions) {\n const w = weights[d.name] ?? 0;\n weightedScore += d.score * w;\n }\n\n // Direct reasoning override: 2+ reasoning markers in the USER prompt = high\n // confidence REASONING. The system prompt is never read here, so a host\n // instruction like \"think step by step\" cannot lift every query to REASONING.\n // The reasoning dimension already counted those matches; its score is 1.0\n // exactly when two or more matched.\n if (reasoningDimension.score === 1.0) {\n const confidence = calibrateConfidence(\n Math.max(weightedScore, 0.3), // ensure positive for confidence calc\n config.confidenceSteepness,\n );\n return {\n score: weightedScore,\n tier: \"REASONING\",\n confidence: Math.max(confidence, 0.85),\n signals,\n agenticScore,\n dimensions,\n };\n }\n\n // Map weighted score to tier using boundaries\n const { simpleMedium, mediumComplex, complexReasoning } = config.tierBoundaries;\n let tier: Tier;\n let distanceFromBoundary: number;\n\n if (weightedScore < simpleMedium) {\n tier = \"SIMPLE\";\n distanceFromBoundary = simpleMedium - weightedScore;\n } else if (weightedScore < mediumComplex) {\n tier = \"MEDIUM\";\n distanceFromBoundary = Math.min(weightedScore - simpleMedium, mediumComplex - weightedScore);\n } else if (weightedScore < complexReasoning) {\n tier = \"COMPLEX\";\n distanceFromBoundary = Math.min(\n weightedScore - mediumComplex,\n complexReasoning - weightedScore,\n );\n } else {\n tier = \"REASONING\";\n distanceFromBoundary = weightedScore - complexReasoning;\n }\n\n // Calibrate confidence via sigmoid of distance from nearest boundary\n const confidence = calibrateConfidence(distanceFromBoundary, config.confidenceSteepness);\n\n // If confidence is below threshold → ambiguous\n if (confidence < config.confidenceThreshold) {\n return { score: weightedScore, tier: null, confidence, signals, agenticScore, dimensions };\n }\n\n return { score: weightedScore, tier, confidence, signals, agenticScore, dimensions };\n}\n\n/**\n * Sigmoid confidence calibration.\n * Maps distance from tier boundary to [0.5, 1.0] confidence range.\n */\nfunction calibrateConfidence(distance: number, steepness: number): number {\n return 1 / (1 + Math.exp(-steepness * distance));\n}\n","/**\n * Tier → Model Selection\n *\n * Maps a classification tier to the cheapest capable model.\n * Builds RoutingDecision metadata with cost estimates and savings.\n */\n\nimport type { Tier, TierConfig, RoutingDecision } from \"./types.js\";\n\nexport type ModelPricing = {\n inputPrice: number; // per 1M tokens\n outputPrice: number; // per 1M tokens\n /** Active promo flat price per request (overrides token-based pricing when set) */\n flatPrice?: number;\n};\n\n// The savings baseline is a price anchor, not \"the current flagship\" — it is\n// deliberately NOT bumped every time a new Opus ships. Opus 4.7, 4.8 and 5 all\n// bill $5/$25, so moving it would change no reported number while breaking\n// comparability with historical journal entries. Only move it if the Opus tier\n// itself is repriced.\nconst BASELINE_MODEL_ID = \"anthropic/claude-opus-4.7\";\n\n// Hardcoded fallback: Claude Opus 4.7 pricing (per 1M tokens)\n// Used when baseline model not found in dynamic pricing map\nconst BASELINE_INPUT_PRICE = 5.0;\nconst BASELINE_OUTPUT_PRICE = 25.0;\n\n/**\n * The pricing entry, or undefined when any field it carries is not a finite,\n * non-negative number. A hand-built price map with a NaN would otherwise put\n * NaN into costEstimate and savings; a malformed price is an unknown price.\n */\nexport function usablePricing(pricing: ModelPricing | undefined): ModelPricing | undefined {\n if (!pricing) return undefined;\n const ok = (value: number | undefined) =>\n value === undefined || (Number.isFinite(value) && value >= 0);\n if (pricing.flatPrice !== undefined) return ok(pricing.flatPrice) ? pricing : undefined;\n return ok(pricing.inputPrice) && ok(pricing.outputPrice) ? pricing : undefined;\n}\n\n/** Raw token cost (no margin, no floor), or the flat promo price when one is set. */\nfunction rawCost(\n pricing: ModelPricing | undefined,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n): number {\n if (pricing?.flatPrice !== undefined) return pricing.flatPrice;\n const inputPrice = pricing?.inputPrice ?? 0;\n const outputPrice = pricing?.outputPrice ?? 0;\n return (estimatedInputTokens / 1_000_000) * inputPrice + (maxOutputTokens / 1_000_000) * outputPrice;\n}\n\n/** What the anchor Opus tier would cost for the same request (see BASELINE_MODEL_ID). */\nfunction baselineCostFor(\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n): number {\n const opusPricing = usablePricing(modelPricing.get(BASELINE_MODEL_ID));\n const inputPrice = opusPricing?.inputPrice ?? BASELINE_INPUT_PRICE;\n const outputPrice = opusPricing?.outputPrice ?? BASELINE_OUTPUT_PRICE;\n return (estimatedInputTokens / 1_000_000) * inputPrice + (maxOutputTokens / 1_000_000) * outputPrice;\n}\n\n/**\n * Fractional savings against the baseline. Premium reports none (it is about\n * quality, not cost), and a model the host has no price for costs an unknown\n * amount, not nothing: reporting its savings as 100% would be a fabricated\n * figure.\n */\nfunction savingsFor(\n costEstimate: number,\n baselineCost: number,\n pricing: ModelPricing | undefined,\n routingProfile: string | undefined,\n): number {\n if (routingProfile === \"premium\" || pricing === undefined || !(baselineCost > 0)) return 0;\n return Math.max(0, (baselineCost - costEstimate) / baselineCost);\n}\n\n/**\n * Select the primary model for a tier and build the RoutingDecision.\n *\n * Cost contract: the estimates here are raw token economics — no server\n * margin, no minimum-payment floor. `calculateModelCost` below applies both\n * to match the actual x402 charge, and hosts that display money (ClawRouter's\n * proxy does) recompute through it rather than reading these fields. Folding\n * the margin in here would double-apply it in every such host.\n */\nexport function selectModel(\n tier: Tier,\n confidence: number,\n method: \"rules\" | \"llm\" | \"portfolio\",\n reasoning: string,\n tierConfigs: Record,\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n routingProfile?: \"free\" | \"eco\" | \"auto\" | \"premium\",\n agenticScore?: number,\n): RoutingDecision {\n const tierConfig = tierConfigs[tier];\n const model = tierConfig.primary;\n const pricing = usablePricing(modelPricing.get(model));\n\n const costEstimate = rawCost(pricing, estimatedInputTokens, maxOutputTokens);\n const baselineCost = baselineCostFor(modelPricing, estimatedInputTokens, maxOutputTokens);\n const savings = savingsFor(costEstimate, baselineCost, pricing, routingProfile);\n\n return {\n model,\n tier,\n confidence,\n method,\n reasoning,\n costEstimate,\n baselineCost,\n savings,\n ...(agenticScore !== undefined && { agenticScore }),\n };\n}\n\n/**\n * Get the ordered fallback chain for a tier: [primary, ...fallbacks].\n */\nexport function getFallbackChain(tier: Tier, tierConfigs: Record): string[] {\n const config = tierConfigs[tier];\n return [config.primary, ...config.fallback];\n}\n\n// Server-side margin applied to all x402 payments (must match blockrun server's MARGIN_PERCENT)\nconst SERVER_MARGIN_PERCENT = 5;\n// Minimum payment enforced by CDP Facilitator (must match blockrun server's MIN_PAYMENT_USD)\nconst MIN_PAYMENT_USD = 0.001;\n\n/**\n * Calculate charge-accurate cost fields for a specific model (server margin\n * and minimum-payment floor included — see the cost contract on selectModel).\n * Hosts call this to display money and to recost a decision after a fallback.\n */\nexport function calculateModelCost(\n model: string,\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n routingProfile?: \"free\" | \"eco\" | \"auto\" | \"premium\",\n): { costEstimate: number; baselineCost: number; savings: number } {\n const pricing = usablePricing(modelPricing.get(model));\n\n // Server margin + minimum payment, to match the actual x402 charge.\n const costEstimate = Math.max(\n rawCost(pricing, estimatedInputTokens, maxOutputTokens) * (1 + SERVER_MARGIN_PERCENT / 100),\n MIN_PAYMENT_USD,\n );\n const baselineCost = baselineCostFor(modelPricing, estimatedInputTokens, maxOutputTokens);\n const savings = savingsFor(costEstimate, baselineCost, pricing, routingProfile);\n\n return { costEstimate, baselineCost, savings };\n}\n\n/** The models satisfying `keep`, or every model when none does. */\nfunction keepOrFailOpen(models: string[], keep: (modelId: string) => boolean): string[] {\n const filtered = models.filter(keep);\n return filtered.length > 0 ? filtered : models;\n}\n\n/**\n * Filter a model list to only those that support tool calling.\n * When hasTools is false, returns the list unchanged.\n * When all models lack tool calling support, returns the full list as a fallback\n * (better to let the API error than produce an empty chain).\n */\nexport function filterByToolCalling(\n models: string[],\n hasTools: boolean,\n supportsToolCalling: (modelId: string) => boolean,\n): string[] {\n return hasTools ? keepOrFailOpen(models, supportsToolCalling) : models;\n}\n\n/**\n * Filter a model list to only those that support vision (image inputs).\n * When hasVision is false, returns the list unchanged.\n * When all models lack vision support, returns the full list as a fallback\n * (better to let the API error than produce an empty chain).\n */\nexport function filterByVision(\n models: string[],\n hasVision: boolean,\n supportsVision: (modelId: string) => boolean,\n): string[] {\n return hasVision ? keepOrFailOpen(models, supportsVision) : models;\n}\n\n/**\n * Filter a model list to remove user-excluded models.\n * When all models are excluded, returns the full list as a fallback\n * (same safety pattern as filterByToolCalling/filterByVision).\n */\nexport function filterByExcludeList(models: string[], excludeList: Set): string[] {\n if (excludeList.size === 0) return models;\n return keepOrFailOpen(models, (m) => !excludeList.has(m));\n}\n\n/**\n * Get the fallback chain filtered by context length.\n * Only returns models that can handle the estimated total context.\n *\n * @param tier - The tier to get fallback chain for\n * @param tierConfigs - Tier configurations\n * @param estimatedTotalTokens - Estimated total context (input + output)\n * @param getContextWindow - Function to get context window for a model ID\n * @returns Filtered list of models that can handle the context\n */\nexport function getFallbackChainFiltered(\n tier: Tier,\n tierConfigs: Record,\n estimatedTotalTokens: number,\n getContextWindow: (modelId: string) => number | undefined,\n): string[] {\n const fullChain = getFallbackChain(tier, tierConfigs);\n\n // Filter to models that can handle the context\n const filtered = fullChain.filter((modelId) => {\n const contextWindow = getContextWindow(modelId);\n if (contextWindow === undefined) {\n // Unknown model - include it (let API reject if needed)\n return true;\n }\n // Add 10% buffer for safety\n return contextWindow >= estimatedTotalTokens * 1.1;\n });\n\n // If all models filtered out, return the original chain\n // (let the API error out - better than no options)\n if (filtered.length === 0) {\n return fullChain;\n }\n\n return filtered;\n}\n\n/**\n * Filter an already-ranked candidate list by total context and requested output.\n * Unlike the legacy tier helper, this supports the V3 portfolio order.\n */\nexport function filterCandidatesByCapacity(\n models: string[],\n estimatedInputTokens: number,\n requestedOutputTokens: number,\n getCapabilities: (modelId: string) => { contextWindow: number; maxOutput: number } | undefined,\n): string[] {\n const filtered = models.filter((modelId) => {\n const capabilities = getCapabilities(modelId);\n if (!capabilities) return true;\n return (\n capabilities.contextWindow >= (estimatedInputTokens + requestedOutputTokens) * 1.1 &&\n capabilities.maxOutput >= requestedOutputTokens\n );\n });\n return filtered;\n}\n","/**\n * Request-size helpers shared by the rules and portfolio strategies.\n *\n * The router never tokenizes — it is on the hot path and model-agnostic — so\n * sizes are estimates. The estimate only has to be honest enough for the\n * decisions that consume it: the long-context task type, the COMPLEX\n * override and the per-model capacity filter.\n */\n\n// Han, kana, Hangul, CJK punctuation and fullwidth forms. Every production\n// tokenizer spends roughly one token per character here, so the Latin\n// four-characters-per-token rule under-counts these scripts about fourfold:\n// a 200k-character Chinese contract would read as 50k tokens, slip under the\n// 80k long-context boundary and pass the capacity filter for models that\n// cannot hold it.\nconst CJK_CHARS = /[ -ヿ㐀-䶿一-鿿가-힯豈-﫿＀-￯]/g;\n\n/** Approximate token count: one per CJK character, one per four of anything else. */\nexport function estimateTokens(text: string): number {\n if (text.length === 0) return 0;\n const cjk = text.match(CJK_CHARS)?.length ?? 0;\n return cjk + Math.ceil((text.length - cjk) / 4);\n}\n\nconst MAX_SCAN_CHARS = 8_000;\n\n/** The scan window the feature regexes read, bounded so a pasted document cannot stall routing. */\nexport function scanLimit(promptTruncationChars: number): number {\n if (!Number.isFinite(promptTruncationChars)) return MAX_SCAN_CHARS;\n return Math.max(1, Math.min(MAX_SCAN_CHARS, Math.floor(promptTruncationChars)));\n}\n\n\n/**\n * Feature regexes need request shape and intent, not the entire document.\n * Sample both ends so a long pasted artifact keeps the task instruction at\n * either boundary, while the full length still drives capacity decisions.\n */\nexport function sampleForScan(value: string, limit: number): string {\n if (value.length <= limit) return value;\n const prefixLength = Math.ceil(limit / 2);\n const suffixLength = limit - prefixLength;\n // slice(-0) is the whole string, so a one-character limit needs its own case.\n if (suffixLength <= 0) return value.slice(0, prefixLength);\n return `${value.slice(0, prefixLength)}\\n${value.slice(-suffixLength)}`;\n}\n","/**\n * Router Strategy Registry\n *\n * Pluggable strategy system for request routing.\n * Default: RulesStrategy — identical to the original inline route() logic, <1ms.\n */\n\nimport type {\n Tier,\n TierConfig,\n Promotion,\n RoutingDecision,\n RouterStrategy,\n RouterOptions,\n} from \"./types.js\";\nimport { classifyByRules } from \"./rules.js\";\nimport { selectModel } from \"./selector.js\";\nimport { estimateTokens, sampleForScan, scanLimit } from \"./tokens.js\";\n\n/**\n * Apply active time-windowed promotions to tier configs.\n * Returns a new tierConfigs object with promotion overrides merged in.\n * Expired or not-yet-active promotions are ignored.\n */\nfunction applyPromotions(\n tierConfigs: Record,\n promotions: Promotion[] | undefined,\n profile: \"auto\" | \"eco\" | \"premium\" | \"agentic\",\n now: Date = new Date(),\n): Record {\n if (!promotions || promotions.length === 0) return tierConfigs;\n\n let result = tierConfigs;\n for (const promo of promotions) {\n // Check time window\n // An unparseable date compares false both ways, which used to make the\n // promotion active forever. A window that cannot be read is not a window.\n const start = Date.parse(promo.startDate);\n const end = Date.parse(promo.endDate);\n if (!Number.isFinite(start) || !Number.isFinite(end)) continue;\n if (now.getTime() < start || now.getTime() >= end) continue;\n\n // Check profile filter\n if (promo.profiles && !promo.profiles.includes(profile)) continue;\n\n // Shallow-clone on first mutation\n if (result === tierConfigs) {\n result = { ...tierConfigs };\n for (const t of Object.keys(result) as Tier[]) {\n result[t] = { ...result[t] };\n }\n }\n\n // Merge overrides\n for (const [tier, override] of Object.entries(promo.tierOverrides) as [\n Tier,\n Partial,\n ][]) {\n if (!result[tier]) continue;\n if (override.primary) result[tier].primary = override.primary;\n if (override.fallback) result[tier].fallback = override.fallback;\n }\n }\n\n return result;\n}\n\n/**\n * Remove host-declared-dead models from every tier chain, promoting the first\n * surviving rung to primary. A tier whose chain is entirely dead keeps its\n * original config — the router has nothing live to offer there, and inventing\n * a model would hide the outage from the host that reported it.\n */\nexport function applyUnavailableModels(\n tierConfigs: Record,\n unavailableModels: readonly string[] | undefined,\n): Record {\n if (!unavailableModels || unavailableModels.length === 0) return tierConfigs;\n const dead = new Set(unavailableModels);\n let result = tierConfigs;\n for (const tier of Object.keys(tierConfigs) as Tier[]) {\n const config = tierConfigs[tier];\n const alive = [config.primary, ...config.fallback].filter((model) => !dead.has(model));\n if (alive.length === 0 || (alive[0] === config.primary && alive.length === config.fallback.length + 1)) {\n continue;\n }\n if (result === tierConfigs) result = { ...tierConfigs };\n result[tier] = { primary: alive[0], fallback: alive.slice(1) };\n }\n return result;\n}\n\n/**\n * Rules-based routing strategy.\n * Extracted from the original route() in index.ts — logic is identical.\n * Attaches tierConfigs and profile to the decision for downstream use.\n */\nexport class RulesStrategy implements RouterStrategy {\n readonly name = \"rules\";\n\n route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n ): RoutingDecision {\n const { config, modelPricing } = options;\n\n const fullText = `${systemPrompt ?? \"\"} ${prompt}`;\n const estimatedTokens = estimateTokens(fullText);\n const limit = scanLimit(config.classifier.promptTruncationChars);\n const scannedPrompt = sampleForScan(prompt, limit);\n const scannedSystemPrompt = systemPrompt ? sampleForScan(systemPrompt, limit) : undefined;\n\n // --- Rule-based classification (runs first to get agenticScore) ---\n const ruleResult = classifyByRules(\n scannedPrompt,\n scannedSystemPrompt,\n estimatedTokens,\n config.scoring,\n );\n\n // --- Select tier configs based on routing profile ---\n const { routingProfile } = options;\n let tierConfigs: Record;\n let profileSuffix: string;\n let profile: NonNullable;\n\n if (routingProfile === \"eco\") {\n // `ecoTiers: null` explicitly disables the special eco tier set while\n // keeping eco routing semantics. Fall back to regular tiers instead of\n // dropping into auto routing (which could select agentic tiers).\n tierConfigs = config.ecoTiers ?? config.tiers;\n profileSuffix = config.ecoTiers ? \" | eco\" : \" | eco (default tiers)\";\n profile = \"eco\";\n } else if (routingProfile === \"premium\") {\n // `premiumTiers: null` disables the premium-specific tier set but the\n // request is still a premium-profile request, so use regular tiers while\n // preserving premium metadata/cost semantics.\n tierConfigs = config.premiumTiers ?? config.tiers;\n profileSuffix = config.premiumTiers ? \" | premium\" : \" | premium (default tiers)\";\n profile = \"premium\";\n } else {\n // Auto profile (or undefined): intelligent routing with agentic detection.\n //\n // `agenticMode` semantics:\n // - `true` → force agentic tiers (ignore heuristics)\n // - `false` → disable agentic tiers entirely (even if tools are present)\n // - `undefined` → auto-detect via heuristics (tools present OR high agenticScore)\n const agenticScore = ruleResult.agenticScore ?? 0;\n const isAutoAgentic = agenticScore >= 0.5;\n const agenticModeSetting = config.overrides.agenticMode;\n const hasToolsInRequest = options.requiresTools ?? options.hasTools ?? false;\n let useAgenticTiers: boolean;\n if (agenticModeSetting === false) {\n // Explicitly disabled — never use agentic tiers\n useAgenticTiers = false;\n } else if (agenticModeSetting === true) {\n // Explicitly enabled — use agentic tiers if available\n useAgenticTiers = config.agenticTiers != null;\n } else {\n // Auto-detect\n useAgenticTiers = (hasToolsInRequest || isAutoAgentic) && config.agenticTiers != null;\n }\n tierConfigs = useAgenticTiers ? config.agenticTiers! : config.tiers;\n profileSuffix = useAgenticTiers ? ` | agentic${hasToolsInRequest ? \" (tools)\" : \"\"}` : \"\";\n profile = useAgenticTiers ? \"agentic\" : \"auto\";\n }\n\n // Apply time-windowed promotions\n tierConfigs = applyPromotions(tierConfigs, config.promotions, profile, options.now);\n\n // Hard-remove models the host has observed dead at the gateway. After\n // promotions, so a promo cannot resurrect a rung the host just killed.\n tierConfigs = applyUnavailableModels(tierConfigs, options.unavailableModels);\n\n const agenticScoreValue = ruleResult.agenticScore;\n\n // --- Override: large context → force COMPLEX ---\n if (estimatedTokens > config.overrides.maxTokensForceComplex) {\n const decision = selectModel(\n \"COMPLEX\",\n 0.95,\n \"rules\",\n `Input exceeds ${config.overrides.maxTokensForceComplex} tokens${profileSuffix}`,\n tierConfigs,\n modelPricing,\n estimatedTokens,\n maxOutputTokens,\n routingProfile,\n agenticScoreValue,\n );\n return { ...decision, tierConfigs, profile };\n }\n\n // Structured output is a protocol fact the host states (`response_format`\n // → requiresStructuredOutput). It used to be inferred from the system\n // prompt as well, but agent hosts describe their tool schemas there on\n // every turn, which upgraded every one of their requests off SIMPLE.\n const hasStructuredOutput = options.requiresStructuredOutput === true;\n\n let tier: Tier;\n let confidence: number;\n const method: \"rules\" | \"llm\" = \"rules\";\n let reasoning = `score=${ruleResult.score.toFixed(2)} | ${ruleResult.signals.join(\", \")}`;\n\n if (ruleResult.tier !== null) {\n tier = ruleResult.tier;\n confidence = ruleResult.confidence;\n } else {\n // Ambiguous — default to configurable tier (no external API call)\n tier = config.overrides.ambiguousDefaultTier;\n confidence = 0.5;\n reasoning += ` | ambiguous -> default: ${tier}`;\n }\n\n // Apply structured output minimum tier\n if (hasStructuredOutput) {\n const tierRank: Record = { SIMPLE: 0, MEDIUM: 1, COMPLEX: 2, REASONING: 3 };\n const minTier = config.overrides.structuredOutputMinTier;\n if (tierRank[tier] < tierRank[minTier]) {\n reasoning += ` | upgraded to ${minTier} (structured output)`;\n tier = minTier;\n }\n }\n\n // Add routing profile suffix to reasoning\n reasoning += profileSuffix;\n\n const decision = selectModel(\n tier,\n confidence,\n method,\n reasoning,\n tierConfigs,\n modelPricing,\n estimatedTokens,\n maxOutputTokens,\n routingProfile,\n agenticScoreValue,\n );\n return { ...decision, tierConfigs, profile };\n }\n}\n\n// --- Strategy Registry ---\n\nconst registry = new Map();\nregistry.set(\"rules\", new RulesStrategy());\n\nexport function getStrategy(name: string): RouterStrategy {\n const strategy = registry.get(name);\n if (!strategy) {\n throw new Error(`Unknown routing strategy: ${name}`);\n }\n return strategy;\n}\n\nexport function registerStrategy(strategy: RouterStrategy): void {\n registry.set(strategy.name, strategy);\n}\n","/**\n * Default Routing Config\n *\n * All routing parameters as a TypeScript constant.\n * Operators override via openclaw.yaml plugin config.\n *\n * Scoring uses 15 weighted dimensions with sigmoid confidence calibration.\n */\n\nimport type { RoutingConfig } from \"./types.js\";\n\nexport const DEFAULT_ROUTING_CONFIG: RoutingConfig = {\n version: \"3.5\",\n strategy: \"portfolio\",\n portfolio: {\n auto: {\n quality: 0.47,\n capability: 0.2,\n cost: 0.18,\n speed: 0.07,\n reliability: 0.03,\n legacy: 0.05,\n },\n eco: {\n quality: 0.36,\n capability: 0.2,\n cost: 0.28,\n speed: 0.1,\n reliability: 0.04,\n legacy: 0.02,\n },\n premium: {\n quality: 0.58,\n capability: 0.2,\n cost: 0.08,\n speed: 0.06,\n reliability: 0.06,\n legacy: 0.02,\n },\n highStakesBoost: { quality: 0.08, reliability: 0.05 },\n latencySensitiveSpeedBoost: 0.08,\n affinityFloorGap: { auto: 0.1, eco: 0.22, premium: 0.05 },\n },\n\n classifier: {\n // gemini-2.5-flash until Google retired it on 2026-12-01 (the gateways\n // redirect it to 3.5 Flash-Lite). Nothing in this package or ClawRouter\n // reads llmModel today. Before wiring it, note that 3.5 Flash-Lite always\n // thinks (it rejects a thinking budget of 0), so llmMaxTokens 10 may be\n // spent on reasoning before any label is emitted.\n llmModel: \"google/gemini-3.5-flash-lite\",\n llmMaxTokens: 10,\n llmTemperature: 0,\n promptTruncationChars: 500,\n cacheTtlMs: 3_600_000, // 1 hour\n },\n\n scoring: {\n tokenCountThresholds: { simple: 50, complex: 500 },\n\n // Multilingual keywords: EN + ZH + JA + RU + DE + ES + PT + KO + AR\n codeKeywords: [\n // English\n \"function\",\n \"class\",\n \"import\",\n \"def\",\n \"SELECT\",\n \"async\",\n \"await\",\n \"const\",\n \"let\",\n \"var\",\n \"return\",\n \"```\",\n // Chinese\n \"函数\",\n \"类\",\n \"导入\",\n \"定义\",\n \"查询\",\n \"异步\",\n \"等待\",\n \"常量\",\n \"变量\",\n \"返回\",\n // Japanese\n \"関数\",\n \"クラス\",\n \"インポート\",\n \"非同期\",\n \"定数\",\n \"変数\",\n // Russian\n \"функция\",\n \"класс\",\n \"импорт\",\n \"определ\",\n \"запрос\",\n \"асинхронный\",\n \"ожидать\",\n \"константа\",\n \"переменная\",\n \"вернуть\",\n // German\n \"funktion\",\n \"klasse\",\n \"importieren\",\n \"definieren\",\n \"abfrage\",\n \"asynchron\",\n \"erwarten\",\n \"konstante\",\n \"variable\",\n \"zurückgeben\",\n // Spanish\n \"función\",\n \"clase\",\n \"importar\",\n \"definir\",\n \"consulta\",\n \"asíncrono\",\n \"esperar\",\n \"constante\",\n \"variable\",\n \"retornar\",\n // Portuguese\n \"função\",\n \"classe\",\n \"importar\",\n \"definir\",\n \"consulta\",\n \"assíncrono\",\n \"aguardar\",\n \"constante\",\n \"variável\",\n \"retornar\",\n // Korean\n \"함수\",\n \"클래스\",\n \"가져오기\",\n \"정의\",\n \"쿼리\",\n \"비동기\",\n \"대기\",\n \"상수\",\n \"변수\",\n \"반환\",\n // Arabic\n \"دالة\",\n \"فئة\",\n \"استيراد\",\n \"تعريف\",\n \"استعلام\",\n \"غير متزامن\",\n \"انتظار\",\n \"ثابت\",\n \"متغير\",\n \"إرجاع\",\n ],\n reasoningKeywords: [\n // English\n \"prove\",\n \"theorem\",\n \"derive\",\n \"step by step\",\n \"chain of thought\",\n \"formally\",\n \"mathematical\",\n \"proof\",\n \"logically\",\n // Chinese\n \"证明\",\n \"定理\",\n \"推导\",\n \"逐步\",\n \"思维链\",\n \"形式化\",\n \"数学\",\n \"逻辑\",\n // Japanese\n \"証明\",\n \"定理\",\n \"導出\",\n \"ステップバイステップ\",\n \"論理的\",\n // Russian\n \"доказать\",\n \"докажи\",\n \"доказательств\",\n \"теорема\",\n \"вывести\",\n \"шаг за шагом\",\n \"пошагово\",\n \"поэтапно\",\n \"цепочка рассуждений\",\n \"рассуждени\",\n \"формально\",\n \"математически\",\n \"логически\",\n // German\n \"beweisen\",\n \"beweis\",\n \"theorem\",\n \"ableiten\",\n \"schritt für schritt\",\n \"gedankenkette\",\n \"formal\",\n \"mathematisch\",\n \"logisch\",\n // Spanish\n \"demostrar\",\n \"teorema\",\n \"derivar\",\n \"paso a paso\",\n \"cadena de pensamiento\",\n \"formalmente\",\n \"matemático\",\n \"prueba\",\n \"lógicamente\",\n // Portuguese\n \"provar\",\n \"teorema\",\n \"derivar\",\n \"passo a passo\",\n \"cadeia de pensamento\",\n \"formalmente\",\n \"matemático\",\n \"prova\",\n \"logicamente\",\n // Korean\n \"증명\",\n \"정리\",\n \"도출\",\n \"단계별\",\n \"사고의 연쇄\",\n \"형식적\",\n \"수학적\",\n \"논리적\",\n // Arabic\n \"إثبات\",\n \"نظرية\",\n \"اشتقاق\",\n \"خطوة بخطوة\",\n \"سلسلة التفكير\",\n \"رسمياً\",\n \"رياضي\",\n \"برهان\",\n \"منطقياً\",\n ],\n simpleKeywords: [\n // English\n \"what is\",\n \"define\",\n \"translate\",\n \"hello\",\n \"yes or no\",\n \"capital of\",\n \"how old\",\n \"who is\",\n \"when was\",\n // Chinese\n \"什么是\",\n \"定义\",\n \"翻译\",\n \"你好\",\n \"是否\",\n \"首都\",\n \"多大\",\n \"谁是\",\n \"何时\",\n // Japanese\n \"とは\",\n \"定義\",\n \"翻訳\",\n \"こんにちは\",\n \"はいかいいえ\",\n \"首都\",\n \"誰\",\n // Russian\n \"что такое\",\n \"определение\",\n \"перевести\",\n \"переведи\",\n \"привет\",\n \"да или нет\",\n \"столица\",\n \"сколько лет\",\n \"кто такой\",\n \"когда\",\n \"объясни\",\n // German\n \"was ist\",\n \"definiere\",\n \"übersetze\",\n \"hallo\",\n \"ja oder nein\",\n \"hauptstadt\",\n \"wie alt\",\n \"wer ist\",\n \"wann\",\n \"erkläre\",\n // Spanish\n \"qué es\",\n \"definir\",\n \"traducir\",\n \"hola\",\n \"sí o no\",\n \"capital de\",\n \"cuántos años\",\n \"quién es\",\n \"cuándo\",\n // Portuguese\n \"o que é\",\n \"definir\",\n \"traduzir\",\n \"olá\",\n \"sim ou não\",\n \"capital de\",\n \"quantos anos\",\n \"quem é\",\n \"quando\",\n // Korean\n \"무엇\",\n \"정의\",\n \"번역\",\n \"안녕하세요\",\n \"예 또는 아니오\",\n \"수도\",\n \"누구\",\n \"언제\",\n // Arabic\n \"ما هو\",\n \"تعريف\",\n \"ترجم\",\n \"مرحبا\",\n \"نعم أو لا\",\n \"عاصمة\",\n \"من هو\",\n \"متى\",\n ],\n technicalKeywords: [\n // English\n \"algorithm\",\n \"optimize\",\n \"architecture\",\n \"distributed\",\n \"kubernetes\",\n \"microservice\",\n \"database\",\n \"infrastructure\",\n // Chinese\n \"算法\",\n \"优化\",\n \"架构\",\n \"分布式\",\n \"微服务\",\n \"数据库\",\n \"基础设施\",\n // Japanese\n \"アルゴリズム\",\n \"最適化\",\n \"アーキテクチャ\",\n \"分散\",\n \"マイクロサービス\",\n \"データベース\",\n // Russian\n \"алгоритм\",\n \"оптимизировать\",\n \"оптимизаци\",\n \"оптимизируй\",\n \"архитектура\",\n \"распределённый\",\n \"микросервис\",\n \"база данных\",\n \"инфраструктура\",\n // German\n \"algorithmus\",\n \"optimieren\",\n \"architektur\",\n \"verteilt\",\n \"kubernetes\",\n \"mikroservice\",\n \"datenbank\",\n \"infrastruktur\",\n // Spanish\n \"algoritmo\",\n \"optimizar\",\n \"arquitectura\",\n \"distribuido\",\n \"microservicio\",\n \"base de datos\",\n \"infraestructura\",\n // Portuguese\n \"algoritmo\",\n \"otimizar\",\n \"arquitetura\",\n \"distribuído\",\n \"microsserviço\",\n \"banco de dados\",\n \"infraestrutura\",\n // Korean\n \"알고리즘\",\n \"최적화\",\n \"아키텍처\",\n \"분산\",\n \"마이크로서비스\",\n \"데이터베이스\",\n \"인프라\",\n // Arabic\n \"خوارزمية\",\n \"تحسين\",\n \"بنية\",\n \"موزع\",\n \"خدمة مصغرة\",\n \"قاعدة بيانات\",\n \"بنية تحتية\",\n ],\n creativeKeywords: [\n // English\n \"story\",\n \"poem\",\n \"compose\",\n \"brainstorm\",\n \"creative\",\n \"imagine\",\n \"write a\",\n // Chinese\n \"故事\",\n \"诗\",\n \"创作\",\n \"头脑风暴\",\n \"创意\",\n \"想象\",\n \"写一个\",\n // Japanese\n \"物語\",\n \"詩\",\n \"作曲\",\n \"ブレインストーム\",\n \"創造的\",\n \"想像\",\n // Russian\n \"история\",\n \"рассказ\",\n \"стихотворение\",\n \"сочинить\",\n \"сочини\",\n \"мозговой штурм\",\n \"творческий\",\n \"представить\",\n \"придумай\",\n \"напиши\",\n // German\n \"geschichte\",\n \"gedicht\",\n \"komponieren\",\n \"brainstorming\",\n \"kreativ\",\n \"vorstellen\",\n \"schreibe\",\n \"erzählung\",\n // Spanish\n \"historia\",\n \"poema\",\n \"componer\",\n \"lluvia de ideas\",\n \"creativo\",\n \"imaginar\",\n \"escribe\",\n // Portuguese\n \"história\",\n \"poema\",\n \"compor\",\n \"criativo\",\n \"imaginar\",\n \"escreva\",\n // Korean\n \"이야기\",\n \"시\",\n \"작곡\",\n \"브레인스토밍\",\n \"창의적\",\n \"상상\",\n \"작성\",\n // Arabic\n \"قصة\",\n \"قصيدة\",\n \"تأليف\",\n \"عصف ذهني\",\n \"إبداعي\",\n \"تخيل\",\n \"اكتب\",\n ],\n\n // New dimension keyword lists (multilingual)\n imperativeVerbs: [\n // English\n \"build\",\n \"create\",\n \"implement\",\n \"design\",\n \"develop\",\n \"construct\",\n \"generate\",\n \"deploy\",\n \"configure\",\n \"set up\",\n // Chinese\n \"构建\",\n \"创建\",\n \"实现\",\n \"设计\",\n \"开发\",\n \"生成\",\n \"部署\",\n \"配置\",\n \"设置\",\n // Japanese\n \"構築\",\n \"作成\",\n \"実装\",\n \"設計\",\n \"開発\",\n \"生成\",\n \"デプロイ\",\n \"設定\",\n // Russian\n \"построить\",\n \"построй\",\n \"создать\",\n \"создай\",\n \"реализовать\",\n \"реализуй\",\n \"спроектировать\",\n \"разработать\",\n \"разработай\",\n \"сконструировать\",\n \"сгенерировать\",\n \"сгенерируй\",\n \"развернуть\",\n \"разверни\",\n \"настроить\",\n \"настрой\",\n // German\n \"erstellen\",\n \"bauen\",\n \"implementieren\",\n \"entwerfen\",\n \"entwickeln\",\n \"konstruieren\",\n \"generieren\",\n \"bereitstellen\",\n \"konfigurieren\",\n \"einrichten\",\n // Spanish\n \"construir\",\n \"crear\",\n \"implementar\",\n \"diseñar\",\n \"desarrollar\",\n \"generar\",\n \"desplegar\",\n \"configurar\",\n // Portuguese\n \"construir\",\n \"criar\",\n \"implementar\",\n \"projetar\",\n \"desenvolver\",\n \"gerar\",\n \"implantar\",\n \"configurar\",\n // Korean\n \"구축\",\n \"생성\",\n \"구현\",\n \"설계\",\n \"개발\",\n \"배포\",\n \"설정\",\n // Arabic\n \"بناء\",\n \"إنشاء\",\n \"تنفيذ\",\n \"تصميم\",\n \"تطوير\",\n \"توليد\",\n \"نشر\",\n \"إعداد\",\n ],\n constraintIndicators: [\n // English\n \"under\",\n \"at most\",\n \"at least\",\n \"within\",\n \"no more than\",\n \"o(\",\n \"maximum\",\n \"minimum\",\n \"limit\",\n \"budget\",\n // Chinese\n \"不超过\",\n \"至少\",\n \"最多\",\n \"在内\",\n \"最大\",\n \"最小\",\n \"限制\",\n \"预算\",\n // Japanese\n \"以下\",\n \"最大\",\n \"最小\",\n \"制限\",\n \"予算\",\n // Russian\n \"не более\",\n \"не менее\",\n \"как минимум\",\n \"в пределах\",\n \"максимум\",\n \"минимум\",\n \"ограничение\",\n \"бюджет\",\n // German\n \"höchstens\",\n \"mindestens\",\n \"innerhalb\",\n \"nicht mehr als\",\n \"maximal\",\n \"minimal\",\n \"grenze\",\n \"budget\",\n // Spanish\n \"como máximo\",\n \"al menos\",\n \"dentro de\",\n \"no más de\",\n \"máximo\",\n \"mínimo\",\n \"límite\",\n \"presupuesto\",\n // Portuguese\n \"no máximo\",\n \"pelo menos\",\n \"dentro de\",\n \"não mais que\",\n \"máximo\",\n \"mínimo\",\n \"limite\",\n \"orçamento\",\n // Korean\n \"이하\",\n \"이상\",\n \"최대\",\n \"최소\",\n \"제한\",\n \"예산\",\n // Arabic\n \"على الأكثر\",\n \"على الأقل\",\n \"ضمن\",\n \"لا يزيد عن\",\n \"أقصى\",\n \"أدنى\",\n \"حد\",\n \"ميزانية\",\n ],\n outputFormatKeywords: [\n // English\n \"json\",\n \"yaml\",\n \"xml\",\n \"table\",\n \"csv\",\n \"markdown\",\n \"schema\",\n \"format as\",\n \"structured\",\n // Chinese\n \"表格\",\n \"格式化为\",\n \"结构化\",\n // Japanese\n \"テーブル\",\n \"フォーマット\",\n \"構造化\",\n // Russian\n \"таблица\",\n \"форматировать как\",\n \"структурированный\",\n // German\n \"tabelle\",\n \"formatieren als\",\n \"strukturiert\",\n // Spanish\n \"tabla\",\n \"formatear como\",\n \"estructurado\",\n // Portuguese\n \"tabela\",\n \"formatar como\",\n \"estruturado\",\n // Korean\n \"테이블\",\n \"형식\",\n \"구조화\",\n // Arabic\n \"جدول\",\n \"تنسيق\",\n \"منظم\",\n ],\n referenceKeywords: [\n // English\n \"above\",\n \"below\",\n \"previous\",\n \"following\",\n \"the docs\",\n \"the api\",\n \"the code\",\n \"earlier\",\n \"attached\",\n // Chinese\n \"上面\",\n \"下面\",\n \"之前\",\n \"接下来\",\n \"文档\",\n \"代码\",\n \"附件\",\n // Japanese\n \"上記\",\n \"下記\",\n \"前の\",\n \"次の\",\n \"ドキュメント\",\n \"コード\",\n // Russian\n \"выше\",\n \"ниже\",\n \"предыдущий\",\n \"следующий\",\n \"документация\",\n \"код\",\n \"ранее\",\n \"вложение\",\n // German\n \"oben\",\n \"unten\",\n \"vorherige\",\n \"folgende\",\n \"dokumentation\",\n \"der code\",\n \"früher\",\n \"anhang\",\n // Spanish\n \"arriba\",\n \"abajo\",\n \"anterior\",\n \"siguiente\",\n \"documentación\",\n \"el código\",\n \"adjunto\",\n // Portuguese\n \"acima\",\n \"abaixo\",\n \"anterior\",\n \"seguinte\",\n \"documentação\",\n \"o código\",\n \"anexo\",\n // Korean\n \"위\",\n \"아래\",\n \"이전\",\n \"다음\",\n \"문서\",\n \"코드\",\n \"첨부\",\n // Arabic\n \"أعلاه\",\n \"أدناه\",\n \"السابق\",\n \"التالي\",\n \"الوثائق\",\n \"الكود\",\n \"مرفق\",\n ],\n negationKeywords: [\n // English\n \"don't\",\n \"do not\",\n \"avoid\",\n \"never\",\n \"without\",\n \"except\",\n \"exclude\",\n \"no longer\",\n // Chinese\n \"不要\",\n \"避免\",\n \"从不\",\n \"没有\",\n \"除了\",\n \"排除\",\n // Japanese\n \"しないで\",\n \"避ける\",\n \"決して\",\n \"なしで\",\n \"除く\",\n // Russian\n \"не делай\",\n \"не надо\",\n \"нельзя\",\n \"избегать\",\n \"никогда\",\n \"без\",\n \"кроме\",\n \"исключить\",\n \"больше не\",\n // German\n \"nicht\",\n \"vermeide\",\n \"niemals\",\n \"ohne\",\n \"außer\",\n \"ausschließen\",\n \"nicht mehr\",\n // Spanish\n \"no hagas\",\n \"evitar\",\n \"nunca\",\n \"sin\",\n \"excepto\",\n \"excluir\",\n // Portuguese\n \"não faça\",\n \"evitar\",\n \"nunca\",\n \"sem\",\n \"exceto\",\n \"excluir\",\n // Korean\n \"하지 마\",\n \"피하다\",\n \"절대\",\n \"없이\",\n \"제외\",\n // Arabic\n \"لا تفعل\",\n \"تجنب\",\n \"أبداً\",\n \"بدون\",\n \"باستثناء\",\n \"استبعاد\",\n ],\n domainSpecificKeywords: [\n // English\n \"quantum\",\n \"fpga\",\n \"vlsi\",\n \"risc-v\",\n \"asic\",\n \"photonics\",\n \"genomics\",\n \"proteomics\",\n \"topological\",\n \"homomorphic\",\n \"zero-knowledge\",\n \"lattice-based\",\n // Chinese\n \"量子\",\n \"光子学\",\n \"基因组学\",\n \"蛋白质组学\",\n \"拓扑\",\n \"同态\",\n \"零知识\",\n \"格密码\",\n // Japanese\n \"量子\",\n \"フォトニクス\",\n \"ゲノミクス\",\n \"トポロジカル\",\n // Russian\n \"квантовый\",\n \"фотоника\",\n \"геномика\",\n \"протеомика\",\n \"топологический\",\n \"гомоморфный\",\n \"с нулевым разглашением\",\n \"на основе решёток\",\n // German\n \"quanten\",\n \"photonik\",\n \"genomik\",\n \"proteomik\",\n \"topologisch\",\n \"homomorph\",\n \"zero-knowledge\",\n \"gitterbasiert\",\n // Spanish\n \"cuántico\",\n \"fotónica\",\n \"genómica\",\n \"proteómica\",\n \"topológico\",\n \"homomórfico\",\n // Portuguese\n \"quântico\",\n \"fotônica\",\n \"genômica\",\n \"proteômica\",\n \"topológico\",\n \"homomórfico\",\n // Korean\n \"양자\",\n \"포토닉스\",\n \"유전체학\",\n \"위상\",\n \"동형\",\n // Arabic\n \"كمي\",\n \"ضوئيات\",\n \"جينوميات\",\n \"طوبولوجي\",\n \"تماثلي\",\n ],\n\n // Agentic task keywords - file ops, execution, multi-step, iterative work\n // Pruned: removed overly common words like \"then\", \"first\", \"run\", \"test\", \"build\"\n agenticTaskKeywords: [\n // English - File operations (clearly agentic)\n \"read file\",\n \"read the file\",\n \"look at\",\n \"check the\",\n \"open the\",\n \"edit\",\n \"modify\",\n \"update the\",\n \"change the\",\n \"write to\",\n \"create file\",\n // English - Execution (specific commands only)\n \"execute\",\n \"deploy\",\n \"install\",\n \"npm\",\n \"pip\",\n \"compile\",\n // English - Multi-step patterns (specific only)\n \"after that\",\n \"and also\",\n \"once done\",\n \"step 1\",\n \"step 2\",\n // English - Iterative work\n \"fix\",\n \"debug\",\n \"until it works\",\n \"keep trying\",\n \"iterate\",\n \"make sure\",\n \"verify\",\n \"confirm\",\n // Chinese (keep specific ones)\n \"读取文件\",\n \"查看\",\n \"打开\",\n \"编辑\",\n \"修改\",\n \"更新\",\n \"创建\",\n \"执行\",\n \"部署\",\n \"安装\",\n \"第一步\",\n \"第二步\",\n \"修复\",\n \"调试\",\n \"直到\",\n \"确认\",\n \"验证\",\n // Spanish\n \"leer archivo\",\n \"editar\",\n \"modificar\",\n \"actualizar\",\n \"ejecutar\",\n \"desplegar\",\n \"instalar\",\n \"paso 1\",\n \"paso 2\",\n \"arreglar\",\n \"depurar\",\n \"verificar\",\n // Portuguese\n \"ler arquivo\",\n \"editar\",\n \"modificar\",\n \"atualizar\",\n \"executar\",\n \"implantar\",\n \"instalar\",\n \"passo 1\",\n \"passo 2\",\n \"corrigir\",\n \"depurar\",\n \"verificar\",\n // Korean\n \"파일 읽기\",\n \"편집\",\n \"수정\",\n \"업데이트\",\n \"실행\",\n \"배포\",\n \"설치\",\n \"단계 1\",\n \"단계 2\",\n \"디버그\",\n \"확인\",\n // Arabic\n \"قراءة ملف\",\n \"تحرير\",\n \"تعديل\",\n \"تحديث\",\n \"تنفيذ\",\n \"نشر\",\n \"تثبيت\",\n \"الخطوة 1\",\n \"الخطوة 2\",\n \"إصلاح\",\n \"تصحيح\",\n \"تحقق\",\n ],\n\n // Dimension weights (sum to 1.0)\n dimensionWeights: {\n tokenCount: 0.08,\n codePresence: 0.15,\n reasoningMarkers: 0.18,\n technicalTerms: 0.1,\n creativeMarkers: 0.05,\n simpleIndicators: 0.02, // Reduced from 0.12 to make room for agenticTask\n multiStepPatterns: 0.12,\n questionComplexity: 0.05,\n imperativeVerbs: 0.03,\n constraintCount: 0.04,\n outputFormat: 0.03,\n referenceComplexity: 0.02,\n negationComplexity: 0.01,\n domainSpecificity: 0.02,\n agenticTask: 0.04, // Reduced - agentic signals influence tier selection, not dominate it\n },\n\n // Tier boundaries on weighted score axis\n tierBoundaries: {\n simpleMedium: 0.0,\n mediumComplex: 0.3, // Raised from 0.18 - prevent simple tasks from reaching expensive COMPLEX tier\n complexReasoning: 0.5, // Raised from 0.4 - reserve for true reasoning tasks\n },\n\n // Sigmoid steepness for confidence calibration\n confidenceSteepness: 12,\n // Below this confidence → ambiguous (null tier)\n confidenceThreshold: 0.7,\n },\n\n // ─── Tier chains ───\n //\n // Catalog refresh 2026-08-29 (V3.5). Every chain below names only models\n // the public catalog lists (GET https://blockrun.ai/api/v1/models). Ids the\n // gateway withholds (`hidden: true`) — kimi-k2.5/k2.6/k2.7, the grok-4-fast\n // and grok-4-1-fast pairs, grok-4-0709, claude-opus-4.6, gemini-3-pro-preview,\n // the whole `free/*` namespace — were removed everywhere, including fallback\n // rungs, so a routed model is always one a user can find on blockrun.ai/models.\n //\n // Primaries moved only where portfolio.ts already carries calibration\n // evidence for the successor (Sonnet 5 over Sonnet 4.6, GPT-5 Mini for\n // agentic MEDIUM, Gemini 3.5 Flash where Kimi K2.7 was). Newcomers with no\n // trajectory evidence yet (gemini-3.6-flash, glm-5.3, glm-5.3-flash,\n // gpt-5.6-luna, grok-4.3, minimax-m3, qwen3.7-plus) enter as fallback rungs;\n // promotion waits for a calibration run, because version recency is not a\n // quality signal.\n //\n // Latency figures in comments are the 2026-08-29 gateway probe\n // (model-profiles.generated.json); prices are the catalog list.\n //\n // Retirements 2026-11-24 (owner-approved; the gateways redirect each id\n // before pricing, so a stale name here is a silent model swap, not an error):\n // - google/gemini-3.5-flash -> google/gemini-3.6-flash. Google has served\n // 3.6 Flash under the 3.5 name since ~2026-10-10. Each 3.5 rung now names\n // 3.6 at the same position; where 3.6 already sat in the same chain, the\n // later of the two is dropped, so the order of the models actually served\n // is unchanged. 3.6 inherits 3.5's affinity values, carried, not measured\n // (portfolio.ts).\n // - openai/o4-mini (and o1, o3-mini) -> openai/gpt-5.4-mini, at the same\n // position. Dead at OpenAI since 2026-10-23 and on Azure since 2026-11-19.\n //\n // Retirements 2026-12-01 (Google retires Gemini 2.5; the gateways redirect):\n // - google/gemini-2.5-flash -> google/gemini-3.5-flash-lite (same\n // $0.30/$2.50), in place, with the same dedupe rule. 3.5 Flash-Lite has\n // no vision tag where 2.5 Flash had one, so a SIMPLE vision turn now\n // falls past it to the next vision-capable rung instead of reaching a\n // redirected model that would drop the image.\n // - google/gemini-2.5-pro -> google/gemini-3.8-flash ($0.75/$3.75), in\n // place.\n\n // Auto (balanced) tier configs - current default smart routing\n tiers: {\n SIMPLE: {\n // Was google/gemini-2.5-flash (60% retention, best, in the 2026-03 run)\n // until its 2026-12-01 retirement. 3.5 Flash-Lite is what the gateways\n // serve under that name from then on; it was this chain's second\n // fallback and is dropped there.\n primary: \"google/gemini-3.5-flash-lite\", // $0.30/$2.50, 1M ctx, thinking mode, no vision\n fallback: [\n \"google/gemini-3-flash-preview\", // $0.50/$3 — GPQA 5/6 in the 2026-07 calibration\n \"deepseek/deepseek-chat\", // $0.14/$0.28, 1M ctx\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50, 1M ctx\n \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx — GPT-5.6 cost tier (cut 2026-07-30)\n \"openai/gpt-5.4-nano\", // $0.20/$1.25, 1M ctx\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n \"nvidia/nemotron-3.5-lightning\", // FREE backstop — NVIDIA free tier (probed 2026-08-30)\n ],\n },\n MEDIUM: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then Gemini 3.5 Flash — the\n // calibrated successor (MGSM 5/5, GPQA 4/6, extraction band) — until its\n // 2026-11-24 retirement. 3.6 Flash is what Google served under that name\n // since ~10-10; it was this chain's first fallback and is dropped there.\n primary: \"google/gemini-3.6-flash\", // $0.75/$3.75, 1M ctx, vision + tools — 3.5's affinity, carried\n fallback: [\n \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools verified live 2026-08-27\n \"openai/gpt-5.6-terra\", // $2/$12, 1M ctx — GPT-5.6 balanced tier\n \"google/gemini-3-flash-preview\", // $0.50/$3\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n \"minimax/minimax-m3\", // $0.30/$1.20, 1M ctx\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"openai/gpt-5.6-luna\", // $0.20/$1.20\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n ],\n },\n COMPLEX: {\n primary: \"google/gemini-3.1-pro\", // $2/$12 — proven long-context flagship (portfolio.ts long_context lead)\n fallback: [\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — Pro-level quality at Flash price (Google's claim); also 3.5 Flash's successor (3.5 retired 2026-11-24 and was the next rung)\n \"anthropic/claude-sonnet-5\", // $3/$15 — near-Opus quality, tau2 + Terminal-Bench calibrated\n \"xai/grok-4.5\", // $2.50/$9 — 503-resistant, independent infra (was grok-4-0709, now hidden)\n \"google/gemini-3.8-flash\", // $0.75/$3.75 — 2.5 Pro's successor (retired 2026-12-01)\n \"anthropic/claude-sonnet-4.6\", // $3/$15\n \"openai/gpt-5.6-terra\", // $2/$12 — GPT-5.6 balanced tier (Sol excluded: #202)\n \"openai/gpt-5.5\", // $5/$30 — prior OpenAI flagship\n \"openai/gpt-5.4\", // $2.50/$15 — previous flagship, benchmarked\n \"zai/glm-5.3\", // $1.40/$4.40, 1M ctx, always-on thinking — verified live 2026-08-19\n \"moonshot/kimi-k3.1-pro\", // $2/$10, 1M ctx — Moonshot flagship (K3 successor)\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87 — strongest open-weight reasoner\n \"deepseek/deepseek-chat\", // $0.14/$0.28 — cheap last resort\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n REASONING: {\n // Was xai/grok-4-1-fast-reasoning ($0.20/$0.50, hidden 2026-08). DeepSeek\n // Reasoner is the cheapest listed reasoner at the same 1M context.\n primary: \"deepseek/deepseek-reasoner\", // $0.14/$0.28, 1M ctx\n fallback: [\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87 — calibrated reasoning band 0.95\n \"xai/grok-4.3\", // $1.50/$4, 1M ctx — xAI reasoning model, vision\n \"qwen/qwen3.7-plus\", // $0.32/$1.28, 1M ctx — reasoning; needs a generous max_tokens (thinking is billed)\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — 3.5 Flash's successor (MGSM 5/5 on 3.5, carried)\n \"openai/gpt-5.4-mini\", // $0.75/$4.50 — o4-mini's successor (o4-mini retired 2026-11-24)\n \"openai/o3\", // $2/$8\n ],\n },\n },\n\n // Eco tier configs - absolute cheapest (blockrun/eco)\n ecoTiers: {\n SIMPLE: {\n primary: \"nvidia/nemotron-3.5-lightning\", // FREE — NVIDIA free tier flagship, 1M ctx\n fallback: [\n // Was nvidia/nemotron-3-nano-30b until blockrun delisted it on 2026-09-08\n // (NVIDIA deprovisioned it for the account — a structured per-account\n // 404). nano-omni is blockrun's own redirect target for that id, so this\n // follows the same rule as the head: the router and the gateway name the\n // same model.\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\", // FREE — nano-30b's successor, 256K ctx\n // The free head keeps rotting with NVIDIA's hosting (deepseek-v4-flash\n // 410 2026-08-12, seed-oss-36b 410 2026-08-03, gpt-oss-120b/20b 400\n // 2026-08-21, and on 2026-08-30 FOUR of the five visible free models at\n // once — step-3.7-flash, nemotron-nano-9b-v2 and nemotron-nano-12b-v2-vl\n // all 410, mistral-nemotron hung). Each retirement retargets the two\n // free rungs to the current free tier; the paid rungs below never move.\n // The head follows blockrun's own redirect of the model it replaces, so\n // the router and the gateway never name different models.\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40 — cheapest paid rung\n \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools\n \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx\n \"openai/gpt-5.4-nano\", // $0.20/$1.25\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n ],\n },\n MEDIUM: {\n primary: \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools verified live — cheapest full-capability model\n fallback: [\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"openai/gpt-5.6-luna\", // $0.20/$1.20\n \"openai/gpt-5.4-nano\", // $0.20/$1.25\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n COMPLEX: {\n primary: \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx\n fallback: [\n \"deepseek/deepseek-chat\", // $0.14/$0.28, 1M ctx\n \"minimax/minimax-m3\", // $0.30/$1.20, 1M ctx\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n REASONING: {\n primary: \"deepseek/deepseek-reasoner\", // $0.14/$0.28, 1M ctx — cheapest listed reasoner\n fallback: [\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87\n \"qwen/qwen3.7-plus\", // $0.32/$1.28 — reasoning\n \"minimax/minimax-m3\", // $0.30/$1.20 — reasoning + coding\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — reasoning tokens alongside content\n ],\n },\n },\n\n // Premium tier configs - best quality (blockrun/premium)\n // codex=complex coding, flash=simple coding, sonnet=reasoning/instructions, fable/opus=architecture/PM/audits\n premiumTiers: {\n SIMPLE: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then Gemini 3.5 Flash until\n // its 2026-11-24 retirement; 3.6 Flash was the first fallback and is\n // dropped there.\n primary: \"google/gemini-3.6-flash\", // $0.75/$3.75, 1M ctx, vision + tools — 3.5's affinity, carried\n fallback: [\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"zai/glm-5.3\", // $1.40/$4.40, 1M ctx\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — written where 2.5 Flash sat (retired 2026-12-01); the duplicate after it is dropped\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n ],\n },\n MEDIUM: {\n primary: \"openai/gpt-5.3-codex\", // $1.75/$14 - 400K context, 128K output — code_edit/debug lead (portfolio.ts)\n fallback: [\n \"anthropic/claude-sonnet-5\", // $3/$15 — code_agent band 0.98\n \"moonshot/kimi-k3.1-pro\", // $2/$10, 1M ctx — Moonshot flagship\n \"zai/glm-5.3\", // $1.40/$4.40 — long-horizon coding\n \"google/gemini-3.6-flash\", // $0.75/$3.75 (3.5 Flash, the next rung, retired 2026-11-24)\n \"google/gemini-3.8-flash\", // $0.75/$3.75 — 2.5 Pro's successor (retired 2026-12-01)\n \"xai/grok-4.5\", // $2.50/$9\n \"anthropic/claude-sonnet-4.6\", // $3/$15\n \"openai/gpt-5.6-terra\", // $2/$12\n ],\n },\n COMPLEX: {\n // fable-5 was promoted here 2026-06-11, force-reverted 2026-06-13 when Anthropic\n // withdrew the offer, and restored 2026-07-14 now that BlockRun has relisted it.\n primary: \"anthropic/claude-fable-5\", // Best quality for complex tasks — Mythos-class flagship above Opus ($10/$50, 1M ctx, always-on thinking)\n // Fallback chain de-Gemini'd 2026-04-22: when Anthropic 503s, Gemini is\n // also prone to \"high demand\" 503s (correlated failure — everyone falls\n // back to Google at the same time). Prefer in-family → xAI → Moonshot →\n // OpenAI flagship → Z.AI → DeepSeek → NVIDIA free instead.\n fallback: [\n \"anthropic/claude-opus-5\", // in-family hot swap first (half the price, 1M ctx + adaptive thinking)\n \"anthropic/claude-opus-4.8\", // in-family hot swap (identical cost to 5)\n \"anthropic/claude-opus-4.7\", // in-family hot swap (identical cost to 4.8)\n \"anthropic/claude-sonnet-5\", // Sonnet-tier drop-down, near-Opus quality\n \"anthropic/claude-sonnet-4.6\",\n \"xai/grok-4.5\", // xAI flagship — 503-resistant, direct-xAI SKU\n \"moonshot/kimi-k3.1-pro\", // Moonshot flagship, independent infra\n \"openai/gpt-5.6-terra\", // GPT-5.6 balanced tier — stable (Sol excluded: #202)\n \"openai/gpt-5.5\", // Prior OpenAI flagship — 1M+ ctx, native agent + computer use\n \"openai/gpt-5.4\", // Previous flagship (slow but stable, benchmarked at 6,213ms)\n \"openai/gpt-5.3-codex\",\n \"zai/glm-5.3\", // Z.AI flagship, 1M ctx\n \"deepseek/deepseek-v4-pro\", // strongest open-weight reasoner\n \"deepseek/deepseek-chat\", // Cheap, reliable\n \"nvidia/nemotron-3.5-lightning\", // NVIDIA free ultimate backstop\n ],\n },\n REASONING: {\n // Sonnet 5 promoted over Sonnet 4.6 (same price; reasoning band 0.98 for both,\n // plus Sonnet 5's tau2/BrowseComp trajectory evidence).\n primary: \"anthropic/claude-sonnet-5\", // $3/$15, 1M ctx, adaptive thinking\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus w/ adaptive thinking\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus w/ adaptive thinking\n \"xai/grok-4.5\", // reasoning band 0.94\n \"deepseek/deepseek-v4-pro\", // reasoning band 0.95\n \"xai/grok-4.3\", // $1.50/$4 — xAI reasoning model\n \"openai/gpt-5.4-mini\", // $0.75/$4.50 — o4-mini's successor (o4-mini retired 2026-11-24)\n \"openai/o3\", // $2/$8\n ],\n },\n },\n\n // Agentic tier configs - models that excel at multi-step autonomous tasks\n agenticTiers: {\n SIMPLE: {\n primary: \"openai/gpt-4o-mini\", // $0.15/$0.60 - best tool compliance at lowest cost\n fallback: [\n \"openai/gpt-5.6-luna\", // $0.20/$1.20 — lightweight agentic tier of GPT-5.6\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — tool calls verified live 2026-08-27\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n MEDIUM: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08). GPT-5 Mini carries the\n // Terminal-Bench and tau2 trajectory evidence in portfolio.ts.\n primary: \"openai/gpt-5-mini\", // $0.25/$2 — 4/7 Terminal-Bench, 5/6 tau2 airline\n fallback: [\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — tool_agent band 0.88 (3.5's, carried)\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — tools verified\n \"openai/gpt-5.6-terra\", // $2/$12\n \"openai/gpt-4o-mini\", // $0.15/$0.60 — reliable tool calling\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"moonshot/kimi-k3.1-pro\", // $2/$10 — tool_agent band 0.85\n ],\n },\n COMPLEX: {\n // Sonnet 5 promoted over Sonnet 4.6: tau2 airline + retail reward 1.0,\n // Terminal-Bench safety band lead (portfolio.ts).\n primary: \"anthropic/claude-sonnet-5\", // $3/$15 — best agentic quality per trajectory evidence\n // Fallback chain de-Gemini'd 2026-04-22: Gemini's \"high demand\" 503s\n // correlate with Anthropic outages (everyone falls back together).\n // Prefer 503-resistant providers first.\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus — in-family hot swap\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus — in-family hot swap\n \"xai/grok-4.5\", // xAI flagship — strong tool use, independent infra\n \"moonshot/kimi-k3.1-pro\", // Moonshot flagship — independent infra\n \"openai/gpt-5.6-terra\", // GPT-5.6 balanced tier — stable (Sol excluded: #202)\n \"openai/gpt-5.5\", // Prior flagship — native agent + computer use (exactly the agentic-tier use case)\n \"openai/gpt-5.4\", // Previous flagship — reliable\n \"openai/gpt-5.3-codex\", // code_agent lead\n \"zai/glm-5.3\", // long-horizon coding\n \"deepseek/deepseek-v4-pro\", // retail high-risk 3/3\n \"deepseek/deepseek-chat\", // cheap, reliable\n \"nvidia/nemotron-3.5-lightning\", // NVIDIA free ultimate backstop\n ],\n },\n REASONING: {\n primary: \"anthropic/claude-sonnet-5\", // $3/$15 — strong tool use + adaptive thinking\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus w/ adaptive thinking\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus w/ adaptive thinking\n \"xai/grok-4.5\", // reasoning band 0.94\n \"deepseek/deepseek-v4-pro\", // reasoning band 0.95\n \"deepseek/deepseek-reasoner\", // $0.14/$0.28\n ],\n },\n },\n\n // Time-windowed promotions — auto-applied when active, ignored when expired.\n // The GLM-5.1 launch promo (2026-04-01 → 2026-05-01) was the last entry and\n // has expired; the list is kept empty so the mechanism stays wired.\n promotions: [],\n\n overrides: {\n maxTokensForceComplex: 100_000,\n structuredOutputMinTier: \"MEDIUM\",\n ambiguousDefaultTier: \"MEDIUM\",\n // agenticMode left undefined → auto-detect via tools/agenticScore.\n // Set to `true` to force agentic tiers; `false` to disable them entirely.\n },\n};\n","/**\n * Model capabilities used for hard routing constraints.\n *\n * Hosts may inject fresher values through RouterOptions.modelCapabilities.\n * Keeping a small built-in snapshot makes the core safe and useful when a\n * product catalog is temporarily unavailable, without importing product code.\n *\n * GENERATED by scripts/sync-model-capabilities.mjs from the public catalog\n * (GET https://blockrun.ai/api/v1/models) on 2026-11-24; supportsTools comes\n * from a live function-calling probe (scripts/probe-tools.json). Regenerate\n * rather than editing by hand — a hand edit is overwritten on the next sync.\n */\nexport type ModelCapabilities = {\n contextWindow: number;\n maxOutputTokens: number;\n supportsTools: boolean;\n supportsVision: boolean;\n};\n\nexport const DEFAULT_MODEL_CAPABILITIES: Readonly> =\n Object.freeze({\n \"anthropic/claude-fable-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-fable-5.1\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-fable-5.2\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"anthropic/claude-haiku-4.5\": { // override: The public catalog's `categories` omit \"vision\" for this Anthropic model even though the gateway accepts image input for it (the prior hand-maintained snapshot had it, and Anthropic's model card lists it). Without this the vision filter would silently drop it — reported against the catalog; remove once the categories carry vision.\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.5\": {\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.7\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.8\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-5.5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-4.5\": {\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-4.6\": { // override: The public catalog's `categories` omit \"vision\" for this Anthropic model even though the gateway accepts image input for it (the prior hand-maintained snapshot had it, and Anthropic's model card lists it). Without this the vision filter would silently drop it — reported against the catalog; remove once the categories carry vision.\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-5.5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"cohere/north-mini-code\": { // supportsTools: not probed — fails closed\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"deepseek/deepseek-chat\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-chat \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-reasoner\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-reasoner \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-v4-flash-vision-exp\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"deepseek/deepseek-v4-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-v4.1-flash\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-v4.1-flash \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-2.5-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-2.5-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-2.5-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3-flash-preview\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.1-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-3.1-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.5-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.5-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-3.6-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.8-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-4-argon\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"google/gemini-4-carbon\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-4-hydrogen\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"google/gemini-4-neon\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"minimax/minimax-m2.7\": {\n contextWindow: 204_800,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"minimax/minimax-m3\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"mistral/mistral-large-4\": { // supportsTools: not probed — fails closed\n contextWindow: 524_288,\n maxOutputTokens: 262_144,\n supportsTools: false,\n supportsVision: true,\n },\n \"moonshot/kimi-k3.1-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"nvidia/minimax-m3.1-flash\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/muse-glimmer-30b\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\": { // override: The catalog tags this model \"vision\", but a correctly sized probe does not hold up (ClawRouter, 2026-08-31): a 64x64 solid-red PNG was named correctly 1 of 4 times on Base, and on Solana the image was silently dropped and a text model answered \"white\". An HTTP 200 with a confident wrong answer gives the caller nothing to branch on, so image turns must not be routed here. It is ecoTiers.SIMPLE.fallback[0] since nemotron-3-nano-30b was delisted (2026-09-08); remove once a probe of this size comes back right on both chains.\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3-super-120b\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: true,\n },\n \"nvidia/nemotron-3-ultra-550b\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3.5-bolt\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: true,\n },\n \"nvidia/nemotron-3.5-lightning\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"openai/chat-latest\": {\n contextWindow: 128_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4.1\": {\n contextWindow: 128_000,\n maxOutputTokens: 32_768,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4.1-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 32_768,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-4o\": {\n contextWindow: 128_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4o-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5-mini\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.1\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.2\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.2-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.3-codex\": { // supportsTools: gateway unavailable at probe time — fails closed; override: 2026-08-29 probe: every request (6 plain + 3 tool attempts) returned a gateway 500, so the probe measured an incident, not the model. Codex's function calling is established by the 2026-07 Terminal-Bench / tau2 calibration trajectories in portfolio.ts. Hosts observing the 500s should drop it with RouterOptions.unavailableModels rather than this snapshot claiming the model cannot call tools.\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.4\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.4-mini\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.4-nano\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.4-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.5\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.5-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.6-luna\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-luna-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.6-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-sol-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-terra\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-terra-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-astra\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-luna\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6.1-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6.2-astra\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-6.2-sol\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/o1\": {\n contextWindow: 200_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o3\": {\n contextWindow: 200_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o3-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o4-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"poolside/laguna-s-2.1\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: false,\n },\n \"poolside/laguna-xs-2.1\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"qwen/qwen3.7-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.7-max\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.7-plus\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.8-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: true,\n },\n \"qwen/qwen3.8-max\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: false,\n },\n \"tencent/hy4-preview\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 64_000,\n supportsTools: false,\n supportsVision: false,\n },\n \"xai/grok-4.3\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.5\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.6\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.7\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-build-0.1\": {\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"xiaomi/mimo-v2.5\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: true,\n },\n \"xiaomi/mimo-v2.5-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5-turbo\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.1\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.2\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.3\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.3-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: true,\n },\n });\n","{\n \"anthropic/claude-fable-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9298.5,\n \"p95LatencyMs\": 9873.4,\n \"outputTokensPerSecond\": 55.17,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-haiku-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3157.4,\n \"p95LatencyMs\": 3170.7,\n \"outputTokensPerSecond\": 162.16,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6497.7,\n \"p95LatencyMs\": 6953.7,\n \"outputTokensPerSecond\": 78.99,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.7\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5316.5,\n \"p95LatencyMs\": 6121.5,\n \"outputTokensPerSecond\": 97.34,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.8\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6216.1,\n \"p95LatencyMs\": 6847.7,\n \"outputTokensPerSecond\": 82.81,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7309,\n \"p95LatencyMs\": 7745.2,\n \"outputTokensPerSecond\": 70.17,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6330.4,\n \"p95LatencyMs\": 6631.6,\n \"outputTokensPerSecond\": 81.03,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-4.6\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6508,\n \"p95LatencyMs\": 6698.3,\n \"outputTokensPerSecond\": 78.6,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6165.4,\n \"p95LatencyMs\": 6582.9,\n \"outputTokensPerSecond\": 83.62,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-chat\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4351.4,\n \"p95LatencyMs\": 4543.7,\n \"outputTokensPerSecond\": 117.78,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-reasoner\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5201.2,\n \"p95LatencyMs\": 6079.6,\n \"outputTokensPerSecond\": 99.77,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-v4-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 8781.2,\n \"p95LatencyMs\": 9881.1,\n \"outputTokensPerSecond\": 58.98,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-v4.1-flash\": {\n \"measuredAt\": \"2026-10-20T18:12:51Z\",\n \"latencyMs\": 2383.5,\n \"p95LatencyMs\": 2547.8,\n \"outputTokensPerSecond\": 216.53,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5416.4,\n \"p95LatencyMs\": 6442.8,\n \"outputTokensPerSecond\": 213.07,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5002.6,\n \"p95LatencyMs\": 5780.3,\n \"outputTokensPerSecond\": 408.43,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 28169.5,\n \"p95LatencyMs\": 29491.4,\n \"outputTokensPerSecond\": 147.3,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3-flash-preview\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4717.1,\n \"p95LatencyMs\": 5037.1,\n \"outputTokensPerSecond\": 198.71,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.1-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2855.8,\n \"p95LatencyMs\": 3172.7,\n \"outputTokensPerSecond\": 286.91,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.1-pro\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 24194.1,\n \"p95LatencyMs\": 27269.6,\n \"outputTokensPerSecond\": 109.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.5-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5320.6,\n \"p95LatencyMs\": 5429.8,\n \"outputTokensPerSecond\": 226.21,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.5-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3515.8,\n \"p95LatencyMs\": 4363.4,\n \"outputTokensPerSecond\": 248.9,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.6-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 13020,\n \"p95LatencyMs\": 15383.1,\n \"outputTokensPerSecond\": 187.87,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"minimax/minimax-m2.7\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 8761.1,\n \"p95LatencyMs\": 10199.3,\n \"outputTokensPerSecond\": 59.18,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"minimax/minimax-m3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 11101.9,\n \"p95LatencyMs\": 26087.1,\n \"outputTokensPerSecond\": 101.12,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"moonshot/kimi-k3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 24498.9,\n \"p95LatencyMs\": 40365.3,\n \"outputTokensPerSecond\": 25.11,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"moonshot/kimi-k3.1-pro\": {\n \"measuredAt\": \"2026-11-23T20:18:18Z\",\n \"latencyMs\": 9243.1,\n \"p95LatencyMs\": 10504.1,\n \"outputTokensPerSecond\": 55.89,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"nvidia/mistral-nemotron\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7349.6,\n \"p95LatencyMs\": 9932.3,\n \"outputTokensPerSecond\": 79.48,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 9324.6,\n \"p95LatencyMs\": 12992,\n \"outputTokensPerSecond\": 64.96,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"nvidia/nemotron-nano-12b-v2-vl\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5846.9,\n \"p95LatencyMs\": 5846.9,\n \"outputTokensPerSecond\": 87.57,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"nvidia/nemotron-nano-9b-v2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5282.5,\n \"p95LatencyMs\": 5282.5,\n \"outputTokensPerSecond\": 96.92,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"nvidia/step-3.7-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4617.4,\n \"p95LatencyMs\": 5237.4,\n \"outputTokensPerSecond\": 112.92,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"openai/chat-latest\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3690.9,\n \"p95LatencyMs\": 4344,\n \"outputTokensPerSecond\": 111.85,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3527.9,\n \"p95LatencyMs\": 3831.7,\n \"outputTokensPerSecond\": 141.27,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4268.2,\n \"p95LatencyMs\": 5101.5,\n \"outputTokensPerSecond\": 103.42,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1-nano\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3088.3,\n \"p95LatencyMs\": 3369.2,\n \"outputTokensPerSecond\": 150.31,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4o\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2995.2,\n \"p95LatencyMs\": 3174.2,\n \"outputTokensPerSecond\": 171.32,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4o-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4751.5,\n \"p95LatencyMs\": 4930.4,\n \"outputTokensPerSecond\": 107.84,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4558.1,\n \"p95LatencyMs\": 5081.9,\n \"outputTokensPerSecond\": 113.25,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5436.6,\n \"p95LatencyMs\": 5928.8,\n \"outputTokensPerSecond\": 95.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.3-codex\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 15290.4,\n \"p95LatencyMs\": 15290.4,\n \"outputTokensPerSecond\": 33.49,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"openai/gpt-5.4\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5596,\n \"p95LatencyMs\": 5919.4,\n \"outputTokensPerSecond\": 91.67,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.4-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3377.8,\n \"p95LatencyMs\": 3646.8,\n \"outputTokensPerSecond\": 138.08,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.4-nano\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4040.4,\n \"p95LatencyMs\": 4205.9,\n \"outputTokensPerSecond\": 118.52,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6367.8,\n \"p95LatencyMs\": 7330.7,\n \"outputTokensPerSecond\": 81.29,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-luna\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6064.5,\n \"p95LatencyMs\": 7347.3,\n \"outputTokensPerSecond\": 87.93,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-luna-pro\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 13914.9,\n \"p95LatencyMs\": 13914.9,\n \"outputTokensPerSecond\": 36.79,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"openai/gpt-5.6-sol\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7720.2,\n \"p95LatencyMs\": 9108.2,\n \"outputTokensPerSecond\": 67.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-sol-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 11442.7,\n \"p95LatencyMs\": 13363.1,\n \"outputTokensPerSecond\": 148.75,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-terra\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4941,\n \"p95LatencyMs\": 5095.3,\n \"outputTokensPerSecond\": 103.69,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-terra-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3574.1,\n \"p95LatencyMs\": 4126.3,\n \"outputTokensPerSecond\": 133.59,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-6.1-sol\": {\n \"measuredAt\": \"2026-10-20T18:12:51Z\",\n \"latencyMs\": 11324,\n \"p95LatencyMs\": 12747.6,\n \"outputTokensPerSecond\": 45.11,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4324.9,\n \"p95LatencyMs\": 5838.1,\n \"outputTokensPerSecond\": 125.86,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5463.4,\n \"p95LatencyMs\": 5613.1,\n \"outputTokensPerSecond\": 93.8,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o3-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2912.7,\n \"p95LatencyMs\": 3092.1,\n \"outputTokensPerSecond\": 176.49,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o4-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4958.7,\n \"p95LatencyMs\": 5313,\n \"outputTokensPerSecond\": 103.81,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3385.5,\n \"p95LatencyMs\": 4042.7,\n \"outputTokensPerSecond\": 153.94,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-max\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9387.1,\n \"p95LatencyMs\": 10490.2,\n \"outputTokensPerSecond\": 54.92,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-plus\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9766.6,\n \"p95LatencyMs\": 9798.2,\n \"outputTokensPerSecond\": 52.42,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"tencent/hy3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6062.3,\n \"p95LatencyMs\": 7070.2,\n \"outputTokensPerSecond\": 87.3,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-4.3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9467.7,\n \"p95LatencyMs\": 10087.9,\n \"outputTokensPerSecond\": 48.36,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 13564.8,\n \"p95LatencyMs\": 17351.9,\n \"outputTokensPerSecond\": 60.71,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-build-0.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 16394.8,\n \"p95LatencyMs\": 18035.4,\n \"outputTokensPerSecond\": 96.86,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xiaomi/mimo-v2.5-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 12070.7,\n \"p95LatencyMs\": 12386.8,\n \"outputTokensPerSecond\": 42.44,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6839.7,\n \"p95LatencyMs\": 7261.4,\n \"outputTokensPerSecond\": 75.16,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5-turbo\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 55348.5,\n \"p95LatencyMs\": 114086.6,\n \"outputTokensPerSecond\": 14.64,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 15658.4,\n \"p95LatencyMs\": 17307.1,\n \"outputTokensPerSecond\": 32.9,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 10308.5,\n \"p95LatencyMs\": 15127.6,\n \"outputTokensPerSecond\": 54.87,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7272.4,\n \"p95LatencyMs\": 7998.1,\n \"outputTokensPerSecond\": 71.09,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.3-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 10545.3,\n \"p95LatencyMs\": 11672.4,\n \"outputTokensPerSecond\": 49.01,\n \"errorRate\": 0,\n \"samples\": 3\n }\n}\n","/**\n * Model-performance priors consumed by the portfolio router.\n *\n * The entries below are a small, auditable seed extracted from the 2026-03-16\n * BlockRun performance run. They are deliberately weak priors: live data\n * injected by the host should replace them through configuration before a\n * release. Historical numbers must never be presented as a current\n * provider SLA or as task-quality measurements.\n */\n\nimport liveProfiles from \"./model-profiles.generated.json\";\n\nexport type ModelPerformanceProfile = {\n measuredAt: string;\n /** Gateway end-to-end latency for the benchmark workload. */\n latencyMs: number;\n /** Tail latency is more relevant than mean latency for urgent requests. */\n p95LatencyMs?: number;\n outputTokensPerSecond: number;\n /** External intelligence index when one was available; not task success. */\n intelligenceIndex?: number;\n /** Failure fraction observed in the same benchmark run. */\n errorRate?: number;\n /** Number of sampled calls behind the observation. */\n samples?: number;\n};\n\n// Generated from benchmark files that satisfy the uncached-inference\n// invariant. These are weak performance priors (speed/reliability), never\n// task-quality labels.\nexport const LIVE_MODEL_PROFILES: Readonly> = Object.freeze(\n liveProfiles as Record,\n);\n\nexport const HISTORICAL_MODEL_PROFILES: Readonly> =\n Object.freeze({\n \"anthropic/claude-haiku-4.5\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2305,\n outputTokensPerSecond: 140.6,\n },\n \"anthropic/claude-sonnet-4.6\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2110,\n outputTokensPerSecond: 121.3,\n },\n \"deepseek/deepseek-chat\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1431,\n outputTokensPerSecond: 179.2,\n intelligenceIndex: 32,\n },\n \"google/gemini-2.5-flash\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1238,\n outputTokensPerSecond: 207.6,\n intelligenceIndex: 20,\n },\n \"google/gemini-2.5-flash-lite\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1353,\n outputTokensPerSecond: 192.5,\n intelligenceIndex: 20,\n },\n \"google/gemini-2.5-pro\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1294,\n outputTokensPerSecond: 197.8,\n },\n \"google/gemini-3.1-pro\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1609,\n outputTokensPerSecond: 167.2,\n },\n \"openai/gpt-4o-mini\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2764,\n outputTokensPerSecond: 92.8,\n },\n \"openai/gpt-5.3-codex\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 7935,\n outputTokensPerSecond: 32.3,\n },\n });\n","/**\n * Whether the request actually requires an external action/tool, as distinct\n * from merely being sent by a host that exposes tools on every turn.\n *\n * The detector intentionally looks for action+target pairs. A generic factual\n * or multiple-choice question must stay false even when the host attaches a\n * large tool schema; otherwise every tool-enabled host turn is over-routed as\n * an agent task and models may browse or mutate state unnecessarily.\n */\nexport function inferToolRequirement(\n prompt: string,\n _systemPrompt?: string,\n toolChoice?: unknown,\n): boolean {\n // OpenAI-compatible clients can state this requirement directly. Treat that\n // protocol signal as authoritative instead of trying to infer it from prose.\n if (toolChoice === \"none\") return false;\n if (toolChoice === \"required\") return true;\n if (\n typeof toolChoice === \"object\" &&\n toolChoice !== null &&\n (toolChoice as { type?: unknown }).type === \"function\"\n ) {\n return true;\n }\n\n // System prompts commonly describe every tool a host exposes. They are not\n // evidence that the user asked to perform an action on this turn. Explicit\n // host requirements should use tool_choice/requiresTools instead.\n const text = prompt;\n const explicitTool =\n /\\b(?:use|call|invoke)\\s+(?:the\\s+)?[\\w.-]+\\s+(?:tool|function|api)\\b|\\btool[_ -]?call\\b|使用.{0,20}(?:工具|函数|接口)|调用.{0,20}(?:工具|函数|接口)/i;\n const codeEnvironment =\n /\\b(?:run|execute)\\s+(?:the\\s+)?(?:tests?|command|script|build|linter)|\\b(?:edit|modify|patch|create|write|save|delete|rename|move|inspect|read)\\b.{0,60}\\b(?:file|repository|repo|codebase|directory|folder)\\b|\\b(?:terminal|shell|bash|zsh|pytest|npm test|pnpm test|git\\s+(?:status|diff|commit)|docker)\\b|(?:运行|执行).{0,20}(?:测试|命令|脚本|构建)|(?:修改|编辑|修复|创建|读取|检查|保存).{0,30}(?:文件|仓库|代码库|目录)/i;\n const webAction =\n /\\b(?:browse|search|look up|fetch|open)\\b.{0,80}\\b(?:web|website|url|online|documentation|docs|news|weather|price)\\b|(?:浏览|搜索|查询|打开).{0,30}(?:网页|网站|链接|文档|新闻|天气|价格)/i;\n const statefulAction =\n /\\b(?:refund|cancel|book|reserve|purchase|buy|return|exchange|transfer|update|change)\\b.{0,80}\\b(?:order|booking|reservation|account|address|payment|subscription|ticket|flight|item)\\b|(?:退款|取消|预订|购买|退货|换货|转账|更新|修改).{0,30}(?:订单|预订|账户|地址|付款|订阅|票|航班|商品)/i;\n return (\n explicitTool.test(text) ||\n codeEnvironment.test(text) ||\n webAction.test(text) ||\n statefulAction.test(text)\n );\n}\n","/**\n * V3 portfolio router.\n *\n * This is deliberately local and deterministic: feature extraction, eligibility\n * checks and scoring read only request data plus the in-process model registry.\n * It is therefore safe for the hot path and provides a stable baseline for the\n * RouterBench evaluation before health telemetry / an optional judge are added.\n */\n\nimport { DEFAULT_ROUTING_CONFIG } from \"./config.js\";\nimport { DEFAULT_MODEL_CAPABILITIES } from \"./model-capabilities.js\";\nimport { getFallbackChain, selectModel, usablePricing } from \"./selector.js\";\nimport { RulesStrategy } from \"./strategy.js\";\nimport {\n HISTORICAL_MODEL_PROFILES,\n LIVE_MODEL_PROFILES,\n type ModelPerformanceProfile,\n} from \"./model-profiles.js\";\nimport type { RouterOptions, RouterStrategy, TaskType, Tier, TierConfig } from \"./types.js\";\nimport { inferToolRequirement } from \"./tool-intent.js\";\nimport { estimateTokens, sampleForScan, scanLimit } from \"./tokens.js\";\n\ntype TaskFeatures = {\n taskType: TaskType;\n estimatedInputTokens: number;\n hasCode: boolean;\n needsTools: boolean;\n toolsAvailable: boolean;\n needsVision: boolean;\n needsStructuredOutput: boolean;\n latencySensitive: boolean;\n highStakes: boolean;\n language: \"zh\" | \"other\";\n likelyParallelToolCalls: boolean;\n complexMultiToolPlan: boolean;\n agentDomain: \"airline\" | \"retail\" | \"web_research\" | \"other\";\n deepWebResearch: boolean;\n agentRisk: \"standard\" | \"high\" | \"complex_high\" | \"policy_exception_simple\" | \"policy_exception\";\n terminalToolSignal: boolean;\n terminalSafetySensitive: boolean;\n implicitTerminalCode: boolean;\n /** A code artifact or coding action is present, not merely a language name. */\n codeArtifact: boolean;\n};\n\n// The bundled config carries the calibrated weights; a host config that omits\n// `portfolio` scores with the same numbers rather than a second copy of them.\nconst DEFAULT_PORTFOLIO_WEIGHTS = DEFAULT_ROUTING_CONFIG.portfolio!;\n\n/**\n * Detect turns that probably need several tool calls. This is a\n * deliberately conservative request-side feature: it uses only the prompt\n * and visible tool count, never benchmark categories or expected answers.\n */\nfunction likelyNeedsParallelToolCalls(\n prompt: string,\n needsTools: boolean,\n toolCount: number | undefined,\n toolNames: readonly string[] | undefined,\n): boolean {\n if (!needsTools || toolCount === undefined || toolCount < 1) return false;\n const text = prompt.trim();\n const explicitRepeat =\n /\\b(?:in parallel|simultaneously|concurrently|for each|each of|every one|both|(?:two|three|multiple|several)\\s+(?:cities|locations|items|tasks|orders|users|files))\\b|并行|同时|分别|每个|各自|(?:两个|三个|多个)(?:城市|地点|项目|任务|订单|用户|文件)|cada uno|para cada|simult[aá]neamente/i.test(\n text,\n );\n if (explicitRepeat) return true;\n\n const sentenceClauses = text\n .split(/[.!?。!?]+/)\n .map((part) => part.trim())\n .filter((part) => part.length >= 8);\n if (\n (/\\b(?:also|additionally|furthermore)\\b|另外|此外|그리고/i.test(text) &&\n sentenceClauses.length >= 2) ||\n /\\band\\s+(?:also|for the)\\b/i.test(text)\n )\n return true;\n\n const pairedQuantity =\n /\\b\\d+(?:\\.\\d+)?\\s+(?:and|or)\\s+\\d+(?:\\.\\d+)?\\s*(?:gb|mb|tb|kg|g|ml|oz|cups?|cores?|cpus?)\\b/i.test(\n text,\n );\n if (pairedQuantity) return true;\n\n // Distinctive tokens from two visible tool names are a strong local signal\n // for a multi-operation turn (for example add_task + delete_task).\n const operationTokens = new Set([\n \"add\",\n \"delete\",\n \"remove\",\n \"cancel\",\n \"return\",\n \"exchange\",\n \"modify\",\n \"book\",\n \"transfer\",\n \"send\",\n \"upload\",\n \"download\",\n \"create\",\n \"close\",\n ]);\n // Whole words only, with an optional inflection: a substring test read\n // \"add\" out of \"address\", \"book\" out of \"facebook\" and \"close\" out of\n // \"closet\" (the same failure rules.ts fixed for its keyword lists).\n const lowered = text.toLowerCase();\n const matchedOperationTokens = new Set(\n (toolNames ?? [])\n .flatMap((name) => name.toLowerCase().split(/[^a-z0-9\\u3400-\\u9fff]+/))\n .filter(\n (token) =>\n operationTokens.has(token) &&\n new RegExp(`\\\\b${token}(?:s|es|d|ed|ing)?\\\\b`).test(lowered),\n ),\n );\n // A single workflow naturally mentions domain nouns like order/item plus\n // one action. Upgrade only when two different visible operation verbs are\n // requested (for example cancel + book or add + delete).\n if (matchedOperationTokens.size >= 2) return true;\n\n // Repeated food/logging entries are commonly expressed as several lines,\n // each with its own quantity rather than an explicit \"for each\" phrase.\n const nonEmptyLines = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter(Boolean);\n const quantityMentions =\n text.match(\n /\\b(?:\\d+(?:\\.\\d+)?|one|two|three|four|five|six|seven|eight|nine|ten)\\s*(?:oz|ounce|ounces|g|gram|grams|kg|ml|cups?|pieces?|tablespoons?)\\b/gi,\n ) ?? [];\n if (nonEmptyLines.length >= 2 && quantityMentions.length >= 2) return true;\n\n // Weather prompts provide a useful language-independent high-confidence\n // pattern: a single lookup tool plus multiple locations joined in one turn.\n const repeatedLookup =\n /\\b(?:weather|climate|clima|tiempo|temperature|snow|news|report)\\b|天气|气象|温度|降雪|新闻|报告/i.test(\n text,\n );\n const multiLocationConnector =\n /\\b(?:and also|both)\\b|\\s(?:y|e)\\s|还有|以及|和|、/i.test(text);\n const commaSeparatedLocations = (text.match(/[,,]/g) ?? []).length >= 2;\n if (repeatedLookup && (multiLocationConnector || commaSeparatedLocations)) return true;\n\n const distinctOrderParts =\n /\\b(?:food|meal)\\b[\\s\\S]*\\bdrink\\b|\\bdrink\\b[\\s\\S]*\\b(?:food|meal)\\b/i.test(text);\n const koreanParallelClauses = (text.match(/,/g) ?? []).length >= 3 && /하고|그리고/.test(text);\n return distinctOrderParts || koreanParallelClauses;\n}\n\nfunction classifyTask(\n prompt: string,\n systemPrompt: string | undefined,\n options: RouterOptions,\n): TaskFeatures {\n const fullText = `${systemPrompt ?? \"\"} ${prompt}`;\n const estimatedInputTokens = estimateTokens(fullText);\n const limit = scanLimit(options.config.classifier.promptTruncationChars);\n const scannedPrompt = sampleForScan(prompt, limit);\n const scannedSystemPrompt = sampleForScan(systemPrompt ?? \"\", limit);\n // Only the deep-web-research clue detectors below read the system prompt,\n // and they are gated on a web-research tool surface. Every other feature\n // reads the user turn: a host's standing instructions (\"be quick\", \"follow\n // security best practices\", a Mandarin persona) describe the assistant, not\n // this request, and must not move its scoring or language band.\n const scannedFullText = `${scannedSystemPrompt} ${scannedPrompt}`;\n const text = scannedPrompt.toLowerCase();\n const explicitCodeSignal =\n /```|\\b(?:typescript|javascript|python|rust|java|sql|stack trace|traceback|exception)\\b|\\.(?:ts|tsx|js|py|go|rs)\\b/i.test(\n scannedPrompt,\n );\n // `class` is common in non-code Agent domains (for example airline cabin\n // class). Treat code constructs as code only when the prompt also contains\n // an implementation/editing cue, instead of letting a single ambiguous\n // noun redirect an entire tool session to the code-agent portfolio.\n const codeConstructSignal =\n /\\b(?:implement|refactor|debug|write|edit|modify|create|define|review|fix)\\b[\\s\\S]{0,48}\\b(?:api|function|class|method)\\b|\\b(?:api|function|class|method)\\b[\\s\\S]{0,48}\\b(?:code|implementation|typescript|javascript|python|rust|java)\\b/i.test(\n scannedPrompt,\n );\n const nativeCodeSignal =\n /\\b(?:programmed|written|implemented?|code)\\s+(?:in|using)\\s+(?:c\\+\\+|c|rust|go)\\b/i.test(\n scannedPrompt,\n );\n // A CamelCase error class (TypeError, NullPointerException) is a runtime\n // artifact, not prose about errors; case-sensitive on purpose.\n const errorClassSignal = /\\b[A-Z][A-Za-z]*(?:Error|Exception)\\b/.test(scannedPrompt);\n const hasCode = explicitCodeSignal || codeConstructSignal || nativeCodeSignal || errorClassSignal;\n // A language name alone (\"java coffee prices\", \"python snake habitat\") is\n // not code work, even on a tool turn. It joins the code-agent pool only\n // together with a coding action.\n const codingAction =\n /\\b(?:write|implement|refactor|debug|fix|patch|compile|build|run|test|script|program|code|function|class|module|repo(?:sitory)?)\\b|编写|实现|重构|调试|修复|编译|脚本|代码/i.test(\n scannedPrompt,\n );\n // Stronger than hasCode: an actual code artifact or coding action, never a\n // bare language name (\"What is Python?\" is trivia, not a code task) and\n // never the English word \"exception\" on its own (\"please make an\n // exception\"); a thrown exception shows up as a CamelCase class above.\n const codeArtifact =\n /```|\\b(?:stack trace|traceback)\\b|\\.(?:ts|tsx|js|py|go|rs)\\b/i.test(scannedPrompt) ||\n codeConstructSignal ||\n nativeCodeSignal ||\n errorClassSignal;\n const toolsAvailable = options.hasTools ?? false;\n const needsTools =\n options.requiresTools ??\n (toolsAvailable && inferToolRequirement(scannedPrompt, scannedSystemPrompt));\n const likelyParallelToolCalls = likelyNeedsParallelToolCalls(\n scannedPrompt,\n needsTools,\n options.toolCount,\n options.toolNames,\n );\n const normalizedToolNames = (options.toolNames ?? []).map((name) => name.toLowerCase());\n const airlineToolSignal = normalizedToolNames.some((name) =>\n /(?:flight|reservation|airport|baggage|passenger)/.test(name),\n );\n const retailToolSignal = normalizedToolNames.some((name) =>\n /(?:order|product|item|return|exchange|address)/.test(name),\n );\n const webResearchToolSignal = normalizedToolNames.some((name) =>\n /^(?:web_?search|web_?fetch)$/.test(name),\n );\n const agentDomain =\n airlineToolSignal && !retailToolSignal\n ? \"airline\"\n : retailToolSignal && !airlineToolSignal\n ? \"retail\"\n : webResearchToolSignal\n ? \"web_research\"\n : \"other\";\n // Distinguish a cheap lookup from a BrowseComp-like investigation. These\n // prompts require joining several clues, resolving an entity, and ending in\n // one exact answer; complete agent trajectories show that treating them as\n // ordinary search causes long, costly loops. This is request/tool-surface\n // evidence only and does not depend on a benchmark id or hidden answer.\n const clueConnectors =\n scannedFullText.match(\n /\\b(?:after|before|while|where|whose|which|in \\d{4}|as of|over \\d+|another|also|furthermore)\\b|(?:之后|之前|其中|截至|超过|另一个|此外)/gi,\n ) ?? [];\n const entityResolutionSignal =\n /\\b(?:identify|who (?:is|was)|what (?:is|was) the name|which (?:person|player|company|country|city)|find the (?:person|player|name|entity))\\b|(?:找出|识别|是谁|哪位|名称是什么)/i.test(\n scannedFullText,\n );\n const exactAnswerSignal =\n /\\b(?:exact answer|single best-supported answer|following clues|multiple public sources)\\b|(?:精确答案|根据.*线索|多个公开来源)/i.test(\n scannedFullText,\n );\n const deepWebResearch =\n agentDomain === \"web_research\" &&\n (exactAnswerSignal ||\n (entityResolutionSignal && (clueConnectors.length >= 3 || prompt.length >= 320)));\n const globalOptimizationSignal =\n /\\b(?:cheapest|lowest[- ]price|least expensive|most expensive|highest(?:[- ]priced)?|largest|smallest|maximum|minimum|best available|closest|not (?:cost|exceed))\\b|最便宜|最低价|最贵|最高价|最大|最小/i.test(\n scannedPrompt,\n );\n const globalScopeSignal =\n /\\b(?:everything|all (?:(?:my|your|their|the) )?(?:future |upcoming )?(?:items|orders|passengers|flights|reservations|bookings)|every (?:item|order|passenger|flight|reservation|booking))\\b|全部|所有|每个/i.test(\n scannedPrompt,\n );\n const globalChoiceSignal = globalOptimizationSignal || globalScopeSignal;\n const crossRecordSignal =\n /\\b(?:another|other|different|previous)\\s+(?:order|reservation|booking|account|address)\\b|另一(?:个)?(?:订单|预订|账户|地址)|其他(?:订单|预订|账户|地址)/i.test(\n scannedPrompt,\n );\n // Reservation locators mix letters and digits (ZFA04Y, 4WQ150). Requiring\n // both keeps shouted words (\"CANCEL MY FLIGHT\") and plain six-digit numbers\n // from reading as two reservations.\n const reservationIds =\n scannedPrompt.match(/\\b(?=[A-Z0-9]*\\d)(?=[A-Z0-9]*[A-Z])[A-Z0-9]{6}\\b/g) ?? [];\n const crossReservationBatchSignal =\n agentDomain === \"airline\" &&\n (/\\b(?:two|three|multiple|several)(?:\\s+of\\s+(?:my|our|the))?\\s+(?:upcoming\\s+)?(?:reservations?|bookings?)\\b|\\b(?:a\\s+)?(?:second|third)\\s+(?:reservation|booking)\\b/i.test(\n scannedPrompt,\n ) ||\n new Set(reservationIds).size >= 2);\n const conditionalGlobalWorkflowSignal =\n agentDomain === \"airline\" &&\n globalScopeSignal &&\n /\\b(?:if|that (?:contain|have)|longer than|shorter than|under|over|at (?:most|least)|wherever possible)\\b|如果|超过|少于|不超过|尽可能/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:cancel|change|upgrade|move|book)\\b[\\s\\S]*\\b(?:cancel|change|upgrade|move|book)\\b|取消[\\s\\S]*(?:升级|更改)|升级[\\s\\S]*(?:取消|更改)/i.test(\n scannedPrompt,\n );\n // A refund explicitly targeted at a named/non-original card can conflict\n // with account state and require escalation rather than a substitute action.\n // This narrow feature is visible on the first turn and avoids sending every\n // ordinary return workflow to the expensive policy specialist.\n const policyExceptionSignal =\n agentDomain === \"retail\" &&\n /\\b(?:return|refund|send back|get (?:my |the )?money back)\\b|退货|退款|退回/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:amex|american express|visa|mastercard|credit card|debit card|different card|another card|other card)\\b|信用卡|借记卡|其他卡|另一张卡/i.test(\n scannedPrompt,\n );\n // A comparative selector can mention two products while requesting only\n // one write (for example \"send back the pricier one\"). Three-repeat tau2\n // calibration found no quality gain from the policy specialist on these\n // single-write cases, so keep them in a distinct, lower-cost risk band.\n const singleSelectedPolicyException =\n policyExceptionSignal &&\n /\\b(?:return|refund|send back)\\b[^.!?。!?]{0,96}\\b(?:the )?(?:pricier|cheaper|more expensive|less expensive|costlier|one)\\b/i.test(\n scannedPrompt,\n );\n // Returns and exchanges often pivot after confirmation (return -> rethink\n // -> exchange -> choose a variant). That future state is not visible to a\n // task-start router, so treat the observable workflow verb as the risk cue.\n // Simpler cancellation and one-field order edits stay on the standard path.\n const negotiatedWorkflowSignal =\n agentDomain === \"retail\" && /\\b(?:return|exchange)\\b|退货|退回|换货|交换/i.test(scannedPrompt);\n const numberedSteps = (scannedPrompt.match(/(?:^|\\s)\\d+(?:\\.\\d+)*[.)]\\s+/g) ?? []).length;\n const complexMultiToolPlan =\n likelyParallelToolCalls &&\n ((options.toolCount ?? 0) >= 6 || numberedSteps >= 3 || prompt.length > 1_200);\n let agentRisk: TaskFeatures[\"agentRisk\"] =\n needsTools && singleSelectedPolicyException\n ? \"policy_exception_simple\"\n : needsTools && policyExceptionSignal\n ? \"policy_exception\"\n : // Airline prompts that require a global optimum (for example the\n // cheapest itinerary across several candidates) are materially harder\n // than applying one change to every passenger in a known reservation.\n // Full-session evidence supports Sonnet for the former, while upgrading\n // the latter merely because it says \"all passengers\" caused a large cost\n // increase without a quality gain.\n needsTools &&\n agentDomain === \"airline\" &&\n (globalOptimizationSignal || conditionalGlobalWorkflowSignal)\n ? \"complex_high\"\n : needsTools &&\n (likelyParallelToolCalls ||\n globalChoiceSignal ||\n crossRecordSignal ||\n crossReservationBatchSignal ||\n negotiatedWorkflowSignal)\n ? \"high\"\n : \"standard\";\n const needsVision = options.hasVision ?? false;\n const needsStructuredOutput = options.requiresStructuredOutput ?? false;\n const latencySensitive =\n /\\b(?:urgent|asap|fast|quick|low latency|real[- ]time)\\b|尽快|马上|快速|低延迟/i.test(\n scannedPrompt,\n );\n const highStakes =\n /\\b(?:production|security|payment|legal|medical|financial|audit)\\b|生产|安全|支付|法律|医疗|财务|审计/i.test(\n scannedPrompt,\n );\n // Terminal tasks often describe the desired artifact rather than naming a\n // programming language. Treat only small, deterministic local build/file\n // work as implicit code. Operational deployment, credentials, destructive\n // work, evaluation, vision, and broad search stay on the stronger generic\n // tool-agent path. This is a request-side feature, not a benchmark ID list.\n const terminalToolSignal = normalizedToolNames.some((name) =>\n /^(?:terminalexec|terminalinspect|terminalsendkeys)$/.test(name),\n );\n const simpleTerminalArtifact =\n /\\b(?:create|write|convert|generate|build|implement|run|fix|repair|debug|make)\\b[\\s\\S]{0,120}\\b(?:file|script|csv|parquet|json|txt|server|endpoint)\\b/i.test(\n scannedPrompt,\n );\n // Multi-file repair is qualitatively different from fixing one known local\n // script. The agent must preserve state across inspections, infer ordering\n // and dependencies, edit several artifacts, and close the loop with tests.\n // A frozen Terminal-Bench trajectory showed the economy model spending 27\n // turns repeatedly rereading files without making an edit, while Opus solved\n // the same task in eight turns. Promote this request-visible pattern before\n // model scoring; no benchmark ID or expected answer is consulted.\n const terminalComplexRepair =\n terminalToolSignal &&\n /\\b(?:multiple|several)\\s+(?:scripts?|files?|components?)\\b|\\b(?:pipeline|dependencies)\\b[\\s\\S]{0,100}\\b(?:fail|issue|fix|repair|run|execute)\\b|\\b(?:identify|find|fix|repair)\\s+(?:and\\s+)?(?:fix\\s+)?all\\s+(?:the\\s+)?issues\\b/i.test(\n scannedPrompt,\n );\n // One artifact that must be accepted by multiple compilers/runtimes is not\n // a routine file-writing task. It requires reasoning across incompatible\n // grammars and validating every execution path; cheap code models can\n // produce plausible-looking source that satisfies neither toolchain.\n const mentionedTerminalRuntimes = new Set(\n (scannedPrompt.match(/\\b(?:gcc|clang|rustc|javac|go\\s+build|node|python)\\b/gi) ?? []).map(\n (name) => name.toLowerCase().replace(/\\s+/g, \" \"),\n ),\n );\n const terminalCrossRuntimeArtifact =\n terminalToolSignal &&\n (/\\bpolyglot\\b/i.test(scannedPrompt) ||\n /\\b(?:both|each)\\b[\\s\\S]{0,120}\\b(?:compilers?|runtimes?|toolchains?)\\b/i.test(\n scannedPrompt,\n ) ||\n (mentionedTerminalRuntimes.size >= 2 &&\n /\\b(?:compile|build|run|execute)\\b/i.test(scannedPrompt)));\n // Framework-to-native ports combine binary checkpoint inspection, weight\n // export, tensor-layout reasoning, image/data decoding, and a separately\n // compiled runtime. A task-start router can see this boundary directly in\n // the request (for example PyTorch state_dict -> a pure C CLI); treating it\n // like routine single-file C work caused a 30-turn read/retry loop in a\n // frozen official Terminal-Bench trajectory.\n const terminalFrameworkToNativeArtifact =\n terminalToolSignal &&\n /\\b(?:pytorch|tensorflow|jax|onnx|state[_ -]?dict|checkpoint|safetensors?)\\b|\\.(?:pth|pt|onnx)\\b/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:pure|native|programmed|written|implemented?)\\s+(?:in|using)\\s+(?:c\\+\\+|c|rust|go)\\b|\\b(?:c\\+\\+|c|rust|go)\\s+(?:program|binary|executable|cli|tool|implementation)\\b/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:inference|model|weights?|tensor|export|convert|load)\\b/i.test(scannedPrompt);\n if (\n needsTools &&\n (terminalComplexRepair || terminalCrossRuntimeArtifact || terminalFrameworkToNativeArtifact) &&\n (agentRisk === \"standard\" || agentRisk === \"high\")\n )\n agentRisk = \"complex_high\";\n const complexTerminalOperation =\n /\\b(?:git|ssh|nginx|https|certificate|authentication|credential|deploy|production|encrypt|gpg|shred|securely delete|decommission|benchmark|evaluate|embedding|chess|image|search the web|schema|statistical|statistics|aggregate|join|multiple inputs?)\\b/i.test(\n scannedPrompt,\n );\n // A bare \"token\" is not a credential signal: blockchain, tokenizer, and\n // LLM tasks use that word routinely (for example \"token transfers\"). Only\n // treat it as sensitive when the prompt gives it an authentication/secret\n // qualifier. API keys remain an unambiguous high-risk signal on their own.\n const terminalCredentialSignal =\n /\\b(?:ssh|nginx|certificate|authentication|credentials?|passwords?|api keys?|deploy|production|encrypt|gpg|shred|securely delete|decommission)\\b/i.test(\n scannedPrompt,\n ) ||\n /\\b(?:access|auth|authentication|bearer|secret|api)\\s+tokens?\\b|\\btokens?\\s+(?:secret|credential|authentication)\\b/i.test(\n scannedPrompt,\n );\n const terminalSafetySensitive = terminalToolSignal && (highStakes || terminalCredentialSignal);\n const implicitTerminalCode =\n needsTools &&\n terminalToolSignal &&\n agentRisk === \"standard\" &&\n !highStakes &&\n !complexTerminalOperation &&\n numberedSteps < 3 &&\n prompt.length <= 1_000 &&\n simpleTerminalArtifact;\n // Han characters alone also spell Japanese; kana marks the prompt as not\n // Mandarin, so it does not get the Mandarin-native extraction band.\n const language =\n /[\\u3400-\\u9fff]/.test(scannedPrompt) && !/[\\u3040-\\u30ff]/.test(scannedPrompt)\n ? \"zh\"\n : \"other\";\n const multipleChoiceSignals = (scannedPrompt.match(/(?:^|\\n)\\s*[A-D][.)]\\s+/gim) ?? []).length;\n const numericSignals = (scannedPrompt.match(/-?\\d+(?:[.,]\\d+)?/g) ?? []).length;\n const compactMathProblem =\n !hasCode &&\n prompt.length < 2_500 &&\n numericSignals >= 2 &&\n (/[+×÷=%$€£¥]|\\b(?:total|each|per|times|half|twice|percent|how many|how much|calculate)\\b/i.test(\n scannedPrompt,\n ) ||\n /[??]\\s*$/.test(scannedPrompt.trim()) ||\n numericSignals >= 3);\n\n let taskType: TaskType = \"chat\";\n if (needsVision) taskType = \"vision\";\n else if (estimatedInputTokens > 80_000) taskType = \"long_context\";\n else if (needsTools && (codeArtifact || (hasCode && codingAction) || implicitTerminalCode))\n taskType = \"code_agent\";\n else if (needsTools && likelyParallelToolCalls && !complexMultiToolPlan)\n taskType = \"tool_agent_parallel\";\n else if (needsTools) taskType = \"tool_agent\";\n else if (multipleChoiceSignals >= 3) taskType = \"reasoning_mcq\";\n else if (compactMathProblem) taskType = \"reasoning_math\";\n else if (\n errorClassSignal ||\n /\\b(?:bug|debug|error|failure|failing|regression|crash)\\b|修复|报错|错误|调试/i.test(text)\n )\n taskType = \"debug\";\n else if (hasCode || /\\b(?:refactor|implement|patch|edit|rewrite)\\b|重构|实现|修改/i.test(text))\n taskType = \"code_edit\";\n else if (needsStructuredOutput || /\\b(?:extract|json|schema|csv)\\b|字段|提取/i.test(text))\n taskType = \"extraction\";\n else if (\n /\\b(?:prove|derive|theorem|formal|mathematical|reasoning)\\b|证明|推导|定理|数学/i.test(text)\n )\n taskType = \"reasoning\";\n\n return {\n taskType,\n estimatedInputTokens,\n hasCode,\n needsTools,\n toolsAvailable,\n needsVision,\n needsStructuredOutput,\n latencySensitive,\n highStakes,\n language,\n likelyParallelToolCalls,\n complexMultiToolPlan,\n agentDomain,\n deepWebResearch,\n agentRisk,\n terminalToolSignal,\n terminalSafetySensitive,\n implicitTerminalCode,\n codeArtifact,\n };\n}\n\n/**\n * Task-affinity bands. Each table maps a model name (the id after the\n * provider slash) to its calibrated affinity for one request shape; anything\n * absent scores the neutral `NEUTRAL_AFFINITY`. Names are matched exactly:\n * model family names are intentionally similar (`gemini-2.5-flash` vs\n * `gemini-2.5-flash-lite`), and a substring match would let a smaller sibling\n * inherit a capability claim measured only for the flagship. A sibling joins a\n * band only with its own evidence.\n */\ntype AffinityBand = Readonly>;\n\n// Every \"gemini-3.6-flash\" value below is CARRIED from Gemini 3.5 Flash, not\n// measured on 3.6. The calibrations that set them (RouterBench GPQA/MGSM and\n// BFCL 2026-07-26/28, the Terminal-Bench and tau2 trajectories of 2026-07-28)\n// ran on 3.5. Google has answered the 3.5 name with 3.6 Flash since\n// ~2026-10-10, and on 2026-11-24 the gateways began redirecting 3.5 to 3.6, so\n// the router has in practice been routing 3.6 on these values since October;\n// the key now names the model that answers. The comments that cite \"Gemini\n// 3.5 Flash\" results describe those runs. Re-measure before treating any of\n// these as 3.6 evidence.\n//\n// Likewise every \"gemini-3.5-flash-lite\" value (extractionZh, extraction,\n// chat) is CARRIED from Gemini 2.5 Flash, which Google retired on 2026-12-01\n// and the gateways redirect to 3.5 Flash-Lite. It is a successor, not a\n// sibling claiming a flagship's evidence (see the rule above), but the values\n// were measured on 2.5 and still need a 3.5 Flash-Lite run.\n\n/** Affinity of a model with no task-specific evidence. */\nconst NEUTRAL_AFFINITY = 0.68;\n\n// Strong native tool loop until the Responses function-output fix is deployed\n// on both gateways; Codex stays available below auto's affinity floor. Sonnet\n// has a verified native multi-turn tool loop and is the safe strong default.\nconst TERMINAL_COMPLEX_HIGH: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.3-codex\": 0.87,\n \"gpt-5-mini\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n};\n\n// Complete-session BrowseComp calibration supersedes the earlier single-case\n// Opus promotion: strict deduplicated evidence has Sonnet 5 at 2/9 versus Opus\n// 5 at 0/3, while Opus also costs more and has a much longer tail. Opus stays\n// an availability fallback until a larger stable-provider sample supports it.\nconst WEB_RESEARCH_DEEP: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5-mini\": 0.88,\n \"gemini-3.6-flash\": 0.84,\n \"claude-opus-5\": 0.8,\n \"claude-opus-4.8\": 0.78,\n};\nconst WEB_RESEARCH: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5-mini\": 0.88,\n \"gemini-3.6-flash\": 0.86,\n \"claude-opus-5\": 0.84,\n \"claude-opus-4.8\": 0.82,\n};\n\nconst RETAIL_POLICY_EXCEPTION: AffinityBand = {\n \"gpt-4.1\": 1,\n \"claude-sonnet-5\": 0.9,\n \"deepseek-v4-pro\": 0.82,\n \"gpt-5-mini\": 0.8,\n \"gpt-4o-mini\": 0.76,\n};\nconst RETAIL_POLICY_EXCEPTION_SIMPLE: AffinityBand = {\n \"gpt-5-mini\": 1,\n \"gpt-4.1\": 0.86,\n \"deepseek-v4-pro\": 0.82,\n \"gpt-4o-mini\": 0.8,\n};\n\nconst AFFINITY = {\n // Seven valid full agent + official Terminal-Bench trajectories (2026-07-28)\n // gave GPT-5 Mini 4/7 resolved tasks versus 1/7 for the prior dynamic\n // code-agent choice. Its token-normalized total cost was higher in this small\n // calibration, so Codex and Sonnet keep quality priors above it; admitting\n // Mini to the scoring band lets the normal quality/cost profile choose it\n // without erasing stronger fallbacks. DeepSeek V4 Pro is kept below the\n // primary band after two consecutive mid-trajectory provider timeouts\n // contaminated its calibration runs.\n codeAgent: {\n \"gpt-5.3-codex\": 1,\n \"claude-sonnet-5\": 0.98,\n \"gpt-5-mini\": 0.96,\n \"gemini-3.6-flash\": 0.92,\n \"kimi-k3.1-pro\": 0.9,\n \"deepseek-v4-pro\": 0.88,\n \"glm-5.2\": 0.88,\n },\n // Seven official Terminal-Bench calibration trajectories favoured GPT-5 Mini\n // over the prior dynamic choice. Codex/Sonnet are close fallbacks; actual\n // request cost breaks the tie.\n terminalTool: {\n \"gpt-5-mini\": 1,\n \"gpt-5.3-codex\": 0.98,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.89,\n },\n // Two complete agent observations on the public Terminal-Bench\n // new-encrypt-command task ended in Codex repeating the same TerminalExec\n // input until the loop guard fired. Codex stays an availability fallback,\n // below the safety-band affinity floor, until its Responses function-output\n // path is verified on both gateways.\n terminalToolSafety: {\n \"claude-sonnet-5\": 1,\n \"claude-opus-4.8\": 0.9,\n \"gpt-5.3-codex\": 0.84,\n },\n // Full-session calibration: GPT-5 Mini completed two local/single retail\n // workflows at a fraction of Sonnet's token cost. It stays ineligible for\n // promotion when the prompt asks for multiple actions, cross-record\n // discovery or a global optimum; those trajectories exposed unstable write\n // arguments. DeepSeek V4 Pro completed all three high-risk retail calibration\n // trajectories (global-choice, cross-record, multi-write); Sonnet one.\n retailStandard: {\n \"gpt-5-mini\": 1,\n \"claude-sonnet-5\": 0.88,\n \"gemini-3.6-flash\": 0.82,\n \"gpt-5.3-codex\": 0.81,\n \"kimi-k3.1-pro\": 0.78,\n \"deepseek-v4-pro\": 0.76,\n },\n retailHigh: {\n \"deepseek-v4-pro\": 1,\n \"claude-sonnet-5\": 0.88,\n \"gemini-3.6-flash\": 0.82,\n \"gpt-5.3-codex\": 0.81,\n \"kimi-k3.1-pro\": 0.78,\n \"gpt-5-mini\": 0.76,\n },\n // Standard airline workflows stay on GPT-5 Mini: six full-session\n // development trajectories gave it the same 5/6 success as Sonnet at roughly\n // one order of magnitude lower normalized token cost. A held-out high-risk\n // cabin/date negotiation then produced a persistent empty assistant turn on\n // Mini even after a semantic retry, while Sonnet 5 completed the identical\n // official tau2 trajectory with reward 1.0. Only global optimization /\n // conditional-global work is promoted. A known batch of reservations is\n // operationally high-risk but still a structured tool workflow: current Tau\n // evidence has Mini and Sonnet at equal task reward there, while Sonnet costs\n // roughly two orders of magnitude more on the long-tail case.\n airlineComplex: {\n \"claude-sonnet-5\": 1,\n \"gpt-5-mini\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n \"deepseek-v4-pro\": 0.74,\n },\n airlineStandard: {\n \"gpt-5-mini\": 1,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.8,\n \"deepseek-v4-pro\": 0.76,\n },\n // Full-trajectory tau2 calibration (2026-07-28, official gpt-4.1 simulator):\n // Sonnet 5 completed both an airline policy task and a retail multi-write\n // task with reward 1.0. Gemini 3.5 Flash emitted function calls as plain text\n // after the first structured calls and looped to the 100-step ceiling on the\n // airline task.\n toolAgent: {\n \"claude-sonnet-5\": 1,\n \"gemini-3.6-flash\": 0.88,\n \"gpt-5.3-codex\": 0.87,\n \"kimi-k3.1-pro\": 0.85,\n \"gpt-5-mini\": 0.84,\n \"deepseek-v4-pro\": 0.82,\n },\n // Multi-file Terminal work is not equivalent to a one-turn parallel\n // function-call benchmark. Sonnet is the strongest trajectory-tested\n // cost-controlled default; Opus remains a close safety fallback.\n parallelTerminalSafety: {\n \"claude-sonnet-5\": 1,\n \"claude-opus-4.8\": 0.9,\n \"gpt-5.3-codex\": 0.86,\n },\n parallelTerminal: {\n \"gpt-5-mini\": 1,\n \"gpt-5.3-codex\": 0.98,\n \"claude-sonnet-5\": 0.92,\n \"gemini-3.6-flash\": 0.88,\n },\n parallelRetail: {\n \"deepseek-v4-pro\": 1,\n \"claude-sonnet-5\": 0.88,\n \"claude-opus-4.8\": 0.84,\n \"gpt-5-mini\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n },\n parallelAirlineComplex: {\n \"claude-sonnet-5\": 1,\n \"gpt-5-mini\": 0.78,\n \"claude-opus-4.8\": 0.76,\n \"gemini-3.6-flash\": 0.74,\n },\n parallelAirline: {\n \"gpt-5-mini\": 1,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.8,\n },\n // RouterBench calibration, 2026-07-26: Opus 4.8 produced complete multi-call\n // payloads on 2/3 multilingual BFCL parallel cases. Gemini 3.5 Flash, Sonnet\n // 5, DeepSeek V4 Pro and Grok 4.5 were 0/3. This narrow prior only applies\n // after the conservative prompt feature in likelyNeedsParallelToolCalls.\n parallel: {\n \"claude-opus-4.8\": 1,\n \"claude-sonnet-5\": 0.84,\n \"grok-4.5\": 0.82,\n \"gemini-3.6-flash\": 0.8,\n \"deepseek-v4-pro\": 0.78,\n },\n codeEdit: {\n \"gpt-5.3-codex\": 1,\n \"claude-sonnet-4.6\": 0.94,\n \"glm-5.2\": 0.9,\n \"deepseek-v4-pro\": 0.86,\n },\n reasoning: {\n \"claude-sonnet-5\": 0.98,\n \"claude-sonnet-4.6\": 0.98,\n \"deepseek-v4-pro\": 0.95,\n \"grok-4.5\": 0.94,\n \"gemini-3.1-pro\": 0.92,\n \"gemini-3.6-flash\": 0.92,\n },\n // RouterBench calibration (2026-07-28, six stratified GPQA Diamond tasks,\n // identical agent adapter and 512-token budget): Gemini 3 Flash Preview\n // scored 5/6, Gemini 3.5 Flash 4/6, and Gemini 3.1 Pro 3/6 while costing\n // ~170x more than Flash. The measured winner is the narrow default; version\n // recency alone is not a quality signal. Unused host tools must not change\n // this reasoning-only model choice.\n reasoningMcq: {\n \"gemini-3-flash-preview\": 1,\n \"gemini-3.6-flash\": 0.91,\n \"grok-4.5\": 0.9,\n \"claude-sonnet-5\": 0.88,\n \"deepseek-v4-pro\": 0.84,\n },\n // Same calibration, five multilingual MGSM tasks: Gemini 3.5 Flash was 5/5\n // with the lowest cost and latency; four current flagships were 4/5 and Kimi\n // K2.7 was 3/5.\n //\n // Kimi K3.1 Pro, paired against Kimi K3 (2026-11-23): all 50 rows of the\n // pinned RouterBench MGSM slice (5 per language x 10 languages), the text\n // adapter's `Answer: ` contract and deterministic grader, 512 output\n // tokens, temperature 0, same rows and settings for both. K3 44/50, K3.1 Pro\n // 41/50; discordant pairs 5 K3-only vs 2 K3.1-only (not significant). Every\n // K3-only win was K3.1 Pro hitting the 512-token cap; the non-truncated\n // errors were the same two rows for both. Rerunning the 10 truncated rows at\n // 2048 tokens gave 8/10 each (46/50 each overall), so the gap is verbosity at\n // the calibration budget, not arithmetic. K3.1 Pro was also slower (p95\n // 10.4s vs 4.7s). It moves from K3's carried 0.9 to 0.88: below the models\n // the 4/5 calibration put at 0.9, by less than the raw 41/44 ratio because\n // the difference is within noise.\n reasoningMath: {\n \"gemini-3.6-flash\": 1,\n \"grok-4.5\": 0.93,\n \"claude-sonnet-5\": 0.9,\n \"deepseek-v4-pro\": 0.9,\n \"kimi-k3.1-pro\": 0.88,\n },\n vision: {\n \"gemini-3.1-pro\": 0.96,\n \"qwen3.7-max\": 0.9,\n \"claude-sonnet-4.6\": 0.9,\n \"kimi-k3.1-pro\": 0.9,\n \"grok-4.3\": 0.9,\n },\n // Long-context eligibility is necessary but not sufficient: a provider can\n // advertise a 1M window yet return an empty completion near that boundary.\n // The proven long-context flagship leads, and less-established alternatives\n // sit in a separate band so price alone cannot displace it.\n longContext: {\n \"gemini-3.1-pro\": 1,\n \"qwen3.7-max\": 0.89,\n \"glm-5.2\": 0.89,\n \"gemini-3.6-flash\": 0.88,\n \"deepseek-v4-pro\": 0.85,\n },\n // A structured extraction must preserve both the output contract and the\n // source-language fields. For Mandarin input the language-native Kimi\n // candidate gets a distinct band — a candidate-pool decision, not a post-hoc\n // override, so it still falls back normally when Kimi is unavailable. The\n // Kimi flagship costs several times the cheap extraction models, so the band\n // must be wider than the auto affinityFloorGap (0.10) or price alone\n // re-selects a non-native model for Mandarin input; 0.12 keeps Kimi alone in\n // the primary band for zh and leaves every other language untouched.\n //\n // Only one \"kimi-k3.1-pro\" value in AFFINITY is measured on K3.1 Pro:\n // reasoningMath (paired K3 vs K3.1 Pro on 50 MGSM rows, 2026-11-23; see that\n // band). Every other value (codeAgent, retailStandard, retailHigh,\n // toolAgent, vision, extractionZh, extraction, chat) is still carried over\n // from the Kimi flagship it replaced (K3, whose values were in turn carried\n // from K2.7). Those bands' calibrations could not be rerun locally: the\n // Terminal-Bench and tau2 trajectories need the RouterBench Franklin host\n // (and Docker for Terminal-Bench), and no extraction or vision slice has a\n // runner. K3.1 Pro's other evidence is the 2026-11-23 live probe: 3/3\n // completions, 0 errors, a well-formed tool call.\n extractionZh: {\n \"kimi-k3.1-pro\": 1,\n \"gemini-3.6-flash\": 0.88,\n \"gemini-3.5-flash-lite\": 0.88,\n \"gpt-4o-mini\": 0.88,\n \"claude-sonnet-5\": 0.88,\n \"claude-sonnet-4.6\": 0.88,\n },\n extraction: {\n \"kimi-k3.1-pro\": 0.9,\n \"gemini-3.6-flash\": 0.9,\n \"gemini-3.5-flash-lite\": 0.9,\n \"gpt-4o-mini\": 0.9,\n \"claude-sonnet-5\": 0.9,\n \"claude-sonnet-4.6\": 0.9,\n },\n chat: {\n \"gemini-3.6-flash\": 0.86,\n \"gemini-3.5-flash-lite\": 0.86,\n \"kimi-k3.1-pro\": 0.86,\n },\n} as const satisfies Record;\n\n/** The affinity band that applies to a classified request. */\nfunction affinityBand(features: TaskFeatures): AffinityBand {\n const { taskType, agentDomain, agentRisk, deepWebResearch, terminalToolSignal } = features;\n const terminalSafety = features.terminalSafetySensitive;\n switch (taskType) {\n case \"code_agent\":\n return terminalToolSignal && agentRisk === \"complex_high\"\n ? TERMINAL_COMPLEX_HIGH\n : AFFINITY.codeAgent;\n case \"tool_agent\":\n if (terminalToolSignal && agentRisk === \"complex_high\") return TERMINAL_COMPLEX_HIGH;\n if (terminalToolSignal) return terminalSafety ? AFFINITY.terminalToolSafety : AFFINITY.terminalTool;\n if (agentDomain === \"web_research\") return deepWebResearch ? WEB_RESEARCH_DEEP : WEB_RESEARCH;\n if (agentDomain === \"retail\") {\n if (agentRisk === \"standard\") return AFFINITY.retailStandard;\n if (agentRisk === \"policy_exception\") return RETAIL_POLICY_EXCEPTION;\n if (agentRisk === \"policy_exception_simple\") return RETAIL_POLICY_EXCEPTION_SIMPLE;\n return AFFINITY.retailHigh;\n }\n if (agentDomain === \"airline\") {\n return agentRisk === \"complex_high\" ? AFFINITY.airlineComplex : AFFINITY.airlineStandard;\n }\n return AFFINITY.toolAgent;\n case \"tool_agent_parallel\":\n if (terminalToolSignal) {\n return terminalSafety ? AFFINITY.parallelTerminalSafety : AFFINITY.parallelTerminal;\n }\n if (agentDomain === \"web_research\") return deepWebResearch ? WEB_RESEARCH_DEEP : WEB_RESEARCH;\n if (agentDomain === \"retail\") {\n if (agentRisk === \"policy_exception\") return RETAIL_POLICY_EXCEPTION;\n if (agentRisk === \"policy_exception_simple\") return RETAIL_POLICY_EXCEPTION_SIMPLE;\n return AFFINITY.parallelRetail;\n }\n if (agentDomain === \"airline\") {\n return agentRisk === \"complex_high\" ? AFFINITY.parallelAirlineComplex : AFFINITY.parallelAirline;\n }\n return AFFINITY.parallel;\n case \"code_edit\":\n case \"debug\":\n return AFFINITY.codeEdit;\n case \"reasoning\":\n return AFFINITY.reasoning;\n case \"reasoning_mcq\":\n return AFFINITY.reasoningMcq;\n case \"reasoning_math\":\n return AFFINITY.reasoningMath;\n case \"vision\":\n return AFFINITY.vision;\n case \"long_context\":\n return AFFINITY.longContext;\n case \"extraction\":\n return features.language === \"zh\" ? AFFINITY.extractionZh : AFFINITY.extraction;\n case \"chat\":\n return AFFINITY.chat;\n }\n}\n\n/** A model's affinity within a band: its calibrated score, never below neutral. */\nfunction affinityIn(band: AffinityBand, modelId: string): number {\n const name = modelId.toLowerCase().slice(modelId.indexOf(\"/\") + 1);\n return Math.max(NEUTRAL_AFFINITY, band[name] ?? 0);\n}\n\nfunction evidenceCandidates(task: TaskType): string[] {\n if (task === \"code_agent\") {\n return [\n \"openai/gpt-5.3-codex\",\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5-mini\",\n \"google/gemini-3.6-flash\",\n \"moonshot/kimi-k3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"tool_agent\") {\n return [\n \"anthropic/claude-sonnet-5\",\n \"anthropic/claude-opus-5\",\n \"openai/gpt-5-mini\",\n \"openai/gpt-4.1\",\n \"openai/gpt-4o-mini\",\n \"google/gemini-3.6-flash\",\n \"openai/gpt-5.3-codex\",\n \"moonshot/kimi-k3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"tool_agent_parallel\") {\n return [\n \"anthropic/claude-opus-5\",\n \"anthropic/claude-opus-4.8\",\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5-mini\",\n \"openai/gpt-4.1\",\n \"openai/gpt-4o-mini\",\n \"xai/grok-4.5\",\n \"google/gemini-3.6-flash\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"long_context\") {\n return [\n \"google/gemini-3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n \"qwen/qwen3.7-max\",\n \"zai/glm-5.2\",\n \"google/gemini-3.6-flash\",\n ];\n }\n if (task === \"reasoning_mcq\") {\n return [\n \"google/gemini-3-flash-preview\",\n \"google/gemini-3.6-flash\",\n \"xai/grok-4.5\",\n \"anthropic/claude-sonnet-5\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"extraction\") {\n // The Kimi flagship is not on the auto MEDIUM chain (K2.7 was); the\n // language-native extraction band (AFFINITY.extractionZh) needs it in the pool.\n return [\"moonshot/kimi-k3.1-pro\", \"google/gemini-3.6-flash\", \"anthropic/claude-sonnet-5\"];\n }\n if (task === \"reasoning_math\") {\n return [\n \"google/gemini-3.6-flash\",\n \"xai/grok-4.5\",\n \"anthropic/claude-sonnet-5\",\n \"deepseek/deepseek-v4-pro\",\n \"moonshot/kimi-k3.1-pro\",\n ];\n }\n return [];\n}\n\n/**\n * Recently added catalog models with a verified structured function call.\n *\n * Tool compliance is enough to make these models safe availability fallbacks,\n * but it is not evidence that they should displace a trajectory-benchmarked\n * primary. Keep them after the configured and benchmark-backed chains until a\n * full agent evaluation earns a task-specific affinity above NEUTRAL_AFFINITY\n * floor. `isEligible` still applies every host capability override, context\n * limit, vision constraint, and unavailable-model guard before they are used.\n */\nconst VERIFIED_TOOL_FALLBACKS = [\n \"anthropic/claude-fable-5.1\",\n \"anthropic/claude-opus-5.5\",\n \"anthropic/claude-sonnet-5.5\",\n \"deepseek/deepseek-v4.1-flash\",\n \"google/gemini-3.8-flash\",\n \"google/gemini-4-carbon\",\n \"openai/gpt-5.1\",\n \"openai/gpt-6-astra\",\n \"openai/gpt-6-luna\",\n \"openai/gpt-6-sol\",\n \"openai/gpt-6.1-sol\",\n \"xai/grok-4.6\",\n \"xai/grok-4.7\",\n \"xiaomi/mimo-v2.5\",\n] as const;\n\nfunction isEligible(\n modelId: string,\n features: TaskFeatures,\n maxOutputTokens: number,\n options: RouterOptions,\n): boolean {\n const model = options.modelCapabilities?.[modelId] ?? DEFAULT_MODEL_CAPABILITIES[modelId];\n // Preserve compatibility for temporarily catalog-less fallback IDs. They are\n // kept behind known-model candidates but are not silently dropped.\n if (!model) return true;\n if (features.needsTools && !model.supportsTools) return false;\n if (features.needsVision && !model.supportsVision) return false;\n if (features.needsStructuredOutput && !model.supportsTools) return false;\n if (model.maxOutputTokens < maxOutputTokens) return false;\n return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;\n}\n\nfunction estimatedCost(\n modelId: string,\n options: RouterOptions,\n inputTokens: number,\n outputTokens: number,\n): number {\n const price = usablePricing(options.modelPricing.get(modelId));\n if (!price) return Number.POSITIVE_INFINITY;\n if (price.flatPrice !== undefined) return price.flatPrice;\n return (inputTokens * price.inputPrice + outputTokens * price.outputPrice) / 1_000_000;\n}\n\nfunction profileScore(\n modelId: string,\n options: RouterOptions,\n now: Date,\n):\n | { quality?: number; speed: number; tailSpeed: number; reliability: number; freshness: number }\n | undefined {\n const profile: ModelPerformanceProfile | undefined =\n options.modelPerformance?.[modelId] ??\n LIVE_MODEL_PROFILES[modelId] ??\n HISTORICAL_MODEL_PROFILES[modelId];\n if (!profile) return undefined;\n const measuredAt = Date.parse(profile.measuredAt);\n if (!Number.isFinite(measuredAt)) return undefined;\n // A host-injected observation with a missing or non-numeric field would\n // turn the whole score into NaN, and NaN compares as \"equal\" in the sort,\n // freezing that candidate wherever it landed. Treat it as no observation.\n const finite = (value: number | undefined, optional: boolean) =>\n value === undefined ? optional : Number.isFinite(value) && value >= 0;\n if (\n !finite(profile.latencyMs, false) ||\n !finite(profile.outputTokensPerSecond, false) ||\n !finite(profile.p95LatencyMs, true) ||\n !finite(profile.intelligenceIndex, true) ||\n !finite(profile.errorRate, true) ||\n !finite(profile.samples, true)\n ) {\n return undefined;\n }\n const ageDays = Math.max(0, (now.getTime() - measuredAt) / 86_400_000);\n // A 30-day half-life makes old data a tie-breaker only. Small probe runs are\n // also weak evidence: three quick samples should not overturn a curated\n // tier ordering merely because of a transient provider tail. Callers that\n // inject an observation without a sample count retain the legacy full\n // confidence behaviour for compatibility.\n const sampleConfidence =\n profile.samples === undefined ? 1 : Math.min(1, Math.max(0, profile.samples) / 10);\n const freshness = Math.pow(0.5, ageDays / 30) * sampleConfidence;\n const quality =\n profile.intelligenceIndex === undefined\n ? undefined\n : Math.min(1, profile.intelligenceIndex / 50);\n const speed = Math.min(\n 1,\n (2_000 / Math.max(500, profile.latencyMs) + profile.outputTokensPerSecond / 250) / 2,\n );\n const tailSpeed = Math.min(1, 3_000 / Math.max(750, profile.p95LatencyMs ?? profile.latencyMs));\n const reliability = Math.max(0, 1 - (profile.errorRate ?? 0));\n return { quality, speed, tailSpeed, reliability, freshness };\n}\n\n/** Candidate router used for Auto. Rules still set the capability tier; V3 ranks within it. */\nexport class PortfolioStrategy implements RouterStrategy {\n readonly name = \"portfolio\";\n // Rules set the capability tier; the strategy is stateless, so one instance serves every request.\n private readonly rules = new RulesStrategy();\n\n route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n ) {\n const features = classifyTask(prompt, systemPrompt, options);\n const base = this.rules.route(prompt, systemPrompt, maxOutputTokens, {\n ...options,\n requiresTools: features.needsTools,\n });\n const tierConfigs = base.tierConfigs;\n if (!tierConfigs) return base;\n // The rules score sets the capability tier, but two task types carry a\n // floor of their own: a compact reasoning problem belongs on the\n // reasoning chain however short it is, and a code edit or stack trace\n // belongs at least on the MEDIUM chain — the SIMPLE chain is curated for\n // trivia and translation and has no model with code affinity. The code\n // floor requires a code artifact or coding action: `debug` and `code_edit`\n // are also assigned from bare verbs (\"rewrite this sentence\", \"margin of\n // error\") and bare language names (\"What is Python?\"), and that prose\n // must stay on the cheap chain.\n const targetTier: Tier =\n (features.taskType === \"reasoning_mcq\" || features.taskType === \"reasoning_math\") &&\n (base.tier === \"SIMPLE\" || base.tier === \"MEDIUM\")\n ? \"REASONING\"\n : (features.taskType === \"debug\" || features.taskType === \"code_edit\") &&\n features.codeArtifact &&\n base.tier === \"SIMPLE\"\n ? \"MEDIUM\"\n : base.tier;\n const tierConfig = tierConfigs[targetTier];\n const configuredCandidates = tierConfig ? getFallbackChain(targetTier, tierConfigs) : [];\n // Evidence candidates join the configured chain, but the host's\n // unavailable set applies to both: the configured side arrives filtered\n // through RulesStrategy, and a dead evidence model must not re-enter here.\n const unavailable = new Set(options.unavailableModels ?? []);\n // `modelPricing` is the host's live catalog view. Do not introduce a\n // built-in fallback that the current gateway does not advertise. These\n // models carry no task evidence, so outside Premium the cheapest one is\n // the first recovery hop; otherwise an outage of the curated chain would\n // jump an Eco turn straight to the most expensive model in the list.\n const verifiedToolFallbacks = features.needsTools\n ? VERIFIED_TOOL_FALLBACKS.filter((model) => options.modelPricing.has(model))\n : [];\n if (options.routingProfile !== \"premium\") {\n const fallbackCost = (model: string) =>\n estimatedCost(model, options, features.estimatedInputTokens, maxOutputTokens);\n verifiedToolFallbacks.sort((a, b) => fallbackCost(a) - fallbackCost(b));\n }\n const chain = [\n ...new Set([\n ...configuredCandidates,\n ...evidenceCandidates(features.taskType),\n ...verifiedToolFallbacks,\n ]),\n ].filter(\n (model): model is string =>\n typeof model === \"string\" && model.length > 0 && !unavailable.has(model),\n );\n const eligible = new Set(\n chain.filter((model) => isEligible(model, features, maxOutputTokens, options)),\n );\n // When nothing is eligible the whole chain competes, scored as incapable.\n const eligibleCandidates = eligible.size > 0 ? [...eligible] : chain;\n if (eligibleCandidates.length === 0) return base;\n const profileName =\n options.routingProfile === \"eco\"\n ? \"eco\"\n : options.routingProfile === \"premium\"\n ? \"premium\"\n : \"auto\";\n const portfolio = options.config.portfolio ?? DEFAULT_PORTFOLIO_WEIGHTS;\n const band = affinityBand(features);\n const affinityCache = new Map();\n const getAffinity = (model: string) => {\n let value = affinityCache.get(model);\n if (value === undefined) {\n value = affinityIn(band, model);\n affinityCache.set(model, value);\n }\n return value;\n };\n const bestAffinity = Math.max(...eligibleCandidates.map(getAffinity));\n const specificAffinity = eligibleCandidates.filter((model) => getAffinity(model) > NEUTRAL_AFFINITY);\n // A tier's fallback list is primarily an availability/recovery chain, not a\n // set of equally validated substitutes. Re-ranking every fallback lets a\n // cheap generic model displace the curated primary merely because it has a\n // favourable short performance probe. Only promote models with explicit\n // task affinity; otherwise retain the first capability-eligible tier model.\n const affinityPool = specificAffinity.length > 0 ? specificAffinity : [eligibleCandidates[0]];\n // Generic Terminal work has much wider trajectory variance than a BFCL-like\n // one-turn parallel call. Keep the strong-model safety band, but admit the\n // next capable tier so Auto's cost/reliability score can reject an Opus\n // primary that is materially more expensive without measured benefit.\n const affinityFloorGap = features.terminalToolSignal\n ? Math.max(\n portfolio.affinityFloorGap[profileName],\n features.terminalSafetySensitive ? 0.15 : 0.12,\n )\n : portfolio.affinityFloorGap[profileName];\n const candidates = affinityPool.filter(\n (model) => getAffinity(model) >= bestAffinity - affinityFloorGap,\n );\n const costs = candidates.map((model) =>\n estimatedCost(model, options, features.estimatedInputTokens, maxOutputTokens),\n );\n const finiteCosts = costs.filter(Number.isFinite);\n const minCost = finiteCosts.length > 0 ? Math.min(...finiteCosts) : 0;\n const maxCost = finiteCosts.length > 0 ? Math.max(...finiteCosts) : 1;\n\n const now = options.now ?? new Date();\n const profileWeights = portfolio[profileName];\n const rankedEntries = candidates\n .map((model, index) => {\n const cost = costs[index];\n // An unpriced candidate costs an unknown amount, so it scores as the\n // most expensive rather than a neutral 0.5 that let it outrank\n // priced models. Pricing presence still never filters a candidate.\n const costScore = !Number.isFinite(cost)\n ? 0\n : maxCost > minCost\n ? 1 - (cost - minCost) / (maxCost - minCost)\n : 0.5;\n const capabilityScore = eligible.has(model) ? 1 : 0;\n const profile = profileScore(model, options, now);\n // Fresh observations can refine affinity. Historical observations fade\n // quickly and never replace task-level RouterBench evidence.\n const observedQuality =\n profile?.quality === undefined\n ? getAffinity(model)\n : getAffinity(model) * (1 - profile.freshness) + profile.quality * profile.freshness;\n // Every observed dimension fades toward its neutral prior as the\n // observation ages, exactly like reliability below. Fading speed\n // toward zero instead ranked any model with a stale probe below a\n // model nobody had measured, which the latter's 0.5 silently won.\n const observedSpeed = profile\n ? profile.speed * profile.freshness + 0.5 * (1 - profile.freshness)\n : 0.5;\n const observedTailSpeed = profile\n ? profile.tailSpeed * profile.freshness + 0.5 * (1 - profile.freshness)\n : 0.5;\n const observedReliability = profile\n ? profile.reliability * profile.freshness + (1 - profile.freshness)\n : 1;\n // Preserve a small amount of the hand-curated fallback order while V3's\n // task affinity and real request constraints do the primary work.\n const legacyScore = 1 - index / Math.max(1, candidates.length - 1);\n const qualityWeight =\n profileWeights.quality + (features.highStakes ? portfolio.highStakesBoost.quality : 0);\n const speedScore = features.latencySensitive ? observedTailSpeed : observedSpeed;\n const speedWeight =\n profileWeights.speed +\n (features.latencySensitive ? portfolio.latencySensitiveSpeedBoost : 0);\n const reliabilityWeight =\n profileWeights.reliability +\n (features.highStakes ? portfolio.highStakesBoost.reliability : 0);\n const score =\n observedQuality * qualityWeight +\n capabilityScore * profileWeights.capability +\n costScore * profileWeights.cost +\n speedScore * speedWeight +\n observedReliability * reliabilityWeight +\n legacyScore * profileWeights.legacy;\n return {\n model,\n score,\n quality: observedQuality,\n cost: costScore,\n speed: speedScore,\n reliability: observedReliability,\n };\n })\n .sort((a, b) => b.score - a.score);\n const scoredModels = rankedEntries.map((item) => item.model);\n // The affinity floor controls which models may compete for the primary;\n // it must not erase availability fallbacks. Append all remaining eligible\n // models in their curated chain order after the scored primary pool.\n const webResearchFallbackOrder = [\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5-mini\",\n \"google/gemini-3.6-flash\",\n \"anthropic/claude-opus-5\",\n \"anthropic/claude-opus-4.8\",\n \"openai/gpt-5.3-codex\",\n ];\n const ranked =\n features.agentDomain === \"web_research\"\n ? [\n ...scoredModels,\n ...webResearchFallbackOrder.filter(\n (model) => eligibleCandidates.includes(model) && !scoredModels.includes(model),\n ),\n ...eligibleCandidates.filter(\n (model) => !scoredModels.includes(model) && !webResearchFallbackOrder.includes(model),\n ),\n ]\n : [...scoredModels, ...eligibleCandidates.filter((model) => !scoredModels.includes(model))];\n\n const model = ranked[0] ?? base.model;\n const selectedTierConfigs: Record = {\n ...tierConfigs,\n [targetTier]: { primary: model, fallback: ranked.slice(1) },\n };\n // selectModel only reads the selected tier; retain the complete tier map for host fallback.\n const decision = selectModel(\n targetTier,\n base.confidence,\n \"portfolio\",\n `${base.reasoning} | v3 task=${features.taskType} agentRisk=${features.agentRisk} deepWebResearch=${features.deepWebResearch} terminalCode=${features.implicitTerminalCode} terminalSafety=${features.terminalSafetySensitive} candidates=${ranked.length}`,\n selectedTierConfigs,\n options.modelPricing,\n features.estimatedInputTokens,\n maxOutputTokens,\n options.routingProfile,\n base.agenticScore,\n );\n return {\n ...decision,\n tierConfigs: selectedTierConfigs,\n profile: base.profile,\n candidates: ranked,\n candidateScores: rankedEntries.map(({ model, score, quality, cost, speed, reliability }) => ({\n model,\n score,\n quality,\n cost,\n speed,\n reliability,\n })),\n taskType: features.taskType,\n routerVersion: \"v3-portfolio\" as const,\n };\n }\n}\n","/** Pure public-catalog parsing. Fetching, caching and UI ordering belong to hosts. */\nimport { DEFAULT_MODEL_CAPABILITIES, type ModelCapabilities } from \"./model-capabilities.js\";\nimport type { ModelPricing } from \"./selector.js\";\n\nexport const MODEL_KINDS = [\"chat\", \"image\", \"video\", \"music\"] as const;\nexport type ModelKind = (typeof MODEL_KINDS)[number];\n\n/** Gateway units are preserved: token prices per 1M tokens; media per unit. */\nexport interface CatalogPricing {\n input?: number;\n output?: number;\n per_image?: number;\n per_second?: number;\n per_track?: number;\n cache_read?: number;\n cache_write?: number;\n transaction_fee?: number;\n per_call_surcharge?: number;\n default_duration_seconds?: number;\n max_duration_seconds?: number;\n}\n\nexport interface CatalogModel {\n id: string;\n name: string;\n categories: readonly string[];\n kinds: readonly ModelKind[];\n billingMode?: string;\n /** Zero pricing alone does not imply a free model. */\n free: boolean;\n pricing: CatalogPricing;\n contextWindow?: number;\n maxOutputTokens?: number;\n}\n\nexport interface ModelCatalog {\n models: readonly CatalogModel[];\n chat: readonly CatalogModel[];\n image: readonly CatalogModel[];\n video: readonly CatalogModel[];\n music: readonly CatalogModel[];\n /**\n * IDs whose authoritative row says `available: false`. The gateway does not\n * reject these; it substitutes another model. Absence from the listing is\n * not unavailability: hidden IDs are still served.\n */\n unavailable: readonly string[];\n}\n\nconst PRICE_KEYS = [\n \"input\", \"output\", \"per_image\", \"per_second\", \"per_track\", \"cache_read\", \"cache_write\",\n \"transaction_fee\", \"per_call_surcharge\", \"default_duration_seconds\", \"max_duration_seconds\",\n] as const;\nconst UNIT_PRICE = { image: \"per_image\", video: \"per_second\", music: \"per_track\" } as const;\nconst MODEL_ID = /^[a-z0-9][a-z0-9._-]*\\/[a-zA-Z0-9][a-zA-Z0-9._:+-]*$/;\nconst record = (value: unknown): value is Record =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst price = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value) && value >= 0;\nconst capacity = (value: unknown): number | undefined =>\n typeof value === \"number\" && Number.isSafeInteger(value) && value > 0 ? value : undefined;\n\n/**\n * Normalize GET /api/v1/models without a model-ID allowlist. New provider IDs\n * appear immediately. Hidden/unavailable rows and invalid per-kind prices are\n * omitted. A malformed envelope throws so a host can retain its last good list;\n * an explicitly empty `data` array is a valid empty catalog.\n *\n * IDs explicitly marked `available: false` are also listed in `unavailable`.\n * Rows outside MODEL_KINDS (speech, sound effects) are omitted.\n *\n * Last duplicate wins, including a final unavailable/invalid row. No sorting,\n * price markup, network request, capability probe or media routing is performed.\n */\nexport function parseModelCatalog(value: unknown): ModelCatalog {\n if (!record(value) || !Array.isArray(value.data)) {\n throw new TypeError(\"Model catalog must contain a data array\");\n }\n const entries = new Map>();\n for (const entry of value.data) {\n if (record(entry) && typeof entry.id === \"string\" && entry.id.length <= 200 && MODEL_ID.test(entry.id)) {\n entries.set(entry.id, entry);\n }\n }\n const result: ModelCatalog = { models: [], chat: [], image: [], video: [], music: [], unavailable: [] };\n const models: CatalogModel[] = [];\n const unavailable: string[] = [];\n for (const [id, entry] of entries) {\n if (entry.available === false) unavailable.push(id);\n if ((entry.available !== undefined && entry.available !== true) ||\n (entry.hidden !== undefined && entry.hidden !== false) ||\n !Array.isArray(entry.categories) || !record(entry.pricing)) continue;\n const categories = [...new Set(entry.categories.filter((c): c is string => typeof c === \"string\"))];\n const rawPricing = entry.pricing;\n const pricing: CatalogPricing = {};\n for (const key of PRICE_KEYS) if (price(rawPricing[key])) pricing[key] = rawPricing[key];\n const kinds = MODEL_KINDS.filter(kind => categories.includes(kind) && (kind === \"chat\"\n ? price(rawPricing.input) && price(rawPricing.output)\n : price(rawPricing[UNIT_PRICE[kind]])));\n if (!kinds.length) continue;\n const model: CatalogModel = {\n id, name: typeof entry.name === \"string\" && entry.name.trim() ? entry.name : id,\n categories, kinds, pricing,\n free: kinds.includes(\"chat\") && entry.billing_mode === \"free\" && pricing.input === 0 && pricing.output === 0,\n ...(typeof entry.billing_mode === \"string\" ? { billingMode: entry.billing_mode } : {}),\n ...(capacity(entry.context_window) !== undefined ? { contextWindow: capacity(entry.context_window) } : {}),\n ...(capacity(entry.max_output) !== undefined ? { maxOutputTokens: capacity(entry.max_output) } : {}),\n };\n models.push(model);\n }\n result.models = models;\n result.unavailable = unavailable;\n for (const kind of MODEL_KINDS) result[kind] = models.filter(model => model.kinds.includes(kind));\n return result;\n}\n\nexport interface CatalogRoutingOptions {\n /** Host evidence, merged over (and overriding per ID) the bundled verified table. */\n verifiedCapabilities?: Readonly>;\n}\n\nexport interface RoutingCatalog {\n modelPricing: Map;\n modelCapabilities: Record;\n unavailableModels: string[];\n}\n\n/**\n * Adapt only the chat catalog for route(). Media never enters LLM candidate\n * chains. Tool support comes from verified evidence, never a name or category.\n * Unknown capacities are zero, rather than invented defaults.\n *\n * Only rows the gateway explicitly marks `available: false` become\n * unavailableModels. Configured IDs that are merely absent from the listing\n * stay routable: the gateway serves hidden IDs, and only the configured chain\n * knows about them.\n */\nexport function toRoutingCatalog(catalog: ModelCatalog, options: CatalogRoutingOptions = {}): RoutingCatalog {\n const verified = { ...DEFAULT_MODEL_CAPABILITIES, ...options.verifiedCapabilities };\n const modelPricing = new Map();\n const modelCapabilities: Record = {};\n for (const model of catalog.chat) {\n modelPricing.set(model.id, { inputPrice: model.pricing.input!, outputPrice: model.pricing.output! });\n const evidence = verified[model.id];\n modelCapabilities[model.id] = {\n contextWindow: model.contextWindow ?? evidence?.contextWindow ?? 0,\n maxOutputTokens: model.maxOutputTokens ?? evidence?.maxOutputTokens ?? 0,\n supportsTools: evidence?.supportsTools === true,\n // Verified evidence wins over the category tag in both directions: the\n // catalog omits \"vision\" for some models that accept images and tags\n // others whose image input does not hold up (see capability-overrides).\n supportsVision: evidence?.supportsVision ?? model.categories.includes(\"vision\"),\n };\n }\n return { modelPricing, modelCapabilities, unavailableModels: [...catalog.unavailable] };\n}\n","/**\n * Smart Router Entry Point\n *\n * Classifies requests and routes to the cheapest capable model.\n * Delegates to pluggable RouterStrategy (default: RulesStrategy, <1ms).\n */\n\nimport type { RoutingDecision, RouterOptions } from \"./types.js\";\nimport { getStrategy, registerStrategy } from \"./strategy.js\";\nimport { PortfolioStrategy } from \"./portfolio.js\";\n\n// Register here instead of strategy.ts so PortfolioStrategy can reuse the\n// stable RulesStrategy without introducing a module cycle.\nregisterStrategy(new PortfolioStrategy());\n\n/**\n * Route a request to the cheapest capable model.\n * Delegates to the configured strategy (PortfolioStrategy by default).\n */\nexport function route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n): RoutingDecision {\n const strategy = getStrategy(options.config.strategy ?? \"portfolio\");\n return strategy.route(prompt, systemPrompt, maxOutputTokens, options);\n}\n\nexport { getStrategy, registerStrategy, applyUnavailableModels } from \"./strategy.js\";\nexport { RulesStrategy } from \"./strategy.js\";\nexport { PortfolioStrategy } from \"./portfolio.js\";\nexport { classifyByRules } from \"./rules.js\";\nexport { inferToolRequirement } from \"./tool-intent.js\";\nexport { estimateTokens } from \"./tokens.js\";\nexport { MODEL_KINDS, parseModelCatalog, toRoutingCatalog } from \"./catalog.js\";\nexport type {\n ModelKind, CatalogPricing, CatalogModel, ModelCatalog, CatalogRoutingOptions, RoutingCatalog,\n} from \"./catalog.js\";\nexport {\n getFallbackChain,\n getFallbackChainFiltered,\n filterByToolCalling,\n filterByVision,\n filterByExcludeList,\n filterCandidatesByCapacity,\n calculateModelCost,\n} from \"./selector.js\";\nexport { DEFAULT_ROUTING_CONFIG } from \"./config.js\";\nexport { DEFAULT_MODEL_CAPABILITIES } from \"./model-capabilities.js\";\nexport { LIVE_MODEL_PROFILES, HISTORICAL_MODEL_PROFILES } from \"./model-profiles.js\";\nexport type {\n RoutingDecision,\n Tier,\n TaskType,\n RoutingConfig,\n RouterOptions,\n RouterStrategy,\n} from \"./types.js\";\nexport type { ModelPricing } from \"./selector.js\";\nexport type { ModelCapabilities } from \"./model-capabilities.js\";\nexport type { ModelPerformanceProfile } from \"./model-profiles.js\";\n"],"mappings":";AAiCA,IAAM,qBACJ;AACF,IAAM,YAAY;AAClB,IAAM,eAAe;AAIrB,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB,QAAQ,mBAAmB;AACnD,IAAM,iBAAiB,OAAO,mBAAmB;AACjD,IAAM,2BAA2B;AACjC,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AACxB,IAAM,eACJ;AACF,IAAM,qBAAqB;AAC3B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,aAAa,MAAM,QAAQ,OAAQ,CAAC;AACnG,UAAM,WAAW,SAAS,MAAM,EAAE;AAClC,sBAAkB,MAAM,EAAE,IAAI;AAAA,MAC5B,eAAe,MAAM,iBAAiB,UAAU,iBAAiB;AAAA,MACjE,iBAAiB,MAAM,mBAAmB,UAAU,mBAAmB;AAAA,MACvE,eAAe,UAAU,kBAAkB;AAAA;AAAA;AAAA;AAAA,MAI3C,gBAAgB,UAAU,kBAAkB,MAAM,WAAW,SAAS,QAAQ;AAAA,IAChF;AAAA,EACF;AACA,SAAO,EAAE,cAAc,mBAAmB,mBAAmB,CAAC,GAAG,QAAQ,WAAW,EAAE;AACxF;;;AC9IA,iBAAiB,IAAI,kBAAkB,CAAC;AAMjC,SAAS,MACd,QACA,cACA,iBACA,SACiB;AACjB,QAAM,WAAW,YAAY,QAAQ,OAAO,YAAY,WAAW;AACnE,SAAO,SAAS,MAAM,QAAQ,cAAc,iBAAiB,OAAO;AACtE;","names":["confidence","decision","price","model"]} \ No newline at end of file +{"version":3,"sources":["../src/rules.ts","../src/selector.ts","../src/tokens.ts","../src/strategy.ts","../src/config.ts","../src/model-capabilities.ts","../src/model-profiles.generated.json","../src/model-profiles.ts","../src/tool-intent.ts","../src/portfolio.ts","../src/catalog.ts","../src/index.ts"],"sourcesContent":["/**\n * Rule-Based Classifier (v2 — Weighted Scoring)\n *\n * Scores a request across 15 weighted dimensions and maps the aggregate\n * score to a tier using configurable boundaries. Confidence is calibrated\n * via sigmoid — low confidence triggers the fallback classifier.\n *\n * Handles 70-80% of requests in < 1ms with zero cost.\n */\n\nimport type { Tier, ScoringResult, ScoringConfig } from \"./types.js\";\n\ntype DimensionScore = { name: string; score: number; signal: string | null };\n\n// ─── Keyword Matching ───\n//\n// A plain substring test counted `class` in \"classic\", `story` in \"history\",\n// `edit` in \"credit\" and `fix` in \"prefix\", so everyday prose picked up code,\n// creative and agentic signals it did not carry. Alphabetic keywords now have\n// to start at a word boundary. Short ASCII keywords additionally have to end\n// at one, after an optional inflection, graded by how much a stray suffix can\n// change the word: a three-letter keyword takes only the English endings that\n// cannot spell another word (fix → fixes, never pip → pipe or def → defer); a\n// four-to-six-letter keyword also takes the common German and Romance endings,\n// because the lists spell those languages in ASCII too (beweis → beweise,\n// klasse → klassen); anything longer stays trailing-open like the substring\n// test it replaces, since its false-positive surface is small and its\n// inflection surface is large. Non-ASCII alphabetic keywords keep a\n// trailing-open match because several are deliberate stems (`оптимизаци`,\n// `рассуждени`). CJK, Hangul and Arabic keywords keep the substring test:\n// those scripts have no word boundaries, or attach particles and articles\n// directly to the word.\n\nconst UNSEGMENTED_SCRIPT =\n /[؀-ۿ -ヿ㐀-䶿一-鿿가-힯豈-﫿＀-￯]/;\nconst WORD_CHAR = /[\\p{L}\\p{N}]/u;\nconst ASCII_PHRASE = /^[a-z0-9' -]+$/;\n// A word boundary is a transition out of the segmented scripts. A CJK\n// character next to a Latin keyword (\"请step by step证明\") is a boundary, not\n// part of the word: mixed-script prompts carry no spaces between scripts.\nconst SEGMENTED_WORD_CHAR = \"\\\\p{Script=Latin}\\\\p{Script=Cyrillic}\\\\p{Script=Greek}\\\\p{N}\";\nconst BOUNDARY_BEFORE = `(?();\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction keywordMatcher(keyword: string): KeywordMatcher {\n const cached = matcherCache.get(keyword);\n if (cached) return cached;\n\n const kw = keyword.toLowerCase();\n let matcher: KeywordMatcher;\n if (UNSEGMENTED_SCRIPT.test(kw) || kw.length === 0) {\n matcher = { needle: kw, pattern: null };\n } else {\n const lead = WORD_CHAR.test(kw[0]) ? BOUNDARY_BEFORE : \"\";\n const escaped = escapeRegExp(kw);\n let body = escaped;\n let trail = \"\";\n let needle = kw;\n const lastWord = kw.slice(kw.lastIndexOf(\" \") + 1);\n if (\n WORD_CHAR.test(kw[kw.length - 1]) &&\n ASCII_PHRASE.test(kw) &&\n lastWord.length <= BOUNDED_LAST_WORD_LENGTH\n ) {\n // ASCII phrases contain no regex metacharacters, so `escaped` slices\n // align with `kw` slices below.\n const forms: string[] = [];\n if (/\\d$/.test(kw)) {\n // \"step 1\" must not absorb \"step 10\".\n forms.push(escaped);\n } else if (lastWord.length <= 3) {\n forms.push(`${escaped}${SHORT_SUFFIXES}`);\n if (/(?:x|s|z|ch|sh)$/.test(kw)) forms.push(`${escaped}${SIBILANT_PLURAL}`);\n } else {\n forms.push(`${escaped}${MID_SUFFIXES}`);\n if (kw.endsWith(\"e\")) {\n forms.push(`${escaped.slice(0, -1)}${DROPPED_E_SUFFIXES}`);\n needle = kw.slice(0, -1);\n } else if (kw.endsWith(\"y\")) {\n forms.push(`${escaped.slice(0, -1)}(?:ies|ied)`);\n needle = kw.slice(0, -1);\n } else if (/[aeiou][bdgmnprt]$/.test(kw)) {\n // debug → debugging, plan → planned\n forms.push(`${escaped}${kw[kw.length - 1]}${DOUBLED_CONSONANT_SUFFIXES}`);\n }\n }\n body = `(?:${forms.join(\"|\")})`;\n trail = BOUNDARY_AFTER;\n }\n matcher = { needle, pattern: new RegExp(`${lead}${body}${trail}`, \"u\") };\n }\n matcherCache.set(keyword, matcher);\n return matcher;\n}\n\n/** Whether lower-cased `text` contains `keyword` as a word (or as a substring for CJK). */\nfunction matchesKeyword(text: string, keyword: string): boolean {\n const { needle, pattern } = keywordMatcher(keyword);\n if (!text.includes(needle)) return false;\n return pattern === null ? true : pattern.test(text);\n}\n\n// ─── Dimension Scorers ───\n// Each returns a score in [-1, 1] and an optional signal string.\n\nfunction scoreTokenCount(\n estimatedTokens: number,\n thresholds: { simple: number; complex: number },\n): DimensionScore {\n if (estimatedTokens < thresholds.simple) {\n return { name: \"tokenCount\", score: -1.0, signal: `short (${estimatedTokens} tokens)` };\n }\n if (estimatedTokens > thresholds.complex) {\n return { name: \"tokenCount\", score: 1.0, signal: `long (${estimatedTokens} tokens)` };\n }\n return { name: \"tokenCount\", score: 0, signal: null };\n}\n\nfunction scoreKeywordMatch(\n text: string,\n keywords: string[],\n name: string,\n signalLabel: string,\n thresholds: { low: number; high: number },\n scores: { none: number; low: number; high: number },\n): DimensionScore {\n const matches = keywords.filter((kw) => matchesKeyword(text, kw));\n if (matches.length >= thresholds.high) {\n return {\n name,\n score: scores.high,\n signal: `${signalLabel} (${matches.slice(0, 3).join(\", \")})`,\n };\n }\n if (matches.length >= thresholds.low) {\n return {\n name,\n score: scores.low,\n signal: `${signalLabel} (${matches.slice(0, 3).join(\", \")})`,\n };\n }\n return { name, score: scores.none, signal: null };\n}\n\nfunction scoreMultiStep(text: string): DimensionScore {\n // A numbered list item must start a line: a bare \"\\d\\.\\s\" also matched\n // every sentence that ends in a number (\"born in 1990. How old…\").\n const patterns = [/first.*then/i, /step \\d/i, /(?:^|\\n)\\s*\\d+[.)]\\s/];\n const hits = patterns.filter((p) => p.test(text));\n if (hits.length > 0) {\n return { name: \"multiStepPatterns\", score: 0.5, signal: \"multi-step\" };\n }\n return { name: \"multiStepPatterns\", score: 0, signal: null };\n}\n\nfunction scoreQuestionComplexity(prompt: string): DimensionScore {\n const count = (prompt.match(/[??]/g) || []).length;\n if (count > 3) {\n return { name: \"questionComplexity\", score: 0.5, signal: `${count} questions` };\n }\n return { name: \"questionComplexity\", score: 0, signal: null };\n}\n\n/**\n * Score agentic task indicators.\n * Returns agenticScore (0-1) based on keyword matches:\n * - 4+ matches = 1.0 (high agentic)\n * - 3 matches = 0.6 (moderate agentic, triggers auto-agentic mode)\n * - 1-2 matches = 0.2 (low agentic)\n *\n * Thresholds raised because common keywords were pruned from the list.\n */\nfunction scoreAgenticTask(\n text: string,\n keywords: string[],\n): { dimensionScore: DimensionScore; agenticScore: number } {\n let matchCount = 0;\n const signals: string[] = [];\n\n for (const keyword of keywords) {\n if (matchesKeyword(text, keyword)) {\n matchCount++;\n if (signals.length < 3) {\n signals.push(keyword);\n }\n }\n }\n\n // Threshold-based scoring (raised thresholds after keyword pruning)\n if (matchCount >= 4) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 1.0,\n signal: `agentic (${signals.join(\", \")})`,\n },\n agenticScore: 1.0,\n };\n } else if (matchCount >= 3) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 0.6,\n signal: `agentic (${signals.join(\", \")})`,\n },\n agenticScore: 0.6,\n };\n } else if (matchCount >= 1) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 0.2,\n signal: `agentic-light (${signals.join(\", \")})`,\n },\n agenticScore: 0.2,\n };\n }\n\n return {\n dimensionScore: { name: \"agenticTask\", score: 0, signal: null },\n agenticScore: 0,\n };\n}\n\n// ─── Main Classifier ───\n\nexport function classifyByRules(\n prompt: string,\n systemPrompt: string | undefined,\n estimatedTokens: number,\n config: ScoringConfig,\n): ScoringResult {\n // Score against user prompt only — system prompts contain boilerplate keywords\n // (tool definitions, skill descriptions, behavioral rules) that dominate scoring\n // and make every request score identically. See GitHub issue #50.\n const userText = prompt.toLowerCase();\n\n const reasoningDimension = scoreKeywordMatch(\n userText,\n config.reasoningKeywords,\n \"reasoningMarkers\",\n \"reasoning\",\n { low: 1, high: 2 },\n { none: 0, low: 0.7, high: 1.0 },\n );\n\n // Score the base dimensions against user text only; the agentic dimension is\n // appended below, so the scored total is one more than this list.\n const dimensions: DimensionScore[] = [\n // Token count uses total estimated tokens (system + user) — context size matters for model selection\n scoreTokenCount(estimatedTokens, config.tokenCountThresholds),\n scoreKeywordMatch(\n userText,\n config.codeKeywords,\n \"codePresence\",\n \"code\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 1.0 },\n ),\n reasoningDimension,\n scoreKeywordMatch(\n userText,\n config.technicalKeywords,\n \"technicalTerms\",\n \"technical\",\n { low: 2, high: 4 },\n { none: 0, low: 0.5, high: 1.0 },\n ),\n scoreKeywordMatch(\n userText,\n config.creativeKeywords,\n \"creativeMarkers\",\n \"creative\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.simpleKeywords,\n \"simpleIndicators\",\n \"simple\",\n { low: 1, high: 2 },\n { none: 0, low: -1.0, high: -1.0 },\n ),\n scoreMultiStep(userText),\n scoreQuestionComplexity(prompt),\n\n // 6 new dimensions\n scoreKeywordMatch(\n userText,\n config.imperativeVerbs,\n \"imperativeVerbs\",\n \"imperative\",\n { low: 1, high: 2 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.constraintIndicators,\n \"constraintCount\",\n \"constraints\",\n { low: 1, high: 3 },\n { none: 0, low: 0.3, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.outputFormatKeywords,\n \"outputFormat\",\n \"format\",\n { low: 1, high: 2 },\n { none: 0, low: 0.4, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.referenceKeywords,\n \"referenceComplexity\",\n \"references\",\n { low: 1, high: 2 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.negationKeywords,\n \"negationComplexity\",\n \"negation\",\n { low: 2, high: 3 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.domainSpecificKeywords,\n \"domainSpecificity\",\n \"domain-specific\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 0.8 },\n ),\n ];\n\n // Score agentic task indicators — user prompt only\n // System prompt describes assistant behavior, not user's intent.\n // e.g. a coding assistant system prompt with \"edit files\" / \"fix bugs\" should NOT\n // force every request into agentic mode.\n const agenticResult = scoreAgenticTask(userText, config.agenticTaskKeywords);\n dimensions.push(agenticResult.dimensionScore);\n const agenticScore = agenticResult.agenticScore;\n\n // Collect signals\n const signals = dimensions.filter((d) => d.signal !== null).map((d) => d.signal!);\n\n // Compute weighted score\n const weights = config.dimensionWeights;\n let weightedScore = 0;\n for (const d of dimensions) {\n const w = weights[d.name] ?? 0;\n weightedScore += d.score * w;\n }\n\n // Direct reasoning override: 2+ reasoning markers in the USER prompt = high\n // confidence REASONING. The system prompt is never read here, so a host\n // instruction like \"think step by step\" cannot lift every query to REASONING.\n // The reasoning dimension already counted those matches; its score is 1.0\n // exactly when two or more matched.\n if (reasoningDimension.score === 1.0) {\n const confidence = calibrateConfidence(\n Math.max(weightedScore, 0.3), // ensure positive for confidence calc\n config.confidenceSteepness,\n );\n return {\n score: weightedScore,\n tier: \"REASONING\",\n confidence: Math.max(confidence, 0.85),\n signals,\n agenticScore,\n dimensions,\n };\n }\n\n // Map weighted score to tier using boundaries\n const { simpleMedium, mediumComplex, complexReasoning } = config.tierBoundaries;\n let tier: Tier;\n let distanceFromBoundary: number;\n\n if (weightedScore < simpleMedium) {\n tier = \"SIMPLE\";\n distanceFromBoundary = simpleMedium - weightedScore;\n } else if (weightedScore < mediumComplex) {\n tier = \"MEDIUM\";\n distanceFromBoundary = Math.min(weightedScore - simpleMedium, mediumComplex - weightedScore);\n } else if (weightedScore < complexReasoning) {\n tier = \"COMPLEX\";\n distanceFromBoundary = Math.min(\n weightedScore - mediumComplex,\n complexReasoning - weightedScore,\n );\n } else {\n tier = \"REASONING\";\n distanceFromBoundary = weightedScore - complexReasoning;\n }\n\n // Calibrate confidence via sigmoid of distance from nearest boundary\n const confidence = calibrateConfidence(distanceFromBoundary, config.confidenceSteepness);\n\n // If confidence is below threshold → ambiguous\n if (confidence < config.confidenceThreshold) {\n return { score: weightedScore, tier: null, confidence, signals, agenticScore, dimensions };\n }\n\n return { score: weightedScore, tier, confidence, signals, agenticScore, dimensions };\n}\n\n/**\n * Sigmoid confidence calibration.\n * Maps distance from tier boundary to [0.5, 1.0] confidence range.\n */\nfunction calibrateConfidence(distance: number, steepness: number): number {\n return 1 / (1 + Math.exp(-steepness * distance));\n}\n","/**\n * Tier → Model Selection\n *\n * Maps a classification tier to the cheapest capable model.\n * Builds RoutingDecision metadata with cost estimates and savings.\n */\n\nimport type { Tier, TierConfig, RoutingDecision } from \"./types.js\";\n\nexport type ModelPricing = {\n inputPrice: number; // per 1M tokens\n outputPrice: number; // per 1M tokens\n /** Active promo flat price per request (overrides token-based pricing when set) */\n flatPrice?: number;\n};\n\n// The savings baseline is a price anchor, not \"the current flagship\" — it is\n// deliberately NOT bumped every time a new Opus ships. Opus 4.7, 4.8 and 5 all\n// bill $5/$25, so moving it would change no reported number while breaking\n// comparability with historical journal entries. Only move it if the Opus tier\n// itself is repriced.\nconst BASELINE_MODEL_ID = \"anthropic/claude-opus-4.7\";\n\n// Hardcoded fallback: Claude Opus 4.7 pricing (per 1M tokens)\n// Used when baseline model not found in dynamic pricing map\nconst BASELINE_INPUT_PRICE = 5.0;\nconst BASELINE_OUTPUT_PRICE = 25.0;\n\n/**\n * The pricing entry, or undefined when any field it carries is not a finite,\n * non-negative number. A hand-built price map with a NaN would otherwise put\n * NaN into costEstimate and savings; a malformed price is an unknown price.\n */\nexport function usablePricing(pricing: ModelPricing | undefined): ModelPricing | undefined {\n if (!pricing) return undefined;\n const ok = (value: number | undefined) =>\n value === undefined || (Number.isFinite(value) && value >= 0);\n if (pricing.flatPrice !== undefined) return ok(pricing.flatPrice) ? pricing : undefined;\n return ok(pricing.inputPrice) && ok(pricing.outputPrice) ? pricing : undefined;\n}\n\n/** Raw token cost (no margin, no floor), or the flat promo price when one is set. */\nfunction rawCost(\n pricing: ModelPricing | undefined,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n): number {\n if (pricing?.flatPrice !== undefined) return pricing.flatPrice;\n const inputPrice = pricing?.inputPrice ?? 0;\n const outputPrice = pricing?.outputPrice ?? 0;\n return (estimatedInputTokens / 1_000_000) * inputPrice + (maxOutputTokens / 1_000_000) * outputPrice;\n}\n\n/** What the anchor Opus tier would cost for the same request (see BASELINE_MODEL_ID). */\nfunction baselineCostFor(\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n): number {\n const opusPricing = usablePricing(modelPricing.get(BASELINE_MODEL_ID));\n const inputPrice = opusPricing?.inputPrice ?? BASELINE_INPUT_PRICE;\n const outputPrice = opusPricing?.outputPrice ?? BASELINE_OUTPUT_PRICE;\n return (estimatedInputTokens / 1_000_000) * inputPrice + (maxOutputTokens / 1_000_000) * outputPrice;\n}\n\n/**\n * Fractional savings against the baseline. Premium reports none (it is about\n * quality, not cost), and a model the host has no price for costs an unknown\n * amount, not nothing: reporting its savings as 100% would be a fabricated\n * figure.\n */\nfunction savingsFor(\n costEstimate: number,\n baselineCost: number,\n pricing: ModelPricing | undefined,\n routingProfile: string | undefined,\n): number {\n if (routingProfile === \"premium\" || pricing === undefined || !(baselineCost > 0)) return 0;\n return Math.max(0, (baselineCost - costEstimate) / baselineCost);\n}\n\n/**\n * Select the primary model for a tier and build the RoutingDecision.\n *\n * Cost contract: the estimates here are raw token economics — no server\n * margin, no minimum-payment floor. `calculateModelCost` below applies both\n * to match the actual x402 charge, and hosts that display money (ClawRouter's\n * proxy does) recompute through it rather than reading these fields. Folding\n * the margin in here would double-apply it in every such host.\n */\nexport function selectModel(\n tier: Tier,\n confidence: number,\n method: \"rules\" | \"llm\" | \"portfolio\",\n reasoning: string,\n tierConfigs: Record,\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n routingProfile?: \"free\" | \"eco\" | \"auto\" | \"premium\",\n agenticScore?: number,\n): RoutingDecision {\n const tierConfig = tierConfigs[tier];\n const model = tierConfig.primary;\n const pricing = usablePricing(modelPricing.get(model));\n\n const costEstimate = rawCost(pricing, estimatedInputTokens, maxOutputTokens);\n const baselineCost = baselineCostFor(modelPricing, estimatedInputTokens, maxOutputTokens);\n const savings = savingsFor(costEstimate, baselineCost, pricing, routingProfile);\n\n return {\n model,\n tier,\n confidence,\n method,\n reasoning,\n costEstimate,\n baselineCost,\n savings,\n ...(agenticScore !== undefined && { agenticScore }),\n };\n}\n\n/**\n * Get the ordered fallback chain for a tier: [primary, ...fallbacks].\n */\nexport function getFallbackChain(tier: Tier, tierConfigs: Record): string[] {\n const config = tierConfigs[tier];\n return [config.primary, ...config.fallback];\n}\n\n// Server-side margin applied to all x402 payments (must match blockrun server's MARGIN_PERCENT)\nconst SERVER_MARGIN_PERCENT = 5;\n// Minimum payment enforced by CDP Facilitator (must match blockrun server's MIN_PAYMENT_USD)\nconst MIN_PAYMENT_USD = 0.001;\n\n/**\n * Calculate charge-accurate cost fields for a specific model (server margin\n * and minimum-payment floor included — see the cost contract on selectModel).\n * Hosts call this to display money and to recost a decision after a fallback.\n */\nexport function calculateModelCost(\n model: string,\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n routingProfile?: \"free\" | \"eco\" | \"auto\" | \"premium\",\n): { costEstimate: number; baselineCost: number; savings: number } {\n const pricing = usablePricing(modelPricing.get(model));\n\n // Server margin + minimum payment, to match the actual x402 charge.\n const costEstimate = Math.max(\n rawCost(pricing, estimatedInputTokens, maxOutputTokens) * (1 + SERVER_MARGIN_PERCENT / 100),\n MIN_PAYMENT_USD,\n );\n const baselineCost = baselineCostFor(modelPricing, estimatedInputTokens, maxOutputTokens);\n const savings = savingsFor(costEstimate, baselineCost, pricing, routingProfile);\n\n return { costEstimate, baselineCost, savings };\n}\n\n/** The models satisfying `keep`, or every model when none does. */\nfunction keepOrFailOpen(models: string[], keep: (modelId: string) => boolean): string[] {\n const filtered = models.filter(keep);\n return filtered.length > 0 ? filtered : models;\n}\n\n/**\n * Filter a model list to only those that support tool calling.\n * When hasTools is false, returns the list unchanged.\n * When all models lack tool calling support, returns the full list as a fallback\n * (better to let the API error than produce an empty chain).\n */\nexport function filterByToolCalling(\n models: string[],\n hasTools: boolean,\n supportsToolCalling: (modelId: string) => boolean,\n): string[] {\n return hasTools ? keepOrFailOpen(models, supportsToolCalling) : models;\n}\n\n/**\n * Filter a model list to only those that support vision (image inputs).\n * When hasVision is false, returns the list unchanged.\n * When all models lack vision support, returns the full list as a fallback\n * (better to let the API error than produce an empty chain).\n */\nexport function filterByVision(\n models: string[],\n hasVision: boolean,\n supportsVision: (modelId: string) => boolean,\n): string[] {\n return hasVision ? keepOrFailOpen(models, supportsVision) : models;\n}\n\n/**\n * Filter a model list to remove user-excluded models.\n * When all models are excluded, returns the full list as a fallback\n * (same safety pattern as filterByToolCalling/filterByVision).\n */\nexport function filterByExcludeList(models: string[], excludeList: Set): string[] {\n if (excludeList.size === 0) return models;\n return keepOrFailOpen(models, (m) => !excludeList.has(m));\n}\n\n/**\n * Get the fallback chain filtered by context length.\n * Only returns models that can handle the estimated total context.\n *\n * @param tier - The tier to get fallback chain for\n * @param tierConfigs - Tier configurations\n * @param estimatedTotalTokens - Estimated total context (input + output)\n * @param getContextWindow - Function to get context window for a model ID\n * @returns Filtered list of models that can handle the context\n */\nexport function getFallbackChainFiltered(\n tier: Tier,\n tierConfigs: Record,\n estimatedTotalTokens: number,\n getContextWindow: (modelId: string) => number | undefined,\n): string[] {\n const fullChain = getFallbackChain(tier, tierConfigs);\n\n // Filter to models that can handle the context\n const filtered = fullChain.filter((modelId) => {\n const contextWindow = getContextWindow(modelId);\n if (contextWindow === undefined) {\n // Unknown model - include it (let API reject if needed)\n return true;\n }\n // Add 10% buffer for safety\n return contextWindow >= estimatedTotalTokens * 1.1;\n });\n\n // If all models filtered out, return the original chain\n // (let the API error out - better than no options)\n if (filtered.length === 0) {\n return fullChain;\n }\n\n return filtered;\n}\n\n/**\n * Filter an already-ranked candidate list by total context and requested output.\n * Unlike the legacy tier helper, this supports the V3 portfolio order.\n */\nexport function filterCandidatesByCapacity(\n models: string[],\n estimatedInputTokens: number,\n requestedOutputTokens: number,\n getCapabilities: (modelId: string) => { contextWindow: number; maxOutput: number } | undefined,\n): string[] {\n const filtered = models.filter((modelId) => {\n const capabilities = getCapabilities(modelId);\n if (!capabilities) return true;\n return (\n capabilities.contextWindow >= (estimatedInputTokens + requestedOutputTokens) * 1.1 &&\n capabilities.maxOutput >= requestedOutputTokens\n );\n });\n return filtered;\n}\n","/**\n * Request-size helpers shared by the rules and portfolio strategies.\n *\n * The router never tokenizes — it is on the hot path and model-agnostic — so\n * sizes are estimates. The estimate only has to be honest enough for the\n * decisions that consume it: the long-context task type, the COMPLEX\n * override and the per-model capacity filter.\n */\n\n// Han, kana, Hangul, CJK punctuation and fullwidth forms. Every production\n// tokenizer spends roughly one token per character here, so the Latin\n// four-characters-per-token rule under-counts these scripts about fourfold:\n// a 200k-character Chinese contract would read as 50k tokens, slip under the\n// 80k long-context boundary and pass the capacity filter for models that\n// cannot hold it.\nconst CJK_CHARS = /[ -ヿ㐀-䶿一-鿿가-힯豈-﫿＀-￯]/g;\n\n/** Approximate token count: one per CJK character, one per four of anything else. */\nexport function estimateTokens(text: string): number {\n if (text.length === 0) return 0;\n const cjk = text.match(CJK_CHARS)?.length ?? 0;\n return cjk + Math.ceil((text.length - cjk) / 4);\n}\n\nconst MAX_SCAN_CHARS = 8_000;\n\n/** The scan window the feature regexes read, bounded so a pasted document cannot stall routing. */\nexport function scanLimit(promptTruncationChars: number): number {\n if (!Number.isFinite(promptTruncationChars)) return MAX_SCAN_CHARS;\n return Math.max(1, Math.min(MAX_SCAN_CHARS, Math.floor(promptTruncationChars)));\n}\n\n\n/**\n * Feature regexes need request shape and intent, not the entire document.\n * Sample both ends so a long pasted artifact keeps the task instruction at\n * either boundary, while the full length still drives capacity decisions.\n */\nexport function sampleForScan(value: string, limit: number): string {\n if (value.length <= limit) return value;\n const prefixLength = Math.ceil(limit / 2);\n const suffixLength = limit - prefixLength;\n // slice(-0) is the whole string, so a one-character limit needs its own case.\n if (suffixLength <= 0) return value.slice(0, prefixLength);\n return `${value.slice(0, prefixLength)}\\n${value.slice(-suffixLength)}`;\n}\n","/**\n * Router Strategy Registry\n *\n * Pluggable strategy system for request routing.\n * Default: RulesStrategy — identical to the original inline route() logic, <1ms.\n */\n\nimport type {\n Tier,\n TierConfig,\n Promotion,\n RoutingDecision,\n RouterStrategy,\n RouterOptions,\n} from \"./types.js\";\nimport { classifyByRules } from \"./rules.js\";\nimport { selectModel } from \"./selector.js\";\nimport { estimateTokens, sampleForScan, scanLimit } from \"./tokens.js\";\n\n/**\n * Apply active time-windowed promotions to tier configs.\n * Returns a new tierConfigs object with promotion overrides merged in.\n * Expired or not-yet-active promotions are ignored.\n */\nfunction applyPromotions(\n tierConfigs: Record,\n promotions: Promotion[] | undefined,\n profile: \"auto\" | \"eco\" | \"premium\" | \"agentic\",\n now: Date = new Date(),\n): Record {\n if (!promotions || promotions.length === 0) return tierConfigs;\n\n let result = tierConfigs;\n for (const promo of promotions) {\n // Check time window\n // An unparseable date compares false both ways, which used to make the\n // promotion active forever. A window that cannot be read is not a window.\n const start = Date.parse(promo.startDate);\n const end = Date.parse(promo.endDate);\n if (!Number.isFinite(start) || !Number.isFinite(end)) continue;\n if (now.getTime() < start || now.getTime() >= end) continue;\n\n // Check profile filter\n if (promo.profiles && !promo.profiles.includes(profile)) continue;\n\n // Shallow-clone on first mutation\n if (result === tierConfigs) {\n result = { ...tierConfigs };\n for (const t of Object.keys(result) as Tier[]) {\n result[t] = { ...result[t] };\n }\n }\n\n // Merge overrides\n for (const [tier, override] of Object.entries(promo.tierOverrides) as [\n Tier,\n Partial,\n ][]) {\n if (!result[tier]) continue;\n if (override.primary) result[tier].primary = override.primary;\n if (override.fallback) result[tier].fallback = override.fallback;\n }\n }\n\n return result;\n}\n\n/**\n * Remove host-declared-dead models from every tier chain, promoting the first\n * surviving rung to primary. A tier whose chain is entirely dead keeps its\n * original config — the router has nothing live to offer there, and inventing\n * a model would hide the outage from the host that reported it.\n */\nexport function applyUnavailableModels(\n tierConfigs: Record,\n unavailableModels: readonly string[] | undefined,\n): Record {\n if (!unavailableModels || unavailableModels.length === 0) return tierConfigs;\n const dead = new Set(unavailableModels);\n let result = tierConfigs;\n for (const tier of Object.keys(tierConfigs) as Tier[]) {\n const config = tierConfigs[tier];\n const alive = [config.primary, ...config.fallback].filter((model) => !dead.has(model));\n if (alive.length === 0 || (alive[0] === config.primary && alive.length === config.fallback.length + 1)) {\n continue;\n }\n if (result === tierConfigs) result = { ...tierConfigs };\n result[tier] = { primary: alive[0], fallback: alive.slice(1) };\n }\n return result;\n}\n\n/**\n * Rules-based routing strategy.\n * Extracted from the original route() in index.ts — logic is identical.\n * Attaches tierConfigs and profile to the decision for downstream use.\n */\nexport class RulesStrategy implements RouterStrategy {\n readonly name = \"rules\";\n\n route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n ): RoutingDecision {\n const { config, modelPricing } = options;\n\n const fullText = `${systemPrompt ?? \"\"} ${prompt}`;\n const estimatedTokens = estimateTokens(fullText);\n const limit = scanLimit(config.classifier.promptTruncationChars);\n const scannedPrompt = sampleForScan(prompt, limit);\n const scannedSystemPrompt = systemPrompt ? sampleForScan(systemPrompt, limit) : undefined;\n\n // --- Rule-based classification (runs first to get agenticScore) ---\n const ruleResult = classifyByRules(\n scannedPrompt,\n scannedSystemPrompt,\n estimatedTokens,\n config.scoring,\n );\n\n // --- Select tier configs based on routing profile ---\n const { routingProfile } = options;\n let tierConfigs: Record;\n let profileSuffix: string;\n let profile: NonNullable;\n\n if (routingProfile === \"eco\") {\n // `ecoTiers: null` explicitly disables the special eco tier set while\n // keeping eco routing semantics. Fall back to regular tiers instead of\n // dropping into auto routing (which could select agentic tiers).\n tierConfigs = config.ecoTiers ?? config.tiers;\n profileSuffix = config.ecoTiers ? \" | eco\" : \" | eco (default tiers)\";\n profile = \"eco\";\n } else if (routingProfile === \"premium\") {\n // `premiumTiers: null` disables the premium-specific tier set but the\n // request is still a premium-profile request, so use regular tiers while\n // preserving premium metadata/cost semantics.\n tierConfigs = config.premiumTiers ?? config.tiers;\n profileSuffix = config.premiumTiers ? \" | premium\" : \" | premium (default tiers)\";\n profile = \"premium\";\n } else {\n // Auto profile (or undefined): intelligent routing with agentic detection.\n //\n // `agenticMode` semantics:\n // - `true` → force agentic tiers (ignore heuristics)\n // - `false` → disable agentic tiers entirely (even if tools are present)\n // - `undefined` → auto-detect via heuristics (tools present OR high agenticScore)\n const agenticScore = ruleResult.agenticScore ?? 0;\n const isAutoAgentic = agenticScore >= 0.5;\n const agenticModeSetting = config.overrides.agenticMode;\n const hasToolsInRequest = options.requiresTools ?? options.hasTools ?? false;\n let useAgenticTiers: boolean;\n if (agenticModeSetting === false) {\n // Explicitly disabled — never use agentic tiers\n useAgenticTiers = false;\n } else if (agenticModeSetting === true) {\n // Explicitly enabled — use agentic tiers if available\n useAgenticTiers = config.agenticTiers != null;\n } else {\n // Auto-detect\n useAgenticTiers = (hasToolsInRequest || isAutoAgentic) && config.agenticTiers != null;\n }\n tierConfigs = useAgenticTiers ? config.agenticTiers! : config.tiers;\n profileSuffix = useAgenticTiers ? ` | agentic${hasToolsInRequest ? \" (tools)\" : \"\"}` : \"\";\n profile = useAgenticTiers ? \"agentic\" : \"auto\";\n }\n\n // Apply time-windowed promotions\n tierConfigs = applyPromotions(tierConfigs, config.promotions, profile, options.now);\n\n // Hard-remove models the host has observed dead at the gateway. After\n // promotions, so a promo cannot resurrect a rung the host just killed.\n tierConfigs = applyUnavailableModels(tierConfigs, options.unavailableModels);\n\n const agenticScoreValue = ruleResult.agenticScore;\n\n // --- Override: large context → force COMPLEX ---\n if (estimatedTokens > config.overrides.maxTokensForceComplex) {\n const decision = selectModel(\n \"COMPLEX\",\n 0.95,\n \"rules\",\n `Input exceeds ${config.overrides.maxTokensForceComplex} tokens${profileSuffix}`,\n tierConfigs,\n modelPricing,\n estimatedTokens,\n maxOutputTokens,\n routingProfile,\n agenticScoreValue,\n );\n return { ...decision, tierConfigs, profile };\n }\n\n // Structured output is a protocol fact the host states (`response_format`\n // → requiresStructuredOutput). It used to be inferred from the system\n // prompt as well, but agent hosts describe their tool schemas there on\n // every turn, which upgraded every one of their requests off SIMPLE.\n const hasStructuredOutput = options.requiresStructuredOutput === true;\n\n let tier: Tier;\n let confidence: number;\n const method: \"rules\" | \"llm\" = \"rules\";\n let reasoning = `score=${ruleResult.score.toFixed(2)} | ${ruleResult.signals.join(\", \")}`;\n\n if (ruleResult.tier !== null) {\n tier = ruleResult.tier;\n confidence = ruleResult.confidence;\n } else {\n // Ambiguous — default to configurable tier (no external API call)\n tier = config.overrides.ambiguousDefaultTier;\n confidence = 0.5;\n reasoning += ` | ambiguous -> default: ${tier}`;\n }\n\n // Apply structured output minimum tier\n if (hasStructuredOutput) {\n const tierRank: Record = { SIMPLE: 0, MEDIUM: 1, COMPLEX: 2, REASONING: 3 };\n const minTier = config.overrides.structuredOutputMinTier;\n if (tierRank[tier] < tierRank[minTier]) {\n reasoning += ` | upgraded to ${minTier} (structured output)`;\n tier = minTier;\n }\n }\n\n // Add routing profile suffix to reasoning\n reasoning += profileSuffix;\n\n const decision = selectModel(\n tier,\n confidence,\n method,\n reasoning,\n tierConfigs,\n modelPricing,\n estimatedTokens,\n maxOutputTokens,\n routingProfile,\n agenticScoreValue,\n );\n return { ...decision, tierConfigs, profile };\n }\n}\n\n// --- Strategy Registry ---\n\nconst registry = new Map();\nregistry.set(\"rules\", new RulesStrategy());\n\nexport function getStrategy(name: string): RouterStrategy {\n const strategy = registry.get(name);\n if (!strategy) {\n throw new Error(`Unknown routing strategy: ${name}`);\n }\n return strategy;\n}\n\nexport function registerStrategy(strategy: RouterStrategy): void {\n registry.set(strategy.name, strategy);\n}\n","/**\n * Default Routing Config\n *\n * All routing parameters as a TypeScript constant.\n * Operators override via openclaw.yaml plugin config.\n *\n * Scoring uses 15 weighted dimensions with sigmoid confidence calibration.\n */\n\nimport type { RoutingConfig } from \"./types.js\";\n\nexport const DEFAULT_ROUTING_CONFIG: RoutingConfig = {\n version: \"3.5\",\n strategy: \"portfolio\",\n portfolio: {\n auto: {\n quality: 0.47,\n capability: 0.2,\n cost: 0.18,\n speed: 0.07,\n reliability: 0.03,\n legacy: 0.05,\n },\n eco: {\n quality: 0.36,\n capability: 0.2,\n cost: 0.28,\n speed: 0.1,\n reliability: 0.04,\n legacy: 0.02,\n },\n premium: {\n quality: 0.58,\n capability: 0.2,\n cost: 0.08,\n speed: 0.06,\n reliability: 0.06,\n legacy: 0.02,\n },\n highStakesBoost: { quality: 0.08, reliability: 0.05 },\n latencySensitiveSpeedBoost: 0.08,\n affinityFloorGap: { auto: 0.1, eco: 0.22, premium: 0.05 },\n },\n\n classifier: {\n // gemini-2.5-flash until Google retired it on 2026-12-01 (the gateways\n // redirect it to 3.5 Flash-Lite). Nothing in this package or ClawRouter\n // reads llmModel today. Before wiring it, note that 3.5 Flash-Lite always\n // thinks (it rejects a thinking budget of 0), so llmMaxTokens 10 may be\n // spent on reasoning before any label is emitted.\n llmModel: \"google/gemini-3.5-flash-lite\",\n llmMaxTokens: 10,\n llmTemperature: 0,\n promptTruncationChars: 500,\n cacheTtlMs: 3_600_000, // 1 hour\n },\n\n scoring: {\n tokenCountThresholds: { simple: 50, complex: 500 },\n\n // Multilingual keywords: EN + ZH + JA + RU + DE + ES + PT + KO + AR\n codeKeywords: [\n // English\n \"function\",\n \"class\",\n \"import\",\n \"def\",\n \"SELECT\",\n \"async\",\n \"await\",\n \"const\",\n \"let\",\n \"var\",\n \"return\",\n \"```\",\n // Chinese\n \"函数\",\n \"类\",\n \"导入\",\n \"定义\",\n \"查询\",\n \"异步\",\n \"等待\",\n \"常量\",\n \"变量\",\n \"返回\",\n // Japanese\n \"関数\",\n \"クラス\",\n \"インポート\",\n \"非同期\",\n \"定数\",\n \"変数\",\n // Russian\n \"функция\",\n \"класс\",\n \"импорт\",\n \"определ\",\n \"запрос\",\n \"асинхронный\",\n \"ожидать\",\n \"константа\",\n \"переменная\",\n \"вернуть\",\n // German\n \"funktion\",\n \"klasse\",\n \"importieren\",\n \"definieren\",\n \"abfrage\",\n \"asynchron\",\n \"erwarten\",\n \"konstante\",\n \"variable\",\n \"zurückgeben\",\n // Spanish\n \"función\",\n \"clase\",\n \"importar\",\n \"definir\",\n \"consulta\",\n \"asíncrono\",\n \"esperar\",\n \"constante\",\n \"variable\",\n \"retornar\",\n // Portuguese\n \"função\",\n \"classe\",\n \"importar\",\n \"definir\",\n \"consulta\",\n \"assíncrono\",\n \"aguardar\",\n \"constante\",\n \"variável\",\n \"retornar\",\n // Korean\n \"함수\",\n \"클래스\",\n \"가져오기\",\n \"정의\",\n \"쿼리\",\n \"비동기\",\n \"대기\",\n \"상수\",\n \"변수\",\n \"반환\",\n // Arabic\n \"دالة\",\n \"فئة\",\n \"استيراد\",\n \"تعريف\",\n \"استعلام\",\n \"غير متزامن\",\n \"انتظار\",\n \"ثابت\",\n \"متغير\",\n \"إرجاع\",\n ],\n reasoningKeywords: [\n // English\n \"prove\",\n \"theorem\",\n \"derive\",\n \"step by step\",\n \"chain of thought\",\n \"formally\",\n \"mathematical\",\n \"proof\",\n \"logically\",\n // Chinese\n \"证明\",\n \"定理\",\n \"推导\",\n \"逐步\",\n \"思维链\",\n \"形式化\",\n \"数学\",\n \"逻辑\",\n // Japanese\n \"証明\",\n \"定理\",\n \"導出\",\n \"ステップバイステップ\",\n \"論理的\",\n // Russian\n \"доказать\",\n \"докажи\",\n \"доказательств\",\n \"теорема\",\n \"вывести\",\n \"шаг за шагом\",\n \"пошагово\",\n \"поэтапно\",\n \"цепочка рассуждений\",\n \"рассуждени\",\n \"формально\",\n \"математически\",\n \"логически\",\n // German\n \"beweisen\",\n \"beweis\",\n \"theorem\",\n \"ableiten\",\n \"schritt für schritt\",\n \"gedankenkette\",\n \"formal\",\n \"mathematisch\",\n \"logisch\",\n // Spanish\n \"demostrar\",\n \"teorema\",\n \"derivar\",\n \"paso a paso\",\n \"cadena de pensamiento\",\n \"formalmente\",\n \"matemático\",\n \"prueba\",\n \"lógicamente\",\n // Portuguese\n \"provar\",\n \"teorema\",\n \"derivar\",\n \"passo a passo\",\n \"cadeia de pensamento\",\n \"formalmente\",\n \"matemático\",\n \"prova\",\n \"logicamente\",\n // Korean\n \"증명\",\n \"정리\",\n \"도출\",\n \"단계별\",\n \"사고의 연쇄\",\n \"형식적\",\n \"수학적\",\n \"논리적\",\n // Arabic\n \"إثبات\",\n \"نظرية\",\n \"اشتقاق\",\n \"خطوة بخطوة\",\n \"سلسلة التفكير\",\n \"رسمياً\",\n \"رياضي\",\n \"برهان\",\n \"منطقياً\",\n ],\n simpleKeywords: [\n // English\n \"what is\",\n \"define\",\n \"translate\",\n \"hello\",\n \"yes or no\",\n \"capital of\",\n \"how old\",\n \"who is\",\n \"when was\",\n // Chinese\n \"什么是\",\n \"定义\",\n \"翻译\",\n \"你好\",\n \"是否\",\n \"首都\",\n \"多大\",\n \"谁是\",\n \"何时\",\n // Japanese\n \"とは\",\n \"定義\",\n \"翻訳\",\n \"こんにちは\",\n \"はいかいいえ\",\n \"首都\",\n \"誰\",\n // Russian\n \"что такое\",\n \"определение\",\n \"перевести\",\n \"переведи\",\n \"привет\",\n \"да или нет\",\n \"столица\",\n \"сколько лет\",\n \"кто такой\",\n \"когда\",\n \"объясни\",\n // German\n \"was ist\",\n \"definiere\",\n \"übersetze\",\n \"hallo\",\n \"ja oder nein\",\n \"hauptstadt\",\n \"wie alt\",\n \"wer ist\",\n \"wann\",\n \"erkläre\",\n // Spanish\n \"qué es\",\n \"definir\",\n \"traducir\",\n \"hola\",\n \"sí o no\",\n \"capital de\",\n \"cuántos años\",\n \"quién es\",\n \"cuándo\",\n // Portuguese\n \"o que é\",\n \"definir\",\n \"traduzir\",\n \"olá\",\n \"sim ou não\",\n \"capital de\",\n \"quantos anos\",\n \"quem é\",\n \"quando\",\n // Korean\n \"무엇\",\n \"정의\",\n \"번역\",\n \"안녕하세요\",\n \"예 또는 아니오\",\n \"수도\",\n \"누구\",\n \"언제\",\n // Arabic\n \"ما هو\",\n \"تعريف\",\n \"ترجم\",\n \"مرحبا\",\n \"نعم أو لا\",\n \"عاصمة\",\n \"من هو\",\n \"متى\",\n ],\n technicalKeywords: [\n // English\n \"algorithm\",\n \"optimize\",\n \"architecture\",\n \"distributed\",\n \"kubernetes\",\n \"microservice\",\n \"database\",\n \"infrastructure\",\n // Chinese\n \"算法\",\n \"优化\",\n \"架构\",\n \"分布式\",\n \"微服务\",\n \"数据库\",\n \"基础设施\",\n // Japanese\n \"アルゴリズム\",\n \"最適化\",\n \"アーキテクチャ\",\n \"分散\",\n \"マイクロサービス\",\n \"データベース\",\n // Russian\n \"алгоритм\",\n \"оптимизировать\",\n \"оптимизаци\",\n \"оптимизируй\",\n \"архитектура\",\n \"распределённый\",\n \"микросервис\",\n \"база данных\",\n \"инфраструктура\",\n // German\n \"algorithmus\",\n \"optimieren\",\n \"architektur\",\n \"verteilt\",\n \"kubernetes\",\n \"mikroservice\",\n \"datenbank\",\n \"infrastruktur\",\n // Spanish\n \"algoritmo\",\n \"optimizar\",\n \"arquitectura\",\n \"distribuido\",\n \"microservicio\",\n \"base de datos\",\n \"infraestructura\",\n // Portuguese\n \"algoritmo\",\n \"otimizar\",\n \"arquitetura\",\n \"distribuído\",\n \"microsserviço\",\n \"banco de dados\",\n \"infraestrutura\",\n // Korean\n \"알고리즘\",\n \"최적화\",\n \"아키텍처\",\n \"분산\",\n \"마이크로서비스\",\n \"데이터베이스\",\n \"인프라\",\n // Arabic\n \"خوارزمية\",\n \"تحسين\",\n \"بنية\",\n \"موزع\",\n \"خدمة مصغرة\",\n \"قاعدة بيانات\",\n \"بنية تحتية\",\n ],\n creativeKeywords: [\n // English\n \"story\",\n \"poem\",\n \"compose\",\n \"brainstorm\",\n \"creative\",\n \"imagine\",\n \"write a\",\n // Chinese\n \"故事\",\n \"诗\",\n \"创作\",\n \"头脑风暴\",\n \"创意\",\n \"想象\",\n \"写一个\",\n // Japanese\n \"物語\",\n \"詩\",\n \"作曲\",\n \"ブレインストーム\",\n \"創造的\",\n \"想像\",\n // Russian\n \"история\",\n \"рассказ\",\n \"стихотворение\",\n \"сочинить\",\n \"сочини\",\n \"мозговой штурм\",\n \"творческий\",\n \"представить\",\n \"придумай\",\n \"напиши\",\n // German\n \"geschichte\",\n \"gedicht\",\n \"komponieren\",\n \"brainstorming\",\n \"kreativ\",\n \"vorstellen\",\n \"schreibe\",\n \"erzählung\",\n // Spanish\n \"historia\",\n \"poema\",\n \"componer\",\n \"lluvia de ideas\",\n \"creativo\",\n \"imaginar\",\n \"escribe\",\n // Portuguese\n \"história\",\n \"poema\",\n \"compor\",\n \"criativo\",\n \"imaginar\",\n \"escreva\",\n // Korean\n \"이야기\",\n \"시\",\n \"작곡\",\n \"브레인스토밍\",\n \"창의적\",\n \"상상\",\n \"작성\",\n // Arabic\n \"قصة\",\n \"قصيدة\",\n \"تأليف\",\n \"عصف ذهني\",\n \"إبداعي\",\n \"تخيل\",\n \"اكتب\",\n ],\n\n // New dimension keyword lists (multilingual)\n imperativeVerbs: [\n // English\n \"build\",\n \"create\",\n \"implement\",\n \"design\",\n \"develop\",\n \"construct\",\n \"generate\",\n \"deploy\",\n \"configure\",\n \"set up\",\n // Chinese\n \"构建\",\n \"创建\",\n \"实现\",\n \"设计\",\n \"开发\",\n \"生成\",\n \"部署\",\n \"配置\",\n \"设置\",\n // Japanese\n \"構築\",\n \"作成\",\n \"実装\",\n \"設計\",\n \"開発\",\n \"生成\",\n \"デプロイ\",\n \"設定\",\n // Russian\n \"построить\",\n \"построй\",\n \"создать\",\n \"создай\",\n \"реализовать\",\n \"реализуй\",\n \"спроектировать\",\n \"разработать\",\n \"разработай\",\n \"сконструировать\",\n \"сгенерировать\",\n \"сгенерируй\",\n \"развернуть\",\n \"разверни\",\n \"настроить\",\n \"настрой\",\n // German\n \"erstellen\",\n \"bauen\",\n \"implementieren\",\n \"entwerfen\",\n \"entwickeln\",\n \"konstruieren\",\n \"generieren\",\n \"bereitstellen\",\n \"konfigurieren\",\n \"einrichten\",\n // Spanish\n \"construir\",\n \"crear\",\n \"implementar\",\n \"diseñar\",\n \"desarrollar\",\n \"generar\",\n \"desplegar\",\n \"configurar\",\n // Portuguese\n \"construir\",\n \"criar\",\n \"implementar\",\n \"projetar\",\n \"desenvolver\",\n \"gerar\",\n \"implantar\",\n \"configurar\",\n // Korean\n \"구축\",\n \"생성\",\n \"구현\",\n \"설계\",\n \"개발\",\n \"배포\",\n \"설정\",\n // Arabic\n \"بناء\",\n \"إنشاء\",\n \"تنفيذ\",\n \"تصميم\",\n \"تطوير\",\n \"توليد\",\n \"نشر\",\n \"إعداد\",\n ],\n constraintIndicators: [\n // English\n \"under\",\n \"at most\",\n \"at least\",\n \"within\",\n \"no more than\",\n \"o(\",\n \"maximum\",\n \"minimum\",\n \"limit\",\n \"budget\",\n // Chinese\n \"不超过\",\n \"至少\",\n \"最多\",\n \"在内\",\n \"最大\",\n \"最小\",\n \"限制\",\n \"预算\",\n // Japanese\n \"以下\",\n \"最大\",\n \"最小\",\n \"制限\",\n \"予算\",\n // Russian\n \"не более\",\n \"не менее\",\n \"как минимум\",\n \"в пределах\",\n \"максимум\",\n \"минимум\",\n \"ограничение\",\n \"бюджет\",\n // German\n \"höchstens\",\n \"mindestens\",\n \"innerhalb\",\n \"nicht mehr als\",\n \"maximal\",\n \"minimal\",\n \"grenze\",\n \"budget\",\n // Spanish\n \"como máximo\",\n \"al menos\",\n \"dentro de\",\n \"no más de\",\n \"máximo\",\n \"mínimo\",\n \"límite\",\n \"presupuesto\",\n // Portuguese\n \"no máximo\",\n \"pelo menos\",\n \"dentro de\",\n \"não mais que\",\n \"máximo\",\n \"mínimo\",\n \"limite\",\n \"orçamento\",\n // Korean\n \"이하\",\n \"이상\",\n \"최대\",\n \"최소\",\n \"제한\",\n \"예산\",\n // Arabic\n \"على الأكثر\",\n \"على الأقل\",\n \"ضمن\",\n \"لا يزيد عن\",\n \"أقصى\",\n \"أدنى\",\n \"حد\",\n \"ميزانية\",\n ],\n outputFormatKeywords: [\n // English\n \"json\",\n \"yaml\",\n \"xml\",\n \"table\",\n \"csv\",\n \"markdown\",\n \"schema\",\n \"format as\",\n \"structured\",\n // Chinese\n \"表格\",\n \"格式化为\",\n \"结构化\",\n // Japanese\n \"テーブル\",\n \"フォーマット\",\n \"構造化\",\n // Russian\n \"таблица\",\n \"форматировать как\",\n \"структурированный\",\n // German\n \"tabelle\",\n \"formatieren als\",\n \"strukturiert\",\n // Spanish\n \"tabla\",\n \"formatear como\",\n \"estructurado\",\n // Portuguese\n \"tabela\",\n \"formatar como\",\n \"estruturado\",\n // Korean\n \"테이블\",\n \"형식\",\n \"구조화\",\n // Arabic\n \"جدول\",\n \"تنسيق\",\n \"منظم\",\n ],\n referenceKeywords: [\n // English\n \"above\",\n \"below\",\n \"previous\",\n \"following\",\n \"the docs\",\n \"the api\",\n \"the code\",\n \"earlier\",\n \"attached\",\n // Chinese\n \"上面\",\n \"下面\",\n \"之前\",\n \"接下来\",\n \"文档\",\n \"代码\",\n \"附件\",\n // Japanese\n \"上記\",\n \"下記\",\n \"前の\",\n \"次の\",\n \"ドキュメント\",\n \"コード\",\n // Russian\n \"выше\",\n \"ниже\",\n \"предыдущий\",\n \"следующий\",\n \"документация\",\n \"код\",\n \"ранее\",\n \"вложение\",\n // German\n \"oben\",\n \"unten\",\n \"vorherige\",\n \"folgende\",\n \"dokumentation\",\n \"der code\",\n \"früher\",\n \"anhang\",\n // Spanish\n \"arriba\",\n \"abajo\",\n \"anterior\",\n \"siguiente\",\n \"documentación\",\n \"el código\",\n \"adjunto\",\n // Portuguese\n \"acima\",\n \"abaixo\",\n \"anterior\",\n \"seguinte\",\n \"documentação\",\n \"o código\",\n \"anexo\",\n // Korean\n \"위\",\n \"아래\",\n \"이전\",\n \"다음\",\n \"문서\",\n \"코드\",\n \"첨부\",\n // Arabic\n \"أعلاه\",\n \"أدناه\",\n \"السابق\",\n \"التالي\",\n \"الوثائق\",\n \"الكود\",\n \"مرفق\",\n ],\n negationKeywords: [\n // English\n \"don't\",\n \"do not\",\n \"avoid\",\n \"never\",\n \"without\",\n \"except\",\n \"exclude\",\n \"no longer\",\n // Chinese\n \"不要\",\n \"避免\",\n \"从不\",\n \"没有\",\n \"除了\",\n \"排除\",\n // Japanese\n \"しないで\",\n \"避ける\",\n \"決して\",\n \"なしで\",\n \"除く\",\n // Russian\n \"не делай\",\n \"не надо\",\n \"нельзя\",\n \"избегать\",\n \"никогда\",\n \"без\",\n \"кроме\",\n \"исключить\",\n \"больше не\",\n // German\n \"nicht\",\n \"vermeide\",\n \"niemals\",\n \"ohne\",\n \"außer\",\n \"ausschließen\",\n \"nicht mehr\",\n // Spanish\n \"no hagas\",\n \"evitar\",\n \"nunca\",\n \"sin\",\n \"excepto\",\n \"excluir\",\n // Portuguese\n \"não faça\",\n \"evitar\",\n \"nunca\",\n \"sem\",\n \"exceto\",\n \"excluir\",\n // Korean\n \"하지 마\",\n \"피하다\",\n \"절대\",\n \"없이\",\n \"제외\",\n // Arabic\n \"لا تفعل\",\n \"تجنب\",\n \"أبداً\",\n \"بدون\",\n \"باستثناء\",\n \"استبعاد\",\n ],\n domainSpecificKeywords: [\n // English\n \"quantum\",\n \"fpga\",\n \"vlsi\",\n \"risc-v\",\n \"asic\",\n \"photonics\",\n \"genomics\",\n \"proteomics\",\n \"topological\",\n \"homomorphic\",\n \"zero-knowledge\",\n \"lattice-based\",\n // Chinese\n \"量子\",\n \"光子学\",\n \"基因组学\",\n \"蛋白质组学\",\n \"拓扑\",\n \"同态\",\n \"零知识\",\n \"格密码\",\n // Japanese\n \"量子\",\n \"フォトニクス\",\n \"ゲノミクス\",\n \"トポロジカル\",\n // Russian\n \"квантовый\",\n \"фотоника\",\n \"геномика\",\n \"протеомика\",\n \"топологический\",\n \"гомоморфный\",\n \"с нулевым разглашением\",\n \"на основе решёток\",\n // German\n \"quanten\",\n \"photonik\",\n \"genomik\",\n \"proteomik\",\n \"topologisch\",\n \"homomorph\",\n \"zero-knowledge\",\n \"gitterbasiert\",\n // Spanish\n \"cuántico\",\n \"fotónica\",\n \"genómica\",\n \"proteómica\",\n \"topológico\",\n \"homomórfico\",\n // Portuguese\n \"quântico\",\n \"fotônica\",\n \"genômica\",\n \"proteômica\",\n \"topológico\",\n \"homomórfico\",\n // Korean\n \"양자\",\n \"포토닉스\",\n \"유전체학\",\n \"위상\",\n \"동형\",\n // Arabic\n \"كمي\",\n \"ضوئيات\",\n \"جينوميات\",\n \"طوبولوجي\",\n \"تماثلي\",\n ],\n\n // Agentic task keywords - file ops, execution, multi-step, iterative work\n // Pruned: removed overly common words like \"then\", \"first\", \"run\", \"test\", \"build\"\n agenticTaskKeywords: [\n // English - File operations (clearly agentic)\n \"read file\",\n \"read the file\",\n \"look at\",\n \"check the\",\n \"open the\",\n \"edit\",\n \"modify\",\n \"update the\",\n \"change the\",\n \"write to\",\n \"create file\",\n // English - Execution (specific commands only)\n \"execute\",\n \"deploy\",\n \"install\",\n \"npm\",\n \"pip\",\n \"compile\",\n // English - Multi-step patterns (specific only)\n \"after that\",\n \"and also\",\n \"once done\",\n \"step 1\",\n \"step 2\",\n // English - Iterative work\n \"fix\",\n \"debug\",\n \"until it works\",\n \"keep trying\",\n \"iterate\",\n \"make sure\",\n \"verify\",\n \"confirm\",\n // Chinese (keep specific ones)\n \"读取文件\",\n \"查看\",\n \"打开\",\n \"编辑\",\n \"修改\",\n \"更新\",\n \"创建\",\n \"执行\",\n \"部署\",\n \"安装\",\n \"第一步\",\n \"第二步\",\n \"修复\",\n \"调试\",\n \"直到\",\n \"确认\",\n \"验证\",\n // Spanish\n \"leer archivo\",\n \"editar\",\n \"modificar\",\n \"actualizar\",\n \"ejecutar\",\n \"desplegar\",\n \"instalar\",\n \"paso 1\",\n \"paso 2\",\n \"arreglar\",\n \"depurar\",\n \"verificar\",\n // Portuguese\n \"ler arquivo\",\n \"editar\",\n \"modificar\",\n \"atualizar\",\n \"executar\",\n \"implantar\",\n \"instalar\",\n \"passo 1\",\n \"passo 2\",\n \"corrigir\",\n \"depurar\",\n \"verificar\",\n // Korean\n \"파일 읽기\",\n \"편집\",\n \"수정\",\n \"업데이트\",\n \"실행\",\n \"배포\",\n \"설치\",\n \"단계 1\",\n \"단계 2\",\n \"디버그\",\n \"확인\",\n // Arabic\n \"قراءة ملف\",\n \"تحرير\",\n \"تعديل\",\n \"تحديث\",\n \"تنفيذ\",\n \"نشر\",\n \"تثبيت\",\n \"الخطوة 1\",\n \"الخطوة 2\",\n \"إصلاح\",\n \"تصحيح\",\n \"تحقق\",\n ],\n\n // Dimension weights (sum to 1.0)\n dimensionWeights: {\n tokenCount: 0.08,\n codePresence: 0.15,\n reasoningMarkers: 0.18,\n technicalTerms: 0.1,\n creativeMarkers: 0.05,\n simpleIndicators: 0.02, // Reduced from 0.12 to make room for agenticTask\n multiStepPatterns: 0.12,\n questionComplexity: 0.05,\n imperativeVerbs: 0.03,\n constraintCount: 0.04,\n outputFormat: 0.03,\n referenceComplexity: 0.02,\n negationComplexity: 0.01,\n domainSpecificity: 0.02,\n agenticTask: 0.04, // Reduced - agentic signals influence tier selection, not dominate it\n },\n\n // Tier boundaries on weighted score axis\n tierBoundaries: {\n simpleMedium: 0.0,\n mediumComplex: 0.3, // Raised from 0.18 - prevent simple tasks from reaching expensive COMPLEX tier\n complexReasoning: 0.5, // Raised from 0.4 - reserve for true reasoning tasks\n },\n\n // Sigmoid steepness for confidence calibration\n confidenceSteepness: 12,\n // Below this confidence → ambiguous (null tier)\n confidenceThreshold: 0.7,\n },\n\n // ─── Tier chains ───\n //\n // Catalog refresh 2026-08-29 (V3.5). Every chain below names only models\n // the public catalog lists (GET https://blockrun.ai/api/v1/models). Ids the\n // gateway withholds (`hidden: true`) — kimi-k2.5/k2.6/k2.7, the grok-4-fast\n // and grok-4-1-fast pairs, grok-4-0709, claude-opus-4.6, gemini-3-pro-preview,\n // the whole `free/*` namespace — were removed everywhere, including fallback\n // rungs, so a routed model is always one a user can find on blockrun.ai/models.\n //\n // Primaries moved only where portfolio.ts already carries calibration\n // evidence for the successor (Sonnet 5 over Sonnet 4.6, GPT-5 Mini for\n // agentic MEDIUM, Gemini 3.5 Flash where Kimi K2.7 was). Newcomers with no\n // trajectory evidence yet (gemini-3.6-flash, glm-5.3, glm-5.3-flash,\n // gpt-5.6-luna, grok-4.3, minimax-m3, qwen3.7-plus) enter as fallback rungs;\n // promotion waits for a calibration run, because version recency is not a\n // quality signal.\n //\n // Latency figures in comments are the 2026-08-29 gateway probe\n // (model-profiles.generated.json); prices are the catalog list.\n //\n // Retirements 2026-11-24 (owner-approved; the gateways redirect each id\n // before pricing, so a stale name here is a silent model swap, not an error):\n // - google/gemini-3.5-flash -> google/gemini-3.6-flash. Google has served\n // 3.6 Flash under the 3.5 name since ~2026-10-10. Each 3.5 rung now names\n // 3.6 at the same position; where 3.6 already sat in the same chain, the\n // later of the two is dropped, so the order of the models actually served\n // is unchanged. 3.6 inherits 3.5's affinity values, carried, not measured\n // (portfolio.ts).\n // - openai/o4-mini (and o1, o3-mini) -> openai/gpt-5.4-mini, at the same\n // position. Dead at OpenAI since 2026-10-23 and on Azure since 2026-11-19.\n //\n // Retirements 2026-12-01 (Google retires Gemini 2.5; the gateways redirect):\n // - google/gemini-2.5-flash -> google/gemini-3.5-flash-lite (same\n // $0.30/$2.50), in place, with the same dedupe rule. 3.5 Flash-Lite has\n // no vision tag where 2.5 Flash had one, so a SIMPLE vision turn now\n // falls past it to the next vision-capable rung instead of reaching a\n // redirected model that would drop the image.\n // - google/gemini-2.5-pro -> google/gemini-3.8-flash ($0.75/$3.75), in\n // place.\n //\n // Retirements 2026-12-11 (OpenAI shuts down o3, gpt-5-mini and gpt-5-nano —\n // developers.openai.com/api/docs/deprecations, notice 2026-06-11; the\n // gateways redirect each and quote the successor):\n // - openai/o3 -> openai/gpt-5.4-mini ($2/$8 -> $0.75/$4.50). Both o3 rungs\n // (auto and premium REASONING) sat directly behind gpt-5.4-mini, so they\n // are dropped by the dedupe rule; the order actually served is unchanged.\n // - openai/gpt-5-mini -> openai/gpt-5.6-luna ($0.25/$2 -> $0.20/$1.20), in\n // place as the agentic MEDIUM primary. Luna inherits gpt-5-mini's\n // affinity values, CARRIED, not measured (portfolio.ts) — gpt-5-mini is a\n // reasoning model and luna runs without reasoning, so those values are a\n // placeholder until a Terminal-Bench/tau2 run on luna.\n // - openai/gpt-5-nano -> openai/gpt-6-luna. In no chain.\n\n // Auto (balanced) tier configs - current default smart routing\n tiers: {\n SIMPLE: {\n // Was google/gemini-2.5-flash (60% retention, best, in the 2026-03 run)\n // until its 2026-12-01 retirement. 3.5 Flash-Lite is what the gateways\n // serve under that name from then on; it was this chain's second\n // fallback and is dropped there.\n primary: \"google/gemini-3.5-flash-lite\", // $0.30/$2.50, 1M ctx, thinking mode, no vision\n fallback: [\n \"google/gemini-3-flash-preview\", // $0.50/$3 — GPQA 5/6 in the 2026-07 calibration\n \"deepseek/deepseek-chat\", // $0.14/$0.28, 1M ctx\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50, 1M ctx\n \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx — GPT-5.6 cost tier (cut 2026-07-30)\n \"openai/gpt-5.4-nano\", // $0.20/$1.25, 1M ctx\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n \"nvidia/nemotron-3.5-lightning\", // FREE backstop — NVIDIA free tier (probed 2026-08-30)\n ],\n },\n MEDIUM: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then Gemini 3.5 Flash — the\n // calibrated successor (MGSM 5/5, GPQA 4/6, extraction band) — until its\n // 2026-11-24 retirement. 3.6 Flash is what Google served under that name\n // since ~10-10; it was this chain's first fallback and is dropped there.\n primary: \"google/gemini-3.6-flash\", // $0.75/$3.75, 1M ctx, vision + tools — 3.5's affinity, carried\n fallback: [\n \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools verified live 2026-08-27\n \"openai/gpt-5.6-terra\", // $2/$12, 1M ctx — GPT-5.6 balanced tier\n \"google/gemini-3-flash-preview\", // $0.50/$3\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n \"minimax/minimax-m3\", // $0.30/$1.20, 1M ctx\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"openai/gpt-5.6-luna\", // $0.20/$1.20\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n ],\n },\n COMPLEX: {\n primary: \"google/gemini-3.1-pro\", // $2/$12 — proven long-context flagship (portfolio.ts long_context lead)\n fallback: [\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — Pro-level quality at Flash price (Google's claim); also 3.5 Flash's successor (3.5 retired 2026-11-24 and was the next rung)\n \"anthropic/claude-sonnet-5\", // $3/$15 — near-Opus quality, tau2 + Terminal-Bench calibrated\n \"xai/grok-4.5\", // $2.50/$9 — 503-resistant, independent infra (was grok-4-0709, now hidden)\n \"google/gemini-3.8-flash\", // $0.75/$3.75 — 2.5 Pro's successor (retired 2026-12-01)\n \"anthropic/claude-sonnet-4.6\", // $3/$15\n \"openai/gpt-5.6-terra\", // $2/$12 — GPT-5.6 balanced tier (Sol excluded: #202)\n \"openai/gpt-5.5\", // $5/$30 — prior OpenAI flagship\n \"openai/gpt-5.4\", // $2.50/$15 — previous flagship, benchmarked\n \"zai/glm-5.3\", // $1.40/$4.40, 1M ctx, always-on thinking — verified live 2026-08-19\n \"moonshot/kimi-k3.1-pro\", // $2/$10, 1M ctx — Moonshot flagship (K3 successor)\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87 — strongest open-weight reasoner\n \"deepseek/deepseek-chat\", // $0.14/$0.28 — cheap last resort\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n REASONING: {\n // Was xai/grok-4-1-fast-reasoning ($0.20/$0.50, hidden 2026-08). DeepSeek\n // Reasoner is the cheapest listed reasoner at the same 1M context.\n primary: \"deepseek/deepseek-reasoner\", // $0.14/$0.28, 1M ctx\n fallback: [\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87 — calibrated reasoning band 0.95\n \"xai/grok-4.3\", // $1.50/$4, 1M ctx — xAI reasoning model, vision\n \"qwen/qwen3.7-plus\", // $0.32/$1.28, 1M ctx — reasoning; needs a generous max_tokens (thinking is billed)\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — 3.5 Flash's successor (MGSM 5/5 on 3.5, carried)\n \"openai/gpt-5.4-mini\", // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung)\n ],\n },\n },\n\n // Eco tier configs - absolute cheapest (blockrun/eco)\n ecoTiers: {\n SIMPLE: {\n primary: \"nvidia/nemotron-3.5-lightning\", // FREE — NVIDIA free tier flagship, 1M ctx\n fallback: [\n // Was nvidia/nemotron-3-nano-30b until blockrun delisted it on 2026-09-08\n // (NVIDIA deprovisioned it for the account — a structured per-account\n // 404). nano-omni is blockrun's own redirect target for that id, so this\n // follows the same rule as the head: the router and the gateway name the\n // same model.\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\", // FREE — nano-30b's successor, 256K ctx\n // The free head keeps rotting with NVIDIA's hosting (deepseek-v4-flash\n // 410 2026-08-12, seed-oss-36b 410 2026-08-03, gpt-oss-120b/20b 400\n // 2026-08-21, and on 2026-08-30 FOUR of the five visible free models at\n // once — step-3.7-flash, nemotron-nano-9b-v2 and nemotron-nano-12b-v2-vl\n // all 410, mistral-nemotron hung). Each retirement retargets the two\n // free rungs to the current free tier; the paid rungs below never move.\n // The head follows blockrun's own redirect of the model it replaces, so\n // the router and the gateway never name different models.\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40 — cheapest paid rung\n \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools\n \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx\n \"openai/gpt-5.4-nano\", // $0.20/$1.25\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n ],\n },\n MEDIUM: {\n primary: \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools verified live — cheapest full-capability model\n fallback: [\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"openai/gpt-5.6-luna\", // $0.20/$1.20\n \"openai/gpt-5.4-nano\", // $0.20/$1.25\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n COMPLEX: {\n primary: \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx\n fallback: [\n \"deepseek/deepseek-chat\", // $0.14/$0.28, 1M ctx\n \"minimax/minimax-m3\", // $0.30/$1.20, 1M ctx\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n REASONING: {\n primary: \"deepseek/deepseek-reasoner\", // $0.14/$0.28, 1M ctx — cheapest listed reasoner\n fallback: [\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87\n \"qwen/qwen3.7-plus\", // $0.32/$1.28 — reasoning\n \"minimax/minimax-m3\", // $0.30/$1.20 — reasoning + coding\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — reasoning tokens alongside content\n ],\n },\n },\n\n // Premium tier configs - best quality (blockrun/premium)\n // codex=complex coding, flash=simple coding, sonnet=reasoning/instructions, fable/opus=architecture/PM/audits\n premiumTiers: {\n SIMPLE: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then Gemini 3.5 Flash until\n // its 2026-11-24 retirement; 3.6 Flash was the first fallback and is\n // dropped there.\n primary: \"google/gemini-3.6-flash\", // $0.75/$3.75, 1M ctx, vision + tools — 3.5's affinity, carried\n fallback: [\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"zai/glm-5.3\", // $1.40/$4.40, 1M ctx\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — written where 2.5 Flash sat (retired 2026-12-01); the duplicate after it is dropped\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n ],\n },\n MEDIUM: {\n primary: \"openai/gpt-5.3-codex\", // $1.75/$14 - 400K context, 128K output — code_edit/debug lead (portfolio.ts)\n fallback: [\n \"anthropic/claude-sonnet-5\", // $3/$15 — code_agent band 0.98\n \"moonshot/kimi-k3.1-pro\", // $2/$10, 1M ctx — Moonshot flagship\n \"zai/glm-5.3\", // $1.40/$4.40 — long-horizon coding\n \"google/gemini-3.6-flash\", // $0.75/$3.75 (3.5 Flash, the next rung, retired 2026-11-24)\n \"google/gemini-3.8-flash\", // $0.75/$3.75 — 2.5 Pro's successor (retired 2026-12-01)\n \"xai/grok-4.5\", // $2.50/$9\n \"anthropic/claude-sonnet-4.6\", // $3/$15\n \"openai/gpt-5.6-terra\", // $2/$12\n ],\n },\n COMPLEX: {\n // fable-5 was promoted here 2026-06-11, force-reverted 2026-06-13 when Anthropic\n // withdrew the offer, and restored 2026-07-14 now that BlockRun has relisted it.\n primary: \"anthropic/claude-fable-5\", // Best quality for complex tasks — Mythos-class flagship above Opus ($10/$50, 1M ctx, always-on thinking)\n // Fallback chain de-Gemini'd 2026-04-22: when Anthropic 503s, Gemini is\n // also prone to \"high demand\" 503s (correlated failure — everyone falls\n // back to Google at the same time). Prefer in-family → xAI → Moonshot →\n // OpenAI flagship → Z.AI → DeepSeek → NVIDIA free instead.\n fallback: [\n \"anthropic/claude-opus-5\", // in-family hot swap first (half the price, 1M ctx + adaptive thinking)\n \"anthropic/claude-opus-4.8\", // in-family hot swap (identical cost to 5)\n \"anthropic/claude-opus-4.7\", // in-family hot swap (identical cost to 4.8)\n \"anthropic/claude-sonnet-5\", // Sonnet-tier drop-down, near-Opus quality\n \"anthropic/claude-sonnet-4.6\",\n \"xai/grok-4.5\", // xAI flagship — 503-resistant, direct-xAI SKU\n \"moonshot/kimi-k3.1-pro\", // Moonshot flagship, independent infra\n \"openai/gpt-5.6-terra\", // GPT-5.6 balanced tier — stable (Sol excluded: #202)\n \"openai/gpt-5.5\", // Prior OpenAI flagship — 1M+ ctx, native agent + computer use\n \"openai/gpt-5.4\", // Previous flagship (slow but stable, benchmarked at 6,213ms)\n \"openai/gpt-5.3-codex\",\n \"zai/glm-5.3\", // Z.AI flagship, 1M ctx\n \"deepseek/deepseek-v4-pro\", // strongest open-weight reasoner\n \"deepseek/deepseek-chat\", // Cheap, reliable\n \"nvidia/nemotron-3.5-lightning\", // NVIDIA free ultimate backstop\n ],\n },\n REASONING: {\n // Sonnet 5 promoted over Sonnet 4.6 (same price; reasoning band 0.98 for both,\n // plus Sonnet 5's tau2/BrowseComp trajectory evidence).\n primary: \"anthropic/claude-sonnet-5\", // $3/$15, 1M ctx, adaptive thinking\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus w/ adaptive thinking\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus w/ adaptive thinking\n \"xai/grok-4.5\", // reasoning band 0.94\n \"deepseek/deepseek-v4-pro\", // reasoning band 0.95\n \"xai/grok-4.3\", // $1.50/$4 — xAI reasoning model\n \"openai/gpt-5.4-mini\", // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung)\n ],\n },\n },\n\n // Agentic tier configs - models that excel at multi-step autonomous tasks\n agenticTiers: {\n SIMPLE: {\n primary: \"openai/gpt-4o-mini\", // $0.15/$0.60 - best tool compliance at lowest cost\n fallback: [\n \"openai/gpt-5.6-luna\", // $0.20/$1.20 — lightweight agentic tier of GPT-5.6\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — tool calls verified live 2026-08-27\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n MEDIUM: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then GPT-5 Mini — which\n // carries the Terminal-Bench and tau2 trajectory evidence in\n // portfolio.ts — until its 2026-12-11 retirement. GPT-5.6 Luna is what\n // the gateways serve under that name from then on.\n primary: \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx, vision + tools — gpt-5-mini's affinity (4/7 Terminal-Bench, 5/6 tau2 airline), carried\n fallback: [\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — tool_agent band 0.88 (3.5's, carried)\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — tools verified\n \"openai/gpt-5.6-terra\", // $2/$12\n \"openai/gpt-4o-mini\", // $0.15/$0.60 — reliable tool calling\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"moonshot/kimi-k3.1-pro\", // $2/$10 — tool_agent band 0.85\n ],\n },\n COMPLEX: {\n // Sonnet 5 promoted over Sonnet 4.6: tau2 airline + retail reward 1.0,\n // Terminal-Bench safety band lead (portfolio.ts).\n primary: \"anthropic/claude-sonnet-5\", // $3/$15 — best agentic quality per trajectory evidence\n // Fallback chain de-Gemini'd 2026-04-22: Gemini's \"high demand\" 503s\n // correlate with Anthropic outages (everyone falls back together).\n // Prefer 503-resistant providers first.\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus — in-family hot swap\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus — in-family hot swap\n \"xai/grok-4.5\", // xAI flagship — strong tool use, independent infra\n \"moonshot/kimi-k3.1-pro\", // Moonshot flagship — independent infra\n \"openai/gpt-5.6-terra\", // GPT-5.6 balanced tier — stable (Sol excluded: #202)\n \"openai/gpt-5.5\", // Prior flagship — native agent + computer use (exactly the agentic-tier use case)\n \"openai/gpt-5.4\", // Previous flagship — reliable\n \"openai/gpt-5.3-codex\", // code_agent lead\n \"zai/glm-5.3\", // long-horizon coding\n \"deepseek/deepseek-v4-pro\", // retail high-risk 3/3\n \"deepseek/deepseek-chat\", // cheap, reliable\n \"nvidia/nemotron-3.5-lightning\", // NVIDIA free ultimate backstop\n ],\n },\n REASONING: {\n primary: \"anthropic/claude-sonnet-5\", // $3/$15 — strong tool use + adaptive thinking\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus w/ adaptive thinking\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus w/ adaptive thinking\n \"xai/grok-4.5\", // reasoning band 0.94\n \"deepseek/deepseek-v4-pro\", // reasoning band 0.95\n \"deepseek/deepseek-reasoner\", // $0.14/$0.28\n ],\n },\n },\n\n // Time-windowed promotions — auto-applied when active, ignored when expired.\n // The GLM-5.1 launch promo (2026-04-01 → 2026-05-01) was the last entry and\n // has expired; the list is kept empty so the mechanism stays wired.\n promotions: [],\n\n overrides: {\n maxTokensForceComplex: 100_000,\n structuredOutputMinTier: \"MEDIUM\",\n ambiguousDefaultTier: \"MEDIUM\",\n // agenticMode left undefined → auto-detect via tools/agenticScore.\n // Set to `true` to force agentic tiers; `false` to disable them entirely.\n },\n};\n","/**\n * Model capabilities used for hard routing constraints.\n *\n * Hosts may inject fresher values through RouterOptions.modelCapabilities.\n * Keeping a small built-in snapshot makes the core safe and useful when a\n * product catalog is temporarily unavailable, without importing product code.\n *\n * GENERATED by scripts/sync-model-capabilities.mjs from the public catalog\n * (GET https://blockrun.ai/api/v1/models) on 2026-11-24; supportsTools comes\n * from a live function-calling probe (scripts/probe-tools.json). Regenerate\n * rather than editing by hand — a hand edit is overwritten on the next sync.\n */\nexport type ModelCapabilities = {\n contextWindow: number;\n maxOutputTokens: number;\n supportsTools: boolean;\n supportsVision: boolean;\n};\n\nexport const DEFAULT_MODEL_CAPABILITIES: Readonly> =\n Object.freeze({\n \"anthropic/claude-fable-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-fable-5.1\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-fable-5.2\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"anthropic/claude-haiku-4.5\": { // override: The public catalog's `categories` omit \"vision\" for this Anthropic model even though the gateway accepts image input for it (the prior hand-maintained snapshot had it, and Anthropic's model card lists it). Without this the vision filter would silently drop it — reported against the catalog; remove once the categories carry vision.\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.5\": {\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.7\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.8\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-5.5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-4.5\": {\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-4.6\": { // override: The public catalog's `categories` omit \"vision\" for this Anthropic model even though the gateway accepts image input for it (the prior hand-maintained snapshot had it, and Anthropic's model card lists it). Without this the vision filter would silently drop it — reported against the catalog; remove once the categories carry vision.\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-5.5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"cohere/north-mini-code\": { // supportsTools: not probed — fails closed\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"deepseek/deepseek-chat\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-chat \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-reasoner\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-reasoner \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-v4-flash-vision-exp\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"deepseek/deepseek-v4-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-v4.1-flash\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-v4.1-flash \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-2.5-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-2.5-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-2.5-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3-flash-preview\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.1-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-3.1-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.5-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.5-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-3.6-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.8-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-4-argon\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"google/gemini-4-carbon\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-4-hydrogen\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"google/gemini-4-neon\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"minimax/minimax-m2.7\": {\n contextWindow: 204_800,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"minimax/minimax-m3\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"mistral/mistral-large-4\": { // supportsTools: not probed — fails closed\n contextWindow: 524_288,\n maxOutputTokens: 262_144,\n supportsTools: false,\n supportsVision: true,\n },\n \"moonshot/kimi-k3.1-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"nvidia/minimax-m3.1-flash\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/muse-glimmer-30b\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\": { // override: The catalog tags this model \"vision\", but a correctly sized probe does not hold up (ClawRouter, 2026-08-31): a 64x64 solid-red PNG was named correctly 1 of 4 times on Base, and on Solana the image was silently dropped and a text model answered \"white\". An HTTP 200 with a confident wrong answer gives the caller nothing to branch on, so image turns must not be routed here. It is ecoTiers.SIMPLE.fallback[0] since nemotron-3-nano-30b was delisted (2026-09-08); remove once a probe of this size comes back right on both chains.\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3-super-120b\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: true,\n },\n \"nvidia/nemotron-3-ultra-550b\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3.5-bolt\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: true,\n },\n \"nvidia/nemotron-3.5-lightning\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"openai/chat-latest\": {\n contextWindow: 128_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4.1\": {\n contextWindow: 128_000,\n maxOutputTokens: 32_768,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4.1-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 32_768,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-4o\": {\n contextWindow: 128_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4o-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5-mini\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.1\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.2\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.2-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.3-codex\": { // supportsTools: gateway unavailable at probe time — fails closed; override: 2026-08-29 probe: every request (6 plain + 3 tool attempts) returned a gateway 500, so the probe measured an incident, not the model. Codex's function calling is established by the 2026-07 Terminal-Bench / tau2 calibration trajectories in portfolio.ts. Hosts observing the 500s should drop it with RouterOptions.unavailableModels rather than this snapshot claiming the model cannot call tools.\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.4\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.4-mini\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.4-nano\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.4-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.5\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.5-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.6-luna\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-luna-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.6-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-sol-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-terra\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-terra-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-astra\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-luna\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6.1-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6.2-astra\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-6.2-sol\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/o1\": {\n contextWindow: 200_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o3\": {\n contextWindow: 200_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o3-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o4-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"poolside/laguna-s-2.1\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: false,\n },\n \"poolside/laguna-xs-2.1\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"qwen/qwen3.7-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.7-max\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.7-plus\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.8-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: true,\n },\n \"qwen/qwen3.8-max\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: false,\n },\n \"tencent/hy4-preview\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 64_000,\n supportsTools: false,\n supportsVision: false,\n },\n \"xai/grok-4.3\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.5\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.6\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.7\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-build-0.1\": {\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"xiaomi/mimo-v2.5\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: true,\n },\n \"xiaomi/mimo-v2.5-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5-turbo\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.1\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.2\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.3\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.3-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: true,\n },\n });\n","{\n \"anthropic/claude-fable-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9298.5,\n \"p95LatencyMs\": 9873.4,\n \"outputTokensPerSecond\": 55.17,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-haiku-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3157.4,\n \"p95LatencyMs\": 3170.7,\n \"outputTokensPerSecond\": 162.16,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6497.7,\n \"p95LatencyMs\": 6953.7,\n \"outputTokensPerSecond\": 78.99,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.7\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5316.5,\n \"p95LatencyMs\": 6121.5,\n \"outputTokensPerSecond\": 97.34,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.8\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6216.1,\n \"p95LatencyMs\": 6847.7,\n \"outputTokensPerSecond\": 82.81,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7309,\n \"p95LatencyMs\": 7745.2,\n \"outputTokensPerSecond\": 70.17,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6330.4,\n \"p95LatencyMs\": 6631.6,\n \"outputTokensPerSecond\": 81.03,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-4.6\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6508,\n \"p95LatencyMs\": 6698.3,\n \"outputTokensPerSecond\": 78.6,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6165.4,\n \"p95LatencyMs\": 6582.9,\n \"outputTokensPerSecond\": 83.62,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-chat\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4351.4,\n \"p95LatencyMs\": 4543.7,\n \"outputTokensPerSecond\": 117.78,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-reasoner\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5201.2,\n \"p95LatencyMs\": 6079.6,\n \"outputTokensPerSecond\": 99.77,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-v4-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 8781.2,\n \"p95LatencyMs\": 9881.1,\n \"outputTokensPerSecond\": 58.98,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-v4.1-flash\": {\n \"measuredAt\": \"2026-10-20T18:12:51Z\",\n \"latencyMs\": 2383.5,\n \"p95LatencyMs\": 2547.8,\n \"outputTokensPerSecond\": 216.53,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5416.4,\n \"p95LatencyMs\": 6442.8,\n \"outputTokensPerSecond\": 213.07,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5002.6,\n \"p95LatencyMs\": 5780.3,\n \"outputTokensPerSecond\": 408.43,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 28169.5,\n \"p95LatencyMs\": 29491.4,\n \"outputTokensPerSecond\": 147.3,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3-flash-preview\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4717.1,\n \"p95LatencyMs\": 5037.1,\n \"outputTokensPerSecond\": 198.71,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.1-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2855.8,\n \"p95LatencyMs\": 3172.7,\n \"outputTokensPerSecond\": 286.91,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.1-pro\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 24194.1,\n \"p95LatencyMs\": 27269.6,\n \"outputTokensPerSecond\": 109.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.5-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5320.6,\n \"p95LatencyMs\": 5429.8,\n \"outputTokensPerSecond\": 226.21,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.5-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3515.8,\n \"p95LatencyMs\": 4363.4,\n \"outputTokensPerSecond\": 248.9,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.6-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 13020,\n \"p95LatencyMs\": 15383.1,\n \"outputTokensPerSecond\": 187.87,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"minimax/minimax-m2.7\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 8761.1,\n \"p95LatencyMs\": 10199.3,\n \"outputTokensPerSecond\": 59.18,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"minimax/minimax-m3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 11101.9,\n \"p95LatencyMs\": 26087.1,\n \"outputTokensPerSecond\": 101.12,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"moonshot/kimi-k3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 24498.9,\n \"p95LatencyMs\": 40365.3,\n \"outputTokensPerSecond\": 25.11,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"moonshot/kimi-k3.1-pro\": {\n \"measuredAt\": \"2026-11-23T20:18:18Z\",\n \"latencyMs\": 9243.1,\n \"p95LatencyMs\": 10504.1,\n \"outputTokensPerSecond\": 55.89,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"nvidia/mistral-nemotron\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7349.6,\n \"p95LatencyMs\": 9932.3,\n \"outputTokensPerSecond\": 79.48,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 9324.6,\n \"p95LatencyMs\": 12992,\n \"outputTokensPerSecond\": 64.96,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"nvidia/nemotron-nano-12b-v2-vl\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5846.9,\n \"p95LatencyMs\": 5846.9,\n \"outputTokensPerSecond\": 87.57,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"nvidia/nemotron-nano-9b-v2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5282.5,\n \"p95LatencyMs\": 5282.5,\n \"outputTokensPerSecond\": 96.92,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"nvidia/step-3.7-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4617.4,\n \"p95LatencyMs\": 5237.4,\n \"outputTokensPerSecond\": 112.92,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"openai/chat-latest\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3690.9,\n \"p95LatencyMs\": 4344,\n \"outputTokensPerSecond\": 111.85,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3527.9,\n \"p95LatencyMs\": 3831.7,\n \"outputTokensPerSecond\": 141.27,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4268.2,\n \"p95LatencyMs\": 5101.5,\n \"outputTokensPerSecond\": 103.42,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1-nano\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3088.3,\n \"p95LatencyMs\": 3369.2,\n \"outputTokensPerSecond\": 150.31,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4o\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2995.2,\n \"p95LatencyMs\": 3174.2,\n \"outputTokensPerSecond\": 171.32,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4o-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4751.5,\n \"p95LatencyMs\": 4930.4,\n \"outputTokensPerSecond\": 107.84,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4558.1,\n \"p95LatencyMs\": 5081.9,\n \"outputTokensPerSecond\": 113.25,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5436.6,\n \"p95LatencyMs\": 5928.8,\n \"outputTokensPerSecond\": 95.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.3-codex\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 15290.4,\n \"p95LatencyMs\": 15290.4,\n \"outputTokensPerSecond\": 33.49,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"openai/gpt-5.4\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5596,\n \"p95LatencyMs\": 5919.4,\n \"outputTokensPerSecond\": 91.67,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.4-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3377.8,\n \"p95LatencyMs\": 3646.8,\n \"outputTokensPerSecond\": 138.08,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.4-nano\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4040.4,\n \"p95LatencyMs\": 4205.9,\n \"outputTokensPerSecond\": 118.52,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6367.8,\n \"p95LatencyMs\": 7330.7,\n \"outputTokensPerSecond\": 81.29,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-luna\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6064.5,\n \"p95LatencyMs\": 7347.3,\n \"outputTokensPerSecond\": 87.93,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-luna-pro\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 13914.9,\n \"p95LatencyMs\": 13914.9,\n \"outputTokensPerSecond\": 36.79,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"openai/gpt-5.6-sol\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7720.2,\n \"p95LatencyMs\": 9108.2,\n \"outputTokensPerSecond\": 67.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-sol-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 11442.7,\n \"p95LatencyMs\": 13363.1,\n \"outputTokensPerSecond\": 148.75,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-terra\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4941,\n \"p95LatencyMs\": 5095.3,\n \"outputTokensPerSecond\": 103.69,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-terra-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3574.1,\n \"p95LatencyMs\": 4126.3,\n \"outputTokensPerSecond\": 133.59,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-6.1-sol\": {\n \"measuredAt\": \"2026-10-20T18:12:51Z\",\n \"latencyMs\": 11324,\n \"p95LatencyMs\": 12747.6,\n \"outputTokensPerSecond\": 45.11,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4324.9,\n \"p95LatencyMs\": 5838.1,\n \"outputTokensPerSecond\": 125.86,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5463.4,\n \"p95LatencyMs\": 5613.1,\n \"outputTokensPerSecond\": 93.8,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o3-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2912.7,\n \"p95LatencyMs\": 3092.1,\n \"outputTokensPerSecond\": 176.49,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o4-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4958.7,\n \"p95LatencyMs\": 5313,\n \"outputTokensPerSecond\": 103.81,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3385.5,\n \"p95LatencyMs\": 4042.7,\n \"outputTokensPerSecond\": 153.94,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-max\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9387.1,\n \"p95LatencyMs\": 10490.2,\n \"outputTokensPerSecond\": 54.92,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-plus\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9766.6,\n \"p95LatencyMs\": 9798.2,\n \"outputTokensPerSecond\": 52.42,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"tencent/hy3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6062.3,\n \"p95LatencyMs\": 7070.2,\n \"outputTokensPerSecond\": 87.3,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-4.3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9467.7,\n \"p95LatencyMs\": 10087.9,\n \"outputTokensPerSecond\": 48.36,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 13564.8,\n \"p95LatencyMs\": 17351.9,\n \"outputTokensPerSecond\": 60.71,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-build-0.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 16394.8,\n \"p95LatencyMs\": 18035.4,\n \"outputTokensPerSecond\": 96.86,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xiaomi/mimo-v2.5-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 12070.7,\n \"p95LatencyMs\": 12386.8,\n \"outputTokensPerSecond\": 42.44,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6839.7,\n \"p95LatencyMs\": 7261.4,\n \"outputTokensPerSecond\": 75.16,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5-turbo\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 55348.5,\n \"p95LatencyMs\": 114086.6,\n \"outputTokensPerSecond\": 14.64,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 15658.4,\n \"p95LatencyMs\": 17307.1,\n \"outputTokensPerSecond\": 32.9,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 10308.5,\n \"p95LatencyMs\": 15127.6,\n \"outputTokensPerSecond\": 54.87,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7272.4,\n \"p95LatencyMs\": 7998.1,\n \"outputTokensPerSecond\": 71.09,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.3-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 10545.3,\n \"p95LatencyMs\": 11672.4,\n \"outputTokensPerSecond\": 49.01,\n \"errorRate\": 0,\n \"samples\": 3\n }\n}\n","/**\n * Model-performance priors consumed by the portfolio router.\n *\n * The entries below are a small, auditable seed extracted from the 2026-03-16\n * BlockRun performance run. They are deliberately weak priors: live data\n * injected by the host should replace them through configuration before a\n * release. Historical numbers must never be presented as a current\n * provider SLA or as task-quality measurements.\n */\n\nimport liveProfiles from \"./model-profiles.generated.json\";\n\nexport type ModelPerformanceProfile = {\n measuredAt: string;\n /** Gateway end-to-end latency for the benchmark workload. */\n latencyMs: number;\n /** Tail latency is more relevant than mean latency for urgent requests. */\n p95LatencyMs?: number;\n outputTokensPerSecond: number;\n /** External intelligence index when one was available; not task success. */\n intelligenceIndex?: number;\n /** Failure fraction observed in the same benchmark run. */\n errorRate?: number;\n /** Number of sampled calls behind the observation. */\n samples?: number;\n};\n\n// Generated from benchmark files that satisfy the uncached-inference\n// invariant. These are weak performance priors (speed/reliability), never\n// task-quality labels.\nexport const LIVE_MODEL_PROFILES: Readonly> = Object.freeze(\n liveProfiles as Record,\n);\n\nexport const HISTORICAL_MODEL_PROFILES: Readonly> =\n Object.freeze({\n \"anthropic/claude-haiku-4.5\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2305,\n outputTokensPerSecond: 140.6,\n },\n \"anthropic/claude-sonnet-4.6\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2110,\n outputTokensPerSecond: 121.3,\n },\n \"deepseek/deepseek-chat\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1431,\n outputTokensPerSecond: 179.2,\n intelligenceIndex: 32,\n },\n \"google/gemini-2.5-flash\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1238,\n outputTokensPerSecond: 207.6,\n intelligenceIndex: 20,\n },\n \"google/gemini-2.5-flash-lite\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1353,\n outputTokensPerSecond: 192.5,\n intelligenceIndex: 20,\n },\n \"google/gemini-2.5-pro\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1294,\n outputTokensPerSecond: 197.8,\n },\n \"google/gemini-3.1-pro\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1609,\n outputTokensPerSecond: 167.2,\n },\n \"openai/gpt-4o-mini\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2764,\n outputTokensPerSecond: 92.8,\n },\n \"openai/gpt-5.3-codex\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 7935,\n outputTokensPerSecond: 32.3,\n },\n });\n","/**\n * Whether the request actually requires an external action/tool, as distinct\n * from merely being sent by a host that exposes tools on every turn.\n *\n * The detector intentionally looks for action+target pairs. A generic factual\n * or multiple-choice question must stay false even when the host attaches a\n * large tool schema; otherwise every tool-enabled host turn is over-routed as\n * an agent task and models may browse or mutate state unnecessarily.\n */\nexport function inferToolRequirement(\n prompt: string,\n _systemPrompt?: string,\n toolChoice?: unknown,\n): boolean {\n // OpenAI-compatible clients can state this requirement directly. Treat that\n // protocol signal as authoritative instead of trying to infer it from prose.\n if (toolChoice === \"none\") return false;\n if (toolChoice === \"required\") return true;\n if (\n typeof toolChoice === \"object\" &&\n toolChoice !== null &&\n (toolChoice as { type?: unknown }).type === \"function\"\n ) {\n return true;\n }\n\n // System prompts commonly describe every tool a host exposes. They are not\n // evidence that the user asked to perform an action on this turn. Explicit\n // host requirements should use tool_choice/requiresTools instead.\n const text = prompt;\n const explicitTool =\n /\\b(?:use|call|invoke)\\s+(?:the\\s+)?[\\w.-]+\\s+(?:tool|function|api)\\b|\\btool[_ -]?call\\b|使用.{0,20}(?:工具|函数|接口)|调用.{0,20}(?:工具|函数|接口)/i;\n const codeEnvironment =\n /\\b(?:run|execute)\\s+(?:the\\s+)?(?:tests?|command|script|build|linter)|\\b(?:edit|modify|patch|create|write|save|delete|rename|move|inspect|read)\\b.{0,60}\\b(?:file|repository|repo|codebase|directory|folder)\\b|\\b(?:terminal|shell|bash|zsh|pytest|npm test|pnpm test|git\\s+(?:status|diff|commit)|docker)\\b|(?:运行|执行).{0,20}(?:测试|命令|脚本|构建)|(?:修改|编辑|修复|创建|读取|检查|保存).{0,30}(?:文件|仓库|代码库|目录)/i;\n const webAction =\n /\\b(?:browse|search|look up|fetch|open)\\b.{0,80}\\b(?:web|website|url|online|documentation|docs|news|weather|price)\\b|(?:浏览|搜索|查询|打开).{0,30}(?:网页|网站|链接|文档|新闻|天气|价格)/i;\n const statefulAction =\n /\\b(?:refund|cancel|book|reserve|purchase|buy|return|exchange|transfer|update|change)\\b.{0,80}\\b(?:order|booking|reservation|account|address|payment|subscription|ticket|flight|item)\\b|(?:退款|取消|预订|购买|退货|换货|转账|更新|修改).{0,30}(?:订单|预订|账户|地址|付款|订阅|票|航班|商品)/i;\n return (\n explicitTool.test(text) ||\n codeEnvironment.test(text) ||\n webAction.test(text) ||\n statefulAction.test(text)\n );\n}\n","/**\n * V3 portfolio router.\n *\n * This is deliberately local and deterministic: feature extraction, eligibility\n * checks and scoring read only request data plus the in-process model registry.\n * It is therefore safe for the hot path and provides a stable baseline for the\n * RouterBench evaluation before health telemetry / an optional judge are added.\n */\n\nimport { DEFAULT_ROUTING_CONFIG } from \"./config.js\";\nimport { DEFAULT_MODEL_CAPABILITIES } from \"./model-capabilities.js\";\nimport { getFallbackChain, selectModel, usablePricing } from \"./selector.js\";\nimport { RulesStrategy } from \"./strategy.js\";\nimport {\n HISTORICAL_MODEL_PROFILES,\n LIVE_MODEL_PROFILES,\n type ModelPerformanceProfile,\n} from \"./model-profiles.js\";\nimport type { RouterOptions, RouterStrategy, TaskType, Tier, TierConfig } from \"./types.js\";\nimport { inferToolRequirement } from \"./tool-intent.js\";\nimport { estimateTokens, sampleForScan, scanLimit } from \"./tokens.js\";\n\ntype TaskFeatures = {\n taskType: TaskType;\n estimatedInputTokens: number;\n hasCode: boolean;\n needsTools: boolean;\n toolsAvailable: boolean;\n needsVision: boolean;\n needsStructuredOutput: boolean;\n latencySensitive: boolean;\n highStakes: boolean;\n language: \"zh\" | \"other\";\n likelyParallelToolCalls: boolean;\n complexMultiToolPlan: boolean;\n agentDomain: \"airline\" | \"retail\" | \"web_research\" | \"other\";\n deepWebResearch: boolean;\n agentRisk: \"standard\" | \"high\" | \"complex_high\" | \"policy_exception_simple\" | \"policy_exception\";\n terminalToolSignal: boolean;\n terminalSafetySensitive: boolean;\n implicitTerminalCode: boolean;\n /** A code artifact or coding action is present, not merely a language name. */\n codeArtifact: boolean;\n};\n\n// The bundled config carries the calibrated weights; a host config that omits\n// `portfolio` scores with the same numbers rather than a second copy of them.\nconst DEFAULT_PORTFOLIO_WEIGHTS = DEFAULT_ROUTING_CONFIG.portfolio!;\n\n/**\n * Detect turns that probably need several tool calls. This is a\n * deliberately conservative request-side feature: it uses only the prompt\n * and visible tool count, never benchmark categories or expected answers.\n */\nfunction likelyNeedsParallelToolCalls(\n prompt: string,\n needsTools: boolean,\n toolCount: number | undefined,\n toolNames: readonly string[] | undefined,\n): boolean {\n if (!needsTools || toolCount === undefined || toolCount < 1) return false;\n const text = prompt.trim();\n const explicitRepeat =\n /\\b(?:in parallel|simultaneously|concurrently|for each|each of|every one|both|(?:two|three|multiple|several)\\s+(?:cities|locations|items|tasks|orders|users|files))\\b|并行|同时|分别|每个|各自|(?:两个|三个|多个)(?:城市|地点|项目|任务|订单|用户|文件)|cada uno|para cada|simult[aá]neamente/i.test(\n text,\n );\n if (explicitRepeat) return true;\n\n const sentenceClauses = text\n .split(/[.!?。!?]+/)\n .map((part) => part.trim())\n .filter((part) => part.length >= 8);\n if (\n (/\\b(?:also|additionally|furthermore)\\b|另外|此外|그리고/i.test(text) &&\n sentenceClauses.length >= 2) ||\n /\\band\\s+(?:also|for the)\\b/i.test(text)\n )\n return true;\n\n const pairedQuantity =\n /\\b\\d+(?:\\.\\d+)?\\s+(?:and|or)\\s+\\d+(?:\\.\\d+)?\\s*(?:gb|mb|tb|kg|g|ml|oz|cups?|cores?|cpus?)\\b/i.test(\n text,\n );\n if (pairedQuantity) return true;\n\n // Distinctive tokens from two visible tool names are a strong local signal\n // for a multi-operation turn (for example add_task + delete_task).\n const operationTokens = new Set([\n \"add\",\n \"delete\",\n \"remove\",\n \"cancel\",\n \"return\",\n \"exchange\",\n \"modify\",\n \"book\",\n \"transfer\",\n \"send\",\n \"upload\",\n \"download\",\n \"create\",\n \"close\",\n ]);\n // Whole words only, with an optional inflection: a substring test read\n // \"add\" out of \"address\", \"book\" out of \"facebook\" and \"close\" out of\n // \"closet\" (the same failure rules.ts fixed for its keyword lists).\n const lowered = text.toLowerCase();\n const matchedOperationTokens = new Set(\n (toolNames ?? [])\n .flatMap((name) => name.toLowerCase().split(/[^a-z0-9\\u3400-\\u9fff]+/))\n .filter(\n (token) =>\n operationTokens.has(token) &&\n new RegExp(`\\\\b${token}(?:s|es|d|ed|ing)?\\\\b`).test(lowered),\n ),\n );\n // A single workflow naturally mentions domain nouns like order/item plus\n // one action. Upgrade only when two different visible operation verbs are\n // requested (for example cancel + book or add + delete).\n if (matchedOperationTokens.size >= 2) return true;\n\n // Repeated food/logging entries are commonly expressed as several lines,\n // each with its own quantity rather than an explicit \"for each\" phrase.\n const nonEmptyLines = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter(Boolean);\n const quantityMentions =\n text.match(\n /\\b(?:\\d+(?:\\.\\d+)?|one|two|three|four|five|six|seven|eight|nine|ten)\\s*(?:oz|ounce|ounces|g|gram|grams|kg|ml|cups?|pieces?|tablespoons?)\\b/gi,\n ) ?? [];\n if (nonEmptyLines.length >= 2 && quantityMentions.length >= 2) return true;\n\n // Weather prompts provide a useful language-independent high-confidence\n // pattern: a single lookup tool plus multiple locations joined in one turn.\n const repeatedLookup =\n /\\b(?:weather|climate|clima|tiempo|temperature|snow|news|report)\\b|天气|气象|温度|降雪|新闻|报告/i.test(\n text,\n );\n const multiLocationConnector =\n /\\b(?:and also|both)\\b|\\s(?:y|e)\\s|还有|以及|和|、/i.test(text);\n const commaSeparatedLocations = (text.match(/[,,]/g) ?? []).length >= 2;\n if (repeatedLookup && (multiLocationConnector || commaSeparatedLocations)) return true;\n\n const distinctOrderParts =\n /\\b(?:food|meal)\\b[\\s\\S]*\\bdrink\\b|\\bdrink\\b[\\s\\S]*\\b(?:food|meal)\\b/i.test(text);\n const koreanParallelClauses = (text.match(/,/g) ?? []).length >= 3 && /하고|그리고/.test(text);\n return distinctOrderParts || koreanParallelClauses;\n}\n\nfunction classifyTask(\n prompt: string,\n systemPrompt: string | undefined,\n options: RouterOptions,\n): TaskFeatures {\n const fullText = `${systemPrompt ?? \"\"} ${prompt}`;\n const estimatedInputTokens = estimateTokens(fullText);\n const limit = scanLimit(options.config.classifier.promptTruncationChars);\n const scannedPrompt = sampleForScan(prompt, limit);\n const scannedSystemPrompt = sampleForScan(systemPrompt ?? \"\", limit);\n // Only the deep-web-research clue detectors below read the system prompt,\n // and they are gated on a web-research tool surface. Every other feature\n // reads the user turn: a host's standing instructions (\"be quick\", \"follow\n // security best practices\", a Mandarin persona) describe the assistant, not\n // this request, and must not move its scoring or language band.\n const scannedFullText = `${scannedSystemPrompt} ${scannedPrompt}`;\n const text = scannedPrompt.toLowerCase();\n const explicitCodeSignal =\n /```|\\b(?:typescript|javascript|python|rust|java|sql|stack trace|traceback|exception)\\b|\\.(?:ts|tsx|js|py|go|rs)\\b/i.test(\n scannedPrompt,\n );\n // `class` is common in non-code Agent domains (for example airline cabin\n // class). Treat code constructs as code only when the prompt also contains\n // an implementation/editing cue, instead of letting a single ambiguous\n // noun redirect an entire tool session to the code-agent portfolio.\n const codeConstructSignal =\n /\\b(?:implement|refactor|debug|write|edit|modify|create|define|review|fix)\\b[\\s\\S]{0,48}\\b(?:api|function|class|method)\\b|\\b(?:api|function|class|method)\\b[\\s\\S]{0,48}\\b(?:code|implementation|typescript|javascript|python|rust|java)\\b/i.test(\n scannedPrompt,\n );\n const nativeCodeSignal =\n /\\b(?:programmed|written|implemented?|code)\\s+(?:in|using)\\s+(?:c\\+\\+|c|rust|go)\\b/i.test(\n scannedPrompt,\n );\n // A CamelCase error class (TypeError, NullPointerException) is a runtime\n // artifact, not prose about errors; case-sensitive on purpose.\n const errorClassSignal = /\\b[A-Z][A-Za-z]*(?:Error|Exception)\\b/.test(scannedPrompt);\n const hasCode = explicitCodeSignal || codeConstructSignal || nativeCodeSignal || errorClassSignal;\n // A language name alone (\"java coffee prices\", \"python snake habitat\") is\n // not code work, even on a tool turn. It joins the code-agent pool only\n // together with a coding action.\n const codingAction =\n /\\b(?:write|implement|refactor|debug|fix|patch|compile|build|run|test|script|program|code|function|class|module|repo(?:sitory)?)\\b|编写|实现|重构|调试|修复|编译|脚本|代码/i.test(\n scannedPrompt,\n );\n // Stronger than hasCode: an actual code artifact or coding action, never a\n // bare language name (\"What is Python?\" is trivia, not a code task) and\n // never the English word \"exception\" on its own (\"please make an\n // exception\"); a thrown exception shows up as a CamelCase class above.\n const codeArtifact =\n /```|\\b(?:stack trace|traceback)\\b|\\.(?:ts|tsx|js|py|go|rs)\\b/i.test(scannedPrompt) ||\n codeConstructSignal ||\n nativeCodeSignal ||\n errorClassSignal;\n const toolsAvailable = options.hasTools ?? false;\n const needsTools =\n options.requiresTools ??\n (toolsAvailable && inferToolRequirement(scannedPrompt, scannedSystemPrompt));\n const likelyParallelToolCalls = likelyNeedsParallelToolCalls(\n scannedPrompt,\n needsTools,\n options.toolCount,\n options.toolNames,\n );\n const normalizedToolNames = (options.toolNames ?? []).map((name) => name.toLowerCase());\n const airlineToolSignal = normalizedToolNames.some((name) =>\n /(?:flight|reservation|airport|baggage|passenger)/.test(name),\n );\n const retailToolSignal = normalizedToolNames.some((name) =>\n /(?:order|product|item|return|exchange|address)/.test(name),\n );\n const webResearchToolSignal = normalizedToolNames.some((name) =>\n /^(?:web_?search|web_?fetch)$/.test(name),\n );\n const agentDomain =\n airlineToolSignal && !retailToolSignal\n ? \"airline\"\n : retailToolSignal && !airlineToolSignal\n ? \"retail\"\n : webResearchToolSignal\n ? \"web_research\"\n : \"other\";\n // Distinguish a cheap lookup from a BrowseComp-like investigation. These\n // prompts require joining several clues, resolving an entity, and ending in\n // one exact answer; complete agent trajectories show that treating them as\n // ordinary search causes long, costly loops. This is request/tool-surface\n // evidence only and does not depend on a benchmark id or hidden answer.\n const clueConnectors =\n scannedFullText.match(\n /\\b(?:after|before|while|where|whose|which|in \\d{4}|as of|over \\d+|another|also|furthermore)\\b|(?:之后|之前|其中|截至|超过|另一个|此外)/gi,\n ) ?? [];\n const entityResolutionSignal =\n /\\b(?:identify|who (?:is|was)|what (?:is|was) the name|which (?:person|player|company|country|city)|find the (?:person|player|name|entity))\\b|(?:找出|识别|是谁|哪位|名称是什么)/i.test(\n scannedFullText,\n );\n const exactAnswerSignal =\n /\\b(?:exact answer|single best-supported answer|following clues|multiple public sources)\\b|(?:精确答案|根据.*线索|多个公开来源)/i.test(\n scannedFullText,\n );\n const deepWebResearch =\n agentDomain === \"web_research\" &&\n (exactAnswerSignal ||\n (entityResolutionSignal && (clueConnectors.length >= 3 || prompt.length >= 320)));\n const globalOptimizationSignal =\n /\\b(?:cheapest|lowest[- ]price|least expensive|most expensive|highest(?:[- ]priced)?|largest|smallest|maximum|minimum|best available|closest|not (?:cost|exceed))\\b|最便宜|最低价|最贵|最高价|最大|最小/i.test(\n scannedPrompt,\n );\n const globalScopeSignal =\n /\\b(?:everything|all (?:(?:my|your|their|the) )?(?:future |upcoming )?(?:items|orders|passengers|flights|reservations|bookings)|every (?:item|order|passenger|flight|reservation|booking))\\b|全部|所有|每个/i.test(\n scannedPrompt,\n );\n const globalChoiceSignal = globalOptimizationSignal || globalScopeSignal;\n const crossRecordSignal =\n /\\b(?:another|other|different|previous)\\s+(?:order|reservation|booking|account|address)\\b|另一(?:个)?(?:订单|预订|账户|地址)|其他(?:订单|预订|账户|地址)/i.test(\n scannedPrompt,\n );\n // Reservation locators mix letters and digits (ZFA04Y, 4WQ150). Requiring\n // both keeps shouted words (\"CANCEL MY FLIGHT\") and plain six-digit numbers\n // from reading as two reservations.\n const reservationIds =\n scannedPrompt.match(/\\b(?=[A-Z0-9]*\\d)(?=[A-Z0-9]*[A-Z])[A-Z0-9]{6}\\b/g) ?? [];\n const crossReservationBatchSignal =\n agentDomain === \"airline\" &&\n (/\\b(?:two|three|multiple|several)(?:\\s+of\\s+(?:my|our|the))?\\s+(?:upcoming\\s+)?(?:reservations?|bookings?)\\b|\\b(?:a\\s+)?(?:second|third)\\s+(?:reservation|booking)\\b/i.test(\n scannedPrompt,\n ) ||\n new Set(reservationIds).size >= 2);\n const conditionalGlobalWorkflowSignal =\n agentDomain === \"airline\" &&\n globalScopeSignal &&\n /\\b(?:if|that (?:contain|have)|longer than|shorter than|under|over|at (?:most|least)|wherever possible)\\b|如果|超过|少于|不超过|尽可能/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:cancel|change|upgrade|move|book)\\b[\\s\\S]*\\b(?:cancel|change|upgrade|move|book)\\b|取消[\\s\\S]*(?:升级|更改)|升级[\\s\\S]*(?:取消|更改)/i.test(\n scannedPrompt,\n );\n // A refund explicitly targeted at a named/non-original card can conflict\n // with account state and require escalation rather than a substitute action.\n // This narrow feature is visible on the first turn and avoids sending every\n // ordinary return workflow to the expensive policy specialist.\n const policyExceptionSignal =\n agentDomain === \"retail\" &&\n /\\b(?:return|refund|send back|get (?:my |the )?money back)\\b|退货|退款|退回/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:amex|american express|visa|mastercard|credit card|debit card|different card|another card|other card)\\b|信用卡|借记卡|其他卡|另一张卡/i.test(\n scannedPrompt,\n );\n // A comparative selector can mention two products while requesting only\n // one write (for example \"send back the pricier one\"). Three-repeat tau2\n // calibration found no quality gain from the policy specialist on these\n // single-write cases, so keep them in a distinct, lower-cost risk band.\n const singleSelectedPolicyException =\n policyExceptionSignal &&\n /\\b(?:return|refund|send back)\\b[^.!?。!?]{0,96}\\b(?:the )?(?:pricier|cheaper|more expensive|less expensive|costlier|one)\\b/i.test(\n scannedPrompt,\n );\n // Returns and exchanges often pivot after confirmation (return -> rethink\n // -> exchange -> choose a variant). That future state is not visible to a\n // task-start router, so treat the observable workflow verb as the risk cue.\n // Simpler cancellation and one-field order edits stay on the standard path.\n const negotiatedWorkflowSignal =\n agentDomain === \"retail\" && /\\b(?:return|exchange)\\b|退货|退回|换货|交换/i.test(scannedPrompt);\n const numberedSteps = (scannedPrompt.match(/(?:^|\\s)\\d+(?:\\.\\d+)*[.)]\\s+/g) ?? []).length;\n const complexMultiToolPlan =\n likelyParallelToolCalls &&\n ((options.toolCount ?? 0) >= 6 || numberedSteps >= 3 || prompt.length > 1_200);\n let agentRisk: TaskFeatures[\"agentRisk\"] =\n needsTools && singleSelectedPolicyException\n ? \"policy_exception_simple\"\n : needsTools && policyExceptionSignal\n ? \"policy_exception\"\n : // Airline prompts that require a global optimum (for example the\n // cheapest itinerary across several candidates) are materially harder\n // than applying one change to every passenger in a known reservation.\n // Full-session evidence supports Sonnet for the former, while upgrading\n // the latter merely because it says \"all passengers\" caused a large cost\n // increase without a quality gain.\n needsTools &&\n agentDomain === \"airline\" &&\n (globalOptimizationSignal || conditionalGlobalWorkflowSignal)\n ? \"complex_high\"\n : needsTools &&\n (likelyParallelToolCalls ||\n globalChoiceSignal ||\n crossRecordSignal ||\n crossReservationBatchSignal ||\n negotiatedWorkflowSignal)\n ? \"high\"\n : \"standard\";\n const needsVision = options.hasVision ?? false;\n const needsStructuredOutput = options.requiresStructuredOutput ?? false;\n const latencySensitive =\n /\\b(?:urgent|asap|fast|quick|low latency|real[- ]time)\\b|尽快|马上|快速|低延迟/i.test(\n scannedPrompt,\n );\n const highStakes =\n /\\b(?:production|security|payment|legal|medical|financial|audit)\\b|生产|安全|支付|法律|医疗|财务|审计/i.test(\n scannedPrompt,\n );\n // Terminal tasks often describe the desired artifact rather than naming a\n // programming language. Treat only small, deterministic local build/file\n // work as implicit code. Operational deployment, credentials, destructive\n // work, evaluation, vision, and broad search stay on the stronger generic\n // tool-agent path. This is a request-side feature, not a benchmark ID list.\n const terminalToolSignal = normalizedToolNames.some((name) =>\n /^(?:terminalexec|terminalinspect|terminalsendkeys)$/.test(name),\n );\n const simpleTerminalArtifact =\n /\\b(?:create|write|convert|generate|build|implement|run|fix|repair|debug|make)\\b[\\s\\S]{0,120}\\b(?:file|script|csv|parquet|json|txt|server|endpoint)\\b/i.test(\n scannedPrompt,\n );\n // Multi-file repair is qualitatively different from fixing one known local\n // script. The agent must preserve state across inspections, infer ordering\n // and dependencies, edit several artifacts, and close the loop with tests.\n // A frozen Terminal-Bench trajectory showed the economy model spending 27\n // turns repeatedly rereading files without making an edit, while Opus solved\n // the same task in eight turns. Promote this request-visible pattern before\n // model scoring; no benchmark ID or expected answer is consulted.\n const terminalComplexRepair =\n terminalToolSignal &&\n /\\b(?:multiple|several)\\s+(?:scripts?|files?|components?)\\b|\\b(?:pipeline|dependencies)\\b[\\s\\S]{0,100}\\b(?:fail|issue|fix|repair|run|execute)\\b|\\b(?:identify|find|fix|repair)\\s+(?:and\\s+)?(?:fix\\s+)?all\\s+(?:the\\s+)?issues\\b/i.test(\n scannedPrompt,\n );\n // One artifact that must be accepted by multiple compilers/runtimes is not\n // a routine file-writing task. It requires reasoning across incompatible\n // grammars and validating every execution path; cheap code models can\n // produce plausible-looking source that satisfies neither toolchain.\n const mentionedTerminalRuntimes = new Set(\n (scannedPrompt.match(/\\b(?:gcc|clang|rustc|javac|go\\s+build|node|python)\\b/gi) ?? []).map(\n (name) => name.toLowerCase().replace(/\\s+/g, \" \"),\n ),\n );\n const terminalCrossRuntimeArtifact =\n terminalToolSignal &&\n (/\\bpolyglot\\b/i.test(scannedPrompt) ||\n /\\b(?:both|each)\\b[\\s\\S]{0,120}\\b(?:compilers?|runtimes?|toolchains?)\\b/i.test(\n scannedPrompt,\n ) ||\n (mentionedTerminalRuntimes.size >= 2 &&\n /\\b(?:compile|build|run|execute)\\b/i.test(scannedPrompt)));\n // Framework-to-native ports combine binary checkpoint inspection, weight\n // export, tensor-layout reasoning, image/data decoding, and a separately\n // compiled runtime. A task-start router can see this boundary directly in\n // the request (for example PyTorch state_dict -> a pure C CLI); treating it\n // like routine single-file C work caused a 30-turn read/retry loop in a\n // frozen official Terminal-Bench trajectory.\n const terminalFrameworkToNativeArtifact =\n terminalToolSignal &&\n /\\b(?:pytorch|tensorflow|jax|onnx|state[_ -]?dict|checkpoint|safetensors?)\\b|\\.(?:pth|pt|onnx)\\b/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:pure|native|programmed|written|implemented?)\\s+(?:in|using)\\s+(?:c\\+\\+|c|rust|go)\\b|\\b(?:c\\+\\+|c|rust|go)\\s+(?:program|binary|executable|cli|tool|implementation)\\b/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:inference|model|weights?|tensor|export|convert|load)\\b/i.test(scannedPrompt);\n if (\n needsTools &&\n (terminalComplexRepair || terminalCrossRuntimeArtifact || terminalFrameworkToNativeArtifact) &&\n (agentRisk === \"standard\" || agentRisk === \"high\")\n )\n agentRisk = \"complex_high\";\n const complexTerminalOperation =\n /\\b(?:git|ssh|nginx|https|certificate|authentication|credential|deploy|production|encrypt|gpg|shred|securely delete|decommission|benchmark|evaluate|embedding|chess|image|search the web|schema|statistical|statistics|aggregate|join|multiple inputs?)\\b/i.test(\n scannedPrompt,\n );\n // A bare \"token\" is not a credential signal: blockchain, tokenizer, and\n // LLM tasks use that word routinely (for example \"token transfers\"). Only\n // treat it as sensitive when the prompt gives it an authentication/secret\n // qualifier. API keys remain an unambiguous high-risk signal on their own.\n const terminalCredentialSignal =\n /\\b(?:ssh|nginx|certificate|authentication|credentials?|passwords?|api keys?|deploy|production|encrypt|gpg|shred|securely delete|decommission)\\b/i.test(\n scannedPrompt,\n ) ||\n /\\b(?:access|auth|authentication|bearer|secret|api)\\s+tokens?\\b|\\btokens?\\s+(?:secret|credential|authentication)\\b/i.test(\n scannedPrompt,\n );\n const terminalSafetySensitive = terminalToolSignal && (highStakes || terminalCredentialSignal);\n const implicitTerminalCode =\n needsTools &&\n terminalToolSignal &&\n agentRisk === \"standard\" &&\n !highStakes &&\n !complexTerminalOperation &&\n numberedSteps < 3 &&\n prompt.length <= 1_000 &&\n simpleTerminalArtifact;\n // Han characters alone also spell Japanese; kana marks the prompt as not\n // Mandarin, so it does not get the Mandarin-native extraction band.\n const language =\n /[\\u3400-\\u9fff]/.test(scannedPrompt) && !/[\\u3040-\\u30ff]/.test(scannedPrompt)\n ? \"zh\"\n : \"other\";\n const multipleChoiceSignals = (scannedPrompt.match(/(?:^|\\n)\\s*[A-D][.)]\\s+/gim) ?? []).length;\n const numericSignals = (scannedPrompt.match(/-?\\d+(?:[.,]\\d+)?/g) ?? []).length;\n const compactMathProblem =\n !hasCode &&\n prompt.length < 2_500 &&\n numericSignals >= 2 &&\n (/[+×÷=%$€£¥]|\\b(?:total|each|per|times|half|twice|percent|how many|how much|calculate)\\b/i.test(\n scannedPrompt,\n ) ||\n /[??]\\s*$/.test(scannedPrompt.trim()) ||\n numericSignals >= 3);\n\n let taskType: TaskType = \"chat\";\n if (needsVision) taskType = \"vision\";\n else if (estimatedInputTokens > 80_000) taskType = \"long_context\";\n else if (needsTools && (codeArtifact || (hasCode && codingAction) || implicitTerminalCode))\n taskType = \"code_agent\";\n else if (needsTools && likelyParallelToolCalls && !complexMultiToolPlan)\n taskType = \"tool_agent_parallel\";\n else if (needsTools) taskType = \"tool_agent\";\n else if (multipleChoiceSignals >= 3) taskType = \"reasoning_mcq\";\n else if (compactMathProblem) taskType = \"reasoning_math\";\n else if (\n errorClassSignal ||\n /\\b(?:bug|debug|error|failure|failing|regression|crash)\\b|修复|报错|错误|调试/i.test(text)\n )\n taskType = \"debug\";\n else if (hasCode || /\\b(?:refactor|implement|patch|edit|rewrite)\\b|重构|实现|修改/i.test(text))\n taskType = \"code_edit\";\n else if (needsStructuredOutput || /\\b(?:extract|json|schema|csv)\\b|字段|提取/i.test(text))\n taskType = \"extraction\";\n else if (\n /\\b(?:prove|derive|theorem|formal|mathematical|reasoning)\\b|证明|推导|定理|数学/i.test(text)\n )\n taskType = \"reasoning\";\n\n return {\n taskType,\n estimatedInputTokens,\n hasCode,\n needsTools,\n toolsAvailable,\n needsVision,\n needsStructuredOutput,\n latencySensitive,\n highStakes,\n language,\n likelyParallelToolCalls,\n complexMultiToolPlan,\n agentDomain,\n deepWebResearch,\n agentRisk,\n terminalToolSignal,\n terminalSafetySensitive,\n implicitTerminalCode,\n codeArtifact,\n };\n}\n\n/**\n * Task-affinity bands. Each table maps a model name (the id after the\n * provider slash) to its calibrated affinity for one request shape; anything\n * absent scores the neutral `NEUTRAL_AFFINITY`. Names are matched exactly:\n * model family names are intentionally similar (`gemini-2.5-flash` vs\n * `gemini-2.5-flash-lite`), and a substring match would let a smaller sibling\n * inherit a capability claim measured only for the flagship. A sibling joins a\n * band only with its own evidence.\n */\ntype AffinityBand = Readonly>;\n\n// Every \"gemini-3.6-flash\" value below is CARRIED from Gemini 3.5 Flash, not\n// measured on 3.6. The calibrations that set them (RouterBench GPQA/MGSM and\n// BFCL 2026-07-26/28, the Terminal-Bench and tau2 trajectories of 2026-07-28)\n// ran on 3.5. Google has answered the 3.5 name with 3.6 Flash since\n// ~2026-10-10, and on 2026-11-24 the gateways began redirecting 3.5 to 3.6, so\n// the router has in practice been routing 3.6 on these values since October;\n// the key now names the model that answers. The comments that cite \"Gemini\n// 3.5 Flash\" results describe those runs. Re-measure before treating any of\n// these as 3.6 evidence.\n//\n// Likewise every \"gemini-3.5-flash-lite\" value (extractionZh, extraction,\n// chat) is CARRIED from Gemini 2.5 Flash, which Google retired on 2026-12-01\n// and the gateways redirect to 3.5 Flash-Lite. It is a successor, not a\n// sibling claiming a flagship's evidence (see the rule above), but the values\n// were measured on 2.5 and still need a 3.5 Flash-Lite run.\n//\n// Likewise every \"gpt-5.6-luna\" value (and its place in the evidence pools and\n// the web-research order) is CARRIED from GPT-5 Mini, which OpenAI shuts down\n// on 2026-12-11 and the gateways redirect to GPT-5.6 Luna. The Terminal-Bench\n// and tau2 trajectories (2026-07-28) and the BrowseComp sessions behind them\n// ran on gpt-5-mini, a reasoning model; luna runs without reasoning, so these\n// are a placeholder, not luna evidence. Re-measure luna on those suites — or\n// move the bands to a measured model — before relying on them.\n\n/** Affinity of a model with no task-specific evidence. */\nconst NEUTRAL_AFFINITY = 0.68;\n\n// Strong native tool loop until the Responses function-output fix is deployed\n// on both gateways; Codex stays available below auto's affinity floor. Sonnet\n// has a verified native multi-turn tool loop and is the safe strong default.\nconst TERMINAL_COMPLEX_HIGH: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.3-codex\": 0.87,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n};\n\n// Complete-session BrowseComp calibration supersedes the earlier single-case\n// Opus promotion: strict deduplicated evidence has Sonnet 5 at 2/9 versus Opus\n// 5 at 0/3, while Opus also costs more and has a much longer tail. Opus stays\n// an availability fallback until a larger stable-provider sample supports it.\nconst WEB_RESEARCH_DEEP: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.88,\n \"gemini-3.6-flash\": 0.84,\n \"claude-opus-5\": 0.8,\n \"claude-opus-4.8\": 0.78,\n};\nconst WEB_RESEARCH: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.88,\n \"gemini-3.6-flash\": 0.86,\n \"claude-opus-5\": 0.84,\n \"claude-opus-4.8\": 0.82,\n};\n\nconst RETAIL_POLICY_EXCEPTION: AffinityBand = {\n \"gpt-4.1\": 1,\n \"claude-sonnet-5\": 0.9,\n \"deepseek-v4-pro\": 0.82,\n \"gpt-5.6-luna\": 0.8,\n \"gpt-4o-mini\": 0.76,\n};\nconst RETAIL_POLICY_EXCEPTION_SIMPLE: AffinityBand = {\n \"gpt-5.6-luna\": 1,\n \"gpt-4.1\": 0.86,\n \"deepseek-v4-pro\": 0.82,\n \"gpt-4o-mini\": 0.8,\n};\n\nconst AFFINITY = {\n // Seven valid full agent + official Terminal-Bench trajectories (2026-07-28)\n // gave GPT-5 Mini 4/7 resolved tasks versus 1/7 for the prior dynamic\n // code-agent choice. Its token-normalized total cost was higher in this small\n // calibration, so Codex and Sonnet keep quality priors above it; admitting\n // Mini to the scoring band lets the normal quality/cost profile choose it\n // without erasing stronger fallbacks. DeepSeek V4 Pro is kept below the\n // primary band after two consecutive mid-trajectory provider timeouts\n // contaminated its calibration runs.\n codeAgent: {\n \"gpt-5.3-codex\": 1,\n \"claude-sonnet-5\": 0.98,\n \"gpt-5.6-luna\": 0.96,\n \"gemini-3.6-flash\": 0.92,\n \"kimi-k3.1-pro\": 0.9,\n \"deepseek-v4-pro\": 0.88,\n \"glm-5.2\": 0.88,\n },\n // Seven official Terminal-Bench calibration trajectories favoured GPT-5 Mini\n // over the prior dynamic choice. Codex/Sonnet are close fallbacks; actual\n // request cost breaks the tie.\n terminalTool: {\n \"gpt-5.6-luna\": 1,\n \"gpt-5.3-codex\": 0.98,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.89,\n },\n // Two complete agent observations on the public Terminal-Bench\n // new-encrypt-command task ended in Codex repeating the same TerminalExec\n // input until the loop guard fired. Codex stays an availability fallback,\n // below the safety-band affinity floor, until its Responses function-output\n // path is verified on both gateways.\n terminalToolSafety: {\n \"claude-sonnet-5\": 1,\n \"claude-opus-4.8\": 0.9,\n \"gpt-5.3-codex\": 0.84,\n },\n // Full-session calibration: GPT-5 Mini completed two local/single retail\n // workflows at a fraction of Sonnet's token cost. It stays ineligible for\n // promotion when the prompt asks for multiple actions, cross-record\n // discovery or a global optimum; those trajectories exposed unstable write\n // arguments. DeepSeek V4 Pro completed all three high-risk retail calibration\n // trajectories (global-choice, cross-record, multi-write); Sonnet one.\n retailStandard: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.88,\n \"gemini-3.6-flash\": 0.82,\n \"gpt-5.3-codex\": 0.81,\n \"kimi-k3.1-pro\": 0.78,\n \"deepseek-v4-pro\": 0.76,\n },\n retailHigh: {\n \"deepseek-v4-pro\": 1,\n \"claude-sonnet-5\": 0.88,\n \"gemini-3.6-flash\": 0.82,\n \"gpt-5.3-codex\": 0.81,\n \"kimi-k3.1-pro\": 0.78,\n \"gpt-5.6-luna\": 0.76,\n },\n // Standard airline workflows stay on GPT-5 Mini: six full-session\n // development trajectories gave it the same 5/6 success as Sonnet at roughly\n // one order of magnitude lower normalized token cost. A held-out high-risk\n // cabin/date negotiation then produced a persistent empty assistant turn on\n // Mini even after a semantic retry, while Sonnet 5 completed the identical\n // official tau2 trajectory with reward 1.0. Only global optimization /\n // conditional-global work is promoted. A known batch of reservations is\n // operationally high-risk but still a structured tool workflow: current Tau\n // evidence has Mini and Sonnet at equal task reward there, while Sonnet costs\n // roughly two orders of magnitude more on the long-tail case.\n airlineComplex: {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n \"deepseek-v4-pro\": 0.74,\n },\n airlineStandard: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.8,\n \"deepseek-v4-pro\": 0.76,\n },\n // Full-trajectory tau2 calibration (2026-07-28, official gpt-4.1 simulator):\n // Sonnet 5 completed both an airline policy task and a retail multi-write\n // task with reward 1.0. Gemini 3.5 Flash emitted function calls as plain text\n // after the first structured calls and looped to the 100-step ceiling on the\n // airline task.\n toolAgent: {\n \"claude-sonnet-5\": 1,\n \"gemini-3.6-flash\": 0.88,\n \"gpt-5.3-codex\": 0.87,\n \"kimi-k3.1-pro\": 0.85,\n \"gpt-5.6-luna\": 0.84,\n \"deepseek-v4-pro\": 0.82,\n },\n // Multi-file Terminal work is not equivalent to a one-turn parallel\n // function-call benchmark. Sonnet is the strongest trajectory-tested\n // cost-controlled default; Opus remains a close safety fallback.\n parallelTerminalSafety: {\n \"claude-sonnet-5\": 1,\n \"claude-opus-4.8\": 0.9,\n \"gpt-5.3-codex\": 0.86,\n },\n parallelTerminal: {\n \"gpt-5.6-luna\": 1,\n \"gpt-5.3-codex\": 0.98,\n \"claude-sonnet-5\": 0.92,\n \"gemini-3.6-flash\": 0.88,\n },\n parallelRetail: {\n \"deepseek-v4-pro\": 1,\n \"claude-sonnet-5\": 0.88,\n \"claude-opus-4.8\": 0.84,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n },\n parallelAirlineComplex: {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.78,\n \"claude-opus-4.8\": 0.76,\n \"gemini-3.6-flash\": 0.74,\n },\n parallelAirline: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.8,\n },\n // RouterBench calibration, 2026-07-26: Opus 4.8 produced complete multi-call\n // payloads on 2/3 multilingual BFCL parallel cases. Gemini 3.5 Flash, Sonnet\n // 5, DeepSeek V4 Pro and Grok 4.5 were 0/3. This narrow prior only applies\n // after the conservative prompt feature in likelyNeedsParallelToolCalls.\n parallel: {\n \"claude-opus-4.8\": 1,\n \"claude-sonnet-5\": 0.84,\n \"grok-4.5\": 0.82,\n \"gemini-3.6-flash\": 0.8,\n \"deepseek-v4-pro\": 0.78,\n },\n codeEdit: {\n \"gpt-5.3-codex\": 1,\n \"claude-sonnet-4.6\": 0.94,\n \"glm-5.2\": 0.9,\n \"deepseek-v4-pro\": 0.86,\n },\n reasoning: {\n \"claude-sonnet-5\": 0.98,\n \"claude-sonnet-4.6\": 0.98,\n \"deepseek-v4-pro\": 0.95,\n \"grok-4.5\": 0.94,\n \"gemini-3.1-pro\": 0.92,\n \"gemini-3.6-flash\": 0.92,\n },\n // RouterBench calibration (2026-07-28, six stratified GPQA Diamond tasks,\n // identical agent adapter and 512-token budget): Gemini 3 Flash Preview\n // scored 5/6, Gemini 3.5 Flash 4/6, and Gemini 3.1 Pro 3/6 while costing\n // ~170x more than Flash. The measured winner is the narrow default; version\n // recency alone is not a quality signal. Unused host tools must not change\n // this reasoning-only model choice.\n reasoningMcq: {\n \"gemini-3-flash-preview\": 1,\n \"gemini-3.6-flash\": 0.91,\n \"grok-4.5\": 0.9,\n \"claude-sonnet-5\": 0.88,\n \"deepseek-v4-pro\": 0.84,\n },\n // Same calibration, five multilingual MGSM tasks: Gemini 3.5 Flash was 5/5\n // with the lowest cost and latency; four current flagships were 4/5 and Kimi\n // K2.7 was 3/5.\n //\n // Kimi K3.1 Pro, paired against Kimi K3 (2026-11-23): all 50 rows of the\n // pinned RouterBench MGSM slice (5 per language x 10 languages), the text\n // adapter's `Answer: ` contract and deterministic grader, 512 output\n // tokens, temperature 0, same rows and settings for both. K3 44/50, K3.1 Pro\n // 41/50; discordant pairs 5 K3-only vs 2 K3.1-only (not significant). Every\n // K3-only win was K3.1 Pro hitting the 512-token cap; the non-truncated\n // errors were the same two rows for both. Rerunning the 10 truncated rows at\n // 2048 tokens gave 8/10 each (46/50 each overall), so the gap is verbosity at\n // the calibration budget, not arithmetic. K3.1 Pro was also slower (p95\n // 10.4s vs 4.7s). It moves from K3's carried 0.9 to 0.88: below the models\n // the 4/5 calibration put at 0.9, by less than the raw 41/44 ratio because\n // the difference is within noise.\n reasoningMath: {\n \"gemini-3.6-flash\": 1,\n \"grok-4.5\": 0.93,\n \"claude-sonnet-5\": 0.9,\n \"deepseek-v4-pro\": 0.9,\n \"kimi-k3.1-pro\": 0.88,\n },\n vision: {\n \"gemini-3.1-pro\": 0.96,\n \"qwen3.7-max\": 0.9,\n \"claude-sonnet-4.6\": 0.9,\n \"kimi-k3.1-pro\": 0.9,\n \"grok-4.3\": 0.9,\n },\n // Long-context eligibility is necessary but not sufficient: a provider can\n // advertise a 1M window yet return an empty completion near that boundary.\n // The proven long-context flagship leads, and less-established alternatives\n // sit in a separate band so price alone cannot displace it.\n longContext: {\n \"gemini-3.1-pro\": 1,\n \"qwen3.7-max\": 0.89,\n \"glm-5.2\": 0.89,\n \"gemini-3.6-flash\": 0.88,\n \"deepseek-v4-pro\": 0.85,\n },\n // A structured extraction must preserve both the output contract and the\n // source-language fields. For Mandarin input the language-native Kimi\n // candidate gets a distinct band — a candidate-pool decision, not a post-hoc\n // override, so it still falls back normally when Kimi is unavailable. The\n // Kimi flagship costs several times the cheap extraction models, so the band\n // must be wider than the auto affinityFloorGap (0.10) or price alone\n // re-selects a non-native model for Mandarin input; 0.12 keeps Kimi alone in\n // the primary band for zh and leaves every other language untouched.\n //\n // Only one \"kimi-k3.1-pro\" value in AFFINITY is measured on K3.1 Pro:\n // reasoningMath (paired K3 vs K3.1 Pro on 50 MGSM rows, 2026-11-23; see that\n // band). Every other value (codeAgent, retailStandard, retailHigh,\n // toolAgent, vision, extractionZh, extraction, chat) is still carried over\n // from the Kimi flagship it replaced (K3, whose values were in turn carried\n // from K2.7). Those bands' calibrations could not be rerun locally: the\n // Terminal-Bench and tau2 trajectories need the RouterBench Franklin host\n // (and Docker for Terminal-Bench), and no extraction or vision slice has a\n // runner. K3.1 Pro's other evidence is the 2026-11-23 live probe: 3/3\n // completions, 0 errors, a well-formed tool call.\n extractionZh: {\n \"kimi-k3.1-pro\": 1,\n \"gemini-3.6-flash\": 0.88,\n \"gemini-3.5-flash-lite\": 0.88,\n \"gpt-4o-mini\": 0.88,\n \"claude-sonnet-5\": 0.88,\n \"claude-sonnet-4.6\": 0.88,\n },\n extraction: {\n \"kimi-k3.1-pro\": 0.9,\n \"gemini-3.6-flash\": 0.9,\n \"gemini-3.5-flash-lite\": 0.9,\n \"gpt-4o-mini\": 0.9,\n \"claude-sonnet-5\": 0.9,\n \"claude-sonnet-4.6\": 0.9,\n },\n chat: {\n \"gemini-3.6-flash\": 0.86,\n \"gemini-3.5-flash-lite\": 0.86,\n \"kimi-k3.1-pro\": 0.86,\n },\n} as const satisfies Record;\n\n/** The affinity band that applies to a classified request. */\nfunction affinityBand(features: TaskFeatures): AffinityBand {\n const { taskType, agentDomain, agentRisk, deepWebResearch, terminalToolSignal } = features;\n const terminalSafety = features.terminalSafetySensitive;\n switch (taskType) {\n case \"code_agent\":\n return terminalToolSignal && agentRisk === \"complex_high\"\n ? TERMINAL_COMPLEX_HIGH\n : AFFINITY.codeAgent;\n case \"tool_agent\":\n if (terminalToolSignal && agentRisk === \"complex_high\") return TERMINAL_COMPLEX_HIGH;\n if (terminalToolSignal) return terminalSafety ? AFFINITY.terminalToolSafety : AFFINITY.terminalTool;\n if (agentDomain === \"web_research\") return deepWebResearch ? WEB_RESEARCH_DEEP : WEB_RESEARCH;\n if (agentDomain === \"retail\") {\n if (agentRisk === \"standard\") return AFFINITY.retailStandard;\n if (agentRisk === \"policy_exception\") return RETAIL_POLICY_EXCEPTION;\n if (agentRisk === \"policy_exception_simple\") return RETAIL_POLICY_EXCEPTION_SIMPLE;\n return AFFINITY.retailHigh;\n }\n if (agentDomain === \"airline\") {\n return agentRisk === \"complex_high\" ? AFFINITY.airlineComplex : AFFINITY.airlineStandard;\n }\n return AFFINITY.toolAgent;\n case \"tool_agent_parallel\":\n if (terminalToolSignal) {\n return terminalSafety ? AFFINITY.parallelTerminalSafety : AFFINITY.parallelTerminal;\n }\n if (agentDomain === \"web_research\") return deepWebResearch ? WEB_RESEARCH_DEEP : WEB_RESEARCH;\n if (agentDomain === \"retail\") {\n if (agentRisk === \"policy_exception\") return RETAIL_POLICY_EXCEPTION;\n if (agentRisk === \"policy_exception_simple\") return RETAIL_POLICY_EXCEPTION_SIMPLE;\n return AFFINITY.parallelRetail;\n }\n if (agentDomain === \"airline\") {\n return agentRisk === \"complex_high\" ? AFFINITY.parallelAirlineComplex : AFFINITY.parallelAirline;\n }\n return AFFINITY.parallel;\n case \"code_edit\":\n case \"debug\":\n return AFFINITY.codeEdit;\n case \"reasoning\":\n return AFFINITY.reasoning;\n case \"reasoning_mcq\":\n return AFFINITY.reasoningMcq;\n case \"reasoning_math\":\n return AFFINITY.reasoningMath;\n case \"vision\":\n return AFFINITY.vision;\n case \"long_context\":\n return AFFINITY.longContext;\n case \"extraction\":\n return features.language === \"zh\" ? AFFINITY.extractionZh : AFFINITY.extraction;\n case \"chat\":\n return AFFINITY.chat;\n }\n}\n\n/** A model's affinity within a band: its calibrated score, never below neutral. */\nfunction affinityIn(band: AffinityBand, modelId: string): number {\n const name = modelId.toLowerCase().slice(modelId.indexOf(\"/\") + 1);\n return Math.max(NEUTRAL_AFFINITY, band[name] ?? 0);\n}\n\nfunction evidenceCandidates(task: TaskType): string[] {\n if (task === \"code_agent\") {\n return [\n \"openai/gpt-5.3-codex\",\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"google/gemini-3.6-flash\",\n \"moonshot/kimi-k3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"tool_agent\") {\n return [\n \"anthropic/claude-sonnet-5\",\n \"anthropic/claude-opus-5\",\n \"openai/gpt-5.6-luna\",\n \"openai/gpt-4.1\",\n \"openai/gpt-4o-mini\",\n \"google/gemini-3.6-flash\",\n \"openai/gpt-5.3-codex\",\n \"moonshot/kimi-k3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"tool_agent_parallel\") {\n return [\n \"anthropic/claude-opus-5\",\n \"anthropic/claude-opus-4.8\",\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"openai/gpt-4.1\",\n \"openai/gpt-4o-mini\",\n \"xai/grok-4.5\",\n \"google/gemini-3.6-flash\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"long_context\") {\n return [\n \"google/gemini-3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n \"qwen/qwen3.7-max\",\n \"zai/glm-5.2\",\n \"google/gemini-3.6-flash\",\n ];\n }\n if (task === \"reasoning_mcq\") {\n return [\n \"google/gemini-3-flash-preview\",\n \"google/gemini-3.6-flash\",\n \"xai/grok-4.5\",\n \"anthropic/claude-sonnet-5\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"extraction\") {\n // The Kimi flagship is not on the auto MEDIUM chain (K2.7 was); the\n // language-native extraction band (AFFINITY.extractionZh) needs it in the pool.\n return [\"moonshot/kimi-k3.1-pro\", \"google/gemini-3.6-flash\", \"anthropic/claude-sonnet-5\"];\n }\n if (task === \"reasoning_math\") {\n return [\n \"google/gemini-3.6-flash\",\n \"xai/grok-4.5\",\n \"anthropic/claude-sonnet-5\",\n \"deepseek/deepseek-v4-pro\",\n \"moonshot/kimi-k3.1-pro\",\n ];\n }\n return [];\n}\n\n/**\n * Recently added catalog models with a verified structured function call.\n *\n * Tool compliance is enough to make these models safe availability fallbacks,\n * but it is not evidence that they should displace a trajectory-benchmarked\n * primary. Keep them after the configured and benchmark-backed chains until a\n * full agent evaluation earns a task-specific affinity above NEUTRAL_AFFINITY\n * floor. `isEligible` still applies every host capability override, context\n * limit, vision constraint, and unavailable-model guard before they are used.\n */\nconst VERIFIED_TOOL_FALLBACKS = [\n \"anthropic/claude-fable-5.1\",\n \"anthropic/claude-opus-5.5\",\n \"anthropic/claude-sonnet-5.5\",\n \"deepseek/deepseek-v4.1-flash\",\n \"google/gemini-3.8-flash\",\n \"google/gemini-4-carbon\",\n \"openai/gpt-5.1\",\n \"openai/gpt-6-astra\",\n \"openai/gpt-6-luna\",\n \"openai/gpt-6-sol\",\n \"openai/gpt-6.1-sol\",\n \"xai/grok-4.6\",\n \"xai/grok-4.7\",\n \"xiaomi/mimo-v2.5\",\n] as const;\n\nfunction isEligible(\n modelId: string,\n features: TaskFeatures,\n maxOutputTokens: number,\n options: RouterOptions,\n): boolean {\n const model = options.modelCapabilities?.[modelId] ?? DEFAULT_MODEL_CAPABILITIES[modelId];\n // Preserve compatibility for temporarily catalog-less fallback IDs. They are\n // kept behind known-model candidates but are not silently dropped.\n if (!model) return true;\n if (features.needsTools && !model.supportsTools) return false;\n if (features.needsVision && !model.supportsVision) return false;\n if (features.needsStructuredOutput && !model.supportsTools) return false;\n if (model.maxOutputTokens < maxOutputTokens) return false;\n return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;\n}\n\nfunction estimatedCost(\n modelId: string,\n options: RouterOptions,\n inputTokens: number,\n outputTokens: number,\n): number {\n const price = usablePricing(options.modelPricing.get(modelId));\n if (!price) return Number.POSITIVE_INFINITY;\n if (price.flatPrice !== undefined) return price.flatPrice;\n return (inputTokens * price.inputPrice + outputTokens * price.outputPrice) / 1_000_000;\n}\n\nfunction profileScore(\n modelId: string,\n options: RouterOptions,\n now: Date,\n):\n | { quality?: number; speed: number; tailSpeed: number; reliability: number; freshness: number }\n | undefined {\n const profile: ModelPerformanceProfile | undefined =\n options.modelPerformance?.[modelId] ??\n LIVE_MODEL_PROFILES[modelId] ??\n HISTORICAL_MODEL_PROFILES[modelId];\n if (!profile) return undefined;\n const measuredAt = Date.parse(profile.measuredAt);\n if (!Number.isFinite(measuredAt)) return undefined;\n // A host-injected observation with a missing or non-numeric field would\n // turn the whole score into NaN, and NaN compares as \"equal\" in the sort,\n // freezing that candidate wherever it landed. Treat it as no observation.\n const finite = (value: number | undefined, optional: boolean) =>\n value === undefined ? optional : Number.isFinite(value) && value >= 0;\n if (\n !finite(profile.latencyMs, false) ||\n !finite(profile.outputTokensPerSecond, false) ||\n !finite(profile.p95LatencyMs, true) ||\n !finite(profile.intelligenceIndex, true) ||\n !finite(profile.errorRate, true) ||\n !finite(profile.samples, true)\n ) {\n return undefined;\n }\n const ageDays = Math.max(0, (now.getTime() - measuredAt) / 86_400_000);\n // A 30-day half-life makes old data a tie-breaker only. Small probe runs are\n // also weak evidence: three quick samples should not overturn a curated\n // tier ordering merely because of a transient provider tail. Callers that\n // inject an observation without a sample count retain the legacy full\n // confidence behaviour for compatibility.\n const sampleConfidence =\n profile.samples === undefined ? 1 : Math.min(1, Math.max(0, profile.samples) / 10);\n const freshness = Math.pow(0.5, ageDays / 30) * sampleConfidence;\n const quality =\n profile.intelligenceIndex === undefined\n ? undefined\n : Math.min(1, profile.intelligenceIndex / 50);\n const speed = Math.min(\n 1,\n (2_000 / Math.max(500, profile.latencyMs) + profile.outputTokensPerSecond / 250) / 2,\n );\n const tailSpeed = Math.min(1, 3_000 / Math.max(750, profile.p95LatencyMs ?? profile.latencyMs));\n const reliability = Math.max(0, 1 - (profile.errorRate ?? 0));\n return { quality, speed, tailSpeed, reliability, freshness };\n}\n\n/** Candidate router used for Auto. Rules still set the capability tier; V3 ranks within it. */\nexport class PortfolioStrategy implements RouterStrategy {\n readonly name = \"portfolio\";\n // Rules set the capability tier; the strategy is stateless, so one instance serves every request.\n private readonly rules = new RulesStrategy();\n\n route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n ) {\n const features = classifyTask(prompt, systemPrompt, options);\n const base = this.rules.route(prompt, systemPrompt, maxOutputTokens, {\n ...options,\n requiresTools: features.needsTools,\n });\n const tierConfigs = base.tierConfigs;\n if (!tierConfigs) return base;\n // The rules score sets the capability tier, but two task types carry a\n // floor of their own: a compact reasoning problem belongs on the\n // reasoning chain however short it is, and a code edit or stack trace\n // belongs at least on the MEDIUM chain — the SIMPLE chain is curated for\n // trivia and translation and has no model with code affinity. The code\n // floor requires a code artifact or coding action: `debug` and `code_edit`\n // are also assigned from bare verbs (\"rewrite this sentence\", \"margin of\n // error\") and bare language names (\"What is Python?\"), and that prose\n // must stay on the cheap chain.\n const targetTier: Tier =\n (features.taskType === \"reasoning_mcq\" || features.taskType === \"reasoning_math\") &&\n (base.tier === \"SIMPLE\" || base.tier === \"MEDIUM\")\n ? \"REASONING\"\n : (features.taskType === \"debug\" || features.taskType === \"code_edit\") &&\n features.codeArtifact &&\n base.tier === \"SIMPLE\"\n ? \"MEDIUM\"\n : base.tier;\n const tierConfig = tierConfigs[targetTier];\n const configuredCandidates = tierConfig ? getFallbackChain(targetTier, tierConfigs) : [];\n // Evidence candidates join the configured chain, but the host's\n // unavailable set applies to both: the configured side arrives filtered\n // through RulesStrategy, and a dead evidence model must not re-enter here.\n const unavailable = new Set(options.unavailableModels ?? []);\n // `modelPricing` is the host's live catalog view. Do not introduce a\n // built-in fallback that the current gateway does not advertise. These\n // models carry no task evidence, so outside Premium the cheapest one is\n // the first recovery hop; otherwise an outage of the curated chain would\n // jump an Eco turn straight to the most expensive model in the list.\n const verifiedToolFallbacks = features.needsTools\n ? VERIFIED_TOOL_FALLBACKS.filter((model) => options.modelPricing.has(model))\n : [];\n if (options.routingProfile !== \"premium\") {\n const fallbackCost = (model: string) =>\n estimatedCost(model, options, features.estimatedInputTokens, maxOutputTokens);\n verifiedToolFallbacks.sort((a, b) => fallbackCost(a) - fallbackCost(b));\n }\n const chain = [\n ...new Set([\n ...configuredCandidates,\n ...evidenceCandidates(features.taskType),\n ...verifiedToolFallbacks,\n ]),\n ].filter(\n (model): model is string =>\n typeof model === \"string\" && model.length > 0 && !unavailable.has(model),\n );\n const eligible = new Set(\n chain.filter((model) => isEligible(model, features, maxOutputTokens, options)),\n );\n // When nothing is eligible the whole chain competes, scored as incapable.\n const eligibleCandidates = eligible.size > 0 ? [...eligible] : chain;\n if (eligibleCandidates.length === 0) return base;\n const profileName =\n options.routingProfile === \"eco\"\n ? \"eco\"\n : options.routingProfile === \"premium\"\n ? \"premium\"\n : \"auto\";\n const portfolio = options.config.portfolio ?? DEFAULT_PORTFOLIO_WEIGHTS;\n const band = affinityBand(features);\n const affinityCache = new Map();\n const getAffinity = (model: string) => {\n let value = affinityCache.get(model);\n if (value === undefined) {\n value = affinityIn(band, model);\n affinityCache.set(model, value);\n }\n return value;\n };\n const bestAffinity = Math.max(...eligibleCandidates.map(getAffinity));\n const specificAffinity = eligibleCandidates.filter((model) => getAffinity(model) > NEUTRAL_AFFINITY);\n // A tier's fallback list is primarily an availability/recovery chain, not a\n // set of equally validated substitutes. Re-ranking every fallback lets a\n // cheap generic model displace the curated primary merely because it has a\n // favourable short performance probe. Only promote models with explicit\n // task affinity; otherwise retain the first capability-eligible tier model.\n const affinityPool = specificAffinity.length > 0 ? specificAffinity : [eligibleCandidates[0]];\n // Generic Terminal work has much wider trajectory variance than a BFCL-like\n // one-turn parallel call. Keep the strong-model safety band, but admit the\n // next capable tier so Auto's cost/reliability score can reject an Opus\n // primary that is materially more expensive without measured benefit.\n const affinityFloorGap = features.terminalToolSignal\n ? Math.max(\n portfolio.affinityFloorGap[profileName],\n features.terminalSafetySensitive ? 0.15 : 0.12,\n )\n : portfolio.affinityFloorGap[profileName];\n const candidates = affinityPool.filter(\n (model) => getAffinity(model) >= bestAffinity - affinityFloorGap,\n );\n const costs = candidates.map((model) =>\n estimatedCost(model, options, features.estimatedInputTokens, maxOutputTokens),\n );\n const finiteCosts = costs.filter(Number.isFinite);\n const minCost = finiteCosts.length > 0 ? Math.min(...finiteCosts) : 0;\n const maxCost = finiteCosts.length > 0 ? Math.max(...finiteCosts) : 1;\n\n const now = options.now ?? new Date();\n const profileWeights = portfolio[profileName];\n const rankedEntries = candidates\n .map((model, index) => {\n const cost = costs[index];\n // An unpriced candidate costs an unknown amount, so it scores as the\n // most expensive rather than a neutral 0.5 that let it outrank\n // priced models. Pricing presence still never filters a candidate.\n const costScore = !Number.isFinite(cost)\n ? 0\n : maxCost > minCost\n ? 1 - (cost - minCost) / (maxCost - minCost)\n : 0.5;\n const capabilityScore = eligible.has(model) ? 1 : 0;\n const profile = profileScore(model, options, now);\n // Fresh observations can refine affinity. Historical observations fade\n // quickly and never replace task-level RouterBench evidence.\n const observedQuality =\n profile?.quality === undefined\n ? getAffinity(model)\n : getAffinity(model) * (1 - profile.freshness) + profile.quality * profile.freshness;\n // Every observed dimension fades toward its neutral prior as the\n // observation ages, exactly like reliability below. Fading speed\n // toward zero instead ranked any model with a stale probe below a\n // model nobody had measured, which the latter's 0.5 silently won.\n const observedSpeed = profile\n ? profile.speed * profile.freshness + 0.5 * (1 - profile.freshness)\n : 0.5;\n const observedTailSpeed = profile\n ? profile.tailSpeed * profile.freshness + 0.5 * (1 - profile.freshness)\n : 0.5;\n const observedReliability = profile\n ? profile.reliability * profile.freshness + (1 - profile.freshness)\n : 1;\n // Preserve a small amount of the hand-curated fallback order while V3's\n // task affinity and real request constraints do the primary work.\n const legacyScore = 1 - index / Math.max(1, candidates.length - 1);\n const qualityWeight =\n profileWeights.quality + (features.highStakes ? portfolio.highStakesBoost.quality : 0);\n const speedScore = features.latencySensitive ? observedTailSpeed : observedSpeed;\n const speedWeight =\n profileWeights.speed +\n (features.latencySensitive ? portfolio.latencySensitiveSpeedBoost : 0);\n const reliabilityWeight =\n profileWeights.reliability +\n (features.highStakes ? portfolio.highStakesBoost.reliability : 0);\n const score =\n observedQuality * qualityWeight +\n capabilityScore * profileWeights.capability +\n costScore * profileWeights.cost +\n speedScore * speedWeight +\n observedReliability * reliabilityWeight +\n legacyScore * profileWeights.legacy;\n return {\n model,\n score,\n quality: observedQuality,\n cost: costScore,\n speed: speedScore,\n reliability: observedReliability,\n };\n })\n .sort((a, b) => b.score - a.score);\n const scoredModels = rankedEntries.map((item) => item.model);\n // The affinity floor controls which models may compete for the primary;\n // it must not erase availability fallbacks. Append all remaining eligible\n // models in their curated chain order after the scored primary pool.\n const webResearchFallbackOrder = [\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"google/gemini-3.6-flash\",\n \"anthropic/claude-opus-5\",\n \"anthropic/claude-opus-4.8\",\n \"openai/gpt-5.3-codex\",\n ];\n const ranked =\n features.agentDomain === \"web_research\"\n ? [\n ...scoredModels,\n ...webResearchFallbackOrder.filter(\n (model) => eligibleCandidates.includes(model) && !scoredModels.includes(model),\n ),\n ...eligibleCandidates.filter(\n (model) => !scoredModels.includes(model) && !webResearchFallbackOrder.includes(model),\n ),\n ]\n : [...scoredModels, ...eligibleCandidates.filter((model) => !scoredModels.includes(model))];\n\n const model = ranked[0] ?? base.model;\n const selectedTierConfigs: Record = {\n ...tierConfigs,\n [targetTier]: { primary: model, fallback: ranked.slice(1) },\n };\n // selectModel only reads the selected tier; retain the complete tier map for host fallback.\n const decision = selectModel(\n targetTier,\n base.confidence,\n \"portfolio\",\n `${base.reasoning} | v3 task=${features.taskType} agentRisk=${features.agentRisk} deepWebResearch=${features.deepWebResearch} terminalCode=${features.implicitTerminalCode} terminalSafety=${features.terminalSafetySensitive} candidates=${ranked.length}`,\n selectedTierConfigs,\n options.modelPricing,\n features.estimatedInputTokens,\n maxOutputTokens,\n options.routingProfile,\n base.agenticScore,\n );\n return {\n ...decision,\n tierConfigs: selectedTierConfigs,\n profile: base.profile,\n candidates: ranked,\n candidateScores: rankedEntries.map(({ model, score, quality, cost, speed, reliability }) => ({\n model,\n score,\n quality,\n cost,\n speed,\n reliability,\n })),\n taskType: features.taskType,\n routerVersion: \"v3-portfolio\" as const,\n };\n }\n}\n","/** Pure public-catalog parsing. Fetching, caching and UI ordering belong to hosts. */\nimport { DEFAULT_MODEL_CAPABILITIES, type ModelCapabilities } from \"./model-capabilities.js\";\nimport type { ModelPricing } from \"./selector.js\";\n\nexport const MODEL_KINDS = [\"chat\", \"image\", \"video\", \"music\"] as const;\nexport type ModelKind = (typeof MODEL_KINDS)[number];\n\n/** Gateway units are preserved: token prices per 1M tokens; media per unit. */\nexport interface CatalogPricing {\n input?: number;\n output?: number;\n per_image?: number;\n per_second?: number;\n per_track?: number;\n cache_read?: number;\n cache_write?: number;\n transaction_fee?: number;\n per_call_surcharge?: number;\n default_duration_seconds?: number;\n max_duration_seconds?: number;\n}\n\nexport interface CatalogModel {\n id: string;\n name: string;\n categories: readonly string[];\n kinds: readonly ModelKind[];\n billingMode?: string;\n /** Zero pricing alone does not imply a free model. */\n free: boolean;\n pricing: CatalogPricing;\n contextWindow?: number;\n maxOutputTokens?: number;\n}\n\nexport interface ModelCatalog {\n models: readonly CatalogModel[];\n chat: readonly CatalogModel[];\n image: readonly CatalogModel[];\n video: readonly CatalogModel[];\n music: readonly CatalogModel[];\n /**\n * IDs whose authoritative row says `available: false`. The gateway does not\n * reject these; it substitutes another model. Absence from the listing is\n * not unavailability: hidden IDs are still served.\n */\n unavailable: readonly string[];\n}\n\nconst PRICE_KEYS = [\n \"input\", \"output\", \"per_image\", \"per_second\", \"per_track\", \"cache_read\", \"cache_write\",\n \"transaction_fee\", \"per_call_surcharge\", \"default_duration_seconds\", \"max_duration_seconds\",\n] as const;\nconst UNIT_PRICE = { image: \"per_image\", video: \"per_second\", music: \"per_track\" } as const;\nconst MODEL_ID = /^[a-z0-9][a-z0-9._-]*\\/[a-zA-Z0-9][a-zA-Z0-9._:+-]*$/;\nconst record = (value: unknown): value is Record =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst price = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value) && value >= 0;\nconst capacity = (value: unknown): number | undefined =>\n typeof value === \"number\" && Number.isSafeInteger(value) && value > 0 ? value : undefined;\n\n/**\n * Normalize GET /api/v1/models without a model-ID allowlist. New provider IDs\n * appear immediately. Hidden/unavailable rows and invalid per-kind prices are\n * omitted. A malformed envelope throws so a host can retain its last good list;\n * an explicitly empty `data` array is a valid empty catalog.\n *\n * IDs explicitly marked `available: false` are also listed in `unavailable`.\n * Rows outside MODEL_KINDS (speech, sound effects) are omitted.\n *\n * Last duplicate wins, including a final unavailable/invalid row. No sorting,\n * price markup, network request, capability probe or media routing is performed.\n */\nexport function parseModelCatalog(value: unknown): ModelCatalog {\n if (!record(value) || !Array.isArray(value.data)) {\n throw new TypeError(\"Model catalog must contain a data array\");\n }\n const entries = new Map>();\n for (const entry of value.data) {\n if (record(entry) && typeof entry.id === \"string\" && entry.id.length <= 200 && MODEL_ID.test(entry.id)) {\n entries.set(entry.id, entry);\n }\n }\n const result: ModelCatalog = { models: [], chat: [], image: [], video: [], music: [], unavailable: [] };\n const models: CatalogModel[] = [];\n const unavailable: string[] = [];\n for (const [id, entry] of entries) {\n if (entry.available === false) unavailable.push(id);\n if ((entry.available !== undefined && entry.available !== true) ||\n (entry.hidden !== undefined && entry.hidden !== false) ||\n !Array.isArray(entry.categories) || !record(entry.pricing)) continue;\n const categories = [...new Set(entry.categories.filter((c): c is string => typeof c === \"string\"))];\n const rawPricing = entry.pricing;\n const pricing: CatalogPricing = {};\n for (const key of PRICE_KEYS) if (price(rawPricing[key])) pricing[key] = rawPricing[key];\n const kinds = MODEL_KINDS.filter(kind => categories.includes(kind) && (kind === \"chat\"\n ? price(rawPricing.input) && price(rawPricing.output)\n : price(rawPricing[UNIT_PRICE[kind]])));\n if (!kinds.length) continue;\n const model: CatalogModel = {\n id, name: typeof entry.name === \"string\" && entry.name.trim() ? entry.name : id,\n categories, kinds, pricing,\n free: kinds.includes(\"chat\") && entry.billing_mode === \"free\" && pricing.input === 0 && pricing.output === 0,\n ...(typeof entry.billing_mode === \"string\" ? { billingMode: entry.billing_mode } : {}),\n ...(capacity(entry.context_window) !== undefined ? { contextWindow: capacity(entry.context_window) } : {}),\n ...(capacity(entry.max_output) !== undefined ? { maxOutputTokens: capacity(entry.max_output) } : {}),\n };\n models.push(model);\n }\n result.models = models;\n result.unavailable = unavailable;\n for (const kind of MODEL_KINDS) result[kind] = models.filter(model => model.kinds.includes(kind));\n return result;\n}\n\nexport interface CatalogRoutingOptions {\n /** Host evidence, merged over (and overriding per ID) the bundled verified table. */\n verifiedCapabilities?: Readonly>;\n}\n\nexport interface RoutingCatalog {\n modelPricing: Map;\n modelCapabilities: Record;\n unavailableModels: string[];\n}\n\n/**\n * Adapt only the chat catalog for route(). Media never enters LLM candidate\n * chains. Tool support comes from verified evidence, never a name or category.\n * Unknown capacities are zero, rather than invented defaults.\n *\n * Only rows the gateway explicitly marks `available: false` become\n * unavailableModels. Configured IDs that are merely absent from the listing\n * stay routable: the gateway serves hidden IDs, and only the configured chain\n * knows about them.\n */\nexport function toRoutingCatalog(catalog: ModelCatalog, options: CatalogRoutingOptions = {}): RoutingCatalog {\n const verified = { ...DEFAULT_MODEL_CAPABILITIES, ...options.verifiedCapabilities };\n const modelPricing = new Map();\n const modelCapabilities: Record = {};\n for (const model of catalog.chat) {\n modelPricing.set(model.id, { inputPrice: model.pricing.input!, outputPrice: model.pricing.output! });\n const evidence = verified[model.id];\n modelCapabilities[model.id] = {\n contextWindow: model.contextWindow ?? evidence?.contextWindow ?? 0,\n maxOutputTokens: model.maxOutputTokens ?? evidence?.maxOutputTokens ?? 0,\n supportsTools: evidence?.supportsTools === true,\n // Verified evidence wins over the category tag in both directions: the\n // catalog omits \"vision\" for some models that accept images and tags\n // others whose image input does not hold up (see capability-overrides).\n supportsVision: evidence?.supportsVision ?? model.categories.includes(\"vision\"),\n };\n }\n return { modelPricing, modelCapabilities, unavailableModels: [...catalog.unavailable] };\n}\n","/**\n * Smart Router Entry Point\n *\n * Classifies requests and routes to the cheapest capable model.\n * Delegates to pluggable RouterStrategy (default: RulesStrategy, <1ms).\n */\n\nimport type { RoutingDecision, RouterOptions } from \"./types.js\";\nimport { getStrategy, registerStrategy } from \"./strategy.js\";\nimport { PortfolioStrategy } from \"./portfolio.js\";\n\n// Register here instead of strategy.ts so PortfolioStrategy can reuse the\n// stable RulesStrategy without introducing a module cycle.\nregisterStrategy(new PortfolioStrategy());\n\n/**\n * Route a request to the cheapest capable model.\n * Delegates to the configured strategy (PortfolioStrategy by default).\n */\nexport function route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n): RoutingDecision {\n const strategy = getStrategy(options.config.strategy ?? \"portfolio\");\n return strategy.route(prompt, systemPrompt, maxOutputTokens, options);\n}\n\nexport { getStrategy, registerStrategy, applyUnavailableModels } from \"./strategy.js\";\nexport { RulesStrategy } from \"./strategy.js\";\nexport { PortfolioStrategy } from \"./portfolio.js\";\nexport { classifyByRules } from \"./rules.js\";\nexport { inferToolRequirement } from \"./tool-intent.js\";\nexport { estimateTokens } from \"./tokens.js\";\nexport { MODEL_KINDS, parseModelCatalog, toRoutingCatalog } from \"./catalog.js\";\nexport type {\n ModelKind, CatalogPricing, CatalogModel, ModelCatalog, CatalogRoutingOptions, RoutingCatalog,\n} from \"./catalog.js\";\nexport {\n getFallbackChain,\n getFallbackChainFiltered,\n filterByToolCalling,\n filterByVision,\n filterByExcludeList,\n filterCandidatesByCapacity,\n calculateModelCost,\n} from \"./selector.js\";\nexport { DEFAULT_ROUTING_CONFIG } from \"./config.js\";\nexport { DEFAULT_MODEL_CAPABILITIES } from \"./model-capabilities.js\";\nexport { LIVE_MODEL_PROFILES, HISTORICAL_MODEL_PROFILES } from \"./model-profiles.js\";\nexport type {\n RoutingDecision,\n Tier,\n TaskType,\n RoutingConfig,\n RouterOptions,\n RouterStrategy,\n} from \"./types.js\";\nexport type { ModelPricing } from \"./selector.js\";\nexport type { ModelCapabilities } from \"./model-capabilities.js\";\nexport type { ModelPerformanceProfile } from \"./model-profiles.js\";\n"],"mappings":";AAiCA,IAAM,qBACJ;AACF,IAAM,YAAY;AAClB,IAAM,eAAe;AAIrB,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB,QAAQ,mBAAmB;AACnD,IAAM,iBAAiB,OAAO,mBAAmB;AACjD,IAAM,2BAA2B;AACjC,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AACxB,IAAM,eACJ;AACF,IAAM,qBAAqB;AAC3B,IAAM,6BAA6B;AAQnC,IAAM,eAAe,oBAAI,IAA4B;AAErD,SAAS,aAAa,OAAuB;AAC3C,SAAO,MAAM,QAAQ,uBAAuB,MAAM;AACpD;AAEA,SAAS,eAAe,SAAiC;AACvD,QAAM,SAAS,aAAa,IAAI,OAAO;AACvC,MAAI,OAAQ,QAAO;AAEnB,QAAM,KAAK,QAAQ,YAAY;AAC/B,MAAI;AACJ,MAAI,mBAAmB,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG;AAClD,cAAU,EAAE,QAAQ,IAAI,SAAS,KAAK;AAAA,EACxC,OAAO;AACL,UAAM,OAAO,UAAU,KAAK,GAAG,CAAC,CAAC,IAAI,kBAAkB;AACvD,UAAM,UAAU,aAAa,EAAE;AAC/B,QAAI,OAAO;AACX,QAAI,QAAQ;AACZ,QAAI,SAAS;AACb,UAAM,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;AACjD,QACE,UAAU,KA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,SACiB;AACjB,QAAM,WAAW,YAAY,QAAQ,OAAO,YAAY,WAAW;AACnE,SAAO,SAAS,MAAM,QAAQ,cAAc,iBAAiB,OAAO;AACtE;","names":["confidence","decision","price","model"]} \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 6e7e1e6..1a3ae04 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1112,6 +1112,19 @@ export const DEFAULT_ROUTING_CONFIG: RoutingConfig = { // redirected model that would drop the image. // - google/gemini-2.5-pro -> google/gemini-3.8-flash ($0.75/$3.75), in // place. + // + // Retirements 2026-12-11 (OpenAI shuts down o3, gpt-5-mini and gpt-5-nano — + // developers.openai.com/api/docs/deprecations, notice 2026-06-11; the + // gateways redirect each and quote the successor): + // - openai/o3 -> openai/gpt-5.4-mini ($2/$8 -> $0.75/$4.50). Both o3 rungs + // (auto and premium REASONING) sat directly behind gpt-5.4-mini, so they + // are dropped by the dedupe rule; the order actually served is unchanged. + // - openai/gpt-5-mini -> openai/gpt-5.6-luna ($0.25/$2 -> $0.20/$1.20), in + // place as the agentic MEDIUM primary. Luna inherits gpt-5-mini's + // affinity values, CARRIED, not measured (portfolio.ts) — gpt-5-mini is a + // reasoning model and luna runs without reasoning, so those values are a + // placeholder until a Terminal-Bench/tau2 run on luna. + // - openai/gpt-5-nano -> openai/gpt-6-luna. In no chain. // Auto (balanced) tier configs - current default smart routing tiers: { @@ -1176,8 +1189,7 @@ export const DEFAULT_ROUTING_CONFIG: RoutingConfig = { "xai/grok-4.3", // $1.50/$4, 1M ctx — xAI reasoning model, vision "qwen/qwen3.7-plus", // $0.32/$1.28, 1M ctx — reasoning; needs a generous max_tokens (thinking is billed) "google/gemini-3.6-flash", // $0.75/$3.75 — 3.5 Flash's successor (MGSM 5/5 on 3.5, carried) - "openai/gpt-5.4-mini", // $0.75/$4.50 — o4-mini's successor (o4-mini retired 2026-11-24) - "openai/o3", // $2/$8 + "openai/gpt-5.4-mini", // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung) ], }, }, @@ -1306,8 +1318,7 @@ export const DEFAULT_ROUTING_CONFIG: RoutingConfig = { "xai/grok-4.5", // reasoning band 0.94 "deepseek/deepseek-v4-pro", // reasoning band 0.95 "xai/grok-4.3", // $1.50/$4 — xAI reasoning model - "openai/gpt-5.4-mini", // $0.75/$4.50 — o4-mini's successor (o4-mini retired 2026-11-24) - "openai/o3", // $2/$8 + "openai/gpt-5.4-mini", // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung) ], }, }, @@ -1324,9 +1335,11 @@ export const DEFAULT_ROUTING_CONFIG: RoutingConfig = { ], }, MEDIUM: { - // Was moonshot/kimi-k2.7 (hidden 2026-08). GPT-5 Mini carries the - // Terminal-Bench and tau2 trajectory evidence in portfolio.ts. - primary: "openai/gpt-5-mini", // $0.25/$2 — 4/7 Terminal-Bench, 5/6 tau2 airline + // Was moonshot/kimi-k2.7 (hidden 2026-08), then GPT-5 Mini — which + // carries the Terminal-Bench and tau2 trajectory evidence in + // portfolio.ts — until its 2026-12-11 retirement. GPT-5.6 Luna is what + // the gateways serve under that name from then on. + primary: "openai/gpt-5.6-luna", // $0.20/$1.20, 1M ctx, vision + tools — gpt-5-mini's affinity (4/7 Terminal-Bench, 5/6 tau2 airline), carried fallback: [ "google/gemini-3.6-flash", // $0.75/$3.75 — tool_agent band 0.88 (3.5's, carried) "zai/glm-5.3-flash", // $0.15/$0.50 — tools verified diff --git a/src/decisions.snapshot.json b/src/decisions.snapshot.json index 085db90..83e14c5 100644 --- a/src/decisions.snapshot.json +++ b/src/decisions.snapshot.json @@ -41,7 +41,7 @@ "tier": "SIMPLE", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (1 tokens) | agentic (tools) | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=27", + "reasoning": "score=-0.08 | short (1 tokens) | agentic (tools) | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=26", "costEstimate": 0.0032001, "baselineCost": 0.032005, "savings": 0.9000124980471801, @@ -54,7 +54,6 @@ "anthropic/claude-haiku-4.5", "google/gemini-3.5-flash-lite", "anthropic/claude-opus-5", - "openai/gpt-5-mini", "openai/gpt-4.1", "google/gemini-3.6-flash", "openai/gpt-5.3-codex", @@ -161,7 +160,7 @@ "tier": "REASONING", "confidence": 0.973403006423134, "method": "portfolio", - "reasoning": "score=0.10 | short (16 tokens), reasoning (prove, step by step) | v3 task=reasoning agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=7", + "reasoning": "score=0.10 | short (16 tokens), reasoning (prove, step by step) | v3 task=reasoning agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=6", "costEstimate": 0.0012016, "baselineCost": 0.00648, "savings": 0.8145679012345679, @@ -172,8 +171,7 @@ "deepseek/deepseek-reasoner", "xai/grok-4.3", "qwen/qwen3.7-plus", - "openai/gpt-5.4-mini", - "openai/o3" + "openai/gpt-5.4-mini" ], "candidateScores": [ { @@ -240,7 +238,7 @@ "tier": "SIMPLE", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (20 tokens) | agentic (tools) | v3 task=tool_agent_parallel agentRisk=high deepWebResearch=false terminalCode=false terminalSafety=false candidates=27", + "reasoning": "score=-0.08 | short (20 tokens) | agentic (tools) | v3 task=tool_agent_parallel agentRisk=high deepWebResearch=false terminalCode=false terminalSafety=false candidates=26", "costEstimate": 0.020291200000000002, "baselineCost": 0.0577, "savings": 0.6483327556325823, @@ -254,7 +252,6 @@ "google/gemini-3.5-flash-lite", "anthropic/claude-opus-5", "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", "openai/gpt-4.1", "xai/grok-4.5", "google/gemini-3.6-flash", @@ -451,7 +448,7 @@ "agenticScore": 0, "candidates": [ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "zai/glm-5.3-flash", "openai/gpt-5.6-terra", @@ -527,7 +524,7 @@ "tier": "REASONING", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (13 tokens) | upgraded to MEDIUM (structured output) | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=10", + "reasoning": "score=-0.08 | short (13 tokens) | upgraded to MEDIUM (structured output) | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=9", "costEstimate": 0.0005406000000000001, "baselineCost": 0.032065, "savings": 0.9831404958677685, @@ -541,7 +538,6 @@ "xai/grok-4.3", "qwen/qwen3.7-plus", "openai/gpt-5.4-mini", - "openai/o3", "moonshot/kimi-k3.1-pro" ], "candidateScores": [ @@ -693,7 +689,7 @@ "agenticScore": 0.2, "candidates": [ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "zai/glm-5.3-flash", "openai/gpt-5.6-terra", @@ -835,7 +831,7 @@ "tier": "REASONING", "confidence": 0.5, "method": "portfolio", - "reasoning": "score=-0.07 | short (33 tokens), constraints (budget, budget) | ambiguous -> default: MEDIUM | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=10", + "reasoning": "score=-0.07 | short (33 tokens), constraints (budget, budget) | ambiguous -> default: MEDIUM | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=9", "costEstimate": 0.0014038, "baselineCost": 0.083365, "savings": 0.9831607988964194, @@ -849,7 +845,6 @@ "xai/grok-4.3", "qwen/qwen3.7-plus", "openai/gpt-5.4-mini", - "openai/o3", "moonshot/kimi-k3.1-pro" ], "candidateScores": [ @@ -940,7 +935,7 @@ "agenticScore": 0, "candidates": [ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "zai/glm-5.3-flash", "openai/gpt-5.6-terra", @@ -1021,7 +1016,7 @@ "tier": "SIMPLE", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (1 tokens) | eco | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=28", + "reasoning": "score=-0.08 | short (1 tokens) | eco | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=27", "costEstimate": 0.0005163000000000001, "baselineCost": 0.032005, "savings": 0.9838681456022498, @@ -1029,13 +1024,12 @@ "candidates": [ "moonshot/kimi-k3.1-pro", "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", "openai/gpt-5.3-codex", "deepseek/deepseek-v4-pro", "google/gemini-3.6-flash", + "openai/gpt-5.6-luna", "google/gemini-2.5-flash-lite", "zai/glm-5.3-flash", - "openai/gpt-5.6-luna", "openai/gpt-5.4-nano", "google/gemini-3.1-flash-lite", "anthropic/claude-opus-5", @@ -1067,43 +1061,43 @@ }, { "model": "anthropic/claude-sonnet-5", - "score": 0.8516631963299768, + "score": 0.8476874744447462, "quality": 1, - "cost": 0.6670718999652657, + "cost": 0.6671586075180138, "speed": 0.44883064339702206, "reliability": 1 }, - { - "model": "openai/gpt-5-mini", - "score": 0.7934838797356724, - "quality": 0.84, - "cost": 0.6668113928447379, - "speed": 0.48376689739145695, - "reliability": 1 - }, { "model": "openai/gpt-5.3-codex", - "score": 0.7789025193766431, + "score": 0.7789268101560526, "quality": 0.87, - "cost": 0.6668982285515804, + "cost": 0.6669849813351855, "speed": 0.3897141538220059, "reliability": 0.79999 }, { "model": "deepseek/deepseek-v4-pro", - "score": 0.6705209415567347, + "score": 0.6705695484448334, "quality": 0.82, - "cost": 0.33344911427579016, + "cost": 0.333622710304714, "speed": 0.41955189559513506, "reliability": 1 }, { "model": "google/gemini-3.6-flash", - "score": 0.6173763474654378, + "score": 0.6174492704622258, "quality": 0.88, - "cost": 0, + "cost": 0.0002604392742426853, "speed": 0.48576347465437786, "reliability": 1 + }, + { + "model": "openai/gpt-5.6-luna", + "score": 0.6076226216670789, + "quality": 0.84, + "cost": 0, + "speed": 0.452226216670789, + "reliability": 1 } ], "taskType": "tool_agent", @@ -1245,7 +1239,7 @@ "tier": "SIMPLE", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (20 tokens) | eco | v3 task=tool_agent_parallel agentRisk=high deepWebResearch=false terminalCode=false terminalSafety=false candidates=28", + "reasoning": "score=-0.08 | short (20 tokens) | eco | v3 task=tool_agent_parallel agentRisk=high deepWebResearch=false terminalCode=false terminalSafety=false candidates=27", "costEstimate": 0.0009656, "baselineCost": 0.0577, "savings": 0.9832651646447141, @@ -1262,7 +1256,6 @@ "openai/gpt-5.4-nano", "google/gemini-3.1-flash-lite", "anthropic/claude-opus-5", - "openai/gpt-5-mini", "openai/gpt-4.1", "openai/gpt-4o-mini", "deepseek/deepseek-v4.1-flash", @@ -1490,7 +1483,7 @@ "tier": "MEDIUM", "confidence": 0.7373034537835593, "method": "portfolio", - "reasoning": "score=0.09 | long (1217 tokens), references (following) | eco | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=30", + "reasoning": "score=0.09 | long (1217 tokens), references (following) | eco | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=29", "costEstimate": 0.0084417, "baselineCost": 0.089285, "savings": 0.905452203617629, @@ -1498,14 +1491,13 @@ "candidates": [ "anthropic/claude-sonnet-5", "moonshot/kimi-k3.1-pro", - "openai/gpt-5-mini", "openai/gpt-5.3-codex", "deepseek/deepseek-v4-pro", "google/gemini-3.6-flash", + "openai/gpt-5.6-luna", "zai/glm-5.3-flash", "deepseek/deepseek-chat", "google/gemini-3.1-flash-lite", - "openai/gpt-5.6-luna", "openai/gpt-5.4-nano", "google/gemini-2.5-flash-lite", "google/gemini-3.5-flash-lite", @@ -1530,9 +1522,9 @@ "candidateScores": [ { "model": "anthropic/claude-sonnet-5", - "score": 0.9149452553778143, + "score": 0.9147490813920776, "quality": 1, - "cost": 0.8930792537075426, + "cost": 0.9066643466156254, "speed": 0.44883064339702206, "reliability": 1 }, @@ -1544,37 +1536,37 @@ "speed": 0.41599064333394636, "reliability": 1 }, - { - "model": "openai/gpt-5-mini", - "score": 0.8160846151098999, - "quality": 0.84, - "cost": 0.747528304895551, - "speed": 0.48376689739145695, - "reliability": 1 - }, { "model": "openai/gpt-5.3-codex", - "score": 0.8150636959754075, + "score": 0.8223196146513846, "quality": 0.87, - "cost": 0.7960452878328814, + "cost": 0.8219592831042283, "speed": 0.3897141538220059, "reliability": 0.79999 }, { "model": "deepseek/deepseek-v4-pro", - "score": 0.6886015298561169, + "score": 0.7100175525314989, "quality": 0.82, - "cost": 0.3980226439164407, + "cost": 0.474508439185662, "speed": 0.41955189559513506, "reliability": 1 }, { "model": "google/gemini-3.6-flash", - "score": 0.6173763474654378, + "score": 0.6529524741402246, "quality": 0.88, - "cost": 0, + "cost": 0.12705759526709592, "speed": 0.48576347465437786, "reliability": 1 + }, + { + "model": "openai/gpt-5.6-luna", + "score": 0.6076226216670789, + "quality": 0.84, + "cost": 0, + "speed": 0.452226216670789, + "reliability": 1 } ], "taskType": "tool_agent", @@ -1779,7 +1771,7 @@ "tier": "MEDIUM", "confidence": 0.5, "method": "portfolio", - "reasoning": "score=-0.06 | short (38 tokens), imperative (deploy), references (the api), agentic-light (check the, deploy) | ambiguous -> default: MEDIUM | eco | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=30", + "reasoning": "score=-0.06 | short (38 tokens), imperative (deploy), references (the api), agentic-light (check the, deploy) | ambiguous -> default: MEDIUM | eco | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=29", "costEstimate": 0.0006437999999999999, "baselineCost": 0.0065899999999999995, "savings": 0.9023065250379363, @@ -1787,14 +1779,13 @@ "candidates": [ "anthropic/claude-sonnet-5", "moonshot/kimi-k3.1-pro", - "openai/gpt-5-mini", "openai/gpt-5.3-codex", "deepseek/deepseek-v4-pro", "google/gemini-3.6-flash", + "openai/gpt-5.6-luna", "zai/glm-5.3-flash", "deepseek/deepseek-chat", "google/gemini-3.1-flash-lite", - "openai/gpt-5.6-luna", "openai/gpt-5.4-nano", "google/gemini-2.5-flash-lite", "google/gemini-3.5-flash-lite", @@ -1819,9 +1810,9 @@ "candidateScores": [ { "model": "anthropic/claude-sonnet-5", - "score": 0.8746228412913752, + "score": 0.8741575568374959, "quality": 1, - "cost": 0.7490706319702602, + "cost": 0.7616946160635482, "speed": 0.44883064339702206, "reliability": 1 }, @@ -1833,37 +1824,37 @@ "speed": 0.41599064333394636, "reliability": 1 }, - { - "model": "openai/gpt-5-mini", - "score": 0.8016837529361717, - "quality": 0.84, - "cost": 0.6960966542750929, - "speed": 0.48376689739145695, - "reliability": 1 - }, { "model": "openai/gpt-5.3-codex", - "score": 0.7920223164974423, + "score": 0.7960545105278317, "quality": 0.87, - "cost": 0.7137546468401487, + "cost": 0.7281553398058253, "speed": 0.3897141538220059, "reliability": 0.79999 }, { "model": "deepseek/deepseek-v4-pro", - "score": 0.6770808401171343, + "score": 0.6861401851464508, "quality": 0.82, - "cost": 0.3568773234200743, + "cost": 0.3892321270962047, "speed": 0.41955189559513506, "reliability": 1 }, { "model": "google/gemini-3.6-flash", - "score": 0.6173763474654378, + "score": 0.6314628434936814, "quality": 0.88, - "cost": 0, + "cost": 0.05030891438658436, "speed": 0.48576347465437786, "reliability": 1 + }, + { + "model": "openai/gpt-5.6-luna", + "score": 0.6076226216670789, + "quality": 0.84, + "cost": 0, + "speed": 0.452226216670789, + "reliability": 1 } ], "taskType": "tool_agent", @@ -2068,7 +2059,7 @@ "tier": "MEDIUM", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=0.08 | long (14423 tokens) | eco | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=30", + "reasoning": "score=0.08 | long (14423 tokens) | eco | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=29", "costEstimate": 0.0046423, "baselineCost": 0.104115, "savings": 0.9554118042549105, @@ -2078,12 +2069,11 @@ "openai/gpt-5.3-codex", "google/gemini-3.6-flash", "deepseek/deepseek-v4-pro", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "moonshot/kimi-k3.1-pro", "zai/glm-5.3-flash", "deepseek/deepseek-chat", "google/gemini-3.1-flash-lite", - "openai/gpt-5.6-luna", "openai/gpt-5.4-nano", "google/gemini-2.5-flash-lite", "google/gemini-3.5-flash-lite", @@ -2108,7 +2098,7 @@ "candidateScores": [ { "model": "anthropic/claude-sonnet-5", - "score": 0.9448830643397024, + "score": 0.9408830643397024, "quality": 1, "cost": 1, "speed": 0.44883064339702206, @@ -2139,11 +2129,11 @@ "reliability": 1 }, { - "model": "openai/gpt-5-mini", - "score": 0.7402759279311213, + "model": "openai/gpt-5.6-luna", + "score": 0.6174516380882741, "quality": 0.84, - "cost": 0.4767829935427701, - "speed": 0.48376689739145695, + "cost": 0.035103630075696834, + "speed": 0.452226216670789, "reliability": 1 }, { @@ -2200,7 +2190,7 @@ "tier": "SIMPLE", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (1 tokens) | agentic (tools) | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=27", + "reasoning": "score=-0.08 | short (1 tokens) | agentic (tools) | v3 task=tool_agent agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=26", "costEstimate": 0.0032001, "baselineCost": 0.032005, "savings": 0.9000124980471801, @@ -2213,7 +2203,6 @@ "anthropic/claude-haiku-4.5", "google/gemini-3.5-flash-lite", "anthropic/claude-opus-5", - "openai/gpt-5-mini", "openai/gpt-4.1", "google/gemini-3.6-flash", "openai/gpt-5.3-codex", @@ -2320,7 +2309,7 @@ "tier": "REASONING", "confidence": 0.973403006423134, "method": "portfolio", - "reasoning": "score=0.10 | short (16 tokens), reasoning (prove, step by step) | v3 task=reasoning agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=7", + "reasoning": "score=0.10 | short (16 tokens), reasoning (prove, step by step) | v3 task=reasoning agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=6", "costEstimate": 0.0012016, "baselineCost": 0.00648, "savings": 0.8145679012345679, @@ -2331,8 +2320,7 @@ "deepseek/deepseek-reasoner", "xai/grok-4.3", "qwen/qwen3.7-plus", - "openai/gpt-5.4-mini", - "openai/o3" + "openai/gpt-5.4-mini" ], "candidateScores": [ { @@ -2399,7 +2387,7 @@ "tier": "SIMPLE", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (20 tokens) | agentic (tools) | v3 task=tool_agent_parallel agentRisk=high deepWebResearch=false terminalCode=false terminalSafety=false candidates=27", + "reasoning": "score=-0.08 | short (20 tokens) | agentic (tools) | v3 task=tool_agent_parallel agentRisk=high deepWebResearch=false terminalCode=false terminalSafety=false candidates=26", "costEstimate": 0.020291200000000002, "baselineCost": 0.0577, "savings": 0.6483327556325823, @@ -2413,7 +2401,6 @@ "google/gemini-3.5-flash-lite", "anthropic/claude-opus-5", "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", "openai/gpt-4.1", "xai/grok-4.5", "google/gemini-3.6-flash", @@ -2610,7 +2597,7 @@ "agenticScore": 0, "candidates": [ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "zai/glm-5.3-flash", "openai/gpt-5.6-terra", @@ -2686,7 +2673,7 @@ "tier": "REASONING", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (13 tokens) | upgraded to MEDIUM (structured output) | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=10", + "reasoning": "score=-0.08 | short (13 tokens) | upgraded to MEDIUM (structured output) | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=9", "costEstimate": 0.0005406000000000001, "baselineCost": 0.032065, "savings": 0.9831404958677685, @@ -2700,7 +2687,6 @@ "xai/grok-4.3", "qwen/qwen3.7-plus", "openai/gpt-5.4-mini", - "openai/o3", "moonshot/kimi-k3.1-pro" ], "candidateScores": [ @@ -2852,7 +2838,7 @@ "agenticScore": 0.2, "candidates": [ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "zai/glm-5.3-flash", "openai/gpt-5.6-terra", @@ -2994,7 +2980,7 @@ "tier": "REASONING", "confidence": 0.5, "method": "portfolio", - "reasoning": "score=-0.07 | short (33 tokens), constraints (budget, budget) | ambiguous -> default: MEDIUM | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=10", + "reasoning": "score=-0.07 | short (33 tokens), constraints (budget, budget) | ambiguous -> default: MEDIUM | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=9", "costEstimate": 0.0014038, "baselineCost": 0.083365, "savings": 0.9831607988964194, @@ -3008,7 +2994,6 @@ "xai/grok-4.3", "qwen/qwen3.7-plus", "openai/gpt-5.4-mini", - "openai/o3", "moonshot/kimi-k3.1-pro" ], "candidateScores": [ @@ -3099,7 +3084,7 @@ "agenticScore": 0, "candidates": [ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "zai/glm-5.3-flash", "openai/gpt-5.6-terra", @@ -3199,7 +3184,7 @@ "google/gemini-3.5-flash-lite", "deepseek/deepseek-chat", "anthropic/claude-opus-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "openai/gpt-5.3-codex", @@ -3305,7 +3290,7 @@ "tier": "REASONING", "confidence": 0.973403006423134, "method": "portfolio", - "reasoning": "score=0.10 | short (16 tokens), reasoning (prove, step by step) | premium | v3 task=reasoning agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=10", + "reasoning": "score=0.10 | short (16 tokens), reasoning (prove, step by step) | premium | v3 task=reasoning agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=9", "costEstimate": 0.0006416, "baselineCost": 0.00648, "savings": 0, @@ -3319,8 +3304,7 @@ "anthropic/claude-opus-4.8", "anthropic/claude-opus-4.7", "xai/grok-4.3", - "openai/gpt-5.4-mini", - "openai/o3" + "openai/gpt-5.4-mini" ], "candidateScores": [ { @@ -3416,7 +3400,7 @@ "deepseek/deepseek-chat", "anthropic/claude-opus-5", "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "xai/grok-4.5", @@ -3617,7 +3601,7 @@ "anthropic/claude-sonnet-4.6", "openai/gpt-5.6-terra", "anthropic/claude-opus-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "deepseek/deepseek-v4-pro", @@ -3684,7 +3668,7 @@ "tier": "REASONING", "confidence": 0.7231218051243898, "method": "portfolio", - "reasoning": "score=-0.08 | short (13 tokens) | upgraded to MEDIUM (structured output) | premium | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=12", + "reasoning": "score=-0.08 | short (13 tokens) | upgraded to MEDIUM (structured output) | premium | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=11", "costEstimate": 0.008595500000000002, "baselineCost": 0.032065, "savings": 0, @@ -3700,7 +3684,6 @@ "deepseek/deepseek-v4-pro", "xai/grok-4.3", "openai/gpt-5.4-mini", - "openai/o3", "moonshot/kimi-k3.1-pro" ], "candidateScores": [ @@ -3839,7 +3822,7 @@ "anthropic/claude-sonnet-4.6", "openai/gpt-5.6-terra", "anthropic/claude-opus-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "deepseek/deepseek-v4-pro", @@ -3979,7 +3962,7 @@ "tier": "REASONING", "confidence": 0.5, "method": "portfolio", - "reasoning": "score=-0.07 | short (33 tokens), constraints (budget, budget) | ambiguous -> default: MEDIUM | premium | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=12", + "reasoning": "score=-0.07 | short (33 tokens), constraints (budget, budget) | ambiguous -> default: MEDIUM | premium | v3 task=reasoning_math agentRisk=standard deepWebResearch=false terminalCode=false terminalSafety=false candidates=11", "costEstimate": 0.0223471, "baselineCost": 0.083365, "savings": 0, @@ -3995,7 +3978,6 @@ "deepseek/deepseek-v4-pro", "xai/grok-4.3", "openai/gpt-5.4-mini", - "openai/o3", "moonshot/kimi-k3.1-pro" ], "candidateScores": [ @@ -4070,7 +4052,7 @@ "anthropic/claude-sonnet-4.6", "openai/gpt-5.6-terra", "anthropic/claude-opus-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "deepseek/deepseek-v4-pro", diff --git a/src/hardening.test.ts b/src/hardening.test.ts index b0af309..4c60ece 100644 --- a/src/hardening.test.ts +++ b/src/hardening.test.ts @@ -18,7 +18,7 @@ const pricing = new Map([ ["anthropic/claude-sonnet-5", { inputPrice: 3, outputPrice: 15 }], ["anthropic/claude-opus-4.8", { inputPrice: 5, outputPrice: 25 }], ["openai/gpt-5.3-codex", { inputPrice: 1.75, outputPrice: 14 }], - ["openai/gpt-5-mini", { inputPrice: 0.25, outputPrice: 2 }], + ["openai/gpt-5.6-luna", { inputPrice: 0.2, outputPrice: 1.2 }], ["google/gemini-3.6-flash", { inputPrice: 0.75, outputPrice: 3.75 }], ["google/gemini-2.5-flash", { inputPrice: 0.3, outputPrice: 2.5 }], ["deepseek/deepseek-v4-pro", { inputPrice: 0.435, outputPrice: 0.87 }], diff --git a/src/portfolio.test.ts b/src/portfolio.test.ts index b7bcce6..377e228 100644 --- a/src/portfolio.test.ts +++ b/src/portfolio.test.ts @@ -10,7 +10,7 @@ const pricing = new Map([ ["anthropic/claude-opus-5", { inputPrice: 5, outputPrice: 25 }], ["anthropic/claude-opus-4.8", { inputPrice: 5, outputPrice: 25 }], ["openai/gpt-5.3-codex", { inputPrice: 1.75, outputPrice: 14 }], - ["openai/gpt-5-mini", { inputPrice: 0.25, outputPrice: 2 }], + ["openai/gpt-5.6-luna", { inputPrice: 0.25, outputPrice: 2 }], ["openai/gpt-4.1", { inputPrice: 2, outputPrice: 8 }], ["google/gemini-3.6-flash", { inputPrice: 0.5, outputPrice: 3 }], ["google/gemini-3-flash-preview", { inputPrice: 0.5, outputPrice: 3 }], @@ -51,7 +51,7 @@ describe("PortfolioStrategy", () => { expect(decision.method).toBe("portfolio"); expect(decision.taskType).toBe("code_agent"); - expect(decision.model).toBe("openai/gpt-5-mini"); + expect(decision.model).toBe("openai/gpt-5.6-luna"); expect(decision.candidates).toContain(decision.model); expect(decision.candidates).toContain("openai/gpt-5.3-codex"); expect(["moonshot/kimi-k2.7", "moonshot/kimi-k2.6", "moonshot/kimi-k2.5"]).not.toContain( @@ -208,7 +208,7 @@ describe("PortfolioStrategy", () => { expect(decision.reasoning).toContain("deepWebResearch=true"); expect(decision.candidates?.slice(0, 3)).toEqual([ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", ]); expect(decision.reasoning).toContain("candidates="); @@ -257,7 +257,7 @@ describe("PortfolioStrategy", () => { expect(["tool_agent", "tool_agent_parallel"]).toContain(decision.taskType); expect(decision.reasoning).toContain("agentRisk=high"); - expect(decision.model).toBe("openai/gpt-5-mini"); + expect(decision.model).toBe("openai/gpt-5.6-luna"); }); it("promotes conditional-global airline work to the complex band", () => { @@ -305,7 +305,7 @@ describe("PortfolioStrategy", () => { }); expect(decision.taskType).toBe("code_agent"); - expect(decision.model).toBe("openai/gpt-5-mini"); + expect(decision.model).toBe("openai/gpt-5.6-luna"); expect(decision.reasoning).toContain("terminalCode=true"); }); @@ -328,7 +328,7 @@ describe("PortfolioStrategy", () => { expect(decision.taskType).toBe("tool_agent"); expect(decision.reasoning).toContain("agentRisk=complex_high"); expect(decision.model).toBe("anthropic/claude-sonnet-5"); - expect(decision.model).not.toBe("openai/gpt-5-mini"); + expect(decision.model).not.toBe("openai/gpt-5.6-luna"); }); it("promotes a cross-runtime polyglot artifact to the strong Terminal Agent band", () => { @@ -456,7 +456,7 @@ describe("PortfolioStrategy", () => { }); expect(["tool_agent", "tool_agent_parallel", "code_agent"]).toContain(decision.taskType); - expect(decision.model).toBe("openai/gpt-5-mini"); + expect(decision.model).toBe("openai/gpt-5.6-luna"); expect(decision.reasoning).toContain("terminalSafety=false"); }); @@ -475,7 +475,7 @@ describe("PortfolioStrategy", () => { }); expect(decision.reasoning).toContain("terminalSafety=true"); - expect(decision.model).not.toBe("openai/gpt-5-mini"); + expect(decision.model).not.toBe("openai/gpt-5.6-luna"); }); it("uses the trajectory-validated high-risk model for retail order tools", () => { @@ -501,7 +501,7 @@ describe("PortfolioStrategy", () => { expect(["tool_agent", "tool_agent_parallel"]).toContain(decision.taskType); expect(decision.model).toBe("deepseek/deepseek-v4-pro"); - expect(decision.candidates).toContain("openai/gpt-5-mini"); + expect(decision.candidates).toContain("openai/gpt-5.6-luna"); }); it("uses the calibrated low-cost model for one local retail operation", () => { @@ -526,7 +526,7 @@ describe("PortfolioStrategy", () => { ); expect(decision.taskType).toBe("tool_agent"); - expect(decision.model).toBe("openai/gpt-5-mini"); + expect(decision.model).toBe("openai/gpt-5.6-luna"); }); it("keeps global retail choices on the high-risk calibrated model", () => { @@ -593,7 +593,7 @@ describe("PortfolioStrategy", () => { }, ); - expect(decision.model).toBe("openai/gpt-5-mini"); + expect(decision.model).toBe("openai/gpt-5.6-luna"); expect(decision.reasoning).toContain("agentRisk=policy_exception_simple"); }); @@ -659,7 +659,7 @@ describe("PortfolioStrategy", () => { }); expect(["tool_agent", "tool_agent_parallel"]).toContain(decision.taskType); - expect(decision.model).toBe("openai/gpt-5-mini"); + expect(decision.model).toBe("openai/gpt-5.6-luna"); expect(decision.candidates).toContain("anthropic/claude-sonnet-5"); }); @@ -684,7 +684,7 @@ describe("PortfolioStrategy", () => { ); expect(decision.taskType).not.toBe("code_agent"); - expect(decision.model).toBe("openai/gpt-5-mini"); + expect(decision.model).toBe("openai/gpt-5.6-luna"); expect(decision.reasoning).toContain("agentRisk=high"); }); diff --git a/src/portfolio.ts b/src/portfolio.ts index e13017b..134e714 100644 --- a/src/portfolio.ts +++ b/src/portfolio.ts @@ -525,6 +525,14 @@ type AffinityBand = Readonly>; // and the gateways redirect to 3.5 Flash-Lite. It is a successor, not a // sibling claiming a flagship's evidence (see the rule above), but the values // were measured on 2.5 and still need a 3.5 Flash-Lite run. +// +// Likewise every "gpt-5.6-luna" value (and its place in the evidence pools and +// the web-research order) is CARRIED from GPT-5 Mini, which OpenAI shuts down +// on 2026-12-11 and the gateways redirect to GPT-5.6 Luna. The Terminal-Bench +// and tau2 trajectories (2026-07-28) and the BrowseComp sessions behind them +// ran on gpt-5-mini, a reasoning model; luna runs without reasoning, so these +// are a placeholder, not luna evidence. Re-measure luna on those suites — or +// move the bands to a measured model — before relying on them. /** Affinity of a model with no task-specific evidence. */ const NEUTRAL_AFFINITY = 0.68; @@ -535,7 +543,7 @@ const NEUTRAL_AFFINITY = 0.68; const TERMINAL_COMPLEX_HIGH: AffinityBand = { "claude-sonnet-5": 1, "gpt-5.3-codex": 0.87, - "gpt-5-mini": 0.78, + "gpt-5.6-luna": 0.78, "gemini-3.6-flash": 0.76, }; @@ -545,14 +553,14 @@ const TERMINAL_COMPLEX_HIGH: AffinityBand = { // an availability fallback until a larger stable-provider sample supports it. const WEB_RESEARCH_DEEP: AffinityBand = { "claude-sonnet-5": 1, - "gpt-5-mini": 0.88, + "gpt-5.6-luna": 0.88, "gemini-3.6-flash": 0.84, "claude-opus-5": 0.8, "claude-opus-4.8": 0.78, }; const WEB_RESEARCH: AffinityBand = { "claude-sonnet-5": 1, - "gpt-5-mini": 0.88, + "gpt-5.6-luna": 0.88, "gemini-3.6-flash": 0.86, "claude-opus-5": 0.84, "claude-opus-4.8": 0.82, @@ -562,11 +570,11 @@ const RETAIL_POLICY_EXCEPTION: AffinityBand = { "gpt-4.1": 1, "claude-sonnet-5": 0.9, "deepseek-v4-pro": 0.82, - "gpt-5-mini": 0.8, + "gpt-5.6-luna": 0.8, "gpt-4o-mini": 0.76, }; const RETAIL_POLICY_EXCEPTION_SIMPLE: AffinityBand = { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "gpt-4.1": 0.86, "deepseek-v4-pro": 0.82, "gpt-4o-mini": 0.8, @@ -584,7 +592,7 @@ const AFFINITY = { codeAgent: { "gpt-5.3-codex": 1, "claude-sonnet-5": 0.98, - "gpt-5-mini": 0.96, + "gpt-5.6-luna": 0.96, "gemini-3.6-flash": 0.92, "kimi-k3.1-pro": 0.9, "deepseek-v4-pro": 0.88, @@ -594,7 +602,7 @@ const AFFINITY = { // over the prior dynamic choice. Codex/Sonnet are close fallbacks; actual // request cost breaks the tie. terminalTool: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "gpt-5.3-codex": 0.98, "claude-sonnet-5": 0.9, "gemini-3.6-flash": 0.89, @@ -616,7 +624,7 @@ const AFFINITY = { // arguments. DeepSeek V4 Pro completed all three high-risk retail calibration // trajectories (global-choice, cross-record, multi-write); Sonnet one. retailStandard: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "claude-sonnet-5": 0.88, "gemini-3.6-flash": 0.82, "gpt-5.3-codex": 0.81, @@ -629,7 +637,7 @@ const AFFINITY = { "gemini-3.6-flash": 0.82, "gpt-5.3-codex": 0.81, "kimi-k3.1-pro": 0.78, - "gpt-5-mini": 0.76, + "gpt-5.6-luna": 0.76, }, // Standard airline workflows stay on GPT-5 Mini: six full-session // development trajectories gave it the same 5/6 success as Sonnet at roughly @@ -643,12 +651,12 @@ const AFFINITY = { // roughly two orders of magnitude more on the long-tail case. airlineComplex: { "claude-sonnet-5": 1, - "gpt-5-mini": 0.78, + "gpt-5.6-luna": 0.78, "gemini-3.6-flash": 0.76, "deepseek-v4-pro": 0.74, }, airlineStandard: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "claude-sonnet-5": 0.9, "gemini-3.6-flash": 0.8, "deepseek-v4-pro": 0.76, @@ -663,7 +671,7 @@ const AFFINITY = { "gemini-3.6-flash": 0.88, "gpt-5.3-codex": 0.87, "kimi-k3.1-pro": 0.85, - "gpt-5-mini": 0.84, + "gpt-5.6-luna": 0.84, "deepseek-v4-pro": 0.82, }, // Multi-file Terminal work is not equivalent to a one-turn parallel @@ -675,7 +683,7 @@ const AFFINITY = { "gpt-5.3-codex": 0.86, }, parallelTerminal: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "gpt-5.3-codex": 0.98, "claude-sonnet-5": 0.92, "gemini-3.6-flash": 0.88, @@ -684,17 +692,17 @@ const AFFINITY = { "deepseek-v4-pro": 1, "claude-sonnet-5": 0.88, "claude-opus-4.8": 0.84, - "gpt-5-mini": 0.78, + "gpt-5.6-luna": 0.78, "gemini-3.6-flash": 0.76, }, parallelAirlineComplex: { "claude-sonnet-5": 1, - "gpt-5-mini": 0.78, + "gpt-5.6-luna": 0.78, "claude-opus-4.8": 0.76, "gemini-3.6-flash": 0.74, }, parallelAirline: { - "gpt-5-mini": 1, + "gpt-5.6-luna": 1, "claude-sonnet-5": 0.9, "gemini-3.6-flash": 0.8, }, @@ -887,7 +895,7 @@ function evidenceCandidates(task: TaskType): string[] { return [ "openai/gpt-5.3-codex", "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "moonshot/kimi-k3.1-pro", "deepseek/deepseek-v4-pro", @@ -897,7 +905,7 @@ function evidenceCandidates(task: TaskType): string[] { return [ "anthropic/claude-sonnet-5", "anthropic/claude-opus-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "google/gemini-3.6-flash", @@ -911,7 +919,7 @@ function evidenceCandidates(task: TaskType): string[] { "anthropic/claude-opus-5", "anthropic/claude-opus-4.8", "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "openai/gpt-4.1", "openai/gpt-4o-mini", "xai/grok-4.5", @@ -1247,7 +1255,7 @@ export class PortfolioStrategy implements RouterStrategy { // models in their curated chain order after the scored primary pool. const webResearchFallbackOrder = [ "anthropic/claude-sonnet-5", - "openai/gpt-5-mini", + "openai/gpt-5.6-luna", "google/gemini-3.6-flash", "anthropic/claude-opus-5", "anthropic/claude-opus-4.8", diff --git a/src/retired-models.test.ts b/src/retired-models.test.ts index a0c052e..9fc68e4 100644 --- a/src/retired-models.test.ts +++ b/src/retired-models.test.ts @@ -28,6 +28,10 @@ const REDIRECTED: Readonly> = { // 2026-12-01: Google retires Gemini 2.5. "google/gemini-2.5-flash": "google/gemini-3.5-flash-lite", "google/gemini-2.5-pro": "google/gemini-3.8-flash", + // 2026-12-11: OpenAI shuts down o3, gpt-5-mini and gpt-5-nano. + "openai/o3": "openai/gpt-5.4-mini", + "openai/gpt-5-mini": "openai/gpt-5.6-luna", + "openai/gpt-5-nano": "openai/gpt-6-luna", }; const TIER_SETS = ["tiers", "ecoTiers", "premiumTiers", "agenticTiers"] as const; @@ -102,6 +106,31 @@ describe("retired models", () => { } }); + it("route never returns a retired id on a web-research turn (its own curated fallback order)", () => { + // The web-research fallback order is a separate list in portfolio.ts that + // the corpus above never reaches: it needs web tools and a research prompt. + for (const profile of [undefined, "eco", "auto", "premium"] as const) { + for (const prompt of [ + "Research the following clues across multiple public sources and identify the country.", + "Search the official documentation for the current API timeout setting.", + ]) { + const decision = route(prompt, undefined, 2048, { + config: DEFAULT_ROUTING_CONFIG, + modelPricing: PRICING, + routingProfile: profile, + hasTools: true, + requiresTools: true, + toolCount: 2, + toolNames: ["web_search", "web_fetch"], + }); + expect(decision.reasoning).toContain("deepWebResearch="); + for (const model of [decision.model, ...(decision.candidates ?? [])]) { + expect(REDIRECTED[model], `${profile ?? "default"} web research returned ${model}`).toBeUndefined(); + } + } + } + }); + it("every successor has capability evidence the eligibility stage can use", () => { for (const successor of new Set(Object.values(REDIRECTED))) { expect(DEFAULT_MODEL_CAPABILITIES[successor], successor).toBeDefined(); From dfed459609c4a3adc5e1b62de83c5c449a866d6f Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Tue, 24 Nov 2026 16:58:36 -0600 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20gpt-5-nano=20is=20not=20redirected?= =?UTF-8?q?=20on=2012-11=20=E2=80=94=20keep=20it=20out=20of=20chains=20wit?= =?UTF-8?q?hout=20calling=20it=20a=20redirect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Owner decision 2026-11-24: the gateways keep serving openai/gpt-5-nano from Azure at its own $0.05/$0.40 until 2027-02-09 instead of redirecting it to gpt-6-luna. It was never in a chain, so routing is unchanged; the config comment and the REDIRECTED test table no longer claim a redirect, and a dedicated test keeps it out of every chain until its retirement. --- README.md | 2 +- dist/index.js | 4 +++- dist/index.js.map | 2 +- src/config.ts | 4 +++- src/retired-models.test.ts | 10 ++++++++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f9352be..7b97d31 100644 --- a/README.md +++ b/README.md @@ -431,7 +431,7 @@ Omitted entries fall back to a weak historical prior rather than disqualifying a ```bash npm ci npm run typecheck # tsc --noEmit -npm test # vitest — 197 tests across 12 files +npm test # vitest — 198 tests across 12 files npm run build # tsup → dist/ npm run check # all three, and what CI runs diff --git a/dist/index.js b/dist/index.js index 2b248e2..85ea824 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1681,7 +1681,9 @@ var DEFAULT_ROUTING_CONFIG = { // affinity values, CARRIED, not measured (portfolio.ts) — gpt-5-mini is a // reasoning model and luna runs without reasoning, so those values are a // placeholder until a Terminal-Bench/tau2 run on luna. - // - openai/gpt-5-nano -> openai/gpt-6-luna. In no chain. + // - openai/gpt-5-nano is NOT redirected (owner decision 2026-11-24): the + // gateways keep serving it from Azure at its own $0.05/$0.40 until + // 2027-02-09. It is hidden and in no chain, and none is added. // Auto (balanced) tier configs - current default smart routing tiers: { SIMPLE: { diff --git a/dist/index.js.map b/dist/index.js.map index e7e4d34..358b967 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/rules.ts","../src/selector.ts","../src/tokens.ts","../src/strategy.ts","../src/config.ts","../src/model-capabilities.ts","../src/model-profiles.generated.json","../src/model-profiles.ts","../src/tool-intent.ts","../src/portfolio.ts","../src/catalog.ts","../src/index.ts"],"sourcesContent":["/**\n * Rule-Based Classifier (v2 — Weighted Scoring)\n *\n * Scores a request across 15 weighted dimensions and maps the aggregate\n * score to a tier using configurable boundaries. Confidence is calibrated\n * via sigmoid — low confidence triggers the fallback classifier.\n *\n * Handles 70-80% of requests in < 1ms with zero cost.\n */\n\nimport type { Tier, ScoringResult, ScoringConfig } from \"./types.js\";\n\ntype DimensionScore = { name: string; score: number; signal: string | null };\n\n// ─── Keyword Matching ───\n//\n// A plain substring test counted `class` in \"classic\", `story` in \"history\",\n// `edit` in \"credit\" and `fix` in \"prefix\", so everyday prose picked up code,\n// creative and agentic signals it did not carry. Alphabetic keywords now have\n// to start at a word boundary. Short ASCII keywords additionally have to end\n// at one, after an optional inflection, graded by how much a stray suffix can\n// change the word: a three-letter keyword takes only the English endings that\n// cannot spell another word (fix → fixes, never pip → pipe or def → defer); a\n// four-to-six-letter keyword also takes the common German and Romance endings,\n// because the lists spell those languages in ASCII too (beweis → beweise,\n// klasse → klassen); anything longer stays trailing-open like the substring\n// test it replaces, since its false-positive surface is small and its\n// inflection surface is large. Non-ASCII alphabetic keywords keep a\n// trailing-open match because several are deliberate stems (`оптимизаци`,\n// `рассуждени`). CJK, Hangul and Arabic keywords keep the substring test:\n// those scripts have no word boundaries, or attach particles and articles\n// directly to the word.\n\nconst UNSEGMENTED_SCRIPT =\n /[؀-ۿ -ヿ㐀-䶿一-鿿가-힯豈-﫿＀-￯]/;\nconst WORD_CHAR = /[\\p{L}\\p{N}]/u;\nconst ASCII_PHRASE = /^[a-z0-9' -]+$/;\n// A word boundary is a transition out of the segmented scripts. A CJK\n// character next to a Latin keyword (\"请step by step证明\") is a boundary, not\n// part of the word: mixed-script prompts carry no spaces between scripts.\nconst SEGMENTED_WORD_CHAR = \"\\\\p{Script=Latin}\\\\p{Script=Cyrillic}\\\\p{Script=Greek}\\\\p{N}\";\nconst BOUNDARY_BEFORE = `(?();\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction keywordMatcher(keyword: string): KeywordMatcher {\n const cached = matcherCache.get(keyword);\n if (cached) return cached;\n\n const kw = keyword.toLowerCase();\n let matcher: KeywordMatcher;\n if (UNSEGMENTED_SCRIPT.test(kw) || kw.length === 0) {\n matcher = { needle: kw, pattern: null };\n } else {\n const lead = WORD_CHAR.test(kw[0]) ? BOUNDARY_BEFORE : \"\";\n const escaped = escapeRegExp(kw);\n let body = escaped;\n let trail = \"\";\n let needle = kw;\n const lastWord = kw.slice(kw.lastIndexOf(\" \") + 1);\n if (\n WORD_CHAR.test(kw[kw.length - 1]) &&\n ASCII_PHRASE.test(kw) &&\n lastWord.length <= BOUNDED_LAST_WORD_LENGTH\n ) {\n // ASCII phrases contain no regex metacharacters, so `escaped` slices\n // align with `kw` slices below.\n const forms: string[] = [];\n if (/\\d$/.test(kw)) {\n // \"step 1\" must not absorb \"step 10\".\n forms.push(escaped);\n } else if (lastWord.length <= 3) {\n forms.push(`${escaped}${SHORT_SUFFIXES}`);\n if (/(?:x|s|z|ch|sh)$/.test(kw)) forms.push(`${escaped}${SIBILANT_PLURAL}`);\n } else {\n forms.push(`${escaped}${MID_SUFFIXES}`);\n if (kw.endsWith(\"e\")) {\n forms.push(`${escaped.slice(0, -1)}${DROPPED_E_SUFFIXES}`);\n needle = kw.slice(0, -1);\n } else if (kw.endsWith(\"y\")) {\n forms.push(`${escaped.slice(0, -1)}(?:ies|ied)`);\n needle = kw.slice(0, -1);\n } else if (/[aeiou][bdgmnprt]$/.test(kw)) {\n // debug → debugging, plan → planned\n forms.push(`${escaped}${kw[kw.length - 1]}${DOUBLED_CONSONANT_SUFFIXES}`);\n }\n }\n body = `(?:${forms.join(\"|\")})`;\n trail = BOUNDARY_AFTER;\n }\n matcher = { needle, pattern: new RegExp(`${lead}${body}${trail}`, \"u\") };\n }\n matcherCache.set(keyword, matcher);\n return matcher;\n}\n\n/** Whether lower-cased `text` contains `keyword` as a word (or as a substring for CJK). */\nfunction matchesKeyword(text: string, keyword: string): boolean {\n const { needle, pattern } = keywordMatcher(keyword);\n if (!text.includes(needle)) return false;\n return pattern === null ? true : pattern.test(text);\n}\n\n// ─── Dimension Scorers ───\n// Each returns a score in [-1, 1] and an optional signal string.\n\nfunction scoreTokenCount(\n estimatedTokens: number,\n thresholds: { simple: number; complex: number },\n): DimensionScore {\n if (estimatedTokens < thresholds.simple) {\n return { name: \"tokenCount\", score: -1.0, signal: `short (${estimatedTokens} tokens)` };\n }\n if (estimatedTokens > thresholds.complex) {\n return { name: \"tokenCount\", score: 1.0, signal: `long (${estimatedTokens} tokens)` };\n }\n return { name: \"tokenCount\", score: 0, signal: null };\n}\n\nfunction scoreKeywordMatch(\n text: string,\n keywords: string[],\n name: string,\n signalLabel: string,\n thresholds: { low: number; high: number },\n scores: { none: number; low: number; high: number },\n): DimensionScore {\n const matches = keywords.filter((kw) => matchesKeyword(text, kw));\n if (matches.length >= thresholds.high) {\n return {\n name,\n score: scores.high,\n signal: `${signalLabel} (${matches.slice(0, 3).join(\", \")})`,\n };\n }\n if (matches.length >= thresholds.low) {\n return {\n name,\n score: scores.low,\n signal: `${signalLabel} (${matches.slice(0, 3).join(\", \")})`,\n };\n }\n return { name, score: scores.none, signal: null };\n}\n\nfunction scoreMultiStep(text: string): DimensionScore {\n // A numbered list item must start a line: a bare \"\\d\\.\\s\" also matched\n // every sentence that ends in a number (\"born in 1990. How old…\").\n const patterns = [/first.*then/i, /step \\d/i, /(?:^|\\n)\\s*\\d+[.)]\\s/];\n const hits = patterns.filter((p) => p.test(text));\n if (hits.length > 0) {\n return { name: \"multiStepPatterns\", score: 0.5, signal: \"multi-step\" };\n }\n return { name: \"multiStepPatterns\", score: 0, signal: null };\n}\n\nfunction scoreQuestionComplexity(prompt: string): DimensionScore {\n const count = (prompt.match(/[??]/g) || []).length;\n if (count > 3) {\n return { name: \"questionComplexity\", score: 0.5, signal: `${count} questions` };\n }\n return { name: \"questionComplexity\", score: 0, signal: null };\n}\n\n/**\n * Score agentic task indicators.\n * Returns agenticScore (0-1) based on keyword matches:\n * - 4+ matches = 1.0 (high agentic)\n * - 3 matches = 0.6 (moderate agentic, triggers auto-agentic mode)\n * - 1-2 matches = 0.2 (low agentic)\n *\n * Thresholds raised because common keywords were pruned from the list.\n */\nfunction scoreAgenticTask(\n text: string,\n keywords: string[],\n): { dimensionScore: DimensionScore; agenticScore: number } {\n let matchCount = 0;\n const signals: string[] = [];\n\n for (const keyword of keywords) {\n if (matchesKeyword(text, keyword)) {\n matchCount++;\n if (signals.length < 3) {\n signals.push(keyword);\n }\n }\n }\n\n // Threshold-based scoring (raised thresholds after keyword pruning)\n if (matchCount >= 4) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 1.0,\n signal: `agentic (${signals.join(\", \")})`,\n },\n agenticScore: 1.0,\n };\n } else if (matchCount >= 3) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 0.6,\n signal: `agentic (${signals.join(\", \")})`,\n },\n agenticScore: 0.6,\n };\n } else if (matchCount >= 1) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 0.2,\n signal: `agentic-light (${signals.join(\", \")})`,\n },\n agenticScore: 0.2,\n };\n }\n\n return {\n dimensionScore: { name: \"agenticTask\", score: 0, signal: null },\n agenticScore: 0,\n };\n}\n\n// ─── Main Classifier ───\n\nexport function classifyByRules(\n prompt: string,\n systemPrompt: string | undefined,\n estimatedTokens: number,\n config: ScoringConfig,\n): ScoringResult {\n // Score against user prompt only — system prompts contain boilerplate keywords\n // (tool definitions, skill descriptions, behavioral rules) that dominate scoring\n // and make every request score identically. See GitHub issue #50.\n const userText = prompt.toLowerCase();\n\n const reasoningDimension = scoreKeywordMatch(\n userText,\n config.reasoningKeywords,\n \"reasoningMarkers\",\n \"reasoning\",\n { low: 1, high: 2 },\n { none: 0, low: 0.7, high: 1.0 },\n );\n\n // Score the base dimensions against user text only; the agentic dimension is\n // appended below, so the scored total is one more than this list.\n const dimensions: DimensionScore[] = [\n // Token count uses total estimated tokens (system + user) — context size matters for model selection\n scoreTokenCount(estimatedTokens, config.tokenCountThresholds),\n scoreKeywordMatch(\n userText,\n config.codeKeywords,\n \"codePresence\",\n \"code\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 1.0 },\n ),\n reasoningDimension,\n scoreKeywordMatch(\n userText,\n config.technicalKeywords,\n \"technicalTerms\",\n \"technical\",\n { low: 2, high: 4 },\n { none: 0, low: 0.5, high: 1.0 },\n ),\n scoreKeywordMatch(\n userText,\n config.creativeKeywords,\n \"creativeMarkers\",\n \"creative\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.simpleKeywords,\n \"simpleIndicators\",\n \"simple\",\n { low: 1, high: 2 },\n { none: 0, low: -1.0, high: -1.0 },\n ),\n scoreMultiStep(userText),\n scoreQuestionComplexity(prompt),\n\n // 6 new dimensions\n scoreKeywordMatch(\n userText,\n config.imperativeVerbs,\n \"imperativeVerbs\",\n \"imperative\",\n { low: 1, high: 2 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.constraintIndicators,\n \"constraintCount\",\n \"constraints\",\n { low: 1, high: 3 },\n { none: 0, low: 0.3, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.outputFormatKeywords,\n \"outputFormat\",\n \"format\",\n { low: 1, high: 2 },\n { none: 0, low: 0.4, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.referenceKeywords,\n \"referenceComplexity\",\n \"references\",\n { low: 1, high: 2 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.negationKeywords,\n \"negationComplexity\",\n \"negation\",\n { low: 2, high: 3 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.domainSpecificKeywords,\n \"domainSpecificity\",\n \"domain-specific\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 0.8 },\n ),\n ];\n\n // Score agentic task indicators — user prompt only\n // System prompt describes assistant behavior, not user's intent.\n // e.g. a coding assistant system prompt with \"edit files\" / \"fix bugs\" should NOT\n // force every request into agentic mode.\n const agenticResult = scoreAgenticTask(userText, config.agenticTaskKeywords);\n dimensions.push(agenticResult.dimensionScore);\n const agenticScore = agenticResult.agenticScore;\n\n // Collect signals\n const signals = dimensions.filter((d) => d.signal !== null).map((d) => d.signal!);\n\n // Compute weighted score\n const weights = config.dimensionWeights;\n let weightedScore = 0;\n for (const d of dimensions) {\n const w = weights[d.name] ?? 0;\n weightedScore += d.score * w;\n }\n\n // Direct reasoning override: 2+ reasoning markers in the USER prompt = high\n // confidence REASONING. The system prompt is never read here, so a host\n // instruction like \"think step by step\" cannot lift every query to REASONING.\n // The reasoning dimension already counted those matches; its score is 1.0\n // exactly when two or more matched.\n if (reasoningDimension.score === 1.0) {\n const confidence = calibrateConfidence(\n Math.max(weightedScore, 0.3), // ensure positive for confidence calc\n config.confidenceSteepness,\n );\n return {\n score: weightedScore,\n tier: \"REASONING\",\n confidence: Math.max(confidence, 0.85),\n signals,\n agenticScore,\n dimensions,\n };\n }\n\n // Map weighted score to tier using boundaries\n const { simpleMedium, mediumComplex, complexReasoning } = config.tierBoundaries;\n let tier: Tier;\n let distanceFromBoundary: number;\n\n if (weightedScore < simpleMedium) {\n tier = \"SIMPLE\";\n distanceFromBoundary = simpleMedium - weightedScore;\n } else if (weightedScore < mediumComplex) {\n tier = \"MEDIUM\";\n distanceFromBoundary = Math.min(weightedScore - simpleMedium, mediumComplex - weightedScore);\n } else if (weightedScore < complexReasoning) {\n tier = \"COMPLEX\";\n distanceFromBoundary = Math.min(\n weightedScore - mediumComplex,\n complexReasoning - weightedScore,\n );\n } else {\n tier = \"REASONING\";\n distanceFromBoundary = weightedScore - complexReasoning;\n }\n\n // Calibrate confidence via sigmoid of distance from nearest boundary\n const confidence = calibrateConfidence(distanceFromBoundary, config.confidenceSteepness);\n\n // If confidence is below threshold → ambiguous\n if (confidence < config.confidenceThreshold) {\n return { score: weightedScore, tier: null, confidence, signals, agenticScore, dimensions };\n }\n\n return { score: weightedScore, tier, confidence, signals, agenticScore, dimensions };\n}\n\n/**\n * Sigmoid confidence calibration.\n * Maps distance from tier boundary to [0.5, 1.0] confidence range.\n */\nfunction calibrateConfidence(distance: number, steepness: number): number {\n return 1 / (1 + Math.exp(-steepness * distance));\n}\n","/**\n * Tier → Model Selection\n *\n * Maps a classification tier to the cheapest capable model.\n * Builds RoutingDecision metadata with cost estimates and savings.\n */\n\nimport type { Tier, TierConfig, RoutingDecision } from \"./types.js\";\n\nexport type ModelPricing = {\n inputPrice: number; // per 1M tokens\n outputPrice: number; // per 1M tokens\n /** Active promo flat price per request (overrides token-based pricing when set) */\n flatPrice?: number;\n};\n\n// The savings baseline is a price anchor, not \"the current flagship\" — it is\n// deliberately NOT bumped every time a new Opus ships. Opus 4.7, 4.8 and 5 all\n// bill $5/$25, so moving it would change no reported number while breaking\n// comparability with historical journal entries. Only move it if the Opus tier\n// itself is repriced.\nconst BASELINE_MODEL_ID = \"anthropic/claude-opus-4.7\";\n\n// Hardcoded fallback: Claude Opus 4.7 pricing (per 1M tokens)\n// Used when baseline model not found in dynamic pricing map\nconst BASELINE_INPUT_PRICE = 5.0;\nconst BASELINE_OUTPUT_PRICE = 25.0;\n\n/**\n * The pricing entry, or undefined when any field it carries is not a finite,\n * non-negative number. A hand-built price map with a NaN would otherwise put\n * NaN into costEstimate and savings; a malformed price is an unknown price.\n */\nexport function usablePricing(pricing: ModelPricing | undefined): ModelPricing | undefined {\n if (!pricing) return undefined;\n const ok = (value: number | undefined) =>\n value === undefined || (Number.isFinite(value) && value >= 0);\n if (pricing.flatPrice !== undefined) return ok(pricing.flatPrice) ? pricing : undefined;\n return ok(pricing.inputPrice) && ok(pricing.outputPrice) ? pricing : undefined;\n}\n\n/** Raw token cost (no margin, no floor), or the flat promo price when one is set. */\nfunction rawCost(\n pricing: ModelPricing | undefined,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n): number {\n if (pricing?.flatPrice !== undefined) return pricing.flatPrice;\n const inputPrice = pricing?.inputPrice ?? 0;\n const outputPrice = pricing?.outputPrice ?? 0;\n return (estimatedInputTokens / 1_000_000) * inputPrice + (maxOutputTokens / 1_000_000) * outputPrice;\n}\n\n/** What the anchor Opus tier would cost for the same request (see BASELINE_MODEL_ID). */\nfunction baselineCostFor(\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n): number {\n const opusPricing = usablePricing(modelPricing.get(BASELINE_MODEL_ID));\n const inputPrice = opusPricing?.inputPrice ?? BASELINE_INPUT_PRICE;\n const outputPrice = opusPricing?.outputPrice ?? BASELINE_OUTPUT_PRICE;\n return (estimatedInputTokens / 1_000_000) * inputPrice + (maxOutputTokens / 1_000_000) * outputPrice;\n}\n\n/**\n * Fractional savings against the baseline. Premium reports none (it is about\n * quality, not cost), and a model the host has no price for costs an unknown\n * amount, not nothing: reporting its savings as 100% would be a fabricated\n * figure.\n */\nfunction savingsFor(\n costEstimate: number,\n baselineCost: number,\n pricing: ModelPricing | undefined,\n routingProfile: string | undefined,\n): number {\n if (routingProfile === \"premium\" || pricing === undefined || !(baselineCost > 0)) return 0;\n return Math.max(0, (baselineCost - costEstimate) / baselineCost);\n}\n\n/**\n * Select the primary model for a tier and build the RoutingDecision.\n *\n * Cost contract: the estimates here are raw token economics — no server\n * margin, no minimum-payment floor. `calculateModelCost` below applies both\n * to match the actual x402 charge, and hosts that display money (ClawRouter's\n * proxy does) recompute through it rather than reading these fields. Folding\n * the margin in here would double-apply it in every such host.\n */\nexport function selectModel(\n tier: Tier,\n confidence: number,\n method: \"rules\" | \"llm\" | \"portfolio\",\n reasoning: string,\n tierConfigs: Record,\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n routingProfile?: \"free\" | \"eco\" | \"auto\" | \"premium\",\n agenticScore?: number,\n): RoutingDecision {\n const tierConfig = tierConfigs[tier];\n const model = tierConfig.primary;\n const pricing = usablePricing(modelPricing.get(model));\n\n const costEstimate = rawCost(pricing, estimatedInputTokens, maxOutputTokens);\n const baselineCost = baselineCostFor(modelPricing, estimatedInputTokens, maxOutputTokens);\n const savings = savingsFor(costEstimate, baselineCost, pricing, routingProfile);\n\n return {\n model,\n tier,\n confidence,\n method,\n reasoning,\n costEstimate,\n baselineCost,\n savings,\n ...(agenticScore !== undefined && { agenticScore }),\n };\n}\n\n/**\n * Get the ordered fallback chain for a tier: [primary, ...fallbacks].\n */\nexport function getFallbackChain(tier: Tier, tierConfigs: Record): string[] {\n const config = tierConfigs[tier];\n return [config.primary, ...config.fallback];\n}\n\n// Server-side margin applied to all x402 payments (must match blockrun server's MARGIN_PERCENT)\nconst SERVER_MARGIN_PERCENT = 5;\n// Minimum payment enforced by CDP Facilitator (must match blockrun server's MIN_PAYMENT_USD)\nconst MIN_PAYMENT_USD = 0.001;\n\n/**\n * Calculate charge-accurate cost fields for a specific model (server margin\n * and minimum-payment floor included — see the cost contract on selectModel).\n * Hosts call this to display money and to recost a decision after a fallback.\n */\nexport function calculateModelCost(\n model: string,\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n routingProfile?: \"free\" | \"eco\" | \"auto\" | \"premium\",\n): { costEstimate: number; baselineCost: number; savings: number } {\n const pricing = usablePricing(modelPricing.get(model));\n\n // Server margin + minimum payment, to match the actual x402 charge.\n const costEstimate = Math.max(\n rawCost(pricing, estimatedInputTokens, maxOutputTokens) * (1 + SERVER_MARGIN_PERCENT / 100),\n MIN_PAYMENT_USD,\n );\n const baselineCost = baselineCostFor(modelPricing, estimatedInputTokens, maxOutputTokens);\n const savings = savingsFor(costEstimate, baselineCost, pricing, routingProfile);\n\n return { costEstimate, baselineCost, savings };\n}\n\n/** The models satisfying `keep`, or every model when none does. */\nfunction keepOrFailOpen(models: string[], keep: (modelId: string) => boolean): string[] {\n const filtered = models.filter(keep);\n return filtered.length > 0 ? filtered : models;\n}\n\n/**\n * Filter a model list to only those that support tool calling.\n * When hasTools is false, returns the list unchanged.\n * When all models lack tool calling support, returns the full list as a fallback\n * (better to let the API error than produce an empty chain).\n */\nexport function filterByToolCalling(\n models: string[],\n hasTools: boolean,\n supportsToolCalling: (modelId: string) => boolean,\n): string[] {\n return hasTools ? keepOrFailOpen(models, supportsToolCalling) : models;\n}\n\n/**\n * Filter a model list to only those that support vision (image inputs).\n * When hasVision is false, returns the list unchanged.\n * When all models lack vision support, returns the full list as a fallback\n * (better to let the API error than produce an empty chain).\n */\nexport function filterByVision(\n models: string[],\n hasVision: boolean,\n supportsVision: (modelId: string) => boolean,\n): string[] {\n return hasVision ? keepOrFailOpen(models, supportsVision) : models;\n}\n\n/**\n * Filter a model list to remove user-excluded models.\n * When all models are excluded, returns the full list as a fallback\n * (same safety pattern as filterByToolCalling/filterByVision).\n */\nexport function filterByExcludeList(models: string[], excludeList: Set): string[] {\n if (excludeList.size === 0) return models;\n return keepOrFailOpen(models, (m) => !excludeList.has(m));\n}\n\n/**\n * Get the fallback chain filtered by context length.\n * Only returns models that can handle the estimated total context.\n *\n * @param tier - The tier to get fallback chain for\n * @param tierConfigs - Tier configurations\n * @param estimatedTotalTokens - Estimated total context (input + output)\n * @param getContextWindow - Function to get context window for a model ID\n * @returns Filtered list of models that can handle the context\n */\nexport function getFallbackChainFiltered(\n tier: Tier,\n tierConfigs: Record,\n estimatedTotalTokens: number,\n getContextWindow: (modelId: string) => number | undefined,\n): string[] {\n const fullChain = getFallbackChain(tier, tierConfigs);\n\n // Filter to models that can handle the context\n const filtered = fullChain.filter((modelId) => {\n const contextWindow = getContextWindow(modelId);\n if (contextWindow === undefined) {\n // Unknown model - include it (let API reject if needed)\n return true;\n }\n // Add 10% buffer for safety\n return contextWindow >= estimatedTotalTokens * 1.1;\n });\n\n // If all models filtered out, return the original chain\n // (let the API error out - better than no options)\n if (filtered.length === 0) {\n return fullChain;\n }\n\n return filtered;\n}\n\n/**\n * Filter an already-ranked candidate list by total context and requested output.\n * Unlike the legacy tier helper, this supports the V3 portfolio order.\n */\nexport function filterCandidatesByCapacity(\n models: string[],\n estimatedInputTokens: number,\n requestedOutputTokens: number,\n getCapabilities: (modelId: string) => { contextWindow: number; maxOutput: number } | undefined,\n): string[] {\n const filtered = models.filter((modelId) => {\n const capabilities = getCapabilities(modelId);\n if (!capabilities) return true;\n return (\n capabilities.contextWindow >= (estimatedInputTokens + requestedOutputTokens) * 1.1 &&\n capabilities.maxOutput >= requestedOutputTokens\n );\n });\n return filtered;\n}\n","/**\n * Request-size helpers shared by the rules and portfolio strategies.\n *\n * The router never tokenizes — it is on the hot path and model-agnostic — so\n * sizes are estimates. The estimate only has to be honest enough for the\n * decisions that consume it: the long-context task type, the COMPLEX\n * override and the per-model capacity filter.\n */\n\n// Han, kana, Hangul, CJK punctuation and fullwidth forms. Every production\n// tokenizer spends roughly one token per character here, so the Latin\n// four-characters-per-token rule under-counts these scripts about fourfold:\n// a 200k-character Chinese contract would read as 50k tokens, slip under the\n// 80k long-context boundary and pass the capacity filter for models that\n// cannot hold it.\nconst CJK_CHARS = /[ -ヿ㐀-䶿一-鿿가-힯豈-﫿＀-￯]/g;\n\n/** Approximate token count: one per CJK character, one per four of anything else. */\nexport function estimateTokens(text: string): number {\n if (text.length === 0) return 0;\n const cjk = text.match(CJK_CHARS)?.length ?? 0;\n return cjk + Math.ceil((text.length - cjk) / 4);\n}\n\nconst MAX_SCAN_CHARS = 8_000;\n\n/** The scan window the feature regexes read, bounded so a pasted document cannot stall routing. */\nexport function scanLimit(promptTruncationChars: number): number {\n if (!Number.isFinite(promptTruncationChars)) return MAX_SCAN_CHARS;\n return Math.max(1, Math.min(MAX_SCAN_CHARS, Math.floor(promptTruncationChars)));\n}\n\n\n/**\n * Feature regexes need request shape and intent, not the entire document.\n * Sample both ends so a long pasted artifact keeps the task instruction at\n * either boundary, while the full length still drives capacity decisions.\n */\nexport function sampleForScan(value: string, limit: number): string {\n if (value.length <= limit) return value;\n const prefixLength = Math.ceil(limit / 2);\n const suffixLength = limit - prefixLength;\n // slice(-0) is the whole string, so a one-character limit needs its own case.\n if (suffixLength <= 0) return value.slice(0, prefixLength);\n return `${value.slice(0, prefixLength)}\\n${value.slice(-suffixLength)}`;\n}\n","/**\n * Router Strategy Registry\n *\n * Pluggable strategy system for request routing.\n * Default: RulesStrategy — identical to the original inline route() logic, <1ms.\n */\n\nimport type {\n Tier,\n TierConfig,\n Promotion,\n RoutingDecision,\n RouterStrategy,\n RouterOptions,\n} from \"./types.js\";\nimport { classifyByRules } from \"./rules.js\";\nimport { selectModel } from \"./selector.js\";\nimport { estimateTokens, sampleForScan, scanLimit } from \"./tokens.js\";\n\n/**\n * Apply active time-windowed promotions to tier configs.\n * Returns a new tierConfigs object with promotion overrides merged in.\n * Expired or not-yet-active promotions are ignored.\n */\nfunction applyPromotions(\n tierConfigs: Record,\n promotions: Promotion[] | undefined,\n profile: \"auto\" | \"eco\" | \"premium\" | \"agentic\",\n now: Date = new Date(),\n): Record {\n if (!promotions || promotions.length === 0) return tierConfigs;\n\n let result = tierConfigs;\n for (const promo of promotions) {\n // Check time window\n // An unparseable date compares false both ways, which used to make the\n // promotion active forever. A window that cannot be read is not a window.\n const start = Date.parse(promo.startDate);\n const end = Date.parse(promo.endDate);\n if (!Number.isFinite(start) || !Number.isFinite(end)) continue;\n if (now.getTime() < start || now.getTime() >= end) continue;\n\n // Check profile filter\n if (promo.profiles && !promo.profiles.includes(profile)) continue;\n\n // Shallow-clone on first mutation\n if (result === tierConfigs) {\n result = { ...tierConfigs };\n for (const t of Object.keys(result) as Tier[]) {\n result[t] = { ...result[t] };\n }\n }\n\n // Merge overrides\n for (const [tier, override] of Object.entries(promo.tierOverrides) as [\n Tier,\n Partial,\n ][]) {\n if (!result[tier]) continue;\n if (override.primary) result[tier].primary = override.primary;\n if (override.fallback) result[tier].fallback = override.fallback;\n }\n }\n\n return result;\n}\n\n/**\n * Remove host-declared-dead models from every tier chain, promoting the first\n * surviving rung to primary. A tier whose chain is entirely dead keeps its\n * original config — the router has nothing live to offer there, and inventing\n * a model would hide the outage from the host that reported it.\n */\nexport function applyUnavailableModels(\n tierConfigs: Record,\n unavailableModels: readonly string[] | undefined,\n): Record {\n if (!unavailableModels || unavailableModels.length === 0) return tierConfigs;\n const dead = new Set(unavailableModels);\n let result = tierConfigs;\n for (const tier of Object.keys(tierConfigs) as Tier[]) {\n const config = tierConfigs[tier];\n const alive = [config.primary, ...config.fallback].filter((model) => !dead.has(model));\n if (alive.length === 0 || (alive[0] === config.primary && alive.length === config.fallback.length + 1)) {\n continue;\n }\n if (result === tierConfigs) result = { ...tierConfigs };\n result[tier] = { primary: alive[0], fallback: alive.slice(1) };\n }\n return result;\n}\n\n/**\n * Rules-based routing strategy.\n * Extracted from the original route() in index.ts — logic is identical.\n * Attaches tierConfigs and profile to the decision for downstream use.\n */\nexport class RulesStrategy implements RouterStrategy {\n readonly name = \"rules\";\n\n route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n ): RoutingDecision {\n const { config, modelPricing } = options;\n\n const fullText = `${systemPrompt ?? \"\"} ${prompt}`;\n const estimatedTokens = estimateTokens(fullText);\n const limit = scanLimit(config.classifier.promptTruncationChars);\n const scannedPrompt = sampleForScan(prompt, limit);\n const scannedSystemPrompt = systemPrompt ? sampleForScan(systemPrompt, limit) : undefined;\n\n // --- Rule-based classification (runs first to get agenticScore) ---\n const ruleResult = classifyByRules(\n scannedPrompt,\n scannedSystemPrompt,\n estimatedTokens,\n config.scoring,\n );\n\n // --- Select tier configs based on routing profile ---\n const { routingProfile } = options;\n let tierConfigs: Record;\n let profileSuffix: string;\n let profile: NonNullable;\n\n if (routingProfile === \"eco\") {\n // `ecoTiers: null` explicitly disables the special eco tier set while\n // keeping eco routing semantics. Fall back to regular tiers instead of\n // dropping into auto routing (which could select agentic tiers).\n tierConfigs = config.ecoTiers ?? config.tiers;\n profileSuffix = config.ecoTiers ? \" | eco\" : \" | eco (default tiers)\";\n profile = \"eco\";\n } else if (routingProfile === \"premium\") {\n // `premiumTiers: null` disables the premium-specific tier set but the\n // request is still a premium-profile request, so use regular tiers while\n // preserving premium metadata/cost semantics.\n tierConfigs = config.premiumTiers ?? config.tiers;\n profileSuffix = config.premiumTiers ? \" | premium\" : \" | premium (default tiers)\";\n profile = \"premium\";\n } else {\n // Auto profile (or undefined): intelligent routing with agentic detection.\n //\n // `agenticMode` semantics:\n // - `true` → force agentic tiers (ignore heuristics)\n // - `false` → disable agentic tiers entirely (even if tools are present)\n // - `undefined` → auto-detect via heuristics (tools present OR high agenticScore)\n const agenticScore = ruleResult.agenticScore ?? 0;\n const isAutoAgentic = agenticScore >= 0.5;\n const agenticModeSetting = config.overrides.agenticMode;\n const hasToolsInRequest = options.requiresTools ?? options.hasTools ?? false;\n let useAgenticTiers: boolean;\n if (agenticModeSetting === false) {\n // Explicitly disabled — never use agentic tiers\n useAgenticTiers = false;\n } else if (agenticModeSetting === true) {\n // Explicitly enabled — use agentic tiers if available\n useAgenticTiers = config.agenticTiers != null;\n } else {\n // Auto-detect\n useAgenticTiers = (hasToolsInRequest || isAutoAgentic) && config.agenticTiers != null;\n }\n tierConfigs = useAgenticTiers ? config.agenticTiers! : config.tiers;\n profileSuffix = useAgenticTiers ? ` | agentic${hasToolsInRequest ? \" (tools)\" : \"\"}` : \"\";\n profile = useAgenticTiers ? \"agentic\" : \"auto\";\n }\n\n // Apply time-windowed promotions\n tierConfigs = applyPromotions(tierConfigs, config.promotions, profile, options.now);\n\n // Hard-remove models the host has observed dead at the gateway. After\n // promotions, so a promo cannot resurrect a rung the host just killed.\n tierConfigs = applyUnavailableModels(tierConfigs, options.unavailableModels);\n\n const agenticScoreValue = ruleResult.agenticScore;\n\n // --- Override: large context → force COMPLEX ---\n if (estimatedTokens > config.overrides.maxTokensForceComplex) {\n const decision = selectModel(\n \"COMPLEX\",\n 0.95,\n \"rules\",\n `Input exceeds ${config.overrides.maxTokensForceComplex} tokens${profileSuffix}`,\n tierConfigs,\n modelPricing,\n estimatedTokens,\n maxOutputTokens,\n routingProfile,\n agenticScoreValue,\n );\n return { ...decision, tierConfigs, profile };\n }\n\n // Structured output is a protocol fact the host states (`response_format`\n // → requiresStructuredOutput). It used to be inferred from the system\n // prompt as well, but agent hosts describe their tool schemas there on\n // every turn, which upgraded every one of their requests off SIMPLE.\n const hasStructuredOutput = options.requiresStructuredOutput === true;\n\n let tier: Tier;\n let confidence: number;\n const method: \"rules\" | \"llm\" = \"rules\";\n let reasoning = `score=${ruleResult.score.toFixed(2)} | ${ruleResult.signals.join(\", \")}`;\n\n if (ruleResult.tier !== null) {\n tier = ruleResult.tier;\n confidence = ruleResult.confidence;\n } else {\n // Ambiguous — default to configurable tier (no external API call)\n tier = config.overrides.ambiguousDefaultTier;\n confidence = 0.5;\n reasoning += ` | ambiguous -> default: ${tier}`;\n }\n\n // Apply structured output minimum tier\n if (hasStructuredOutput) {\n const tierRank: Record = { SIMPLE: 0, MEDIUM: 1, COMPLEX: 2, REASONING: 3 };\n const minTier = config.overrides.structuredOutputMinTier;\n if (tierRank[tier] < tierRank[minTier]) {\n reasoning += ` | upgraded to ${minTier} (structured output)`;\n tier = minTier;\n }\n }\n\n // Add routing profile suffix to reasoning\n reasoning += profileSuffix;\n\n const decision = selectModel(\n tier,\n confidence,\n method,\n reasoning,\n tierConfigs,\n modelPricing,\n estimatedTokens,\n maxOutputTokens,\n routingProfile,\n agenticScoreValue,\n );\n return { ...decision, tierConfigs, profile };\n }\n}\n\n// --- Strategy Registry ---\n\nconst registry = new Map();\nregistry.set(\"rules\", new RulesStrategy());\n\nexport function getStrategy(name: string): RouterStrategy {\n const strategy = registry.get(name);\n if (!strategy) {\n throw new Error(`Unknown routing strategy: ${name}`);\n }\n return strategy;\n}\n\nexport function registerStrategy(strategy: RouterStrategy): void {\n registry.set(strategy.name, strategy);\n}\n","/**\n * Default Routing Config\n *\n * All routing parameters as a TypeScript constant.\n * Operators override via openclaw.yaml plugin config.\n *\n * Scoring uses 15 weighted dimensions with sigmoid confidence calibration.\n */\n\nimport type { RoutingConfig } from \"./types.js\";\n\nexport const DEFAULT_ROUTING_CONFIG: RoutingConfig = {\n version: \"3.5\",\n strategy: \"portfolio\",\n portfolio: {\n auto: {\n quality: 0.47,\n capability: 0.2,\n cost: 0.18,\n speed: 0.07,\n reliability: 0.03,\n legacy: 0.05,\n },\n eco: {\n quality: 0.36,\n capability: 0.2,\n cost: 0.28,\n speed: 0.1,\n reliability: 0.04,\n legacy: 0.02,\n },\n premium: {\n quality: 0.58,\n capability: 0.2,\n cost: 0.08,\n speed: 0.06,\n reliability: 0.06,\n legacy: 0.02,\n },\n highStakesBoost: { quality: 0.08, reliability: 0.05 },\n latencySensitiveSpeedBoost: 0.08,\n affinityFloorGap: { auto: 0.1, eco: 0.22, premium: 0.05 },\n },\n\n classifier: {\n // gemini-2.5-flash until Google retired it on 2026-12-01 (the gateways\n // redirect it to 3.5 Flash-Lite). Nothing in this package or ClawRouter\n // reads llmModel today. Before wiring it, note that 3.5 Flash-Lite always\n // thinks (it rejects a thinking budget of 0), so llmMaxTokens 10 may be\n // spent on reasoning before any label is emitted.\n llmModel: \"google/gemini-3.5-flash-lite\",\n llmMaxTokens: 10,\n llmTemperature: 0,\n promptTruncationChars: 500,\n cacheTtlMs: 3_600_000, // 1 hour\n },\n\n scoring: {\n tokenCountThresholds: { simple: 50, complex: 500 },\n\n // Multilingual keywords: EN + ZH + JA + RU + DE + ES + PT + KO + AR\n codeKeywords: [\n // English\n \"function\",\n \"class\",\n \"import\",\n \"def\",\n \"SELECT\",\n \"async\",\n \"await\",\n \"const\",\n \"let\",\n \"var\",\n \"return\",\n \"```\",\n // Chinese\n \"函数\",\n \"类\",\n \"导入\",\n \"定义\",\n \"查询\",\n \"异步\",\n \"等待\",\n \"常量\",\n \"变量\",\n \"返回\",\n // Japanese\n \"関数\",\n \"クラス\",\n \"インポート\",\n \"非同期\",\n \"定数\",\n \"変数\",\n // Russian\n \"функция\",\n \"класс\",\n \"импорт\",\n \"определ\",\n \"запрос\",\n \"асинхронный\",\n \"ожидать\",\n \"константа\",\n \"переменная\",\n \"вернуть\",\n // German\n \"funktion\",\n \"klasse\",\n \"importieren\",\n \"definieren\",\n \"abfrage\",\n \"asynchron\",\n \"erwarten\",\n \"konstante\",\n \"variable\",\n \"zurückgeben\",\n // Spanish\n \"función\",\n \"clase\",\n \"importar\",\n \"definir\",\n \"consulta\",\n \"asíncrono\",\n \"esperar\",\n \"constante\",\n \"variable\",\n \"retornar\",\n // Portuguese\n \"função\",\n \"classe\",\n \"importar\",\n \"definir\",\n \"consulta\",\n \"assíncrono\",\n \"aguardar\",\n \"constante\",\n \"variável\",\n \"retornar\",\n // Korean\n \"함수\",\n \"클래스\",\n \"가져오기\",\n \"정의\",\n \"쿼리\",\n \"비동기\",\n \"대기\",\n \"상수\",\n \"변수\",\n \"반환\",\n // Arabic\n \"دالة\",\n \"فئة\",\n \"استيراد\",\n \"تعريف\",\n \"استعلام\",\n \"غير متزامن\",\n \"انتظار\",\n \"ثابت\",\n \"متغير\",\n \"إرجاع\",\n ],\n reasoningKeywords: [\n // English\n \"prove\",\n \"theorem\",\n \"derive\",\n \"step by step\",\n \"chain of thought\",\n \"formally\",\n \"mathematical\",\n \"proof\",\n \"logically\",\n // Chinese\n \"证明\",\n \"定理\",\n \"推导\",\n \"逐步\",\n \"思维链\",\n \"形式化\",\n \"数学\",\n \"逻辑\",\n // Japanese\n \"証明\",\n \"定理\",\n \"導出\",\n \"ステップバイステップ\",\n \"論理的\",\n // Russian\n \"доказать\",\n \"докажи\",\n \"доказательств\",\n \"теорема\",\n \"вывести\",\n \"шаг за шагом\",\n \"пошагово\",\n \"поэтапно\",\n \"цепочка рассуждений\",\n \"рассуждени\",\n \"формально\",\n \"математически\",\n \"логически\",\n // German\n \"beweisen\",\n \"beweis\",\n \"theorem\",\n \"ableiten\",\n \"schritt für schritt\",\n \"gedankenkette\",\n \"formal\",\n \"mathematisch\",\n \"logisch\",\n // Spanish\n \"demostrar\",\n \"teorema\",\n \"derivar\",\n \"paso a paso\",\n \"cadena de pensamiento\",\n \"formalmente\",\n \"matemático\",\n \"prueba\",\n \"lógicamente\",\n // Portuguese\n \"provar\",\n \"teorema\",\n \"derivar\",\n \"passo a passo\",\n \"cadeia de pensamento\",\n \"formalmente\",\n \"matemático\",\n \"prova\",\n \"logicamente\",\n // Korean\n \"증명\",\n \"정리\",\n \"도출\",\n \"단계별\",\n \"사고의 연쇄\",\n \"형식적\",\n \"수학적\",\n \"논리적\",\n // Arabic\n \"إثبات\",\n \"نظرية\",\n \"اشتقاق\",\n \"خطوة بخطوة\",\n \"سلسلة التفكير\",\n \"رسمياً\",\n \"رياضي\",\n \"برهان\",\n \"منطقياً\",\n ],\n simpleKeywords: [\n // English\n \"what is\",\n \"define\",\n \"translate\",\n \"hello\",\n \"yes or no\",\n \"capital of\",\n \"how old\",\n \"who is\",\n \"when was\",\n // Chinese\n \"什么是\",\n \"定义\",\n \"翻译\",\n \"你好\",\n \"是否\",\n \"首都\",\n \"多大\",\n \"谁是\",\n \"何时\",\n // Japanese\n \"とは\",\n \"定義\",\n \"翻訳\",\n \"こんにちは\",\n \"はいかいいえ\",\n \"首都\",\n \"誰\",\n // Russian\n \"что такое\",\n \"определение\",\n \"перевести\",\n \"переведи\",\n \"привет\",\n \"да или нет\",\n \"столица\",\n \"сколько лет\",\n \"кто такой\",\n \"когда\",\n \"объясни\",\n // German\n \"was ist\",\n \"definiere\",\n \"übersetze\",\n \"hallo\",\n \"ja oder nein\",\n \"hauptstadt\",\n \"wie alt\",\n \"wer ist\",\n \"wann\",\n \"erkläre\",\n // Spanish\n \"qué es\",\n \"definir\",\n \"traducir\",\n \"hola\",\n \"sí o no\",\n \"capital de\",\n \"cuántos años\",\n \"quién es\",\n \"cuándo\",\n // Portuguese\n \"o que é\",\n \"definir\",\n \"traduzir\",\n \"olá\",\n \"sim ou não\",\n \"capital de\",\n \"quantos anos\",\n \"quem é\",\n \"quando\",\n // Korean\n \"무엇\",\n \"정의\",\n \"번역\",\n \"안녕하세요\",\n \"예 또는 아니오\",\n \"수도\",\n \"누구\",\n \"언제\",\n // Arabic\n \"ما هو\",\n \"تعريف\",\n \"ترجم\",\n \"مرحبا\",\n \"نعم أو لا\",\n \"عاصمة\",\n \"من هو\",\n \"متى\",\n ],\n technicalKeywords: [\n // English\n \"algorithm\",\n \"optimize\",\n \"architecture\",\n \"distributed\",\n \"kubernetes\",\n \"microservice\",\n \"database\",\n \"infrastructure\",\n // Chinese\n \"算法\",\n \"优化\",\n \"架构\",\n \"分布式\",\n \"微服务\",\n \"数据库\",\n \"基础设施\",\n // Japanese\n \"アルゴリズム\",\n \"最適化\",\n \"アーキテクチャ\",\n \"分散\",\n \"マイクロサービス\",\n \"データベース\",\n // Russian\n \"алгоритм\",\n \"оптимизировать\",\n \"оптимизаци\",\n \"оптимизируй\",\n \"архитектура\",\n \"распределённый\",\n \"микросервис\",\n \"база данных\",\n \"инфраструктура\",\n // German\n \"algorithmus\",\n \"optimieren\",\n \"architektur\",\n \"verteilt\",\n \"kubernetes\",\n \"mikroservice\",\n \"datenbank\",\n \"infrastruktur\",\n // Spanish\n \"algoritmo\",\n \"optimizar\",\n \"arquitectura\",\n \"distribuido\",\n \"microservicio\",\n \"base de datos\",\n \"infraestructura\",\n // Portuguese\n \"algoritmo\",\n \"otimizar\",\n \"arquitetura\",\n \"distribuído\",\n \"microsserviço\",\n \"banco de dados\",\n \"infraestrutura\",\n // Korean\n \"알고리즘\",\n \"최적화\",\n \"아키텍처\",\n \"분산\",\n \"마이크로서비스\",\n \"데이터베이스\",\n \"인프라\",\n // Arabic\n \"خوارزمية\",\n \"تحسين\",\n \"بنية\",\n \"موزع\",\n \"خدمة مصغرة\",\n \"قاعدة بيانات\",\n \"بنية تحتية\",\n ],\n creativeKeywords: [\n // English\n \"story\",\n \"poem\",\n \"compose\",\n \"brainstorm\",\n \"creative\",\n \"imagine\",\n \"write a\",\n // Chinese\n \"故事\",\n \"诗\",\n \"创作\",\n \"头脑风暴\",\n \"创意\",\n \"想象\",\n \"写一个\",\n // Japanese\n \"物語\",\n \"詩\",\n \"作曲\",\n \"ブレインストーム\",\n \"創造的\",\n \"想像\",\n // Russian\n \"история\",\n \"рассказ\",\n \"стихотворение\",\n \"сочинить\",\n \"сочини\",\n \"мозговой штурм\",\n \"творческий\",\n \"представить\",\n \"придумай\",\n \"напиши\",\n // German\n \"geschichte\",\n \"gedicht\",\n \"komponieren\",\n \"brainstorming\",\n \"kreativ\",\n \"vorstellen\",\n \"schreibe\",\n \"erzählung\",\n // Spanish\n \"historia\",\n \"poema\",\n \"componer\",\n \"lluvia de ideas\",\n \"creativo\",\n \"imaginar\",\n \"escribe\",\n // Portuguese\n \"história\",\n \"poema\",\n \"compor\",\n \"criativo\",\n \"imaginar\",\n \"escreva\",\n // Korean\n \"이야기\",\n \"시\",\n \"작곡\",\n \"브레인스토밍\",\n \"창의적\",\n \"상상\",\n \"작성\",\n // Arabic\n \"قصة\",\n \"قصيدة\",\n \"تأليف\",\n \"عصف ذهني\",\n \"إبداعي\",\n \"تخيل\",\n \"اكتب\",\n ],\n\n // New dimension keyword lists (multilingual)\n imperativeVerbs: [\n // English\n \"build\",\n \"create\",\n \"implement\",\n \"design\",\n \"develop\",\n \"construct\",\n \"generate\",\n \"deploy\",\n \"configure\",\n \"set up\",\n // Chinese\n \"构建\",\n \"创建\",\n \"实现\",\n \"设计\",\n \"开发\",\n \"生成\",\n \"部署\",\n \"配置\",\n \"设置\",\n // Japanese\n \"構築\",\n \"作成\",\n \"実装\",\n \"設計\",\n \"開発\",\n \"生成\",\n \"デプロイ\",\n \"設定\",\n // Russian\n \"построить\",\n \"построй\",\n \"создать\",\n \"создай\",\n \"реализовать\",\n \"реализуй\",\n \"спроектировать\",\n \"разработать\",\n \"разработай\",\n \"сконструировать\",\n \"сгенерировать\",\n \"сгенерируй\",\n \"развернуть\",\n \"разверни\",\n \"настроить\",\n \"настрой\",\n // German\n \"erstellen\",\n \"bauen\",\n \"implementieren\",\n \"entwerfen\",\n \"entwickeln\",\n \"konstruieren\",\n \"generieren\",\n \"bereitstellen\",\n \"konfigurieren\",\n \"einrichten\",\n // Spanish\n \"construir\",\n \"crear\",\n \"implementar\",\n \"diseñar\",\n \"desarrollar\",\n \"generar\",\n \"desplegar\",\n \"configurar\",\n // Portuguese\n \"construir\",\n \"criar\",\n \"implementar\",\n \"projetar\",\n \"desenvolver\",\n \"gerar\",\n \"implantar\",\n \"configurar\",\n // Korean\n \"구축\",\n \"생성\",\n \"구현\",\n \"설계\",\n \"개발\",\n \"배포\",\n \"설정\",\n // Arabic\n \"بناء\",\n \"إنشاء\",\n \"تنفيذ\",\n \"تصميم\",\n \"تطوير\",\n \"توليد\",\n \"نشر\",\n \"إعداد\",\n ],\n constraintIndicators: [\n // English\n \"under\",\n \"at most\",\n \"at least\",\n \"within\",\n \"no more than\",\n \"o(\",\n \"maximum\",\n \"minimum\",\n \"limit\",\n \"budget\",\n // Chinese\n \"不超过\",\n \"至少\",\n \"最多\",\n \"在内\",\n \"最大\",\n \"最小\",\n \"限制\",\n \"预算\",\n // Japanese\n \"以下\",\n \"最大\",\n \"最小\",\n \"制限\",\n \"予算\",\n // Russian\n \"не более\",\n \"не менее\",\n \"как минимум\",\n \"в пределах\",\n \"максимум\",\n \"минимум\",\n \"ограничение\",\n \"бюджет\",\n // German\n \"höchstens\",\n \"mindestens\",\n \"innerhalb\",\n \"nicht mehr als\",\n \"maximal\",\n \"minimal\",\n \"grenze\",\n \"budget\",\n // Spanish\n \"como máximo\",\n \"al menos\",\n \"dentro de\",\n \"no más de\",\n \"máximo\",\n \"mínimo\",\n \"límite\",\n \"presupuesto\",\n // Portuguese\n \"no máximo\",\n \"pelo menos\",\n \"dentro de\",\n \"não mais que\",\n \"máximo\",\n \"mínimo\",\n \"limite\",\n \"orçamento\",\n // Korean\n \"이하\",\n \"이상\",\n \"최대\",\n \"최소\",\n \"제한\",\n \"예산\",\n // Arabic\n \"على الأكثر\",\n \"على الأقل\",\n \"ضمن\",\n \"لا يزيد عن\",\n \"أقصى\",\n \"أدنى\",\n \"حد\",\n \"ميزانية\",\n ],\n outputFormatKeywords: [\n // English\n \"json\",\n \"yaml\",\n \"xml\",\n \"table\",\n \"csv\",\n \"markdown\",\n \"schema\",\n \"format as\",\n \"structured\",\n // Chinese\n \"表格\",\n \"格式化为\",\n \"结构化\",\n // Japanese\n \"テーブル\",\n \"フォーマット\",\n \"構造化\",\n // Russian\n \"таблица\",\n \"форматировать как\",\n \"структурированный\",\n // German\n \"tabelle\",\n \"formatieren als\",\n \"strukturiert\",\n // Spanish\n \"tabla\",\n \"formatear como\",\n \"estructurado\",\n // Portuguese\n \"tabela\",\n \"formatar como\",\n \"estruturado\",\n // Korean\n \"테이블\",\n \"형식\",\n \"구조화\",\n // Arabic\n \"جدول\",\n \"تنسيق\",\n \"منظم\",\n ],\n referenceKeywords: [\n // English\n \"above\",\n \"below\",\n \"previous\",\n \"following\",\n \"the docs\",\n \"the api\",\n \"the code\",\n \"earlier\",\n \"attached\",\n // Chinese\n \"上面\",\n \"下面\",\n \"之前\",\n \"接下来\",\n \"文档\",\n \"代码\",\n \"附件\",\n // Japanese\n \"上記\",\n \"下記\",\n \"前の\",\n \"次の\",\n \"ドキュメント\",\n \"コード\",\n // Russian\n \"выше\",\n \"ниже\",\n \"предыдущий\",\n \"следующий\",\n \"документация\",\n \"код\",\n \"ранее\",\n \"вложение\",\n // German\n \"oben\",\n \"unten\",\n \"vorherige\",\n \"folgende\",\n \"dokumentation\",\n \"der code\",\n \"früher\",\n \"anhang\",\n // Spanish\n \"arriba\",\n \"abajo\",\n \"anterior\",\n \"siguiente\",\n \"documentación\",\n \"el código\",\n \"adjunto\",\n // Portuguese\n \"acima\",\n \"abaixo\",\n \"anterior\",\n \"seguinte\",\n \"documentação\",\n \"o código\",\n \"anexo\",\n // Korean\n \"위\",\n \"아래\",\n \"이전\",\n \"다음\",\n \"문서\",\n \"코드\",\n \"첨부\",\n // Arabic\n \"أعلاه\",\n \"أدناه\",\n \"السابق\",\n \"التالي\",\n \"الوثائق\",\n \"الكود\",\n \"مرفق\",\n ],\n negationKeywords: [\n // English\n \"don't\",\n \"do not\",\n \"avoid\",\n \"never\",\n \"without\",\n \"except\",\n \"exclude\",\n \"no longer\",\n // Chinese\n \"不要\",\n \"避免\",\n \"从不\",\n \"没有\",\n \"除了\",\n \"排除\",\n // Japanese\n \"しないで\",\n \"避ける\",\n \"決して\",\n \"なしで\",\n \"除く\",\n // Russian\n \"не делай\",\n \"не надо\",\n \"нельзя\",\n \"избегать\",\n \"никогда\",\n \"без\",\n \"кроме\",\n \"исключить\",\n \"больше не\",\n // German\n \"nicht\",\n \"vermeide\",\n \"niemals\",\n \"ohne\",\n \"außer\",\n \"ausschließen\",\n \"nicht mehr\",\n // Spanish\n \"no hagas\",\n \"evitar\",\n \"nunca\",\n \"sin\",\n \"excepto\",\n \"excluir\",\n // Portuguese\n \"não faça\",\n \"evitar\",\n \"nunca\",\n \"sem\",\n \"exceto\",\n \"excluir\",\n // Korean\n \"하지 마\",\n \"피하다\",\n \"절대\",\n \"없이\",\n \"제외\",\n // Arabic\n \"لا تفعل\",\n \"تجنب\",\n \"أبداً\",\n \"بدون\",\n \"باستثناء\",\n \"استبعاد\",\n ],\n domainSpecificKeywords: [\n // English\n \"quantum\",\n \"fpga\",\n \"vlsi\",\n \"risc-v\",\n \"asic\",\n \"photonics\",\n \"genomics\",\n \"proteomics\",\n \"topological\",\n \"homomorphic\",\n \"zero-knowledge\",\n \"lattice-based\",\n // Chinese\n \"量子\",\n \"光子学\",\n \"基因组学\",\n \"蛋白质组学\",\n \"拓扑\",\n \"同态\",\n \"零知识\",\n \"格密码\",\n // Japanese\n \"量子\",\n \"フォトニクス\",\n \"ゲノミクス\",\n \"トポロジカル\",\n // Russian\n \"квантовый\",\n \"фотоника\",\n \"геномика\",\n \"протеомика\",\n \"топологический\",\n \"гомоморфный\",\n \"с нулевым разглашением\",\n \"на основе решёток\",\n // German\n \"quanten\",\n \"photonik\",\n \"genomik\",\n \"proteomik\",\n \"topologisch\",\n \"homomorph\",\n \"zero-knowledge\",\n \"gitterbasiert\",\n // Spanish\n \"cuántico\",\n \"fotónica\",\n \"genómica\",\n \"proteómica\",\n \"topológico\",\n \"homomórfico\",\n // Portuguese\n \"quântico\",\n \"fotônica\",\n \"genômica\",\n \"proteômica\",\n \"topológico\",\n \"homomórfico\",\n // Korean\n \"양자\",\n \"포토닉스\",\n \"유전체학\",\n \"위상\",\n \"동형\",\n // Arabic\n \"كمي\",\n \"ضوئيات\",\n \"جينوميات\",\n \"طوبولوجي\",\n \"تماثلي\",\n ],\n\n // Agentic task keywords - file ops, execution, multi-step, iterative work\n // Pruned: removed overly common words like \"then\", \"first\", \"run\", \"test\", \"build\"\n agenticTaskKeywords: [\n // English - File operations (clearly agentic)\n \"read file\",\n \"read the file\",\n \"look at\",\n \"check the\",\n \"open the\",\n \"edit\",\n \"modify\",\n \"update the\",\n \"change the\",\n \"write to\",\n \"create file\",\n // English - Execution (specific commands only)\n \"execute\",\n \"deploy\",\n \"install\",\n \"npm\",\n \"pip\",\n \"compile\",\n // English - Multi-step patterns (specific only)\n \"after that\",\n \"and also\",\n \"once done\",\n \"step 1\",\n \"step 2\",\n // English - Iterative work\n \"fix\",\n \"debug\",\n \"until it works\",\n \"keep trying\",\n \"iterate\",\n \"make sure\",\n \"verify\",\n \"confirm\",\n // Chinese (keep specific ones)\n \"读取文件\",\n \"查看\",\n \"打开\",\n \"编辑\",\n \"修改\",\n \"更新\",\n \"创建\",\n \"执行\",\n \"部署\",\n \"安装\",\n \"第一步\",\n \"第二步\",\n \"修复\",\n \"调试\",\n \"直到\",\n \"确认\",\n \"验证\",\n // Spanish\n \"leer archivo\",\n \"editar\",\n \"modificar\",\n \"actualizar\",\n \"ejecutar\",\n \"desplegar\",\n \"instalar\",\n \"paso 1\",\n \"paso 2\",\n \"arreglar\",\n \"depurar\",\n \"verificar\",\n // Portuguese\n \"ler arquivo\",\n \"editar\",\n \"modificar\",\n \"atualizar\",\n \"executar\",\n \"implantar\",\n \"instalar\",\n \"passo 1\",\n \"passo 2\",\n \"corrigir\",\n \"depurar\",\n \"verificar\",\n // Korean\n \"파일 읽기\",\n \"편집\",\n \"수정\",\n \"업데이트\",\n \"실행\",\n \"배포\",\n \"설치\",\n \"단계 1\",\n \"단계 2\",\n \"디버그\",\n \"확인\",\n // Arabic\n \"قراءة ملف\",\n \"تحرير\",\n \"تعديل\",\n \"تحديث\",\n \"تنفيذ\",\n \"نشر\",\n \"تثبيت\",\n \"الخطوة 1\",\n \"الخطوة 2\",\n \"إصلاح\",\n \"تصحيح\",\n \"تحقق\",\n ],\n\n // Dimension weights (sum to 1.0)\n dimensionWeights: {\n tokenCount: 0.08,\n codePresence: 0.15,\n reasoningMarkers: 0.18,\n technicalTerms: 0.1,\n creativeMarkers: 0.05,\n simpleIndicators: 0.02, // Reduced from 0.12 to make room for agenticTask\n multiStepPatterns: 0.12,\n questionComplexity: 0.05,\n imperativeVerbs: 0.03,\n constraintCount: 0.04,\n outputFormat: 0.03,\n referenceComplexity: 0.02,\n negationComplexity: 0.01,\n domainSpecificity: 0.02,\n agenticTask: 0.04, // Reduced - agentic signals influence tier selection, not dominate it\n },\n\n // Tier boundaries on weighted score axis\n tierBoundaries: {\n simpleMedium: 0.0,\n mediumComplex: 0.3, // Raised from 0.18 - prevent simple tasks from reaching expensive COMPLEX tier\n complexReasoning: 0.5, // Raised from 0.4 - reserve for true reasoning tasks\n },\n\n // Sigmoid steepness for confidence calibration\n confidenceSteepness: 12,\n // Below this confidence → ambiguous (null tier)\n confidenceThreshold: 0.7,\n },\n\n // ─── Tier chains ───\n //\n // Catalog refresh 2026-08-29 (V3.5). Every chain below names only models\n // the public catalog lists (GET https://blockrun.ai/api/v1/models). Ids the\n // gateway withholds (`hidden: true`) — kimi-k2.5/k2.6/k2.7, the grok-4-fast\n // and grok-4-1-fast pairs, grok-4-0709, claude-opus-4.6, gemini-3-pro-preview,\n // the whole `free/*` namespace — were removed everywhere, including fallback\n // rungs, so a routed model is always one a user can find on blockrun.ai/models.\n //\n // Primaries moved only where portfolio.ts already carries calibration\n // evidence for the successor (Sonnet 5 over Sonnet 4.6, GPT-5 Mini for\n // agentic MEDIUM, Gemini 3.5 Flash where Kimi K2.7 was). Newcomers with no\n // trajectory evidence yet (gemini-3.6-flash, glm-5.3, glm-5.3-flash,\n // gpt-5.6-luna, grok-4.3, minimax-m3, qwen3.7-plus) enter as fallback rungs;\n // promotion waits for a calibration run, because version recency is not a\n // quality signal.\n //\n // Latency figures in comments are the 2026-08-29 gateway probe\n // (model-profiles.generated.json); prices are the catalog list.\n //\n // Retirements 2026-11-24 (owner-approved; the gateways redirect each id\n // before pricing, so a stale name here is a silent model swap, not an error):\n // - google/gemini-3.5-flash -> google/gemini-3.6-flash. Google has served\n // 3.6 Flash under the 3.5 name since ~2026-10-10. Each 3.5 rung now names\n // 3.6 at the same position; where 3.6 already sat in the same chain, the\n // later of the two is dropped, so the order of the models actually served\n // is unchanged. 3.6 inherits 3.5's affinity values, carried, not measured\n // (portfolio.ts).\n // - openai/o4-mini (and o1, o3-mini) -> openai/gpt-5.4-mini, at the same\n // position. Dead at OpenAI since 2026-10-23 and on Azure since 2026-11-19.\n //\n // Retirements 2026-12-01 (Google retires Gemini 2.5; the gateways redirect):\n // - google/gemini-2.5-flash -> google/gemini-3.5-flash-lite (same\n // $0.30/$2.50), in place, with the same dedupe rule. 3.5 Flash-Lite has\n // no vision tag where 2.5 Flash had one, so a SIMPLE vision turn now\n // falls past it to the next vision-capable rung instead of reaching a\n // redirected model that would drop the image.\n // - google/gemini-2.5-pro -> google/gemini-3.8-flash ($0.75/$3.75), in\n // place.\n //\n // Retirements 2026-12-11 (OpenAI shuts down o3, gpt-5-mini and gpt-5-nano —\n // developers.openai.com/api/docs/deprecations, notice 2026-06-11; the\n // gateways redirect each and quote the successor):\n // - openai/o3 -> openai/gpt-5.4-mini ($2/$8 -> $0.75/$4.50). Both o3 rungs\n // (auto and premium REASONING) sat directly behind gpt-5.4-mini, so they\n // are dropped by the dedupe rule; the order actually served is unchanged.\n // - openai/gpt-5-mini -> openai/gpt-5.6-luna ($0.25/$2 -> $0.20/$1.20), in\n // place as the agentic MEDIUM primary. Luna inherits gpt-5-mini's\n // affinity values, CARRIED, not measured (portfolio.ts) — gpt-5-mini is a\n // reasoning model and luna runs without reasoning, so those values are a\n // placeholder until a Terminal-Bench/tau2 run on luna.\n // - openai/gpt-5-nano -> openai/gpt-6-luna. In no chain.\n\n // Auto (balanced) tier configs - current default smart routing\n tiers: {\n SIMPLE: {\n // Was google/gemini-2.5-flash (60% retention, best, in the 2026-03 run)\n // until its 2026-12-01 retirement. 3.5 Flash-Lite is what the gateways\n // serve under that name from then on; it was this chain's second\n // fallback and is dropped there.\n primary: \"google/gemini-3.5-flash-lite\", // $0.30/$2.50, 1M ctx, thinking mode, no vision\n fallback: [\n \"google/gemini-3-flash-preview\", // $0.50/$3 — GPQA 5/6 in the 2026-07 calibration\n \"deepseek/deepseek-chat\", // $0.14/$0.28, 1M ctx\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50, 1M ctx\n \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx — GPT-5.6 cost tier (cut 2026-07-30)\n \"openai/gpt-5.4-nano\", // $0.20/$1.25, 1M ctx\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n \"nvidia/nemotron-3.5-lightning\", // FREE backstop — NVIDIA free tier (probed 2026-08-30)\n ],\n },\n MEDIUM: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then Gemini 3.5 Flash — the\n // calibrated successor (MGSM 5/5, GPQA 4/6, extraction band) — until its\n // 2026-11-24 retirement. 3.6 Flash is what Google served under that name\n // since ~10-10; it was this chain's first fallback and is dropped there.\n primary: \"google/gemini-3.6-flash\", // $0.75/$3.75, 1M ctx, vision + tools — 3.5's affinity, carried\n fallback: [\n \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools verified live 2026-08-27\n \"openai/gpt-5.6-terra\", // $2/$12, 1M ctx — GPT-5.6 balanced tier\n \"google/gemini-3-flash-preview\", // $0.50/$3\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n \"minimax/minimax-m3\", // $0.30/$1.20, 1M ctx\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"openai/gpt-5.6-luna\", // $0.20/$1.20\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n ],\n },\n COMPLEX: {\n primary: \"google/gemini-3.1-pro\", // $2/$12 — proven long-context flagship (portfolio.ts long_context lead)\n fallback: [\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — Pro-level quality at Flash price (Google's claim); also 3.5 Flash's successor (3.5 retired 2026-11-24 and was the next rung)\n \"anthropic/claude-sonnet-5\", // $3/$15 — near-Opus quality, tau2 + Terminal-Bench calibrated\n \"xai/grok-4.5\", // $2.50/$9 — 503-resistant, independent infra (was grok-4-0709, now hidden)\n \"google/gemini-3.8-flash\", // $0.75/$3.75 — 2.5 Pro's successor (retired 2026-12-01)\n \"anthropic/claude-sonnet-4.6\", // $3/$15\n \"openai/gpt-5.6-terra\", // $2/$12 — GPT-5.6 balanced tier (Sol excluded: #202)\n \"openai/gpt-5.5\", // $5/$30 — prior OpenAI flagship\n \"openai/gpt-5.4\", // $2.50/$15 — previous flagship, benchmarked\n \"zai/glm-5.3\", // $1.40/$4.40, 1M ctx, always-on thinking — verified live 2026-08-19\n \"moonshot/kimi-k3.1-pro\", // $2/$10, 1M ctx — Moonshot flagship (K3 successor)\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87 — strongest open-weight reasoner\n \"deepseek/deepseek-chat\", // $0.14/$0.28 — cheap last resort\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n REASONING: {\n // Was xai/grok-4-1-fast-reasoning ($0.20/$0.50, hidden 2026-08). DeepSeek\n // Reasoner is the cheapest listed reasoner at the same 1M context.\n primary: \"deepseek/deepseek-reasoner\", // $0.14/$0.28, 1M ctx\n fallback: [\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87 — calibrated reasoning band 0.95\n \"xai/grok-4.3\", // $1.50/$4, 1M ctx — xAI reasoning model, vision\n \"qwen/qwen3.7-plus\", // $0.32/$1.28, 1M ctx — reasoning; needs a generous max_tokens (thinking is billed)\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — 3.5 Flash's successor (MGSM 5/5 on 3.5, carried)\n \"openai/gpt-5.4-mini\", // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung)\n ],\n },\n },\n\n // Eco tier configs - absolute cheapest (blockrun/eco)\n ecoTiers: {\n SIMPLE: {\n primary: \"nvidia/nemotron-3.5-lightning\", // FREE — NVIDIA free tier flagship, 1M ctx\n fallback: [\n // Was nvidia/nemotron-3-nano-30b until blockrun delisted it on 2026-09-08\n // (NVIDIA deprovisioned it for the account — a structured per-account\n // 404). nano-omni is blockrun's own redirect target for that id, so this\n // follows the same rule as the head: the router and the gateway name the\n // same model.\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\", // FREE — nano-30b's successor, 256K ctx\n // The free head keeps rotting with NVIDIA's hosting (deepseek-v4-flash\n // 410 2026-08-12, seed-oss-36b 410 2026-08-03, gpt-oss-120b/20b 400\n // 2026-08-21, and on 2026-08-30 FOUR of the five visible free models at\n // once — step-3.7-flash, nemotron-nano-9b-v2 and nemotron-nano-12b-v2-vl\n // all 410, mistral-nemotron hung). Each retirement retargets the two\n // free rungs to the current free tier; the paid rungs below never move.\n // The head follows blockrun's own redirect of the model it replaces, so\n // the router and the gateway never name different models.\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40 — cheapest paid rung\n \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools\n \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx\n \"openai/gpt-5.4-nano\", // $0.20/$1.25\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n ],\n },\n MEDIUM: {\n primary: \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools verified live — cheapest full-capability model\n fallback: [\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"openai/gpt-5.6-luna\", // $0.20/$1.20\n \"openai/gpt-5.4-nano\", // $0.20/$1.25\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n COMPLEX: {\n primary: \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx\n fallback: [\n \"deepseek/deepseek-chat\", // $0.14/$0.28, 1M ctx\n \"minimax/minimax-m3\", // $0.30/$1.20, 1M ctx\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n REASONING: {\n primary: \"deepseek/deepseek-reasoner\", // $0.14/$0.28, 1M ctx — cheapest listed reasoner\n fallback: [\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87\n \"qwen/qwen3.7-plus\", // $0.32/$1.28 — reasoning\n \"minimax/minimax-m3\", // $0.30/$1.20 — reasoning + coding\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — reasoning tokens alongside content\n ],\n },\n },\n\n // Premium tier configs - best quality (blockrun/premium)\n // codex=complex coding, flash=simple coding, sonnet=reasoning/instructions, fable/opus=architecture/PM/audits\n premiumTiers: {\n SIMPLE: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then Gemini 3.5 Flash until\n // its 2026-11-24 retirement; 3.6 Flash was the first fallback and is\n // dropped there.\n primary: \"google/gemini-3.6-flash\", // $0.75/$3.75, 1M ctx, vision + tools — 3.5's affinity, carried\n fallback: [\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"zai/glm-5.3\", // $1.40/$4.40, 1M ctx\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — written where 2.5 Flash sat (retired 2026-12-01); the duplicate after it is dropped\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n ],\n },\n MEDIUM: {\n primary: \"openai/gpt-5.3-codex\", // $1.75/$14 - 400K context, 128K output — code_edit/debug lead (portfolio.ts)\n fallback: [\n \"anthropic/claude-sonnet-5\", // $3/$15 — code_agent band 0.98\n \"moonshot/kimi-k3.1-pro\", // $2/$10, 1M ctx — Moonshot flagship\n \"zai/glm-5.3\", // $1.40/$4.40 — long-horizon coding\n \"google/gemini-3.6-flash\", // $0.75/$3.75 (3.5 Flash, the next rung, retired 2026-11-24)\n \"google/gemini-3.8-flash\", // $0.75/$3.75 — 2.5 Pro's successor (retired 2026-12-01)\n \"xai/grok-4.5\", // $2.50/$9\n \"anthropic/claude-sonnet-4.6\", // $3/$15\n \"openai/gpt-5.6-terra\", // $2/$12\n ],\n },\n COMPLEX: {\n // fable-5 was promoted here 2026-06-11, force-reverted 2026-06-13 when Anthropic\n // withdrew the offer, and restored 2026-07-14 now that BlockRun has relisted it.\n primary: \"anthropic/claude-fable-5\", // Best quality for complex tasks — Mythos-class flagship above Opus ($10/$50, 1M ctx, always-on thinking)\n // Fallback chain de-Gemini'd 2026-04-22: when Anthropic 503s, Gemini is\n // also prone to \"high demand\" 503s (correlated failure — everyone falls\n // back to Google at the same time). Prefer in-family → xAI → Moonshot →\n // OpenAI flagship → Z.AI → DeepSeek → NVIDIA free instead.\n fallback: [\n \"anthropic/claude-opus-5\", // in-family hot swap first (half the price, 1M ctx + adaptive thinking)\n \"anthropic/claude-opus-4.8\", // in-family hot swap (identical cost to 5)\n \"anthropic/claude-opus-4.7\", // in-family hot swap (identical cost to 4.8)\n \"anthropic/claude-sonnet-5\", // Sonnet-tier drop-down, near-Opus quality\n \"anthropic/claude-sonnet-4.6\",\n \"xai/grok-4.5\", // xAI flagship — 503-resistant, direct-xAI SKU\n \"moonshot/kimi-k3.1-pro\", // Moonshot flagship, independent infra\n \"openai/gpt-5.6-terra\", // GPT-5.6 balanced tier — stable (Sol excluded: #202)\n \"openai/gpt-5.5\", // Prior OpenAI flagship — 1M+ ctx, native agent + computer use\n \"openai/gpt-5.4\", // Previous flagship (slow but stable, benchmarked at 6,213ms)\n \"openai/gpt-5.3-codex\",\n \"zai/glm-5.3\", // Z.AI flagship, 1M ctx\n \"deepseek/deepseek-v4-pro\", // strongest open-weight reasoner\n \"deepseek/deepseek-chat\", // Cheap, reliable\n \"nvidia/nemotron-3.5-lightning\", // NVIDIA free ultimate backstop\n ],\n },\n REASONING: {\n // Sonnet 5 promoted over Sonnet 4.6 (same price; reasoning band 0.98 for both,\n // plus Sonnet 5's tau2/BrowseComp trajectory evidence).\n primary: \"anthropic/claude-sonnet-5\", // $3/$15, 1M ctx, adaptive thinking\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus w/ adaptive thinking\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus w/ adaptive thinking\n \"xai/grok-4.5\", // reasoning band 0.94\n \"deepseek/deepseek-v4-pro\", // reasoning band 0.95\n \"xai/grok-4.3\", // $1.50/$4 — xAI reasoning model\n \"openai/gpt-5.4-mini\", // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung)\n ],\n },\n },\n\n // Agentic tier configs - models that excel at multi-step autonomous tasks\n agenticTiers: {\n SIMPLE: {\n primary: \"openai/gpt-4o-mini\", // $0.15/$0.60 - best tool compliance at lowest cost\n fallback: [\n \"openai/gpt-5.6-luna\", // $0.20/$1.20 — lightweight agentic tier of GPT-5.6\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — tool calls verified live 2026-08-27\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n MEDIUM: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then GPT-5 Mini — which\n // carries the Terminal-Bench and tau2 trajectory evidence in\n // portfolio.ts — until its 2026-12-11 retirement. GPT-5.6 Luna is what\n // the gateways serve under that name from then on.\n primary: \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx, vision + tools — gpt-5-mini's affinity (4/7 Terminal-Bench, 5/6 tau2 airline), carried\n fallback: [\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — tool_agent band 0.88 (3.5's, carried)\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — tools verified\n \"openai/gpt-5.6-terra\", // $2/$12\n \"openai/gpt-4o-mini\", // $0.15/$0.60 — reliable tool calling\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"moonshot/kimi-k3.1-pro\", // $2/$10 — tool_agent band 0.85\n ],\n },\n COMPLEX: {\n // Sonnet 5 promoted over Sonnet 4.6: tau2 airline + retail reward 1.0,\n // Terminal-Bench safety band lead (portfolio.ts).\n primary: \"anthropic/claude-sonnet-5\", // $3/$15 — best agentic quality per trajectory evidence\n // Fallback chain de-Gemini'd 2026-04-22: Gemini's \"high demand\" 503s\n // correlate with Anthropic outages (everyone falls back together).\n // Prefer 503-resistant providers first.\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus — in-family hot swap\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus — in-family hot swap\n \"xai/grok-4.5\", // xAI flagship — strong tool use, independent infra\n \"moonshot/kimi-k3.1-pro\", // Moonshot flagship — independent infra\n \"openai/gpt-5.6-terra\", // GPT-5.6 balanced tier — stable (Sol excluded: #202)\n \"openai/gpt-5.5\", // Prior flagship — native agent + computer use (exactly the agentic-tier use case)\n \"openai/gpt-5.4\", // Previous flagship — reliable\n \"openai/gpt-5.3-codex\", // code_agent lead\n \"zai/glm-5.3\", // long-horizon coding\n \"deepseek/deepseek-v4-pro\", // retail high-risk 3/3\n \"deepseek/deepseek-chat\", // cheap, reliable\n \"nvidia/nemotron-3.5-lightning\", // NVIDIA free ultimate backstop\n ],\n },\n REASONING: {\n primary: \"anthropic/claude-sonnet-5\", // $3/$15 — strong tool use + adaptive thinking\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus w/ adaptive thinking\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus w/ adaptive thinking\n \"xai/grok-4.5\", // reasoning band 0.94\n \"deepseek/deepseek-v4-pro\", // reasoning band 0.95\n \"deepseek/deepseek-reasoner\", // $0.14/$0.28\n ],\n },\n },\n\n // Time-windowed promotions — auto-applied when active, ignored when expired.\n // The GLM-5.1 launch promo (2026-04-01 → 2026-05-01) was the last entry and\n // has expired; the list is kept empty so the mechanism stays wired.\n promotions: [],\n\n overrides: {\n maxTokensForceComplex: 100_000,\n structuredOutputMinTier: \"MEDIUM\",\n ambiguousDefaultTier: \"MEDIUM\",\n // agenticMode left undefined → auto-detect via tools/agenticScore.\n // Set to `true` to force agentic tiers; `false` to disable them entirely.\n },\n};\n","/**\n * Model capabilities used for hard routing constraints.\n *\n * Hosts may inject fresher values through RouterOptions.modelCapabilities.\n * Keeping a small built-in snapshot makes the core safe and useful when a\n * product catalog is temporarily unavailable, without importing product code.\n *\n * GENERATED by scripts/sync-model-capabilities.mjs from the public catalog\n * (GET https://blockrun.ai/api/v1/models) on 2026-11-24; supportsTools comes\n * from a live function-calling probe (scripts/probe-tools.json). Regenerate\n * rather than editing by hand — a hand edit is overwritten on the next sync.\n */\nexport type ModelCapabilities = {\n contextWindow: number;\n maxOutputTokens: number;\n supportsTools: boolean;\n supportsVision: boolean;\n};\n\nexport const DEFAULT_MODEL_CAPABILITIES: Readonly> =\n Object.freeze({\n \"anthropic/claude-fable-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-fable-5.1\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-fable-5.2\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"anthropic/claude-haiku-4.5\": { // override: The public catalog's `categories` omit \"vision\" for this Anthropic model even though the gateway accepts image input for it (the prior hand-maintained snapshot had it, and Anthropic's model card lists it). Without this the vision filter would silently drop it — reported against the catalog; remove once the categories carry vision.\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.5\": {\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.7\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.8\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-5.5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-4.5\": {\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-4.6\": { // override: The public catalog's `categories` omit \"vision\" for this Anthropic model even though the gateway accepts image input for it (the prior hand-maintained snapshot had it, and Anthropic's model card lists it). Without this the vision filter would silently drop it — reported against the catalog; remove once the categories carry vision.\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-5.5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"cohere/north-mini-code\": { // supportsTools: not probed — fails closed\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"deepseek/deepseek-chat\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-chat \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-reasoner\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-reasoner \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-v4-flash-vision-exp\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"deepseek/deepseek-v4-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-v4.1-flash\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-v4.1-flash \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-2.5-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-2.5-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-2.5-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3-flash-preview\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.1-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-3.1-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.5-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.5-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-3.6-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.8-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-4-argon\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"google/gemini-4-carbon\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-4-hydrogen\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"google/gemini-4-neon\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"minimax/minimax-m2.7\": {\n contextWindow: 204_800,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"minimax/minimax-m3\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"mistral/mistral-large-4\": { // supportsTools: not probed — fails closed\n contextWindow: 524_288,\n maxOutputTokens: 262_144,\n supportsTools: false,\n supportsVision: true,\n },\n \"moonshot/kimi-k3.1-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"nvidia/minimax-m3.1-flash\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/muse-glimmer-30b\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\": { // override: The catalog tags this model \"vision\", but a correctly sized probe does not hold up (ClawRouter, 2026-08-31): a 64x64 solid-red PNG was named correctly 1 of 4 times on Base, and on Solana the image was silently dropped and a text model answered \"white\". An HTTP 200 with a confident wrong answer gives the caller nothing to branch on, so image turns must not be routed here. It is ecoTiers.SIMPLE.fallback[0] since nemotron-3-nano-30b was delisted (2026-09-08); remove once a probe of this size comes back right on both chains.\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3-super-120b\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: true,\n },\n \"nvidia/nemotron-3-ultra-550b\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3.5-bolt\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: true,\n },\n \"nvidia/nemotron-3.5-lightning\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"openai/chat-latest\": {\n contextWindow: 128_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4.1\": {\n contextWindow: 128_000,\n maxOutputTokens: 32_768,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4.1-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 32_768,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-4o\": {\n contextWindow: 128_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4o-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5-mini\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.1\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.2\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.2-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.3-codex\": { // supportsTools: gateway unavailable at probe time — fails closed; override: 2026-08-29 probe: every request (6 plain + 3 tool attempts) returned a gateway 500, so the probe measured an incident, not the model. Codex's function calling is established by the 2026-07 Terminal-Bench / tau2 calibration trajectories in portfolio.ts. Hosts observing the 500s should drop it with RouterOptions.unavailableModels rather than this snapshot claiming the model cannot call tools.\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.4\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.4-mini\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.4-nano\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.4-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.5\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.5-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.6-luna\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-luna-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.6-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-sol-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-terra\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-terra-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-astra\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-luna\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6.1-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6.2-astra\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-6.2-sol\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/o1\": {\n contextWindow: 200_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o3\": {\n contextWindow: 200_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o3-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o4-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"poolside/laguna-s-2.1\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: false,\n },\n \"poolside/laguna-xs-2.1\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"qwen/qwen3.7-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.7-max\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.7-plus\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.8-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: true,\n },\n \"qwen/qwen3.8-max\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: false,\n },\n \"tencent/hy4-preview\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 64_000,\n supportsTools: false,\n supportsVision: false,\n },\n \"xai/grok-4.3\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.5\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.6\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.7\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-build-0.1\": {\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"xiaomi/mimo-v2.5\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: true,\n },\n \"xiaomi/mimo-v2.5-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5-turbo\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.1\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.2\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.3\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.3-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: true,\n },\n });\n","{\n \"anthropic/claude-fable-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9298.5,\n \"p95LatencyMs\": 9873.4,\n \"outputTokensPerSecond\": 55.17,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-haiku-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3157.4,\n \"p95LatencyMs\": 3170.7,\n \"outputTokensPerSecond\": 162.16,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6497.7,\n \"p95LatencyMs\": 6953.7,\n \"outputTokensPerSecond\": 78.99,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.7\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5316.5,\n \"p95LatencyMs\": 6121.5,\n \"outputTokensPerSecond\": 97.34,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.8\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6216.1,\n \"p95LatencyMs\": 6847.7,\n \"outputTokensPerSecond\": 82.81,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7309,\n \"p95LatencyMs\": 7745.2,\n \"outputTokensPerSecond\": 70.17,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6330.4,\n \"p95LatencyMs\": 6631.6,\n \"outputTokensPerSecond\": 81.03,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-4.6\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6508,\n \"p95LatencyMs\": 6698.3,\n \"outputTokensPerSecond\": 78.6,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6165.4,\n \"p95LatencyMs\": 6582.9,\n \"outputTokensPerSecond\": 83.62,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-chat\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4351.4,\n \"p95LatencyMs\": 4543.7,\n \"outputTokensPerSecond\": 117.78,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-reasoner\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5201.2,\n \"p95LatencyMs\": 6079.6,\n \"outputTokensPerSecond\": 99.77,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-v4-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 8781.2,\n \"p95LatencyMs\": 9881.1,\n \"outputTokensPerSecond\": 58.98,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-v4.1-flash\": {\n \"measuredAt\": \"2026-10-20T18:12:51Z\",\n \"latencyMs\": 2383.5,\n \"p95LatencyMs\": 2547.8,\n \"outputTokensPerSecond\": 216.53,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5416.4,\n \"p95LatencyMs\": 6442.8,\n \"outputTokensPerSecond\": 213.07,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5002.6,\n \"p95LatencyMs\": 5780.3,\n \"outputTokensPerSecond\": 408.43,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 28169.5,\n \"p95LatencyMs\": 29491.4,\n \"outputTokensPerSecond\": 147.3,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3-flash-preview\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4717.1,\n \"p95LatencyMs\": 5037.1,\n \"outputTokensPerSecond\": 198.71,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.1-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2855.8,\n \"p95LatencyMs\": 3172.7,\n \"outputTokensPerSecond\": 286.91,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.1-pro\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 24194.1,\n \"p95LatencyMs\": 27269.6,\n \"outputTokensPerSecond\": 109.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.5-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5320.6,\n \"p95LatencyMs\": 5429.8,\n \"outputTokensPerSecond\": 226.21,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.5-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3515.8,\n \"p95LatencyMs\": 4363.4,\n \"outputTokensPerSecond\": 248.9,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.6-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 13020,\n \"p95LatencyMs\": 15383.1,\n \"outputTokensPerSecond\": 187.87,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"minimax/minimax-m2.7\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 8761.1,\n \"p95LatencyMs\": 10199.3,\n \"outputTokensPerSecond\": 59.18,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"minimax/minimax-m3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 11101.9,\n \"p95LatencyMs\": 26087.1,\n \"outputTokensPerSecond\": 101.12,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"moonshot/kimi-k3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 24498.9,\n \"p95LatencyMs\": 40365.3,\n \"outputTokensPerSecond\": 25.11,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"moonshot/kimi-k3.1-pro\": {\n \"measuredAt\": \"2026-11-23T20:18:18Z\",\n \"latencyMs\": 9243.1,\n \"p95LatencyMs\": 10504.1,\n \"outputTokensPerSecond\": 55.89,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"nvidia/mistral-nemotron\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7349.6,\n \"p95LatencyMs\": 9932.3,\n \"outputTokensPerSecond\": 79.48,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 9324.6,\n \"p95LatencyMs\": 12992,\n \"outputTokensPerSecond\": 64.96,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"nvidia/nemotron-nano-12b-v2-vl\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5846.9,\n \"p95LatencyMs\": 5846.9,\n \"outputTokensPerSecond\": 87.57,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"nvidia/nemotron-nano-9b-v2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5282.5,\n \"p95LatencyMs\": 5282.5,\n \"outputTokensPerSecond\": 96.92,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"nvidia/step-3.7-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4617.4,\n \"p95LatencyMs\": 5237.4,\n \"outputTokensPerSecond\": 112.92,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"openai/chat-latest\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3690.9,\n \"p95LatencyMs\": 4344,\n \"outputTokensPerSecond\": 111.85,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3527.9,\n \"p95LatencyMs\": 3831.7,\n \"outputTokensPerSecond\": 141.27,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4268.2,\n \"p95LatencyMs\": 5101.5,\n \"outputTokensPerSecond\": 103.42,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1-nano\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3088.3,\n \"p95LatencyMs\": 3369.2,\n \"outputTokensPerSecond\": 150.31,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4o\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2995.2,\n \"p95LatencyMs\": 3174.2,\n \"outputTokensPerSecond\": 171.32,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4o-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4751.5,\n \"p95LatencyMs\": 4930.4,\n \"outputTokensPerSecond\": 107.84,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4558.1,\n \"p95LatencyMs\": 5081.9,\n \"outputTokensPerSecond\": 113.25,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5436.6,\n \"p95LatencyMs\": 5928.8,\n \"outputTokensPerSecond\": 95.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.3-codex\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 15290.4,\n \"p95LatencyMs\": 15290.4,\n \"outputTokensPerSecond\": 33.49,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"openai/gpt-5.4\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5596,\n \"p95LatencyMs\": 5919.4,\n \"outputTokensPerSecond\": 91.67,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.4-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3377.8,\n \"p95LatencyMs\": 3646.8,\n \"outputTokensPerSecond\": 138.08,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.4-nano\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4040.4,\n \"p95LatencyMs\": 4205.9,\n \"outputTokensPerSecond\": 118.52,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6367.8,\n \"p95LatencyMs\": 7330.7,\n \"outputTokensPerSecond\": 81.29,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-luna\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6064.5,\n \"p95LatencyMs\": 7347.3,\n \"outputTokensPerSecond\": 87.93,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-luna-pro\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 13914.9,\n \"p95LatencyMs\": 13914.9,\n \"outputTokensPerSecond\": 36.79,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"openai/gpt-5.6-sol\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7720.2,\n \"p95LatencyMs\": 9108.2,\n \"outputTokensPerSecond\": 67.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-sol-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 11442.7,\n \"p95LatencyMs\": 13363.1,\n \"outputTokensPerSecond\": 148.75,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-terra\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4941,\n \"p95LatencyMs\": 5095.3,\n \"outputTokensPerSecond\": 103.69,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-terra-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3574.1,\n \"p95LatencyMs\": 4126.3,\n \"outputTokensPerSecond\": 133.59,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-6.1-sol\": {\n \"measuredAt\": \"2026-10-20T18:12:51Z\",\n \"latencyMs\": 11324,\n \"p95LatencyMs\": 12747.6,\n \"outputTokensPerSecond\": 45.11,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4324.9,\n \"p95LatencyMs\": 5838.1,\n \"outputTokensPerSecond\": 125.86,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5463.4,\n \"p95LatencyMs\": 5613.1,\n \"outputTokensPerSecond\": 93.8,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o3-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2912.7,\n \"p95LatencyMs\": 3092.1,\n \"outputTokensPerSecond\": 176.49,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o4-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4958.7,\n \"p95LatencyMs\": 5313,\n \"outputTokensPerSecond\": 103.81,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3385.5,\n \"p95LatencyMs\": 4042.7,\n \"outputTokensPerSecond\": 153.94,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-max\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9387.1,\n \"p95LatencyMs\": 10490.2,\n \"outputTokensPerSecond\": 54.92,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-plus\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9766.6,\n \"p95LatencyMs\": 9798.2,\n \"outputTokensPerSecond\": 52.42,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"tencent/hy3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6062.3,\n \"p95LatencyMs\": 7070.2,\n \"outputTokensPerSecond\": 87.3,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-4.3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9467.7,\n \"p95LatencyMs\": 10087.9,\n \"outputTokensPerSecond\": 48.36,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 13564.8,\n \"p95LatencyMs\": 17351.9,\n \"outputTokensPerSecond\": 60.71,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-build-0.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 16394.8,\n \"p95LatencyMs\": 18035.4,\n \"outputTokensPerSecond\": 96.86,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xiaomi/mimo-v2.5-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 12070.7,\n \"p95LatencyMs\": 12386.8,\n \"outputTokensPerSecond\": 42.44,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6839.7,\n \"p95LatencyMs\": 7261.4,\n \"outputTokensPerSecond\": 75.16,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5-turbo\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 55348.5,\n \"p95LatencyMs\": 114086.6,\n \"outputTokensPerSecond\": 14.64,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 15658.4,\n \"p95LatencyMs\": 17307.1,\n \"outputTokensPerSecond\": 32.9,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 10308.5,\n \"p95LatencyMs\": 15127.6,\n \"outputTokensPerSecond\": 54.87,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7272.4,\n \"p95LatencyMs\": 7998.1,\n \"outputTokensPerSecond\": 71.09,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.3-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 10545.3,\n \"p95LatencyMs\": 11672.4,\n \"outputTokensPerSecond\": 49.01,\n \"errorRate\": 0,\n \"samples\": 3\n }\n}\n","/**\n * Model-performance priors consumed by the portfolio router.\n *\n * The entries below are a small, auditable seed extracted from the 2026-03-16\n * BlockRun performance run. They are deliberately weak priors: live data\n * injected by the host should replace them through configuration before a\n * release. Historical numbers must never be presented as a current\n * provider SLA or as task-quality measurements.\n */\n\nimport liveProfiles from \"./model-profiles.generated.json\";\n\nexport type ModelPerformanceProfile = {\n measuredAt: string;\n /** Gateway end-to-end latency for the benchmark workload. */\n latencyMs: number;\n /** Tail latency is more relevant than mean latency for urgent requests. */\n p95LatencyMs?: number;\n outputTokensPerSecond: number;\n /** External intelligence index when one was available; not task success. */\n intelligenceIndex?: number;\n /** Failure fraction observed in the same benchmark run. */\n errorRate?: number;\n /** Number of sampled calls behind the observation. */\n samples?: number;\n};\n\n// Generated from benchmark files that satisfy the uncached-inference\n// invariant. These are weak performance priors (speed/reliability), never\n// task-quality labels.\nexport const LIVE_MODEL_PROFILES: Readonly> = Object.freeze(\n liveProfiles as Record,\n);\n\nexport const HISTORICAL_MODEL_PROFILES: Readonly> =\n Object.freeze({\n \"anthropic/claude-haiku-4.5\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2305,\n outputTokensPerSecond: 140.6,\n },\n \"anthropic/claude-sonnet-4.6\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2110,\n outputTokensPerSecond: 121.3,\n },\n \"deepseek/deepseek-chat\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1431,\n outputTokensPerSecond: 179.2,\n intelligenceIndex: 32,\n },\n \"google/gemini-2.5-flash\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1238,\n outputTokensPerSecond: 207.6,\n intelligenceIndex: 20,\n },\n \"google/gemini-2.5-flash-lite\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1353,\n outputTokensPerSecond: 192.5,\n intelligenceIndex: 20,\n },\n \"google/gemini-2.5-pro\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1294,\n outputTokensPerSecond: 197.8,\n },\n \"google/gemini-3.1-pro\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1609,\n outputTokensPerSecond: 167.2,\n },\n \"openai/gpt-4o-mini\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2764,\n outputTokensPerSecond: 92.8,\n },\n \"openai/gpt-5.3-codex\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 7935,\n outputTokensPerSecond: 32.3,\n },\n });\n","/**\n * Whether the request actually requires an external action/tool, as distinct\n * from merely being sent by a host that exposes tools on every turn.\n *\n * The detector intentionally looks for action+target pairs. A generic factual\n * or multiple-choice question must stay false even when the host attaches a\n * large tool schema; otherwise every tool-enabled host turn is over-routed as\n * an agent task and models may browse or mutate state unnecessarily.\n */\nexport function inferToolRequirement(\n prompt: string,\n _systemPrompt?: string,\n toolChoice?: unknown,\n): boolean {\n // OpenAI-compatible clients can state this requirement directly. Treat that\n // protocol signal as authoritative instead of trying to infer it from prose.\n if (toolChoice === \"none\") return false;\n if (toolChoice === \"required\") return true;\n if (\n typeof toolChoice === \"object\" &&\n toolChoice !== null &&\n (toolChoice as { type?: unknown }).type === \"function\"\n ) {\n return true;\n }\n\n // System prompts commonly describe every tool a host exposes. They are not\n // evidence that the user asked to perform an action on this turn. Explicit\n // host requirements should use tool_choice/requiresTools instead.\n const text = prompt;\n const explicitTool =\n /\\b(?:use|call|invoke)\\s+(?:the\\s+)?[\\w.-]+\\s+(?:tool|function|api)\\b|\\btool[_ -]?call\\b|使用.{0,20}(?:工具|函数|接口)|调用.{0,20}(?:工具|函数|接口)/i;\n const codeEnvironment =\n /\\b(?:run|execute)\\s+(?:the\\s+)?(?:tests?|command|script|build|linter)|\\b(?:edit|modify|patch|create|write|save|delete|rename|move|inspect|read)\\b.{0,60}\\b(?:file|repository|repo|codebase|directory|folder)\\b|\\b(?:terminal|shell|bash|zsh|pytest|npm test|pnpm test|git\\s+(?:status|diff|commit)|docker)\\b|(?:运行|执行).{0,20}(?:测试|命令|脚本|构建)|(?:修改|编辑|修复|创建|读取|检查|保存).{0,30}(?:文件|仓库|代码库|目录)/i;\n const webAction =\n /\\b(?:browse|search|look up|fetch|open)\\b.{0,80}\\b(?:web|website|url|online|documentation|docs|news|weather|price)\\b|(?:浏览|搜索|查询|打开).{0,30}(?:网页|网站|链接|文档|新闻|天气|价格)/i;\n const statefulAction =\n /\\b(?:refund|cancel|book|reserve|purchase|buy|return|exchange|transfer|update|change)\\b.{0,80}\\b(?:order|booking|reservation|account|address|payment|subscription|ticket|flight|item)\\b|(?:退款|取消|预订|购买|退货|换货|转账|更新|修改).{0,30}(?:订单|预订|账户|地址|付款|订阅|票|航班|商品)/i;\n return (\n explicitTool.test(text) ||\n codeEnvironment.test(text) ||\n webAction.test(text) ||\n statefulAction.test(text)\n );\n}\n","/**\n * V3 portfolio router.\n *\n * This is deliberately local and deterministic: feature extraction, eligibility\n * checks and scoring read only request data plus the in-process model registry.\n * It is therefore safe for the hot path and provides a stable baseline for the\n * RouterBench evaluation before health telemetry / an optional judge are added.\n */\n\nimport { DEFAULT_ROUTING_CONFIG } from \"./config.js\";\nimport { DEFAULT_MODEL_CAPABILITIES } from \"./model-capabilities.js\";\nimport { getFallbackChain, selectModel, usablePricing } from \"./selector.js\";\nimport { RulesStrategy } from \"./strategy.js\";\nimport {\n HISTORICAL_MODEL_PROFILES,\n LIVE_MODEL_PROFILES,\n type ModelPerformanceProfile,\n} from \"./model-profiles.js\";\nimport type { RouterOptions, RouterStrategy, TaskType, Tier, TierConfig } from \"./types.js\";\nimport { inferToolRequirement } from \"./tool-intent.js\";\nimport { estimateTokens, sampleForScan, scanLimit } from \"./tokens.js\";\n\ntype TaskFeatures = {\n taskType: TaskType;\n estimatedInputTokens: number;\n hasCode: boolean;\n needsTools: boolean;\n toolsAvailable: boolean;\n needsVision: boolean;\n needsStructuredOutput: boolean;\n latencySensitive: boolean;\n highStakes: boolean;\n language: \"zh\" | \"other\";\n likelyParallelToolCalls: boolean;\n complexMultiToolPlan: boolean;\n agentDomain: \"airline\" | \"retail\" | \"web_research\" | \"other\";\n deepWebResearch: boolean;\n agentRisk: \"standard\" | \"high\" | \"complex_high\" | \"policy_exception_simple\" | \"policy_exception\";\n terminalToolSignal: boolean;\n terminalSafetySensitive: boolean;\n implicitTerminalCode: boolean;\n /** A code artifact or coding action is present, not merely a language name. */\n codeArtifact: boolean;\n};\n\n// The bundled config carries the calibrated weights; a host config that omits\n// `portfolio` scores with the same numbers rather than a second copy of them.\nconst DEFAULT_PORTFOLIO_WEIGHTS = DEFAULT_ROUTING_CONFIG.portfolio!;\n\n/**\n * Detect turns that probably need several tool calls. This is a\n * deliberately conservative request-side feature: it uses only the prompt\n * and visible tool count, never benchmark categories or expected answers.\n */\nfunction likelyNeedsParallelToolCalls(\n prompt: string,\n needsTools: boolean,\n toolCount: number | undefined,\n toolNames: readonly string[] | undefined,\n): boolean {\n if (!needsTools || toolCount === undefined || toolCount < 1) return false;\n const text = prompt.trim();\n const explicitRepeat =\n /\\b(?:in parallel|simultaneously|concurrently|for each|each of|every one|both|(?:two|three|multiple|several)\\s+(?:cities|locations|items|tasks|orders|users|files))\\b|并行|同时|分别|每个|各自|(?:两个|三个|多个)(?:城市|地点|项目|任务|订单|用户|文件)|cada uno|para cada|simult[aá]neamente/i.test(\n text,\n );\n if (explicitRepeat) return true;\n\n const sentenceClauses = text\n .split(/[.!?。!?]+/)\n .map((part) => part.trim())\n .filter((part) => part.length >= 8);\n if (\n (/\\b(?:also|additionally|furthermore)\\b|另外|此外|그리고/i.test(text) &&\n sentenceClauses.length >= 2) ||\n /\\band\\s+(?:also|for the)\\b/i.test(text)\n )\n return true;\n\n const pairedQuantity =\n /\\b\\d+(?:\\.\\d+)?\\s+(?:and|or)\\s+\\d+(?:\\.\\d+)?\\s*(?:gb|mb|tb|kg|g|ml|oz|cups?|cores?|cpus?)\\b/i.test(\n text,\n );\n if (pairedQuantity) return true;\n\n // Distinctive tokens from two visible tool names are a strong local signal\n // for a multi-operation turn (for example add_task + delete_task).\n const operationTokens = new Set([\n \"add\",\n \"delete\",\n \"remove\",\n \"cancel\",\n \"return\",\n \"exchange\",\n \"modify\",\n \"book\",\n \"transfer\",\n \"send\",\n \"upload\",\n \"download\",\n \"create\",\n \"close\",\n ]);\n // Whole words only, with an optional inflection: a substring test read\n // \"add\" out of \"address\", \"book\" out of \"facebook\" and \"close\" out of\n // \"closet\" (the same failure rules.ts fixed for its keyword lists).\n const lowered = text.toLowerCase();\n const matchedOperationTokens = new Set(\n (toolNames ?? [])\n .flatMap((name) => name.toLowerCase().split(/[^a-z0-9\\u3400-\\u9fff]+/))\n .filter(\n (token) =>\n operationTokens.has(token) &&\n new RegExp(`\\\\b${token}(?:s|es|d|ed|ing)?\\\\b`).test(lowered),\n ),\n );\n // A single workflow naturally mentions domain nouns like order/item plus\n // one action. Upgrade only when two different visible operation verbs are\n // requested (for example cancel + book or add + delete).\n if (matchedOperationTokens.size >= 2) return true;\n\n // Repeated food/logging entries are commonly expressed as several lines,\n // each with its own quantity rather than an explicit \"for each\" phrase.\n const nonEmptyLines = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter(Boolean);\n const quantityMentions =\n text.match(\n /\\b(?:\\d+(?:\\.\\d+)?|one|two|three|four|five|six|seven|eight|nine|ten)\\s*(?:oz|ounce|ounces|g|gram|grams|kg|ml|cups?|pieces?|tablespoons?)\\b/gi,\n ) ?? [];\n if (nonEmptyLines.length >= 2 && quantityMentions.length >= 2) return true;\n\n // Weather prompts provide a useful language-independent high-confidence\n // pattern: a single lookup tool plus multiple locations joined in one turn.\n const repeatedLookup =\n /\\b(?:weather|climate|clima|tiempo|temperature|snow|news|report)\\b|天气|气象|温度|降雪|新闻|报告/i.test(\n text,\n );\n const multiLocationConnector =\n /\\b(?:and also|both)\\b|\\s(?:y|e)\\s|还有|以及|和|、/i.test(text);\n const commaSeparatedLocations = (text.match(/[,,]/g) ?? []).length >= 2;\n if (repeatedLookup && (multiLocationConnector || commaSeparatedLocations)) return true;\n\n const distinctOrderParts =\n /\\b(?:food|meal)\\b[\\s\\S]*\\bdrink\\b|\\bdrink\\b[\\s\\S]*\\b(?:food|meal)\\b/i.test(text);\n const koreanParallelClauses = (text.match(/,/g) ?? []).length >= 3 && /하고|그리고/.test(text);\n return distinctOrderParts || koreanParallelClauses;\n}\n\nfunction classifyTask(\n prompt: string,\n systemPrompt: string | undefined,\n options: RouterOptions,\n): TaskFeatures {\n const fullText = `${systemPrompt ?? \"\"} ${prompt}`;\n const estimatedInputTokens = estimateTokens(fullText);\n const limit = scanLimit(options.config.classifier.promptTruncationChars);\n const scannedPrompt = sampleForScan(prompt, limit);\n const scannedSystemPrompt = sampleForScan(systemPrompt ?? \"\", limit);\n // Only the deep-web-research clue detectors below read the system prompt,\n // and they are gated on a web-research tool surface. Every other feature\n // reads the user turn: a host's standing instructions (\"be quick\", \"follow\n // security best practices\", a Mandarin persona) describe the assistant, not\n // this request, and must not move its scoring or language band.\n const scannedFullText = `${scannedSystemPrompt} ${scannedPrompt}`;\n const text = scannedPrompt.toLowerCase();\n const explicitCodeSignal =\n /```|\\b(?:typescript|javascript|python|rust|java|sql|stack trace|traceback|exception)\\b|\\.(?:ts|tsx|js|py|go|rs)\\b/i.test(\n scannedPrompt,\n );\n // `class` is common in non-code Agent domains (for example airline cabin\n // class). Treat code constructs as code only when the prompt also contains\n // an implementation/editing cue, instead of letting a single ambiguous\n // noun redirect an entire tool session to the code-agent portfolio.\n const codeConstructSignal =\n /\\b(?:implement|refactor|debug|write|edit|modify|create|define|review|fix)\\b[\\s\\S]{0,48}\\b(?:api|function|class|method)\\b|\\b(?:api|function|class|method)\\b[\\s\\S]{0,48}\\b(?:code|implementation|typescript|javascript|python|rust|java)\\b/i.test(\n scannedPrompt,\n );\n const nativeCodeSignal =\n /\\b(?:programmed|written|implemented?|code)\\s+(?:in|using)\\s+(?:c\\+\\+|c|rust|go)\\b/i.test(\n scannedPrompt,\n );\n // A CamelCase error class (TypeError, NullPointerException) is a runtime\n // artifact, not prose about errors; case-sensitive on purpose.\n const errorClassSignal = /\\b[A-Z][A-Za-z]*(?:Error|Exception)\\b/.test(scannedPrompt);\n const hasCode = explicitCodeSignal || codeConstructSignal || nativeCodeSignal || errorClassSignal;\n // A language name alone (\"java coffee prices\", \"python snake habitat\") is\n // not code work, even on a tool turn. It joins the code-agent pool only\n // together with a coding action.\n const codingAction =\n /\\b(?:write|implement|refactor|debug|fix|patch|compile|build|run|test|script|program|code|function|class|module|repo(?:sitory)?)\\b|编写|实现|重构|调试|修复|编译|脚本|代码/i.test(\n scannedPrompt,\n );\n // Stronger than hasCode: an actual code artifact or coding action, never a\n // bare language name (\"What is Python?\" is trivia, not a code task) and\n // never the English word \"exception\" on its own (\"please make an\n // exception\"); a thrown exception shows up as a CamelCase class above.\n const codeArtifact =\n /```|\\b(?:stack trace|traceback)\\b|\\.(?:ts|tsx|js|py|go|rs)\\b/i.test(scannedPrompt) ||\n codeConstructSignal ||\n nativeCodeSignal ||\n errorClassSignal;\n const toolsAvailable = options.hasTools ?? false;\n const needsTools =\n options.requiresTools ??\n (toolsAvailable && inferToolRequirement(scannedPrompt, scannedSystemPrompt));\n const likelyParallelToolCalls = likelyNeedsParallelToolCalls(\n scannedPrompt,\n needsTools,\n options.toolCount,\n options.toolNames,\n );\n const normalizedToolNames = (options.toolNames ?? []).map((name) => name.toLowerCase());\n const airlineToolSignal = normalizedToolNames.some((name) =>\n /(?:flight|reservation|airport|baggage|passenger)/.test(name),\n );\n const retailToolSignal = normalizedToolNames.some((name) =>\n /(?:order|product|item|return|exchange|address)/.test(name),\n );\n const webResearchToolSignal = normalizedToolNames.some((name) =>\n /^(?:web_?search|web_?fetch)$/.test(name),\n );\n const agentDomain =\n airlineToolSignal && !retailToolSignal\n ? \"airline\"\n : retailToolSignal && !airlineToolSignal\n ? \"retail\"\n : webResearchToolSignal\n ? \"web_research\"\n : \"other\";\n // Distinguish a cheap lookup from a BrowseComp-like investigation. These\n // prompts require joining several clues, resolving an entity, and ending in\n // one exact answer; complete agent trajectories show that treating them as\n // ordinary search causes long, costly loops. This is request/tool-surface\n // evidence only and does not depend on a benchmark id or hidden answer.\n const clueConnectors =\n scannedFullText.match(\n /\\b(?:after|before|while|where|whose|which|in \\d{4}|as of|over \\d+|another|also|furthermore)\\b|(?:之后|之前|其中|截至|超过|另一个|此外)/gi,\n ) ?? [];\n const entityResolutionSignal =\n /\\b(?:identify|who (?:is|was)|what (?:is|was) the name|which (?:person|player|company|country|city)|find the (?:person|player|name|entity))\\b|(?:找出|识别|是谁|哪位|名称是什么)/i.test(\n scannedFullText,\n );\n const exactAnswerSignal =\n /\\b(?:exact answer|single best-supported answer|following clues|multiple public sources)\\b|(?:精确答案|根据.*线索|多个公开来源)/i.test(\n scannedFullText,\n );\n const deepWebResearch =\n agentDomain === \"web_research\" &&\n (exactAnswerSignal ||\n (entityResolutionSignal && (clueConnectors.length >= 3 || prompt.length >= 320)));\n const globalOptimizationSignal =\n /\\b(?:cheapest|lowest[- ]price|least expensive|most expensive|highest(?:[- ]priced)?|largest|smallest|maximum|minimum|best available|closest|not (?:cost|exceed))\\b|最便宜|最低价|最贵|最高价|最大|最小/i.test(\n scannedPrompt,\n );\n const globalScopeSignal =\n /\\b(?:everything|all (?:(?:my|your|their|the) )?(?:future |upcoming )?(?:items|orders|passengers|flights|reservations|bookings)|every (?:item|order|passenger|flight|reservation|booking))\\b|全部|所有|每个/i.test(\n scannedPrompt,\n );\n const globalChoiceSignal = globalOptimizationSignal || globalScopeSignal;\n const crossRecordSignal =\n /\\b(?:another|other|different|previous)\\s+(?:order|reservation|booking|account|address)\\b|另一(?:个)?(?:订单|预订|账户|地址)|其他(?:订单|预订|账户|地址)/i.test(\n scannedPrompt,\n );\n // Reservation locators mix letters and digits (ZFA04Y, 4WQ150). Requiring\n // both keeps shouted words (\"CANCEL MY FLIGHT\") and plain six-digit numbers\n // from reading as two reservations.\n const reservationIds =\n scannedPrompt.match(/\\b(?=[A-Z0-9]*\\d)(?=[A-Z0-9]*[A-Z])[A-Z0-9]{6}\\b/g) ?? [];\n const crossReservationBatchSignal =\n agentDomain === \"airline\" &&\n (/\\b(?:two|three|multiple|several)(?:\\s+of\\s+(?:my|our|the))?\\s+(?:upcoming\\s+)?(?:reservations?|bookings?)\\b|\\b(?:a\\s+)?(?:second|third)\\s+(?:reservation|booking)\\b/i.test(\n scannedPrompt,\n ) ||\n new Set(reservationIds).size >= 2);\n const conditionalGlobalWorkflowSignal =\n agentDomain === \"airline\" &&\n globalScopeSignal &&\n /\\b(?:if|that (?:contain|have)|longer than|shorter than|under|over|at (?:most|least)|wherever possible)\\b|如果|超过|少于|不超过|尽可能/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:cancel|change|upgrade|move|book)\\b[\\s\\S]*\\b(?:cancel|change|upgrade|move|book)\\b|取消[\\s\\S]*(?:升级|更改)|升级[\\s\\S]*(?:取消|更改)/i.test(\n scannedPrompt,\n );\n // A refund explicitly targeted at a named/non-original card can conflict\n // with account state and require escalation rather than a substitute action.\n // This narrow feature is visible on the first turn and avoids sending every\n // ordinary return workflow to the expensive policy specialist.\n const policyExceptionSignal =\n agentDomain === \"retail\" &&\n /\\b(?:return|refund|send back|get (?:my |the )?money back)\\b|退货|退款|退回/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:amex|american express|visa|mastercard|credit card|debit card|different card|another card|other card)\\b|信用卡|借记卡|其他卡|另一张卡/i.test(\n scannedPrompt,\n );\n // A comparative selector can mention two products while requesting only\n // one write (for example \"send back the pricier one\"). Three-repeat tau2\n // calibration found no quality gain from the policy specialist on these\n // single-write cases, so keep them in a distinct, lower-cost risk band.\n const singleSelectedPolicyException =\n policyExceptionSignal &&\n /\\b(?:return|refund|send back)\\b[^.!?。!?]{0,96}\\b(?:the )?(?:pricier|cheaper|more expensive|less expensive|costlier|one)\\b/i.test(\n scannedPrompt,\n );\n // Returns and exchanges often pivot after confirmation (return -> rethink\n // -> exchange -> choose a variant). That future state is not visible to a\n // task-start router, so treat the observable workflow verb as the risk cue.\n // Simpler cancellation and one-field order edits stay on the standard path.\n const negotiatedWorkflowSignal =\n agentDomain === \"retail\" && /\\b(?:return|exchange)\\b|退货|退回|换货|交换/i.test(scannedPrompt);\n const numberedSteps = (scannedPrompt.match(/(?:^|\\s)\\d+(?:\\.\\d+)*[.)]\\s+/g) ?? []).length;\n const complexMultiToolPlan =\n likelyParallelToolCalls &&\n ((options.toolCount ?? 0) >= 6 || numberedSteps >= 3 || prompt.length > 1_200);\n let agentRisk: TaskFeatures[\"agentRisk\"] =\n needsTools && singleSelectedPolicyException\n ? \"policy_exception_simple\"\n : needsTools && policyExceptionSignal\n ? \"policy_exception\"\n : // Airline prompts that require a global optimum (for example the\n // cheapest itinerary across several candidates) are materially harder\n // than applying one change to every passenger in a known reservation.\n // Full-session evidence supports Sonnet for the former, while upgrading\n // the latter merely because it says \"all passengers\" caused a large cost\n // increase without a quality gain.\n needsTools &&\n agentDomain === \"airline\" &&\n (globalOptimizationSignal || conditionalGlobalWorkflowSignal)\n ? \"complex_high\"\n : needsTools &&\n (likelyParallelToolCalls ||\n globalChoiceSignal ||\n crossRecordSignal ||\n crossReservationBatchSignal ||\n negotiatedWorkflowSignal)\n ? \"high\"\n : \"standard\";\n const needsVision = options.hasVision ?? false;\n const needsStructuredOutput = options.requiresStructuredOutput ?? false;\n const latencySensitive =\n /\\b(?:urgent|asap|fast|quick|low latency|real[- ]time)\\b|尽快|马上|快速|低延迟/i.test(\n scannedPrompt,\n );\n const highStakes =\n /\\b(?:production|security|payment|legal|medical|financial|audit)\\b|生产|安全|支付|法律|医疗|财务|审计/i.test(\n scannedPrompt,\n );\n // Terminal tasks often describe the desired artifact rather than naming a\n // programming language. Treat only small, deterministic local build/file\n // work as implicit code. Operational deployment, credentials, destructive\n // work, evaluation, vision, and broad search stay on the stronger generic\n // tool-agent path. This is a request-side feature, not a benchmark ID list.\n const terminalToolSignal = normalizedToolNames.some((name) =>\n /^(?:terminalexec|terminalinspect|terminalsendkeys)$/.test(name),\n );\n const simpleTerminalArtifact =\n /\\b(?:create|write|convert|generate|build|implement|run|fix|repair|debug|make)\\b[\\s\\S]{0,120}\\b(?:file|script|csv|parquet|json|txt|server|endpoint)\\b/i.test(\n scannedPrompt,\n );\n // Multi-file repair is qualitatively different from fixing one known local\n // script. The agent must preserve state across inspections, infer ordering\n // and dependencies, edit several artifacts, and close the loop with tests.\n // A frozen Terminal-Bench trajectory showed the economy model spending 27\n // turns repeatedly rereading files without making an edit, while Opus solved\n // the same task in eight turns. Promote this request-visible pattern before\n // model scoring; no benchmark ID or expected answer is consulted.\n const terminalComplexRepair =\n terminalToolSignal &&\n /\\b(?:multiple|several)\\s+(?:scripts?|files?|components?)\\b|\\b(?:pipeline|dependencies)\\b[\\s\\S]{0,100}\\b(?:fail|issue|fix|repair|run|execute)\\b|\\b(?:identify|find|fix|repair)\\s+(?:and\\s+)?(?:fix\\s+)?all\\s+(?:the\\s+)?issues\\b/i.test(\n scannedPrompt,\n );\n // One artifact that must be accepted by multiple compilers/runtimes is not\n // a routine file-writing task. It requires reasoning across incompatible\n // grammars and validating every execution path; cheap code models can\n // produce plausible-looking source that satisfies neither toolchain.\n const mentionedTerminalRuntimes = new Set(\n (scannedPrompt.match(/\\b(?:gcc|clang|rustc|javac|go\\s+build|node|python)\\b/gi) ?? []).map(\n (name) => name.toLowerCase().replace(/\\s+/g, \" \"),\n ),\n );\n const terminalCrossRuntimeArtifact =\n terminalToolSignal &&\n (/\\bpolyglot\\b/i.test(scannedPrompt) ||\n /\\b(?:both|each)\\b[\\s\\S]{0,120}\\b(?:compilers?|runtimes?|toolchains?)\\b/i.test(\n scannedPrompt,\n ) ||\n (mentionedTerminalRuntimes.size >= 2 &&\n /\\b(?:compile|build|run|execute)\\b/i.test(scannedPrompt)));\n // Framework-to-native ports combine binary checkpoint inspection, weight\n // export, tensor-layout reasoning, image/data decoding, and a separately\n // compiled runtime. A task-start router can see this boundary directly in\n // the request (for example PyTorch state_dict -> a pure C CLI); treating it\n // like routine single-file C work caused a 30-turn read/retry loop in a\n // frozen official Terminal-Bench trajectory.\n const terminalFrameworkToNativeArtifact =\n terminalToolSignal &&\n /\\b(?:pytorch|tensorflow|jax|onnx|state[_ -]?dict|checkpoint|safetensors?)\\b|\\.(?:pth|pt|onnx)\\b/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:pure|native|programmed|written|implemented?)\\s+(?:in|using)\\s+(?:c\\+\\+|c|rust|go)\\b|\\b(?:c\\+\\+|c|rust|go)\\s+(?:program|binary|executable|cli|tool|implementation)\\b/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:inference|model|weights?|tensor|export|convert|load)\\b/i.test(scannedPrompt);\n if (\n needsTools &&\n (terminalComplexRepair || terminalCrossRuntimeArtifact || terminalFrameworkToNativeArtifact) &&\n (agentRisk === \"standard\" || agentRisk === \"high\")\n )\n agentRisk = \"complex_high\";\n const complexTerminalOperation =\n /\\b(?:git|ssh|nginx|https|certificate|authentication|credential|deploy|production|encrypt|gpg|shred|securely delete|decommission|benchmark|evaluate|embedding|chess|image|search the web|schema|statistical|statistics|aggregate|join|multiple inputs?)\\b/i.test(\n scannedPrompt,\n );\n // A bare \"token\" is not a credential signal: blockchain, tokenizer, and\n // LLM tasks use that word routinely (for example \"token transfers\"). Only\n // treat it as sensitive when the prompt gives it an authentication/secret\n // qualifier. API keys remain an unambiguous high-risk signal on their own.\n const terminalCredentialSignal =\n /\\b(?:ssh|nginx|certificate|authentication|credentials?|passwords?|api keys?|deploy|production|encrypt|gpg|shred|securely delete|decommission)\\b/i.test(\n scannedPrompt,\n ) ||\n /\\b(?:access|auth|authentication|bearer|secret|api)\\s+tokens?\\b|\\btokens?\\s+(?:secret|credential|authentication)\\b/i.test(\n scannedPrompt,\n );\n const terminalSafetySensitive = terminalToolSignal && (highStakes || terminalCredentialSignal);\n const implicitTerminalCode =\n needsTools &&\n terminalToolSignal &&\n agentRisk === \"standard\" &&\n !highStakes &&\n !complexTerminalOperation &&\n numberedSteps < 3 &&\n prompt.length <= 1_000 &&\n simpleTerminalArtifact;\n // Han characters alone also spell Japanese; kana marks the prompt as not\n // Mandarin, so it does not get the Mandarin-native extraction band.\n const language =\n /[\\u3400-\\u9fff]/.test(scannedPrompt) && !/[\\u3040-\\u30ff]/.test(scannedPrompt)\n ? \"zh\"\n : \"other\";\n const multipleChoiceSignals = (scannedPrompt.match(/(?:^|\\n)\\s*[A-D][.)]\\s+/gim) ?? []).length;\n const numericSignals = (scannedPrompt.match(/-?\\d+(?:[.,]\\d+)?/g) ?? []).length;\n const compactMathProblem =\n !hasCode &&\n prompt.length < 2_500 &&\n numericSignals >= 2 &&\n (/[+×÷=%$€£¥]|\\b(?:total|each|per|times|half|twice|percent|how many|how much|calculate)\\b/i.test(\n scannedPrompt,\n ) ||\n /[??]\\s*$/.test(scannedPrompt.trim()) ||\n numericSignals >= 3);\n\n let taskType: TaskType = \"chat\";\n if (needsVision) taskType = \"vision\";\n else if (estimatedInputTokens > 80_000) taskType = \"long_context\";\n else if (needsTools && (codeArtifact || (hasCode && codingAction) || implicitTerminalCode))\n taskType = \"code_agent\";\n else if (needsTools && likelyParallelToolCalls && !complexMultiToolPlan)\n taskType = \"tool_agent_parallel\";\n else if (needsTools) taskType = \"tool_agent\";\n else if (multipleChoiceSignals >= 3) taskType = \"reasoning_mcq\";\n else if (compactMathProblem) taskType = \"reasoning_math\";\n else if (\n errorClassSignal ||\n /\\b(?:bug|debug|error|failure|failing|regression|crash)\\b|修复|报错|错误|调试/i.test(text)\n )\n taskType = \"debug\";\n else if (hasCode || /\\b(?:refactor|implement|patch|edit|rewrite)\\b|重构|实现|修改/i.test(text))\n taskType = \"code_edit\";\n else if (needsStructuredOutput || /\\b(?:extract|json|schema|csv)\\b|字段|提取/i.test(text))\n taskType = \"extraction\";\n else if (\n /\\b(?:prove|derive|theorem|formal|mathematical|reasoning)\\b|证明|推导|定理|数学/i.test(text)\n )\n taskType = \"reasoning\";\n\n return {\n taskType,\n estimatedInputTokens,\n hasCode,\n needsTools,\n toolsAvailable,\n needsVision,\n needsStructuredOutput,\n latencySensitive,\n highStakes,\n language,\n likelyParallelToolCalls,\n complexMultiToolPlan,\n agentDomain,\n deepWebResearch,\n agentRisk,\n terminalToolSignal,\n terminalSafetySensitive,\n implicitTerminalCode,\n codeArtifact,\n };\n}\n\n/**\n * Task-affinity bands. Each table maps a model name (the id after the\n * provider slash) to its calibrated affinity for one request shape; anything\n * absent scores the neutral `NEUTRAL_AFFINITY`. Names are matched exactly:\n * model family names are intentionally similar (`gemini-2.5-flash` vs\n * `gemini-2.5-flash-lite`), and a substring match would let a smaller sibling\n * inherit a capability claim measured only for the flagship. A sibling joins a\n * band only with its own evidence.\n */\ntype AffinityBand = Readonly>;\n\n// Every \"gemini-3.6-flash\" value below is CARRIED from Gemini 3.5 Flash, not\n// measured on 3.6. The calibrations that set them (RouterBench GPQA/MGSM and\n// BFCL 2026-07-26/28, the Terminal-Bench and tau2 trajectories of 2026-07-28)\n// ran on 3.5. Google has answered the 3.5 name with 3.6 Flash since\n// ~2026-10-10, and on 2026-11-24 the gateways began redirecting 3.5 to 3.6, so\n// the router has in practice been routing 3.6 on these values since October;\n// the key now names the model that answers. The comments that cite \"Gemini\n// 3.5 Flash\" results describe those runs. Re-measure before treating any of\n// these as 3.6 evidence.\n//\n// Likewise every \"gemini-3.5-flash-lite\" value (extractionZh, extraction,\n// chat) is CARRIED from Gemini 2.5 Flash, which Google retired on 2026-12-01\n// and the gateways redirect to 3.5 Flash-Lite. It is a successor, not a\n// sibling claiming a flagship's evidence (see the rule above), but the values\n// were measured on 2.5 and still need a 3.5 Flash-Lite run.\n//\n// Likewise every \"gpt-5.6-luna\" value (and its place in the evidence pools and\n// the web-research order) is CARRIED from GPT-5 Mini, which OpenAI shuts down\n// on 2026-12-11 and the gateways redirect to GPT-5.6 Luna. The Terminal-Bench\n// and tau2 trajectories (2026-07-28) and the BrowseComp sessions behind them\n// ran on gpt-5-mini, a reasoning model; luna runs without reasoning, so these\n// are a placeholder, not luna evidence. Re-measure luna on those suites — or\n// move the bands to a measured model — before relying on them.\n\n/** Affinity of a model with no task-specific evidence. */\nconst NEUTRAL_AFFINITY = 0.68;\n\n// Strong native tool loop until the Responses function-output fix is deployed\n// on both gateways; Codex stays available below auto's affinity floor. Sonnet\n// has a verified native multi-turn tool loop and is the safe strong default.\nconst TERMINAL_COMPLEX_HIGH: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.3-codex\": 0.87,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n};\n\n// Complete-session BrowseComp calibration supersedes the earlier single-case\n// Opus promotion: strict deduplicated evidence has Sonnet 5 at 2/9 versus Opus\n// 5 at 0/3, while Opus also costs more and has a much longer tail. Opus stays\n// an availability fallback until a larger stable-provider sample supports it.\nconst WEB_RESEARCH_DEEP: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.88,\n \"gemini-3.6-flash\": 0.84,\n \"claude-opus-5\": 0.8,\n \"claude-opus-4.8\": 0.78,\n};\nconst WEB_RESEARCH: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.88,\n \"gemini-3.6-flash\": 0.86,\n \"claude-opus-5\": 0.84,\n \"claude-opus-4.8\": 0.82,\n};\n\nconst RETAIL_POLICY_EXCEPTION: AffinityBand = {\n \"gpt-4.1\": 1,\n \"claude-sonnet-5\": 0.9,\n \"deepseek-v4-pro\": 0.82,\n \"gpt-5.6-luna\": 0.8,\n \"gpt-4o-mini\": 0.76,\n};\nconst RETAIL_POLICY_EXCEPTION_SIMPLE: AffinityBand = {\n \"gpt-5.6-luna\": 1,\n \"gpt-4.1\": 0.86,\n \"deepseek-v4-pro\": 0.82,\n \"gpt-4o-mini\": 0.8,\n};\n\nconst AFFINITY = {\n // Seven valid full agent + official Terminal-Bench trajectories (2026-07-28)\n // gave GPT-5 Mini 4/7 resolved tasks versus 1/7 for the prior dynamic\n // code-agent choice. Its token-normalized total cost was higher in this small\n // calibration, so Codex and Sonnet keep quality priors above it; admitting\n // Mini to the scoring band lets the normal quality/cost profile choose it\n // without erasing stronger fallbacks. DeepSeek V4 Pro is kept below the\n // primary band after two consecutive mid-trajectory provider timeouts\n // contaminated its calibration runs.\n codeAgent: {\n \"gpt-5.3-codex\": 1,\n \"claude-sonnet-5\": 0.98,\n \"gpt-5.6-luna\": 0.96,\n \"gemini-3.6-flash\": 0.92,\n \"kimi-k3.1-pro\": 0.9,\n \"deepseek-v4-pro\": 0.88,\n \"glm-5.2\": 0.88,\n },\n // Seven official Terminal-Bench calibration trajectories favoured GPT-5 Mini\n // over the prior dynamic choice. Codex/Sonnet are close fallbacks; actual\n // request cost breaks the tie.\n terminalTool: {\n \"gpt-5.6-luna\": 1,\n \"gpt-5.3-codex\": 0.98,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.89,\n },\n // Two complete agent observations on the public Terminal-Bench\n // new-encrypt-command task ended in Codex repeating the same TerminalExec\n // input until the loop guard fired. Codex stays an availability fallback,\n // below the safety-band affinity floor, until its Responses function-output\n // path is verified on both gateways.\n terminalToolSafety: {\n \"claude-sonnet-5\": 1,\n \"claude-opus-4.8\": 0.9,\n \"gpt-5.3-codex\": 0.84,\n },\n // Full-session calibration: GPT-5 Mini completed two local/single retail\n // workflows at a fraction of Sonnet's token cost. It stays ineligible for\n // promotion when the prompt asks for multiple actions, cross-record\n // discovery or a global optimum; those trajectories exposed unstable write\n // arguments. DeepSeek V4 Pro completed all three high-risk retail calibration\n // trajectories (global-choice, cross-record, multi-write); Sonnet one.\n retailStandard: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.88,\n \"gemini-3.6-flash\": 0.82,\n \"gpt-5.3-codex\": 0.81,\n \"kimi-k3.1-pro\": 0.78,\n \"deepseek-v4-pro\": 0.76,\n },\n retailHigh: {\n \"deepseek-v4-pro\": 1,\n \"claude-sonnet-5\": 0.88,\n \"gemini-3.6-flash\": 0.82,\n \"gpt-5.3-codex\": 0.81,\n \"kimi-k3.1-pro\": 0.78,\n \"gpt-5.6-luna\": 0.76,\n },\n // Standard airline workflows stay on GPT-5 Mini: six full-session\n // development trajectories gave it the same 5/6 success as Sonnet at roughly\n // one order of magnitude lower normalized token cost. A held-out high-risk\n // cabin/date negotiation then produced a persistent empty assistant turn on\n // Mini even after a semantic retry, while Sonnet 5 completed the identical\n // official tau2 trajectory with reward 1.0. Only global optimization /\n // conditional-global work is promoted. A known batch of reservations is\n // operationally high-risk but still a structured tool workflow: current Tau\n // evidence has Mini and Sonnet at equal task reward there, while Sonnet costs\n // roughly two orders of magnitude more on the long-tail case.\n airlineComplex: {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n \"deepseek-v4-pro\": 0.74,\n },\n airlineStandard: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.8,\n \"deepseek-v4-pro\": 0.76,\n },\n // Full-trajectory tau2 calibration (2026-07-28, official gpt-4.1 simulator):\n // Sonnet 5 completed both an airline policy task and a retail multi-write\n // task with reward 1.0. Gemini 3.5 Flash emitted function calls as plain text\n // after the first structured calls and looped to the 100-step ceiling on the\n // airline task.\n toolAgent: {\n \"claude-sonnet-5\": 1,\n \"gemini-3.6-flash\": 0.88,\n \"gpt-5.3-codex\": 0.87,\n \"kimi-k3.1-pro\": 0.85,\n \"gpt-5.6-luna\": 0.84,\n \"deepseek-v4-pro\": 0.82,\n },\n // Multi-file Terminal work is not equivalent to a one-turn parallel\n // function-call benchmark. Sonnet is the strongest trajectory-tested\n // cost-controlled default; Opus remains a close safety fallback.\n parallelTerminalSafety: {\n \"claude-sonnet-5\": 1,\n \"claude-opus-4.8\": 0.9,\n \"gpt-5.3-codex\": 0.86,\n },\n parallelTerminal: {\n \"gpt-5.6-luna\": 1,\n \"gpt-5.3-codex\": 0.98,\n \"claude-sonnet-5\": 0.92,\n \"gemini-3.6-flash\": 0.88,\n },\n parallelRetail: {\n \"deepseek-v4-pro\": 1,\n \"claude-sonnet-5\": 0.88,\n \"claude-opus-4.8\": 0.84,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n },\n parallelAirlineComplex: {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.78,\n \"claude-opus-4.8\": 0.76,\n \"gemini-3.6-flash\": 0.74,\n },\n parallelAirline: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.8,\n },\n // RouterBench calibration, 2026-07-26: Opus 4.8 produced complete multi-call\n // payloads on 2/3 multilingual BFCL parallel cases. Gemini 3.5 Flash, Sonnet\n // 5, DeepSeek V4 Pro and Grok 4.5 were 0/3. This narrow prior only applies\n // after the conservative prompt feature in likelyNeedsParallelToolCalls.\n parallel: {\n \"claude-opus-4.8\": 1,\n \"claude-sonnet-5\": 0.84,\n \"grok-4.5\": 0.82,\n \"gemini-3.6-flash\": 0.8,\n \"deepseek-v4-pro\": 0.78,\n },\n codeEdit: {\n \"gpt-5.3-codex\": 1,\n \"claude-sonnet-4.6\": 0.94,\n \"glm-5.2\": 0.9,\n \"deepseek-v4-pro\": 0.86,\n },\n reasoning: {\n \"claude-sonnet-5\": 0.98,\n \"claude-sonnet-4.6\": 0.98,\n \"deepseek-v4-pro\": 0.95,\n \"grok-4.5\": 0.94,\n \"gemini-3.1-pro\": 0.92,\n \"gemini-3.6-flash\": 0.92,\n },\n // RouterBench calibration (2026-07-28, six stratified GPQA Diamond tasks,\n // identical agent adapter and 512-token budget): Gemini 3 Flash Preview\n // scored 5/6, Gemini 3.5 Flash 4/6, and Gemini 3.1 Pro 3/6 while costing\n // ~170x more than Flash. The measured winner is the narrow default; version\n // recency alone is not a quality signal. Unused host tools must not change\n // this reasoning-only model choice.\n reasoningMcq: {\n \"gemini-3-flash-preview\": 1,\n \"gemini-3.6-flash\": 0.91,\n \"grok-4.5\": 0.9,\n \"claude-sonnet-5\": 0.88,\n \"deepseek-v4-pro\": 0.84,\n },\n // Same calibration, five multilingual MGSM tasks: Gemini 3.5 Flash was 5/5\n // with the lowest cost and latency; four current flagships were 4/5 and Kimi\n // K2.7 was 3/5.\n //\n // Kimi K3.1 Pro, paired against Kimi K3 (2026-11-23): all 50 rows of the\n // pinned RouterBench MGSM slice (5 per language x 10 languages), the text\n // adapter's `Answer: ` contract and deterministic grader, 512 output\n // tokens, temperature 0, same rows and settings for both. K3 44/50, K3.1 Pro\n // 41/50; discordant pairs 5 K3-only vs 2 K3.1-only (not significant). Every\n // K3-only win was K3.1 Pro hitting the 512-token cap; the non-truncated\n // errors were the same two rows for both. Rerunning the 10 truncated rows at\n // 2048 tokens gave 8/10 each (46/50 each overall), so the gap is verbosity at\n // the calibration budget, not arithmetic. K3.1 Pro was also slower (p95\n // 10.4s vs 4.7s). It moves from K3's carried 0.9 to 0.88: below the models\n // the 4/5 calibration put at 0.9, by less than the raw 41/44 ratio because\n // the difference is within noise.\n reasoningMath: {\n \"gemini-3.6-flash\": 1,\n \"grok-4.5\": 0.93,\n \"claude-sonnet-5\": 0.9,\n \"deepseek-v4-pro\": 0.9,\n \"kimi-k3.1-pro\": 0.88,\n },\n vision: {\n \"gemini-3.1-pro\": 0.96,\n \"qwen3.7-max\": 0.9,\n \"claude-sonnet-4.6\": 0.9,\n \"kimi-k3.1-pro\": 0.9,\n \"grok-4.3\": 0.9,\n },\n // Long-context eligibility is necessary but not sufficient: a provider can\n // advertise a 1M window yet return an empty completion near that boundary.\n // The proven long-context flagship leads, and less-established alternatives\n // sit in a separate band so price alone cannot displace it.\n longContext: {\n \"gemini-3.1-pro\": 1,\n \"qwen3.7-max\": 0.89,\n \"glm-5.2\": 0.89,\n \"gemini-3.6-flash\": 0.88,\n \"deepseek-v4-pro\": 0.85,\n },\n // A structured extraction must preserve both the output contract and the\n // source-language fields. For Mandarin input the language-native Kimi\n // candidate gets a distinct band — a candidate-pool decision, not a post-hoc\n // override, so it still falls back normally when Kimi is unavailable. The\n // Kimi flagship costs several times the cheap extraction models, so the band\n // must be wider than the auto affinityFloorGap (0.10) or price alone\n // re-selects a non-native model for Mandarin input; 0.12 keeps Kimi alone in\n // the primary band for zh and leaves every other language untouched.\n //\n // Only one \"kimi-k3.1-pro\" value in AFFINITY is measured on K3.1 Pro:\n // reasoningMath (paired K3 vs K3.1 Pro on 50 MGSM rows, 2026-11-23; see that\n // band). Every other value (codeAgent, retailStandard, retailHigh,\n // toolAgent, vision, extractionZh, extraction, chat) is still carried over\n // from the Kimi flagship it replaced (K3, whose values were in turn carried\n // from K2.7). Those bands' calibrations could not be rerun locally: the\n // Terminal-Bench and tau2 trajectories need the RouterBench Franklin host\n // (and Docker for Terminal-Bench), and no extraction or vision slice has a\n // runner. K3.1 Pro's other evidence is the 2026-11-23 live probe: 3/3\n // completions, 0 errors, a well-formed tool call.\n extractionZh: {\n \"kimi-k3.1-pro\": 1,\n \"gemini-3.6-flash\": 0.88,\n \"gemini-3.5-flash-lite\": 0.88,\n \"gpt-4o-mini\": 0.88,\n \"claude-sonnet-5\": 0.88,\n \"claude-sonnet-4.6\": 0.88,\n },\n extraction: {\n \"kimi-k3.1-pro\": 0.9,\n \"gemini-3.6-flash\": 0.9,\n \"gemini-3.5-flash-lite\": 0.9,\n \"gpt-4o-mini\": 0.9,\n \"claude-sonnet-5\": 0.9,\n \"claude-sonnet-4.6\": 0.9,\n },\n chat: {\n \"gemini-3.6-flash\": 0.86,\n \"gemini-3.5-flash-lite\": 0.86,\n \"kimi-k3.1-pro\": 0.86,\n },\n} as const satisfies Record;\n\n/** The affinity band that applies to a classified request. */\nfunction affinityBand(features: TaskFeatures): AffinityBand {\n const { taskType, agentDomain, agentRisk, deepWebResearch, terminalToolSignal } = features;\n const terminalSafety = features.terminalSafetySensitive;\n switch (taskType) {\n case \"code_agent\":\n return terminalToolSignal && agentRisk === \"complex_high\"\n ? TERMINAL_COMPLEX_HIGH\n : AFFINITY.codeAgent;\n case \"tool_agent\":\n if (terminalToolSignal && agentRisk === \"complex_high\") return TERMINAL_COMPLEX_HIGH;\n if (terminalToolSignal) return terminalSafety ? AFFINITY.terminalToolSafety : AFFINITY.terminalTool;\n if (agentDomain === \"web_research\") return deepWebResearch ? WEB_RESEARCH_DEEP : WEB_RESEARCH;\n if (agentDomain === \"retail\") {\n if (agentRisk === \"standard\") return AFFINITY.retailStandard;\n if (agentRisk === \"policy_exception\") return RETAIL_POLICY_EXCEPTION;\n if (agentRisk === \"policy_exception_simple\") return RETAIL_POLICY_EXCEPTION_SIMPLE;\n return AFFINITY.retailHigh;\n }\n if (agentDomain === \"airline\") {\n return agentRisk === \"complex_high\" ? AFFINITY.airlineComplex : AFFINITY.airlineStandard;\n }\n return AFFINITY.toolAgent;\n case \"tool_agent_parallel\":\n if (terminalToolSignal) {\n return terminalSafety ? AFFINITY.parallelTerminalSafety : AFFINITY.parallelTerminal;\n }\n if (agentDomain === \"web_research\") return deepWebResearch ? WEB_RESEARCH_DEEP : WEB_RESEARCH;\n if (agentDomain === \"retail\") {\n if (agentRisk === \"policy_exception\") return RETAIL_POLICY_EXCEPTION;\n if (agentRisk === \"policy_exception_simple\") return RETAIL_POLICY_EXCEPTION_SIMPLE;\n return AFFINITY.parallelRetail;\n }\n if (agentDomain === \"airline\") {\n return agentRisk === \"complex_high\" ? AFFINITY.parallelAirlineComplex : AFFINITY.parallelAirline;\n }\n return AFFINITY.parallel;\n case \"code_edit\":\n case \"debug\":\n return AFFINITY.codeEdit;\n case \"reasoning\":\n return AFFINITY.reasoning;\n case \"reasoning_mcq\":\n return AFFINITY.reasoningMcq;\n case \"reasoning_math\":\n return AFFINITY.reasoningMath;\n case \"vision\":\n return AFFINITY.vision;\n case \"long_context\":\n return AFFINITY.longContext;\n case \"extraction\":\n return features.language === \"zh\" ? AFFINITY.extractionZh : AFFINITY.extraction;\n case \"chat\":\n return AFFINITY.chat;\n }\n}\n\n/** A model's affinity within a band: its calibrated score, never below neutral. */\nfunction affinityIn(band: AffinityBand, modelId: string): number {\n const name = modelId.toLowerCase().slice(modelId.indexOf(\"/\") + 1);\n return Math.max(NEUTRAL_AFFINITY, band[name] ?? 0);\n}\n\nfunction evidenceCandidates(task: TaskType): string[] {\n if (task === \"code_agent\") {\n return [\n \"openai/gpt-5.3-codex\",\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"google/gemini-3.6-flash\",\n \"moonshot/kimi-k3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"tool_agent\") {\n return [\n \"anthropic/claude-sonnet-5\",\n \"anthropic/claude-opus-5\",\n \"openai/gpt-5.6-luna\",\n \"openai/gpt-4.1\",\n \"openai/gpt-4o-mini\",\n \"google/gemini-3.6-flash\",\n \"openai/gpt-5.3-codex\",\n \"moonshot/kimi-k3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"tool_agent_parallel\") {\n return [\n \"anthropic/claude-opus-5\",\n \"anthropic/claude-opus-4.8\",\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"openai/gpt-4.1\",\n \"openai/gpt-4o-mini\",\n \"xai/grok-4.5\",\n \"google/gemini-3.6-flash\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"long_context\") {\n return [\n \"google/gemini-3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n \"qwen/qwen3.7-max\",\n \"zai/glm-5.2\",\n \"google/gemini-3.6-flash\",\n ];\n }\n if (task === \"reasoning_mcq\") {\n return [\n \"google/gemini-3-flash-preview\",\n \"google/gemini-3.6-flash\",\n \"xai/grok-4.5\",\n \"anthropic/claude-sonnet-5\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"extraction\") {\n // The Kimi flagship is not on the auto MEDIUM chain (K2.7 was); the\n // language-native extraction band (AFFINITY.extractionZh) needs it in the pool.\n return [\"moonshot/kimi-k3.1-pro\", \"google/gemini-3.6-flash\", \"anthropic/claude-sonnet-5\"];\n }\n if (task === \"reasoning_math\") {\n return [\n \"google/gemini-3.6-flash\",\n \"xai/grok-4.5\",\n \"anthropic/claude-sonnet-5\",\n \"deepseek/deepseek-v4-pro\",\n \"moonshot/kimi-k3.1-pro\",\n ];\n }\n return [];\n}\n\n/**\n * Recently added catalog models with a verified structured function call.\n *\n * Tool compliance is enough to make these models safe availability fallbacks,\n * but it is not evidence that they should displace a trajectory-benchmarked\n * primary. Keep them after the configured and benchmark-backed chains until a\n * full agent evaluation earns a task-specific affinity above NEUTRAL_AFFINITY\n * floor. `isEligible` still applies every host capability override, context\n * limit, vision constraint, and unavailable-model guard before they are used.\n */\nconst VERIFIED_TOOL_FALLBACKS = [\n \"anthropic/claude-fable-5.1\",\n \"anthropic/claude-opus-5.5\",\n \"anthropic/claude-sonnet-5.5\",\n \"deepseek/deepseek-v4.1-flash\",\n \"google/gemini-3.8-flash\",\n \"google/gemini-4-carbon\",\n \"openai/gpt-5.1\",\n \"openai/gpt-6-astra\",\n \"openai/gpt-6-luna\",\n \"openai/gpt-6-sol\",\n \"openai/gpt-6.1-sol\",\n \"xai/grok-4.6\",\n \"xai/grok-4.7\",\n \"xiaomi/mimo-v2.5\",\n] as const;\n\nfunction isEligible(\n modelId: string,\n features: TaskFeatures,\n maxOutputTokens: number,\n options: RouterOptions,\n): boolean {\n const model = options.modelCapabilities?.[modelId] ?? DEFAULT_MODEL_CAPABILITIES[modelId];\n // Preserve compatibility for temporarily catalog-less fallback IDs. They are\n // kept behind known-model candidates but are not silently dropped.\n if (!model) return true;\n if (features.needsTools && !model.supportsTools) return false;\n if (features.needsVision && !model.supportsVision) return false;\n if (features.needsStructuredOutput && !model.supportsTools) return false;\n if (model.maxOutputTokens < maxOutputTokens) return false;\n return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;\n}\n\nfunction estimatedCost(\n modelId: string,\n options: RouterOptions,\n inputTokens: number,\n outputTokens: number,\n): number {\n const price = usablePricing(options.modelPricing.get(modelId));\n if (!price) return Number.POSITIVE_INFINITY;\n if (price.flatPrice !== undefined) return price.flatPrice;\n return (inputTokens * price.inputPrice + outputTokens * price.outputPrice) / 1_000_000;\n}\n\nfunction profileScore(\n modelId: string,\n options: RouterOptions,\n now: Date,\n):\n | { quality?: number; speed: number; tailSpeed: number; reliability: number; freshness: number }\n | undefined {\n const profile: ModelPerformanceProfile | undefined =\n options.modelPerformance?.[modelId] ??\n LIVE_MODEL_PROFILES[modelId] ??\n HISTORICAL_MODEL_PROFILES[modelId];\n if (!profile) return undefined;\n const measuredAt = Date.parse(profile.measuredAt);\n if (!Number.isFinite(measuredAt)) return undefined;\n // A host-injected observation with a missing or non-numeric field would\n // turn the whole score into NaN, and NaN compares as \"equal\" in the sort,\n // freezing that candidate wherever it landed. Treat it as no observation.\n const finite = (value: number | undefined, optional: boolean) =>\n value === undefined ? optional : Number.isFinite(value) && value >= 0;\n if (\n !finite(profile.latencyMs, false) ||\n !finite(profile.outputTokensPerSecond, false) ||\n !finite(profile.p95LatencyMs, true) ||\n !finite(profile.intelligenceIndex, true) ||\n !finite(profile.errorRate, true) ||\n !finite(profile.samples, true)\n ) {\n return undefined;\n }\n const ageDays = Math.max(0, (now.getTime() - measuredAt) / 86_400_000);\n // A 30-day half-life makes old data a tie-breaker only. Small probe runs are\n // also weak evidence: three quick samples should not overturn a curated\n // tier ordering merely because of a transient provider tail. Callers that\n // inject an observation without a sample count retain the legacy full\n // confidence behaviour for compatibility.\n const sampleConfidence =\n profile.samples === undefined ? 1 : Math.min(1, Math.max(0, profile.samples) / 10);\n const freshness = Math.pow(0.5, ageDays / 30) * sampleConfidence;\n const quality =\n profile.intelligenceIndex === undefined\n ? undefined\n : Math.min(1, profile.intelligenceIndex / 50);\n const speed = Math.min(\n 1,\n (2_000 / Math.max(500, profile.latencyMs) + profile.outputTokensPerSecond / 250) / 2,\n );\n const tailSpeed = Math.min(1, 3_000 / Math.max(750, profile.p95LatencyMs ?? profile.latencyMs));\n const reliability = Math.max(0, 1 - (profile.errorRate ?? 0));\n return { quality, speed, tailSpeed, reliability, freshness };\n}\n\n/** Candidate router used for Auto. Rules still set the capability tier; V3 ranks within it. */\nexport class PortfolioStrategy implements RouterStrategy {\n readonly name = \"portfolio\";\n // Rules set the capability tier; the strategy is stateless, so one instance serves every request.\n private readonly rules = new RulesStrategy();\n\n route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n ) {\n const features = classifyTask(prompt, systemPrompt, options);\n const base = this.rules.route(prompt, systemPrompt, maxOutputTokens, {\n ...options,\n requiresTools: features.needsTools,\n });\n const tierConfigs = base.tierConfigs;\n if (!tierConfigs) return base;\n // The rules score sets the capability tier, but two task types carry a\n // floor of their own: a compact reasoning problem belongs on the\n // reasoning chain however short it is, and a code edit or stack trace\n // belongs at least on the MEDIUM chain — the SIMPLE chain is curated for\n // trivia and translation and has no model with code affinity. The code\n // floor requires a code artifact or coding action: `debug` and `code_edit`\n // are also assigned from bare verbs (\"rewrite this sentence\", \"margin of\n // error\") and bare language names (\"What is Python?\"), and that prose\n // must stay on the cheap chain.\n const targetTier: Tier =\n (features.taskType === \"reasoning_mcq\" || features.taskType === \"reasoning_math\") &&\n (base.tier === \"SIMPLE\" || base.tier === \"MEDIUM\")\n ? \"REASONING\"\n : (features.taskType === \"debug\" || features.taskType === \"code_edit\") &&\n features.codeArtifact &&\n base.tier === \"SIMPLE\"\n ? \"MEDIUM\"\n : base.tier;\n const tierConfig = tierConfigs[targetTier];\n const configuredCandidates = tierConfig ? getFallbackChain(targetTier, tierConfigs) : [];\n // Evidence candidates join the configured chain, but the host's\n // unavailable set applies to both: the configured side arrives filtered\n // through RulesStrategy, and a dead evidence model must not re-enter here.\n const unavailable = new Set(options.unavailableModels ?? []);\n // `modelPricing` is the host's live catalog view. Do not introduce a\n // built-in fallback that the current gateway does not advertise. These\n // models carry no task evidence, so outside Premium the cheapest one is\n // the first recovery hop; otherwise an outage of the curated chain would\n // jump an Eco turn straight to the most expensive model in the list.\n const verifiedToolFallbacks = features.needsTools\n ? VERIFIED_TOOL_FALLBACKS.filter((model) => options.modelPricing.has(model))\n : [];\n if (options.routingProfile !== \"premium\") {\n const fallbackCost = (model: string) =>\n estimatedCost(model, options, features.estimatedInputTokens, maxOutputTokens);\n verifiedToolFallbacks.sort((a, b) => fallbackCost(a) - fallbackCost(b));\n }\n const chain = [\n ...new Set([\n ...configuredCandidates,\n ...evidenceCandidates(features.taskType),\n ...verifiedToolFallbacks,\n ]),\n ].filter(\n (model): model is string =>\n typeof model === \"string\" && model.length > 0 && !unavailable.has(model),\n );\n const eligible = new Set(\n chain.filter((model) => isEligible(model, features, maxOutputTokens, options)),\n );\n // When nothing is eligible the whole chain competes, scored as incapable.\n const eligibleCandidates = eligible.size > 0 ? [...eligible] : chain;\n if (eligibleCandidates.length === 0) return base;\n const profileName =\n options.routingProfile === \"eco\"\n ? \"eco\"\n : options.routingProfile === \"premium\"\n ? \"premium\"\n : \"auto\";\n const portfolio = options.config.portfolio ?? DEFAULT_PORTFOLIO_WEIGHTS;\n const band = affinityBand(features);\n const affinityCache = new Map();\n const getAffinity = (model: string) => {\n let value = affinityCache.get(model);\n if (value === undefined) {\n value = affinityIn(band, model);\n affinityCache.set(model, value);\n }\n return value;\n };\n const bestAffinity = Math.max(...eligibleCandidates.map(getAffinity));\n const specificAffinity = eligibleCandidates.filter((model) => getAffinity(model) > NEUTRAL_AFFINITY);\n // A tier's fallback list is primarily an availability/recovery chain, not a\n // set of equally validated substitutes. Re-ranking every fallback lets a\n // cheap generic model displace the curated primary merely because it has a\n // favourable short performance probe. Only promote models with explicit\n // task affinity; otherwise retain the first capability-eligible tier model.\n const affinityPool = specificAffinity.length > 0 ? specificAffinity : [eligibleCandidates[0]];\n // Generic Terminal work has much wider trajectory variance than a BFCL-like\n // one-turn parallel call. Keep the strong-model safety band, but admit the\n // next capable tier so Auto's cost/reliability score can reject an Opus\n // primary that is materially more expensive without measured benefit.\n const affinityFloorGap = features.terminalToolSignal\n ? Math.max(\n portfolio.affinityFloorGap[profileName],\n features.terminalSafetySensitive ? 0.15 : 0.12,\n )\n : portfolio.affinityFloorGap[profileName];\n const candidates = affinityPool.filter(\n (model) => getAffinity(model) >= bestAffinity - affinityFloorGap,\n );\n const costs = candidates.map((model) =>\n estimatedCost(model, options, features.estimatedInputTokens, maxOutputTokens),\n );\n const finiteCosts = costs.filter(Number.isFinite);\n const minCost = finiteCosts.length > 0 ? Math.min(...finiteCosts) : 0;\n const maxCost = finiteCosts.length > 0 ? Math.max(...finiteCosts) : 1;\n\n const now = options.now ?? new Date();\n const profileWeights = portfolio[profileName];\n const rankedEntries = candidates\n .map((model, index) => {\n const cost = costs[index];\n // An unpriced candidate costs an unknown amount, so it scores as the\n // most expensive rather than a neutral 0.5 that let it outrank\n // priced models. Pricing presence still never filters a candidate.\n const costScore = !Number.isFinite(cost)\n ? 0\n : maxCost > minCost\n ? 1 - (cost - minCost) / (maxCost - minCost)\n : 0.5;\n const capabilityScore = eligible.has(model) ? 1 : 0;\n const profile = profileScore(model, options, now);\n // Fresh observations can refine affinity. Historical observations fade\n // quickly and never replace task-level RouterBench evidence.\n const observedQuality =\n profile?.quality === undefined\n ? getAffinity(model)\n : getAffinity(model) * (1 - profile.freshness) + profile.quality * profile.freshness;\n // Every observed dimension fades toward its neutral prior as the\n // observation ages, exactly like reliability below. Fading speed\n // toward zero instead ranked any model with a stale probe below a\n // model nobody had measured, which the latter's 0.5 silently won.\n const observedSpeed = profile\n ? profile.speed * profile.freshness + 0.5 * (1 - profile.freshness)\n : 0.5;\n const observedTailSpeed = profile\n ? profile.tailSpeed * profile.freshness + 0.5 * (1 - profile.freshness)\n : 0.5;\n const observedReliability = profile\n ? profile.reliability * profile.freshness + (1 - profile.freshness)\n : 1;\n // Preserve a small amount of the hand-curated fallback order while V3's\n // task affinity and real request constraints do the primary work.\n const legacyScore = 1 - index / Math.max(1, candidates.length - 1);\n const qualityWeight =\n profileWeights.quality + (features.highStakes ? portfolio.highStakesBoost.quality : 0);\n const speedScore = features.latencySensitive ? observedTailSpeed : observedSpeed;\n const speedWeight =\n profileWeights.speed +\n (features.latencySensitive ? portfolio.latencySensitiveSpeedBoost : 0);\n const reliabilityWeight =\n profileWeights.reliability +\n (features.highStakes ? portfolio.highStakesBoost.reliability : 0);\n const score =\n observedQuality * qualityWeight +\n capabilityScore * profileWeights.capability +\n costScore * profileWeights.cost +\n speedScore * speedWeight +\n observedReliability * reliabilityWeight +\n legacyScore * profileWeights.legacy;\n return {\n model,\n score,\n quality: observedQuality,\n cost: costScore,\n speed: speedScore,\n reliability: observedReliability,\n };\n })\n .sort((a, b) => b.score - a.score);\n const scoredModels = rankedEntries.map((item) => item.model);\n // The affinity floor controls which models may compete for the primary;\n // it must not erase availability fallbacks. Append all remaining eligible\n // models in their curated chain order after the scored primary pool.\n const webResearchFallbackOrder = [\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"google/gemini-3.6-flash\",\n \"anthropic/claude-opus-5\",\n \"anthropic/claude-opus-4.8\",\n \"openai/gpt-5.3-codex\",\n ];\n const ranked =\n features.agentDomain === \"web_research\"\n ? [\n ...scoredModels,\n ...webResearchFallbackOrder.filter(\n (model) => eligibleCandidates.includes(model) && !scoredModels.includes(model),\n ),\n ...eligibleCandidates.filter(\n (model) => !scoredModels.includes(model) && !webResearchFallbackOrder.includes(model),\n ),\n ]\n : [...scoredModels, ...eligibleCandidates.filter((model) => !scoredModels.includes(model))];\n\n const model = ranked[0] ?? base.model;\n const selectedTierConfigs: Record = {\n ...tierConfigs,\n [targetTier]: { primary: model, fallback: ranked.slice(1) },\n };\n // selectModel only reads the selected tier; retain the complete tier map for host fallback.\n const decision = selectModel(\n targetTier,\n base.confidence,\n \"portfolio\",\n `${base.reasoning} | v3 task=${features.taskType} agentRisk=${features.agentRisk} deepWebResearch=${features.deepWebResearch} terminalCode=${features.implicitTerminalCode} terminalSafety=${features.terminalSafetySensitive} candidates=${ranked.length}`,\n selectedTierConfigs,\n options.modelPricing,\n features.estimatedInputTokens,\n maxOutputTokens,\n options.routingProfile,\n base.agenticScore,\n );\n return {\n ...decision,\n tierConfigs: selectedTierConfigs,\n profile: base.profile,\n candidates: ranked,\n candidateScores: rankedEntries.map(({ model, score, quality, cost, speed, reliability }) => ({\n model,\n score,\n quality,\n cost,\n speed,\n reliability,\n })),\n taskType: features.taskType,\n routerVersion: \"v3-portfolio\" as const,\n };\n }\n}\n","/** Pure public-catalog parsing. Fetching, caching and UI ordering belong to hosts. */\nimport { DEFAULT_MODEL_CAPABILITIES, type ModelCapabilities } from \"./model-capabilities.js\";\nimport type { ModelPricing } from \"./selector.js\";\n\nexport const MODEL_KINDS = [\"chat\", \"image\", \"video\", \"music\"] as const;\nexport type ModelKind = (typeof MODEL_KINDS)[number];\n\n/** Gateway units are preserved: token prices per 1M tokens; media per unit. */\nexport interface CatalogPricing {\n input?: number;\n output?: number;\n per_image?: number;\n per_second?: number;\n per_track?: number;\n cache_read?: number;\n cache_write?: number;\n transaction_fee?: number;\n per_call_surcharge?: number;\n default_duration_seconds?: number;\n max_duration_seconds?: number;\n}\n\nexport interface CatalogModel {\n id: string;\n name: string;\n categories: readonly string[];\n kinds: readonly ModelKind[];\n billingMode?: string;\n /** Zero pricing alone does not imply a free model. */\n free: boolean;\n pricing: CatalogPricing;\n contextWindow?: number;\n maxOutputTokens?: number;\n}\n\nexport interface ModelCatalog {\n models: readonly CatalogModel[];\n chat: readonly CatalogModel[];\n image: readonly CatalogModel[];\n video: readonly CatalogModel[];\n music: readonly CatalogModel[];\n /**\n * IDs whose authoritative row says `available: false`. The gateway does not\n * reject these; it substitutes another model. Absence from the listing is\n * not unavailability: hidden IDs are still served.\n */\n unavailable: readonly string[];\n}\n\nconst PRICE_KEYS = [\n \"input\", \"output\", \"per_image\", \"per_second\", \"per_track\", \"cache_read\", \"cache_write\",\n \"transaction_fee\", \"per_call_surcharge\", \"default_duration_seconds\", \"max_duration_seconds\",\n] as const;\nconst UNIT_PRICE = { image: \"per_image\", video: \"per_second\", music: \"per_track\" } as const;\nconst MODEL_ID = /^[a-z0-9][a-z0-9._-]*\\/[a-zA-Z0-9][a-zA-Z0-9._:+-]*$/;\nconst record = (value: unknown): value is Record =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst price = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value) && value >= 0;\nconst capacity = (value: unknown): number | undefined =>\n typeof value === \"number\" && Number.isSafeInteger(value) && value > 0 ? value : undefined;\n\n/**\n * Normalize GET /api/v1/models without a model-ID allowlist. New provider IDs\n * appear immediately. Hidden/unavailable rows and invalid per-kind prices are\n * omitted. A malformed envelope throws so a host can retain its last good list;\n * an explicitly empty `data` array is a valid empty catalog.\n *\n * IDs explicitly marked `available: false` are also listed in `unavailable`.\n * Rows outside MODEL_KINDS (speech, sound effects) are omitted.\n *\n * Last duplicate wins, including a final unavailable/invalid row. No sorting,\n * price markup, network request, capability probe or media routing is performed.\n */\nexport function parseModelCatalog(value: unknown): ModelCatalog {\n if (!record(value) || !Array.isArray(value.data)) {\n throw new TypeError(\"Model catalog must contain a data array\");\n }\n const entries = new Map>();\n for (const entry of value.data) {\n if (record(entry) && typeof entry.id === \"string\" && entry.id.length <= 200 && MODEL_ID.test(entry.id)) {\n entries.set(entry.id, entry);\n }\n }\n const result: ModelCatalog = { models: [], chat: [], image: [], video: [], music: [], unavailable: [] };\n const models: CatalogModel[] = [];\n const unavailable: string[] = [];\n for (const [id, entry] of entries) {\n if (entry.available === false) unavailable.push(id);\n if ((entry.available !== undefined && entry.available !== true) ||\n (entry.hidden !== undefined && entry.hidden !== false) ||\n !Array.isArray(entry.categories) || !record(entry.pricing)) continue;\n const categories = [...new Set(entry.categories.filter((c): c is string => typeof c === \"string\"))];\n const rawPricing = entry.pricing;\n const pricing: CatalogPricing = {};\n for (const key of PRICE_KEYS) if (price(rawPricing[key])) pricing[key] = rawPricing[key];\n const kinds = MODEL_KINDS.filter(kind => categories.includes(kind) && (kind === \"chat\"\n ? price(rawPricing.input) && price(rawPricing.output)\n : price(rawPricing[UNIT_PRICE[kind]])));\n if (!kinds.length) continue;\n const model: CatalogModel = {\n id, name: typeof entry.name === \"string\" && entry.name.trim() ? entry.name : id,\n categories, kinds, pricing,\n free: kinds.includes(\"chat\") && entry.billing_mode === \"free\" && pricing.input === 0 && pricing.output === 0,\n ...(typeof entry.billing_mode === \"string\" ? { billingMode: entry.billing_mode } : {}),\n ...(capacity(entry.context_window) !== undefined ? { contextWindow: capacity(entry.context_window) } : {}),\n ...(capacity(entry.max_output) !== undefined ? { maxOutputTokens: capacity(entry.max_output) } : {}),\n };\n models.push(model);\n }\n result.models = models;\n result.unavailable = unavailable;\n for (const kind of MODEL_KINDS) result[kind] = models.filter(model => model.kinds.includes(kind));\n return result;\n}\n\nexport interface CatalogRoutingOptions {\n /** Host evidence, merged over (and overriding per ID) the bundled verified table. */\n verifiedCapabilities?: Readonly>;\n}\n\nexport interface RoutingCatalog {\n modelPricing: Map;\n modelCapabilities: Record;\n unavailableModels: string[];\n}\n\n/**\n * Adapt only the chat catalog for route(). Media never enters LLM candidate\n * chains. Tool support comes from verified evidence, never a name or category.\n * Unknown capacities are zero, rather than invented defaults.\n *\n * Only rows the gateway explicitly marks `available: false` become\n * unavailableModels. Configured IDs that are merely absent from the listing\n * stay routable: the gateway serves hidden IDs, and only the configured chain\n * knows about them.\n */\nexport function toRoutingCatalog(catalog: ModelCatalog, options: CatalogRoutingOptions = {}): RoutingCatalog {\n const verified = { ...DEFAULT_MODEL_CAPABILITIES, ...options.verifiedCapabilities };\n const modelPricing = new Map();\n const modelCapabilities: Record = {};\n for (const model of catalog.chat) {\n modelPricing.set(model.id, { inputPrice: model.pricing.input!, outputPrice: model.pricing.output! });\n const evidence = verified[model.id];\n modelCapabilities[model.id] = {\n contextWindow: model.contextWindow ?? evidence?.contextWindow ?? 0,\n maxOutputTokens: model.maxOutputTokens ?? evidence?.maxOutputTokens ?? 0,\n supportsTools: evidence?.supportsTools === true,\n // Verified evidence wins over the category tag in both directions: the\n // catalog omits \"vision\" for some models that accept images and tags\n // others whose image input does not hold up (see capability-overrides).\n supportsVision: evidence?.supportsVision ?? model.categories.includes(\"vision\"),\n };\n }\n return { modelPricing, modelCapabilities, unavailableModels: [...catalog.unavailable] };\n}\n","/**\n * Smart Router Entry Point\n *\n * Classifies requests and routes to the cheapest capable model.\n * Delegates to pluggable RouterStrategy (default: RulesStrategy, <1ms).\n */\n\nimport type { RoutingDecision, RouterOptions } from \"./types.js\";\nimport { getStrategy, registerStrategy } from \"./strategy.js\";\nimport { PortfolioStrategy } from \"./portfolio.js\";\n\n// Register here instead of strategy.ts so PortfolioStrategy can reuse the\n// stable RulesStrategy without introducing a module cycle.\nregisterStrategy(new PortfolioStrategy());\n\n/**\n * Route a request to the cheapest capable model.\n * Delegates to the configured strategy (PortfolioStrategy by default).\n */\nexport function route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n): RoutingDecision {\n const strategy = getStrategy(options.config.strategy ?? \"portfolio\");\n return strategy.route(prompt, systemPrompt, maxOutputTokens, options);\n}\n\nexport { getStrategy, registerStrategy, applyUnavailableModels } from \"./strategy.js\";\nexport { RulesStrategy } from \"./strategy.js\";\nexport { PortfolioStrategy } from \"./portfolio.js\";\nexport { classifyByRules } from \"./rules.js\";\nexport { inferToolRequirement } from \"./tool-intent.js\";\nexport { estimateTokens } from \"./tokens.js\";\nexport { MODEL_KINDS, parseModelCatalog, toRoutingCatalog } from \"./catalog.js\";\nexport type {\n ModelKind, CatalogPricing, CatalogModel, ModelCatalog, CatalogRoutingOptions, RoutingCatalog,\n} from \"./catalog.js\";\nexport {\n getFallbackChain,\n getFallbackChainFiltered,\n filterByToolCalling,\n filterByVision,\n filterByExcludeList,\n filterCandidatesByCapacity,\n calculateModelCost,\n} from \"./selector.js\";\nexport { DEFAULT_ROUTING_CONFIG } from \"./config.js\";\nexport { DEFAULT_MODEL_CAPABILITIES } from \"./model-capabilities.js\";\nexport { LIVE_MODEL_PROFILES, HISTORICAL_MODEL_PROFILES } from \"./model-profiles.js\";\nexport type {\n RoutingDecision,\n Tier,\n TaskType,\n RoutingConfig,\n RouterOptions,\n RouterStrategy,\n} from \"./types.js\";\nexport type { ModelPricing } from \"./selector.js\";\nexport type { ModelCapabilities } from \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KAAK,KAAK;AAAA,EACnB;AACA,SAAO,SAAS;AAChB,SAAO,cAAc;AACrB,aAAW,QAAQ,YAAa,QAAO,IAAI,IAAI,OAAO,OAAO,WAAS,MAAM,MAAM,SAAS,IAAI,CAAC;AAChG,SAAO;AACT;AAuBO,SAAS,iBAAiB,SAAuB,UAAiC,CAAC,GAAmB;AAC3G,QAAM,WAAW,EAAE,GAAG,4BAA4B,GAAG,QAAQ,qBAAqB;AAClF,QAAM,eAAe,oBAAI,IAA0B;AACnD,QAAM,oBAAuD,CAAC;AAC9D,aAAW,SAAS,QAAQ,MAAM;AAChC,iBAAa,IAAI,MAAM,IAAI,EAAE,YAAY,MAAM,QAAQ,OAAQ,aAAa,MAAM,QAAQ,OAAQ,CAAC;AACnG,UAAM,WAAW,SAAS,MAAM,EAAE;AAClC,sBAAkB,MAAM,EAAE,IAAI;AAAA,MAC5B,eAAe,MAAM,iBAAiB,UAAU,iBAAiB;AAAA,MACjE,iBAAiB,MAAM,mBAAmB,UAAU,mBAAmB;AAAA,MACvE,eAAe,UAAU,kBAAkB;AAAA;AAAA;AAAA;AAAA,MAI3C,gBAAgB,UAAU,kBAAkB,MAAM,WAAW,SAAS,QAAQ;AAAA,IAChF;AAAA,EACF;AACA,SAAO,EAAE,cAAc,mBAAmB,mBAAmB,CAAC,GAAG,QAAQ,WAAW,EAAE;AACxF;;;AC9IA,iBAAiB,IAAI,kBAAkB,CAAC;AAMjC,SAAS,MACd,QACA,cACA,iBACA,SACiB;AACjB,QAAM,WAAW,YAAY,QAAQ,OAAO,YAAY,WAAW;AACnE,SAAO,SAAS,MAAM,QAAQ,cAAc,iBAAiB,OAAO;AACtE;","names":["confidence","decision","price","model"]} \ No newline at end of file +{"version":3,"sources":["../src/rules.ts","../src/selector.ts","../src/tokens.ts","../src/strategy.ts","../src/config.ts","../src/model-capabilities.ts","../src/model-profiles.generated.json","../src/model-profiles.ts","../src/tool-intent.ts","../src/portfolio.ts","../src/catalog.ts","../src/index.ts"],"sourcesContent":["/**\n * Rule-Based Classifier (v2 — Weighted Scoring)\n *\n * Scores a request across 15 weighted dimensions and maps the aggregate\n * score to a tier using configurable boundaries. Confidence is calibrated\n * via sigmoid — low confidence triggers the fallback classifier.\n *\n * Handles 70-80% of requests in < 1ms with zero cost.\n */\n\nimport type { Tier, ScoringResult, ScoringConfig } from \"./types.js\";\n\ntype DimensionScore = { name: string; score: number; signal: string | null };\n\n// ─── Keyword Matching ───\n//\n// A plain substring test counted `class` in \"classic\", `story` in \"history\",\n// `edit` in \"credit\" and `fix` in \"prefix\", so everyday prose picked up code,\n// creative and agentic signals it did not carry. Alphabetic keywords now have\n// to start at a word boundary. Short ASCII keywords additionally have to end\n// at one, after an optional inflection, graded by how much a stray suffix can\n// change the word: a three-letter keyword takes only the English endings that\n// cannot spell another word (fix → fixes, never pip → pipe or def → defer); a\n// four-to-six-letter keyword also takes the common German and Romance endings,\n// because the lists spell those languages in ASCII too (beweis → beweise,\n// klasse → klassen); anything longer stays trailing-open like the substring\n// test it replaces, since its false-positive surface is small and its\n// inflection surface is large. Non-ASCII alphabetic keywords keep a\n// trailing-open match because several are deliberate stems (`оптимизаци`,\n// `рассуждени`). CJK, Hangul and Arabic keywords keep the substring test:\n// those scripts have no word boundaries, or attach particles and articles\n// directly to the word.\n\nconst UNSEGMENTED_SCRIPT =\n /[؀-ۿ -ヿ㐀-䶿一-鿿가-힯豈-﫿＀-￯]/;\nconst WORD_CHAR = /[\\p{L}\\p{N}]/u;\nconst ASCII_PHRASE = /^[a-z0-9' -]+$/;\n// A word boundary is a transition out of the segmented scripts. A CJK\n// character next to a Latin keyword (\"请step by step证明\") is a boundary, not\n// part of the word: mixed-script prompts carry no spaces between scripts.\nconst SEGMENTED_WORD_CHAR = \"\\\\p{Script=Latin}\\\\p{Script=Cyrillic}\\\\p{Script=Greek}\\\\p{N}\";\nconst BOUNDARY_BEFORE = `(?();\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction keywordMatcher(keyword: string): KeywordMatcher {\n const cached = matcherCache.get(keyword);\n if (cached) return cached;\n\n const kw = keyword.toLowerCase();\n let matcher: KeywordMatcher;\n if (UNSEGMENTED_SCRIPT.test(kw) || kw.length === 0) {\n matcher = { needle: kw, pattern: null };\n } else {\n const lead = WORD_CHAR.test(kw[0]) ? BOUNDARY_BEFORE : \"\";\n const escaped = escapeRegExp(kw);\n let body = escaped;\n let trail = \"\";\n let needle = kw;\n const lastWord = kw.slice(kw.lastIndexOf(\" \") + 1);\n if (\n WORD_CHAR.test(kw[kw.length - 1]) &&\n ASCII_PHRASE.test(kw) &&\n lastWord.length <= BOUNDED_LAST_WORD_LENGTH\n ) {\n // ASCII phrases contain no regex metacharacters, so `escaped` slices\n // align with `kw` slices below.\n const forms: string[] = [];\n if (/\\d$/.test(kw)) {\n // \"step 1\" must not absorb \"step 10\".\n forms.push(escaped);\n } else if (lastWord.length <= 3) {\n forms.push(`${escaped}${SHORT_SUFFIXES}`);\n if (/(?:x|s|z|ch|sh)$/.test(kw)) forms.push(`${escaped}${SIBILANT_PLURAL}`);\n } else {\n forms.push(`${escaped}${MID_SUFFIXES}`);\n if (kw.endsWith(\"e\")) {\n forms.push(`${escaped.slice(0, -1)}${DROPPED_E_SUFFIXES}`);\n needle = kw.slice(0, -1);\n } else if (kw.endsWith(\"y\")) {\n forms.push(`${escaped.slice(0, -1)}(?:ies|ied)`);\n needle = kw.slice(0, -1);\n } else if (/[aeiou][bdgmnprt]$/.test(kw)) {\n // debug → debugging, plan → planned\n forms.push(`${escaped}${kw[kw.length - 1]}${DOUBLED_CONSONANT_SUFFIXES}`);\n }\n }\n body = `(?:${forms.join(\"|\")})`;\n trail = BOUNDARY_AFTER;\n }\n matcher = { needle, pattern: new RegExp(`${lead}${body}${trail}`, \"u\") };\n }\n matcherCache.set(keyword, matcher);\n return matcher;\n}\n\n/** Whether lower-cased `text` contains `keyword` as a word (or as a substring for CJK). */\nfunction matchesKeyword(text: string, keyword: string): boolean {\n const { needle, pattern } = keywordMatcher(keyword);\n if (!text.includes(needle)) return false;\n return pattern === null ? true : pattern.test(text);\n}\n\n// ─── Dimension Scorers ───\n// Each returns a score in [-1, 1] and an optional signal string.\n\nfunction scoreTokenCount(\n estimatedTokens: number,\n thresholds: { simple: number; complex: number },\n): DimensionScore {\n if (estimatedTokens < thresholds.simple) {\n return { name: \"tokenCount\", score: -1.0, signal: `short (${estimatedTokens} tokens)` };\n }\n if (estimatedTokens > thresholds.complex) {\n return { name: \"tokenCount\", score: 1.0, signal: `long (${estimatedTokens} tokens)` };\n }\n return { name: \"tokenCount\", score: 0, signal: null };\n}\n\nfunction scoreKeywordMatch(\n text: string,\n keywords: string[],\n name: string,\n signalLabel: string,\n thresholds: { low: number; high: number },\n scores: { none: number; low: number; high: number },\n): DimensionScore {\n const matches = keywords.filter((kw) => matchesKeyword(text, kw));\n if (matches.length >= thresholds.high) {\n return {\n name,\n score: scores.high,\n signal: `${signalLabel} (${matches.slice(0, 3).join(\", \")})`,\n };\n }\n if (matches.length >= thresholds.low) {\n return {\n name,\n score: scores.low,\n signal: `${signalLabel} (${matches.slice(0, 3).join(\", \")})`,\n };\n }\n return { name, score: scores.none, signal: null };\n}\n\nfunction scoreMultiStep(text: string): DimensionScore {\n // A numbered list item must start a line: a bare \"\\d\\.\\s\" also matched\n // every sentence that ends in a number (\"born in 1990. How old…\").\n const patterns = [/first.*then/i, /step \\d/i, /(?:^|\\n)\\s*\\d+[.)]\\s/];\n const hits = patterns.filter((p) => p.test(text));\n if (hits.length > 0) {\n return { name: \"multiStepPatterns\", score: 0.5, signal: \"multi-step\" };\n }\n return { name: \"multiStepPatterns\", score: 0, signal: null };\n}\n\nfunction scoreQuestionComplexity(prompt: string): DimensionScore {\n const count = (prompt.match(/[??]/g) || []).length;\n if (count > 3) {\n return { name: \"questionComplexity\", score: 0.5, signal: `${count} questions` };\n }\n return { name: \"questionComplexity\", score: 0, signal: null };\n}\n\n/**\n * Score agentic task indicators.\n * Returns agenticScore (0-1) based on keyword matches:\n * - 4+ matches = 1.0 (high agentic)\n * - 3 matches = 0.6 (moderate agentic, triggers auto-agentic mode)\n * - 1-2 matches = 0.2 (low agentic)\n *\n * Thresholds raised because common keywords were pruned from the list.\n */\nfunction scoreAgenticTask(\n text: string,\n keywords: string[],\n): { dimensionScore: DimensionScore; agenticScore: number } {\n let matchCount = 0;\n const signals: string[] = [];\n\n for (const keyword of keywords) {\n if (matchesKeyword(text, keyword)) {\n matchCount++;\n if (signals.length < 3) {\n signals.push(keyword);\n }\n }\n }\n\n // Threshold-based scoring (raised thresholds after keyword pruning)\n if (matchCount >= 4) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 1.0,\n signal: `agentic (${signals.join(\", \")})`,\n },\n agenticScore: 1.0,\n };\n } else if (matchCount >= 3) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 0.6,\n signal: `agentic (${signals.join(\", \")})`,\n },\n agenticScore: 0.6,\n };\n } else if (matchCount >= 1) {\n return {\n dimensionScore: {\n name: \"agenticTask\",\n score: 0.2,\n signal: `agentic-light (${signals.join(\", \")})`,\n },\n agenticScore: 0.2,\n };\n }\n\n return {\n dimensionScore: { name: \"agenticTask\", score: 0, signal: null },\n agenticScore: 0,\n };\n}\n\n// ─── Main Classifier ───\n\nexport function classifyByRules(\n prompt: string,\n systemPrompt: string | undefined,\n estimatedTokens: number,\n config: ScoringConfig,\n): ScoringResult {\n // Score against user prompt only — system prompts contain boilerplate keywords\n // (tool definitions, skill descriptions, behavioral rules) that dominate scoring\n // and make every request score identically. See GitHub issue #50.\n const userText = prompt.toLowerCase();\n\n const reasoningDimension = scoreKeywordMatch(\n userText,\n config.reasoningKeywords,\n \"reasoningMarkers\",\n \"reasoning\",\n { low: 1, high: 2 },\n { none: 0, low: 0.7, high: 1.0 },\n );\n\n // Score the base dimensions against user text only; the agentic dimension is\n // appended below, so the scored total is one more than this list.\n const dimensions: DimensionScore[] = [\n // Token count uses total estimated tokens (system + user) — context size matters for model selection\n scoreTokenCount(estimatedTokens, config.tokenCountThresholds),\n scoreKeywordMatch(\n userText,\n config.codeKeywords,\n \"codePresence\",\n \"code\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 1.0 },\n ),\n reasoningDimension,\n scoreKeywordMatch(\n userText,\n config.technicalKeywords,\n \"technicalTerms\",\n \"technical\",\n { low: 2, high: 4 },\n { none: 0, low: 0.5, high: 1.0 },\n ),\n scoreKeywordMatch(\n userText,\n config.creativeKeywords,\n \"creativeMarkers\",\n \"creative\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.simpleKeywords,\n \"simpleIndicators\",\n \"simple\",\n { low: 1, high: 2 },\n { none: 0, low: -1.0, high: -1.0 },\n ),\n scoreMultiStep(userText),\n scoreQuestionComplexity(prompt),\n\n // 6 new dimensions\n scoreKeywordMatch(\n userText,\n config.imperativeVerbs,\n \"imperativeVerbs\",\n \"imperative\",\n { low: 1, high: 2 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.constraintIndicators,\n \"constraintCount\",\n \"constraints\",\n { low: 1, high: 3 },\n { none: 0, low: 0.3, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.outputFormatKeywords,\n \"outputFormat\",\n \"format\",\n { low: 1, high: 2 },\n { none: 0, low: 0.4, high: 0.7 },\n ),\n scoreKeywordMatch(\n userText,\n config.referenceKeywords,\n \"referenceComplexity\",\n \"references\",\n { low: 1, high: 2 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.negationKeywords,\n \"negationComplexity\",\n \"negation\",\n { low: 2, high: 3 },\n { none: 0, low: 0.3, high: 0.5 },\n ),\n scoreKeywordMatch(\n userText,\n config.domainSpecificKeywords,\n \"domainSpecificity\",\n \"domain-specific\",\n { low: 1, high: 2 },\n { none: 0, low: 0.5, high: 0.8 },\n ),\n ];\n\n // Score agentic task indicators — user prompt only\n // System prompt describes assistant behavior, not user's intent.\n // e.g. a coding assistant system prompt with \"edit files\" / \"fix bugs\" should NOT\n // force every request into agentic mode.\n const agenticResult = scoreAgenticTask(userText, config.agenticTaskKeywords);\n dimensions.push(agenticResult.dimensionScore);\n const agenticScore = agenticResult.agenticScore;\n\n // Collect signals\n const signals = dimensions.filter((d) => d.signal !== null).map((d) => d.signal!);\n\n // Compute weighted score\n const weights = config.dimensionWeights;\n let weightedScore = 0;\n for (const d of dimensions) {\n const w = weights[d.name] ?? 0;\n weightedScore += d.score * w;\n }\n\n // Direct reasoning override: 2+ reasoning markers in the USER prompt = high\n // confidence REASONING. The system prompt is never read here, so a host\n // instruction like \"think step by step\" cannot lift every query to REASONING.\n // The reasoning dimension already counted those matches; its score is 1.0\n // exactly when two or more matched.\n if (reasoningDimension.score === 1.0) {\n const confidence = calibrateConfidence(\n Math.max(weightedScore, 0.3), // ensure positive for confidence calc\n config.confidenceSteepness,\n );\n return {\n score: weightedScore,\n tier: \"REASONING\",\n confidence: Math.max(confidence, 0.85),\n signals,\n agenticScore,\n dimensions,\n };\n }\n\n // Map weighted score to tier using boundaries\n const { simpleMedium, mediumComplex, complexReasoning } = config.tierBoundaries;\n let tier: Tier;\n let distanceFromBoundary: number;\n\n if (weightedScore < simpleMedium) {\n tier = \"SIMPLE\";\n distanceFromBoundary = simpleMedium - weightedScore;\n } else if (weightedScore < mediumComplex) {\n tier = \"MEDIUM\";\n distanceFromBoundary = Math.min(weightedScore - simpleMedium, mediumComplex - weightedScore);\n } else if (weightedScore < complexReasoning) {\n tier = \"COMPLEX\";\n distanceFromBoundary = Math.min(\n weightedScore - mediumComplex,\n complexReasoning - weightedScore,\n );\n } else {\n tier = \"REASONING\";\n distanceFromBoundary = weightedScore - complexReasoning;\n }\n\n // Calibrate confidence via sigmoid of distance from nearest boundary\n const confidence = calibrateConfidence(distanceFromBoundary, config.confidenceSteepness);\n\n // If confidence is below threshold → ambiguous\n if (confidence < config.confidenceThreshold) {\n return { score: weightedScore, tier: null, confidence, signals, agenticScore, dimensions };\n }\n\n return { score: weightedScore, tier, confidence, signals, agenticScore, dimensions };\n}\n\n/**\n * Sigmoid confidence calibration.\n * Maps distance from tier boundary to [0.5, 1.0] confidence range.\n */\nfunction calibrateConfidence(distance: number, steepness: number): number {\n return 1 / (1 + Math.exp(-steepness * distance));\n}\n","/**\n * Tier → Model Selection\n *\n * Maps a classification tier to the cheapest capable model.\n * Builds RoutingDecision metadata with cost estimates and savings.\n */\n\nimport type { Tier, TierConfig, RoutingDecision } from \"./types.js\";\n\nexport type ModelPricing = {\n inputPrice: number; // per 1M tokens\n outputPrice: number; // per 1M tokens\n /** Active promo flat price per request (overrides token-based pricing when set) */\n flatPrice?: number;\n};\n\n// The savings baseline is a price anchor, not \"the current flagship\" — it is\n// deliberately NOT bumped every time a new Opus ships. Opus 4.7, 4.8 and 5 all\n// bill $5/$25, so moving it would change no reported number while breaking\n// comparability with historical journal entries. Only move it if the Opus tier\n// itself is repriced.\nconst BASELINE_MODEL_ID = \"anthropic/claude-opus-4.7\";\n\n// Hardcoded fallback: Claude Opus 4.7 pricing (per 1M tokens)\n// Used when baseline model not found in dynamic pricing map\nconst BASELINE_INPUT_PRICE = 5.0;\nconst BASELINE_OUTPUT_PRICE = 25.0;\n\n/**\n * The pricing entry, or undefined when any field it carries is not a finite,\n * non-negative number. A hand-built price map with a NaN would otherwise put\n * NaN into costEstimate and savings; a malformed price is an unknown price.\n */\nexport function usablePricing(pricing: ModelPricing | undefined): ModelPricing | undefined {\n if (!pricing) return undefined;\n const ok = (value: number | undefined) =>\n value === undefined || (Number.isFinite(value) && value >= 0);\n if (pricing.flatPrice !== undefined) return ok(pricing.flatPrice) ? pricing : undefined;\n return ok(pricing.inputPrice) && ok(pricing.outputPrice) ? pricing : undefined;\n}\n\n/** Raw token cost (no margin, no floor), or the flat promo price when one is set. */\nfunction rawCost(\n pricing: ModelPricing | undefined,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n): number {\n if (pricing?.flatPrice !== undefined) return pricing.flatPrice;\n const inputPrice = pricing?.inputPrice ?? 0;\n const outputPrice = pricing?.outputPrice ?? 0;\n return (estimatedInputTokens / 1_000_000) * inputPrice + (maxOutputTokens / 1_000_000) * outputPrice;\n}\n\n/** What the anchor Opus tier would cost for the same request (see BASELINE_MODEL_ID). */\nfunction baselineCostFor(\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n): number {\n const opusPricing = usablePricing(modelPricing.get(BASELINE_MODEL_ID));\n const inputPrice = opusPricing?.inputPrice ?? BASELINE_INPUT_PRICE;\n const outputPrice = opusPricing?.outputPrice ?? BASELINE_OUTPUT_PRICE;\n return (estimatedInputTokens / 1_000_000) * inputPrice + (maxOutputTokens / 1_000_000) * outputPrice;\n}\n\n/**\n * Fractional savings against the baseline. Premium reports none (it is about\n * quality, not cost), and a model the host has no price for costs an unknown\n * amount, not nothing: reporting its savings as 100% would be a fabricated\n * figure.\n */\nfunction savingsFor(\n costEstimate: number,\n baselineCost: number,\n pricing: ModelPricing | undefined,\n routingProfile: string | undefined,\n): number {\n if (routingProfile === \"premium\" || pricing === undefined || !(baselineCost > 0)) return 0;\n return Math.max(0, (baselineCost - costEstimate) / baselineCost);\n}\n\n/**\n * Select the primary model for a tier and build the RoutingDecision.\n *\n * Cost contract: the estimates here are raw token economics — no server\n * margin, no minimum-payment floor. `calculateModelCost` below applies both\n * to match the actual x402 charge, and hosts that display money (ClawRouter's\n * proxy does) recompute through it rather than reading these fields. Folding\n * the margin in here would double-apply it in every such host.\n */\nexport function selectModel(\n tier: Tier,\n confidence: number,\n method: \"rules\" | \"llm\" | \"portfolio\",\n reasoning: string,\n tierConfigs: Record,\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n routingProfile?: \"free\" | \"eco\" | \"auto\" | \"premium\",\n agenticScore?: number,\n): RoutingDecision {\n const tierConfig = tierConfigs[tier];\n const model = tierConfig.primary;\n const pricing = usablePricing(modelPricing.get(model));\n\n const costEstimate = rawCost(pricing, estimatedInputTokens, maxOutputTokens);\n const baselineCost = baselineCostFor(modelPricing, estimatedInputTokens, maxOutputTokens);\n const savings = savingsFor(costEstimate, baselineCost, pricing, routingProfile);\n\n return {\n model,\n tier,\n confidence,\n method,\n reasoning,\n costEstimate,\n baselineCost,\n savings,\n ...(agenticScore !== undefined && { agenticScore }),\n };\n}\n\n/**\n * Get the ordered fallback chain for a tier: [primary, ...fallbacks].\n */\nexport function getFallbackChain(tier: Tier, tierConfigs: Record): string[] {\n const config = tierConfigs[tier];\n return [config.primary, ...config.fallback];\n}\n\n// Server-side margin applied to all x402 payments (must match blockrun server's MARGIN_PERCENT)\nconst SERVER_MARGIN_PERCENT = 5;\n// Minimum payment enforced by CDP Facilitator (must match blockrun server's MIN_PAYMENT_USD)\nconst MIN_PAYMENT_USD = 0.001;\n\n/**\n * Calculate charge-accurate cost fields for a specific model (server margin\n * and minimum-payment floor included — see the cost contract on selectModel).\n * Hosts call this to display money and to recost a decision after a fallback.\n */\nexport function calculateModelCost(\n model: string,\n modelPricing: Map,\n estimatedInputTokens: number,\n maxOutputTokens: number,\n routingProfile?: \"free\" | \"eco\" | \"auto\" | \"premium\",\n): { costEstimate: number; baselineCost: number; savings: number } {\n const pricing = usablePricing(modelPricing.get(model));\n\n // Server margin + minimum payment, to match the actual x402 charge.\n const costEstimate = Math.max(\n rawCost(pricing, estimatedInputTokens, maxOutputTokens) * (1 + SERVER_MARGIN_PERCENT / 100),\n MIN_PAYMENT_USD,\n );\n const baselineCost = baselineCostFor(modelPricing, estimatedInputTokens, maxOutputTokens);\n const savings = savingsFor(costEstimate, baselineCost, pricing, routingProfile);\n\n return { costEstimate, baselineCost, savings };\n}\n\n/** The models satisfying `keep`, or every model when none does. */\nfunction keepOrFailOpen(models: string[], keep: (modelId: string) => boolean): string[] {\n const filtered = models.filter(keep);\n return filtered.length > 0 ? filtered : models;\n}\n\n/**\n * Filter a model list to only those that support tool calling.\n * When hasTools is false, returns the list unchanged.\n * When all models lack tool calling support, returns the full list as a fallback\n * (better to let the API error than produce an empty chain).\n */\nexport function filterByToolCalling(\n models: string[],\n hasTools: boolean,\n supportsToolCalling: (modelId: string) => boolean,\n): string[] {\n return hasTools ? keepOrFailOpen(models, supportsToolCalling) : models;\n}\n\n/**\n * Filter a model list to only those that support vision (image inputs).\n * When hasVision is false, returns the list unchanged.\n * When all models lack vision support, returns the full list as a fallback\n * (better to let the API error than produce an empty chain).\n */\nexport function filterByVision(\n models: string[],\n hasVision: boolean,\n supportsVision: (modelId: string) => boolean,\n): string[] {\n return hasVision ? keepOrFailOpen(models, supportsVision) : models;\n}\n\n/**\n * Filter a model list to remove user-excluded models.\n * When all models are excluded, returns the full list as a fallback\n * (same safety pattern as filterByToolCalling/filterByVision).\n */\nexport function filterByExcludeList(models: string[], excludeList: Set): string[] {\n if (excludeList.size === 0) return models;\n return keepOrFailOpen(models, (m) => !excludeList.has(m));\n}\n\n/**\n * Get the fallback chain filtered by context length.\n * Only returns models that can handle the estimated total context.\n *\n * @param tier - The tier to get fallback chain for\n * @param tierConfigs - Tier configurations\n * @param estimatedTotalTokens - Estimated total context (input + output)\n * @param getContextWindow - Function to get context window for a model ID\n * @returns Filtered list of models that can handle the context\n */\nexport function getFallbackChainFiltered(\n tier: Tier,\n tierConfigs: Record,\n estimatedTotalTokens: number,\n getContextWindow: (modelId: string) => number | undefined,\n): string[] {\n const fullChain = getFallbackChain(tier, tierConfigs);\n\n // Filter to models that can handle the context\n const filtered = fullChain.filter((modelId) => {\n const contextWindow = getContextWindow(modelId);\n if (contextWindow === undefined) {\n // Unknown model - include it (let API reject if needed)\n return true;\n }\n // Add 10% buffer for safety\n return contextWindow >= estimatedTotalTokens * 1.1;\n });\n\n // If all models filtered out, return the original chain\n // (let the API error out - better than no options)\n if (filtered.length === 0) {\n return fullChain;\n }\n\n return filtered;\n}\n\n/**\n * Filter an already-ranked candidate list by total context and requested output.\n * Unlike the legacy tier helper, this supports the V3 portfolio order.\n */\nexport function filterCandidatesByCapacity(\n models: string[],\n estimatedInputTokens: number,\n requestedOutputTokens: number,\n getCapabilities: (modelId: string) => { contextWindow: number; maxOutput: number } | undefined,\n): string[] {\n const filtered = models.filter((modelId) => {\n const capabilities = getCapabilities(modelId);\n if (!capabilities) return true;\n return (\n capabilities.contextWindow >= (estimatedInputTokens + requestedOutputTokens) * 1.1 &&\n capabilities.maxOutput >= requestedOutputTokens\n );\n });\n return filtered;\n}\n","/**\n * Request-size helpers shared by the rules and portfolio strategies.\n *\n * The router never tokenizes — it is on the hot path and model-agnostic — so\n * sizes are estimates. The estimate only has to be honest enough for the\n * decisions that consume it: the long-context task type, the COMPLEX\n * override and the per-model capacity filter.\n */\n\n// Han, kana, Hangul, CJK punctuation and fullwidth forms. Every production\n// tokenizer spends roughly one token per character here, so the Latin\n// four-characters-per-token rule under-counts these scripts about fourfold:\n// a 200k-character Chinese contract would read as 50k tokens, slip under the\n// 80k long-context boundary and pass the capacity filter for models that\n// cannot hold it.\nconst CJK_CHARS = /[ -ヿ㐀-䶿一-鿿가-힯豈-﫿＀-￯]/g;\n\n/** Approximate token count: one per CJK character, one per four of anything else. */\nexport function estimateTokens(text: string): number {\n if (text.length === 0) return 0;\n const cjk = text.match(CJK_CHARS)?.length ?? 0;\n return cjk + Math.ceil((text.length - cjk) / 4);\n}\n\nconst MAX_SCAN_CHARS = 8_000;\n\n/** The scan window the feature regexes read, bounded so a pasted document cannot stall routing. */\nexport function scanLimit(promptTruncationChars: number): number {\n if (!Number.isFinite(promptTruncationChars)) return MAX_SCAN_CHARS;\n return Math.max(1, Math.min(MAX_SCAN_CHARS, Math.floor(promptTruncationChars)));\n}\n\n\n/**\n * Feature regexes need request shape and intent, not the entire document.\n * Sample both ends so a long pasted artifact keeps the task instruction at\n * either boundary, while the full length still drives capacity decisions.\n */\nexport function sampleForScan(value: string, limit: number): string {\n if (value.length <= limit) return value;\n const prefixLength = Math.ceil(limit / 2);\n const suffixLength = limit - prefixLength;\n // slice(-0) is the whole string, so a one-character limit needs its own case.\n if (suffixLength <= 0) return value.slice(0, prefixLength);\n return `${value.slice(0, prefixLength)}\\n${value.slice(-suffixLength)}`;\n}\n","/**\n * Router Strategy Registry\n *\n * Pluggable strategy system for request routing.\n * Default: RulesStrategy — identical to the original inline route() logic, <1ms.\n */\n\nimport type {\n Tier,\n TierConfig,\n Promotion,\n RoutingDecision,\n RouterStrategy,\n RouterOptions,\n} from \"./types.js\";\nimport { classifyByRules } from \"./rules.js\";\nimport { selectModel } from \"./selector.js\";\nimport { estimateTokens, sampleForScan, scanLimit } from \"./tokens.js\";\n\n/**\n * Apply active time-windowed promotions to tier configs.\n * Returns a new tierConfigs object with promotion overrides merged in.\n * Expired or not-yet-active promotions are ignored.\n */\nfunction applyPromotions(\n tierConfigs: Record,\n promotions: Promotion[] | undefined,\n profile: \"auto\" | \"eco\" | \"premium\" | \"agentic\",\n now: Date = new Date(),\n): Record {\n if (!promotions || promotions.length === 0) return tierConfigs;\n\n let result = tierConfigs;\n for (const promo of promotions) {\n // Check time window\n // An unparseable date compares false both ways, which used to make the\n // promotion active forever. A window that cannot be read is not a window.\n const start = Date.parse(promo.startDate);\n const end = Date.parse(promo.endDate);\n if (!Number.isFinite(start) || !Number.isFinite(end)) continue;\n if (now.getTime() < start || now.getTime() >= end) continue;\n\n // Check profile filter\n if (promo.profiles && !promo.profiles.includes(profile)) continue;\n\n // Shallow-clone on first mutation\n if (result === tierConfigs) {\n result = { ...tierConfigs };\n for (const t of Object.keys(result) as Tier[]) {\n result[t] = { ...result[t] };\n }\n }\n\n // Merge overrides\n for (const [tier, override] of Object.entries(promo.tierOverrides) as [\n Tier,\n Partial,\n ][]) {\n if (!result[tier]) continue;\n if (override.primary) result[tier].primary = override.primary;\n if (override.fallback) result[tier].fallback = override.fallback;\n }\n }\n\n return result;\n}\n\n/**\n * Remove host-declared-dead models from every tier chain, promoting the first\n * surviving rung to primary. A tier whose chain is entirely dead keeps its\n * original config — the router has nothing live to offer there, and inventing\n * a model would hide the outage from the host that reported it.\n */\nexport function applyUnavailableModels(\n tierConfigs: Record,\n unavailableModels: readonly string[] | undefined,\n): Record {\n if (!unavailableModels || unavailableModels.length === 0) return tierConfigs;\n const dead = new Set(unavailableModels);\n let result = tierConfigs;\n for (const tier of Object.keys(tierConfigs) as Tier[]) {\n const config = tierConfigs[tier];\n const alive = [config.primary, ...config.fallback].filter((model) => !dead.has(model));\n if (alive.length === 0 || (alive[0] === config.primary && alive.length === config.fallback.length + 1)) {\n continue;\n }\n if (result === tierConfigs) result = { ...tierConfigs };\n result[tier] = { primary: alive[0], fallback: alive.slice(1) };\n }\n return result;\n}\n\n/**\n * Rules-based routing strategy.\n * Extracted from the original route() in index.ts — logic is identical.\n * Attaches tierConfigs and profile to the decision for downstream use.\n */\nexport class RulesStrategy implements RouterStrategy {\n readonly name = \"rules\";\n\n route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n ): RoutingDecision {\n const { config, modelPricing } = options;\n\n const fullText = `${systemPrompt ?? \"\"} ${prompt}`;\n const estimatedTokens = estimateTokens(fullText);\n const limit = scanLimit(config.classifier.promptTruncationChars);\n const scannedPrompt = sampleForScan(prompt, limit);\n const scannedSystemPrompt = systemPrompt ? sampleForScan(systemPrompt, limit) : undefined;\n\n // --- Rule-based classification (runs first to get agenticScore) ---\n const ruleResult = classifyByRules(\n scannedPrompt,\n scannedSystemPrompt,\n estimatedTokens,\n config.scoring,\n );\n\n // --- Select tier configs based on routing profile ---\n const { routingProfile } = options;\n let tierConfigs: Record;\n let profileSuffix: string;\n let profile: NonNullable;\n\n if (routingProfile === \"eco\") {\n // `ecoTiers: null` explicitly disables the special eco tier set while\n // keeping eco routing semantics. Fall back to regular tiers instead of\n // dropping into auto routing (which could select agentic tiers).\n tierConfigs = config.ecoTiers ?? config.tiers;\n profileSuffix = config.ecoTiers ? \" | eco\" : \" | eco (default tiers)\";\n profile = \"eco\";\n } else if (routingProfile === \"premium\") {\n // `premiumTiers: null` disables the premium-specific tier set but the\n // request is still a premium-profile request, so use regular tiers while\n // preserving premium metadata/cost semantics.\n tierConfigs = config.premiumTiers ?? config.tiers;\n profileSuffix = config.premiumTiers ? \" | premium\" : \" | premium (default tiers)\";\n profile = \"premium\";\n } else {\n // Auto profile (or undefined): intelligent routing with agentic detection.\n //\n // `agenticMode` semantics:\n // - `true` → force agentic tiers (ignore heuristics)\n // - `false` → disable agentic tiers entirely (even if tools are present)\n // - `undefined` → auto-detect via heuristics (tools present OR high agenticScore)\n const agenticScore = ruleResult.agenticScore ?? 0;\n const isAutoAgentic = agenticScore >= 0.5;\n const agenticModeSetting = config.overrides.agenticMode;\n const hasToolsInRequest = options.requiresTools ?? options.hasTools ?? false;\n let useAgenticTiers: boolean;\n if (agenticModeSetting === false) {\n // Explicitly disabled — never use agentic tiers\n useAgenticTiers = false;\n } else if (agenticModeSetting === true) {\n // Explicitly enabled — use agentic tiers if available\n useAgenticTiers = config.agenticTiers != null;\n } else {\n // Auto-detect\n useAgenticTiers = (hasToolsInRequest || isAutoAgentic) && config.agenticTiers != null;\n }\n tierConfigs = useAgenticTiers ? config.agenticTiers! : config.tiers;\n profileSuffix = useAgenticTiers ? ` | agentic${hasToolsInRequest ? \" (tools)\" : \"\"}` : \"\";\n profile = useAgenticTiers ? \"agentic\" : \"auto\";\n }\n\n // Apply time-windowed promotions\n tierConfigs = applyPromotions(tierConfigs, config.promotions, profile, options.now);\n\n // Hard-remove models the host has observed dead at the gateway. After\n // promotions, so a promo cannot resurrect a rung the host just killed.\n tierConfigs = applyUnavailableModels(tierConfigs, options.unavailableModels);\n\n const agenticScoreValue = ruleResult.agenticScore;\n\n // --- Override: large context → force COMPLEX ---\n if (estimatedTokens > config.overrides.maxTokensForceComplex) {\n const decision = selectModel(\n \"COMPLEX\",\n 0.95,\n \"rules\",\n `Input exceeds ${config.overrides.maxTokensForceComplex} tokens${profileSuffix}`,\n tierConfigs,\n modelPricing,\n estimatedTokens,\n maxOutputTokens,\n routingProfile,\n agenticScoreValue,\n );\n return { ...decision, tierConfigs, profile };\n }\n\n // Structured output is a protocol fact the host states (`response_format`\n // → requiresStructuredOutput). It used to be inferred from the system\n // prompt as well, but agent hosts describe their tool schemas there on\n // every turn, which upgraded every one of their requests off SIMPLE.\n const hasStructuredOutput = options.requiresStructuredOutput === true;\n\n let tier: Tier;\n let confidence: number;\n const method: \"rules\" | \"llm\" = \"rules\";\n let reasoning = `score=${ruleResult.score.toFixed(2)} | ${ruleResult.signals.join(\", \")}`;\n\n if (ruleResult.tier !== null) {\n tier = ruleResult.tier;\n confidence = ruleResult.confidence;\n } else {\n // Ambiguous — default to configurable tier (no external API call)\n tier = config.overrides.ambiguousDefaultTier;\n confidence = 0.5;\n reasoning += ` | ambiguous -> default: ${tier}`;\n }\n\n // Apply structured output minimum tier\n if (hasStructuredOutput) {\n const tierRank: Record = { SIMPLE: 0, MEDIUM: 1, COMPLEX: 2, REASONING: 3 };\n const minTier = config.overrides.structuredOutputMinTier;\n if (tierRank[tier] < tierRank[minTier]) {\n reasoning += ` | upgraded to ${minTier} (structured output)`;\n tier = minTier;\n }\n }\n\n // Add routing profile suffix to reasoning\n reasoning += profileSuffix;\n\n const decision = selectModel(\n tier,\n confidence,\n method,\n reasoning,\n tierConfigs,\n modelPricing,\n estimatedTokens,\n maxOutputTokens,\n routingProfile,\n agenticScoreValue,\n );\n return { ...decision, tierConfigs, profile };\n }\n}\n\n// --- Strategy Registry ---\n\nconst registry = new Map();\nregistry.set(\"rules\", new RulesStrategy());\n\nexport function getStrategy(name: string): RouterStrategy {\n const strategy = registry.get(name);\n if (!strategy) {\n throw new Error(`Unknown routing strategy: ${name}`);\n }\n return strategy;\n}\n\nexport function registerStrategy(strategy: RouterStrategy): void {\n registry.set(strategy.name, strategy);\n}\n","/**\n * Default Routing Config\n *\n * All routing parameters as a TypeScript constant.\n * Operators override via openclaw.yaml plugin config.\n *\n * Scoring uses 15 weighted dimensions with sigmoid confidence calibration.\n */\n\nimport type { RoutingConfig } from \"./types.js\";\n\nexport const DEFAULT_ROUTING_CONFIG: RoutingConfig = {\n version: \"3.5\",\n strategy: \"portfolio\",\n portfolio: {\n auto: {\n quality: 0.47,\n capability: 0.2,\n cost: 0.18,\n speed: 0.07,\n reliability: 0.03,\n legacy: 0.05,\n },\n eco: {\n quality: 0.36,\n capability: 0.2,\n cost: 0.28,\n speed: 0.1,\n reliability: 0.04,\n legacy: 0.02,\n },\n premium: {\n quality: 0.58,\n capability: 0.2,\n cost: 0.08,\n speed: 0.06,\n reliability: 0.06,\n legacy: 0.02,\n },\n highStakesBoost: { quality: 0.08, reliability: 0.05 },\n latencySensitiveSpeedBoost: 0.08,\n affinityFloorGap: { auto: 0.1, eco: 0.22, premium: 0.05 },\n },\n\n classifier: {\n // gemini-2.5-flash until Google retired it on 2026-12-01 (the gateways\n // redirect it to 3.5 Flash-Lite). Nothing in this package or ClawRouter\n // reads llmModel today. Before wiring it, note that 3.5 Flash-Lite always\n // thinks (it rejects a thinking budget of 0), so llmMaxTokens 10 may be\n // spent on reasoning before any label is emitted.\n llmModel: \"google/gemini-3.5-flash-lite\",\n llmMaxTokens: 10,\n llmTemperature: 0,\n promptTruncationChars: 500,\n cacheTtlMs: 3_600_000, // 1 hour\n },\n\n scoring: {\n tokenCountThresholds: { simple: 50, complex: 500 },\n\n // Multilingual keywords: EN + ZH + JA + RU + DE + ES + PT + KO + AR\n codeKeywords: [\n // English\n \"function\",\n \"class\",\n \"import\",\n \"def\",\n \"SELECT\",\n \"async\",\n \"await\",\n \"const\",\n \"let\",\n \"var\",\n \"return\",\n \"```\",\n // Chinese\n \"函数\",\n \"类\",\n \"导入\",\n \"定义\",\n \"查询\",\n \"异步\",\n \"等待\",\n \"常量\",\n \"变量\",\n \"返回\",\n // Japanese\n \"関数\",\n \"クラス\",\n \"インポート\",\n \"非同期\",\n \"定数\",\n \"変数\",\n // Russian\n \"функция\",\n \"класс\",\n \"импорт\",\n \"определ\",\n \"запрос\",\n \"асинхронный\",\n \"ожидать\",\n \"константа\",\n \"переменная\",\n \"вернуть\",\n // German\n \"funktion\",\n \"klasse\",\n \"importieren\",\n \"definieren\",\n \"abfrage\",\n \"asynchron\",\n \"erwarten\",\n \"konstante\",\n \"variable\",\n \"zurückgeben\",\n // Spanish\n \"función\",\n \"clase\",\n \"importar\",\n \"definir\",\n \"consulta\",\n \"asíncrono\",\n \"esperar\",\n \"constante\",\n \"variable\",\n \"retornar\",\n // Portuguese\n \"função\",\n \"classe\",\n \"importar\",\n \"definir\",\n \"consulta\",\n \"assíncrono\",\n \"aguardar\",\n \"constante\",\n \"variável\",\n \"retornar\",\n // Korean\n \"함수\",\n \"클래스\",\n \"가져오기\",\n \"정의\",\n \"쿼리\",\n \"비동기\",\n \"대기\",\n \"상수\",\n \"변수\",\n \"반환\",\n // Arabic\n \"دالة\",\n \"فئة\",\n \"استيراد\",\n \"تعريف\",\n \"استعلام\",\n \"غير متزامن\",\n \"انتظار\",\n \"ثابت\",\n \"متغير\",\n \"إرجاع\",\n ],\n reasoningKeywords: [\n // English\n \"prove\",\n \"theorem\",\n \"derive\",\n \"step by step\",\n \"chain of thought\",\n \"formally\",\n \"mathematical\",\n \"proof\",\n \"logically\",\n // Chinese\n \"证明\",\n \"定理\",\n \"推导\",\n \"逐步\",\n \"思维链\",\n \"形式化\",\n \"数学\",\n \"逻辑\",\n // Japanese\n \"証明\",\n \"定理\",\n \"導出\",\n \"ステップバイステップ\",\n \"論理的\",\n // Russian\n \"доказать\",\n \"докажи\",\n \"доказательств\",\n \"теорема\",\n \"вывести\",\n \"шаг за шагом\",\n \"пошагово\",\n \"поэтапно\",\n \"цепочка рассуждений\",\n \"рассуждени\",\n \"формально\",\n \"математически\",\n \"логически\",\n // German\n \"beweisen\",\n \"beweis\",\n \"theorem\",\n \"ableiten\",\n \"schritt für schritt\",\n \"gedankenkette\",\n \"formal\",\n \"mathematisch\",\n \"logisch\",\n // Spanish\n \"demostrar\",\n \"teorema\",\n \"derivar\",\n \"paso a paso\",\n \"cadena de pensamiento\",\n \"formalmente\",\n \"matemático\",\n \"prueba\",\n \"lógicamente\",\n // Portuguese\n \"provar\",\n \"teorema\",\n \"derivar\",\n \"passo a passo\",\n \"cadeia de pensamento\",\n \"formalmente\",\n \"matemático\",\n \"prova\",\n \"logicamente\",\n // Korean\n \"증명\",\n \"정리\",\n \"도출\",\n \"단계별\",\n \"사고의 연쇄\",\n \"형식적\",\n \"수학적\",\n \"논리적\",\n // Arabic\n \"إثبات\",\n \"نظرية\",\n \"اشتقاق\",\n \"خطوة بخطوة\",\n \"سلسلة التفكير\",\n \"رسمياً\",\n \"رياضي\",\n \"برهان\",\n \"منطقياً\",\n ],\n simpleKeywords: [\n // English\n \"what is\",\n \"define\",\n \"translate\",\n \"hello\",\n \"yes or no\",\n \"capital of\",\n \"how old\",\n \"who is\",\n \"when was\",\n // Chinese\n \"什么是\",\n \"定义\",\n \"翻译\",\n \"你好\",\n \"是否\",\n \"首都\",\n \"多大\",\n \"谁是\",\n \"何时\",\n // Japanese\n \"とは\",\n \"定義\",\n \"翻訳\",\n \"こんにちは\",\n \"はいかいいえ\",\n \"首都\",\n \"誰\",\n // Russian\n \"что такое\",\n \"определение\",\n \"перевести\",\n \"переведи\",\n \"привет\",\n \"да или нет\",\n \"столица\",\n \"сколько лет\",\n \"кто такой\",\n \"когда\",\n \"объясни\",\n // German\n \"was ist\",\n \"definiere\",\n \"übersetze\",\n \"hallo\",\n \"ja oder nein\",\n \"hauptstadt\",\n \"wie alt\",\n \"wer ist\",\n \"wann\",\n \"erkläre\",\n // Spanish\n \"qué es\",\n \"definir\",\n \"traducir\",\n \"hola\",\n \"sí o no\",\n \"capital de\",\n \"cuántos años\",\n \"quién es\",\n \"cuándo\",\n // Portuguese\n \"o que é\",\n \"definir\",\n \"traduzir\",\n \"olá\",\n \"sim ou não\",\n \"capital de\",\n \"quantos anos\",\n \"quem é\",\n \"quando\",\n // Korean\n \"무엇\",\n \"정의\",\n \"번역\",\n \"안녕하세요\",\n \"예 또는 아니오\",\n \"수도\",\n \"누구\",\n \"언제\",\n // Arabic\n \"ما هو\",\n \"تعريف\",\n \"ترجم\",\n \"مرحبا\",\n \"نعم أو لا\",\n \"عاصمة\",\n \"من هو\",\n \"متى\",\n ],\n technicalKeywords: [\n // English\n \"algorithm\",\n \"optimize\",\n \"architecture\",\n \"distributed\",\n \"kubernetes\",\n \"microservice\",\n \"database\",\n \"infrastructure\",\n // Chinese\n \"算法\",\n \"优化\",\n \"架构\",\n \"分布式\",\n \"微服务\",\n \"数据库\",\n \"基础设施\",\n // Japanese\n \"アルゴリズム\",\n \"最適化\",\n \"アーキテクチャ\",\n \"分散\",\n \"マイクロサービス\",\n \"データベース\",\n // Russian\n \"алгоритм\",\n \"оптимизировать\",\n \"оптимизаци\",\n \"оптимизируй\",\n \"архитектура\",\n \"распределённый\",\n \"микросервис\",\n \"база данных\",\n \"инфраструктура\",\n // German\n \"algorithmus\",\n \"optimieren\",\n \"architektur\",\n \"verteilt\",\n \"kubernetes\",\n \"mikroservice\",\n \"datenbank\",\n \"infrastruktur\",\n // Spanish\n \"algoritmo\",\n \"optimizar\",\n \"arquitectura\",\n \"distribuido\",\n \"microservicio\",\n \"base de datos\",\n \"infraestructura\",\n // Portuguese\n \"algoritmo\",\n \"otimizar\",\n \"arquitetura\",\n \"distribuído\",\n \"microsserviço\",\n \"banco de dados\",\n \"infraestrutura\",\n // Korean\n \"알고리즘\",\n \"최적화\",\n \"아키텍처\",\n \"분산\",\n \"마이크로서비스\",\n \"데이터베이스\",\n \"인프라\",\n // Arabic\n \"خوارزمية\",\n \"تحسين\",\n \"بنية\",\n \"موزع\",\n \"خدمة مصغرة\",\n \"قاعدة بيانات\",\n \"بنية تحتية\",\n ],\n creativeKeywords: [\n // English\n \"story\",\n \"poem\",\n \"compose\",\n \"brainstorm\",\n \"creative\",\n \"imagine\",\n \"write a\",\n // Chinese\n \"故事\",\n \"诗\",\n \"创作\",\n \"头脑风暴\",\n \"创意\",\n \"想象\",\n \"写一个\",\n // Japanese\n \"物語\",\n \"詩\",\n \"作曲\",\n \"ブレインストーム\",\n \"創造的\",\n \"想像\",\n // Russian\n \"история\",\n \"рассказ\",\n \"стихотворение\",\n \"сочинить\",\n \"сочини\",\n \"мозговой штурм\",\n \"творческий\",\n \"представить\",\n \"придумай\",\n \"напиши\",\n // German\n \"geschichte\",\n \"gedicht\",\n \"komponieren\",\n \"brainstorming\",\n \"kreativ\",\n \"vorstellen\",\n \"schreibe\",\n \"erzählung\",\n // Spanish\n \"historia\",\n \"poema\",\n \"componer\",\n \"lluvia de ideas\",\n \"creativo\",\n \"imaginar\",\n \"escribe\",\n // Portuguese\n \"história\",\n \"poema\",\n \"compor\",\n \"criativo\",\n \"imaginar\",\n \"escreva\",\n // Korean\n \"이야기\",\n \"시\",\n \"작곡\",\n \"브레인스토밍\",\n \"창의적\",\n \"상상\",\n \"작성\",\n // Arabic\n \"قصة\",\n \"قصيدة\",\n \"تأليف\",\n \"عصف ذهني\",\n \"إبداعي\",\n \"تخيل\",\n \"اكتب\",\n ],\n\n // New dimension keyword lists (multilingual)\n imperativeVerbs: [\n // English\n \"build\",\n \"create\",\n \"implement\",\n \"design\",\n \"develop\",\n \"construct\",\n \"generate\",\n \"deploy\",\n \"configure\",\n \"set up\",\n // Chinese\n \"构建\",\n \"创建\",\n \"实现\",\n \"设计\",\n \"开发\",\n \"生成\",\n \"部署\",\n \"配置\",\n \"设置\",\n // Japanese\n \"構築\",\n \"作成\",\n \"実装\",\n \"設計\",\n \"開発\",\n \"生成\",\n \"デプロイ\",\n \"設定\",\n // Russian\n \"построить\",\n \"построй\",\n \"создать\",\n \"создай\",\n \"реализовать\",\n \"реализуй\",\n \"спроектировать\",\n \"разработать\",\n \"разработай\",\n \"сконструировать\",\n \"сгенерировать\",\n \"сгенерируй\",\n \"развернуть\",\n \"разверни\",\n \"настроить\",\n \"настрой\",\n // German\n \"erstellen\",\n \"bauen\",\n \"implementieren\",\n \"entwerfen\",\n \"entwickeln\",\n \"konstruieren\",\n \"generieren\",\n \"bereitstellen\",\n \"konfigurieren\",\n \"einrichten\",\n // Spanish\n \"construir\",\n \"crear\",\n \"implementar\",\n \"diseñar\",\n \"desarrollar\",\n \"generar\",\n \"desplegar\",\n \"configurar\",\n // Portuguese\n \"construir\",\n \"criar\",\n \"implementar\",\n \"projetar\",\n \"desenvolver\",\n \"gerar\",\n \"implantar\",\n \"configurar\",\n // Korean\n \"구축\",\n \"생성\",\n \"구현\",\n \"설계\",\n \"개발\",\n \"배포\",\n \"설정\",\n // Arabic\n \"بناء\",\n \"إنشاء\",\n \"تنفيذ\",\n \"تصميم\",\n \"تطوير\",\n \"توليد\",\n \"نشر\",\n \"إعداد\",\n ],\n constraintIndicators: [\n // English\n \"under\",\n \"at most\",\n \"at least\",\n \"within\",\n \"no more than\",\n \"o(\",\n \"maximum\",\n \"minimum\",\n \"limit\",\n \"budget\",\n // Chinese\n \"不超过\",\n \"至少\",\n \"最多\",\n \"在内\",\n \"最大\",\n \"最小\",\n \"限制\",\n \"预算\",\n // Japanese\n \"以下\",\n \"最大\",\n \"最小\",\n \"制限\",\n \"予算\",\n // Russian\n \"не более\",\n \"не менее\",\n \"как минимум\",\n \"в пределах\",\n \"максимум\",\n \"минимум\",\n \"ограничение\",\n \"бюджет\",\n // German\n \"höchstens\",\n \"mindestens\",\n \"innerhalb\",\n \"nicht mehr als\",\n \"maximal\",\n \"minimal\",\n \"grenze\",\n \"budget\",\n // Spanish\n \"como máximo\",\n \"al menos\",\n \"dentro de\",\n \"no más de\",\n \"máximo\",\n \"mínimo\",\n \"límite\",\n \"presupuesto\",\n // Portuguese\n \"no máximo\",\n \"pelo menos\",\n \"dentro de\",\n \"não mais que\",\n \"máximo\",\n \"mínimo\",\n \"limite\",\n \"orçamento\",\n // Korean\n \"이하\",\n \"이상\",\n \"최대\",\n \"최소\",\n \"제한\",\n \"예산\",\n // Arabic\n \"على الأكثر\",\n \"على الأقل\",\n \"ضمن\",\n \"لا يزيد عن\",\n \"أقصى\",\n \"أدنى\",\n \"حد\",\n \"ميزانية\",\n ],\n outputFormatKeywords: [\n // English\n \"json\",\n \"yaml\",\n \"xml\",\n \"table\",\n \"csv\",\n \"markdown\",\n \"schema\",\n \"format as\",\n \"structured\",\n // Chinese\n \"表格\",\n \"格式化为\",\n \"结构化\",\n // Japanese\n \"テーブル\",\n \"フォーマット\",\n \"構造化\",\n // Russian\n \"таблица\",\n \"форматировать как\",\n \"структурированный\",\n // German\n \"tabelle\",\n \"formatieren als\",\n \"strukturiert\",\n // Spanish\n \"tabla\",\n \"formatear como\",\n \"estructurado\",\n // Portuguese\n \"tabela\",\n \"formatar como\",\n \"estruturado\",\n // Korean\n \"테이블\",\n \"형식\",\n \"구조화\",\n // Arabic\n \"جدول\",\n \"تنسيق\",\n \"منظم\",\n ],\n referenceKeywords: [\n // English\n \"above\",\n \"below\",\n \"previous\",\n \"following\",\n \"the docs\",\n \"the api\",\n \"the code\",\n \"earlier\",\n \"attached\",\n // Chinese\n \"上面\",\n \"下面\",\n \"之前\",\n \"接下来\",\n \"文档\",\n \"代码\",\n \"附件\",\n // Japanese\n \"上記\",\n \"下記\",\n \"前の\",\n \"次の\",\n \"ドキュメント\",\n \"コード\",\n // Russian\n \"выше\",\n \"ниже\",\n \"предыдущий\",\n \"следующий\",\n \"документация\",\n \"код\",\n \"ранее\",\n \"вложение\",\n // German\n \"oben\",\n \"unten\",\n \"vorherige\",\n \"folgende\",\n \"dokumentation\",\n \"der code\",\n \"früher\",\n \"anhang\",\n // Spanish\n \"arriba\",\n \"abajo\",\n \"anterior\",\n \"siguiente\",\n \"documentación\",\n \"el código\",\n \"adjunto\",\n // Portuguese\n \"acima\",\n \"abaixo\",\n \"anterior\",\n \"seguinte\",\n \"documentação\",\n \"o código\",\n \"anexo\",\n // Korean\n \"위\",\n \"아래\",\n \"이전\",\n \"다음\",\n \"문서\",\n \"코드\",\n \"첨부\",\n // Arabic\n \"أعلاه\",\n \"أدناه\",\n \"السابق\",\n \"التالي\",\n \"الوثائق\",\n \"الكود\",\n \"مرفق\",\n ],\n negationKeywords: [\n // English\n \"don't\",\n \"do not\",\n \"avoid\",\n \"never\",\n \"without\",\n \"except\",\n \"exclude\",\n \"no longer\",\n // Chinese\n \"不要\",\n \"避免\",\n \"从不\",\n \"没有\",\n \"除了\",\n \"排除\",\n // Japanese\n \"しないで\",\n \"避ける\",\n \"決して\",\n \"なしで\",\n \"除く\",\n // Russian\n \"не делай\",\n \"не надо\",\n \"нельзя\",\n \"избегать\",\n \"никогда\",\n \"без\",\n \"кроме\",\n \"исключить\",\n \"больше не\",\n // German\n \"nicht\",\n \"vermeide\",\n \"niemals\",\n \"ohne\",\n \"außer\",\n \"ausschließen\",\n \"nicht mehr\",\n // Spanish\n \"no hagas\",\n \"evitar\",\n \"nunca\",\n \"sin\",\n \"excepto\",\n \"excluir\",\n // Portuguese\n \"não faça\",\n \"evitar\",\n \"nunca\",\n \"sem\",\n \"exceto\",\n \"excluir\",\n // Korean\n \"하지 마\",\n \"피하다\",\n \"절대\",\n \"없이\",\n \"제외\",\n // Arabic\n \"لا تفعل\",\n \"تجنب\",\n \"أبداً\",\n \"بدون\",\n \"باستثناء\",\n \"استبعاد\",\n ],\n domainSpecificKeywords: [\n // English\n \"quantum\",\n \"fpga\",\n \"vlsi\",\n \"risc-v\",\n \"asic\",\n \"photonics\",\n \"genomics\",\n \"proteomics\",\n \"topological\",\n \"homomorphic\",\n \"zero-knowledge\",\n \"lattice-based\",\n // Chinese\n \"量子\",\n \"光子学\",\n \"基因组学\",\n \"蛋白质组学\",\n \"拓扑\",\n \"同态\",\n \"零知识\",\n \"格密码\",\n // Japanese\n \"量子\",\n \"フォトニクス\",\n \"ゲノミクス\",\n \"トポロジカル\",\n // Russian\n \"квантовый\",\n \"фотоника\",\n \"геномика\",\n \"протеомика\",\n \"топологический\",\n \"гомоморфный\",\n \"с нулевым разглашением\",\n \"на основе решёток\",\n // German\n \"quanten\",\n \"photonik\",\n \"genomik\",\n \"proteomik\",\n \"topologisch\",\n \"homomorph\",\n \"zero-knowledge\",\n \"gitterbasiert\",\n // Spanish\n \"cuántico\",\n \"fotónica\",\n \"genómica\",\n \"proteómica\",\n \"topológico\",\n \"homomórfico\",\n // Portuguese\n \"quântico\",\n \"fotônica\",\n \"genômica\",\n \"proteômica\",\n \"topológico\",\n \"homomórfico\",\n // Korean\n \"양자\",\n \"포토닉스\",\n \"유전체학\",\n \"위상\",\n \"동형\",\n // Arabic\n \"كمي\",\n \"ضوئيات\",\n \"جينوميات\",\n \"طوبولوجي\",\n \"تماثلي\",\n ],\n\n // Agentic task keywords - file ops, execution, multi-step, iterative work\n // Pruned: removed overly common words like \"then\", \"first\", \"run\", \"test\", \"build\"\n agenticTaskKeywords: [\n // English - File operations (clearly agentic)\n \"read file\",\n \"read the file\",\n \"look at\",\n \"check the\",\n \"open the\",\n \"edit\",\n \"modify\",\n \"update the\",\n \"change the\",\n \"write to\",\n \"create file\",\n // English - Execution (specific commands only)\n \"execute\",\n \"deploy\",\n \"install\",\n \"npm\",\n \"pip\",\n \"compile\",\n // English - Multi-step patterns (specific only)\n \"after that\",\n \"and also\",\n \"once done\",\n \"step 1\",\n \"step 2\",\n // English - Iterative work\n \"fix\",\n \"debug\",\n \"until it works\",\n \"keep trying\",\n \"iterate\",\n \"make sure\",\n \"verify\",\n \"confirm\",\n // Chinese (keep specific ones)\n \"读取文件\",\n \"查看\",\n \"打开\",\n \"编辑\",\n \"修改\",\n \"更新\",\n \"创建\",\n \"执行\",\n \"部署\",\n \"安装\",\n \"第一步\",\n \"第二步\",\n \"修复\",\n \"调试\",\n \"直到\",\n \"确认\",\n \"验证\",\n // Spanish\n \"leer archivo\",\n \"editar\",\n \"modificar\",\n \"actualizar\",\n \"ejecutar\",\n \"desplegar\",\n \"instalar\",\n \"paso 1\",\n \"paso 2\",\n \"arreglar\",\n \"depurar\",\n \"verificar\",\n // Portuguese\n \"ler arquivo\",\n \"editar\",\n \"modificar\",\n \"atualizar\",\n \"executar\",\n \"implantar\",\n \"instalar\",\n \"passo 1\",\n \"passo 2\",\n \"corrigir\",\n \"depurar\",\n \"verificar\",\n // Korean\n \"파일 읽기\",\n \"편집\",\n \"수정\",\n \"업데이트\",\n \"실행\",\n \"배포\",\n \"설치\",\n \"단계 1\",\n \"단계 2\",\n \"디버그\",\n \"확인\",\n // Arabic\n \"قراءة ملف\",\n \"تحرير\",\n \"تعديل\",\n \"تحديث\",\n \"تنفيذ\",\n \"نشر\",\n \"تثبيت\",\n \"الخطوة 1\",\n \"الخطوة 2\",\n \"إصلاح\",\n \"تصحيح\",\n \"تحقق\",\n ],\n\n // Dimension weights (sum to 1.0)\n dimensionWeights: {\n tokenCount: 0.08,\n codePresence: 0.15,\n reasoningMarkers: 0.18,\n technicalTerms: 0.1,\n creativeMarkers: 0.05,\n simpleIndicators: 0.02, // Reduced from 0.12 to make room for agenticTask\n multiStepPatterns: 0.12,\n questionComplexity: 0.05,\n imperativeVerbs: 0.03,\n constraintCount: 0.04,\n outputFormat: 0.03,\n referenceComplexity: 0.02,\n negationComplexity: 0.01,\n domainSpecificity: 0.02,\n agenticTask: 0.04, // Reduced - agentic signals influence tier selection, not dominate it\n },\n\n // Tier boundaries on weighted score axis\n tierBoundaries: {\n simpleMedium: 0.0,\n mediumComplex: 0.3, // Raised from 0.18 - prevent simple tasks from reaching expensive COMPLEX tier\n complexReasoning: 0.5, // Raised from 0.4 - reserve for true reasoning tasks\n },\n\n // Sigmoid steepness for confidence calibration\n confidenceSteepness: 12,\n // Below this confidence → ambiguous (null tier)\n confidenceThreshold: 0.7,\n },\n\n // ─── Tier chains ───\n //\n // Catalog refresh 2026-08-29 (V3.5). Every chain below names only models\n // the public catalog lists (GET https://blockrun.ai/api/v1/models). Ids the\n // gateway withholds (`hidden: true`) — kimi-k2.5/k2.6/k2.7, the grok-4-fast\n // and grok-4-1-fast pairs, grok-4-0709, claude-opus-4.6, gemini-3-pro-preview,\n // the whole `free/*` namespace — were removed everywhere, including fallback\n // rungs, so a routed model is always one a user can find on blockrun.ai/models.\n //\n // Primaries moved only where portfolio.ts already carries calibration\n // evidence for the successor (Sonnet 5 over Sonnet 4.6, GPT-5 Mini for\n // agentic MEDIUM, Gemini 3.5 Flash where Kimi K2.7 was). Newcomers with no\n // trajectory evidence yet (gemini-3.6-flash, glm-5.3, glm-5.3-flash,\n // gpt-5.6-luna, grok-4.3, minimax-m3, qwen3.7-plus) enter as fallback rungs;\n // promotion waits for a calibration run, because version recency is not a\n // quality signal.\n //\n // Latency figures in comments are the 2026-08-29 gateway probe\n // (model-profiles.generated.json); prices are the catalog list.\n //\n // Retirements 2026-11-24 (owner-approved; the gateways redirect each id\n // before pricing, so a stale name here is a silent model swap, not an error):\n // - google/gemini-3.5-flash -> google/gemini-3.6-flash. Google has served\n // 3.6 Flash under the 3.5 name since ~2026-10-10. Each 3.5 rung now names\n // 3.6 at the same position; where 3.6 already sat in the same chain, the\n // later of the two is dropped, so the order of the models actually served\n // is unchanged. 3.6 inherits 3.5's affinity values, carried, not measured\n // (portfolio.ts).\n // - openai/o4-mini (and o1, o3-mini) -> openai/gpt-5.4-mini, at the same\n // position. Dead at OpenAI since 2026-10-23 and on Azure since 2026-11-19.\n //\n // Retirements 2026-12-01 (Google retires Gemini 2.5; the gateways redirect):\n // - google/gemini-2.5-flash -> google/gemini-3.5-flash-lite (same\n // $0.30/$2.50), in place, with the same dedupe rule. 3.5 Flash-Lite has\n // no vision tag where 2.5 Flash had one, so a SIMPLE vision turn now\n // falls past it to the next vision-capable rung instead of reaching a\n // redirected model that would drop the image.\n // - google/gemini-2.5-pro -> google/gemini-3.8-flash ($0.75/$3.75), in\n // place.\n //\n // Retirements 2026-12-11 (OpenAI shuts down o3, gpt-5-mini and gpt-5-nano —\n // developers.openai.com/api/docs/deprecations, notice 2026-06-11; the\n // gateways redirect each and quote the successor):\n // - openai/o3 -> openai/gpt-5.4-mini ($2/$8 -> $0.75/$4.50). Both o3 rungs\n // (auto and premium REASONING) sat directly behind gpt-5.4-mini, so they\n // are dropped by the dedupe rule; the order actually served is unchanged.\n // - openai/gpt-5-mini -> openai/gpt-5.6-luna ($0.25/$2 -> $0.20/$1.20), in\n // place as the agentic MEDIUM primary. Luna inherits gpt-5-mini's\n // affinity values, CARRIED, not measured (portfolio.ts) — gpt-5-mini is a\n // reasoning model and luna runs without reasoning, so those values are a\n // placeholder until a Terminal-Bench/tau2 run on luna.\n // - openai/gpt-5-nano is NOT redirected (owner decision 2026-11-24): the\n // gateways keep serving it from Azure at its own $0.05/$0.40 until\n // 2027-02-09. It is hidden and in no chain, and none is added.\n\n // Auto (balanced) tier configs - current default smart routing\n tiers: {\n SIMPLE: {\n // Was google/gemini-2.5-flash (60% retention, best, in the 2026-03 run)\n // until its 2026-12-01 retirement. 3.5 Flash-Lite is what the gateways\n // serve under that name from then on; it was this chain's second\n // fallback and is dropped there.\n primary: \"google/gemini-3.5-flash-lite\", // $0.30/$2.50, 1M ctx, thinking mode, no vision\n fallback: [\n \"google/gemini-3-flash-preview\", // $0.50/$3 — GPQA 5/6 in the 2026-07 calibration\n \"deepseek/deepseek-chat\", // $0.14/$0.28, 1M ctx\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50, 1M ctx\n \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx — GPT-5.6 cost tier (cut 2026-07-30)\n \"openai/gpt-5.4-nano\", // $0.20/$1.25, 1M ctx\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n \"nvidia/nemotron-3.5-lightning\", // FREE backstop — NVIDIA free tier (probed 2026-08-30)\n ],\n },\n MEDIUM: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then Gemini 3.5 Flash — the\n // calibrated successor (MGSM 5/5, GPQA 4/6, extraction band) — until its\n // 2026-11-24 retirement. 3.6 Flash is what Google served under that name\n // since ~10-10; it was this chain's first fallback and is dropped there.\n primary: \"google/gemini-3.6-flash\", // $0.75/$3.75, 1M ctx, vision + tools — 3.5's affinity, carried\n fallback: [\n \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools verified live 2026-08-27\n \"openai/gpt-5.6-terra\", // $2/$12, 1M ctx — GPT-5.6 balanced tier\n \"google/gemini-3-flash-preview\", // $0.50/$3\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n \"minimax/minimax-m3\", // $0.30/$1.20, 1M ctx\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"openai/gpt-5.6-luna\", // $0.20/$1.20\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n ],\n },\n COMPLEX: {\n primary: \"google/gemini-3.1-pro\", // $2/$12 — proven long-context flagship (portfolio.ts long_context lead)\n fallback: [\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — Pro-level quality at Flash price (Google's claim); also 3.5 Flash's successor (3.5 retired 2026-11-24 and was the next rung)\n \"anthropic/claude-sonnet-5\", // $3/$15 — near-Opus quality, tau2 + Terminal-Bench calibrated\n \"xai/grok-4.5\", // $2.50/$9 — 503-resistant, independent infra (was grok-4-0709, now hidden)\n \"google/gemini-3.8-flash\", // $0.75/$3.75 — 2.5 Pro's successor (retired 2026-12-01)\n \"anthropic/claude-sonnet-4.6\", // $3/$15\n \"openai/gpt-5.6-terra\", // $2/$12 — GPT-5.6 balanced tier (Sol excluded: #202)\n \"openai/gpt-5.5\", // $5/$30 — prior OpenAI flagship\n \"openai/gpt-5.4\", // $2.50/$15 — previous flagship, benchmarked\n \"zai/glm-5.3\", // $1.40/$4.40, 1M ctx, always-on thinking — verified live 2026-08-19\n \"moonshot/kimi-k3.1-pro\", // $2/$10, 1M ctx — Moonshot flagship (K3 successor)\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87 — strongest open-weight reasoner\n \"deepseek/deepseek-chat\", // $0.14/$0.28 — cheap last resort\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n REASONING: {\n // Was xai/grok-4-1-fast-reasoning ($0.20/$0.50, hidden 2026-08). DeepSeek\n // Reasoner is the cheapest listed reasoner at the same 1M context.\n primary: \"deepseek/deepseek-reasoner\", // $0.14/$0.28, 1M ctx\n fallback: [\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87 — calibrated reasoning band 0.95\n \"xai/grok-4.3\", // $1.50/$4, 1M ctx — xAI reasoning model, vision\n \"qwen/qwen3.7-plus\", // $0.32/$1.28, 1M ctx — reasoning; needs a generous max_tokens (thinking is billed)\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — 3.5 Flash's successor (MGSM 5/5 on 3.5, carried)\n \"openai/gpt-5.4-mini\", // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung)\n ],\n },\n },\n\n // Eco tier configs - absolute cheapest (blockrun/eco)\n ecoTiers: {\n SIMPLE: {\n primary: \"nvidia/nemotron-3.5-lightning\", // FREE — NVIDIA free tier flagship, 1M ctx\n fallback: [\n // Was nvidia/nemotron-3-nano-30b until blockrun delisted it on 2026-09-08\n // (NVIDIA deprovisioned it for the account — a structured per-account\n // 404). nano-omni is blockrun's own redirect target for that id, so this\n // follows the same rule as the head: the router and the gateway name the\n // same model.\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\", // FREE — nano-30b's successor, 256K ctx\n // The free head keeps rotting with NVIDIA's hosting (deepseek-v4-flash\n // 410 2026-08-12, seed-oss-36b 410 2026-08-03, gpt-oss-120b/20b 400\n // 2026-08-21, and on 2026-08-30 FOUR of the five visible free models at\n // once — step-3.7-flash, nemotron-nano-9b-v2 and nemotron-nano-12b-v2-vl\n // all 410, mistral-nemotron hung). Each retirement retargets the two\n // free rungs to the current free tier; the paid rungs below never move.\n // The head follows blockrun's own redirect of the model it replaces, so\n // the router and the gateway never name different models.\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40 — cheapest paid rung\n \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools\n \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx\n \"openai/gpt-5.4-nano\", // $0.20/$1.25\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n ],\n },\n MEDIUM: {\n primary: \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx, vision + tools verified live — cheapest full-capability model\n fallback: [\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"openai/gpt-5.6-luna\", // $0.20/$1.20\n \"openai/gpt-5.4-nano\", // $0.20/$1.25\n \"google/gemini-2.5-flash-lite\", // $0.10/$0.40\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n COMPLEX: {\n primary: \"zai/glm-5.3-flash\", // $0.15/$0.50, 1M ctx\n fallback: [\n \"deepseek/deepseek-chat\", // $0.14/$0.28, 1M ctx\n \"minimax/minimax-m3\", // $0.30/$1.20, 1M ctx\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87\n \"google/gemini-3.1-flash-lite\", // $0.25/$1.50\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n REASONING: {\n primary: \"deepseek/deepseek-reasoner\", // $0.14/$0.28, 1M ctx — cheapest listed reasoner\n fallback: [\n \"deepseek/deepseek-v4-pro\", // $0.435/$0.87\n \"qwen/qwen3.7-plus\", // $0.32/$1.28 — reasoning\n \"minimax/minimax-m3\", // $0.30/$1.20 — reasoning + coding\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — reasoning tokens alongside content\n ],\n },\n },\n\n // Premium tier configs - best quality (blockrun/premium)\n // codex=complex coding, flash=simple coding, sonnet=reasoning/instructions, fable/opus=architecture/PM/audits\n premiumTiers: {\n SIMPLE: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then Gemini 3.5 Flash until\n // its 2026-11-24 retirement; 3.6 Flash was the first fallback and is\n // dropped there.\n primary: \"google/gemini-3.6-flash\", // $0.75/$3.75, 1M ctx, vision + tools — 3.5's affinity, carried\n fallback: [\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"zai/glm-5.3\", // $1.40/$4.40, 1M ctx\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — written where 2.5 Flash sat (retired 2026-12-01); the duplicate after it is dropped\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n ],\n },\n MEDIUM: {\n primary: \"openai/gpt-5.3-codex\", // $1.75/$14 - 400K context, 128K output — code_edit/debug lead (portfolio.ts)\n fallback: [\n \"anthropic/claude-sonnet-5\", // $3/$15 — code_agent band 0.98\n \"moonshot/kimi-k3.1-pro\", // $2/$10, 1M ctx — Moonshot flagship\n \"zai/glm-5.3\", // $1.40/$4.40 — long-horizon coding\n \"google/gemini-3.6-flash\", // $0.75/$3.75 (3.5 Flash, the next rung, retired 2026-11-24)\n \"google/gemini-3.8-flash\", // $0.75/$3.75 — 2.5 Pro's successor (retired 2026-12-01)\n \"xai/grok-4.5\", // $2.50/$9\n \"anthropic/claude-sonnet-4.6\", // $3/$15\n \"openai/gpt-5.6-terra\", // $2/$12\n ],\n },\n COMPLEX: {\n // fable-5 was promoted here 2026-06-11, force-reverted 2026-06-13 when Anthropic\n // withdrew the offer, and restored 2026-07-14 now that BlockRun has relisted it.\n primary: \"anthropic/claude-fable-5\", // Best quality for complex tasks — Mythos-class flagship above Opus ($10/$50, 1M ctx, always-on thinking)\n // Fallback chain de-Gemini'd 2026-04-22: when Anthropic 503s, Gemini is\n // also prone to \"high demand\" 503s (correlated failure — everyone falls\n // back to Google at the same time). Prefer in-family → xAI → Moonshot →\n // OpenAI flagship → Z.AI → DeepSeek → NVIDIA free instead.\n fallback: [\n \"anthropic/claude-opus-5\", // in-family hot swap first (half the price, 1M ctx + adaptive thinking)\n \"anthropic/claude-opus-4.8\", // in-family hot swap (identical cost to 5)\n \"anthropic/claude-opus-4.7\", // in-family hot swap (identical cost to 4.8)\n \"anthropic/claude-sonnet-5\", // Sonnet-tier drop-down, near-Opus quality\n \"anthropic/claude-sonnet-4.6\",\n \"xai/grok-4.5\", // xAI flagship — 503-resistant, direct-xAI SKU\n \"moonshot/kimi-k3.1-pro\", // Moonshot flagship, independent infra\n \"openai/gpt-5.6-terra\", // GPT-5.6 balanced tier — stable (Sol excluded: #202)\n \"openai/gpt-5.5\", // Prior OpenAI flagship — 1M+ ctx, native agent + computer use\n \"openai/gpt-5.4\", // Previous flagship (slow but stable, benchmarked at 6,213ms)\n \"openai/gpt-5.3-codex\",\n \"zai/glm-5.3\", // Z.AI flagship, 1M ctx\n \"deepseek/deepseek-v4-pro\", // strongest open-weight reasoner\n \"deepseek/deepseek-chat\", // Cheap, reliable\n \"nvidia/nemotron-3.5-lightning\", // NVIDIA free ultimate backstop\n ],\n },\n REASONING: {\n // Sonnet 5 promoted over Sonnet 4.6 (same price; reasoning band 0.98 for both,\n // plus Sonnet 5's tau2/BrowseComp trajectory evidence).\n primary: \"anthropic/claude-sonnet-5\", // $3/$15, 1M ctx, adaptive thinking\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus w/ adaptive thinking\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus w/ adaptive thinking\n \"xai/grok-4.5\", // reasoning band 0.94\n \"deepseek/deepseek-v4-pro\", // reasoning band 0.95\n \"xai/grok-4.3\", // $1.50/$4 — xAI reasoning model\n \"openai/gpt-5.4-mini\", // $0.75/$4.50 — o4-mini's and o3's successor (retired 2026-11-24 and 2026-12-11; o3 was the next rung)\n ],\n },\n },\n\n // Agentic tier configs - models that excel at multi-step autonomous tasks\n agenticTiers: {\n SIMPLE: {\n primary: \"openai/gpt-4o-mini\", // $0.15/$0.60 - best tool compliance at lowest cost\n fallback: [\n \"openai/gpt-5.6-luna\", // $0.20/$1.20 — lightweight agentic tier of GPT-5.6\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — tool calls verified live 2026-08-27\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"google/gemini-3.5-flash-lite\", // $0.30/$2.50 — 2.5 Flash's successor (retired 2026-12-01)\n ],\n },\n MEDIUM: {\n // Was moonshot/kimi-k2.7 (hidden 2026-08), then GPT-5 Mini — which\n // carries the Terminal-Bench and tau2 trajectory evidence in\n // portfolio.ts — until its 2026-12-11 retirement. GPT-5.6 Luna is what\n // the gateways serve under that name from then on.\n primary: \"openai/gpt-5.6-luna\", // $0.20/$1.20, 1M ctx, vision + tools — gpt-5-mini's affinity (4/7 Terminal-Bench, 5/6 tau2 airline), carried\n fallback: [\n \"google/gemini-3.6-flash\", // $0.75/$3.75 — tool_agent band 0.88 (3.5's, carried)\n \"zai/glm-5.3-flash\", // $0.15/$0.50 — tools verified\n \"openai/gpt-5.6-terra\", // $2/$12\n \"openai/gpt-4o-mini\", // $0.15/$0.60 — reliable tool calling\n \"anthropic/claude-haiku-4.5\", // $1/$5\n \"deepseek/deepseek-chat\", // $0.14/$0.28\n \"moonshot/kimi-k3.1-pro\", // $2/$10 — tool_agent band 0.85\n ],\n },\n COMPLEX: {\n // Sonnet 5 promoted over Sonnet 4.6: tau2 airline + retail reward 1.0,\n // Terminal-Bench safety band lead (portfolio.ts).\n primary: \"anthropic/claude-sonnet-5\", // $3/$15 — best agentic quality per trajectory evidence\n // Fallback chain de-Gemini'd 2026-04-22: Gemini's \"high demand\" 503s\n // correlate with Anthropic outages (everyone falls back together).\n // Prefer 503-resistant providers first.\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus — in-family hot swap\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus — in-family hot swap\n \"xai/grok-4.5\", // xAI flagship — strong tool use, independent infra\n \"moonshot/kimi-k3.1-pro\", // Moonshot flagship — independent infra\n \"openai/gpt-5.6-terra\", // GPT-5.6 balanced tier — stable (Sol excluded: #202)\n \"openai/gpt-5.5\", // Prior flagship — native agent + computer use (exactly the agentic-tier use case)\n \"openai/gpt-5.4\", // Previous flagship — reliable\n \"openai/gpt-5.3-codex\", // code_agent lead\n \"zai/glm-5.3\", // long-horizon coding\n \"deepseek/deepseek-v4-pro\", // retail high-risk 3/3\n \"deepseek/deepseek-chat\", // cheap, reliable\n \"nvidia/nemotron-3.5-lightning\", // NVIDIA free ultimate backstop\n ],\n },\n REASONING: {\n primary: \"anthropic/claude-sonnet-5\", // $3/$15 — strong tool use + adaptive thinking\n fallback: [\n \"anthropic/claude-sonnet-4.6\", // in-family hot swap — same cost\n \"anthropic/claude-opus-5\", // Newest flagship Opus w/ adaptive thinking\n \"anthropic/claude-opus-4.8\", // Prior flagship Opus — identical cost to 5\n \"anthropic/claude-opus-4.7\", // Flagship Opus w/ adaptive thinking\n \"xai/grok-4.5\", // reasoning band 0.94\n \"deepseek/deepseek-v4-pro\", // reasoning band 0.95\n \"deepseek/deepseek-reasoner\", // $0.14/$0.28\n ],\n },\n },\n\n // Time-windowed promotions — auto-applied when active, ignored when expired.\n // The GLM-5.1 launch promo (2026-04-01 → 2026-05-01) was the last entry and\n // has expired; the list is kept empty so the mechanism stays wired.\n promotions: [],\n\n overrides: {\n maxTokensForceComplex: 100_000,\n structuredOutputMinTier: \"MEDIUM\",\n ambiguousDefaultTier: \"MEDIUM\",\n // agenticMode left undefined → auto-detect via tools/agenticScore.\n // Set to `true` to force agentic tiers; `false` to disable them entirely.\n },\n};\n","/**\n * Model capabilities used for hard routing constraints.\n *\n * Hosts may inject fresher values through RouterOptions.modelCapabilities.\n * Keeping a small built-in snapshot makes the core safe and useful when a\n * product catalog is temporarily unavailable, without importing product code.\n *\n * GENERATED by scripts/sync-model-capabilities.mjs from the public catalog\n * (GET https://blockrun.ai/api/v1/models) on 2026-11-24; supportsTools comes\n * from a live function-calling probe (scripts/probe-tools.json). Regenerate\n * rather than editing by hand — a hand edit is overwritten on the next sync.\n */\nexport type ModelCapabilities = {\n contextWindow: number;\n maxOutputTokens: number;\n supportsTools: boolean;\n supportsVision: boolean;\n};\n\nexport const DEFAULT_MODEL_CAPABILITIES: Readonly> =\n Object.freeze({\n \"anthropic/claude-fable-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-fable-5.1\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-fable-5.2\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"anthropic/claude-haiku-4.5\": { // override: The public catalog's `categories` omit \"vision\" for this Anthropic model even though the gateway accepts image input for it (the prior hand-maintained snapshot had it, and Anthropic's model card lists it). Without this the vision filter would silently drop it — reported against the catalog; remove once the categories carry vision.\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.5\": {\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.7\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-4.8\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-opus-5.5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-4.5\": {\n contextWindow: 200_000,\n maxOutputTokens: 64_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-4.6\": { // override: The public catalog's `categories` omit \"vision\" for this Anthropic model even though the gateway accepts image input for it (the prior hand-maintained snapshot had it, and Anthropic's model card lists it). Without this the vision filter would silently drop it — reported against the catalog; remove once the categories carry vision.\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"anthropic/claude-sonnet-5.5\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"cohere/north-mini-code\": { // supportsTools: not probed — fails closed\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"deepseek/deepseek-chat\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-chat \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-reasoner\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-reasoner \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-v4-flash-vision-exp\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"deepseek/deepseek-v4-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"deepseek/deepseek-v4.1-flash\": { // override: The 2026-11-08 catalog began tagging deepseek/deepseek-v4.1-flash \"vision\" (it was text-only through 2026-10-20), and DeepSeek still ships image input as a separate experimental id (deepseek/deepseek-v4-flash-vision-exp). No image probe has confirmed the tag. Routing an image turn to a model that silently drops the image returns a confident 200 the caller cannot branch on, so this fails closed until a correctly sized image probe passes on both chains; then remove this entry.\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-2.5-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-2.5-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-2.5-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3-flash-preview\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.1-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-3.1-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.5-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.5-flash-lite\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"google/gemini-3.6-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-3.8-flash\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-4-argon\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"google/gemini-4-carbon\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"google/gemini-4-hydrogen\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"google/gemini-4-neon\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: false,\n supportsVision: true,\n },\n \"minimax/minimax-m2.7\": {\n contextWindow: 204_800,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"minimax/minimax-m3\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"mistral/mistral-large-4\": { // supportsTools: not probed — fails closed\n contextWindow: 524_288,\n maxOutputTokens: 262_144,\n supportsTools: false,\n supportsVision: true,\n },\n \"moonshot/kimi-k3.1-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: true,\n },\n \"nvidia/minimax-m3.1-flash\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/muse-glimmer-30b\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\": { // override: The catalog tags this model \"vision\", but a correctly sized probe does not hold up (ClawRouter, 2026-08-31): a 64x64 solid-red PNG was named correctly 1 of 4 times on Base, and on Solana the image was silently dropped and a text model answered \"white\". An HTTP 200 with a confident wrong answer gives the caller nothing to branch on, so image turns must not be routed here. It is ecoTiers.SIMPLE.fallback[0] since nemotron-3-nano-30b was delisted (2026-09-08); remove once a probe of this size comes back right on both chains.\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3-super-120b\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: true,\n },\n \"nvidia/nemotron-3-ultra-550b\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"nvidia/nemotron-3.5-bolt\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: true,\n },\n \"nvidia/nemotron-3.5-lightning\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"openai/chat-latest\": {\n contextWindow: 128_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4.1\": {\n contextWindow: 128_000,\n maxOutputTokens: 32_768,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4.1-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 32_768,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-4o\": {\n contextWindow: 128_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-4o-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5-mini\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.1\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.2\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.2-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.3-codex\": { // supportsTools: gateway unavailable at probe time — fails closed; override: 2026-08-29 probe: every request (6 plain + 3 tool attempts) returned a gateway 500, so the probe measured an incident, not the model. Codex's function calling is established by the 2026-07 Terminal-Bench / tau2 calibration trajectories in portfolio.ts. Hosts observing the 500s should drop it with RouterOptions.unavailableModels rather than this snapshot claiming the model cannot call tools.\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.4\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.4-mini\": {\n contextWindow: 400_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.4-nano\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/gpt-5.4-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.5\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.5-pro\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.6-luna\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-luna-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-5.6-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-sol-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-terra\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-5.6-terra-pro\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-astra\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-luna\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6.1-sol\": {\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: true,\n },\n \"openai/gpt-6.2-astra\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/gpt-6.2-sol\": { // supportsTools: not probed — fails closed\n contextWindow: 1_050_000,\n maxOutputTokens: 128_000,\n supportsTools: false,\n supportsVision: true,\n },\n \"openai/o1\": {\n contextWindow: 200_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o3\": {\n contextWindow: 200_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o3-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"openai/o4-mini\": {\n contextWindow: 128_000,\n maxOutputTokens: 100_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"poolside/laguna-s-2.1\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: false,\n },\n \"poolside/laguna-xs-2.1\": { // supportsTools: not probed — fails closed\n contextWindow: 131_072,\n maxOutputTokens: 16_384,\n supportsTools: false,\n supportsVision: false,\n },\n \"qwen/qwen3.7-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.7-max\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 65_536,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.7-plus\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"qwen/qwen3.8-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: true,\n },\n \"qwen/qwen3.8-max\": { // supportsTools: not probed — fails closed\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: false,\n supportsVision: false,\n },\n \"tencent/hy4-preview\": { // supportsTools: not probed — fails closed\n contextWindow: 1_048_576,\n maxOutputTokens: 64_000,\n supportsTools: false,\n supportsVision: false,\n },\n \"xai/grok-4.3\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.5\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.6\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-4.7\": {\n contextWindow: 500_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: true,\n },\n \"xai/grok-build-0.1\": {\n contextWindow: 256_000,\n maxOutputTokens: 16_384,\n supportsTools: true,\n supportsVision: false,\n },\n \"xiaomi/mimo-v2.5\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: true,\n },\n \"xiaomi/mimo-v2.5-pro\": {\n contextWindow: 1_048_576,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5-turbo\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.1\": {\n contextWindow: 200_000,\n maxOutputTokens: 128_000,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.2\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.3\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: false,\n },\n \"zai/glm-5.3-flash\": {\n contextWindow: 1_000_000,\n maxOutputTokens: 131_072,\n supportsTools: true,\n supportsVision: true,\n },\n });\n","{\n \"anthropic/claude-fable-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9298.5,\n \"p95LatencyMs\": 9873.4,\n \"outputTokensPerSecond\": 55.17,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-haiku-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3157.4,\n \"p95LatencyMs\": 3170.7,\n \"outputTokensPerSecond\": 162.16,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6497.7,\n \"p95LatencyMs\": 6953.7,\n \"outputTokensPerSecond\": 78.99,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.7\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5316.5,\n \"p95LatencyMs\": 6121.5,\n \"outputTokensPerSecond\": 97.34,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-4.8\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6216.1,\n \"p95LatencyMs\": 6847.7,\n \"outputTokensPerSecond\": 82.81,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-opus-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7309,\n \"p95LatencyMs\": 7745.2,\n \"outputTokensPerSecond\": 70.17,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6330.4,\n \"p95LatencyMs\": 6631.6,\n \"outputTokensPerSecond\": 81.03,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-4.6\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6508,\n \"p95LatencyMs\": 6698.3,\n \"outputTokensPerSecond\": 78.6,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"anthropic/claude-sonnet-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6165.4,\n \"p95LatencyMs\": 6582.9,\n \"outputTokensPerSecond\": 83.62,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-chat\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4351.4,\n \"p95LatencyMs\": 4543.7,\n \"outputTokensPerSecond\": 117.78,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-reasoner\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5201.2,\n \"p95LatencyMs\": 6079.6,\n \"outputTokensPerSecond\": 99.77,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-v4-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 8781.2,\n \"p95LatencyMs\": 9881.1,\n \"outputTokensPerSecond\": 58.98,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"deepseek/deepseek-v4.1-flash\": {\n \"measuredAt\": \"2026-10-20T18:12:51Z\",\n \"latencyMs\": 2383.5,\n \"p95LatencyMs\": 2547.8,\n \"outputTokensPerSecond\": 216.53,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5416.4,\n \"p95LatencyMs\": 6442.8,\n \"outputTokensPerSecond\": 213.07,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5002.6,\n \"p95LatencyMs\": 5780.3,\n \"outputTokensPerSecond\": 408.43,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-2.5-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 28169.5,\n \"p95LatencyMs\": 29491.4,\n \"outputTokensPerSecond\": 147.3,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3-flash-preview\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4717.1,\n \"p95LatencyMs\": 5037.1,\n \"outputTokensPerSecond\": 198.71,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.1-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2855.8,\n \"p95LatencyMs\": 3172.7,\n \"outputTokensPerSecond\": 286.91,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.1-pro\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 24194.1,\n \"p95LatencyMs\": 27269.6,\n \"outputTokensPerSecond\": 109.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.5-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5320.6,\n \"p95LatencyMs\": 5429.8,\n \"outputTokensPerSecond\": 226.21,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.5-flash-lite\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3515.8,\n \"p95LatencyMs\": 4363.4,\n \"outputTokensPerSecond\": 248.9,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"google/gemini-3.6-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 13020,\n \"p95LatencyMs\": 15383.1,\n \"outputTokensPerSecond\": 187.87,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"minimax/minimax-m2.7\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 8761.1,\n \"p95LatencyMs\": 10199.3,\n \"outputTokensPerSecond\": 59.18,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"minimax/minimax-m3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 11101.9,\n \"p95LatencyMs\": 26087.1,\n \"outputTokensPerSecond\": 101.12,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"moonshot/kimi-k3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 24498.9,\n \"p95LatencyMs\": 40365.3,\n \"outputTokensPerSecond\": 25.11,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"moonshot/kimi-k3.1-pro\": {\n \"measuredAt\": \"2026-11-23T20:18:18Z\",\n \"latencyMs\": 9243.1,\n \"p95LatencyMs\": 10504.1,\n \"outputTokensPerSecond\": 55.89,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"nvidia/mistral-nemotron\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7349.6,\n \"p95LatencyMs\": 9932.3,\n \"outputTokensPerSecond\": 79.48,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 9324.6,\n \"p95LatencyMs\": 12992,\n \"outputTokensPerSecond\": 64.96,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"nvidia/nemotron-nano-12b-v2-vl\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5846.9,\n \"p95LatencyMs\": 5846.9,\n \"outputTokensPerSecond\": 87.57,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"nvidia/nemotron-nano-9b-v2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5282.5,\n \"p95LatencyMs\": 5282.5,\n \"outputTokensPerSecond\": 96.92,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"nvidia/step-3.7-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4617.4,\n \"p95LatencyMs\": 5237.4,\n \"outputTokensPerSecond\": 112.92,\n \"errorRate\": 0.3333,\n \"samples\": 3\n },\n \"openai/chat-latest\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3690.9,\n \"p95LatencyMs\": 4344,\n \"outputTokensPerSecond\": 111.85,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3527.9,\n \"p95LatencyMs\": 3831.7,\n \"outputTokensPerSecond\": 141.27,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4268.2,\n \"p95LatencyMs\": 5101.5,\n \"outputTokensPerSecond\": 103.42,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4.1-nano\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3088.3,\n \"p95LatencyMs\": 3369.2,\n \"outputTokensPerSecond\": 150.31,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4o\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2995.2,\n \"p95LatencyMs\": 3174.2,\n \"outputTokensPerSecond\": 171.32,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-4o-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4751.5,\n \"p95LatencyMs\": 4930.4,\n \"outputTokensPerSecond\": 107.84,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4558.1,\n \"p95LatencyMs\": 5081.9,\n \"outputTokensPerSecond\": 113.25,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5436.6,\n \"p95LatencyMs\": 5928.8,\n \"outputTokensPerSecond\": 95.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.3-codex\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 15290.4,\n \"p95LatencyMs\": 15290.4,\n \"outputTokensPerSecond\": 33.49,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"openai/gpt-5.4\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5596,\n \"p95LatencyMs\": 5919.4,\n \"outputTokensPerSecond\": 91.67,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.4-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3377.8,\n \"p95LatencyMs\": 3646.8,\n \"outputTokensPerSecond\": 138.08,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.4-nano\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4040.4,\n \"p95LatencyMs\": 4205.9,\n \"outputTokensPerSecond\": 118.52,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6367.8,\n \"p95LatencyMs\": 7330.7,\n \"outputTokensPerSecond\": 81.29,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-luna\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6064.5,\n \"p95LatencyMs\": 7347.3,\n \"outputTokensPerSecond\": 87.93,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-luna-pro\": {\n \"measuredAt\": \"2026-08-29T16:59:54Z\",\n \"latencyMs\": 13914.9,\n \"p95LatencyMs\": 13914.9,\n \"outputTokensPerSecond\": 36.79,\n \"errorRate\": 0.6667,\n \"samples\": 3\n },\n \"openai/gpt-5.6-sol\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7720.2,\n \"p95LatencyMs\": 9108.2,\n \"outputTokensPerSecond\": 67.47,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-sol-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 11442.7,\n \"p95LatencyMs\": 13363.1,\n \"outputTokensPerSecond\": 148.75,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-terra\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4941,\n \"p95LatencyMs\": 5095.3,\n \"outputTokensPerSecond\": 103.69,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-5.6-terra-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3574.1,\n \"p95LatencyMs\": 4126.3,\n \"outputTokensPerSecond\": 133.59,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/gpt-6.1-sol\": {\n \"measuredAt\": \"2026-10-20T18:12:51Z\",\n \"latencyMs\": 11324,\n \"p95LatencyMs\": 12747.6,\n \"outputTokensPerSecond\": 45.11,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4324.9,\n \"p95LatencyMs\": 5838.1,\n \"outputTokensPerSecond\": 125.86,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 5463.4,\n \"p95LatencyMs\": 5613.1,\n \"outputTokensPerSecond\": 93.8,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o3-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 2912.7,\n \"p95LatencyMs\": 3092.1,\n \"outputTokensPerSecond\": 176.49,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"openai/o4-mini\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 4958.7,\n \"p95LatencyMs\": 5313,\n \"outputTokensPerSecond\": 103.81,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 3385.5,\n \"p95LatencyMs\": 4042.7,\n \"outputTokensPerSecond\": 153.94,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-max\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9387.1,\n \"p95LatencyMs\": 10490.2,\n \"outputTokensPerSecond\": 54.92,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"qwen/qwen3.7-plus\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9766.6,\n \"p95LatencyMs\": 9798.2,\n \"outputTokensPerSecond\": 52.42,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"tencent/hy3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6062.3,\n \"p95LatencyMs\": 7070.2,\n \"outputTokensPerSecond\": 87.3,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-4.3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 9467.7,\n \"p95LatencyMs\": 10087.9,\n \"outputTokensPerSecond\": 48.36,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-4.5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 13564.8,\n \"p95LatencyMs\": 17351.9,\n \"outputTokensPerSecond\": 60.71,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xai/grok-build-0.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 16394.8,\n \"p95LatencyMs\": 18035.4,\n \"outputTokensPerSecond\": 96.86,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"xiaomi/mimo-v2.5-pro\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 12070.7,\n \"p95LatencyMs\": 12386.8,\n \"outputTokensPerSecond\": 42.44,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 6839.7,\n \"p95LatencyMs\": 7261.4,\n \"outputTokensPerSecond\": 75.16,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5-turbo\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 55348.5,\n \"p95LatencyMs\": 114086.6,\n \"outputTokensPerSecond\": 14.64,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.1\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 15658.4,\n \"p95LatencyMs\": 17307.1,\n \"outputTokensPerSecond\": 32.9,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.2\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 10308.5,\n \"p95LatencyMs\": 15127.6,\n \"outputTokensPerSecond\": 54.87,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.3\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 7272.4,\n \"p95LatencyMs\": 7998.1,\n \"outputTokensPerSecond\": 71.09,\n \"errorRate\": 0,\n \"samples\": 3\n },\n \"zai/glm-5.3-flash\": {\n \"measuredAt\": \"2026-08-29T16:51:33Z\",\n \"latencyMs\": 10545.3,\n \"p95LatencyMs\": 11672.4,\n \"outputTokensPerSecond\": 49.01,\n \"errorRate\": 0,\n \"samples\": 3\n }\n}\n","/**\n * Model-performance priors consumed by the portfolio router.\n *\n * The entries below are a small, auditable seed extracted from the 2026-03-16\n * BlockRun performance run. They are deliberately weak priors: live data\n * injected by the host should replace them through configuration before a\n * release. Historical numbers must never be presented as a current\n * provider SLA or as task-quality measurements.\n */\n\nimport liveProfiles from \"./model-profiles.generated.json\";\n\nexport type ModelPerformanceProfile = {\n measuredAt: string;\n /** Gateway end-to-end latency for the benchmark workload. */\n latencyMs: number;\n /** Tail latency is more relevant than mean latency for urgent requests. */\n p95LatencyMs?: number;\n outputTokensPerSecond: number;\n /** External intelligence index when one was available; not task success. */\n intelligenceIndex?: number;\n /** Failure fraction observed in the same benchmark run. */\n errorRate?: number;\n /** Number of sampled calls behind the observation. */\n samples?: number;\n};\n\n// Generated from benchmark files that satisfy the uncached-inference\n// invariant. These are weak performance priors (speed/reliability), never\n// task-quality labels.\nexport const LIVE_MODEL_PROFILES: Readonly> = Object.freeze(\n liveProfiles as Record,\n);\n\nexport const HISTORICAL_MODEL_PROFILES: Readonly> =\n Object.freeze({\n \"anthropic/claude-haiku-4.5\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2305,\n outputTokensPerSecond: 140.6,\n },\n \"anthropic/claude-sonnet-4.6\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2110,\n outputTokensPerSecond: 121.3,\n },\n \"deepseek/deepseek-chat\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1431,\n outputTokensPerSecond: 179.2,\n intelligenceIndex: 32,\n },\n \"google/gemini-2.5-flash\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1238,\n outputTokensPerSecond: 207.6,\n intelligenceIndex: 20,\n },\n \"google/gemini-2.5-flash-lite\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1353,\n outputTokensPerSecond: 192.5,\n intelligenceIndex: 20,\n },\n \"google/gemini-2.5-pro\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1294,\n outputTokensPerSecond: 197.8,\n },\n \"google/gemini-3.1-pro\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 1609,\n outputTokensPerSecond: 167.2,\n },\n \"openai/gpt-4o-mini\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 2764,\n outputTokensPerSecond: 92.8,\n },\n \"openai/gpt-5.3-codex\": {\n measuredAt: \"2026-03-16T13:50:48Z\",\n latencyMs: 7935,\n outputTokensPerSecond: 32.3,\n },\n });\n","/**\n * Whether the request actually requires an external action/tool, as distinct\n * from merely being sent by a host that exposes tools on every turn.\n *\n * The detector intentionally looks for action+target pairs. A generic factual\n * or multiple-choice question must stay false even when the host attaches a\n * large tool schema; otherwise every tool-enabled host turn is over-routed as\n * an agent task and models may browse or mutate state unnecessarily.\n */\nexport function inferToolRequirement(\n prompt: string,\n _systemPrompt?: string,\n toolChoice?: unknown,\n): boolean {\n // OpenAI-compatible clients can state this requirement directly. Treat that\n // protocol signal as authoritative instead of trying to infer it from prose.\n if (toolChoice === \"none\") return false;\n if (toolChoice === \"required\") return true;\n if (\n typeof toolChoice === \"object\" &&\n toolChoice !== null &&\n (toolChoice as { type?: unknown }).type === \"function\"\n ) {\n return true;\n }\n\n // System prompts commonly describe every tool a host exposes. They are not\n // evidence that the user asked to perform an action on this turn. Explicit\n // host requirements should use tool_choice/requiresTools instead.\n const text = prompt;\n const explicitTool =\n /\\b(?:use|call|invoke)\\s+(?:the\\s+)?[\\w.-]+\\s+(?:tool|function|api)\\b|\\btool[_ -]?call\\b|使用.{0,20}(?:工具|函数|接口)|调用.{0,20}(?:工具|函数|接口)/i;\n const codeEnvironment =\n /\\b(?:run|execute)\\s+(?:the\\s+)?(?:tests?|command|script|build|linter)|\\b(?:edit|modify|patch|create|write|save|delete|rename|move|inspect|read)\\b.{0,60}\\b(?:file|repository|repo|codebase|directory|folder)\\b|\\b(?:terminal|shell|bash|zsh|pytest|npm test|pnpm test|git\\s+(?:status|diff|commit)|docker)\\b|(?:运行|执行).{0,20}(?:测试|命令|脚本|构建)|(?:修改|编辑|修复|创建|读取|检查|保存).{0,30}(?:文件|仓库|代码库|目录)/i;\n const webAction =\n /\\b(?:browse|search|look up|fetch|open)\\b.{0,80}\\b(?:web|website|url|online|documentation|docs|news|weather|price)\\b|(?:浏览|搜索|查询|打开).{0,30}(?:网页|网站|链接|文档|新闻|天气|价格)/i;\n const statefulAction =\n /\\b(?:refund|cancel|book|reserve|purchase|buy|return|exchange|transfer|update|change)\\b.{0,80}\\b(?:order|booking|reservation|account|address|payment|subscription|ticket|flight|item)\\b|(?:退款|取消|预订|购买|退货|换货|转账|更新|修改).{0,30}(?:订单|预订|账户|地址|付款|订阅|票|航班|商品)/i;\n return (\n explicitTool.test(text) ||\n codeEnvironment.test(text) ||\n webAction.test(text) ||\n statefulAction.test(text)\n );\n}\n","/**\n * V3 portfolio router.\n *\n * This is deliberately local and deterministic: feature extraction, eligibility\n * checks and scoring read only request data plus the in-process model registry.\n * It is therefore safe for the hot path and provides a stable baseline for the\n * RouterBench evaluation before health telemetry / an optional judge are added.\n */\n\nimport { DEFAULT_ROUTING_CONFIG } from \"./config.js\";\nimport { DEFAULT_MODEL_CAPABILITIES } from \"./model-capabilities.js\";\nimport { getFallbackChain, selectModel, usablePricing } from \"./selector.js\";\nimport { RulesStrategy } from \"./strategy.js\";\nimport {\n HISTORICAL_MODEL_PROFILES,\n LIVE_MODEL_PROFILES,\n type ModelPerformanceProfile,\n} from \"./model-profiles.js\";\nimport type { RouterOptions, RouterStrategy, TaskType, Tier, TierConfig } from \"./types.js\";\nimport { inferToolRequirement } from \"./tool-intent.js\";\nimport { estimateTokens, sampleForScan, scanLimit } from \"./tokens.js\";\n\ntype TaskFeatures = {\n taskType: TaskType;\n estimatedInputTokens: number;\n hasCode: boolean;\n needsTools: boolean;\n toolsAvailable: boolean;\n needsVision: boolean;\n needsStructuredOutput: boolean;\n latencySensitive: boolean;\n highStakes: boolean;\n language: \"zh\" | \"other\";\n likelyParallelToolCalls: boolean;\n complexMultiToolPlan: boolean;\n agentDomain: \"airline\" | \"retail\" | \"web_research\" | \"other\";\n deepWebResearch: boolean;\n agentRisk: \"standard\" | \"high\" | \"complex_high\" | \"policy_exception_simple\" | \"policy_exception\";\n terminalToolSignal: boolean;\n terminalSafetySensitive: boolean;\n implicitTerminalCode: boolean;\n /** A code artifact or coding action is present, not merely a language name. */\n codeArtifact: boolean;\n};\n\n// The bundled config carries the calibrated weights; a host config that omits\n// `portfolio` scores with the same numbers rather than a second copy of them.\nconst DEFAULT_PORTFOLIO_WEIGHTS = DEFAULT_ROUTING_CONFIG.portfolio!;\n\n/**\n * Detect turns that probably need several tool calls. This is a\n * deliberately conservative request-side feature: it uses only the prompt\n * and visible tool count, never benchmark categories or expected answers.\n */\nfunction likelyNeedsParallelToolCalls(\n prompt: string,\n needsTools: boolean,\n toolCount: number | undefined,\n toolNames: readonly string[] | undefined,\n): boolean {\n if (!needsTools || toolCount === undefined || toolCount < 1) return false;\n const text = prompt.trim();\n const explicitRepeat =\n /\\b(?:in parallel|simultaneously|concurrently|for each|each of|every one|both|(?:two|three|multiple|several)\\s+(?:cities|locations|items|tasks|orders|users|files))\\b|并行|同时|分别|每个|各自|(?:两个|三个|多个)(?:城市|地点|项目|任务|订单|用户|文件)|cada uno|para cada|simult[aá]neamente/i.test(\n text,\n );\n if (explicitRepeat) return true;\n\n const sentenceClauses = text\n .split(/[.!?。!?]+/)\n .map((part) => part.trim())\n .filter((part) => part.length >= 8);\n if (\n (/\\b(?:also|additionally|furthermore)\\b|另外|此外|그리고/i.test(text) &&\n sentenceClauses.length >= 2) ||\n /\\band\\s+(?:also|for the)\\b/i.test(text)\n )\n return true;\n\n const pairedQuantity =\n /\\b\\d+(?:\\.\\d+)?\\s+(?:and|or)\\s+\\d+(?:\\.\\d+)?\\s*(?:gb|mb|tb|kg|g|ml|oz|cups?|cores?|cpus?)\\b/i.test(\n text,\n );\n if (pairedQuantity) return true;\n\n // Distinctive tokens from two visible tool names are a strong local signal\n // for a multi-operation turn (for example add_task + delete_task).\n const operationTokens = new Set([\n \"add\",\n \"delete\",\n \"remove\",\n \"cancel\",\n \"return\",\n \"exchange\",\n \"modify\",\n \"book\",\n \"transfer\",\n \"send\",\n \"upload\",\n \"download\",\n \"create\",\n \"close\",\n ]);\n // Whole words only, with an optional inflection: a substring test read\n // \"add\" out of \"address\", \"book\" out of \"facebook\" and \"close\" out of\n // \"closet\" (the same failure rules.ts fixed for its keyword lists).\n const lowered = text.toLowerCase();\n const matchedOperationTokens = new Set(\n (toolNames ?? [])\n .flatMap((name) => name.toLowerCase().split(/[^a-z0-9\\u3400-\\u9fff]+/))\n .filter(\n (token) =>\n operationTokens.has(token) &&\n new RegExp(`\\\\b${token}(?:s|es|d|ed|ing)?\\\\b`).test(lowered),\n ),\n );\n // A single workflow naturally mentions domain nouns like order/item plus\n // one action. Upgrade only when two different visible operation verbs are\n // requested (for example cancel + book or add + delete).\n if (matchedOperationTokens.size >= 2) return true;\n\n // Repeated food/logging entries are commonly expressed as several lines,\n // each with its own quantity rather than an explicit \"for each\" phrase.\n const nonEmptyLines = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter(Boolean);\n const quantityMentions =\n text.match(\n /\\b(?:\\d+(?:\\.\\d+)?|one|two|three|four|five|six|seven|eight|nine|ten)\\s*(?:oz|ounce|ounces|g|gram|grams|kg|ml|cups?|pieces?|tablespoons?)\\b/gi,\n ) ?? [];\n if (nonEmptyLines.length >= 2 && quantityMentions.length >= 2) return true;\n\n // Weather prompts provide a useful language-independent high-confidence\n // pattern: a single lookup tool plus multiple locations joined in one turn.\n const repeatedLookup =\n /\\b(?:weather|climate|clima|tiempo|temperature|snow|news|report)\\b|天气|气象|温度|降雪|新闻|报告/i.test(\n text,\n );\n const multiLocationConnector =\n /\\b(?:and also|both)\\b|\\s(?:y|e)\\s|还有|以及|和|、/i.test(text);\n const commaSeparatedLocations = (text.match(/[,,]/g) ?? []).length >= 2;\n if (repeatedLookup && (multiLocationConnector || commaSeparatedLocations)) return true;\n\n const distinctOrderParts =\n /\\b(?:food|meal)\\b[\\s\\S]*\\bdrink\\b|\\bdrink\\b[\\s\\S]*\\b(?:food|meal)\\b/i.test(text);\n const koreanParallelClauses = (text.match(/,/g) ?? []).length >= 3 && /하고|그리고/.test(text);\n return distinctOrderParts || koreanParallelClauses;\n}\n\nfunction classifyTask(\n prompt: string,\n systemPrompt: string | undefined,\n options: RouterOptions,\n): TaskFeatures {\n const fullText = `${systemPrompt ?? \"\"} ${prompt}`;\n const estimatedInputTokens = estimateTokens(fullText);\n const limit = scanLimit(options.config.classifier.promptTruncationChars);\n const scannedPrompt = sampleForScan(prompt, limit);\n const scannedSystemPrompt = sampleForScan(systemPrompt ?? \"\", limit);\n // Only the deep-web-research clue detectors below read the system prompt,\n // and they are gated on a web-research tool surface. Every other feature\n // reads the user turn: a host's standing instructions (\"be quick\", \"follow\n // security best practices\", a Mandarin persona) describe the assistant, not\n // this request, and must not move its scoring or language band.\n const scannedFullText = `${scannedSystemPrompt} ${scannedPrompt}`;\n const text = scannedPrompt.toLowerCase();\n const explicitCodeSignal =\n /```|\\b(?:typescript|javascript|python|rust|java|sql|stack trace|traceback|exception)\\b|\\.(?:ts|tsx|js|py|go|rs)\\b/i.test(\n scannedPrompt,\n );\n // `class` is common in non-code Agent domains (for example airline cabin\n // class). Treat code constructs as code only when the prompt also contains\n // an implementation/editing cue, instead of letting a single ambiguous\n // noun redirect an entire tool session to the code-agent portfolio.\n const codeConstructSignal =\n /\\b(?:implement|refactor|debug|write|edit|modify|create|define|review|fix)\\b[\\s\\S]{0,48}\\b(?:api|function|class|method)\\b|\\b(?:api|function|class|method)\\b[\\s\\S]{0,48}\\b(?:code|implementation|typescript|javascript|python|rust|java)\\b/i.test(\n scannedPrompt,\n );\n const nativeCodeSignal =\n /\\b(?:programmed|written|implemented?|code)\\s+(?:in|using)\\s+(?:c\\+\\+|c|rust|go)\\b/i.test(\n scannedPrompt,\n );\n // A CamelCase error class (TypeError, NullPointerException) is a runtime\n // artifact, not prose about errors; case-sensitive on purpose.\n const errorClassSignal = /\\b[A-Z][A-Za-z]*(?:Error|Exception)\\b/.test(scannedPrompt);\n const hasCode = explicitCodeSignal || codeConstructSignal || nativeCodeSignal || errorClassSignal;\n // A language name alone (\"java coffee prices\", \"python snake habitat\") is\n // not code work, even on a tool turn. It joins the code-agent pool only\n // together with a coding action.\n const codingAction =\n /\\b(?:write|implement|refactor|debug|fix|patch|compile|build|run|test|script|program|code|function|class|module|repo(?:sitory)?)\\b|编写|实现|重构|调试|修复|编译|脚本|代码/i.test(\n scannedPrompt,\n );\n // Stronger than hasCode: an actual code artifact or coding action, never a\n // bare language name (\"What is Python?\" is trivia, not a code task) and\n // never the English word \"exception\" on its own (\"please make an\n // exception\"); a thrown exception shows up as a CamelCase class above.\n const codeArtifact =\n /```|\\b(?:stack trace|traceback)\\b|\\.(?:ts|tsx|js|py|go|rs)\\b/i.test(scannedPrompt) ||\n codeConstructSignal ||\n nativeCodeSignal ||\n errorClassSignal;\n const toolsAvailable = options.hasTools ?? false;\n const needsTools =\n options.requiresTools ??\n (toolsAvailable && inferToolRequirement(scannedPrompt, scannedSystemPrompt));\n const likelyParallelToolCalls = likelyNeedsParallelToolCalls(\n scannedPrompt,\n needsTools,\n options.toolCount,\n options.toolNames,\n );\n const normalizedToolNames = (options.toolNames ?? []).map((name) => name.toLowerCase());\n const airlineToolSignal = normalizedToolNames.some((name) =>\n /(?:flight|reservation|airport|baggage|passenger)/.test(name),\n );\n const retailToolSignal = normalizedToolNames.some((name) =>\n /(?:order|product|item|return|exchange|address)/.test(name),\n );\n const webResearchToolSignal = normalizedToolNames.some((name) =>\n /^(?:web_?search|web_?fetch)$/.test(name),\n );\n const agentDomain =\n airlineToolSignal && !retailToolSignal\n ? \"airline\"\n : retailToolSignal && !airlineToolSignal\n ? \"retail\"\n : webResearchToolSignal\n ? \"web_research\"\n : \"other\";\n // Distinguish a cheap lookup from a BrowseComp-like investigation. These\n // prompts require joining several clues, resolving an entity, and ending in\n // one exact answer; complete agent trajectories show that treating them as\n // ordinary search causes long, costly loops. This is request/tool-surface\n // evidence only and does not depend on a benchmark id or hidden answer.\n const clueConnectors =\n scannedFullText.match(\n /\\b(?:after|before|while|where|whose|which|in \\d{4}|as of|over \\d+|another|also|furthermore)\\b|(?:之后|之前|其中|截至|超过|另一个|此外)/gi,\n ) ?? [];\n const entityResolutionSignal =\n /\\b(?:identify|who (?:is|was)|what (?:is|was) the name|which (?:person|player|company|country|city)|find the (?:person|player|name|entity))\\b|(?:找出|识别|是谁|哪位|名称是什么)/i.test(\n scannedFullText,\n );\n const exactAnswerSignal =\n /\\b(?:exact answer|single best-supported answer|following clues|multiple public sources)\\b|(?:精确答案|根据.*线索|多个公开来源)/i.test(\n scannedFullText,\n );\n const deepWebResearch =\n agentDomain === \"web_research\" &&\n (exactAnswerSignal ||\n (entityResolutionSignal && (clueConnectors.length >= 3 || prompt.length >= 320)));\n const globalOptimizationSignal =\n /\\b(?:cheapest|lowest[- ]price|least expensive|most expensive|highest(?:[- ]priced)?|largest|smallest|maximum|minimum|best available|closest|not (?:cost|exceed))\\b|最便宜|最低价|最贵|最高价|最大|最小/i.test(\n scannedPrompt,\n );\n const globalScopeSignal =\n /\\b(?:everything|all (?:(?:my|your|their|the) )?(?:future |upcoming )?(?:items|orders|passengers|flights|reservations|bookings)|every (?:item|order|passenger|flight|reservation|booking))\\b|全部|所有|每个/i.test(\n scannedPrompt,\n );\n const globalChoiceSignal = globalOptimizationSignal || globalScopeSignal;\n const crossRecordSignal =\n /\\b(?:another|other|different|previous)\\s+(?:order|reservation|booking|account|address)\\b|另一(?:个)?(?:订单|预订|账户|地址)|其他(?:订单|预订|账户|地址)/i.test(\n scannedPrompt,\n );\n // Reservation locators mix letters and digits (ZFA04Y, 4WQ150). Requiring\n // both keeps shouted words (\"CANCEL MY FLIGHT\") and plain six-digit numbers\n // from reading as two reservations.\n const reservationIds =\n scannedPrompt.match(/\\b(?=[A-Z0-9]*\\d)(?=[A-Z0-9]*[A-Z])[A-Z0-9]{6}\\b/g) ?? [];\n const crossReservationBatchSignal =\n agentDomain === \"airline\" &&\n (/\\b(?:two|three|multiple|several)(?:\\s+of\\s+(?:my|our|the))?\\s+(?:upcoming\\s+)?(?:reservations?|bookings?)\\b|\\b(?:a\\s+)?(?:second|third)\\s+(?:reservation|booking)\\b/i.test(\n scannedPrompt,\n ) ||\n new Set(reservationIds).size >= 2);\n const conditionalGlobalWorkflowSignal =\n agentDomain === \"airline\" &&\n globalScopeSignal &&\n /\\b(?:if|that (?:contain|have)|longer than|shorter than|under|over|at (?:most|least)|wherever possible)\\b|如果|超过|少于|不超过|尽可能/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:cancel|change|upgrade|move|book)\\b[\\s\\S]*\\b(?:cancel|change|upgrade|move|book)\\b|取消[\\s\\S]*(?:升级|更改)|升级[\\s\\S]*(?:取消|更改)/i.test(\n scannedPrompt,\n );\n // A refund explicitly targeted at a named/non-original card can conflict\n // with account state and require escalation rather than a substitute action.\n // This narrow feature is visible on the first turn and avoids sending every\n // ordinary return workflow to the expensive policy specialist.\n const policyExceptionSignal =\n agentDomain === \"retail\" &&\n /\\b(?:return|refund|send back|get (?:my |the )?money back)\\b|退货|退款|退回/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:amex|american express|visa|mastercard|credit card|debit card|different card|another card|other card)\\b|信用卡|借记卡|其他卡|另一张卡/i.test(\n scannedPrompt,\n );\n // A comparative selector can mention two products while requesting only\n // one write (for example \"send back the pricier one\"). Three-repeat tau2\n // calibration found no quality gain from the policy specialist on these\n // single-write cases, so keep them in a distinct, lower-cost risk band.\n const singleSelectedPolicyException =\n policyExceptionSignal &&\n /\\b(?:return|refund|send back)\\b[^.!?。!?]{0,96}\\b(?:the )?(?:pricier|cheaper|more expensive|less expensive|costlier|one)\\b/i.test(\n scannedPrompt,\n );\n // Returns and exchanges often pivot after confirmation (return -> rethink\n // -> exchange -> choose a variant). That future state is not visible to a\n // task-start router, so treat the observable workflow verb as the risk cue.\n // Simpler cancellation and one-field order edits stay on the standard path.\n const negotiatedWorkflowSignal =\n agentDomain === \"retail\" && /\\b(?:return|exchange)\\b|退货|退回|换货|交换/i.test(scannedPrompt);\n const numberedSteps = (scannedPrompt.match(/(?:^|\\s)\\d+(?:\\.\\d+)*[.)]\\s+/g) ?? []).length;\n const complexMultiToolPlan =\n likelyParallelToolCalls &&\n ((options.toolCount ?? 0) >= 6 || numberedSteps >= 3 || prompt.length > 1_200);\n let agentRisk: TaskFeatures[\"agentRisk\"] =\n needsTools && singleSelectedPolicyException\n ? \"policy_exception_simple\"\n : needsTools && policyExceptionSignal\n ? \"policy_exception\"\n : // Airline prompts that require a global optimum (for example the\n // cheapest itinerary across several candidates) are materially harder\n // than applying one change to every passenger in a known reservation.\n // Full-session evidence supports Sonnet for the former, while upgrading\n // the latter merely because it says \"all passengers\" caused a large cost\n // increase without a quality gain.\n needsTools &&\n agentDomain === \"airline\" &&\n (globalOptimizationSignal || conditionalGlobalWorkflowSignal)\n ? \"complex_high\"\n : needsTools &&\n (likelyParallelToolCalls ||\n globalChoiceSignal ||\n crossRecordSignal ||\n crossReservationBatchSignal ||\n negotiatedWorkflowSignal)\n ? \"high\"\n : \"standard\";\n const needsVision = options.hasVision ?? false;\n const needsStructuredOutput = options.requiresStructuredOutput ?? false;\n const latencySensitive =\n /\\b(?:urgent|asap|fast|quick|low latency|real[- ]time)\\b|尽快|马上|快速|低延迟/i.test(\n scannedPrompt,\n );\n const highStakes =\n /\\b(?:production|security|payment|legal|medical|financial|audit)\\b|生产|安全|支付|法律|医疗|财务|审计/i.test(\n scannedPrompt,\n );\n // Terminal tasks often describe the desired artifact rather than naming a\n // programming language. Treat only small, deterministic local build/file\n // work as implicit code. Operational deployment, credentials, destructive\n // work, evaluation, vision, and broad search stay on the stronger generic\n // tool-agent path. This is a request-side feature, not a benchmark ID list.\n const terminalToolSignal = normalizedToolNames.some((name) =>\n /^(?:terminalexec|terminalinspect|terminalsendkeys)$/.test(name),\n );\n const simpleTerminalArtifact =\n /\\b(?:create|write|convert|generate|build|implement|run|fix|repair|debug|make)\\b[\\s\\S]{0,120}\\b(?:file|script|csv|parquet|json|txt|server|endpoint)\\b/i.test(\n scannedPrompt,\n );\n // Multi-file repair is qualitatively different from fixing one known local\n // script. The agent must preserve state across inspections, infer ordering\n // and dependencies, edit several artifacts, and close the loop with tests.\n // A frozen Terminal-Bench trajectory showed the economy model spending 27\n // turns repeatedly rereading files without making an edit, while Opus solved\n // the same task in eight turns. Promote this request-visible pattern before\n // model scoring; no benchmark ID or expected answer is consulted.\n const terminalComplexRepair =\n terminalToolSignal &&\n /\\b(?:multiple|several)\\s+(?:scripts?|files?|components?)\\b|\\b(?:pipeline|dependencies)\\b[\\s\\S]{0,100}\\b(?:fail|issue|fix|repair|run|execute)\\b|\\b(?:identify|find|fix|repair)\\s+(?:and\\s+)?(?:fix\\s+)?all\\s+(?:the\\s+)?issues\\b/i.test(\n scannedPrompt,\n );\n // One artifact that must be accepted by multiple compilers/runtimes is not\n // a routine file-writing task. It requires reasoning across incompatible\n // grammars and validating every execution path; cheap code models can\n // produce plausible-looking source that satisfies neither toolchain.\n const mentionedTerminalRuntimes = new Set(\n (scannedPrompt.match(/\\b(?:gcc|clang|rustc|javac|go\\s+build|node|python)\\b/gi) ?? []).map(\n (name) => name.toLowerCase().replace(/\\s+/g, \" \"),\n ),\n );\n const terminalCrossRuntimeArtifact =\n terminalToolSignal &&\n (/\\bpolyglot\\b/i.test(scannedPrompt) ||\n /\\b(?:both|each)\\b[\\s\\S]{0,120}\\b(?:compilers?|runtimes?|toolchains?)\\b/i.test(\n scannedPrompt,\n ) ||\n (mentionedTerminalRuntimes.size >= 2 &&\n /\\b(?:compile|build|run|execute)\\b/i.test(scannedPrompt)));\n // Framework-to-native ports combine binary checkpoint inspection, weight\n // export, tensor-layout reasoning, image/data decoding, and a separately\n // compiled runtime. A task-start router can see this boundary directly in\n // the request (for example PyTorch state_dict -> a pure C CLI); treating it\n // like routine single-file C work caused a 30-turn read/retry loop in a\n // frozen official Terminal-Bench trajectory.\n const terminalFrameworkToNativeArtifact =\n terminalToolSignal &&\n /\\b(?:pytorch|tensorflow|jax|onnx|state[_ -]?dict|checkpoint|safetensors?)\\b|\\.(?:pth|pt|onnx)\\b/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:pure|native|programmed|written|implemented?)\\s+(?:in|using)\\s+(?:c\\+\\+|c|rust|go)\\b|\\b(?:c\\+\\+|c|rust|go)\\s+(?:program|binary|executable|cli|tool|implementation)\\b/i.test(\n scannedPrompt,\n ) &&\n /\\b(?:inference|model|weights?|tensor|export|convert|load)\\b/i.test(scannedPrompt);\n if (\n needsTools &&\n (terminalComplexRepair || terminalCrossRuntimeArtifact || terminalFrameworkToNativeArtifact) &&\n (agentRisk === \"standard\" || agentRisk === \"high\")\n )\n agentRisk = \"complex_high\";\n const complexTerminalOperation =\n /\\b(?:git|ssh|nginx|https|certificate|authentication|credential|deploy|production|encrypt|gpg|shred|securely delete|decommission|benchmark|evaluate|embedding|chess|image|search the web|schema|statistical|statistics|aggregate|join|multiple inputs?)\\b/i.test(\n scannedPrompt,\n );\n // A bare \"token\" is not a credential signal: blockchain, tokenizer, and\n // LLM tasks use that word routinely (for example \"token transfers\"). Only\n // treat it as sensitive when the prompt gives it an authentication/secret\n // qualifier. API keys remain an unambiguous high-risk signal on their own.\n const terminalCredentialSignal =\n /\\b(?:ssh|nginx|certificate|authentication|credentials?|passwords?|api keys?|deploy|production|encrypt|gpg|shred|securely delete|decommission)\\b/i.test(\n scannedPrompt,\n ) ||\n /\\b(?:access|auth|authentication|bearer|secret|api)\\s+tokens?\\b|\\btokens?\\s+(?:secret|credential|authentication)\\b/i.test(\n scannedPrompt,\n );\n const terminalSafetySensitive = terminalToolSignal && (highStakes || terminalCredentialSignal);\n const implicitTerminalCode =\n needsTools &&\n terminalToolSignal &&\n agentRisk === \"standard\" &&\n !highStakes &&\n !complexTerminalOperation &&\n numberedSteps < 3 &&\n prompt.length <= 1_000 &&\n simpleTerminalArtifact;\n // Han characters alone also spell Japanese; kana marks the prompt as not\n // Mandarin, so it does not get the Mandarin-native extraction band.\n const language =\n /[\\u3400-\\u9fff]/.test(scannedPrompt) && !/[\\u3040-\\u30ff]/.test(scannedPrompt)\n ? \"zh\"\n : \"other\";\n const multipleChoiceSignals = (scannedPrompt.match(/(?:^|\\n)\\s*[A-D][.)]\\s+/gim) ?? []).length;\n const numericSignals = (scannedPrompt.match(/-?\\d+(?:[.,]\\d+)?/g) ?? []).length;\n const compactMathProblem =\n !hasCode &&\n prompt.length < 2_500 &&\n numericSignals >= 2 &&\n (/[+×÷=%$€£¥]|\\b(?:total|each|per|times|half|twice|percent|how many|how much|calculate)\\b/i.test(\n scannedPrompt,\n ) ||\n /[??]\\s*$/.test(scannedPrompt.trim()) ||\n numericSignals >= 3);\n\n let taskType: TaskType = \"chat\";\n if (needsVision) taskType = \"vision\";\n else if (estimatedInputTokens > 80_000) taskType = \"long_context\";\n else if (needsTools && (codeArtifact || (hasCode && codingAction) || implicitTerminalCode))\n taskType = \"code_agent\";\n else if (needsTools && likelyParallelToolCalls && !complexMultiToolPlan)\n taskType = \"tool_agent_parallel\";\n else if (needsTools) taskType = \"tool_agent\";\n else if (multipleChoiceSignals >= 3) taskType = \"reasoning_mcq\";\n else if (compactMathProblem) taskType = \"reasoning_math\";\n else if (\n errorClassSignal ||\n /\\b(?:bug|debug|error|failure|failing|regression|crash)\\b|修复|报错|错误|调试/i.test(text)\n )\n taskType = \"debug\";\n else if (hasCode || /\\b(?:refactor|implement|patch|edit|rewrite)\\b|重构|实现|修改/i.test(text))\n taskType = \"code_edit\";\n else if (needsStructuredOutput || /\\b(?:extract|json|schema|csv)\\b|字段|提取/i.test(text))\n taskType = \"extraction\";\n else if (\n /\\b(?:prove|derive|theorem|formal|mathematical|reasoning)\\b|证明|推导|定理|数学/i.test(text)\n )\n taskType = \"reasoning\";\n\n return {\n taskType,\n estimatedInputTokens,\n hasCode,\n needsTools,\n toolsAvailable,\n needsVision,\n needsStructuredOutput,\n latencySensitive,\n highStakes,\n language,\n likelyParallelToolCalls,\n complexMultiToolPlan,\n agentDomain,\n deepWebResearch,\n agentRisk,\n terminalToolSignal,\n terminalSafetySensitive,\n implicitTerminalCode,\n codeArtifact,\n };\n}\n\n/**\n * Task-affinity bands. Each table maps a model name (the id after the\n * provider slash) to its calibrated affinity for one request shape; anything\n * absent scores the neutral `NEUTRAL_AFFINITY`. Names are matched exactly:\n * model family names are intentionally similar (`gemini-2.5-flash` vs\n * `gemini-2.5-flash-lite`), and a substring match would let a smaller sibling\n * inherit a capability claim measured only for the flagship. A sibling joins a\n * band only with its own evidence.\n */\ntype AffinityBand = Readonly>;\n\n// Every \"gemini-3.6-flash\" value below is CARRIED from Gemini 3.5 Flash, not\n// measured on 3.6. The calibrations that set them (RouterBench GPQA/MGSM and\n// BFCL 2026-07-26/28, the Terminal-Bench and tau2 trajectories of 2026-07-28)\n// ran on 3.5. Google has answered the 3.5 name with 3.6 Flash since\n// ~2026-10-10, and on 2026-11-24 the gateways began redirecting 3.5 to 3.6, so\n// the router has in practice been routing 3.6 on these values since October;\n// the key now names the model that answers. The comments that cite \"Gemini\n// 3.5 Flash\" results describe those runs. Re-measure before treating any of\n// these as 3.6 evidence.\n//\n// Likewise every \"gemini-3.5-flash-lite\" value (extractionZh, extraction,\n// chat) is CARRIED from Gemini 2.5 Flash, which Google retired on 2026-12-01\n// and the gateways redirect to 3.5 Flash-Lite. It is a successor, not a\n// sibling claiming a flagship's evidence (see the rule above), but the values\n// were measured on 2.5 and still need a 3.5 Flash-Lite run.\n//\n// Likewise every \"gpt-5.6-luna\" value (and its place in the evidence pools and\n// the web-research order) is CARRIED from GPT-5 Mini, which OpenAI shuts down\n// on 2026-12-11 and the gateways redirect to GPT-5.6 Luna. The Terminal-Bench\n// and tau2 trajectories (2026-07-28) and the BrowseComp sessions behind them\n// ran on gpt-5-mini, a reasoning model; luna runs without reasoning, so these\n// are a placeholder, not luna evidence. Re-measure luna on those suites — or\n// move the bands to a measured model — before relying on them.\n\n/** Affinity of a model with no task-specific evidence. */\nconst NEUTRAL_AFFINITY = 0.68;\n\n// Strong native tool loop until the Responses function-output fix is deployed\n// on both gateways; Codex stays available below auto's affinity floor. Sonnet\n// has a verified native multi-turn tool loop and is the safe strong default.\nconst TERMINAL_COMPLEX_HIGH: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.3-codex\": 0.87,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n};\n\n// Complete-session BrowseComp calibration supersedes the earlier single-case\n// Opus promotion: strict deduplicated evidence has Sonnet 5 at 2/9 versus Opus\n// 5 at 0/3, while Opus also costs more and has a much longer tail. Opus stays\n// an availability fallback until a larger stable-provider sample supports it.\nconst WEB_RESEARCH_DEEP: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.88,\n \"gemini-3.6-flash\": 0.84,\n \"claude-opus-5\": 0.8,\n \"claude-opus-4.8\": 0.78,\n};\nconst WEB_RESEARCH: AffinityBand = {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.88,\n \"gemini-3.6-flash\": 0.86,\n \"claude-opus-5\": 0.84,\n \"claude-opus-4.8\": 0.82,\n};\n\nconst RETAIL_POLICY_EXCEPTION: AffinityBand = {\n \"gpt-4.1\": 1,\n \"claude-sonnet-5\": 0.9,\n \"deepseek-v4-pro\": 0.82,\n \"gpt-5.6-luna\": 0.8,\n \"gpt-4o-mini\": 0.76,\n};\nconst RETAIL_POLICY_EXCEPTION_SIMPLE: AffinityBand = {\n \"gpt-5.6-luna\": 1,\n \"gpt-4.1\": 0.86,\n \"deepseek-v4-pro\": 0.82,\n \"gpt-4o-mini\": 0.8,\n};\n\nconst AFFINITY = {\n // Seven valid full agent + official Terminal-Bench trajectories (2026-07-28)\n // gave GPT-5 Mini 4/7 resolved tasks versus 1/7 for the prior dynamic\n // code-agent choice. Its token-normalized total cost was higher in this small\n // calibration, so Codex and Sonnet keep quality priors above it; admitting\n // Mini to the scoring band lets the normal quality/cost profile choose it\n // without erasing stronger fallbacks. DeepSeek V4 Pro is kept below the\n // primary band after two consecutive mid-trajectory provider timeouts\n // contaminated its calibration runs.\n codeAgent: {\n \"gpt-5.3-codex\": 1,\n \"claude-sonnet-5\": 0.98,\n \"gpt-5.6-luna\": 0.96,\n \"gemini-3.6-flash\": 0.92,\n \"kimi-k3.1-pro\": 0.9,\n \"deepseek-v4-pro\": 0.88,\n \"glm-5.2\": 0.88,\n },\n // Seven official Terminal-Bench calibration trajectories favoured GPT-5 Mini\n // over the prior dynamic choice. Codex/Sonnet are close fallbacks; actual\n // request cost breaks the tie.\n terminalTool: {\n \"gpt-5.6-luna\": 1,\n \"gpt-5.3-codex\": 0.98,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.89,\n },\n // Two complete agent observations on the public Terminal-Bench\n // new-encrypt-command task ended in Codex repeating the same TerminalExec\n // input until the loop guard fired. Codex stays an availability fallback,\n // below the safety-band affinity floor, until its Responses function-output\n // path is verified on both gateways.\n terminalToolSafety: {\n \"claude-sonnet-5\": 1,\n \"claude-opus-4.8\": 0.9,\n \"gpt-5.3-codex\": 0.84,\n },\n // Full-session calibration: GPT-5 Mini completed two local/single retail\n // workflows at a fraction of Sonnet's token cost. It stays ineligible for\n // promotion when the prompt asks for multiple actions, cross-record\n // discovery or a global optimum; those trajectories exposed unstable write\n // arguments. DeepSeek V4 Pro completed all three high-risk retail calibration\n // trajectories (global-choice, cross-record, multi-write); Sonnet one.\n retailStandard: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.88,\n \"gemini-3.6-flash\": 0.82,\n \"gpt-5.3-codex\": 0.81,\n \"kimi-k3.1-pro\": 0.78,\n \"deepseek-v4-pro\": 0.76,\n },\n retailHigh: {\n \"deepseek-v4-pro\": 1,\n \"claude-sonnet-5\": 0.88,\n \"gemini-3.6-flash\": 0.82,\n \"gpt-5.3-codex\": 0.81,\n \"kimi-k3.1-pro\": 0.78,\n \"gpt-5.6-luna\": 0.76,\n },\n // Standard airline workflows stay on GPT-5 Mini: six full-session\n // development trajectories gave it the same 5/6 success as Sonnet at roughly\n // one order of magnitude lower normalized token cost. A held-out high-risk\n // cabin/date negotiation then produced a persistent empty assistant turn on\n // Mini even after a semantic retry, while Sonnet 5 completed the identical\n // official tau2 trajectory with reward 1.0. Only global optimization /\n // conditional-global work is promoted. A known batch of reservations is\n // operationally high-risk but still a structured tool workflow: current Tau\n // evidence has Mini and Sonnet at equal task reward there, while Sonnet costs\n // roughly two orders of magnitude more on the long-tail case.\n airlineComplex: {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n \"deepseek-v4-pro\": 0.74,\n },\n airlineStandard: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.8,\n \"deepseek-v4-pro\": 0.76,\n },\n // Full-trajectory tau2 calibration (2026-07-28, official gpt-4.1 simulator):\n // Sonnet 5 completed both an airline policy task and a retail multi-write\n // task with reward 1.0. Gemini 3.5 Flash emitted function calls as plain text\n // after the first structured calls and looped to the 100-step ceiling on the\n // airline task.\n toolAgent: {\n \"claude-sonnet-5\": 1,\n \"gemini-3.6-flash\": 0.88,\n \"gpt-5.3-codex\": 0.87,\n \"kimi-k3.1-pro\": 0.85,\n \"gpt-5.6-luna\": 0.84,\n \"deepseek-v4-pro\": 0.82,\n },\n // Multi-file Terminal work is not equivalent to a one-turn parallel\n // function-call benchmark. Sonnet is the strongest trajectory-tested\n // cost-controlled default; Opus remains a close safety fallback.\n parallelTerminalSafety: {\n \"claude-sonnet-5\": 1,\n \"claude-opus-4.8\": 0.9,\n \"gpt-5.3-codex\": 0.86,\n },\n parallelTerminal: {\n \"gpt-5.6-luna\": 1,\n \"gpt-5.3-codex\": 0.98,\n \"claude-sonnet-5\": 0.92,\n \"gemini-3.6-flash\": 0.88,\n },\n parallelRetail: {\n \"deepseek-v4-pro\": 1,\n \"claude-sonnet-5\": 0.88,\n \"claude-opus-4.8\": 0.84,\n \"gpt-5.6-luna\": 0.78,\n \"gemini-3.6-flash\": 0.76,\n },\n parallelAirlineComplex: {\n \"claude-sonnet-5\": 1,\n \"gpt-5.6-luna\": 0.78,\n \"claude-opus-4.8\": 0.76,\n \"gemini-3.6-flash\": 0.74,\n },\n parallelAirline: {\n \"gpt-5.6-luna\": 1,\n \"claude-sonnet-5\": 0.9,\n \"gemini-3.6-flash\": 0.8,\n },\n // RouterBench calibration, 2026-07-26: Opus 4.8 produced complete multi-call\n // payloads on 2/3 multilingual BFCL parallel cases. Gemini 3.5 Flash, Sonnet\n // 5, DeepSeek V4 Pro and Grok 4.5 were 0/3. This narrow prior only applies\n // after the conservative prompt feature in likelyNeedsParallelToolCalls.\n parallel: {\n \"claude-opus-4.8\": 1,\n \"claude-sonnet-5\": 0.84,\n \"grok-4.5\": 0.82,\n \"gemini-3.6-flash\": 0.8,\n \"deepseek-v4-pro\": 0.78,\n },\n codeEdit: {\n \"gpt-5.3-codex\": 1,\n \"claude-sonnet-4.6\": 0.94,\n \"glm-5.2\": 0.9,\n \"deepseek-v4-pro\": 0.86,\n },\n reasoning: {\n \"claude-sonnet-5\": 0.98,\n \"claude-sonnet-4.6\": 0.98,\n \"deepseek-v4-pro\": 0.95,\n \"grok-4.5\": 0.94,\n \"gemini-3.1-pro\": 0.92,\n \"gemini-3.6-flash\": 0.92,\n },\n // RouterBench calibration (2026-07-28, six stratified GPQA Diamond tasks,\n // identical agent adapter and 512-token budget): Gemini 3 Flash Preview\n // scored 5/6, Gemini 3.5 Flash 4/6, and Gemini 3.1 Pro 3/6 while costing\n // ~170x more than Flash. The measured winner is the narrow default; version\n // recency alone is not a quality signal. Unused host tools must not change\n // this reasoning-only model choice.\n reasoningMcq: {\n \"gemini-3-flash-preview\": 1,\n \"gemini-3.6-flash\": 0.91,\n \"grok-4.5\": 0.9,\n \"claude-sonnet-5\": 0.88,\n \"deepseek-v4-pro\": 0.84,\n },\n // Same calibration, five multilingual MGSM tasks: Gemini 3.5 Flash was 5/5\n // with the lowest cost and latency; four current flagships were 4/5 and Kimi\n // K2.7 was 3/5.\n //\n // Kimi K3.1 Pro, paired against Kimi K3 (2026-11-23): all 50 rows of the\n // pinned RouterBench MGSM slice (5 per language x 10 languages), the text\n // adapter's `Answer: ` contract and deterministic grader, 512 output\n // tokens, temperature 0, same rows and settings for both. K3 44/50, K3.1 Pro\n // 41/50; discordant pairs 5 K3-only vs 2 K3.1-only (not significant). Every\n // K3-only win was K3.1 Pro hitting the 512-token cap; the non-truncated\n // errors were the same two rows for both. Rerunning the 10 truncated rows at\n // 2048 tokens gave 8/10 each (46/50 each overall), so the gap is verbosity at\n // the calibration budget, not arithmetic. K3.1 Pro was also slower (p95\n // 10.4s vs 4.7s). It moves from K3's carried 0.9 to 0.88: below the models\n // the 4/5 calibration put at 0.9, by less than the raw 41/44 ratio because\n // the difference is within noise.\n reasoningMath: {\n \"gemini-3.6-flash\": 1,\n \"grok-4.5\": 0.93,\n \"claude-sonnet-5\": 0.9,\n \"deepseek-v4-pro\": 0.9,\n \"kimi-k3.1-pro\": 0.88,\n },\n vision: {\n \"gemini-3.1-pro\": 0.96,\n \"qwen3.7-max\": 0.9,\n \"claude-sonnet-4.6\": 0.9,\n \"kimi-k3.1-pro\": 0.9,\n \"grok-4.3\": 0.9,\n },\n // Long-context eligibility is necessary but not sufficient: a provider can\n // advertise a 1M window yet return an empty completion near that boundary.\n // The proven long-context flagship leads, and less-established alternatives\n // sit in a separate band so price alone cannot displace it.\n longContext: {\n \"gemini-3.1-pro\": 1,\n \"qwen3.7-max\": 0.89,\n \"glm-5.2\": 0.89,\n \"gemini-3.6-flash\": 0.88,\n \"deepseek-v4-pro\": 0.85,\n },\n // A structured extraction must preserve both the output contract and the\n // source-language fields. For Mandarin input the language-native Kimi\n // candidate gets a distinct band — a candidate-pool decision, not a post-hoc\n // override, so it still falls back normally when Kimi is unavailable. The\n // Kimi flagship costs several times the cheap extraction models, so the band\n // must be wider than the auto affinityFloorGap (0.10) or price alone\n // re-selects a non-native model for Mandarin input; 0.12 keeps Kimi alone in\n // the primary band for zh and leaves every other language untouched.\n //\n // Only one \"kimi-k3.1-pro\" value in AFFINITY is measured on K3.1 Pro:\n // reasoningMath (paired K3 vs K3.1 Pro on 50 MGSM rows, 2026-11-23; see that\n // band). Every other value (codeAgent, retailStandard, retailHigh,\n // toolAgent, vision, extractionZh, extraction, chat) is still carried over\n // from the Kimi flagship it replaced (K3, whose values were in turn carried\n // from K2.7). Those bands' calibrations could not be rerun locally: the\n // Terminal-Bench and tau2 trajectories need the RouterBench Franklin host\n // (and Docker for Terminal-Bench), and no extraction or vision slice has a\n // runner. K3.1 Pro's other evidence is the 2026-11-23 live probe: 3/3\n // completions, 0 errors, a well-formed tool call.\n extractionZh: {\n \"kimi-k3.1-pro\": 1,\n \"gemini-3.6-flash\": 0.88,\n \"gemini-3.5-flash-lite\": 0.88,\n \"gpt-4o-mini\": 0.88,\n \"claude-sonnet-5\": 0.88,\n \"claude-sonnet-4.6\": 0.88,\n },\n extraction: {\n \"kimi-k3.1-pro\": 0.9,\n \"gemini-3.6-flash\": 0.9,\n \"gemini-3.5-flash-lite\": 0.9,\n \"gpt-4o-mini\": 0.9,\n \"claude-sonnet-5\": 0.9,\n \"claude-sonnet-4.6\": 0.9,\n },\n chat: {\n \"gemini-3.6-flash\": 0.86,\n \"gemini-3.5-flash-lite\": 0.86,\n \"kimi-k3.1-pro\": 0.86,\n },\n} as const satisfies Record;\n\n/** The affinity band that applies to a classified request. */\nfunction affinityBand(features: TaskFeatures): AffinityBand {\n const { taskType, agentDomain, agentRisk, deepWebResearch, terminalToolSignal } = features;\n const terminalSafety = features.terminalSafetySensitive;\n switch (taskType) {\n case \"code_agent\":\n return terminalToolSignal && agentRisk === \"complex_high\"\n ? TERMINAL_COMPLEX_HIGH\n : AFFINITY.codeAgent;\n case \"tool_agent\":\n if (terminalToolSignal && agentRisk === \"complex_high\") return TERMINAL_COMPLEX_HIGH;\n if (terminalToolSignal) return terminalSafety ? AFFINITY.terminalToolSafety : AFFINITY.terminalTool;\n if (agentDomain === \"web_research\") return deepWebResearch ? WEB_RESEARCH_DEEP : WEB_RESEARCH;\n if (agentDomain === \"retail\") {\n if (agentRisk === \"standard\") return AFFINITY.retailStandard;\n if (agentRisk === \"policy_exception\") return RETAIL_POLICY_EXCEPTION;\n if (agentRisk === \"policy_exception_simple\") return RETAIL_POLICY_EXCEPTION_SIMPLE;\n return AFFINITY.retailHigh;\n }\n if (agentDomain === \"airline\") {\n return agentRisk === \"complex_high\" ? AFFINITY.airlineComplex : AFFINITY.airlineStandard;\n }\n return AFFINITY.toolAgent;\n case \"tool_agent_parallel\":\n if (terminalToolSignal) {\n return terminalSafety ? AFFINITY.parallelTerminalSafety : AFFINITY.parallelTerminal;\n }\n if (agentDomain === \"web_research\") return deepWebResearch ? WEB_RESEARCH_DEEP : WEB_RESEARCH;\n if (agentDomain === \"retail\") {\n if (agentRisk === \"policy_exception\") return RETAIL_POLICY_EXCEPTION;\n if (agentRisk === \"policy_exception_simple\") return RETAIL_POLICY_EXCEPTION_SIMPLE;\n return AFFINITY.parallelRetail;\n }\n if (agentDomain === \"airline\") {\n return agentRisk === \"complex_high\" ? AFFINITY.parallelAirlineComplex : AFFINITY.parallelAirline;\n }\n return AFFINITY.parallel;\n case \"code_edit\":\n case \"debug\":\n return AFFINITY.codeEdit;\n case \"reasoning\":\n return AFFINITY.reasoning;\n case \"reasoning_mcq\":\n return AFFINITY.reasoningMcq;\n case \"reasoning_math\":\n return AFFINITY.reasoningMath;\n case \"vision\":\n return AFFINITY.vision;\n case \"long_context\":\n return AFFINITY.longContext;\n case \"extraction\":\n return features.language === \"zh\" ? AFFINITY.extractionZh : AFFINITY.extraction;\n case \"chat\":\n return AFFINITY.chat;\n }\n}\n\n/** A model's affinity within a band: its calibrated score, never below neutral. */\nfunction affinityIn(band: AffinityBand, modelId: string): number {\n const name = modelId.toLowerCase().slice(modelId.indexOf(\"/\") + 1);\n return Math.max(NEUTRAL_AFFINITY, band[name] ?? 0);\n}\n\nfunction evidenceCandidates(task: TaskType): string[] {\n if (task === \"code_agent\") {\n return [\n \"openai/gpt-5.3-codex\",\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"google/gemini-3.6-flash\",\n \"moonshot/kimi-k3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"tool_agent\") {\n return [\n \"anthropic/claude-sonnet-5\",\n \"anthropic/claude-opus-5\",\n \"openai/gpt-5.6-luna\",\n \"openai/gpt-4.1\",\n \"openai/gpt-4o-mini\",\n \"google/gemini-3.6-flash\",\n \"openai/gpt-5.3-codex\",\n \"moonshot/kimi-k3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"tool_agent_parallel\") {\n return [\n \"anthropic/claude-opus-5\",\n \"anthropic/claude-opus-4.8\",\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"openai/gpt-4.1\",\n \"openai/gpt-4o-mini\",\n \"xai/grok-4.5\",\n \"google/gemini-3.6-flash\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"long_context\") {\n return [\n \"google/gemini-3.1-pro\",\n \"deepseek/deepseek-v4-pro\",\n \"qwen/qwen3.7-max\",\n \"zai/glm-5.2\",\n \"google/gemini-3.6-flash\",\n ];\n }\n if (task === \"reasoning_mcq\") {\n return [\n \"google/gemini-3-flash-preview\",\n \"google/gemini-3.6-flash\",\n \"xai/grok-4.5\",\n \"anthropic/claude-sonnet-5\",\n \"deepseek/deepseek-v4-pro\",\n ];\n }\n if (task === \"extraction\") {\n // The Kimi flagship is not on the auto MEDIUM chain (K2.7 was); the\n // language-native extraction band (AFFINITY.extractionZh) needs it in the pool.\n return [\"moonshot/kimi-k3.1-pro\", \"google/gemini-3.6-flash\", \"anthropic/claude-sonnet-5\"];\n }\n if (task === \"reasoning_math\") {\n return [\n \"google/gemini-3.6-flash\",\n \"xai/grok-4.5\",\n \"anthropic/claude-sonnet-5\",\n \"deepseek/deepseek-v4-pro\",\n \"moonshot/kimi-k3.1-pro\",\n ];\n }\n return [];\n}\n\n/**\n * Recently added catalog models with a verified structured function call.\n *\n * Tool compliance is enough to make these models safe availability fallbacks,\n * but it is not evidence that they should displace a trajectory-benchmarked\n * primary. Keep them after the configured and benchmark-backed chains until a\n * full agent evaluation earns a task-specific affinity above NEUTRAL_AFFINITY\n * floor. `isEligible` still applies every host capability override, context\n * limit, vision constraint, and unavailable-model guard before they are used.\n */\nconst VERIFIED_TOOL_FALLBACKS = [\n \"anthropic/claude-fable-5.1\",\n \"anthropic/claude-opus-5.5\",\n \"anthropic/claude-sonnet-5.5\",\n \"deepseek/deepseek-v4.1-flash\",\n \"google/gemini-3.8-flash\",\n \"google/gemini-4-carbon\",\n \"openai/gpt-5.1\",\n \"openai/gpt-6-astra\",\n \"openai/gpt-6-luna\",\n \"openai/gpt-6-sol\",\n \"openai/gpt-6.1-sol\",\n \"xai/grok-4.6\",\n \"xai/grok-4.7\",\n \"xiaomi/mimo-v2.5\",\n] as const;\n\nfunction isEligible(\n modelId: string,\n features: TaskFeatures,\n maxOutputTokens: number,\n options: RouterOptions,\n): boolean {\n const model = options.modelCapabilities?.[modelId] ?? DEFAULT_MODEL_CAPABILITIES[modelId];\n // Preserve compatibility for temporarily catalog-less fallback IDs. They are\n // kept behind known-model candidates but are not silently dropped.\n if (!model) return true;\n if (features.needsTools && !model.supportsTools) return false;\n if (features.needsVision && !model.supportsVision) return false;\n if (features.needsStructuredOutput && !model.supportsTools) return false;\n if (model.maxOutputTokens < maxOutputTokens) return false;\n return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;\n}\n\nfunction estimatedCost(\n modelId: string,\n options: RouterOptions,\n inputTokens: number,\n outputTokens: number,\n): number {\n const price = usablePricing(options.modelPricing.get(modelId));\n if (!price) return Number.POSITIVE_INFINITY;\n if (price.flatPrice !== undefined) return price.flatPrice;\n return (inputTokens * price.inputPrice + outputTokens * price.outputPrice) / 1_000_000;\n}\n\nfunction profileScore(\n modelId: string,\n options: RouterOptions,\n now: Date,\n):\n | { quality?: number; speed: number; tailSpeed: number; reliability: number; freshness: number }\n | undefined {\n const profile: ModelPerformanceProfile | undefined =\n options.modelPerformance?.[modelId] ??\n LIVE_MODEL_PROFILES[modelId] ??\n HISTORICAL_MODEL_PROFILES[modelId];\n if (!profile) return undefined;\n const measuredAt = Date.parse(profile.measuredAt);\n if (!Number.isFinite(measuredAt)) return undefined;\n // A host-injected observation with a missing or non-numeric field would\n // turn the whole score into NaN, and NaN compares as \"equal\" in the sort,\n // freezing that candidate wherever it landed. Treat it as no observation.\n const finite = (value: number | undefined, optional: boolean) =>\n value === undefined ? optional : Number.isFinite(value) && value >= 0;\n if (\n !finite(profile.latencyMs, false) ||\n !finite(profile.outputTokensPerSecond, false) ||\n !finite(profile.p95LatencyMs, true) ||\n !finite(profile.intelligenceIndex, true) ||\n !finite(profile.errorRate, true) ||\n !finite(profile.samples, true)\n ) {\n return undefined;\n }\n const ageDays = Math.max(0, (now.getTime() - measuredAt) / 86_400_000);\n // A 30-day half-life makes old data a tie-breaker only. Small probe runs are\n // also weak evidence: three quick samples should not overturn a curated\n // tier ordering merely because of a transient provider tail. Callers that\n // inject an observation without a sample count retain the legacy full\n // confidence behaviour for compatibility.\n const sampleConfidence =\n profile.samples === undefined ? 1 : Math.min(1, Math.max(0, profile.samples) / 10);\n const freshness = Math.pow(0.5, ageDays / 30) * sampleConfidence;\n const quality =\n profile.intelligenceIndex === undefined\n ? undefined\n : Math.min(1, profile.intelligenceIndex / 50);\n const speed = Math.min(\n 1,\n (2_000 / Math.max(500, profile.latencyMs) + profile.outputTokensPerSecond / 250) / 2,\n );\n const tailSpeed = Math.min(1, 3_000 / Math.max(750, profile.p95LatencyMs ?? profile.latencyMs));\n const reliability = Math.max(0, 1 - (profile.errorRate ?? 0));\n return { quality, speed, tailSpeed, reliability, freshness };\n}\n\n/** Candidate router used for Auto. Rules still set the capability tier; V3 ranks within it. */\nexport class PortfolioStrategy implements RouterStrategy {\n readonly name = \"portfolio\";\n // Rules set the capability tier; the strategy is stateless, so one instance serves every request.\n private readonly rules = new RulesStrategy();\n\n route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n ) {\n const features = classifyTask(prompt, systemPrompt, options);\n const base = this.rules.route(prompt, systemPrompt, maxOutputTokens, {\n ...options,\n requiresTools: features.needsTools,\n });\n const tierConfigs = base.tierConfigs;\n if (!tierConfigs) return base;\n // The rules score sets the capability tier, but two task types carry a\n // floor of their own: a compact reasoning problem belongs on the\n // reasoning chain however short it is, and a code edit or stack trace\n // belongs at least on the MEDIUM chain — the SIMPLE chain is curated for\n // trivia and translation and has no model with code affinity. The code\n // floor requires a code artifact or coding action: `debug` and `code_edit`\n // are also assigned from bare verbs (\"rewrite this sentence\", \"margin of\n // error\") and bare language names (\"What is Python?\"), and that prose\n // must stay on the cheap chain.\n const targetTier: Tier =\n (features.taskType === \"reasoning_mcq\" || features.taskType === \"reasoning_math\") &&\n (base.tier === \"SIMPLE\" || base.tier === \"MEDIUM\")\n ? \"REASONING\"\n : (features.taskType === \"debug\" || features.taskType === \"code_edit\") &&\n features.codeArtifact &&\n base.tier === \"SIMPLE\"\n ? \"MEDIUM\"\n : base.tier;\n const tierConfig = tierConfigs[targetTier];\n const configuredCandidates = tierConfig ? getFallbackChain(targetTier, tierConfigs) : [];\n // Evidence candidates join the configured chain, but the host's\n // unavailable set applies to both: the configured side arrives filtered\n // through RulesStrategy, and a dead evidence model must not re-enter here.\n const unavailable = new Set(options.unavailableModels ?? []);\n // `modelPricing` is the host's live catalog view. Do not introduce a\n // built-in fallback that the current gateway does not advertise. These\n // models carry no task evidence, so outside Premium the cheapest one is\n // the first recovery hop; otherwise an outage of the curated chain would\n // jump an Eco turn straight to the most expensive model in the list.\n const verifiedToolFallbacks = features.needsTools\n ? VERIFIED_TOOL_FALLBACKS.filter((model) => options.modelPricing.has(model))\n : [];\n if (options.routingProfile !== \"premium\") {\n const fallbackCost = (model: string) =>\n estimatedCost(model, options, features.estimatedInputTokens, maxOutputTokens);\n verifiedToolFallbacks.sort((a, b) => fallbackCost(a) - fallbackCost(b));\n }\n const chain = [\n ...new Set([\n ...configuredCandidates,\n ...evidenceCandidates(features.taskType),\n ...verifiedToolFallbacks,\n ]),\n ].filter(\n (model): model is string =>\n typeof model === \"string\" && model.length > 0 && !unavailable.has(model),\n );\n const eligible = new Set(\n chain.filter((model) => isEligible(model, features, maxOutputTokens, options)),\n );\n // When nothing is eligible the whole chain competes, scored as incapable.\n const eligibleCandidates = eligible.size > 0 ? [...eligible] : chain;\n if (eligibleCandidates.length === 0) return base;\n const profileName =\n options.routingProfile === \"eco\"\n ? \"eco\"\n : options.routingProfile === \"premium\"\n ? \"premium\"\n : \"auto\";\n const portfolio = options.config.portfolio ?? DEFAULT_PORTFOLIO_WEIGHTS;\n const band = affinityBand(features);\n const affinityCache = new Map();\n const getAffinity = (model: string) => {\n let value = affinityCache.get(model);\n if (value === undefined) {\n value = affinityIn(band, model);\n affinityCache.set(model, value);\n }\n return value;\n };\n const bestAffinity = Math.max(...eligibleCandidates.map(getAffinity));\n const specificAffinity = eligibleCandidates.filter((model) => getAffinity(model) > NEUTRAL_AFFINITY);\n // A tier's fallback list is primarily an availability/recovery chain, not a\n // set of equally validated substitutes. Re-ranking every fallback lets a\n // cheap generic model displace the curated primary merely because it has a\n // favourable short performance probe. Only promote models with explicit\n // task affinity; otherwise retain the first capability-eligible tier model.\n const affinityPool = specificAffinity.length > 0 ? specificAffinity : [eligibleCandidates[0]];\n // Generic Terminal work has much wider trajectory variance than a BFCL-like\n // one-turn parallel call. Keep the strong-model safety band, but admit the\n // next capable tier so Auto's cost/reliability score can reject an Opus\n // primary that is materially more expensive without measured benefit.\n const affinityFloorGap = features.terminalToolSignal\n ? Math.max(\n portfolio.affinityFloorGap[profileName],\n features.terminalSafetySensitive ? 0.15 : 0.12,\n )\n : portfolio.affinityFloorGap[profileName];\n const candidates = affinityPool.filter(\n (model) => getAffinity(model) >= bestAffinity - affinityFloorGap,\n );\n const costs = candidates.map((model) =>\n estimatedCost(model, options, features.estimatedInputTokens, maxOutputTokens),\n );\n const finiteCosts = costs.filter(Number.isFinite);\n const minCost = finiteCosts.length > 0 ? Math.min(...finiteCosts) : 0;\n const maxCost = finiteCosts.length > 0 ? Math.max(...finiteCosts) : 1;\n\n const now = options.now ?? new Date();\n const profileWeights = portfolio[profileName];\n const rankedEntries = candidates\n .map((model, index) => {\n const cost = costs[index];\n // An unpriced candidate costs an unknown amount, so it scores as the\n // most expensive rather than a neutral 0.5 that let it outrank\n // priced models. Pricing presence still never filters a candidate.\n const costScore = !Number.isFinite(cost)\n ? 0\n : maxCost > minCost\n ? 1 - (cost - minCost) / (maxCost - minCost)\n : 0.5;\n const capabilityScore = eligible.has(model) ? 1 : 0;\n const profile = profileScore(model, options, now);\n // Fresh observations can refine affinity. Historical observations fade\n // quickly and never replace task-level RouterBench evidence.\n const observedQuality =\n profile?.quality === undefined\n ? getAffinity(model)\n : getAffinity(model) * (1 - profile.freshness) + profile.quality * profile.freshness;\n // Every observed dimension fades toward its neutral prior as the\n // observation ages, exactly like reliability below. Fading speed\n // toward zero instead ranked any model with a stale probe below a\n // model nobody had measured, which the latter's 0.5 silently won.\n const observedSpeed = profile\n ? profile.speed * profile.freshness + 0.5 * (1 - profile.freshness)\n : 0.5;\n const observedTailSpeed = profile\n ? profile.tailSpeed * profile.freshness + 0.5 * (1 - profile.freshness)\n : 0.5;\n const observedReliability = profile\n ? profile.reliability * profile.freshness + (1 - profile.freshness)\n : 1;\n // Preserve a small amount of the hand-curated fallback order while V3's\n // task affinity and real request constraints do the primary work.\n const legacyScore = 1 - index / Math.max(1, candidates.length - 1);\n const qualityWeight =\n profileWeights.quality + (features.highStakes ? portfolio.highStakesBoost.quality : 0);\n const speedScore = features.latencySensitive ? observedTailSpeed : observedSpeed;\n const speedWeight =\n profileWeights.speed +\n (features.latencySensitive ? portfolio.latencySensitiveSpeedBoost : 0);\n const reliabilityWeight =\n profileWeights.reliability +\n (features.highStakes ? portfolio.highStakesBoost.reliability : 0);\n const score =\n observedQuality * qualityWeight +\n capabilityScore * profileWeights.capability +\n costScore * profileWeights.cost +\n speedScore * speedWeight +\n observedReliability * reliabilityWeight +\n legacyScore * profileWeights.legacy;\n return {\n model,\n score,\n quality: observedQuality,\n cost: costScore,\n speed: speedScore,\n reliability: observedReliability,\n };\n })\n .sort((a, b) => b.score - a.score);\n const scoredModels = rankedEntries.map((item) => item.model);\n // The affinity floor controls which models may compete for the primary;\n // it must not erase availability fallbacks. Append all remaining eligible\n // models in their curated chain order after the scored primary pool.\n const webResearchFallbackOrder = [\n \"anthropic/claude-sonnet-5\",\n \"openai/gpt-5.6-luna\",\n \"google/gemini-3.6-flash\",\n \"anthropic/claude-opus-5\",\n \"anthropic/claude-opus-4.8\",\n \"openai/gpt-5.3-codex\",\n ];\n const ranked =\n features.agentDomain === \"web_research\"\n ? [\n ...scoredModels,\n ...webResearchFallbackOrder.filter(\n (model) => eligibleCandidates.includes(model) && !scoredModels.includes(model),\n ),\n ...eligibleCandidates.filter(\n (model) => !scoredModels.includes(model) && !webResearchFallbackOrder.includes(model),\n ),\n ]\n : [...scoredModels, ...eligibleCandidates.filter((model) => !scoredModels.includes(model))];\n\n const model = ranked[0] ?? base.model;\n const selectedTierConfigs: Record = {\n ...tierConfigs,\n [targetTier]: { primary: model, fallback: ranked.slice(1) },\n };\n // selectModel only reads the selected tier; retain the complete tier map for host fallback.\n const decision = selectModel(\n targetTier,\n base.confidence,\n \"portfolio\",\n `${base.reasoning} | v3 task=${features.taskType} agentRisk=${features.agentRisk} deepWebResearch=${features.deepWebResearch} terminalCode=${features.implicitTerminalCode} terminalSafety=${features.terminalSafetySensitive} candidates=${ranked.length}`,\n selectedTierConfigs,\n options.modelPricing,\n features.estimatedInputTokens,\n maxOutputTokens,\n options.routingProfile,\n base.agenticScore,\n );\n return {\n ...decision,\n tierConfigs: selectedTierConfigs,\n profile: base.profile,\n candidates: ranked,\n candidateScores: rankedEntries.map(({ model, score, quality, cost, speed, reliability }) => ({\n model,\n score,\n quality,\n cost,\n speed,\n reliability,\n })),\n taskType: features.taskType,\n routerVersion: \"v3-portfolio\" as const,\n };\n }\n}\n","/** Pure public-catalog parsing. Fetching, caching and UI ordering belong to hosts. */\nimport { DEFAULT_MODEL_CAPABILITIES, type ModelCapabilities } from \"./model-capabilities.js\";\nimport type { ModelPricing } from \"./selector.js\";\n\nexport const MODEL_KINDS = [\"chat\", \"image\", \"video\", \"music\"] as const;\nexport type ModelKind = (typeof MODEL_KINDS)[number];\n\n/** Gateway units are preserved: token prices per 1M tokens; media per unit. */\nexport interface CatalogPricing {\n input?: number;\n output?: number;\n per_image?: number;\n per_second?: number;\n per_track?: number;\n cache_read?: number;\n cache_write?: number;\n transaction_fee?: number;\n per_call_surcharge?: number;\n default_duration_seconds?: number;\n max_duration_seconds?: number;\n}\n\nexport interface CatalogModel {\n id: string;\n name: string;\n categories: readonly string[];\n kinds: readonly ModelKind[];\n billingMode?: string;\n /** Zero pricing alone does not imply a free model. */\n free: boolean;\n pricing: CatalogPricing;\n contextWindow?: number;\n maxOutputTokens?: number;\n}\n\nexport interface ModelCatalog {\n models: readonly CatalogModel[];\n chat: readonly CatalogModel[];\n image: readonly CatalogModel[];\n video: readonly CatalogModel[];\n music: readonly CatalogModel[];\n /**\n * IDs whose authoritative row says `available: false`. The gateway does not\n * reject these; it substitutes another model. Absence from the listing is\n * not unavailability: hidden IDs are still served.\n */\n unavailable: readonly string[];\n}\n\nconst PRICE_KEYS = [\n \"input\", \"output\", \"per_image\", \"per_second\", \"per_track\", \"cache_read\", \"cache_write\",\n \"transaction_fee\", \"per_call_surcharge\", \"default_duration_seconds\", \"max_duration_seconds\",\n] as const;\nconst UNIT_PRICE = { image: \"per_image\", video: \"per_second\", music: \"per_track\" } as const;\nconst MODEL_ID = /^[a-z0-9][a-z0-9._-]*\\/[a-zA-Z0-9][a-zA-Z0-9._:+-]*$/;\nconst record = (value: unknown): value is Record =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst price = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value) && value >= 0;\nconst capacity = (value: unknown): number | undefined =>\n typeof value === \"number\" && Number.isSafeInteger(value) && value > 0 ? value : undefined;\n\n/**\n * Normalize GET /api/v1/models without a model-ID allowlist. New provider IDs\n * appear immediately. Hidden/unavailable rows and invalid per-kind prices are\n * omitted. A malformed envelope throws so a host can retain its last good list;\n * an explicitly empty `data` array is a valid empty catalog.\n *\n * IDs explicitly marked `available: false` are also listed in `unavailable`.\n * Rows outside MODEL_KINDS (speech, sound effects) are omitted.\n *\n * Last duplicate wins, including a final unavailable/invalid row. No sorting,\n * price markup, network request, capability probe or media routing is performed.\n */\nexport function parseModelCatalog(value: unknown): ModelCatalog {\n if (!record(value) || !Array.isArray(value.data)) {\n throw new TypeError(\"Model catalog must contain a data array\");\n }\n const entries = new Map>();\n for (const entry of value.data) {\n if (record(entry) && typeof entry.id === \"string\" && entry.id.length <= 200 && MODEL_ID.test(entry.id)) {\n entries.set(entry.id, entry);\n }\n }\n const result: ModelCatalog = { models: [], chat: [], image: [], video: [], music: [], unavailable: [] };\n const models: CatalogModel[] = [];\n const unavailable: string[] = [];\n for (const [id, entry] of entries) {\n if (entry.available === false) unavailable.push(id);\n if ((entry.available !== undefined && entry.available !== true) ||\n (entry.hidden !== undefined && entry.hidden !== false) ||\n !Array.isArray(entry.categories) || !record(entry.pricing)) continue;\n const categories = [...new Set(entry.categories.filter((c): c is string => typeof c === \"string\"))];\n const rawPricing = entry.pricing;\n const pricing: CatalogPricing = {};\n for (const key of PRICE_KEYS) if (price(rawPricing[key])) pricing[key] = rawPricing[key];\n const kinds = MODEL_KINDS.filter(kind => categories.includes(kind) && (kind === \"chat\"\n ? price(rawPricing.input) && price(rawPricing.output)\n : price(rawPricing[UNIT_PRICE[kind]])));\n if (!kinds.length) continue;\n const model: CatalogModel = {\n id, name: typeof entry.name === \"string\" && entry.name.trim() ? entry.name : id,\n categories, kinds, pricing,\n free: kinds.includes(\"chat\") && entry.billing_mode === \"free\" && pricing.input === 0 && pricing.output === 0,\n ...(typeof entry.billing_mode === \"string\" ? { billingMode: entry.billing_mode } : {}),\n ...(capacity(entry.context_window) !== undefined ? { contextWindow: capacity(entry.context_window) } : {}),\n ...(capacity(entry.max_output) !== undefined ? { maxOutputTokens: capacity(entry.max_output) } : {}),\n };\n models.push(model);\n }\n result.models = models;\n result.unavailable = unavailable;\n for (const kind of MODEL_KINDS) result[kind] = models.filter(model => model.kinds.includes(kind));\n return result;\n}\n\nexport interface CatalogRoutingOptions {\n /** Host evidence, merged over (and overriding per ID) the bundled verified table. */\n verifiedCapabilities?: Readonly>;\n}\n\nexport interface RoutingCatalog {\n modelPricing: Map;\n modelCapabilities: Record;\n unavailableModels: string[];\n}\n\n/**\n * Adapt only the chat catalog for route(). Media never enters LLM candidate\n * chains. Tool support comes from verified evidence, never a name or category.\n * Unknown capacities are zero, rather than invented defaults.\n *\n * Only rows the gateway explicitly marks `available: false` become\n * unavailableModels. Configured IDs that are merely absent from the listing\n * stay routable: the gateway serves hidden IDs, and only the configured chain\n * knows about them.\n */\nexport function toRoutingCatalog(catalog: ModelCatalog, options: CatalogRoutingOptions = {}): RoutingCatalog {\n const verified = { ...DEFAULT_MODEL_CAPABILITIES, ...options.verifiedCapabilities };\n const modelPricing = new Map();\n const modelCapabilities: Record = {};\n for (const model of catalog.chat) {\n modelPricing.set(model.id, { inputPrice: model.pricing.input!, outputPrice: model.pricing.output! });\n const evidence = verified[model.id];\n modelCapabilities[model.id] = {\n contextWindow: model.contextWindow ?? evidence?.contextWindow ?? 0,\n maxOutputTokens: model.maxOutputTokens ?? evidence?.maxOutputTokens ?? 0,\n supportsTools: evidence?.supportsTools === true,\n // Verified evidence wins over the category tag in both directions: the\n // catalog omits \"vision\" for some models that accept images and tags\n // others whose image input does not hold up (see capability-overrides).\n supportsVision: evidence?.supportsVision ?? model.categories.includes(\"vision\"),\n };\n }\n return { modelPricing, modelCapabilities, unavailableModels: [...catalog.unavailable] };\n}\n","/**\n * Smart Router Entry Point\n *\n * Classifies requests and routes to the cheapest capable model.\n * Delegates to pluggable RouterStrategy (default: RulesStrategy, <1ms).\n */\n\nimport type { RoutingDecision, RouterOptions } from \"./types.js\";\nimport { getStrategy, registerStrategy } from \"./strategy.js\";\nimport { PortfolioStrategy } from \"./portfolio.js\";\n\n// Register here instead of strategy.ts so PortfolioStrategy can reuse the\n// stable RulesStrategy without introducing a module cycle.\nregisterStrategy(new PortfolioStrategy());\n\n/**\n * Route a request to the cheapest capable model.\n * Delegates to the configured strategy (PortfolioStrategy by default).\n */\nexport function route(\n prompt: string,\n systemPrompt: string | undefined,\n maxOutputTokens: number,\n options: RouterOptions,\n): RoutingDecision {\n const strategy = getStrategy(options.config.strategy ?? \"portfolio\");\n return strategy.route(prompt, systemPrompt, maxOutputTokens, options);\n}\n\nexport { getStrategy, registerStrategy, applyUnavailableModels } from \"./strategy.js\";\nexport { RulesStrategy } from \"./strategy.js\";\nexport { PortfolioStrategy } from \"./portfolio.js\";\nexport { classifyByRules } from \"./rules.js\";\nexport { inferToolRequirement } from \"./tool-intent.js\";\nexport { estimateTokens } from \"./tokens.js\";\nexport { MODEL_KINDS, parseModelCatalog, toRoutingCatalog } from \"./catalog.js\";\nexport type {\n ModelKind, CatalogPricing, CatalogModel, ModelCatalog, CatalogRoutingOptions, RoutingCatalog,\n} from \"./catalog.js\";\nexport {\n getFallbackChain,\n getFallbackChainFiltered,\n filterByToolCalling,\n filterByVision,\n filterByExcludeList,\n filterCandidatesByCapacity,\n calculateModelCost,\n} from \"./selector.js\";\nexport { DEFAULT_ROUTING_CONFIG } from \"./config.js\";\nexport { DEFAULT_MODEL_CAPABILITIES } from \"./model-capabilities.js\";\nexport { LIVE_MODEL_PROFILES, HISTORICAL_MODEL_PROFILES } from \"./model-profiles.js\";\nexport type {\n RoutingDecision,\n Tier,\n TaskType,\n RoutingConfig,\n RouterOptions,\n RouterStrategy,\n} from \"./types.js\";\nexport type { ModelPricing } from \"./selector.js\";\nexport type { ModelCapabilities } from \"./model-capabilities.js\";\nexport type { ModelPerformanceProfile } from \"./model-profiles.js\";\n"],"mappings":";AAiCA,IAAM,qBACJ;AACF,IAAM,YAAY;AAClB,IAAM,eAAe;AAIrB,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB,QAAQ,mBAAmB;AACnD,IAAM,iBAAiB,OAAO,mBAAmB;AACjD,IAAM,2BAA2B;AACjC,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AACxB,IAAM,eACJ;AACF,IAAM,qBAAqB;AAC3B,IAAM,6BAA6B;AAQnC,IAAM,eAAe,oBAAI,IAA4B;AAErD,SAAS,aAAa,OAAuB;AAC3C,SAAO,MAAM,Q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EAAE,YAAY,MAAM,QAAQ,OAAQ,aAAa,MAAM,QAAQ,OAAQ,CAAC;AACnG,UAAM,WAAW,SAAS,MAAM,EAAE;AAClC,sBAAkB,MAAM,EAAE,IAAI;AAAA,MAC5B,eAAe,MAAM,iBAAiB,UAAU,iBAAiB;AAAA,MACjE,iBAAiB,MAAM,mBAAmB,UAAU,mBAAmB;AAAA,MACvE,eAAe,UAAU,kBAAkB;AAAA;AAAA;AAAA;AAAA,MAI3C,gBAAgB,UAAU,kBAAkB,MAAM,WAAW,SAAS,QAAQ;AAAA,IAChF;AAAA,EACF;AACA,SAAO,EAAE,cAAc,mBAAmB,mBAAmB,CAAC,GAAG,QAAQ,WAAW,EAAE;AACxF;;;AC9IA,iBAAiB,IAAI,kBAAkB,CAAC;AAMjC,SAAS,MACd,QACA,cACA,iBACA,SACiB;AACjB,QAAM,WAAW,YAAY,QAAQ,OAAO,YAAY,WAAW;AACnE,SAAO,SAAS,MAAM,QAAQ,cAAc,iBAAiB,OAAO;AACtE;","names":["confidence","decision","price","model"]} \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 1a3ae04..d950568 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1124,7 +1124,9 @@ export const DEFAULT_ROUTING_CONFIG: RoutingConfig = { // affinity values, CARRIED, not measured (portfolio.ts) — gpt-5-mini is a // reasoning model and luna runs without reasoning, so those values are a // placeholder until a Terminal-Bench/tau2 run on luna. - // - openai/gpt-5-nano -> openai/gpt-6-luna. In no chain. + // - openai/gpt-5-nano is NOT redirected (owner decision 2026-11-24): the + // gateways keep serving it from Azure at its own $0.05/$0.40 until + // 2027-02-09. It is hidden and in no chain, and none is added. // Auto (balanced) tier configs - current default smart routing tiers: { diff --git a/src/retired-models.test.ts b/src/retired-models.test.ts index 9fc68e4..eca6f39 100644 --- a/src/retired-models.test.ts +++ b/src/retired-models.test.ts @@ -28,10 +28,10 @@ const REDIRECTED: Readonly> = { // 2026-12-01: Google retires Gemini 2.5. "google/gemini-2.5-flash": "google/gemini-3.5-flash-lite", "google/gemini-2.5-pro": "google/gemini-3.8-flash", - // 2026-12-11: OpenAI shuts down o3, gpt-5-mini and gpt-5-nano. + // 2026-12-11: OpenAI shuts down o3 and gpt-5-mini. (gpt-5-nano too, but the + // gateways keep serving it from Azure until 2027-02-09: not a redirect.) "openai/o3": "openai/gpt-5.4-mini", "openai/gpt-5-mini": "openai/gpt-5.6-luna", - "openai/gpt-5-nano": "openai/gpt-6-luna", }; const TIER_SETS = ["tiers", "ecoTiers", "premiumTiers", "agenticTiers"] as const; @@ -83,6 +83,12 @@ describe("retired models", () => { } }); + it("no configured chain names openai/gpt-5-nano (hidden, Azure-only until its 2027-02-09 retirement)", () => { + for (const [name, config] of chains()) { + expect([config.primary, ...config.fallback], name).not.toContain("openai/gpt-5-nano"); + } + }); + it("no chain lists a model twice (a successor written in place must not duplicate a rung)", () => { for (const [name, config] of chains()) { const models = [config.primary, ...config.fallback];