@bastani/atomic 0.9.80-alpha.1 → 0.9.81-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/client.ts +12 -1
  4. package/dist/builtin/intercom/index.bundle.mjs +16 -4
  5. package/dist/builtin/intercom/package.json +1 -1
  6. package/dist/builtin/mcp/package.json +1 -1
  7. package/dist/builtin/subagents/CHANGELOG.md +10 -0
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +40 -2
  10. package/dist/builtin/subagents/src/extension/index.bundle.mjs +123 -25
  11. package/dist/builtin/web-access/package.json +1 -1
  12. package/dist/builtin/workflows/CHANGELOG.md +20 -0
  13. package/dist/builtin/workflows/builtin/{chunk-m56qhe4b.js → chunk-zpkcqyhr.js} +2 -0
  14. package/dist/builtin/workflows/builtin/index.js +1 -1
  15. package/dist/builtin/workflows/builtin/ralph.js +1 -1
  16. package/dist/builtin/workflows/package.json +1 -1
  17. package/dist/builtin/workflows/src/extension/index.bundle.mjs +16 -4
  18. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +12 -2
  19. package/dist/builtin/workflows/src/index.js +12 -2
  20. package/dist/builtin/workflows/src/local-worker-entry.mjs +12 -2
  21. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +8 -1
  22. package/dist/cli/args.d.ts.map +1 -1
  23. package/dist/cli/args.js +4 -2
  24. package/dist/cli/args.js.map +1 -1
  25. package/dist/core/cache-stats.d.ts +21 -0
  26. package/dist/core/cache-stats.d.ts.map +1 -1
  27. package/dist/core/cache-stats.js +42 -2
  28. package/dist/core/cache-stats.js.map +1 -1
  29. package/dist/core/exec.d.ts +1 -0
  30. package/dist/core/exec.d.ts.map +1 -1
  31. package/dist/core/exec.js +2 -1
  32. package/dist/core/exec.js.map +1 -1
  33. package/dist/core/execution-model-router.d.ts +17 -0
  34. package/dist/core/execution-model-router.d.ts.map +1 -1
  35. package/dist/core/execution-model-router.js +52 -23
  36. package/dist/core/execution-model-router.js.map +1 -1
  37. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  38. package/dist/core/model-fallback-failures.js +1 -0
  39. package/dist/core/model-fallback-failures.js.map +1 -1
  40. package/dist/core/model-resolver-scope.d.ts +0 -1
  41. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  42. package/dist/core/model-resolver-scope.js +0 -8
  43. package/dist/core/model-resolver-scope.js.map +1 -1
  44. package/dist/core/model-resolver.d.ts +1 -1
  45. package/dist/core/model-resolver.d.ts.map +1 -1
  46. package/dist/core/model-resolver.js +1 -1
  47. package/dist/core/model-resolver.js.map +1 -1
  48. package/dist/core/model-routing-candidates.d.ts +30 -5
  49. package/dist/core/model-routing-candidates.d.ts.map +1 -1
  50. package/dist/core/model-routing-candidates.js +381 -105
  51. package/dist/core/model-routing-candidates.js.map +1 -1
  52. package/dist/core/model-routing-estimates.d.ts +70 -0
  53. package/dist/core/model-routing-estimates.d.ts.map +1 -0
  54. package/dist/core/model-routing-estimates.js +244 -0
  55. package/dist/core/model-routing-estimates.js.map +1 -0
  56. package/dist/core/model-routing-needs.d.ts +1 -0
  57. package/dist/core/model-routing-needs.d.ts.map +1 -1
  58. package/dist/core/model-routing-needs.js +1 -1
  59. package/dist/core/model-routing-needs.js.map +1 -1
  60. package/dist/core/provider-display-names.js +2 -2
  61. package/dist/core/provider-display-names.js.map +1 -1
  62. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  63. package/dist/core/remote-catalog-provider.js +6 -0
  64. package/dist/core/remote-catalog-provider.js.map +1 -1
  65. package/dist/core/storage/session/released-history-files.d.ts.map +1 -1
  66. package/dist/core/storage/session/released-history-files.js +5 -0
  67. package/dist/core/storage/session/released-history-files.js.map +1 -1
  68. package/dist/core/tasks/supervisor.d.ts +1 -1
  69. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  70. package/dist/core/tasks/supervisor.js.map +1 -1
  71. package/dist/core/tools/find.d.ts.map +1 -1
  72. package/dist/core/tools/find.js +20 -11
  73. package/dist/core/tools/find.js.map +1 -1
  74. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  75. package/dist/core/tools/output-accumulator.js +2 -1
  76. package/dist/core/tools/output-accumulator.js.map +1 -1
  77. package/dist/index.d.ts +1 -1
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/main.d.ts.map +1 -1
  81. package/dist/main.js +30 -10
  82. package/dist/main.js.map +1 -1
  83. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +5 -0
  84. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  85. package/dist/modes/interactive/components/chat-session-host-actions.js +86 -9
  86. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  87. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  88. package/dist/modes/interactive/components/chat-session-host-events.js +6 -3
  89. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  90. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  91. package/dist/modes/interactive/components/chat-session-host-rendering.js +5 -2
  92. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  93. package/dist/modes/interactive/components/chat-session-host-state.d.ts +5 -0
  94. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
  96. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  97. package/dist/modes/interactive/components/footer.d.ts +4 -2
  98. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/footer.js +11 -4
  100. package/dist/modes/interactive/components/footer.js.map +1 -1
  101. package/dist/modes/interactive/components/session-selector-list.d.ts +4 -1
  102. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/session-selector-list.js +24 -1
  104. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  105. package/dist/modes/interactive/components/session-selector.d.ts +1 -0
  106. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/session-selector.js +29 -36
  108. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  109. package/dist/modes/interactive/interactive-agent-events.js +6 -6
  110. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  111. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  112. package/dist/modes/interactive/interactive-deferred-startup.js +11 -3
  113. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  114. package/dist/modes/interactive/interactive-input-handling.js +11 -1
  115. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  116. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  117. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  118. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  119. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  120. package/dist/modes/interactive/interactive-process-lifecycle.js +34 -7
  121. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  122. package/dist/modes/interactive/interactive-queueing.d.ts +24 -0
  123. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  124. package/dist/modes/interactive/interactive-queueing.js +61 -0
  125. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  126. package/dist/modes/interactive/interactive-render-chat.js +2 -3
  127. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  128. package/dist/modes/interactive/interactive-slash-commands.js +2 -2
  129. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  130. package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
  131. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  132. package/dist/modes/interactive-engine/isolated-runtime.js +10 -0
  133. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  134. package/dist/modes/rpc/rpc-mode.d.ts +2 -0
  135. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  136. package/dist/modes/rpc/rpc-mode.js +1 -0
  137. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  138. package/dist/modes/rpc/rpc-session-binding.d.ts +3 -1
  139. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  140. package/dist/modes/rpc/rpc-session-binding.js +4 -1
  141. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  142. package/docs/background-tasks.md +2 -2
  143. package/docs/extensions/api-reference.md +1 -1
  144. package/docs/models/model-selection.md +7 -7
  145. package/docs/providers.md +12 -17
  146. package/docs/skills.md +1 -1
  147. package/docs/subagents.md +3 -1
  148. package/docs/tools.md +1 -1
  149. package/docs/usage.md +1 -1
  150. package/docs/workflows/authoring.md +2 -0
  151. package/docs/workflows/operations.md +1 -1
  152. package/npm-shrinkwrap.json +57 -33
  153. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"model-routing-candidates.js","sourceRoot":"","sources":["../../src/core/model-routing-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EAEpB,mBAAmB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAA0B,UAAU,EAAiB,MAAM,0BAA0B,CAAC;AAuB7F,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACpF,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAElF,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;AAElE,wFAAwF;AACxF,MAAM,YAAY,GAA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ity,\n\ttype EvalsCatalog,\n\tmodelEvidenceTokens,\n} from \"./model-routing-evals.js\";\nimport { type ResolvedTaskNeeds, taskDemand, type WorkKind } from \"./model-routing-needs.js\";\n\n/** What ranking needs to know about one eligible model. */\nexport interface CandidateModel {\n\t/** `provider/id`, as used in router selections. */\n\treadonly model: string;\n\treadonly name: string;\n\treadonly cost: { readonly input: number; readonly output: number };\n\treadonly input: readonly string[];\n\t/** `provider/id` of the base model when this entry is its derived fast route (`fastRoute` metadata). */\n\treadonly fastRouteOf?: string;\n\t/** Explicit provider tier, used to avoid claiming measured latency for ultrafast. */\n\treadonly fastRouteServiceTier?: \"priority\" | \"ultrafast\";\n\t/** True when `cost` already holds the route tier's published rates rather than the base model's. */\n\treadonly fastRoutePriced?: boolean;\n}\n\ninterface Metric {\n\treadonly key: string;\n\treadonly label: string;\n\treadonly unit: \"%\" | \"\";\n}\n\nconst percent = (key: string, label: string): Metric => ({ key, label, unit: \"%\" });\nconst points = (key: string, label: string): Metric => ({ key, label, unit: \"\" });\n\nconst OVERALL: Metric = points(\"aa:idx\", \"AA Intelligence Index\");\n\n/** evals.md columns that measure each kind of work, in the order results are quoted. */\nconst WORK_METRICS: Record<WorkKind, readonly Metric[]> = {\n\tcomputer_use: [\n\t\tpercent(\"pub:OSW2\", \"OSWorld 2.0\"),\n\t\tpercent(\"pub:SSP\", \"ScreenSpot-Pro\"),\n\t\tpercent(\"pub:ALE\", \"Agents' Last Exam\"),\n\t\tpercent(\"aa:MMMU\", \"MMMU-Pro\"),\n\t],\n\tcoding: [\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"dswe:Pass@1\", \"DeepSWE\"),\n\t\tpercent(\"pub:DSWE\", \"DeepSWE\"),\n\t\tpercent(\"fc:Main\", \"FrontierCode\"),\n\t\tpercent(\"aa:TB21\", \"Terminal-Bench 2.1\"),\n\t],\n\tcode_review: [\n\t\tpercent(\"fc:Main\", \"FrontierCode\"),\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"pub:XGym\", \"ExploitGym\"),\n\t\tpercent(\"pub:SECPro\", \"SEC-Bench Pro\"),\n\t],\n\tcodebase_lookup: [\n\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\"),\n\t\tpercent(\"aa:tau2\", \"τ²-Bench\"),\n\t\tpercent(\"aa:IF\", \"IFBench\"),\n\t],\n\tresearch: [\n\t\tpercent(\"aa:HLE\", \"Humanity's Last Exam\"),\n\t\tpercent(\"pub:BComp\", \"BrowseComp\"),\n\t\tpercent(\"aa:GPQA\", \"GPQA Diamond\"),\n\t\tpercent(\"aa:LCR\", \"AA-LCR\"),\n\t],\n\tbusiness_workflow: [\n\t\tpercent(\"aa:Auto\", \"AutomationBench-AA\"),\n\t\tpercent(\"pub:ABench\", \"AutomationBench\"),\n\t\tpercent(\"aa:tau2\", \"τ²-Bench\"),\n\t\tpercent(\"aa:Ent\", \"EnterpriseOps-Gym\"),\n\t],\n\tmath_science: [\n\t\tpercent(\"pub:FMT4\", \"FrontierMath Tier 4\"),\n\t\tpercent(\"pub:TBSci\", \"Terminal-Bench-Science\"),\n\t\tpercent(\"aa:Crit\", \"CritPt\"),\n\t\tpercent(\"aa:Sci\", \"SciCode\"),\n\t],\n\twriting: [\n\t\tpercent(\"aa:IF\", \"IFBench\"),\n\t\tpoints(\"aa:Gn\", \"GDPval\"),\n\t\tpoints(\"aa:Brief\", \"AA-Briefcase\"),\n\t\tpercent(\"aa:LCR\", \"AA-LCR\"),\n\t],\n};\n\n/** When speed matters, a fast route edges out its standard route for the model's single slot. */\nconst FAST_ROUTE_BONUS = 0.02;\n\n/** A standing is stated only when enough benchmarked models share the measurement. */\nconst MIN_RANKED_MODELS = 4;\n\nexport interface RankedCandidate extends CandidateModel {\n\t/** Identity shared by one model's providers and its derived fast route, which collapse onto it. */\n\treadonly baseKey: string;\n\treadonly score: number;\n\treadonly values: ReadonlyMap<string, number>;\n\t/** How each quoted value was measured, for example its effort, harness or reporter. */\n\treadonly conditions: ReadonlyMap<string, string>;\n\treadonly released?: string;\n\treadonly workStanding?: number;\n\treadonly overallStanding?: number;\n}\n\nfunction sectionKind(intro: readonly string[]): \"aa\" | \"dswe\" | \"fc\" | \"pub\" {\n\tconst heading = intro.find((line) => line.startsWith(\"## \")) ?? \"\";\n\tif (/DeepSWE/u.test(heading)) return \"dswe\";\n\tif (/FrontierCode/u.test(heading)) return \"fc\";\n\tif (/Published/u.test(heading)) return \"pub\";\n\treturn \"aa\";\n}\n\nconst cells = (line: string) =>\n\tline\n\t\t.split(\"|\")\n\t\t.slice(1, -1)\n\t\t.map((cell) => cell.trim());\n\nconst nameWords = (text: string) => new Set(text.match(/\\p{Lu}[\\p{L}]{2,}/gu) ?? []);\n\n/**\n * The parts of a published result's setting that apply to this row: a clause\n * naming other models (for example \"Fable values are Mythos\" on a GPT row) is a\n * footnote for them and is dropped.\n */\nfunction ownSetting(setting: string, rowModel: string, modelWords: ReadonlySet<string>): string {\n\tconst own = nameWords(rowModel);\n\treturn setting\n\t\t.split(\";\")\n\t\t.map((clause) => clause.trim())\n\t\t.filter((clause) => {\n\t\t\tconst named = [...nameWords(clause)].filter((word) => modelWords.has(word));\n\t\t\treturn named.length === 0 || named.some((word) => own.has(word));\n\t\t})\n\t\t.join(\", \");\n}\n\n/** Parenthetical measurement setting in an Artificial Analysis model name, for example \"Max Effort\". */\nfunction nameCondition(name: string | undefined): string | undefined {\n\tconst setting = /\\(([^)]+)\\)\\s*$/u.exec(name ?? \"\")?.[1];\n\treturn setting && /^(?:minimal|low|medium|high|xhigh|max)$/u.test(setting) ? `${setting} effort` : setting;\n}\n\ninterface Reading {\n\treadonly key: string;\n\treadonly value: number;\n\treadonly condition?: string;\n}\n\ninterface CatalogReadings {\n\t/** Readings of each catalog row, indexed by the row's `order`. */\n\treadonly rows: readonly (readonly Reading[])[];\n\t/** Per measurement, the best value of each catalog model. */\n\treadonly cohorts: ReadonlyMap<string, ReadonlyMap<string, number>>;\n}\n\nconst readingsByCatalog = new WeakMap<EvalsCatalog, CatalogReadings>();\n\n/** Every measured value in the catalog, read once per parsed catalog. */\nfunction catalogReadings(catalog: EvalsCatalog): CatalogReadings {\n\tconst cached = readingsByCatalog.get(catalog);\n\tif (cached) return cached;\n\tconst kinds = catalog.sections.map((section) => sectionKind(section.intro));\n\tconst headers = catalog.sections.map((section) =>\n\t\tcells(section.intro.find((line) => line.startsWith(\"| slug |\")) ?? \"\"),\n\t);\n\tconst modelColumn = headers.map((header) => header.indexOf(\"Model\"));\n\tconst modelWords = catalog.sections.map((_, section) => {\n\t\tconst words = new Set<string>();\n\t\tfor (const row of catalog.rows)\n\t\t\tif (row.section === section)\n\t\t\t\tfor (const word of nameWords(cells(row.line)[modelColumn[section]!] ?? \"\")) words.add(word);\n\t\treturn words;\n\t});\n\tconst rows = catalog.rows.map((row) => {\n\t\tconst header = headers[row.section]!;\n\t\tconst rowCells = cells(row.line);\n\t\tconst column = (name: string) => (header.includes(name) ? rowCells[header.indexOf(name)] : undefined);\n\t\tconst readings: Reading[] = [];\n\t\tconst read = (key: string, raw: string | undefined, condition: string | undefined) => {\n\t\t\tconst value = Number.parseFloat(raw ?? \"\");\n\t\t\tif (Number.isFinite(value)) readings.push({ key, value, ...(condition ? { condition } : {}) });\n\t\t};\n\t\tif (kinds[row.section] === \"pub\") {\n\t\t\tconst reporter = column(\"Source\");\n\t\t\tconst setting = ownSetting(column(\"Setting\") ?? \"\", column(\"Model\") ?? \"\", modelWords[row.section]!);\n\t\t\tconst condition = [setting, reporter ? `reported by ${reporter}` : undefined].filter(Boolean).join(\", \");\n\t\t\t// Each reporter's results form their own cohort: a vendor harness and an\n\t\t\t// official leaderboard are not ranked against each other.\n\t\t\tread(`pub:${column(\"Benchmark\")}@${reporter ?? \"\"}`, column(\"Score\"), condition);\n\t\t} else {\n\t\t\tconst effort = column(\"Effort\");\n\t\t\tconst condition = effort ? `${effort} effort` : nameCondition(column(\"Model\"));\n\t\t\tfor (const [index, name] of header.entries())\n\t\t\t\tif (index > 1 && name !== \"Effort\" && name !== \"Release date\")\n\t\t\t\t\tread(`${kinds[row.section]}:${name}`, rowCells[index], condition);\n\t\t}\n\t\treturn readings;\n\t});\n\tconst cohorts = new Map<string, Map<string, number>>();\n\tfor (const row of catalog.rows) {\n\t\tconst identity = catalogModelIdentity(row.tokens);\n\t\tfor (const { key, value } of rows[row.order]!) {\n\t\t\tconst cohort = cohorts.get(key) ?? new Map<string, number>();\n\t\t\tcohort.set(identity, Math.max(cohort.get(identity) ?? value, value));\n\t\t\tcohorts.set(key, cohort);\n\t\t}\n\t}\n\tconst readings = { rows, cohorts };\n\treadingsByCatalog.set(catalog, readings);\n\treturn readings;\n}\n\n/**\n * Best value per metric across every evals row describing the model, with the\n * conditions it was measured under, the catalog models those rows belong to,\n * and the model's newest release date.\n */\nfunction measure(\n\tcatalog: EvalsCatalog,\n\tmodel: string,\n): { values: Map<string, number>; conditions: Map<string, string>; identities: Set<string>; released?: string } {\n\tconst readings = catalogReadings(catalog);\n\tconst values = new Map<string, number>();\n\tconst conditions = new Map<string, string>();\n\tconst identities = new Set<string>();\n\tlet released: string | undefined;\n\tfor (const row of candidateEvidenceRows(catalog, model)) {\n\t\tidentities.add(catalogModelIdentity(row.tokens));\n\t\tfor (const { key, value, condition } of readings.rows[row.order]!) {\n\t\t\tif (value <= (values.get(key) ?? Number.NEGATIVE_INFINITY)) continue;\n\t\t\tvalues.set(key, value);\n\t\t\tif (condition) conditions.set(key, condition);\n\t\t\telse conditions.delete(key);\n\t\t}\n\t\tif (row.releaseDate && (!released || row.releaseDate > released)) released = row.releaseDate;\n\t}\n\treturn { values, conditions, identities, ...(released ? { released } : {}) };\n}\n\n/** Value keys measuring `metric`: the column itself, or one per reporter for published results. */\nconst cohortKeys = (values: ReadonlyMap<string, number>, metric: Metric) =>\n\t[...values.keys()].filter((key) => key === metric.key || key.startsWith(`${metric.key}@`));\n\nconst baseKey = (candidate: CandidateModel) => modelEvidenceTokens(candidate.fastRouteOf ?? candidate.model).join(\"-\");\n\nconst blended = (candidate: CandidateModel) => (3 * candidate.cost.input + candidate.cost.output) / 4;\n\n/**\n * Rank every eligible model for the task in code. Quality is the model's\n * standing among every benchmarked model in the catalog on the benchmarks for\n * this kind of work (overall intelligence when it has none), so it does not\n * depend on which other models are eligible. It is weighed against price by how\n * demanding the task is, with a small preference for newer releases.\n */\nexport function rankCandidates(\n\tcatalog: EvalsCatalog,\n\tcandidates: readonly CandidateModel[],\n\tneeds: ResolvedTaskNeeds,\n): RankedCandidate[] {\n\tconst { cohorts } = catalogReadings(catalog);\n\tconst measured = candidates.map((candidate) => ({\n\t\tcandidate,\n\t\tbase: baseKey(candidate),\n\t\t...measure(catalog, candidate.fastRouteOf ?? candidate.model),\n\t}));\n\tconst rankOf = (key: string, value: number, own: ReadonlySet<string>): number | undefined => {\n\t\tconst cohort = cohorts.get(key);\n\t\tif (cohort === undefined || cohort.size < MIN_RANKED_MODELS) return undefined;\n\t\tconst others = [...cohort].filter(([identity]) => !own.has(identity)).map(([, other]) => other);\n\t\treturn others.length ? others.filter((other) => other < value).length / others.length : undefined;\n\t};\n\tconst standingOf = (values: ReadonlyMap<string, number>, own: ReadonlySet<string>, metrics: readonly Metric[]) => {\n\t\tconst ranks = metrics\n\t\t\t.flatMap((metric) => cohortKeys(values, metric))\n\t\t\t.map((key) => rankOf(key, values.get(key)!, own))\n\t\t\t.filter((rank): rank is number => rank !== undefined);\n\t\treturn ranks.length ? ranks.reduce((a, b) => a + b, 0) / ranks.length : undefined;\n\t};\n\tconst logPrices = measured\n\t\t.map((entry) => blended(entry.candidate))\n\t\t.filter((price) => price > 0)\n\t\t.map(Math.log);\n\tconst [low, high] = [Math.min(...logPrices), Math.max(...logPrices)];\n\tconst newest = measured\n\t\t.map((entry) => entry.released ?? \"\")\n\t\t.sort()\n\t\t.at(-1);\n\tconst demand = taskDemand(needs);\n\tconst qualityWeight = 0.25 + 0.65 * demand;\n\tconst priceWeight = 0.65 - 0.65 * demand;\n\n\treturn measured\n\t\t.map(({ candidate, base, values, conditions, identities, released }) => {\n\t\t\tconst workStanding = standingOf(values, identities, WORK_METRICS[needs.work]);\n\t\t\tconst overallStanding = standingOf(values, identities, [OVERALL]);\n\t\t\tconst quality = workStanding ?? (overallStanding !== undefined ? 0.8 * overallStanding : 0.2);\n\t\t\tconst price = blended(candidate);\n\t\t\tconst cheapness = price > 0 && high > low ? 1 - (Math.log(price) - low) / (high - low) : 1;\n\t\t\tconst ageDays = released && newest ? (Date.parse(newest) - Date.parse(released)) / 86_400_000 : 365;\n\t\t\tconst recency = 1 - Math.min(1, ageDays / 365);\n\t\t\treturn {\n\t\t\t\t...candidate,\n\t\t\t\tbaseKey: base,\n\t\t\t\tscore:\n\t\t\t\t\tqualityWeight * quality +\n\t\t\t\t\tpriceWeight * cheapness +\n\t\t\t\t\t0.1 * recency +\n\t\t\t\t\t(needs.latencySensitive && candidate.fastRouteOf && candidate.fastRouteServiceTier !== \"ultrafast\"\n\t\t\t\t\t\t? FAST_ROUTE_BONUS\n\t\t\t\t\t\t: 0),\n\t\t\t\tvalues,\n\t\t\t\tconditions,\n\t\t\t\t...(released ? { released } : {}),\n\t\t\t\t...(workStanding !== undefined ? { workStanding } : {}),\n\t\t\t\t...(overallStanding !== undefined ? { overallStanding } : {}),\n\t\t\t};\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) =>\n\t\t\t\tb.score - a.score ||\n\t\t\t\tNumber(a.fastRouteOf !== undefined) - Number(b.fastRouteOf !== undefined) ||\n\t\t\t\ta.model.localeCompare(b.model),\n\t\t);\n}\n\n/** The best `size` candidates with at most one per base model. */\nexport function distinctTop(ranked: readonly RankedCandidate[], size: number): RankedCandidate[] {\n\tconst seen = new Set<string>();\n\tconst top: RankedCandidate[] = [];\n\tfor (const candidate of ranked) {\n\t\tif (seen.has(candidate.baseKey)) continue;\n\t\tseen.add(candidate.baseKey);\n\t\ttop.push(candidate);\n\t\tif (top.length === size) break;\n\t}\n\treturn top;\n}\n\nfunction standingLabel(fraction: number): string {\n\tif (fraction >= 0.9) return \"top 10%\";\n\tif (fraction >= 0.75) return \"top quarter\";\n\tif (fraction >= 0.5) return \"above median\";\n\tif (fraction >= 0.25) return \"below median\";\n\treturn \"bottom quarter\";\n}\n\nconst money = (value: number) => `$${Number(value.toPrecision(3))}`;\n\n/**\n * One shortlisted option described with its own evidence, so the router compares\n * options directly: release date, price tier, image input, and results for this\n * kind of work and overall, with standings among catalog models measured on the same benchmark by the same source.\n */\nexport function describeOption(\n\toption: RankedCandidate,\n\tneeds: ResolvedTaskNeeds,\n\teligible: readonly RankedCandidate[],\n): string {\n\tconst prices = eligible.map(blended).sort((a, b) => a - b);\n\tconst position = prices.filter((other) => other < blended(option)).length / Math.max(1, prices.length - 1);\n\tconst tier = position < 1 / 3 ? \"low\" : position < 2 / 3 ? \"mid\" : \"high\";\n\tconst newest = eligible\n\t\t.map((candidate) => candidate.released ?? \"\")\n\t\t.sort()\n\t\t.at(-1);\n\tconst quote = (metrics: readonly Metric[], standing: number | undefined) => {\n\t\tconst present = metrics\n\t\t\t.map((metric) => {\n\t\t\t\tconst keys = cohortKeys(option.values, metric);\n\t\t\t\tconst best = keys.sort((a, b) => option.values.get(b)! - option.values.get(a)!)[0];\n\t\t\t\treturn best === undefined ? undefined : { metric, key: best };\n\t\t\t})\n\t\t\t.filter((entry) => entry !== undefined)\n\t\t\t.slice(0, 2);\n\t\tif (present.length === 0) return \"no published results\";\n\t\tconst results = present\n\t\t\t.map(({ metric, key }) => {\n\t\t\t\tconst condition = option.conditions.get(key);\n\t\t\t\treturn `${metric.label} ${option.values.get(key)}${metric.unit}${condition ? ` measured with ${condition}` : \"\"}`;\n\t\t\t})\n\t\t\t.join(\"; \");\n\t\treturn `${standing === undefined ? \"measured\" : `${standingLabel(standing)} of models with the same benchmark and source`} (${results})`;\n\t};\n\tlet released = \"unknown\";\n\tif (option.released) {\n\t\tconst months = newest ? Math.round((Date.parse(newest) - Date.parse(option.released)) / (30.44 * 86_400_000)) : 0;\n\t\treleased =\n\t\t\tmonths <= 1\n\t\t\t\t? `${option.released}, among the newest`\n\t\t\t\t: `${option.released}, ${months} months older than the newest`;\n\t}\n\tconst fastBase = option.fastRouteOf\n\t\t? eligible.find((candidate) => candidate.model === option.fastRouteOf)\n\t\t: undefined;\n\treturn JSON.stringify({\n\t\tmodel: option.name,\n\t\tid: option.model,\n\t\treleased,\n\t\tprice: `${tier}: ${money(option.cost.input)} / ${money(option.cost.output)} per million tokens`,\n\t\treads_images: option.input.includes(\"image\"),\n\t\t[needs.work]: quote(WORK_METRICS[needs.work], option.workStanding),\n\t\toverall: quote([OVERALL], option.overallStanding),\n\t\t...(option.fastRouteOf\n\t\t\t? {\n\t\t\t\t\troute:\n\t\t\t\t\t\toption.fastRouteServiceTier === \"ultrafast\"\n\t\t\t\t\t\t\t? `ultrafast request for ${fastBase?.name ?? option.fastRouteOf}; base-model evidence only, no separate latency or benchmark score; account access required`\n\t\t\t\t\t\t\t: `faster route of ${fastBase?.name ?? option.fastRouteOf} with the same results; ${option.fastRoutePriced ? \"the listed prices are its Fast rates\" : \"billed above the listed prices\"}`,\n\t\t\t\t}\n\t\t\t: {}),\n\t});\n}\n"]}
1
+ {"version":3,"file":"model-routing-candidates.js","sourceRoot":"","sources":["../../src/core/model-routing-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,kBAAkB,GAGlB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EAEpB,mBAAmB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA0B,UAAU,EAAE,MAAM,0BAA0B,CAAC;AA8BjH,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,MAAM,GAAG,CAAC,EAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;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,CAAC;gBACA,KAAK,EACJ,MAAM,CAAC,oBAAoB,KAAK,WAAW;oBAC1C,CAAC,CAAC,yBAAyB,QAAQ,EAAE,IAAI,IAAI,MAAM,CAAC,WAAW,6FAA6F;oBAC5J,CAAC,CAAC,mBAAmB,QAAQ,EAAE,IAAI,IAAI,MAAM,CAAC,WAAW,2BAA2B,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,gCAAgC,EAAE;aAC1L;YACF,CAAC,CAAC,EAAE,CAAC;KACN,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\ttype BenchmarkCompletion,\n\tcompleteBenchmarks,\n\ttype Observation,\n\ttype QualityEstimate,\n} from \"./model-routing-estimates.js\";\nimport {\n\tcandidateEvidenceRows,\n\tcatalogModelIdentity,\n\ttype EvalsCatalog,\n\tmodelEvidenceTokens,\n} from \"./model-routing-evals.js\";\nimport { EFFORT_ORDER, effortForDifficulty, type ResolvedTaskNeeds, taskDemand } from \"./model-routing-needs.js\";\n\n/** What ranking needs to know about one eligible model. */\nexport interface CandidateModel {\n\t/** `provider/id`, as used in router selections. */\n\treadonly model: string;\n\treadonly name: string;\n\treadonly cost: { readonly input: number; readonly output: number };\n\treadonly input: readonly string[];\n\t/** `provider/id` of the base model when this entry is its derived fast route (`fastRoute` metadata). */\n\treadonly fastRouteOf?: string;\n\t/** Explicit provider tier, used to avoid claiming measured latency for ultrafast. */\n\treadonly fastRouteServiceTier?: \"priority\" | \"ultrafast\";\n\t/** True when `cost` already holds the route tier's published rates rather than the base model's. */\n\treadonly fastRoutePriced?: boolean;\n\t/**\n\t * Reasoning efforts the model can run at (`null` without configurable reasoning). Routing ranks the\n\t * model at the effort it would run for the task; absent, every measured effort counts alike.\n\t */\n\treadonly efforts?: readonly (string | null)[];\n}\n\ninterface Metric {\n\treadonly key: string;\n\treadonly label: string;\n\treadonly unit: \"%\" | \"\";\n\t/** How much this benchmark counts toward quality for the task; quoted results follow this order. */\n\treadonly weight: number;\n}\n\nconst percent = (key: string, label: string, weight = 1): Metric => ({ key, label, unit: \"%\", weight });\nconst points = (key: string, label: string, weight = 1): Metric => ({ key, label, unit: \"\", weight });\n\nconst OVERALL: Metric = points(\"aa:idx\", \"AA Intelligence Index\");\n\n/**\n * Weight of each long-task benchmark (DeepSWE, FrontierCode) for long coding and\n * review: together they outweigh every other benchmark of the work, so the\n * quality estimate rests mainly on them. A model without a measured result has\n * them estimated, and the estimate's uncertainty lowers its cautious quality.\n */\nconst LONG_TASK_WEIGHT = 4;\n\n/** True when the task is long implementation work: hard, very hard, or holding a large codebase in context. */\nconst longWork = (needs: ResolvedTaskNeeds) =>\n\tneeds.difficulty === \"hard\" || needs.difficulty === \"very_hard\" || needs.longContext;\n/** True when the task is short, terminal-shaped work: trivial or easy, or latency-sensitive. */\nconst shortWork = (needs: ResolvedTaskNeeds) =>\n\tneeds.difficulty === \"trivial\" || needs.difficulty === \"easy\" || needs.latencySensitive;\n\n/**\n * evals.md benchmarks that measure the task's kind of work, weighted by its\n * shape: long implementation leans on DeepSWE and FrontierCode, short terminal\n * work on Terminal-Bench 4.0, review on FrontierCode and security suites.\n */\nfunction workMetrics(needs: ResolvedTaskNeeds): Metric[] {\n\tconst long = longWork(needs);\n\tconst short = shortWork(needs) && !long;\n\tconst metrics: Metric[] = (() => {\n\t\tswitch (needs.work) {\n\t\t\tcase \"computer_use\":\n\t\t\t\treturn [\n\t\t\t\t\tpercent(\"pub:OSW2\", \"OSWorld 2.0\"),\n\t\t\t\t\tpercent(\"pub:OSW21\", \"OSWorld 2.1\"),\n\t\t\t\t\tpercent(\"pub:SSP\", \"ScreenSpot-Pro\"),\n\t\t\t\t\tpercent(\"pub:ALE\", \"Agents' Last Exam\"),\n\t\t\t\t\tpercent(\"aa:MMMU\", \"MMMU-Pro\"),\n\t\t\t\t];\n\t\t\tcase \"coding\":\n\t\t\t\treturn [\n\t\t\t\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\", short ? 2 : 1),\n\t\t\t\t\tpercent(\"dswe:Pass@1\", \"DeepSWE\", long ? LONG_TASK_WEIGHT : short ? 0.5 : 1),\n\t\t\t\t\tpercent(\"pub:DSWE\", \"DeepSWE\", long ? LONG_TASK_WEIGHT : short ? 0.5 : 1),\n\t\t\t\t\tpercent(\"fc:Main\", \"FrontierCode\", long ? LONG_TASK_WEIGHT : short ? 0.5 : 1),\n\t\t\t\t\tpercent(\"pub:FC11\", \"FrontierCode\", long ? LONG_TASK_WEIGHT : short ? 0.5 : 1),\n\t\t\t\t\tpercent(\"aa:TB21\", \"Terminal-Bench 2.1\", 0.5),\n\t\t\t\t];\n\t\t\tcase \"code_review\":\n\t\t\t\treturn [\n\t\t\t\t\tpercent(\"fc:Main\", \"FrontierCode\", long ? LONG_TASK_WEIGHT : 2),\n\t\t\t\t\tpercent(\"pub:FC11\", \"FrontierCode\", long ? LONG_TASK_WEIGHT : 2),\n\t\t\t\t\tpercent(\"pub:XGym\", \"ExploitGym\"),\n\t\t\t\t\tpercent(\"pub:SECPro\", \"SEC-Bench Pro\"),\n\t\t\t\t\tpercent(\"pub:CWE\", \"CWE-bench\"),\n\t\t\t\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\", 0.5),\n\t\t\t\t];\n\t\t\tcase \"codebase_lookup\":\n\t\t\t\treturn [\n\t\t\t\t\tpercent(\"aa:TB4\", \"Terminal-Bench 4.0\", 2),\n\t\t\t\t\tpercent(\"aa:tau2\", \"τ²-Bench\", 0.5),\n\t\t\t\t\tpercent(\"aa:IF\", \"IFBench\", 0.5),\n\t\t\t\t\tpercent(\"aa:LCR\", \"AA-LCR\", needs.longContext ? 1.5 : 0.5),\n\t\t\t\t];\n\t\t\tcase \"research\":\n\t\t\t\treturn [\n\t\t\t\t\tpercent(\"aa:HLE\", \"Humanity's Last Exam\"),\n\t\t\t\t\tpercent(\"pub:BComp\", \"BrowseComp\"),\n\t\t\t\t\tpercent(\"pub:HLEt\", \"Humanity's Last Exam with tools\"),\n\t\t\t\t\tpercent(\"aa:GPQA\", \"GPQA Diamond\"),\n\t\t\t\t\tpercent(\"aa:LCR\", \"AA-LCR\", needs.longContext ? 2 : 1),\n\t\t\t\t];\n\t\t\tcase \"business_workflow\":\n\t\t\t\treturn [\n\t\t\t\t\tpercent(\"aa:Auto\", \"AutomationBench-AA\"),\n\t\t\t\t\tpercent(\"pub:ABench\", \"AutomationBench\"),\n\t\t\t\t\tpercent(\"aa:tau2\", \"τ²-Bench\"),\n\t\t\t\t\tpercent(\"aa:Ent\", \"EnterpriseOps-Gym\"),\n\t\t\t\t];\n\t\t\tcase \"math_science\":\n\t\t\t\treturn [\n\t\t\t\t\tpercent(\"pub:FMT4\", \"FrontierMath Tier 4\"),\n\t\t\t\t\tpercent(\"pub:TBSci\", \"Terminal-Bench-Science\"),\n\t\t\t\t\tpercent(\"aa:Crit\", \"CritPt\"),\n\t\t\t\t\tpercent(\"aa:Sci\", \"SciCode\"),\n\t\t\t\t];\n\t\t\tcase \"writing\":\n\t\t\t\treturn [\n\t\t\t\t\tpercent(\"aa:IF\", \"IFBench\"),\n\t\t\t\t\tpoints(\"aa:Gn\", \"GDPval\"),\n\t\t\t\t\tpoints(\"aa:Brief\", \"AA-Briefcase\"),\n\t\t\t\t\tpercent(\"aa:LCR\", \"AA-LCR\", needs.longContext ? 2 : 1),\n\t\t\t\t];\n\t\t}\n\t})();\n\treturn metrics.sort((a, b) => b.weight - a.weight);\n}\n\n/**\n * Catalog columns that describe a run rather than a model's ability: price,\n * tokens, steps, confidence intervals, flag rates, openness, and FrontierCode's\n * pass-rate and Extended columns, which restate Main.\n */\nconst NOT_ABILITY = new Set([\n\t\"aa:Open\",\n\t\"dswe:CI\",\n\t\"dswe:Cost\",\n\t\"dswe:Out tok\",\n\t\"dswe:Steps\",\n\t\"fc:Main pass\",\n\t\"fc:Extended\",\n\t\"fc:Ext pass\",\n\t\"fc:Flag\",\n\t\"fc:Cost\",\n]);\n\n/**\n * Published benchmarks that an independent table also measures. A vendor's\n * report uses its own harness, so it is not ranked against the independent\n * results, but it is evidence about the same ability: the completion takes it\n * as a noisier observation of the independent benchmark.\n */\nconst SAME_BENCHMARK: Readonly<Record<string, string>> = {\n\t\"pub:DSWE\": \"dswe:Pass@1\",\n\t\"pub:TB4\": \"aa:TB4\",\n\t\"pub:FC11\": \"fc:Main\",\n\t\"pub:GDPpdf\": \"aa:PDF\",\n\t\"pub:HLE\": \"aa:HLE\",\n};\n\n/** A model's results as the completion sees them: its ability measurements, and published reports of the same benchmarks. */\nfunction abilityResults(values: ReadonlyMap<string, number>): {\n\tresults: Map<string, number>;\n\treported: Map<string, number>;\n} {\n\tconst results = new Map<string, number>();\n\tconst reports = new Map<string, number[]>();\n\tfor (const [key, value] of values) {\n\t\tif (NOT_ABILITY.has(key)) continue;\n\t\tresults.set(key, value);\n\t\tconst same = key.startsWith(\"pub:\") ? SAME_BENCHMARK[key.slice(0, key.lastIndexOf(\"@\"))] : undefined;\n\t\tif (same) reports.set(same, [...(reports.get(same) ?? []), value]);\n\t}\n\tconst reported = new Map([...reports].map(([key, all]) => [key, all.reduce((a, b) => a + b, 0) / all.length]));\n\treturn { results, reported };\n}\n\n/** A result reported under another harness counts as this many times noisier than a direct measurement. */\nconst REPORTED_NOISE = 2;\nconst EFFORT_WORD = /\\b(non[- ]reasoning|minimal|low|medium|high|xhigh|max)\\b/iu;\nconst EFFORT_SETTING = /\\b(non[- ]reasoning|(?:minimal|low|medium|high|xhigh|max)(?=\\s+effort))\\b/iu;\n\n/** The reasoning effort a measurement names, `off` for non-reasoning, or \"\" when it names none. */\nfunction effortLabel(text: string | undefined, pattern: RegExp = EFFORT_WORD): string {\n\tconst word = pattern.exec(text ?? \"\")?.[1]?.toLowerCase();\n\tif (word === undefined) return \"\";\n\treturn word.startsWith(\"non\") ? \"off\" : word;\n}\n\n/**\n * Position of an effort on the reasoning scale, centered on `high`. A result\n * that names no effort is taken at `high`, the setting leaderboards most often\n * report by default.\n */\nconst effortPosition = (label: string) => (EFFORT_ORDER.indexOf(label || \"high\") - EFFORT_ORDER.indexOf(\"high\")) / 2;\n\n/** A model's results at every effort it was measured at, as observations for the completion. */\nfunction observationsOf(byEffort: ReadonlyMap<string, ReadonlyMap<string, number>>, direct = false): Observation[] {\n\tconst observations: Observation[] = [];\n\tfor (const [label, values] of byEffort) {\n\t\tconst effort = effortPosition(label);\n\t\tconst { results, reported } = abilityResults(values);\n\t\tfor (const [key, value] of results) observations.push({ key, value, effort });\n\t\tif (!direct)\n\t\t\tfor (const [key, value] of reported) observations.push({ key, value, effort, noise: REPORTED_NOISE });\n\t}\n\treturn observations;\n}\n\n/** Benchmarks of long, multi-step software work: DeepSWE and FrontierCode, from their leaderboards or vendors. */\nconst LONG_TASK_BENCHMARKS = [\"dswe:Pass@1\", \"fc:Main\", \"pub:DSWE\", \"pub:FC11\"];\n\n/** True when the model has a measured long-task result; an estimate of one never counts. */\nconst hasLongTaskEvidence = (values: ReadonlyMap<string, number>) =>\n\t[...values.keys()].some((key) =>\n\t\tLONG_TASK_BENCHMARKS.some((benchmark) => key === benchmark || key.startsWith(`${benchmark}@`)),\n\t);\n\n/**\n * Hard coding and review, and long-context coding, are long tasks that short\n * benchmarks predict poorly. For them, models measured on a long-task benchmark\n * rank ahead of models that are not; the rest stay eligible behind them.\n */\nconst needsLongTaskEvidence = (needs: ResolvedTaskNeeds) =>\n\t(needs.work === \"coding\" || needs.work === \"code_review\") &&\n\t(needs.difficulty === \"hard\" || needs.difficulty === \"very_hard\" || (needs.work === \"coding\" && needs.longContext));\n\n/** Quality is ranked on the estimate minus this many standard errors, so thin evidence counts less. */\nconst CONSERVATIVE_ERRORS = 1;\n\n/** When speed matters, a fast route edges out its standard route for the model's single slot. */\nconst FAST_ROUTE_BONUS = 0.02;\n\n/** A standing is stated only when enough benchmarked models share the measurement. */\nconst MIN_RANKED_MODELS = 4;\n\nexport interface RankedCandidate extends CandidateModel {\n\t/** Identity shared by one model's providers and its derived fast route, which collapse onto it. */\n\treadonly baseKey: string;\n\treadonly score: number;\n\treadonly values: ReadonlyMap<string, number>;\n\t/** How each quoted value was measured, for example its effort, harness or reporter. */\n\treadonly conditions: ReadonlyMap<string, string>;\n\treadonly released?: string;\n\t/**\n\t * Standing among benchmarked catalog models of the conservative quality\n\t * estimate for this work, present when the model has any result in the fit.\n\t */\n\treadonly workStanding?: number;\n\treadonly overallStanding?: number;\n\t/** Quality for this work, from measured results and the completion's estimates of missing ones. */\n\treadonly estimate?: QualityEstimate;\n\t/** True when the model has a measured DeepSWE or FrontierCode result, from a leaderboard or its vendor. */\n\treadonly longTaskEvidence?: boolean;\n\t/** The effort the model is ranked at: the one routing would run it at for this task. */\n\treadonly effort?: string | null;\n\t/** Results measured at `effort`, quoted in preference to results at other efforts. */\n\treadonly effortValues?: ReadonlyMap<string, number>;\n\treadonly effortConditions?: ReadonlyMap<string, string>;\n}\n\nfunction sectionKind(intro: readonly string[]): \"aa\" | \"dswe\" | \"fc\" | \"pub\" {\n\tconst heading = intro.find((line) => line.startsWith(\"## \")) ?? \"\";\n\tif (/DeepSWE/u.test(heading)) return \"dswe\";\n\tif (/FrontierCode/u.test(heading)) return \"fc\";\n\tif (/Published/u.test(heading)) return \"pub\";\n\treturn \"aa\";\n}\n\nconst cells = (line: string) =>\n\tline\n\t\t.split(\"|\")\n\t\t.slice(1, -1)\n\t\t.map((cell) => cell.trim());\n\nconst nameWords = (text: string) => new Set(text.match(/\\p{Lu}[\\p{L}]{2,}/gu) ?? []);\n\n/**\n * The parts of a published result's setting that apply to this row: a clause\n * naming other models (for example \"Fable values are Mythos\" on a GPT row) is a\n * footnote for them and is dropped.\n */\nfunction ownSetting(setting: string, rowModel: string, modelWords: ReadonlySet<string>): string {\n\tconst own = nameWords(rowModel);\n\treturn setting\n\t\t.split(\";\")\n\t\t.map((clause) => clause.trim())\n\t\t.filter((clause) => {\n\t\t\tconst named = [...nameWords(clause)].filter((word) => modelWords.has(word));\n\t\t\treturn named.length === 0 || named.some((word) => own.has(word));\n\t\t})\n\t\t.join(\", \");\n}\n\n/** Parenthetical measurement setting in an Artificial Analysis model name, for example \"Max Effort\". */\nfunction nameCondition(name: string | undefined): string | undefined {\n\tconst setting = /\\(([^)]+)\\)\\s*$/u.exec(name ?? \"\")?.[1];\n\treturn setting && /^(?:minimal|low|medium|high|xhigh|max)$/u.test(setting) ? `${setting} effort` : setting;\n}\n\ninterface Reading {\n\treadonly key: string;\n\treadonly value: number;\n\treadonly condition?: string;\n\t/** The reasoning effort the row was measured at, or \"\" when it names none. */\n\treadonly effort: string;\n}\n\ninterface CatalogReadings {\n\t/** Readings of each catalog row, indexed by the row's `order`. */\n\treadonly rows: readonly (readonly Reading[])[];\n\t/** Per measurement, the best value of each catalog model. */\n\treadonly cohorts: ReadonlyMap<string, ReadonlyMap<string, number>>;\n\t/** Per catalog model, its results at each measured effort. */\n\treadonly models: ReadonlyMap<string, ReadonlyMap<string, ReadonlyMap<string, number>>>;\n\t/** Low-rank completion of every ability measurement, fitted on first use. */\n\tcompletion(): BenchmarkCompletion;\n\t/** Per benchmark weighting, every fitted catalog model's conservative quality, computed on first use. */\n\treadonly populations: Map<string, readonly (readonly [string, number])[]>;\n}\n\nconst readingsByCatalog = new WeakMap<EvalsCatalog, CatalogReadings>();\n\n/** Every measured value in the catalog, read once per parsed catalog. */\nfunction catalogReadings(catalog: EvalsCatalog): CatalogReadings {\n\tconst cached = readingsByCatalog.get(catalog);\n\tif (cached) return cached;\n\tconst kinds = catalog.sections.map((section) => sectionKind(section.intro));\n\tconst headers = catalog.sections.map((section) =>\n\t\tcells(section.intro.find((line) => line.startsWith(\"| slug |\")) ?? \"\"),\n\t);\n\tconst modelColumn = headers.map((header) => header.indexOf(\"Model\"));\n\tconst modelWords = catalog.sections.map((_, section) => {\n\t\tconst words = new Set<string>();\n\t\tfor (const row of catalog.rows)\n\t\t\tif (row.section === section)\n\t\t\t\tfor (const word of nameWords(cells(row.line)[modelColumn[section]!] ?? \"\")) words.add(word);\n\t\treturn words;\n\t});\n\tconst rows = catalog.rows.map((row) => {\n\t\tconst header = headers[row.section]!;\n\t\tconst rowCells = cells(row.line);\n\t\tconst column = (name: string) => (header.includes(name) ? rowCells[header.indexOf(name)] : undefined);\n\t\tconst readings: Reading[] = [];\n\t\tconst read = (key: string, raw: string | undefined, condition: string | undefined, effort: string) => {\n\t\t\tconst value = Number.parseFloat(raw ?? \"\");\n\t\t\tif (Number.isFinite(value)) readings.push({ key, value, effort, ...(condition ? { condition } : {}) });\n\t\t};\n\t\tif (kinds[row.section] === \"pub\") {\n\t\t\tconst reporter = column(\"Source\");\n\t\t\tconst setting = ownSetting(column(\"Setting\") ?? \"\", column(\"Model\") ?? \"\", modelWords[row.section]!);\n\t\t\tconst condition = [setting, reporter ? `reported by ${reporter}` : undefined].filter(Boolean).join(\", \");\n\t\t\t// Each reporter's results form their own cohort: a vendor harness and an\n\t\t\t// official leaderboard are not ranked against each other.\n\t\t\tread(\n\t\t\t\t`pub:${column(\"Benchmark\")}@${reporter ?? \"\"}`,\n\t\t\t\tcolumn(\"Score\"),\n\t\t\t\tcondition,\n\t\t\t\teffortLabel(setting, EFFORT_SETTING),\n\t\t\t);\n\t\t} else {\n\t\t\tconst effort = column(\"Effort\");\n\t\t\tconst condition = effort ? `${effort} effort` : nameCondition(column(\"Model\"));\n\t\t\tconst label = effortLabel(effort ?? /\\(([^)]+)\\)\\s*$/u.exec(column(\"Model\") ?? \"\")?.[1]);\n\t\t\tfor (const [index, name] of header.entries())\n\t\t\t\tif (index > 1 && name !== \"Effort\" && name !== \"Release date\")\n\t\t\t\t\tread(`${kinds[row.section]}:${name}`, rowCells[index], condition, label);\n\t\t}\n\t\treturn readings;\n\t});\n\tconst cohorts = new Map<string, Map<string, number>>();\n\tfor (const row of catalog.rows) {\n\t\tconst identity = catalogModelIdentity(row.tokens);\n\t\tfor (const { key, value } of rows[row.order]!) {\n\t\t\tconst cohort = cohorts.get(key) ?? new Map<string, number>();\n\t\t\tcohort.set(identity, Math.max(cohort.get(identity) ?? value, value));\n\t\t\tcohorts.set(key, cohort);\n\t\t}\n\t}\n\t// Per catalog model and effort, the best value of each measurement.\n\tconst models = new Map<string, Map<string, Map<string, number>>>();\n\tfor (const row of catalog.rows) {\n\t\tconst identity = catalogModelIdentity(row.tokens);\n\t\tconst efforts = models.get(identity) ?? new Map<string, Map<string, number>>();\n\t\tmodels.set(identity, efforts);\n\t\tfor (const { key, value, effort } of rows[row.order]!) {\n\t\t\tconst values = efforts.get(effort) ?? new Map<string, number>();\n\t\t\tvalues.set(key, Math.max(values.get(key) ?? value, value));\n\t\t\tefforts.set(effort, values);\n\t\t}\n\t}\n\tlet completion: BenchmarkCompletion | undefined;\n\tconst readings: CatalogReadings = {\n\t\trows,\n\t\tcohorts,\n\t\tmodels,\n\t\tcompletion: () => {\n\t\t\tif (completion === undefined) {\n\t\t\t\tcompletion = completeBenchmarks(\n\t\t\t\t\tnew Map([...models].map(([identity, efforts]) => [identity, observationsOf(efforts, true)])),\n\t\t\t\t\tMIN_RANKED_MODELS,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn completion;\n\t\t},\n\t\tpopulations: new Map(),\n\t};\n\treadingsByCatalog.set(catalog, readings);\n\treturn readings;\n}\n\n/**\n * Best value per metric across every evals row describing the model, with the\n * conditions it was measured under, the catalog models those rows belong to,\n * and the model's newest release date.\n */\nfunction measure(\n\tcatalog: EvalsCatalog,\n\tmodel: string,\n): {\n\tvalues: Map<string, number>;\n\tconditions: Map<string, string>;\n\tbyEffort: Map<string, Map<string, number>>;\n\teffortConditions: Map<string, Map<string, string>>;\n\tidentities: Set<string>;\n\treleased?: string;\n} {\n\tconst readings = catalogReadings(catalog);\n\tconst values = new Map<string, number>();\n\tconst conditions = new Map<string, string>();\n\tconst byEffort = new Map<string, Map<string, number>>();\n\tconst effortConditions = new Map<string, Map<string, string>>();\n\tconst identities = new Set<string>();\n\tlet released: string | undefined;\n\tconst keepBest = (\n\t\tinto: Map<string, number>,\n\t\tnotes: Map<string, string>,\n\t\tkey: string,\n\t\tvalue: number,\n\t\tcondition: string | undefined,\n\t) => {\n\t\tif (value <= (into.get(key) ?? Number.NEGATIVE_INFINITY)) return;\n\t\tinto.set(key, value);\n\t\tif (condition) notes.set(key, condition);\n\t\telse notes.delete(key);\n\t};\n\tfor (const row of candidateEvidenceRows(catalog, model)) {\n\t\tidentities.add(catalogModelIdentity(row.tokens));\n\t\tfor (const { key, value, condition, effort } of readings.rows[row.order]!) {\n\t\t\tkeepBest(values, conditions, key, value, condition);\n\t\t\tif (!byEffort.has(effort)) {\n\t\t\t\tbyEffort.set(effort, new Map());\n\t\t\t\teffortConditions.set(effort, new Map());\n\t\t\t}\n\t\t\tkeepBest(byEffort.get(effort)!, effortConditions.get(effort)!, key, value, condition);\n\t\t}\n\t\tif (row.releaseDate && (!released || row.releaseDate > released)) released = row.releaseDate;\n\t}\n\treturn { values, conditions, byEffort, effortConditions, identities, ...(released ? { released } : {}) };\n}\n\n/** Value keys measuring `metric`: the column itself, or one per reporter for published results. */\nconst cohortKeys = (values: ReadonlyMap<string, number>, metric: Metric) =>\n\t[...values.keys()].filter((key) => key === metric.key || key.startsWith(`${metric.key}@`));\n\nconst baseKey = (candidate: CandidateModel) => modelEvidenceTokens(candidate.fastRouteOf ?? candidate.model).join(\"-\");\n\nconst blended = (candidate: CandidateModel) => (3 * candidate.cost.input + candidate.cost.output) / 4;\n\n/** The weight of each of `metrics` the completion fitted. */\nfunction benchmarkWeights(completion: BenchmarkCompletion, metrics: readonly Metric[]): Map<string, number> {\n\tconst weights = new Map<string, number>();\n\tfor (const metric of metrics) {\n\t\tconst keys = [...completion.keys].filter((key) => key === metric.key || key.startsWith(`${metric.key}@`));\n\t\tfor (const key of keys) weights.set(key, (weights.get(key) ?? 0) + metric.weight / keys.length);\n\t}\n\treturn weights;\n}\n\n/** True when any of a model's observations is a benchmark the completion fitted. */\nconst fitsAny = (completion: BenchmarkCompletion, observations: readonly Observation[]) =>\n\tobservations.some((observation) => completion.keys.has(observation.key));\n\nconst conservative = (estimate: QualityEstimate) => estimate.mean - CONSERVATIVE_ERRORS * estimate.error;\n\n/**\n * Rank every eligible model for the task in code. Quality is a conservative\n * estimate for this kind of work: the model's weighted results on the work's\n * benchmarks, with missing ones estimated from all of its other results, less\n * one standard error, scaled from the weakest to the strongest candidate. A\n * model with one strong result therefore ranks below models with broader,\n * consistent evidence. The standing quoted to the router compares the same\n * estimate with every benchmarked catalog model, so it does not depend on\n * which other models are eligible. Quality is weighed against price by how\n * demanding the task is, with a small preference for newer releases.\n */\nexport function rankCandidates(\n\tcatalog: EvalsCatalog,\n\tcandidates: readonly CandidateModel[],\n\tneeds: ResolvedTaskNeeds,\n): RankedCandidate[] {\n\tconst readings = catalogReadings(catalog);\n\tconst { cohorts } = readings;\n\tconst completion = readings.completion();\n\tconst weights = benchmarkWeights(completion, workMetrics(needs));\n\tconst signature = JSON.stringify([...weights]);\n\tlet population = readings.populations.get(signature);\n\tif (population === undefined) {\n\t\t// Every catalog model at each effort it was measured at.\n\t\tpopulation = [...readings.models].flatMap(([identity, efforts]) => {\n\t\t\tconst observations = observationsOf(efforts);\n\t\t\tif (!fitsAny(completion, observations)) return [];\n\t\t\treturn [...efforts.keys()].flatMap((label) => {\n\t\t\t\tconst estimate = completion.estimate(observations, weights, effortPosition(label));\n\t\t\t\treturn estimate ? [[identity, conservative(estimate)] as const] : [];\n\t\t\t});\n\t\t});\n\t\treadings.populations.set(signature, population);\n\t}\n\tconst fitted = population;\n\tconst measured = candidates.map((candidate) => {\n\t\tconst evidence = measure(catalog, candidate.fastRouteOf ?? candidate.model);\n\t\t// The model is ranked at the effort routing would run it at for this task.\n\t\tconst effort = candidate.efforts\n\t\t\t? effortForDifficulty(candidate.efforts, needs.difficulty, needs.latencySensitive)\n\t\t\t: undefined;\n\t\t// Without known efforts, the model is ranked at the highest effort it was measured at.\n\t\tconst label =\n\t\t\teffort === undefined\n\t\t\t\t? [...evidence.byEffort.keys()].sort((a, b) => EFFORT_ORDER.indexOf(b) - EFFORT_ORDER.indexOf(a))[0]\n\t\t\t\t: (effort ?? \"\");\n\t\tconst observations = observationsOf(evidence.byEffort);\n\t\treturn {\n\t\t\tcandidate,\n\t\t\tbase: baseKey(candidate),\n\t\t\t...evidence,\n\t\t\teffort,\n\t\t\teffortValues: label === undefined ? undefined : evidence.byEffort.get(label),\n\t\t\teffortNotes: label === undefined ? undefined : evidence.effortConditions.get(label),\n\t\t\testimate: completion.estimate(observations, weights, effortPosition(label ?? \"\")),\n\t\t\t// Only a model with a result in the fit has a standing of its own; an\n\t\t\t// unbenchmarked model is ranked on the catalog-wide prior, whose wide\n\t\t\t// uncertainty keeps it below measured models.\n\t\t\tevidenced: fitsAny(completion, observations),\n\t\t};\n\t});\n\t// Quality for ranking spans the candidates being ranked: catalog standings\n\t// crowd every frontier model into the top few percent, where price would\n\t// decide, while the cautious estimates themselves still separate them.\n\tconst cautious = measured.flatMap((entry) => (entry.estimate ? [conservative(entry.estimate)] : []));\n\tconst [weakest, strongest] = [Math.min(...cautious), Math.max(...cautious)];\n\tconst relativeQuality = (estimate: QualityEstimate) =>\n\t\tstrongest > weakest ? (conservative(estimate) - weakest) / (strongest - weakest) : 1;\n\tconst rankOf = (key: string, value: number, own: ReadonlySet<string>): number | undefined => {\n\t\tconst cohort = cohorts.get(key);\n\t\tif (cohort === undefined || cohort.size < MIN_RANKED_MODELS) return undefined;\n\t\tconst others = [...cohort].filter(([identity]) => !own.has(identity)).map(([, other]) => other);\n\t\treturn others.length ? others.filter((other) => other < value).length / others.length : undefined;\n\t};\n\tconst estimateStanding = (value: number, own: ReadonlySet<string>): number | undefined => {\n\t\tif (fitted.length < MIN_RANKED_MODELS) return undefined;\n\t\tconst others = fitted.filter(([identity]) => !own.has(identity));\n\t\treturn others.length ? others.filter(([, other]) => other < value).length / others.length : undefined;\n\t};\n\tconst overallOf = (values: ReadonlyMap<string, number>, own: ReadonlySet<string>) => {\n\t\tconst ranks = cohortKeys(values, OVERALL)\n\t\t\t.map((key) => rankOf(key, values.get(key)!, own))\n\t\t\t.filter((rank): rank is number => rank !== undefined);\n\t\treturn ranks.length ? ranks.reduce((a, b) => a + b, 0) / ranks.length : undefined;\n\t};\n\tconst logPrices = measured\n\t\t.map((entry) => blended(entry.candidate))\n\t\t.filter((price) => price > 0)\n\t\t.map(Math.log);\n\tconst [low, high] = [Math.min(...logPrices), Math.max(...logPrices)];\n\tconst newest = measured\n\t\t.map((entry) => entry.released ?? \"\")\n\t\t.sort()\n\t\t.at(-1);\n\tconst demand = taskDemand(needs);\n\tconst gated = needsLongTaskEvidence(needs);\n\t// Quality is relative to the candidates, so it spans the whole range between\n\t// them even for modest tasks. Below moderate demand its weight therefore falls\n\t// with the square of demand, and an easy, low-stakes task goes to an adequate\n\t// cheaper model; from moderate demand up the weights are unchanged.\n\tconst qualityWeight = demand >= 0.5 ? 0.25 + 0.65 * demand : 0.575 * (demand / 0.5) ** 2;\n\tconst priceWeight = 0.65 - 0.65 * demand;\n\n\treturn measured\n\t\t.map(\n\t\t\t({\n\t\t\t\tcandidate,\n\t\t\t\tbase,\n\t\t\t\tvalues,\n\t\t\t\tconditions,\n\t\t\t\tidentities,\n\t\t\t\treleased,\n\t\t\t\testimate,\n\t\t\t\tevidenced,\n\t\t\t\teffort,\n\t\t\t\teffortValues,\n\t\t\t\teffortNotes,\n\t\t\t}) => {\n\t\t\t\tconst standing = estimate ? estimateStanding(conservative(estimate), identities) : undefined;\n\t\t\t\tconst workStanding = evidenced ? standing : undefined;\n\t\t\t\tconst overallStanding = overallOf(values, identities);\n\t\t\t\tconst quality =\n\t\t\t\t\testimate && standing !== undefined\n\t\t\t\t\t\t? relativeQuality(estimate)\n\t\t\t\t\t\t: overallStanding !== undefined\n\t\t\t\t\t\t\t? 0.8 * overallStanding\n\t\t\t\t\t\t\t: 0.2;\n\t\t\t\tconst price = blended(candidate);\n\t\t\t\tconst cheapness = price > 0 && high > low ? 1 - (Math.log(price) - low) / (high - low) : 1;\n\t\t\t\tconst ageDays = released && newest ? (Date.parse(newest) - Date.parse(released)) / 86_400_000 : 365;\n\t\t\t\tconst recency = 1 - Math.min(1, ageDays / 365);\n\t\t\t\treturn {\n\t\t\t\t\t...candidate,\n\t\t\t\t\tbaseKey: base,\n\t\t\t\t\tscore:\n\t\t\t\t\t\tqualityWeight * quality +\n\t\t\t\t\t\tpriceWeight * cheapness +\n\t\t\t\t\t\t0.1 * recency +\n\t\t\t\t\t\t(needs.latencySensitive && candidate.fastRouteOf && candidate.fastRouteServiceTier !== \"ultrafast\"\n\t\t\t\t\t\t\t? FAST_ROUTE_BONUS\n\t\t\t\t\t\t\t: 0),\n\t\t\t\t\tvalues,\n\t\t\t\t\tconditions,\n\t\t\t\t\t...(released ? { released } : {}),\n\t\t\t\t\t...(workStanding !== undefined ? { workStanding } : {}),\n\t\t\t\t\t...(overallStanding !== undefined ? { overallStanding } : {}),\n\t\t\t\t\t...(estimate && evidenced ? { estimate } : {}),\n\t\t\t\t\t...(effort !== undefined ? { effort } : {}),\n\t\t\t\t\t...(hasLongTaskEvidence(values) ? { longTaskEvidence: true } : {}),\n\t\t\t\t\t...(effortValues ? { effortValues } : {}),\n\t\t\t\t\t...(effortNotes ? { effortConditions: effortNotes } : {}),\n\t\t\t\t};\n\t\t\t},\n\t\t)\n\t\t.sort(\n\t\t\t(a, b) =>\n\t\t\t\tNumber(gated && !a.longTaskEvidence) - Number(gated && !b.longTaskEvidence) ||\n\t\t\t\tb.score - a.score ||\n\t\t\t\tNumber(a.fastRouteOf !== undefined) - Number(b.fastRouteOf !== undefined) ||\n\t\t\t\ta.model.localeCompare(b.model),\n\t\t);\n}\n\n/** The best `size` candidates with at most one per base model. */\nexport function distinctTop(ranked: readonly RankedCandidate[], size: number): RankedCandidate[] {\n\tconst seen = new Set<string>();\n\tconst top: RankedCandidate[] = [];\n\tfor (const candidate of ranked) {\n\t\tif (seen.has(candidate.baseKey)) continue;\n\t\tseen.add(candidate.baseKey);\n\t\ttop.push(candidate);\n\t\tif (top.length === size) break;\n\t}\n\treturn top;\n}\n\nfunction standingLabel(fraction: number): string {\n\tif (fraction >= 0.9) return \"top 10%\";\n\tif (fraction >= 0.75) return \"top quarter\";\n\tif (fraction >= 0.5) return \"above median\";\n\tif (fraction >= 0.25) return \"below median\";\n\treturn \"bottom quarter\";\n}\n\nconst round = (value: number) => Number(value.toFixed(1));\n\nconst money = (value: number) => `$${Number(value.toPrecision(3))}`;\n\n/**\n * One shortlisted option described with its own evidence, so the router compares\n * options directly: release date, price tier, image input, and results for this\n * kind of work and overall. The work standing compares the conservative\n * quality estimate with every benchmarked catalog model's, and says which\n * results are measured and which are estimated from the model's other results.\n */\nexport function describeOption(\n\toption: RankedCandidate,\n\tneeds: ResolvedTaskNeeds,\n\teligible: readonly RankedCandidate[],\n): string {\n\tconst prices = eligible.map(blended).sort((a, b) => a - b);\n\tconst position = prices.filter((other) => other < blended(option)).length / Math.max(1, prices.length - 1);\n\tconst tier = position < 1 / 3 ? \"low\" : position < 2 / 3 ? \"mid\" : \"high\";\n\tconst newest = eligible\n\t\t.map((candidate) => candidate.released ?? \"\")\n\t\t.sort()\n\t\t.at(-1);\n\t// Work results at the effort the model is ranked at take the place of its best results at\n\t// other efforts; the overall result stays the best one, which its standing describes.\n\tinterface Source {\n\t\treadonly values: ReadonlyMap<string, number>;\n\t\treadonly notes: ReadonlyMap<string, string>;\n\t}\n\tconst best: Source = { values: option.values, notes: option.conditions };\n\tconst atEffort: Source = {\n\t\tvalues: new Map([...option.values, ...(option.effortValues ?? [])]),\n\t\tnotes: new Map([...option.conditions, ...(option.effortConditions ?? [])]),\n\t};\n\tconst measuredOf = (metrics: readonly Metric[], source: Source) =>\n\t\tmetrics\n\t\t\t.map((metric) => {\n\t\t\t\tconst keys = cohortKeys(source.values, metric);\n\t\t\t\tconst top = keys.sort((a, b) => source.values.get(b)! - source.values.get(a)!)[0];\n\t\t\t\treturn top === undefined ? undefined : { metric, key: top };\n\t\t\t})\n\t\t\t.filter((entry) => entry !== undefined);\n\tconst results = (metrics: readonly Metric[], source: Source, count = 2) =>\n\t\tmeasuredOf(metrics, source)\n\t\t\t.slice(0, count)\n\t\t\t.map(({ metric, key }) => {\n\t\t\t\tconst condition = source.notes.get(key);\n\t\t\t\treturn `${metric.label} ${source.values.get(key)}${metric.unit}${condition ? ` measured with ${condition}` : \"\"}`;\n\t\t\t})\n\t\t\t.join(\"; \");\n\tconst quote = (metrics: readonly Metric[], standing: number | undefined, source: Source) => {\n\t\tconst measured = results(metrics, source);\n\t\tif (!measured) return \"no published results\";\n\t\treturn `${standing === undefined ? \"measured\" : `${standingLabel(standing)} of models with the same benchmark and source`} (${measured})`;\n\t};\n\tconst metrics = workMetrics(needs);\n\tconst work = () => {\n\t\tconst { estimate, workStanding } = option;\n\t\tif (estimate === undefined || workStanding === undefined) return quote(metrics, undefined, atEffort);\n\t\tconst measured = results(metrics, atEffort, 3);\n\t\tconst quotedLabels = new Set(measuredOf(metrics, atEffort).map(({ metric }) => metric.label));\n\t\tconst estimated = metrics\n\t\t\t.flatMap((metric) =>\n\t\t\t\testimate.estimated\n\t\t\t\t\t.filter((result) => result.key === metric.key || result.key.startsWith(`${metric.key}@`))\n\t\t\t\t\t.map((result) => ({ metric, result })),\n\t\t\t)\n\t\t\t.filter(\n\t\t\t\t({ metric }, index, all) =>\n\t\t\t\t\t!quotedLabels.has(metric.label) &&\n\t\t\t\t\tall.findIndex((entry) => entry.metric.label === metric.label) === index,\n\t\t\t)\n\t\t\t.slice(0, 2)\n\t\t\t.map(\n\t\t\t\t({ metric, result }) =>\n\t\t\t\t\t`${metric.label} about ${round(result.value)}${metric.unit} ± ${round(result.error)}${metric.unit === \"%\" ? \" points\" : \"\"}`,\n\t\t\t)\n\t\t\t.join(\"; \");\n\t\tconst parts = [\n\t\t\tmeasured ? `measured: ${measured}` : \"no result measured for this work\",\n\t\t\t...(estimated ? [`estimated from its other results, not measured: ${estimated}`] : []),\n\t\t];\n\t\tconst at = typeof option.effort === \"string\" ? ` at ${option.effort} effort` : \"\";\n\t\treturn `${standingLabel(workStanding)} of benchmarked models on a cautious estimate for this work${at}, above ${round(100 * workStanding)}% of them (${parts.join(\"; \")})`;\n\t};\n\tlet released = \"unknown\";\n\tif (option.released) {\n\t\tconst months = newest ? Math.round((Date.parse(newest) - Date.parse(option.released)) / (30.44 * 86_400_000)) : 0;\n\t\treleased =\n\t\t\tmonths <= 1\n\t\t\t\t? `${option.released}, among the newest`\n\t\t\t\t: `${option.released}, ${months} months older than the newest`;\n\t}\n\tconst fastBase = option.fastRouteOf\n\t\t? eligible.find((candidate) => candidate.model === option.fastRouteOf)\n\t\t: undefined;\n\treturn JSON.stringify({\n\t\tmodel: option.name,\n\t\tid: option.model,\n\t\treleased,\n\t\tprice: `${tier}: ${money(option.cost.input)} / ${money(option.cost.output)} per million tokens`,\n\t\treads_images: option.input.includes(\"image\"),\n\t\t[needs.work]: work(),\n\t\toverall: quote([OVERALL], option.overallStanding, best),\n\t\t...(option.fastRouteOf\n\t\t\t? {\n\t\t\t\t\troute:\n\t\t\t\t\t\toption.fastRouteServiceTier === \"ultrafast\"\n\t\t\t\t\t\t\t? `ultrafast request for ${fastBase?.name ?? option.fastRouteOf}; base-model evidence only, no separate latency or benchmark score; account access required`\n\t\t\t\t\t\t\t: `faster route of ${fastBase?.name ?? option.fastRouteOf} with the same results; ${option.fastRoutePriced ? \"the listed prices are its Fast rates\" : \"billed above the listed prices\"}`,\n\t\t\t\t}\n\t\t\t: {}),\n\t});\n}\n"]}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Low-rank completion of the benchmark table in `evals.md`.
3
+ *
4
+ * Benchmarks are strongly correlated, so a model's missing results can be
5
+ * estimated from the results it has. Each benchmark (column) is standardized
6
+ * to z-scores over the measured results, and the partially observed
7
+ * (model, reasoning effort) × benchmark matrix is factored with regularized
8
+ * alternating least squares. A row is one model at one effort; its factor is
9
+ * `a + t·b`, where `t` is the effort's position on the reasoning scale and
10
+ * `a`, `b` belong to the model, so every effort of a model, measured or not,
11
+ * shares its evidence: rows the catalog never measured are interpolated from
12
+ * the model's measured efforts and the effort trend of other models. The
13
+ * benchmark factors, the residual variance and the spread of model factors
14
+ * then define a Gaussian model: a model's factors have the empirical prior of
15
+ * the catalog's models, and its own results update that prior by Bayesian
16
+ * linear regression. The posterior gives every
17
+ * result, measured or missing, a mean and a variance, so a model measured on
18
+ * one benchmark carries more uncertainty than one measured on many, and one
19
+ * outlying result moves the estimate only as far as the model's other results
20
+ * support. Estimates stay within the range measured results span.
21
+ *
22
+ * Everything is deterministic: a fixed-seed initialization and a fixed number
23
+ * of sweeps. A fit over the shipped catalog takes tens of milliseconds and runs
24
+ * once per parsed catalog.
25
+ */
26
+ /** One result a model has for a benchmark. */
27
+ export interface Observation {
28
+ readonly key: string;
29
+ readonly value: number;
30
+ /** Position of the result's reasoning effort on the effort scale. */
31
+ readonly effort: number;
32
+ /** Multiple of the residual variance this result carries; 1, the default, is a direct measurement. */
33
+ readonly noise?: number;
34
+ }
35
+ /** A model's estimated result on one benchmark, in the benchmark's own unit. */
36
+ export interface EstimatedResult {
37
+ readonly key: string;
38
+ readonly value: number;
39
+ /** Standard error of `value`, in the benchmark's own unit. */
40
+ readonly error: number;
41
+ }
42
+ /** A model's estimated quality for one weighting of benchmarks. */
43
+ export interface QualityEstimate {
44
+ /** Weighted mean z-score over the weighted benchmarks at the requested effort. */
45
+ readonly mean: number;
46
+ /** Standard error of `mean`. */
47
+ readonly error: number;
48
+ /** Weighted benchmarks the model has a direct result for at the requested effort. */
49
+ readonly measured: readonly string[];
50
+ /** Weighted benchmarks the model lacks at the requested effort, with the completion's estimate. */
51
+ readonly estimated: readonly EstimatedResult[];
52
+ }
53
+ /** The fitted completion for one catalog. */
54
+ export interface BenchmarkCompletion {
55
+ /** Benchmarks with enough results to take part in the fit. */
56
+ readonly keys: ReadonlySet<string>;
57
+ /**
58
+ * Estimate quality at `effort` from a model's own results under
59
+ * per-benchmark `weights`. An observation with `noise` above 1, such as a
60
+ * result reported under another harness, carries that many times the
61
+ * residual variance and is not counted as measured.
62
+ */
63
+ estimate(observations: readonly Observation[], weights: ReadonlyMap<string, number>, effort: number): QualityEstimate | undefined;
64
+ }
65
+ /**
66
+ * Fit the completion to each catalog model's direct results. Benchmarks
67
+ * measured on fewer than `minModels` models, or without spread, are left out.
68
+ */
69
+ export declare function completeBenchmarks(models: ReadonlyMap<string, readonly Observation[]>, minModels: number): BenchmarkCompletion;
70
+ //# sourceMappingURL=model-routing-estimates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-routing-estimates.d.ts","sourceRoot":"","sources":["../../src/core/model-routing-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAwEH,8CAA8C;AAC9C,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sGAAsG;IACtG,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,mGAAmG;IACnG,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;CAC/C;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IACnC,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CACP,YAAY,EAAE,SAAS,WAAW,EAAE,EACpC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,MAAM,EAAE,MAAM,GACZ,eAAe,GAAG,SAAS,CAAC;CAC/B;AAYD;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,EACnD,SAAS,EAAE,MAAM,GACf,mBAAmB,CAoKrB"}
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Low-rank completion of the benchmark table in `evals.md`.
3
+ *
4
+ * Benchmarks are strongly correlated, so a model's missing results can be
5
+ * estimated from the results it has. Each benchmark (column) is standardized
6
+ * to z-scores over the measured results, and the partially observed
7
+ * (model, reasoning effort) × benchmark matrix is factored with regularized
8
+ * alternating least squares. A row is one model at one effort; its factor is
9
+ * `a + t·b`, where `t` is the effort's position on the reasoning scale and
10
+ * `a`, `b` belong to the model, so every effort of a model, measured or not,
11
+ * shares its evidence: rows the catalog never measured are interpolated from
12
+ * the model's measured efforts and the effort trend of other models. The
13
+ * benchmark factors, the residual variance and the spread of model factors
14
+ * then define a Gaussian model: a model's factors have the empirical prior of
15
+ * the catalog's models, and its own results update that prior by Bayesian
16
+ * linear regression. The posterior gives every
17
+ * result, measured or missing, a mean and a variance, so a model measured on
18
+ * one benchmark carries more uncertainty than one measured on many, and one
19
+ * outlying result moves the estimate only as far as the model's other results
20
+ * support. Estimates stay within the range measured results span.
21
+ *
22
+ * Everything is deterministic: a fixed-seed initialization and a fixed number
23
+ * of sweeps. A fit over the shipped catalog takes tens of milliseconds and runs
24
+ * once per parsed catalog.
25
+ */
26
+ /** Latent dimensions of the fit. Rank 3 predicts held-out results about as well as larger ranks. */
27
+ const RANK = 3;
28
+ /** Ridge penalty on factors during alternating least squares. */
29
+ const RIDGE = 1;
30
+ const SWEEPS = 60;
31
+ const SEED = 0x4689;
32
+ /** Floor on the residual variance, in squared z units, so in-sample fit never claims certainty. */
33
+ const MIN_RESIDUAL_VARIANCE = 0.05;
34
+ /** Deterministic standard normal draws (mulberry32 with Box-Muller). */
35
+ function normalSource(seed) {
36
+ let state = seed >>> 0;
37
+ const uniform = () => {
38
+ state = (state + 0x6d2b79f5) >>> 0;
39
+ let t = state;
40
+ t = Math.imul(t ^ (t >>> 15), t | 1);
41
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
42
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
43
+ };
44
+ return () => Math.sqrt(-2 * Math.log(1 - uniform())) * Math.cos(2 * Math.PI * uniform());
45
+ }
46
+ const zeros = (size) => new Array(size).fill(0);
47
+ const identity = (size, scale = 1) => Array.from({ length: size }, (_, row) => Array.from({ length: size }, (_, col) => (row === col ? scale : 0)));
48
+ const dot = (a, b) => a.reduce((sum, value, index) => sum + value * b[index], 0);
49
+ /** Solve `A x = b` for a small symmetric positive-definite `A` by Gaussian elimination with partial pivoting. */
50
+ function solve(matrix, rhs) {
51
+ const size = rhs.length;
52
+ const a = matrix.map((row, index) => [...row, rhs[index]]);
53
+ for (let col = 0; col < size; col++) {
54
+ let pivot = col;
55
+ for (let row = col + 1; row < size; row++)
56
+ if (Math.abs(a[row][col]) > Math.abs(a[pivot][col]))
57
+ pivot = row;
58
+ [a[col], a[pivot]] = [a[pivot], a[col]];
59
+ const lead = a[col][col];
60
+ for (let row = 0; row < size; row++) {
61
+ if (row === col)
62
+ continue;
63
+ const factor = a[row][col] / lead;
64
+ for (let k = col; k <= size; k++)
65
+ a[row][k] -= factor * a[col][k];
66
+ }
67
+ }
68
+ return a.map((row, index) => row[size] / row[index]);
69
+ }
70
+ const inverse = (matrix) => {
71
+ const columns = identity(matrix.length).map((unit) => solve(matrix, unit));
72
+ return matrix.map((_, row) => columns.map((column) => column[row]));
73
+ };
74
+ /** `Σ_k x_k x_kᵀ + diag`, the normal-equation matrix of a ridge regression. */
75
+ function gram(vectors, diagonal) {
76
+ const result = diagonal.map((row) => [...row]);
77
+ for (const vector of vectors)
78
+ for (let i = 0; i < vector.length; i++)
79
+ for (let j = 0; j < vector.length; j++)
80
+ result[i][j] += vector[i] * vector[j];
81
+ return result;
82
+ }
83
+ function ridgeFit(features, targets, size) {
84
+ const rhs = zeros(size);
85
+ features.forEach((feature, index) => {
86
+ for (let k = 0; k < size; k++)
87
+ rhs[k] += feature[k] * targets[index];
88
+ });
89
+ return solve(gram(features, identity(size, RIDGE)), rhs);
90
+ }
91
+ /** Regression features of one entry for a model's factors `[a, b]`: the benchmark loading, and it scaled by effort. */
92
+ const features = (loading, effort) => [...loading, ...loading.map((x) => x * effort)];
93
+ /**
94
+ * Fit the completion to each catalog model's direct results. Benchmarks
95
+ * measured on fewer than `minModels` models, or without spread, are left out.
96
+ */
97
+ export function completeBenchmarks(models, minModels) {
98
+ const byKey = new Map();
99
+ for (const [model, observations] of models)
100
+ for (const { key, value } of observations) {
101
+ const entry = byKey.get(key) ?? { values: [], models: new Set() };
102
+ entry.values.push(value);
103
+ entry.models.add(model);
104
+ byKey.set(key, entry);
105
+ }
106
+ const keys = [];
107
+ const center = [];
108
+ const scale = [];
109
+ const low = [];
110
+ const high = [];
111
+ for (const [key, { values, models: measured }] of byKey) {
112
+ if (measured.size < minModels)
113
+ continue;
114
+ const mean = values.reduce((a, b) => a + b, 0) / values.length;
115
+ const sd = Math.sqrt(values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / values.length);
116
+ if (!(sd > 0))
117
+ continue;
118
+ keys.push(key);
119
+ center.push(mean);
120
+ scale.push(sd);
121
+ low.push((Math.min(...values) - mean) / sd);
122
+ high.push((Math.max(...values) - mean) / sd);
123
+ }
124
+ const column = new Map(keys.map((key, index) => [key, index]));
125
+ const z = (key, value) => {
126
+ const index = column.get(key);
127
+ return (value - center[index]) / scale[index];
128
+ };
129
+ const toEntries = (observations) => observations
130
+ .filter((observation) => column.has(observation.key))
131
+ .map((observation) => ({
132
+ column: column.get(observation.key),
133
+ z: z(observation.key, observation.value),
134
+ effort: observation.effort,
135
+ noise: observation.noise ?? 1,
136
+ }));
137
+ const rows = [...models.values()].map(toEntries).filter((entries) => entries.length > 0);
138
+ const byColumn = keys.map(() => []);
139
+ rows.forEach((entries, row) => {
140
+ for (const entry of entries)
141
+ byColumn[entry.column].push({ row, entry });
142
+ });
143
+ const size = 2 * RANK;
144
+ const draw = normalSource(SEED);
145
+ const u = rows.map(() => Array.from({ length: size }, () => 0.1 * draw()));
146
+ const v = keys.map(() => Array.from({ length: RANK }, () => 0.1 * draw()));
147
+ /** A model's factor at one effort: `a + t·b`. */
148
+ const at = (factors, effort) => Array.from({ length: RANK }, (_, k) => factors[k] + effort * factors[RANK + k]);
149
+ for (let sweep = 0; sweep < SWEEPS && keys.length > 0; sweep++) {
150
+ rows.forEach((entries, row) => {
151
+ u[row] = ridgeFit(entries.map((entry) => features(v[entry.column], entry.effort)), entries.map((entry) => entry.z), size);
152
+ });
153
+ byColumn.forEach((entries, col) => {
154
+ v[col] = ridgeFit(entries.map(({ row, entry }) => at(u[row], entry.effort)), entries.map(({ entry }) => entry.z), RANK);
155
+ });
156
+ }
157
+ // Empirical prior of a model's factors: the mean and covariance of the fitted model factors.
158
+ const priorMean = zeros(size);
159
+ for (const factor of u)
160
+ for (let k = 0; k < size; k++)
161
+ priorMean[k] += factor[k] / Math.max(1, u.length);
162
+ const priorCovariance = identity(size, 1e-6);
163
+ for (const factor of u)
164
+ for (let i = 0; i < size; i++)
165
+ for (let j = 0; j < size; j++)
166
+ priorCovariance[i][j] +=
167
+ ((factor[i] - priorMean[i]) * (factor[j] - priorMean[j])) / Math.max(1, u.length - 1);
168
+ const priorPrecision = inverse(priorCovariance);
169
+ const priorShift = priorPrecision.map((row) => dot(row, priorMean));
170
+ /** Posterior mean and covariance of a model's factors given its standardized results. */
171
+ const posterior = (entries, residual) => {
172
+ const precision = gram(entries.map((entry) => features(v[entry.column], entry.effort).map((x) => x / Math.sqrt(residual * entry.noise))), priorPrecision);
173
+ const shift = [...priorShift];
174
+ for (const entry of entries) {
175
+ const feature = features(v[entry.column], entry.effort);
176
+ for (let k = 0; k < size; k++)
177
+ shift[k] += (feature[k] * entry.z) / (residual * entry.noise);
178
+ }
179
+ const covariance = inverse(precision);
180
+ return { factor: covariance.map((row) => dot(row, shift)), covariance };
181
+ };
182
+ const quadratic = (covariance, vector) => dot(vector, covariance.map((row) => dot(row, vector)));
183
+ // Residual variance from leave-one-out predictions, which unlike the in-sample
184
+ // fit do not reward a model for matching the result it was fitted to. Each
185
+ // left-out residual is the in-sample one inflated by the result's leverage.
186
+ let residual = 1;
187
+ for (let pass = 0; pass < 3 && keys.length > 0; pass++) {
188
+ let squared = 0;
189
+ let count = 0;
190
+ for (const entries of rows) {
191
+ const { factor, covariance } = posterior(entries, residual);
192
+ for (const entry of entries) {
193
+ const feature = features(v[entry.column], entry.effort);
194
+ const leverage = Math.min(0.99, quadratic(covariance, feature) / residual);
195
+ squared += ((entry.z - dot(factor, feature)) / (1 - leverage)) ** 2;
196
+ count++;
197
+ }
198
+ }
199
+ residual = Math.max(MIN_RESIDUAL_VARIANCE, count ? squared / count : 1);
200
+ }
201
+ return {
202
+ keys: new Set(keys),
203
+ estimate(observations, weights, effort) {
204
+ const weighted = [...weights].filter(([key, weight]) => weight > 0 && column.has(key));
205
+ const total = weighted.reduce((sum, [, weight]) => sum + weight, 0);
206
+ if (total === 0)
207
+ return undefined;
208
+ const entries = toEntries(observations);
209
+ const { factor, covariance } = posterior(entries, residual);
210
+ const direct = new Set(entries.filter((entry) => entry.noise === 1 && entry.effort === effort).map((entry) => keys[entry.column]));
211
+ // Quality is the model's inferred ability on each weighted benchmark at
212
+ // this effort: a measured result is weighed with everything else the
213
+ // model scored, so one outlying result moves the estimate only as far as
214
+ // the rest supports. Estimates stay within the range measured results span.
215
+ let sum = 0;
216
+ let missingNoise = 0;
217
+ const direction = zeros(size);
218
+ const measured = [];
219
+ const estimated = [];
220
+ for (const [key, weight] of weighted) {
221
+ const index = column.get(key);
222
+ const feature = features(v[index], effort);
223
+ const ability = Math.min(high[index], Math.max(low[index], dot(factor, feature)));
224
+ sum += weight * ability;
225
+ for (let k = 0; k < size; k++)
226
+ direction[k] += weight * feature[k];
227
+ if (direct.has(key)) {
228
+ measured.push(key);
229
+ continue;
230
+ }
231
+ // A result nobody measured also varies from the model's ability by the residual.
232
+ missingNoise += weight * weight * residual;
233
+ estimated.push({
234
+ key,
235
+ value: center[index] + ability * scale[index],
236
+ error: Math.sqrt(quadratic(covariance, feature) + residual) * scale[index],
237
+ });
238
+ }
239
+ const variance = quadratic(covariance, direction) + missingNoise;
240
+ return { mean: sum / total, error: Math.sqrt(variance) / total, measured, estimated };
241
+ },
242
+ };
243
+ }
244
+ //# sourceMappingURL=model-routing-estimates.js.map