@chibitek/chibi 0.1.207 → 0.1.208

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 (93) hide show
  1. package/dist/assets/{TerminalPanel-Cqjxle8G.js → TerminalPanel-B5bwdaJ5.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-XB80WX43.js → abnfDiagram-O67JEVCF-BLKuHvdS.js} +1 -1
  3. package/dist/assets/{arc-BERcgYDi.js → arc-BeOf3Y3d.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-Dnc9s6SQ.js → architectureDiagram-NJMV4G6O-DnXr729a.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-Cxc21eYL.js → blockDiagram-BEXU5L5S-CEiwrTaI.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-CW-3gUcf.js → c4Diagram-YGBWAQC7-C0-29khR.js} +1 -1
  7. package/dist/assets/channel-_JFliC5C.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-Bs484eiW.js → chunk-2Q5K7J3B-D8dKbbui.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-qhnBgRDy.js → chunk-3FUC2YCW-fAEY1oOe.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-CsCqAEkH.js → chunk-5VM5RSS4-Djza4B4b.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-ChBgFjPw.js → chunk-GTNCS2PH-BWFGSXNt.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-Df5-WClq.js → chunk-GWA4HPMP-BGo5oevY.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-BdMXRJhO.js → chunk-JWPE2WC7-DIdxOMOn.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-rmAqJ9nY.js → chunk-NETBCI7D-Dc4tJ9uD.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-DYmTw4lw.js → chunk-WEXAMYUT-DvZ9F5yw.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-C4o5SHm0.js → chunk-XXDRQBXY-BYUVYcxq.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-Bm-ZzDk5.js → classDiagram-v2-NBCMYWYE-BtnsJQvT.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-CFMRSfMu.js → cose-bilkent-JH36ORCC-DLDe1VHc.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-BDedZ5yW.js → cynefin-OW5HDTMX-a1GJE5iI.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-i7KARSqF.js → cynefinDiagram-VND7K2PF-DXxGLDlQ.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-CwWpV0i_.js → dagre-6A5THRUB-DAW_YZe9.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-CWIMT3-K.js → diagram-22UHCM2B-oq3saywD.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-C7HGc_ap.js → diagram-3UASUU5V-BhCP3hS9.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-BeLM7ihN.js → diagram-ATOU4E4O-ByFRn1dW.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-CN1rVM-W.js → diagram-CDSNMT55-DWoCvkNH.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-CuLcsx4e.js → diagram-MLGK6HIB-CSH5kSlk.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-Bie61r-h.js → diagram-MPIPVDR6-Cnpx1s-T.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-ChMg86y3.js → ebnfDiagram-ZINNZB2B-DPmX63Vg.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-DG9xXwoW.js → elk-276RUBZZ-DUtmO9kb.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-C9bl-nWK.js → erDiagram-OPXOYQCR-SxwJeJu-.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-DvdWxFI8.js → flowDiagram-KWPJA3E3--QZAAUjB.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-DDCNSEYc.js → ganttDiagram-FUAMR5RP-CRz6i2Pe.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-PFvmOSMd.js → gitGraphDiagram-X574FWY7-Dx9Cisl2.js} +1 -1
  34. package/dist/assets/{index-DnniNB7N.js → index-BGkOob08.js} +1 -1
  35. package/dist/assets/{index-Ci2mINhA.js → index-vIsgWbJW.js} +83 -83
  36. package/dist/assets/{infoDiagram-VRGFBTTK-HEZh-PnK.js → infoDiagram-VRGFBTTK-CDLogk8N.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-P3mmCGAU.js → ishikawaDiagram-OU5B5YK6-DsrF1wno.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-dKG4AQu2.js → journeyDiagram-ZHPQQLJL-DUi8LEA6.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-BeIHeQTt.js → kanban-definition-PNTS6WVX-BAdWXobw.js} +1 -1
  40. package/dist/assets/{linear-DnEqDr6r.js → linear-Dha948ns.js} +1 -1
  41. package/dist/assets/{mermaid.core-D7hz6n4u.js → mermaid.core-BqT1aUP9.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-BxJ8p-DN.js → mindmap-definition-NLK3R4M7-XS1wDQ80.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-CkQT2dHJ.js → pegDiagram-GJSIUBJH-BphuafcF.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-DmVVhYaY.js → pieDiagram-5QR66LMP-JN9mbdiU.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-DsOz-qCY.js → quadrantDiagram-O4NWA36T-CkBF7Woa.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-CeYfvaki.js → railroadDiagram-XR7U4H2S-Ie1GVpj5.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-BCtM-2uN.js → requirementDiagram-PLB6GJNP-B8xGM6w4.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-Cu8ki35x.js → sankeyDiagram-IPEJSGJF-BgTSlqMg.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-DKbS5Gcs.js → sequenceDiagram-PO4LG4MO-B1J4EIne.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-Ceut6PrE.js → sizeCapture-INFHLROL-Cpcjc5oE.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-Bl5uMY2f.js → stateDiagram-v2-GCMORJYK-CtQKYLT4.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-CoMPbJ2k.js → swimlanes-2SLR337P-DpIk02zs.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-DPTl4zVS.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-D0xkKp46.js → timeline-definition-EJHVYXUP-DsA7dQhy.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-BCCL6QIf.js → usecaseDiagram-POWQR4AR-BM42_rDz.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U-B7g3jK72.js → vennDiagram-UO4OBE2U-DgLtqgJF.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-DFhnqQKP.js → wardleyDiagram-VNRHLVJA-BKUUTKBJ.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-mIXMscRS.js → xychartDiagram-PMCCYNJV-B9RWvizV.js} +1 -1
  59. package/dist/index.html +1 -1
  60. package/dist-server/index.js +3150 -2724
  61. package/dist-server/openmausbot.js +816 -635
  62. package/dist-server/pair-cli.js +816 -635
  63. package/dist-server/server/connection-cap-failover.js +8 -6
  64. package/dist-server/server/drivers/acp/core.js +20 -47
  65. package/dist-server/server/drivers/acp/custom.js +5 -0
  66. package/dist-server/server/drivers/acp/hermes.js +1 -0
  67. package/dist-server/server/drivers/acp/kimi-turn-failure.js +68 -0
  68. package/dist-server/server/drivers/acp/kimi.js +7 -0
  69. package/dist-server/server/drivers/acp/mcp-limit.js +47 -0
  70. package/dist-server/server/drivers/acp/rpc-error.js +35 -0
  71. package/dist-server/server/drivers/acp/setup-failure.js +9 -0
  72. package/dist-server/server/drivers/acp/vibe.js +11 -5
  73. package/dist-server/server/drivers/chat-text-only.js +47 -0
  74. package/dist-server/server/drivers/openai-chat-protocol.js +15 -0
  75. package/dist-server/server/drivers/openai-chat.js +8 -18
  76. package/dist-server/server/drivers/turn-mcp.js +3 -0
  77. package/dist-server/server/drivers/vibe-login.js +17 -8
  78. package/dist-server/server/engine-failover.js +16 -29
  79. package/dist-server/server/engine-rest.js +4 -3
  80. package/dist-server/server/engine-tiers.js +12 -9
  81. package/dist-server/server/index.js +16 -15
  82. package/dist-server/server/injected-model-rest.js +17 -0
  83. package/dist-server/server/model-levels/aliases.js +243 -38
  84. package/dist-server/server/model-levels/chibitek-rankings.js +8 -8
  85. package/dist-server/server/model-levels/classes.js +106 -38
  86. package/dist-server/server/model-levels/index.js +26 -14
  87. package/dist-server/server/model-levels/model-ids.js +91 -0
  88. package/dist-server/server/model-levels/overrides.js +7 -4
  89. package/dist-server/server/model-levels/sources.js +4 -1
  90. package/dist-server/server/pay-per-use.js +13 -1
  91. package/package.json +1 -1
  92. package/dist/assets/channel-DaeKCO76.js +0 -1
  93. package/dist/assets/swimlanesDiagram-TC7HE7FX-DLJq0mAR.js +0 -8
@@ -6,20 +6,33 @@
6
6
  // Intelligence Index scores when both exist, else whichever exists, else its
7
7
  // default (or non-reasoning) variant. A model listed only at other efforts
8
8
  // gets a documented estimate, flagged as such: its xhigh score, else its max
9
- // score minus 3, else its best low score. The score is banded (Mezcal >= 50,
9
+ // score minus 3. A model listed only at low or minimal effort has no score
10
+ // (a low row says little about the model at the efforts it is run at), and
11
+ // the next source decides. The score is banded (Mezcal >= 50,
10
12
  // Plata >= 44, Reposado >= 38, else Añejo; editable).
11
13
  //
12
14
  // Sources, per model, first one with a score wins:
13
15
  // 1. a person's override
14
- // 2. Artificial Analysis, fetched with a key (live or its cache)
16
+ // 2. Artificial Analysis, fetched with a key (live or its cache); rows
17
+ // fetched more than AA_STALE_AFTER_DAYS ago give way to a newer
18
+ // LMArena grade, and still supply cost and speed
15
19
  // 3. LMArena, fetched without a key (live or its cache): the model's
16
20
  // overall percentile among runnable models, by quartile
17
21
  // 4. the bundled baseline: Artificial Analysis rows, then LMArena rows
18
- // 5. Añejo, as a default
22
+ // 5. the newest graded version of the same family, for a version newer
23
+ // than every graded one (claude-fable-5-3 while 5-2 is the newest
24
+ // graded): a new release is not worse than the one it replaces, and
25
+ // the default would hide it from every ladder until a board lists it
26
+ // 6. Añejo, as a default
19
27
  import { MODEL_CLASSES, classForScore, DEFAULT_CLASS_BANDS } from "../../shared/engine-tiers.js";
20
- import { normalizeName, suggestionFor } from "./aliases.js";
28
+ import { bareModelId, nameResolver, normalizeName, suggestionFor } from "./aliases.js";
21
29
  import { parseAaName } from "./artificial-analysis.js";
22
30
  import { classForPercentile, overallPercentile } from "./grade.js";
31
+ import { compareVersions, familyOf, modelKey, newerVersion } from "./model-ids.js";
32
+ /** Fetched Artificial Analysis rows older than this no longer outrank a
33
+ * newer LMArena grade: a cache left behind by a key that is gone, or a fetch
34
+ * that keeps failing, would otherwise decide classes for good. */
35
+ export const AA_STALE_AFTER_DAYS = 14;
23
36
  /** How far below its max score a model listed only at max is placed. */
24
37
  export const MAX_ESTIMATE_PENALTY = 3;
25
38
  const EFFORT_ORDER = ["max", "xhigh", "high", "medium", "low", "minimal", "default", "non-reasoning"];
@@ -40,34 +53,24 @@ export function scoreVariants(variants) {
40
53
  const max = at("max");
41
54
  if (max)
42
55
  return { score: round1(max.intelligence - MAX_ESTIMATE_PENALTY), used: ["max"], estimated: "max-minus-3" };
43
- const low = [at("low"), at("minimal")].filter((variant) => variant !== undefined)
44
- .sort((a, b) => b.intelligence - a.intelligence)[0];
45
- if (low)
46
- return { score: low.intelligence, used: [low.effort], estimated: "low" };
47
56
  return undefined;
48
57
  }
49
58
  /** Credits each Artificial Analysis row to a catalog model by its name
50
- * without the effort part, exactly as listed in the catalog's `aa` names or
51
- * a person's alias override; anything else is reported, never guessed. */
59
+ * without the effort part: a name the catalog's `aa` names or a person's
60
+ * alias override list, or one that is a model's id ("Claude Sonnet 5.5" is
61
+ * claude-sonnet-5-5); anything else is reported, never guessed. */
52
62
  export function matchAaRows(rows, catalog, aliasOverrides = {}) {
53
- const index = new Map();
54
- for (const model of catalog)
55
- for (const name of model.aa ?? [])
56
- index.set(normalizeName(name), model.id);
63
+ const resolve = nameResolver(catalog, (model) => model.aa ?? [], aliasOverrides);
57
64
  const ids = new Set(catalog.map((model) => model.id));
58
- const overrides = new Map();
59
- for (const [name, target] of Object.entries(aliasOverrides))
60
- overrides.set(normalizeName(name), target);
61
65
  const byModel = new Map();
62
66
  const unmatched = new Map();
63
67
  for (const row of rows) {
64
68
  const { base, effort } = parseAaName(row.name);
65
- const key = normalizeName(base);
66
- const override = overrides.get(key);
67
- if (override === null)
69
+ const id = resolve(base);
70
+ if (id === null)
68
71
  continue;
69
- const id = override ?? index.get(key);
70
72
  if (id === undefined) {
73
+ const key = normalizeName(base);
71
74
  if (!unmatched.has(key)) {
72
75
  const suggestion = suggestionFor(key, ids);
73
76
  unmatched.set(key, { name: base, organization: row.creator, sources: ["artificial-analysis"], ...(suggestion ? { suggestion } : {}) });
@@ -119,7 +122,36 @@ const lmarenaClass = (input, id) => {
119
122
  const percentile = capabilities ? overallPercentile(capabilities) : undefined;
120
123
  return percentile === undefined ? undefined : { modelClass: classForPercentile(percentile), percentile };
121
124
  };
122
- /** Every catalog model's class, and every model a class override names. */
125
+ /** The models a source or a person grades, by family (model-ids.ts). */
126
+ export function gradedFamilies(models) {
127
+ const families = new Map();
128
+ for (const model of models) {
129
+ const { source, modelClass } = model.modelClass;
130
+ const family = model.overrideOnly || source === "default" || source === "inherited" ? undefined : familyOf(modelKey(model.id));
131
+ if (family && !family.latest)
132
+ families.set(family.family, [...families.get(family.family) ?? [], { id: model.id, family, modelClass }]);
133
+ }
134
+ return families;
135
+ }
136
+ /** The class an ungraded id takes from its family: that of the newest
137
+ * graded version, and only when the id is newer than every graded one. An
138
+ * older or in-between version stays ungraded, another family never counts,
139
+ * and an id still carrying a provider or a tag (a local or routed copy) is
140
+ * not a plain model name. */
141
+ export function inheritedClass(id, families) {
142
+ if (/[:/]/.test(id))
143
+ return undefined;
144
+ const family = familyOf(modelKey(id));
145
+ const siblings = family && families.get(family.family);
146
+ if (!family || !siblings?.every((sibling) => newerVersion(family, sibling.family)))
147
+ return undefined;
148
+ const newest = siblings.reduce((best, sibling) => (compareVersions(sibling.family.version, best.family.version) > 0 ? sibling : best));
149
+ return { modelClass: newest.modelClass, inheritedFrom: newest.id };
150
+ }
151
+ /** Every catalog model's class, and every id a class override names apart
152
+ * from its model. A person's override for a model's id, in any spelling,
153
+ * is the model's class at every effort; an override for one variant's id
154
+ * ("gpt-5.5-high") is that id's class alone. */
123
155
  export function classifyModels(input) {
124
156
  const bands = input.bands ?? DEFAULT_CLASS_BANDS;
125
157
  const emptyCapabilities = () => ({
@@ -147,14 +179,16 @@ export function classifyModels(input) {
147
179
  ...(metrics?.tokensPerSecond !== undefined ? { tokensPerSecond: metrics.tokensPerSecond } : {}),
148
180
  };
149
181
  }
150
- if (fromAa)
182
+ const live = lmarenaClass(input.lmarena, id);
183
+ const outdated = Boolean(input.aa?.stale && live && (input.lmarena.date ?? "") > input.aa.date);
184
+ if (fromAa && !outdated)
151
185
  return { ...fromAa, source: "artificial-analysis", sourceDate: input.aa.date };
152
186
  const metrics = variants.length ? aaGrade(variants, bands) : undefined;
153
- const withVariants = { variants: metrics?.variants ?? [],
187
+ // Rows that give no score (low effort only) are still listed, unused.
188
+ const withVariants = { variants: metrics?.variants ?? variants,
154
189
  ...(metrics?.costPerTask !== undefined ? { costPerTask: metrics.costPerTask } : {}),
155
190
  ...(metrics?.pricePer1M !== undefined ? { pricePer1M: metrics.pricePer1M } : {}),
156
191
  ...(metrics?.tokensPerSecond !== undefined ? { tokensPerSecond: metrics.tokensPerSecond } : {}) };
157
- const live = lmarenaClass(input.lmarena, id);
158
192
  if (live)
159
193
  return { ...withVariants, ...live, source: "lmarena", ...(input.lmarena.date ? { sourceDate: input.lmarena.date } : {}) };
160
194
  const baseline = input.aaBaseline?.match.byModel.get(id);
@@ -168,31 +202,65 @@ export function classifyModels(input) {
168
202
  }
169
203
  return { ...withVariants, modelClass: "Añejo", source: "default" };
170
204
  };
171
- const withOverride = (id, grade) => {
172
- const modelClass = input.overrides.classes[id];
205
+ const withOverride = (modelClass, grade) => {
173
206
  if (!modelClass)
174
207
  return grade;
175
208
  const { modelClass: scoredClass, source, score, percentile, ...rest } = grade;
176
209
  return {
177
210
  ...rest, modelClass, source: "override",
178
- ...(source !== "override" && source !== "default"
211
+ ...(source !== "override" && source !== "default" && source !== "inherited"
179
212
  ? { scored: { modelClass: scoredClass, source, ...(score !== undefined ? { score } : {}), ...(percentile !== undefined ? { percentile } : {}) } }
180
213
  : {}),
181
214
  ...(score !== undefined ? { score } : {}),
182
215
  };
183
216
  };
217
+ const overrides = input.overrides.classes;
218
+ const overrideIds = Object.keys(overrides).sort();
219
+ const spelled = new Map();
220
+ for (const id of overrideIds)
221
+ if (!spelled.has(modelKey(id)))
222
+ spelled.set(modelKey(id), id);
223
+ const applied = new Set();
224
+ const scored = new Map();
184
225
  const capabilitiesOf = (id) => input.lmarena?.capabilities.get(id) ?? input.lmarenaBaseline?.capabilities.get(id) ?? emptyCapabilities();
185
- const graded = input.catalog.map((model) => ({
186
- id: model.id, label: model.label, runs: model.runs,
187
- modelClass: withOverride(model.id, scoredGrade(model.id)),
188
- capabilities: capabilitiesOf(model.id),
189
- }));
190
- const known = new Set(input.catalog.map((model) => model.id));
191
- for (const id of Object.keys(input.overrides.classes).sort()) {
192
- if (known.has(id))
226
+ const graded = input.catalog.map((model) => {
227
+ const overrideId = overrides[model.id] ? model.id : spelled.get(modelKey(model.id));
228
+ if (overrideId !== undefined)
229
+ applied.add(overrideId);
230
+ const grade = scoredGrade(model.id);
231
+ scored.set(model.id, grade);
232
+ return {
233
+ id: model.id, label: model.label, runs: model.runs, ...(model.variantRuns ? { variantRuns: model.variantRuns } : {}),
234
+ modelClass: withOverride(overrideId === undefined ? undefined : overrides[overrideId], grade),
235
+ capabilities: capabilitiesOf(model.id),
236
+ };
237
+ });
238
+ const families = gradedFamilies(graded);
239
+ for (const model of graded) {
240
+ if (model.modelClass.source !== "default")
193
241
  continue;
194
- graded.push({ id, label: id, runs: [], overrideOnly: true,
195
- modelClass: withOverride(id, { modelClass: "Añejo", source: "default", variants: [] }), capabilities: emptyCapabilities() });
242
+ const inherited = inheritedClass(model.id, families);
243
+ if (inherited)
244
+ model.modelClass = { ...model.modelClass, ...inherited, source: "inherited" };
245
+ }
246
+ for (const id of overrideIds) {
247
+ if (applied.has(id))
248
+ continue;
249
+ // The engine ids that are exactly this id leave their model: its class
250
+ // is the model's everywhere but here.
251
+ const mine = (run) => run.model === id || bareModelId(run.model) === id;
252
+ const owner = graded.find((model) => !model.overrideOnly && [...model.runs, ...model.variantRuns ?? []].some(mine));
253
+ const runs = owner ? [...owner.runs, ...owner.variantRuns ?? []].filter(mine) : [];
254
+ if (owner) {
255
+ owner.runs = owner.runs.filter((run) => !mine(run));
256
+ if (owner.variantRuns)
257
+ owner.variantRuns = owner.variantRuns.filter((run) => !mine(run));
258
+ }
259
+ graded.push({
260
+ id, label: id, runs, overrideOnly: true,
261
+ modelClass: withOverride(overrides[id], (owner && scored.get(owner.id)) ?? { modelClass: "Añejo", source: "default", variants: [] }),
262
+ capabilities: owner?.capabilities ?? emptyCapabilities(),
263
+ });
196
264
  }
197
265
  return graded;
198
266
  }
@@ -13,13 +13,13 @@ import { statSync } from "node:fs";
13
13
  import { join } from "node:path";
14
14
  import { DEFAULT_CLASS_BANDS } from "../../shared/engine-tiers.js";
15
15
  import { AA_BASELINE } from "./aa-baseline.js";
16
- import { MODEL_CATALOG, catalogIdFor, localTag, matchSnapshots, onDeviceModel, withOfferedModels } from "./aliases.js";
16
+ import { MODEL_CATALOG, bareModelId, catalogIdFor, localTag, matchSnapshots, onDeviceModel, withOfferedModels } from "./aliases.js";
17
17
  import { AA_ATTRIBUTION, AA_MODELS_URL, artificialAnalysisKey, fetchArtificialAnalysis } from "./artificial-analysis.js";
18
18
  import { BASELINE } from "./baseline.js";
19
19
  import { AA_CACHE_FILE, CACHE_FILE, readAaCache, readCache, validSnapshots, writeAaCache, writeCache } from "./cache.js";
20
20
  import { setPublishedHarnessWeights } from "../ladder-order.js";
21
21
  import { CHIBITEK_RANKINGS_CACHE, fetchRankings, parseRankings, readRankingsCache, writeRankingsCache } from "./chibitek-rankings.js";
22
- import { byClass, classifyModels, matchAaRows } from "./classes.js";
22
+ import { AA_STALE_AFTER_DAYS, byClass, classifyModels, gradedFamilies, inheritedClass, matchAaRows } from "./classes.js";
23
23
  import { fetchSource } from "./fetch.js";
24
24
  import { PERCENTILE_CUTOFFS, gradeCapabilities } from "./grade.js";
25
25
  import { OVERRIDES_FILE, readOverrides, withClassOverride, writeOverrides } from "./overrides.js";
@@ -94,7 +94,7 @@ export function createModelLevels(options) {
94
94
  const models = classifyModels({
95
95
  catalog,
96
96
  ...(rankings ? { rankings } : {}),
97
- ...(aa ? { aa: { match: aa, date: dateOf(aaFetched.fetchedAt) } } : {}),
97
+ ...(aa ? { aa: { match: aa, date: dateOf(aaFetched.fetchedAt), stale: now().getTime() - Date.parse(aaFetched.fetchedAt) > AA_STALE_AFTER_DAYS * DAY_MS } } : {}),
98
98
  ...(aaBase ? { aaBaseline: { match: aaBase, date: dateOf(aaBaseline.fetchedAt) } } : {}),
99
99
  // Fetched LMArena rows rank above the baselines; while only bundled
100
100
  // rows are known, LMArena is the last baseline.
@@ -162,22 +162,34 @@ export function createModelLevels(options) {
162
162
  };
163
163
  };
164
164
  const graded = () => classified().models;
165
+ // Built once per grading: classOf runs on every turn start and failover.
166
+ const lookups = new WeakMap();
167
+ const lookupOf = (models) => {
168
+ let lookup = lookups.get(models);
169
+ if (!lookup)
170
+ lookups.set(models, (lookup = { byId: new Map(models.map((entry) => [entry.id, entry])), families: gradedFamilies(models) }));
171
+ return lookup;
172
+ };
165
173
  const classOf = (driverKind, model) => {
166
- const models = graded();
167
- const byId = (id) => models.find((entry) => entry.id === id);
168
- // An override written for the engine's own model id ("opencode-go/kimi-k3")
169
- // names exactly this model. Once the engine offers it, the model also
170
- // joins the catalog under its bare id ("kimi-k3", withOfferedModels), and
171
- // reading only that entry dropped the person's class.
172
- const exact = byId(model);
174
+ const { byId, families } = lookupOf(graded());
175
+ const of = ({ modelClass }) => ({ modelClass: modelClass.modelClass, source: modelClass.source, ...(modelClass.inheritedFrom ? { inheritedFrom: modelClass.inheritedFrom } : {}) });
176
+ // An override written for exactly this id ("opencode-go/kimi-k3", or one
177
+ // effort's "gpt-5.5-high") names this id alone; the model it belongs to
178
+ // keeps its own class under every other id.
179
+ const exact = byId.get(model) ?? byId.get(bareModelId(model));
173
180
  if (exact?.overrideOnly)
174
- return { modelClass: exact.modelClass.modelClass, source: exact.modelClass.source };
175
- const found = byId(catalogIdFor(driverKind, model, catalog) ?? model);
181
+ return of(exact);
182
+ const found = byId.get(catalogIdFor(driverKind, model, catalog) ?? model);
176
183
  if (found && found.modelClass.source !== "default")
177
- return { modelClass: found.modelClass.modelClass, source: found.modelClass.source };
184
+ return of(found);
178
185
  if (localTag(model) !== undefined || onDeviceModel(driverKind, model))
179
186
  return { modelClass: "Añejo", source: "default", local: true };
180
- return found ? { modelClass: found.modelClass.modelClass, source: "default" } : undefined;
187
+ if (found)
188
+ return { modelClass: found.modelClass.modelClass, source: "default" };
189
+ // An id no engine has listed yet: a version newer than every graded one
190
+ // of its family takes that family's newest class (classes.ts).
191
+ const inherited = inheritedClass(bareModelId(model), families);
192
+ return inherited ? { ...inherited, source: "inherited" } : undefined;
181
193
  };
182
194
  const runRefresh = async () => {
183
195
  const fetch = options.fetch ?? globalThis.fetch;
@@ -0,0 +1,91 @@
1
+ // One spelling for the ids engines use and the names leaderboards print.
2
+ //
3
+ // Engines spell one model many ways: "claude-fable-5-1" and
4
+ // "claude-fable-5.1", "Kimi-K3" and "kimi-k3", and one id per effort or speed
5
+ // ("claude-fable-5-1-thinking-high", "gpt-5.5-low-fast"). Graded apart, each
6
+ // spelling took whatever a leaderboard name happened to match and the rest
7
+ // fell to the Añejo default. modelKey gives every spelling of a name one key;
8
+ // variantKeys takes the effort and speed parts off, one at a time, so an id
9
+ // can be looked up as the model it runs.
10
+ //
11
+ // Still exact: a key either equals a known model's key or it does not.
12
+ // Nothing here compares families or guesses a sibling; familyOf exists only
13
+ // so a version newer than every graded one can inherit (classes.ts).
14
+ /** Lower case, every run of other characters one hyphen: "Claude Fable 5.1
15
+ * (Max)", "claude-fable-5.1-max" and "claude-fable-5-1-max" are one key. */
16
+ export function modelKey(name) {
17
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
18
+ }
19
+ const EFFORT_WORDS = ["minimal", "low", "medium", "high", "xhigh", "max"];
20
+ const VARIANT_PART = /-(thinking|minimal|low|medium|high|xhigh|max|fast)$/;
21
+ const LATEST = "-latest";
22
+ /** Names whose last word reads as an effort or a speed but is the model:
23
+ * Alibaba's Max line ("qwen3.8-max" is not "qwen3.8" at max effort) and
24
+ * xAI's Fast line ("grok-4-fast" is a smaller model than "grok-4"). */
25
+ const NAMED_BY_SUFFIX = [/^(?:qwen|qvq)[a-z0-9-]*-max$/, /^grok(?:-\d+)+-fast$/];
26
+ /** `key`, then `key` with each trailing effort or speed part taken off in
27
+ * turn: "gpt-5-5-high-fast", "gpt-5-5-high", "gpt-5-5". */
28
+ export function variantKeys(key) {
29
+ const out = [key];
30
+ let base = key;
31
+ while (!NAMED_BY_SUFFIX.some((named) => named.test(base))) {
32
+ const next = base.replace(VARIANT_PART, "");
33
+ if (next === base || !next)
34
+ break;
35
+ out.push(next);
36
+ base = next;
37
+ }
38
+ return out;
39
+ }
40
+ /** Every key an id may be known by: variantKeys, then the same for the id
41
+ * without a trailing "-latest". The alias is only ever taken off to reach a
42
+ * model that is known ("deepseek-v4-flash-latest"); "claude-fable-latest"
43
+ * names no one version, and stays itself. */
44
+ export function lookupKeys(key) {
45
+ const keys = variantKeys(key);
46
+ const last = keys.at(-1);
47
+ return last.endsWith(LATEST) && last.length > LATEST.length ? [...keys, ...variantKeys(last.slice(0, -LATEST.length))] : keys;
48
+ }
49
+ /** What was taken off `key` to reach `base`, e.g. ["high", "fast"]. */
50
+ export const variantParts = (key, base) => (key === base ? [] : key.slice(base.length + 1).split("-"));
51
+ /** The effort an id's variant parts name, if any. */
52
+ export const partsEffort = (parts) => parts.find((part) => EFFORT_WORDS.includes(part));
53
+ /** How well a variant stands for its model on a ladder, lower is better: the
54
+ * efforts a class is graded on first (high, then medium), thinking before
55
+ * not, a speed or "latest" alias last. */
56
+ export function variantRank(parts) {
57
+ const effort = partsEffort(parts);
58
+ const order = ["high", "medium", "xhigh", "max", undefined, "low", "minimal"];
59
+ return (parts.includes("fast") || parts.includes("latest") ? 100 : 0) + order.indexOf(effort) * 2 + (parts.includes("thinking") ? 0 : 1);
60
+ }
61
+ /** The family and version a key names, or undefined when it has no version.
62
+ * A date or a size is not a version: "claude-opus-4-20250514" is version 4
63
+ * of its own family, "qwen3-8-27b" version 3.8 of "qwen#27b", and
64
+ * "mistral-large-2407" has none. */
65
+ export function familyOf(key) {
66
+ const base = variantKeys(key).at(-1);
67
+ if (base.endsWith(LATEST))
68
+ return { family: `${base.slice(0, -LATEST.length)}-#`, version: [], latest: true };
69
+ const match = /^(.*?)(?<!\d)(\d{1,3}(?:-\d{1,2})*)(?=-|$)(?:-(.*))?$/.exec(base);
70
+ return match ? { family: `${match[1]}#${match[3] ?? ""}`, version: match[2].split("-") } : undefined;
71
+ }
72
+ const compareParts = (a, b, value) => {
73
+ for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
74
+ const difference = value(a[index] ?? "0", index) - value(b[index] ?? "0", index);
75
+ if (difference)
76
+ return difference;
77
+ }
78
+ return 0;
79
+ };
80
+ /** Versions as vendors mostly mean them, minor parts read as decimals: 4.20
81
+ * is before 4.3. */
82
+ export const compareVersions = (a, b) => compareParts(a, b, (part, index) => (index === 0 ? Number(part) : Number(`0.${part}`)));
83
+ /** Is `a` newer than `b` however the minor part is read? 5.3 is newer than
84
+ * 5.2 either way; 4.20 against 4.7 depends on the reading, so it is not. */
85
+ export function newerVersion(a, b) {
86
+ if (b.latest)
87
+ return false;
88
+ if (a.latest)
89
+ return true;
90
+ return compareVersions(a.version, b.version) > 0 && compareParts(a.version, b.version, (part) => Number(part)) > 0;
91
+ }
@@ -19,6 +19,7 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs";
19
19
  import { dirname } from "node:path";
20
20
  import { MODEL_CLASSES, toModelClass } from "../../shared/engine-tiers.js";
21
21
  import { writeFileAtomic } from "../atomic.js";
22
+ import { modelKey } from "./model-ids.js";
22
23
  export const OVERRIDES_FILE = "model-levels-overrides.json";
23
24
  /** Legacy `levels` entries: the all-capabilities value, else the first of
24
25
  * these that is set. */
@@ -113,12 +114,14 @@ export function writeOverrides(path, overrides) {
113
114
  mkdirSync(dirname(path), { recursive: true });
114
115
  writeFileAtomic(path, `${JSON.stringify(file, null, 2)}\n`);
115
116
  }
116
- /** One model's class override set (a class) or removed (null). */
117
+ /** One model's class override set (a class) or removed (null). An override
118
+ * under another spelling of the id ("claude-opus-4-6" for "claude-opus-4.6")
119
+ * is the same override (classifyModels), so it goes too: otherwise Settings
120
+ * could neither change nor clear it. */
117
121
  export function withClassOverride(overrides, id, modelClass) {
118
- const classes = { ...overrides.classes };
122
+ const key = modelKey(id);
123
+ const classes = Object.fromEntries(Object.entries(overrides.classes).filter(([other]) => modelKey(other) !== key));
119
124
  if (modelClass)
120
125
  classes[id] = modelClass;
121
- else
122
- delete classes[id];
123
126
  return { ...overrides, classes };
124
127
  }
@@ -30,7 +30,10 @@ export const CAPABILITIES = ["agent", "tools", "coding", "search", "writing"];
30
30
  export const CAPABILITY_WEIGHTS = {
31
31
  // The overall agent arena leads; finished tasks and following instructions refine it.
32
32
  agent: { "lmarena:agent": 0.5, "lmarena:agent_task_outcome_explicit": 0.3, "lmarena:agent_steerability": 0.2 },
33
- tools: { "lmarena:agent_tool_hallucination": 1 },
33
+ // The tool-hallucination board is saturated (its top 20 scores agreed to
34
+ // twelve digits on 2026-11-18), so its order is noise: it is still fetched
35
+ // and listed, and weighs nothing until it separates models again.
36
+ tools: {},
34
37
  coding: { "lmarena:webdev": 1 },
35
38
  search: { "lmarena:search": 0.6, "lmarena:search_factuality": 0.4 },
36
39
  // Style control removes the length and formatting bias, so it weighs most.
@@ -72,8 +72,20 @@ export class PayPerUseEpisodes {
72
72
  open.turns = (open.turns ?? 0) + 1;
73
73
  this.save();
74
74
  }
75
- /** A turn found a subscription free: the episode is over. */
75
+ /** A turn was placed on a subscription. Without the person's "Keep going"
76
+ * the episode is over. With it the approval stands until a subscription
77
+ * actually answers (subscriptionAnswered): a subscription that is picked
78
+ * and fails again a minute later is not back, and ending the episode on
79
+ * the pick threw the approval away within seconds of it being given. */
76
80
  subscriptionUsed() {
81
+ if (this.episodes[0]?.keptGoingAt === undefined)
82
+ this.end();
83
+ }
84
+ /** A subscription finished a turn: they are back, the episode is over. */
85
+ subscriptionAnswered() {
86
+ this.end();
87
+ }
88
+ end() {
77
89
  const open = this.episodes[0];
78
90
  if (!open || open.endedAt !== undefined)
79
91
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chibitek/chibi",
3
- "version": "0.1.207",
3
+ "version": "0.1.208",
4
4
  "description": "Atomic by Chibitek: run your AI team's server anywhere and pair your devices to it",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-D7hz6n4u.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1,8 +0,0 @@
1
- import{c as r,s as e}from"./flowDiagram-KWPJA3E3-DvdWxFI8.js";import{_ as a}from"./mermaid.core-D7hz6n4u.js";import"./chunk-5VM5RSS4-CsCqAEkH.js";import"./chunk-XXDRQBXY-C4o5SHm0.js";import"./chunk-WEXAMYUT-DYmTw4lw.js";import"./chunk-GWA4HPMP-Df5-WClq.js";import"./channel-DaeKCO76.js";import"./index-Ci2mINhA.js";var o=a(t=>`${e(t)}
2
- .swimlane.cluster:not([data-color-id]) rect {
3
- stroke: ${t.clusterBorder} !important;
4
- }
5
- [data-look="neo"].cluster rect {
6
- filter: none;
7
- }
8
- `,"getStyles"),s=o,u=r({styles:s});export{u as diagram};