@bastani/atomic 0.9.80 → 0.9.81

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 (150) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +16 -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 +25 -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 +25 -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/tasks/supervisor.d.ts +1 -1
  66. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  67. package/dist/core/tasks/supervisor.js.map +1 -1
  68. package/dist/core/tools/find.d.ts.map +1 -1
  69. package/dist/core/tools/find.js +20 -11
  70. package/dist/core/tools/find.js.map +1 -1
  71. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  72. package/dist/core/tools/output-accumulator.js +2 -1
  73. package/dist/core/tools/output-accumulator.js.map +1 -1
  74. package/dist/index.d.ts +1 -1
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js.map +1 -1
  77. package/dist/main.d.ts.map +1 -1
  78. package/dist/main.js +30 -10
  79. package/dist/main.js.map +1 -1
  80. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +5 -0
  81. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  82. package/dist/modes/interactive/components/chat-session-host-actions.js +86 -9
  83. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  84. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  85. package/dist/modes/interactive/components/chat-session-host-events.js +6 -3
  86. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  87. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  88. package/dist/modes/interactive/components/chat-session-host-rendering.js +5 -2
  89. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  90. package/dist/modes/interactive/components/chat-session-host-state.d.ts +5 -0
  91. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  92. package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
  93. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  94. package/dist/modes/interactive/components/footer.d.ts +4 -2
  95. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  96. package/dist/modes/interactive/components/footer.js +11 -4
  97. package/dist/modes/interactive/components/footer.js.map +1 -1
  98. package/dist/modes/interactive/components/session-selector-list.d.ts +4 -1
  99. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  100. package/dist/modes/interactive/components/session-selector-list.js +24 -1
  101. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  102. package/dist/modes/interactive/components/session-selector.d.ts +1 -0
  103. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  104. package/dist/modes/interactive/components/session-selector.js +29 -36
  105. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  106. package/dist/modes/interactive/interactive-agent-events.js +6 -6
  107. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  108. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  109. package/dist/modes/interactive/interactive-deferred-startup.js +11 -3
  110. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  111. package/dist/modes/interactive/interactive-input-handling.js +11 -1
  112. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  113. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  114. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  115. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  116. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  117. package/dist/modes/interactive/interactive-process-lifecycle.js +34 -7
  118. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  119. package/dist/modes/interactive/interactive-queueing.d.ts +24 -0
  120. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  121. package/dist/modes/interactive/interactive-queueing.js +61 -0
  122. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  123. package/dist/modes/interactive/interactive-render-chat.js +2 -3
  124. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  125. package/dist/modes/interactive/interactive-slash-commands.js +2 -2
  126. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  127. package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
  128. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  129. package/dist/modes/interactive-engine/isolated-runtime.js +10 -0
  130. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  131. package/dist/modes/rpc/rpc-mode.d.ts +2 -0
  132. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  133. package/dist/modes/rpc/rpc-mode.js +1 -0
  134. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  135. package/dist/modes/rpc/rpc-session-binding.d.ts +3 -1
  136. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  137. package/dist/modes/rpc/rpc-session-binding.js +4 -1
  138. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  139. package/docs/background-tasks.md +2 -2
  140. package/docs/extensions/api-reference.md +1 -1
  141. package/docs/models/model-selection.md +7 -7
  142. package/docs/providers.md +12 -17
  143. package/docs/skills.md +1 -1
  144. package/docs/subagents.md +3 -1
  145. package/docs/tools.md +1 -1
  146. package/docs/usage.md +1 -1
  147. package/docs/workflows/authoring.md +2 -0
  148. package/docs/workflows/operations.md +1 -1
  149. package/npm-shrinkwrap.json +57 -33
  150. package/package.json +3 -3
@@ -1,59 +1,185 @@
1
+ import { completeBenchmarks, } from "./model-routing-estimates.js";
1
2
  import { candidateEvidenceRows, catalogModelIdentity, modelEvidenceTokens, } from "./model-routing-evals.js";
2
- import { taskDemand } from "./model-routing-needs.js";
3
- const percent = (key, label) => ({ key, label, unit: "%" });
4
- const points = (key, label) => ({ key, label, unit: "" });
3
+ import { EFFORT_ORDER, effortForDifficulty, taskDemand } from "./model-routing-needs.js";
4
+ const percent = (key, label, weight = 1) => ({ key, label, unit: "%", weight });
5
+ const points = (key, label, weight = 1) => ({ key, label, unit: "", weight });
5
6
  const OVERALL = points("aa:idx", "AA Intelligence Index");
6
- /** evals.md columns that measure each kind of work, in the order results are quoted. */
7
- const WORK_METRICS = {
8
- computer_use: [
9
- percent("pub:OSW2", "OSWorld 2.0"),
10
- percent("pub:SSP", "ScreenSpot-Pro"),
11
- percent("pub:ALE", "Agents' Last Exam"),
12
- percent("aa:MMMU", "MMMU-Pro"),
13
- ],
14
- coding: [
15
- percent("aa:TB4", "Terminal-Bench 4.0"),
16
- percent("dswe:Pass@1", "DeepSWE"),
17
- percent("pub:DSWE", "DeepSWE"),
18
- percent("fc:Main", "FrontierCode"),
19
- percent("aa:TB21", "Terminal-Bench 2.1"),
20
- ],
21
- code_review: [
22
- percent("fc:Main", "FrontierCode"),
23
- percent("aa:TB4", "Terminal-Bench 4.0"),
24
- percent("pub:XGym", "ExploitGym"),
25
- percent("pub:SECPro", "SEC-Bench Pro"),
26
- ],
27
- codebase_lookup: [
28
- percent("aa:TB4", "Terminal-Bench 4.0"),
29
- percent("aa:tau2", "τ²-Bench"),
30
- percent("aa:IF", "IFBench"),
31
- ],
32
- research: [
33
- percent("aa:HLE", "Humanity's Last Exam"),
34
- percent("pub:BComp", "BrowseComp"),
35
- percent("aa:GPQA", "GPQA Diamond"),
36
- percent("aa:LCR", "AA-LCR"),
37
- ],
38
- business_workflow: [
39
- percent("aa:Auto", "AutomationBench-AA"),
40
- percent("pub:ABench", "AutomationBench"),
41
- percent("aa:tau2", "τ²-Bench"),
42
- percent("aa:Ent", "EnterpriseOps-Gym"),
43
- ],
44
- math_science: [
45
- percent("pub:FMT4", "FrontierMath Tier 4"),
46
- percent("pub:TBSci", "Terminal-Bench-Science"),
47
- percent("aa:Crit", "CritPt"),
48
- percent("aa:Sci", "SciCode"),
49
- ],
50
- writing: [
51
- percent("aa:IF", "IFBench"),
52
- points("aa:Gn", "GDPval"),
53
- points("aa:Brief", "AA-Briefcase"),
54
- percent("aa:LCR", "AA-LCR"),
55
- ],
7
+ /**
8
+ * Weight of each long-task benchmark (DeepSWE, FrontierCode) for long coding and
9
+ * review: together they outweigh every other benchmark of the work, so the
10
+ * quality estimate rests mainly on them. A model without a measured result has
11
+ * them estimated, and the estimate's uncertainty lowers its cautious quality.
12
+ */
13
+ const LONG_TASK_WEIGHT = 4;
14
+ /** True when the task is long implementation work: hard, very hard, or holding a large codebase in context. */
15
+ const longWork = (needs) => needs.difficulty === "hard" || needs.difficulty === "very_hard" || needs.longContext;
16
+ /** True when the task is short, terminal-shaped work: trivial or easy, or latency-sensitive. */
17
+ const shortWork = (needs) => needs.difficulty === "trivial" || needs.difficulty === "easy" || needs.latencySensitive;
18
+ /**
19
+ * evals.md benchmarks that measure the task's kind of work, weighted by its
20
+ * shape: long implementation leans on DeepSWE and FrontierCode, short terminal
21
+ * work on Terminal-Bench 4.0, review on FrontierCode and security suites.
22
+ */
23
+ function workMetrics(needs) {
24
+ const long = longWork(needs);
25
+ const short = shortWork(needs) && !long;
26
+ const metrics = (() => {
27
+ switch (needs.work) {
28
+ case "computer_use":
29
+ return [
30
+ percent("pub:OSW2", "OSWorld 2.0"),
31
+ percent("pub:OSW21", "OSWorld 2.1"),
32
+ percent("pub:SSP", "ScreenSpot-Pro"),
33
+ percent("pub:ALE", "Agents' Last Exam"),
34
+ percent("aa:MMMU", "MMMU-Pro"),
35
+ ];
36
+ case "coding":
37
+ return [
38
+ percent("aa:TB4", "Terminal-Bench 4.0", short ? 2 : 1),
39
+ percent("dswe:Pass@1", "DeepSWE", long ? LONG_TASK_WEIGHT : short ? 0.5 : 1),
40
+ percent("pub:DSWE", "DeepSWE", long ? LONG_TASK_WEIGHT : short ? 0.5 : 1),
41
+ percent("fc:Main", "FrontierCode", long ? LONG_TASK_WEIGHT : short ? 0.5 : 1),
42
+ percent("pub:FC11", "FrontierCode", long ? LONG_TASK_WEIGHT : short ? 0.5 : 1),
43
+ percent("aa:TB21", "Terminal-Bench 2.1", 0.5),
44
+ ];
45
+ case "code_review":
46
+ return [
47
+ percent("fc:Main", "FrontierCode", long ? LONG_TASK_WEIGHT : 2),
48
+ percent("pub:FC11", "FrontierCode", long ? LONG_TASK_WEIGHT : 2),
49
+ percent("pub:XGym", "ExploitGym"),
50
+ percent("pub:SECPro", "SEC-Bench Pro"),
51
+ percent("pub:CWE", "CWE-bench"),
52
+ percent("aa:TB4", "Terminal-Bench 4.0", 0.5),
53
+ ];
54
+ case "codebase_lookup":
55
+ return [
56
+ percent("aa:TB4", "Terminal-Bench 4.0", 2),
57
+ percent("aa:tau2", "τ²-Bench", 0.5),
58
+ percent("aa:IF", "IFBench", 0.5),
59
+ percent("aa:LCR", "AA-LCR", needs.longContext ? 1.5 : 0.5),
60
+ ];
61
+ case "research":
62
+ return [
63
+ percent("aa:HLE", "Humanity's Last Exam"),
64
+ percent("pub:BComp", "BrowseComp"),
65
+ percent("pub:HLEt", "Humanity's Last Exam with tools"),
66
+ percent("aa:GPQA", "GPQA Diamond"),
67
+ percent("aa:LCR", "AA-LCR", needs.longContext ? 2 : 1),
68
+ ];
69
+ case "business_workflow":
70
+ return [
71
+ percent("aa:Auto", "AutomationBench-AA"),
72
+ percent("pub:ABench", "AutomationBench"),
73
+ percent("aa:tau2", "τ²-Bench"),
74
+ percent("aa:Ent", "EnterpriseOps-Gym"),
75
+ ];
76
+ case "math_science":
77
+ return [
78
+ percent("pub:FMT4", "FrontierMath Tier 4"),
79
+ percent("pub:TBSci", "Terminal-Bench-Science"),
80
+ percent("aa:Crit", "CritPt"),
81
+ percent("aa:Sci", "SciCode"),
82
+ ];
83
+ case "writing":
84
+ return [
85
+ percent("aa:IF", "IFBench"),
86
+ points("aa:Gn", "GDPval"),
87
+ points("aa:Brief", "AA-Briefcase"),
88
+ percent("aa:LCR", "AA-LCR", needs.longContext ? 2 : 1),
89
+ ];
90
+ }
91
+ })();
92
+ return metrics.sort((a, b) => b.weight - a.weight);
93
+ }
94
+ /**
95
+ * Catalog columns that describe a run rather than a model's ability: price,
96
+ * tokens, steps, confidence intervals, flag rates, openness, and FrontierCode's
97
+ * pass-rate and Extended columns, which restate Main.
98
+ */
99
+ const NOT_ABILITY = new Set([
100
+ "aa:Open",
101
+ "dswe:CI",
102
+ "dswe:Cost",
103
+ "dswe:Out tok",
104
+ "dswe:Steps",
105
+ "fc:Main pass",
106
+ "fc:Extended",
107
+ "fc:Ext pass",
108
+ "fc:Flag",
109
+ "fc:Cost",
110
+ ]);
111
+ /**
112
+ * Published benchmarks that an independent table also measures. A vendor's
113
+ * report uses its own harness, so it is not ranked against the independent
114
+ * results, but it is evidence about the same ability: the completion takes it
115
+ * as a noisier observation of the independent benchmark.
116
+ */
117
+ const SAME_BENCHMARK = {
118
+ "pub:DSWE": "dswe:Pass@1",
119
+ "pub:TB4": "aa:TB4",
120
+ "pub:FC11": "fc:Main",
121
+ "pub:GDPpdf": "aa:PDF",
122
+ "pub:HLE": "aa:HLE",
56
123
  };
124
+ /** A model's results as the completion sees them: its ability measurements, and published reports of the same benchmarks. */
125
+ function abilityResults(values) {
126
+ const results = new Map();
127
+ const reports = new Map();
128
+ for (const [key, value] of values) {
129
+ if (NOT_ABILITY.has(key))
130
+ continue;
131
+ results.set(key, value);
132
+ const same = key.startsWith("pub:") ? SAME_BENCHMARK[key.slice(0, key.lastIndexOf("@"))] : undefined;
133
+ if (same)
134
+ reports.set(same, [...(reports.get(same) ?? []), value]);
135
+ }
136
+ const reported = new Map([...reports].map(([key, all]) => [key, all.reduce((a, b) => a + b, 0) / all.length]));
137
+ return { results, reported };
138
+ }
139
+ /** A result reported under another harness counts as this many times noisier than a direct measurement. */
140
+ const REPORTED_NOISE = 2;
141
+ const EFFORT_WORD = /\b(non[- ]reasoning|minimal|low|medium|high|xhigh|max)\b/iu;
142
+ const EFFORT_SETTING = /\b(non[- ]reasoning|(?:minimal|low|medium|high|xhigh|max)(?=\s+effort))\b/iu;
143
+ /** The reasoning effort a measurement names, `off` for non-reasoning, or "" when it names none. */
144
+ function effortLabel(text, pattern = EFFORT_WORD) {
145
+ const word = pattern.exec(text ?? "")?.[1]?.toLowerCase();
146
+ if (word === undefined)
147
+ return "";
148
+ return word.startsWith("non") ? "off" : word;
149
+ }
150
+ /**
151
+ * Position of an effort on the reasoning scale, centered on `high`. A result
152
+ * that names no effort is taken at `high`, the setting leaderboards most often
153
+ * report by default.
154
+ */
155
+ const effortPosition = (label) => (EFFORT_ORDER.indexOf(label || "high") - EFFORT_ORDER.indexOf("high")) / 2;
156
+ /** A model's results at every effort it was measured at, as observations for the completion. */
157
+ function observationsOf(byEffort, direct = false) {
158
+ const observations = [];
159
+ for (const [label, values] of byEffort) {
160
+ const effort = effortPosition(label);
161
+ const { results, reported } = abilityResults(values);
162
+ for (const [key, value] of results)
163
+ observations.push({ key, value, effort });
164
+ if (!direct)
165
+ for (const [key, value] of reported)
166
+ observations.push({ key, value, effort, noise: REPORTED_NOISE });
167
+ }
168
+ return observations;
169
+ }
170
+ /** Benchmarks of long, multi-step software work: DeepSWE and FrontierCode, from their leaderboards or vendors. */
171
+ const LONG_TASK_BENCHMARKS = ["dswe:Pass@1", "fc:Main", "pub:DSWE", "pub:FC11"];
172
+ /** True when the model has a measured long-task result; an estimate of one never counts. */
173
+ const hasLongTaskEvidence = (values) => [...values.keys()].some((key) => LONG_TASK_BENCHMARKS.some((benchmark) => key === benchmark || key.startsWith(`${benchmark}@`)));
174
+ /**
175
+ * Hard coding and review, and long-context coding, are long tasks that short
176
+ * benchmarks predict poorly. For them, models measured on a long-task benchmark
177
+ * rank ahead of models that are not; the rest stay eligible behind them.
178
+ */
179
+ const needsLongTaskEvidence = (needs) => (needs.work === "coding" || needs.work === "code_review") &&
180
+ (needs.difficulty === "hard" || needs.difficulty === "very_hard" || (needs.work === "coding" && needs.longContext));
181
+ /** Quality is ranked on the estimate minus this many standard errors, so thin evidence counts less. */
182
+ const CONSERVATIVE_ERRORS = 1;
57
183
  /** When speed matters, a fast route edges out its standard route for the model's single slot. */
58
184
  const FAST_ROUTE_BONUS = 0.02;
59
185
  /** A standing is stated only when enough benchmarked models share the measurement. */
@@ -116,10 +242,10 @@ function catalogReadings(catalog) {
116
242
  const rowCells = cells(row.line);
117
243
  const column = (name) => (header.includes(name) ? rowCells[header.indexOf(name)] : undefined);
118
244
  const readings = [];
119
- const read = (key, raw, condition) => {
245
+ const read = (key, raw, condition, effort) => {
120
246
  const value = Number.parseFloat(raw ?? "");
121
247
  if (Number.isFinite(value))
122
- readings.push({ key, value, ...(condition ? { condition } : {}) });
248
+ readings.push({ key, value, effort, ...(condition ? { condition } : {}) });
123
249
  };
124
250
  if (kinds[row.section] === "pub") {
125
251
  const reporter = column("Source");
@@ -127,14 +253,15 @@ function catalogReadings(catalog) {
127
253
  const condition = [setting, reporter ? `reported by ${reporter}` : undefined].filter(Boolean).join(", ");
128
254
  // Each reporter's results form their own cohort: a vendor harness and an
129
255
  // official leaderboard are not ranked against each other.
130
- read(`pub:${column("Benchmark")}@${reporter ?? ""}`, column("Score"), condition);
256
+ read(`pub:${column("Benchmark")}@${reporter ?? ""}`, column("Score"), condition, effortLabel(setting, EFFORT_SETTING));
131
257
  }
132
258
  else {
133
259
  const effort = column("Effort");
134
260
  const condition = effort ? `${effort} effort` : nameCondition(column("Model"));
261
+ const label = effortLabel(effort ?? /\(([^)]+)\)\s*$/u.exec(column("Model") ?? "")?.[1]);
135
262
  for (const [index, name] of header.entries())
136
263
  if (index > 1 && name !== "Effort" && name !== "Release date")
137
- read(`${kinds[row.section]}:${name}`, rowCells[index], condition);
264
+ read(`${kinds[row.section]}:${name}`, rowCells[index], condition, label);
138
265
  }
139
266
  return readings;
140
267
  });
@@ -147,7 +274,31 @@ function catalogReadings(catalog) {
147
274
  cohorts.set(key, cohort);
148
275
  }
149
276
  }
150
- const readings = { rows, cohorts };
277
+ // Per catalog model and effort, the best value of each measurement.
278
+ const models = new Map();
279
+ for (const row of catalog.rows) {
280
+ const identity = catalogModelIdentity(row.tokens);
281
+ const efforts = models.get(identity) ?? new Map();
282
+ models.set(identity, efforts);
283
+ for (const { key, value, effort } of rows[row.order]) {
284
+ const values = efforts.get(effort) ?? new Map();
285
+ values.set(key, Math.max(values.get(key) ?? value, value));
286
+ efforts.set(effort, values);
287
+ }
288
+ }
289
+ let completion;
290
+ const readings = {
291
+ rows,
292
+ cohorts,
293
+ models,
294
+ completion: () => {
295
+ if (completion === undefined) {
296
+ completion = completeBenchmarks(new Map([...models].map(([identity, efforts]) => [identity, observationsOf(efforts, true)])), MIN_RANKED_MODELS);
297
+ }
298
+ return completion;
299
+ },
300
+ populations: new Map(),
301
+ };
151
302
  readingsByCatalog.set(catalog, readings);
152
303
  return readings;
153
304
  }
@@ -160,42 +311,114 @@ function measure(catalog, model) {
160
311
  const readings = catalogReadings(catalog);
161
312
  const values = new Map();
162
313
  const conditions = new Map();
314
+ const byEffort = new Map();
315
+ const effortConditions = new Map();
163
316
  const identities = new Set();
164
317
  let released;
318
+ const keepBest = (into, notes, key, value, condition) => {
319
+ if (value <= (into.get(key) ?? Number.NEGATIVE_INFINITY))
320
+ return;
321
+ into.set(key, value);
322
+ if (condition)
323
+ notes.set(key, condition);
324
+ else
325
+ notes.delete(key);
326
+ };
165
327
  for (const row of candidateEvidenceRows(catalog, model)) {
166
328
  identities.add(catalogModelIdentity(row.tokens));
167
- for (const { key, value, condition } of readings.rows[row.order]) {
168
- if (value <= (values.get(key) ?? Number.NEGATIVE_INFINITY))
169
- continue;
170
- values.set(key, value);
171
- if (condition)
172
- conditions.set(key, condition);
173
- else
174
- conditions.delete(key);
329
+ for (const { key, value, condition, effort } of readings.rows[row.order]) {
330
+ keepBest(values, conditions, key, value, condition);
331
+ if (!byEffort.has(effort)) {
332
+ byEffort.set(effort, new Map());
333
+ effortConditions.set(effort, new Map());
334
+ }
335
+ keepBest(byEffort.get(effort), effortConditions.get(effort), key, value, condition);
175
336
  }
176
337
  if (row.releaseDate && (!released || row.releaseDate > released))
177
338
  released = row.releaseDate;
178
339
  }
179
- return { values, conditions, identities, ...(released ? { released } : {}) };
340
+ return { values, conditions, byEffort, effortConditions, identities, ...(released ? { released } : {}) };
180
341
  }
181
342
  /** Value keys measuring `metric`: the column itself, or one per reporter for published results. */
182
343
  const cohortKeys = (values, metric) => [...values.keys()].filter((key) => key === metric.key || key.startsWith(`${metric.key}@`));
183
344
  const baseKey = (candidate) => modelEvidenceTokens(candidate.fastRouteOf ?? candidate.model).join("-");
184
345
  const blended = (candidate) => (3 * candidate.cost.input + candidate.cost.output) / 4;
346
+ /** The weight of each of `metrics` the completion fitted. */
347
+ function benchmarkWeights(completion, metrics) {
348
+ const weights = new Map();
349
+ for (const metric of metrics) {
350
+ const keys = [...completion.keys].filter((key) => key === metric.key || key.startsWith(`${metric.key}@`));
351
+ for (const key of keys)
352
+ weights.set(key, (weights.get(key) ?? 0) + metric.weight / keys.length);
353
+ }
354
+ return weights;
355
+ }
356
+ /** True when any of a model's observations is a benchmark the completion fitted. */
357
+ const fitsAny = (completion, observations) => observations.some((observation) => completion.keys.has(observation.key));
358
+ const conservative = (estimate) => estimate.mean - CONSERVATIVE_ERRORS * estimate.error;
185
359
  /**
186
- * Rank every eligible model for the task in code. Quality is the model's
187
- * standing among every benchmarked model in the catalog on the benchmarks for
188
- * this kind of work (overall intelligence when it has none), so it does not
189
- * depend on which other models are eligible. It is weighed against price by how
360
+ * Rank every eligible model for the task in code. Quality is a conservative
361
+ * estimate for this kind of work: the model's weighted results on the work's
362
+ * benchmarks, with missing ones estimated from all of its other results, less
363
+ * one standard error, scaled from the weakest to the strongest candidate. A
364
+ * model with one strong result therefore ranks below models with broader,
365
+ * consistent evidence. The standing quoted to the router compares the same
366
+ * estimate with every benchmarked catalog model, so it does not depend on
367
+ * which other models are eligible. Quality is weighed against price by how
190
368
  * demanding the task is, with a small preference for newer releases.
191
369
  */
192
370
  export function rankCandidates(catalog, candidates, needs) {
193
- const { cohorts } = catalogReadings(catalog);
194
- const measured = candidates.map((candidate) => ({
195
- candidate,
196
- base: baseKey(candidate),
197
- ...measure(catalog, candidate.fastRouteOf ?? candidate.model),
198
- }));
371
+ const readings = catalogReadings(catalog);
372
+ const { cohorts } = readings;
373
+ const completion = readings.completion();
374
+ const weights = benchmarkWeights(completion, workMetrics(needs));
375
+ const signature = JSON.stringify([...weights]);
376
+ let population = readings.populations.get(signature);
377
+ if (population === undefined) {
378
+ // Every catalog model at each effort it was measured at.
379
+ population = [...readings.models].flatMap(([identity, efforts]) => {
380
+ const observations = observationsOf(efforts);
381
+ if (!fitsAny(completion, observations))
382
+ return [];
383
+ return [...efforts.keys()].flatMap((label) => {
384
+ const estimate = completion.estimate(observations, weights, effortPosition(label));
385
+ return estimate ? [[identity, conservative(estimate)]] : [];
386
+ });
387
+ });
388
+ readings.populations.set(signature, population);
389
+ }
390
+ const fitted = population;
391
+ const measured = candidates.map((candidate) => {
392
+ const evidence = measure(catalog, candidate.fastRouteOf ?? candidate.model);
393
+ // The model is ranked at the effort routing would run it at for this task.
394
+ const effort = candidate.efforts
395
+ ? effortForDifficulty(candidate.efforts, needs.difficulty, needs.latencySensitive)
396
+ : undefined;
397
+ // Without known efforts, the model is ranked at the highest effort it was measured at.
398
+ const label = effort === undefined
399
+ ? [...evidence.byEffort.keys()].sort((a, b) => EFFORT_ORDER.indexOf(b) - EFFORT_ORDER.indexOf(a))[0]
400
+ : (effort ?? "");
401
+ const observations = observationsOf(evidence.byEffort);
402
+ return {
403
+ candidate,
404
+ base: baseKey(candidate),
405
+ ...evidence,
406
+ effort,
407
+ effortValues: label === undefined ? undefined : evidence.byEffort.get(label),
408
+ effortNotes: label === undefined ? undefined : evidence.effortConditions.get(label),
409
+ estimate: completion.estimate(observations, weights, effortPosition(label ?? "")),
410
+ // Only a model with a result in the fit has a standing of its own; an
411
+ // unbenchmarked model is ranked on the catalog-wide prior, whose wide
412
+ // uncertainty keeps it below measured models.
413
+ evidenced: fitsAny(completion, observations),
414
+ };
415
+ });
416
+ // Quality for ranking spans the candidates being ranked: catalog standings
417
+ // crowd every frontier model into the top few percent, where price would
418
+ // decide, while the cautious estimates themselves still separate them.
419
+ const cautious = measured.flatMap((entry) => (entry.estimate ? [conservative(entry.estimate)] : []));
420
+ const [weakest, strongest] = [Math.min(...cautious), Math.max(...cautious)];
421
+ const relativeQuality = (estimate) => strongest > weakest ? (conservative(estimate) - weakest) / (strongest - weakest) : 1;
199
422
  const rankOf = (key, value, own) => {
200
423
  const cohort = cohorts.get(key);
201
424
  if (cohort === undefined || cohort.size < MIN_RANKED_MODELS)
@@ -203,9 +426,14 @@ export function rankCandidates(catalog, candidates, needs) {
203
426
  const others = [...cohort].filter(([identity]) => !own.has(identity)).map(([, other]) => other);
204
427
  return others.length ? others.filter((other) => other < value).length / others.length : undefined;
205
428
  };
206
- const standingOf = (values, own, metrics) => {
207
- const ranks = metrics
208
- .flatMap((metric) => cohortKeys(values, metric))
429
+ const estimateStanding = (value, own) => {
430
+ if (fitted.length < MIN_RANKED_MODELS)
431
+ return undefined;
432
+ const others = fitted.filter(([identity]) => !own.has(identity));
433
+ return others.length ? others.filter(([, other]) => other < value).length / others.length : undefined;
434
+ };
435
+ const overallOf = (values, own) => {
436
+ const ranks = cohortKeys(values, OVERALL)
209
437
  .map((key) => rankOf(key, values.get(key), own))
210
438
  .filter((rank) => rank !== undefined);
211
439
  return ranks.length ? ranks.reduce((a, b) => a + b, 0) / ranks.length : undefined;
@@ -220,13 +448,23 @@ export function rankCandidates(catalog, candidates, needs) {
220
448
  .sort()
221
449
  .at(-1);
222
450
  const demand = taskDemand(needs);
223
- const qualityWeight = 0.25 + 0.65 * demand;
451
+ const gated = needsLongTaskEvidence(needs);
452
+ // Quality is relative to the candidates, so it spans the whole range between
453
+ // them even for modest tasks. Below moderate demand its weight therefore falls
454
+ // with the square of demand, and an easy, low-stakes task goes to an adequate
455
+ // cheaper model; from moderate demand up the weights are unchanged.
456
+ const qualityWeight = demand >= 0.5 ? 0.25 + 0.65 * demand : 0.575 * (demand / 0.5) ** 2;
224
457
  const priceWeight = 0.65 - 0.65 * demand;
225
458
  return measured
226
- .map(({ candidate, base, values, conditions, identities, released }) => {
227
- const workStanding = standingOf(values, identities, WORK_METRICS[needs.work]);
228
- const overallStanding = standingOf(values, identities, [OVERALL]);
229
- const quality = workStanding ?? (overallStanding !== undefined ? 0.8 * overallStanding : 0.2);
459
+ .map(({ candidate, base, values, conditions, identities, released, estimate, evidenced, effort, effortValues, effortNotes, }) => {
460
+ const standing = estimate ? estimateStanding(conservative(estimate), identities) : undefined;
461
+ const workStanding = evidenced ? standing : undefined;
462
+ const overallStanding = overallOf(values, identities);
463
+ const quality = estimate && standing !== undefined
464
+ ? relativeQuality(estimate)
465
+ : overallStanding !== undefined
466
+ ? 0.8 * overallStanding
467
+ : 0.2;
230
468
  const price = blended(candidate);
231
469
  const cheapness = price > 0 && high > low ? 1 - (Math.log(price) - low) / (high - low) : 1;
232
470
  const ageDays = released && newest ? (Date.parse(newest) - Date.parse(released)) / 86_400_000 : 365;
@@ -245,9 +483,15 @@ export function rankCandidates(catalog, candidates, needs) {
245
483
  ...(released ? { released } : {}),
246
484
  ...(workStanding !== undefined ? { workStanding } : {}),
247
485
  ...(overallStanding !== undefined ? { overallStanding } : {}),
486
+ ...(estimate && evidenced ? { estimate } : {}),
487
+ ...(effort !== undefined ? { effort } : {}),
488
+ ...(hasLongTaskEvidence(values) ? { longTaskEvidence: true } : {}),
489
+ ...(effortValues ? { effortValues } : {}),
490
+ ...(effortNotes ? { effortConditions: effortNotes } : {}),
248
491
  };
249
492
  })
250
- .sort((a, b) => b.score - a.score ||
493
+ .sort((a, b) => Number(gated && !a.longTaskEvidence) - Number(gated && !b.longTaskEvidence) ||
494
+ b.score - a.score ||
251
495
  Number(a.fastRouteOf !== undefined) - Number(b.fastRouteOf !== undefined) ||
252
496
  a.model.localeCompare(b.model));
253
497
  }
@@ -276,11 +520,14 @@ function standingLabel(fraction) {
276
520
  return "below median";
277
521
  return "bottom quarter";
278
522
  }
523
+ const round = (value) => Number(value.toFixed(1));
279
524
  const money = (value) => `$${Number(value.toPrecision(3))}`;
280
525
  /**
281
526
  * One shortlisted option described with its own evidence, so the router compares
282
527
  * options directly: release date, price tier, image input, and results for this
283
- * kind of work and overall, with standings among catalog models measured on the same benchmark by the same source.
528
+ * kind of work and overall. The work standing compares the conservative
529
+ * quality estimate with every benchmarked catalog model's, and says which
530
+ * results are measured and which are estimated from the model's other results.
284
531
  */
285
532
  export function describeOption(option, needs, eligible) {
286
533
  const prices = eligible.map(blended).sort((a, b) => a - b);
@@ -290,24 +537,53 @@ export function describeOption(option, needs, eligible) {
290
537
  .map((candidate) => candidate.released ?? "")
291
538
  .sort()
292
539
  .at(-1);
293
- const quote = (metrics, standing) => {
294
- const present = metrics
295
- .map((metric) => {
296
- const keys = cohortKeys(option.values, metric);
297
- const best = keys.sort((a, b) => option.values.get(b) - option.values.get(a))[0];
298
- return best === undefined ? undefined : { metric, key: best };
299
- })
300
- .filter((entry) => entry !== undefined)
301
- .slice(0, 2);
302
- if (present.length === 0)
540
+ const best = { values: option.values, notes: option.conditions };
541
+ const atEffort = {
542
+ values: new Map([...option.values, ...(option.effortValues ?? [])]),
543
+ notes: new Map([...option.conditions, ...(option.effortConditions ?? [])]),
544
+ };
545
+ const measuredOf = (metrics, source) => metrics
546
+ .map((metric) => {
547
+ const keys = cohortKeys(source.values, metric);
548
+ const top = keys.sort((a, b) => source.values.get(b) - source.values.get(a))[0];
549
+ return top === undefined ? undefined : { metric, key: top };
550
+ })
551
+ .filter((entry) => entry !== undefined);
552
+ const results = (metrics, source, count = 2) => measuredOf(metrics, source)
553
+ .slice(0, count)
554
+ .map(({ metric, key }) => {
555
+ const condition = source.notes.get(key);
556
+ return `${metric.label} ${source.values.get(key)}${metric.unit}${condition ? ` measured with ${condition}` : ""}`;
557
+ })
558
+ .join("; ");
559
+ const quote = (metrics, standing, source) => {
560
+ const measured = results(metrics, source);
561
+ if (!measured)
303
562
  return "no published results";
304
- const results = present
305
- .map(({ metric, key }) => {
306
- const condition = option.conditions.get(key);
307
- return `${metric.label} ${option.values.get(key)}${metric.unit}${condition ? ` measured with ${condition}` : ""}`;
308
- })
563
+ return `${standing === undefined ? "measured" : `${standingLabel(standing)} of models with the same benchmark and source`} (${measured})`;
564
+ };
565
+ const metrics = workMetrics(needs);
566
+ const work = () => {
567
+ const { estimate, workStanding } = option;
568
+ if (estimate === undefined || workStanding === undefined)
569
+ return quote(metrics, undefined, atEffort);
570
+ const measured = results(metrics, atEffort, 3);
571
+ const quotedLabels = new Set(measuredOf(metrics, atEffort).map(({ metric }) => metric.label));
572
+ const estimated = metrics
573
+ .flatMap((metric) => estimate.estimated
574
+ .filter((result) => result.key === metric.key || result.key.startsWith(`${metric.key}@`))
575
+ .map((result) => ({ metric, result })))
576
+ .filter(({ metric }, index, all) => !quotedLabels.has(metric.label) &&
577
+ all.findIndex((entry) => entry.metric.label === metric.label) === index)
578
+ .slice(0, 2)
579
+ .map(({ metric, result }) => `${metric.label} about ${round(result.value)}${metric.unit} ± ${round(result.error)}${metric.unit === "%" ? " points" : ""}`)
309
580
  .join("; ");
310
- return `${standing === undefined ? "measured" : `${standingLabel(standing)} of models with the same benchmark and source`} (${results})`;
581
+ const parts = [
582
+ measured ? `measured: ${measured}` : "no result measured for this work",
583
+ ...(estimated ? [`estimated from its other results, not measured: ${estimated}`] : []),
584
+ ];
585
+ const at = typeof option.effort === "string" ? ` at ${option.effort} effort` : "";
586
+ return `${standingLabel(workStanding)} of benchmarked models on a cautious estimate for this work${at}, above ${round(100 * workStanding)}% of them (${parts.join("; ")})`;
311
587
  };
312
588
  let released = "unknown";
313
589
  if (option.released) {
@@ -326,8 +602,8 @@ export function describeOption(option, needs, eligible) {
326
602
  released,
327
603
  price: `${tier}: ${money(option.cost.input)} / ${money(option.cost.output)} per million tokens`,
328
604
  reads_images: option.input.includes("image"),
329
- [needs.work]: quote(WORK_METRICS[needs.work], option.workStanding),
330
- overall: quote([OVERALL], option.overallStanding),
605
+ [needs.work]: work(),
606
+ overall: quote([OVERALL], option.overallStanding, best),
331
607
  ...(option.fastRouteOf
332
608
  ? {
333
609
  route: option.fastRouteServiceTier === "ultrafast"