@chibitek/chibi 0.1.190 → 0.1.192

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 (109) hide show
  1. package/dist/assets/TerminalPanel-DFuMZ0ql.css +1 -0
  2. package/dist/assets/TerminalPanel-PcPGVxjJ.js +10 -0
  3. package/dist/assets/{abnfDiagram-O67JEVCF-Bz3wlNsQ.js → abnfDiagram-O67JEVCF-CrdtKXgW.js} +1 -1
  4. package/dist/assets/{arc-CX0dJSa0.js → arc-DZp6zTLS.js} +1 -1
  5. package/dist/assets/{architectureDiagram-NJMV4G6O-APIM9yGf.js → architectureDiagram-NJMV4G6O-By4YaF8p.js} +1 -1
  6. package/dist/assets/{blockDiagram-BEXU5L5S-DNmNNaVY.js → blockDiagram-BEXU5L5S-b9XT0BEX.js} +1 -1
  7. package/dist/assets/{c4Diagram-YGBWAQC7-CAPPUeMU.js → c4Diagram-YGBWAQC7-ClDc6UCa.js} +1 -1
  8. package/dist/assets/channel-CP6zTF5h.js +1 -0
  9. package/dist/assets/{chunk-2Q5K7J3B-DfCDsQgU.js → chunk-2Q5K7J3B-D8FDC39i.js} +1 -1
  10. package/dist/assets/{chunk-3FUC2YCW-vdffwGmy.js → chunk-3FUC2YCW-_Lb0IVFX.js} +2 -2
  11. package/dist/assets/{chunk-5VM5RSS4-BazIL_2e.js → chunk-5VM5RSS4-f7re7-dy.js} +1 -1
  12. package/dist/assets/{chunk-GTNCS2PH-GpKjNZ-V.js → chunk-GTNCS2PH-Cl4oAWQ1.js} +1 -1
  13. package/dist/assets/{chunk-GWA4HPMP-BuRq21LZ.js → chunk-GWA4HPMP-CLO3k8zE.js} +1 -1
  14. package/dist/assets/{chunk-JWPE2WC7-CqNGOyHV.js → chunk-JWPE2WC7-kXWDfQP-.js} +1 -1
  15. package/dist/assets/{chunk-NETBCI7D-B1DpzVCP.js → chunk-NETBCI7D-DPtewwHN.js} +1 -1
  16. package/dist/assets/{chunk-WEXAMYUT-DcH1Euc6.js → chunk-WEXAMYUT-B17lA9FX.js} +1 -1
  17. package/dist/assets/{chunk-XXDRQBXY-M1JLd_cm.js → chunk-XXDRQBXY-B6RbRjkG.js} +1 -1
  18. package/dist/assets/{classDiagram-v2-NBCMYWYE-C8mBZ7i2.js → classDiagram-v2-NBCMYWYE-BrZPolTO.js} +1 -1
  19. package/dist/assets/{cose-bilkent-JH36ORCC-Cr3TqHDz.js → cose-bilkent-JH36ORCC-DAvSQrfJ.js} +1 -1
  20. package/dist/assets/{cynefin-OW5HDTMX-BKPr6l0I.js → cynefin-OW5HDTMX-BBEKoW-B.js} +1 -1
  21. package/dist/assets/{cynefinDiagram-VND7K2PF-Cbg5mrIM.js → cynefinDiagram-VND7K2PF-DTeD9b7A.js} +1 -1
  22. package/dist/assets/{dagre-6A5THRUB-9I9X1J3r.js → dagre-6A5THRUB-7Lem_oJB.js} +1 -1
  23. package/dist/assets/{diagram-22UHCM2B-B43b8pqQ.js → diagram-22UHCM2B-BBMu1DQ4.js} +1 -1
  24. package/dist/assets/{diagram-3UASUU5V-CIehgEkZ.js → diagram-3UASUU5V-wTBd45sT.js} +1 -1
  25. package/dist/assets/{diagram-ATOU4E4O-gx8nkXLZ.js → diagram-ATOU4E4O-DejXVMcb.js} +1 -1
  26. package/dist/assets/{diagram-CDSNMT55-BZzWgYHa.js → diagram-CDSNMT55-CqYId1m8.js} +1 -1
  27. package/dist/assets/{diagram-MLGK6HIB-BqoCqkZD.js → diagram-MLGK6HIB-DrOnQ-Zt.js} +1 -1
  28. package/dist/assets/{diagram-MPIPVDR6-Bsc7x0UT.js → diagram-MPIPVDR6-CHDvidFk.js} +1 -1
  29. package/dist/assets/{ebnfDiagram-ZINNZB2B-8HjdD_s8.js → ebnfDiagram-ZINNZB2B-BzwpPn5m.js} +1 -1
  30. package/dist/assets/{elk-276RUBZZ-bmxiEFtT.js → elk-276RUBZZ-E1HDqzYH.js} +1 -1
  31. package/dist/assets/{erDiagram-OPXOYQCR-BU-sRLe3.js → erDiagram-OPXOYQCR-D5E6uaT3.js} +1 -1
  32. package/dist/assets/{flowDiagram-KWPJA3E3-D45vn40U.js → flowDiagram-KWPJA3E3-R1exlkB4.js} +1 -1
  33. package/dist/assets/{ganttDiagram-FUAMR5RP-CArB98Hu.js → ganttDiagram-FUAMR5RP-B5kjMGRd.js} +1 -1
  34. package/dist/assets/{gitGraphDiagram-X574FWY7-fPB1k-W7.js → gitGraphDiagram-X574FWY7-BqkJtDvq.js} +1 -1
  35. package/dist/assets/index-DBOyvapT.css +1 -0
  36. package/dist/assets/{index-QsXeEMxJ.js → index-D_WPT1i-.js} +172 -171
  37. package/dist/assets/{index-u1wvoacp.js → index-DvEhLbPJ.js} +1 -1
  38. package/dist/assets/{infoDiagram-VRGFBTTK-ZRVWXAr4.js → infoDiagram-VRGFBTTK-LXwGqqoO.js} +1 -1
  39. package/dist/assets/{ishikawaDiagram-OU5B5YK6-DOaurRbX.js → ishikawaDiagram-OU5B5YK6-D_E17iEV.js} +1 -1
  40. package/dist/assets/{journeyDiagram-ZHPQQLJL-Ca9B-09w.js → journeyDiagram-ZHPQQLJL-BkKKJrLR.js} +1 -1
  41. package/dist/assets/{kanban-definition-PNTS6WVX-CA2XswEJ.js → kanban-definition-PNTS6WVX-y6rjCvyW.js} +1 -1
  42. package/dist/assets/{linear-B-F7icip.js → linear-BYdFcAFG.js} +1 -1
  43. package/dist/assets/{mermaid.core-ymtCpbZ5.js → mermaid.core-BZnTzEV7.js} +5 -5
  44. package/dist/assets/{mindmap-definition-NLK3R4M7-02vIazCi.js → mindmap-definition-NLK3R4M7-HPM-ymN0.js} +1 -1
  45. package/dist/assets/{pegDiagram-GJSIUBJH-DRb7Pn72.js → pegDiagram-GJSIUBJH-X2YHQQDC.js} +1 -1
  46. package/dist/assets/{pieDiagram-5QR66LMP-B2YwP3S_.js → pieDiagram-5QR66LMP-FQ47RvEb.js} +1 -1
  47. package/dist/assets/{quadrantDiagram-O4NWA36T-CbR573mu.js → quadrantDiagram-O4NWA36T-CZok45i-.js} +1 -1
  48. package/dist/assets/{railroadDiagram-XR7U4H2S-CqHuDCnM.js → railroadDiagram-XR7U4H2S-CkzgSbiA.js} +1 -1
  49. package/dist/assets/{requirementDiagram-PLB6GJNP-BSeC-H1j.js → requirementDiagram-PLB6GJNP-B96vOB2k.js} +1 -1
  50. package/dist/assets/{sankeyDiagram-IPEJSGJF-BMFuhoh1.js → sankeyDiagram-IPEJSGJF-C3OzzNBk.js} +1 -1
  51. package/dist/assets/{sequenceDiagram-PO4LG4MO-DRT_EI9u.js → sequenceDiagram-PO4LG4MO-UEjwqc9C.js} +1 -1
  52. package/dist/assets/{sizeCapture-INFHLROL-BLFT4fV7.js → sizeCapture-INFHLROL-CYlsATAn.js} +1 -1
  53. package/dist/assets/{stateDiagram-v2-GCMORJYK-C8vB_69H.js → stateDiagram-v2-GCMORJYK-i3kPrA1F.js} +1 -1
  54. package/dist/assets/{swimlanes-2SLR337P-T6BBolT8.js → swimlanes-2SLR337P-CwxGl-A-.js} +1 -1
  55. package/dist/assets/swimlanesDiagram-TC7HE7FX-BxG6JDb-.js +8 -0
  56. package/dist/assets/{timeline-definition-EJHVYXUP-DjdjBRQV.js → timeline-definition-EJHVYXUP-B-CIp72A.js} +1 -1
  57. package/dist/assets/{usecaseDiagram-POWQR4AR-CDGccZMN.js → usecaseDiagram-POWQR4AR-CvI2j7z-.js} +1 -1
  58. package/dist/assets/{vennDiagram-UO4OBE2U-CgYSihtW.js → vennDiagram-UO4OBE2U--l2Nr666.js} +1 -1
  59. package/dist/assets/{wardleyDiagram-VNRHLVJA-Bub5ScM8.js → wardleyDiagram-VNRHLVJA-C_WERxNO.js} +1 -1
  60. package/dist/assets/{xychartDiagram-PMCCYNJV-DK5iMX67.js → xychartDiagram-PMCCYNJV-VoRUD4V6.js} +1 -1
  61. package/dist/index.html +2 -2
  62. package/dist-server/container-mcp.js +84 -81
  63. package/dist-server/drivers/agents-proxy.js +81 -81
  64. package/dist-server/index.js +2115 -1577
  65. package/dist-server/openmausbot.js +611 -606
  66. package/dist-server/pair-cli.js +611 -606
  67. package/dist-server/server/config.js +1 -1
  68. package/dist-server/server/engine-failover.js +20 -7
  69. package/dist-server/server/engine-failure.js +5 -5
  70. package/dist-server/server/engine-tiers.js +12 -42
  71. package/dist-server/server/hermes-reply-failure.js +27 -0
  72. package/dist-server/server/index.js +26 -23
  73. package/dist-server/server/ladder-order.js +74 -0
  74. package/dist-server/server/model-levels/chibitek-rankings.js +8 -3
  75. package/dist-server/server/model-levels/index.js +3 -0
  76. package/dist-server/server/nexus-memory/backoff.js +68 -0
  77. package/dist-server/server/nexus-memory/client.js +55 -11
  78. package/dist-server/server/nexus-memory/index.js +6 -29
  79. package/dist-server/server/paw/nexus-sync.js +160 -0
  80. package/dist-server/server/paw/service.js +25 -3
  81. package/dist-server/server/paw/sync.js +19 -30
  82. package/dist-server/server/remote-desktop.js +1 -0
  83. package/dist-server/server/routes/terminal.js +72 -0
  84. package/dist-server/server/terminal-places.js +63 -0
  85. package/dist-server/server/terminal.js +124 -0
  86. package/dist-server/server/vault/store.js +8 -4
  87. package/dist-server/shared/approval-mode.js +12 -2
  88. package/dist-server/shared/engine-choices.js +14 -0
  89. package/dist-server/shared/engine-tiers.js +14 -8
  90. package/dist-server/shared/harness-weights.js +33 -0
  91. package/dist-server/shared/vault-api-providers.js +16 -2
  92. package/dist-server/shared/vault.js +3 -2
  93. package/dist-server/vps-container-mcp.js +84 -81
  94. package/package.json +1 -1
  95. package/skills/build-paw/SKILL.md +53 -0
  96. package/skills/build-paw/VENDORED.md +4 -0
  97. package/skills/build-paw/manifest.json +10 -2
  98. package/skills/build-paw/references/roles.md +134 -0
  99. package/skills/build-paw/references/wiring.md +77 -0
  100. package/dist/assets/channel-CnfDal05.js +0 -1
  101. package/dist/assets/index-CI0vGAif.css +0 -1
  102. package/dist/assets/swimlanesDiagram-TC7HE7FX-BIY4fGCv.js +0 -8
  103. package/dist-server/server/session-fallback.js +0 -76
  104. package/skills/icm-workspace-builder/SKILL.md +0 -154
  105. package/skills/icm-workspace-builder/VENDORED.md +0 -14
  106. package/skills/icm-workspace-builder/manifest.json +0 -15
  107. package/skills/icm-workspace-builder/references/interview.md +0 -39
  108. package/skills/icm-workspace-builder/references/templates.md +0 -147
  109. package/skills/icm-workspace-builder/references/wiring.md +0 -69
@@ -0,0 +1,124 @@
1
+ // Live terminal sessions for the Computer panel's Terminal tab
2
+ // (docs/computer-terminal.md). One shell per session, owned by the person at
3
+ // the desktop: a bot never sees these routes.
4
+ //
5
+ // No native PTY module ships with the app (the server is a self-contained
6
+ // bundle, electron-builder.yml), so a PTY comes from the OS: BSD/util-linux
7
+ // `script` on macOS and Linux. Windows runs the shell over plain pipes.
8
+ import { spawn } from "node:child_process";
9
+ import { randomUUID } from "node:crypto";
10
+ import { StringDecoder } from "node:string_decoder";
11
+ const REPLAY_CAP = 64 * 1024;
12
+ export const MAX_SESSIONS = 8;
13
+ /** The argv that gives `spec.command` a real terminal on this platform. On
14
+ * Windows there is none: the shell talks over pipes (no colours, no cursor
15
+ * keys; a line console). */
16
+ export function ptyWrap(spec, platform = process.platform) {
17
+ // BSD script refuses a socket on stdin (Node's child pipes are socketpairs:
18
+ // "tcgetattr/ioctl: Operation not supported on socket"), so a `cat` behind a
19
+ // process substitution hands it a FIFO instead.
20
+ if (platform === "darwin")
21
+ return { command: "bash", args: ["-c", 'exec script -q /dev/null "$@" < <(cat)', "atomic-terminal", spec.command, ...spec.args] };
22
+ if (platform === "linux") {
23
+ const line = [spec.command, ...spec.args].map((part) => `'${part.replace(/'/g, `'\\''`)}'`).join(" ");
24
+ return { command: "script", args: ["-qfc", line, "/dev/null"] };
25
+ }
26
+ return { command: spec.command, args: spec.args };
27
+ }
28
+ /** A shell prefix that sizes the terminal once, at open. Later resizes are
29
+ * ignored. ponytail: fixed size per session; node-pty (ioctl TIOCSWINSZ) if
30
+ * live resize matters. */
31
+ export function sizedShell(cols, rows, shell) {
32
+ return ["sh", "-c", `stty cols ${cols} rows ${rows} 2>/dev/null; exec ${shell}`];
33
+ }
34
+ export function clampSize(value, fallback) {
35
+ const n = typeof value === "number" && Number.isFinite(value) ? Math.round(value) : fallback;
36
+ return Math.min(500, Math.max(10, n));
37
+ }
38
+ export class TerminalRegistry {
39
+ sessions = new Map();
40
+ platform;
41
+ constructor(platform = process.platform) {
42
+ this.platform = platform;
43
+ }
44
+ get size() {
45
+ return this.sessions.size;
46
+ }
47
+ get(id) {
48
+ return this.sessions.get(id);
49
+ }
50
+ open(spec, owner) {
51
+ if (this.sessions.size >= MAX_SESSIONS)
52
+ throw Object.assign(new Error(`at most ${MAX_SESSIONS} terminals can be open at once`), { status: 429 });
53
+ const wrapped = ptyWrap(spec, this.platform);
54
+ const child = spawn(wrapped.command, wrapped.args, {
55
+ cwd: spec.cwd,
56
+ env: { ...process.env, TERM: "xterm-256color", COLUMNS: String(spec.cols), LINES: String(spec.rows), ...spec.env },
57
+ stdio: ["pipe", "pipe", "pipe"],
58
+ windowsHide: true,
59
+ });
60
+ const id = randomUUID();
61
+ const listeners = new Set();
62
+ let replay = "";
63
+ const emit = (event) => {
64
+ if (event.type === "output")
65
+ replay = (replay + event.data).slice(-REPLAY_CAP);
66
+ for (const listener of listeners)
67
+ listener(event);
68
+ };
69
+ child.stdin?.on("error", () => { });
70
+ const decoder = new StringDecoder("utf8");
71
+ const errDecoder = new StringDecoder("utf8");
72
+ child.stdout?.on("data", (chunk) => emit({ type: "output", data: decoder.write(chunk) }));
73
+ child.stderr?.on("data", (chunk) => emit({ type: "output", data: errDecoder.write(chunk) }));
74
+ const session = {
75
+ id,
76
+ label: spec.label,
77
+ owner,
78
+ startedAt: Date.now(),
79
+ exited: null,
80
+ write: (data) => {
81
+ if (session.exited || !child.stdin?.writable)
82
+ return;
83
+ child.stdin.write(data);
84
+ },
85
+ close: () => {
86
+ if (session.exited)
87
+ return;
88
+ child.kill("SIGHUP");
89
+ setTimeout(() => { if (!session.exited)
90
+ child.kill("SIGKILL"); }, 2_000).unref();
91
+ },
92
+ subscribe: (listener) => {
93
+ if (replay)
94
+ listener({ type: "output", data: replay });
95
+ if (session.exited) {
96
+ listener({ type: "exit", ...session.exited });
97
+ return () => { };
98
+ }
99
+ listeners.add(listener);
100
+ return () => { listeners.delete(listener); };
101
+ },
102
+ };
103
+ const finish = (code, signal) => {
104
+ if (session.exited)
105
+ return;
106
+ session.exited = { code, signal };
107
+ child.stdin?.end();
108
+ emit({ type: "exit", code, signal });
109
+ listeners.clear();
110
+ this.sessions.delete(id);
111
+ };
112
+ child.on("error", (error) => {
113
+ emit({ type: "output", data: `\r\n${error.message}\r\n` });
114
+ finish(null, null);
115
+ });
116
+ child.on("exit", finish);
117
+ this.sessions.set(id, session);
118
+ return session;
119
+ }
120
+ closeAll() {
121
+ for (const session of this.sessions.values())
122
+ session.close();
123
+ }
124
+ }
@@ -8,6 +8,7 @@ import { lstatSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
8
8
  import { join } from "node:path";
9
9
  import { z } from "zod";
10
10
  import { vaultGranted, vaultInputSchema, vaultMetadata, vaultUseAllowed } from "../../shared/vault.js";
11
+ import { apiAuthFor } from "../../shared/vault-api-providers.js";
11
12
  import { writeFileAtomic } from "../atomic.js";
12
13
  const MAX_BYTES = 16 * 1024 * 1024;
13
14
  const MAX_ITEMS = 3000;
@@ -161,7 +162,8 @@ export class VaultStore {
161
162
  const item = this.read().find((candidate) => candidate.id === id);
162
163
  if (!item || item.kind !== "apiKey" || !vaultUseAllowed(item, actor, now))
163
164
  return null;
164
- return { header: item.header, value: item.prefix + item.secret, secret: item.secret };
165
+ const { header, prefix } = apiAuthFor(actor.destination, item);
166
+ return { header, value: prefix + item.secret, secret: item.secret };
165
167
  }
166
168
  create(ownerId, input) {
167
169
  owner(ownerId);
@@ -232,9 +234,11 @@ export class VaultStore {
232
234
  if (!current)
233
235
  throw new VaultError("Vault item is unavailable.");
234
236
  const { id: _id, ownerId: _owner, createdAt: _created, updatedAt: _updated, ...previous } = current;
235
- // A blank password is invalid; omission preserves it, so metadata can
236
- // be edited without ever reading the saved secret back to the UI.
237
- const parsed = vaultInputSchema.safeParse({ ...previous, ...input });
237
+ // Blank API key edits preserve the saved value, just like omission.
238
+ const patch = { ...input };
239
+ if (current.kind === "apiKey" && typeof patch.secret === "string" && !patch.secret.trim())
240
+ delete patch.secret;
241
+ const parsed = vaultInputSchema.safeParse({ ...previous, ...patch });
238
242
  if (!parsed.success)
239
243
  throw new VaultError("Invalid Vault item.");
240
244
  if (current.kind !== parsed.data.kind)
@@ -35,8 +35,18 @@ export function supportsApprovalMode(driverKind, mode) {
35
35
  }
36
36
  /** A Full/Custom grant belongs to one provider's tool semantics. Other
37
37
  * modes carry across only when the destination actually implements them.
38
- * Adapted from tahodev's provider-switch guard in PR #1120. */
39
- export function modelSwitchNeedsAsk(mode, fromDriver, toDriver) {
38
+ * Adapted from tahodev's provider-switch guard in PR #1120.
39
+ *
40
+ * `workspaceGrant`: the Full comes from workspace GOD MODE, which the person
41
+ * turned on for every bot and every engine (the harness answers permission
42
+ * requests itself), not from a grant made on one provider. It carries
43
+ * anywhere, so a turn may start on or fail over to any engine. Without this
44
+ * a thread under GOD MODE was held to the kind of engine it last ran on:
45
+ * Chibi's turn tried only two dead OpenCode Go accounts while its own Claude
46
+ * account was ready (Erick, 2026-11-14). */
47
+ export function modelSwitchNeedsAsk(mode, fromDriver, toDriver, workspaceGrant = false) {
48
+ if (workspaceGrant)
49
+ return false;
40
50
  return !supportsApprovalMode(toDriver, mode) ||
41
51
  ((mode === "full" || mode === "custom") && fromDriver !== toDriver);
42
52
  }
@@ -310,6 +310,20 @@ export function anyAccountEntry(entry, engine, others) {
310
310
  const alternate = engine.models.map((model) => model.id).find((id) => !used(id));
311
311
  return alternate ? { engine: engine.driverKind, model: alternate } : undefined;
312
312
  }
313
+ /** A rung's account choice: "default" is one account of the provider,
314
+ * "any" every account of it, "subscription" every plan of any provider
315
+ * that serves the rung's model (`model` is the one shown, the engine's
316
+ * default when the rung names none). Undefined when anyAccountEntry finds
317
+ * no free route. */
318
+ export function accountChoiceEntry(kind, entry, engine, others, model) {
319
+ const next = anyAccountEntry(entry, engine, others);
320
+ if (!next || kind === "default")
321
+ return next;
322
+ if (kind === "any")
323
+ return { ...next, anyAccount: true };
324
+ const named = next.model ?? model;
325
+ return named ? { ...next, model: named, anySubscription: true } : next;
326
+ }
313
327
  /** Providers with accounts the person should name: brand and how many accounts it has. */
314
328
  export function accountsToName(choices) {
315
329
  const out = new Map();
@@ -189,14 +189,20 @@ export function effortShort(effort) {
189
189
  default: return undefined;
190
190
  }
191
191
  }
192
- /** The subscription accounts one rung may use, from those matching it (the
193
- * bot's own first). A rung naming an instance, or one a person set to "Any
194
- * account", keeps them all. Any other rung names a provider and gets one:
195
- * the first that is not refused for this turn (the personal line, policy),
196
- * so a turn never moves to another account of the provider unasked. Keys
197
- * are not decided here: they join every ladder's last band by themselves. */
198
- export function rungAccounts(entry, accounts, refused) {
192
+ /** The subscription accounts one rung may use, from those matching it. A
193
+ * rung naming an instance, or one a person set to "Any account", keeps them
194
+ * all. Any other rung names a provider and gets one: the bot's own account
195
+ * (`own`) when it can take the turn, else the first that can. `passedOver`
196
+ * says an account cannot: refused for this turn (the personal line,
197
+ * policy) or signed out. A signed-out account must never be the one a
198
+ * provider is held to: that skipped every Claude rung on a computer whose
199
+ * first Claude profile was signed out while the bot's own was ready. An
200
+ * account that is only resting is still the provider's one account, so a
201
+ * turn never moves to another account of the provider unasked. Keys are not
202
+ * decided here: they join every ladder's last band by themselves. */
203
+ export function rungAccounts(entry, accounts, passedOver, own) {
199
204
  if (entry.anyAccount || accounts.length < 2 || accounts.some((account) => account.instanceId === entry.engine))
200
205
  return accounts;
201
- return [accounts.find((account) => !refused?.(account)) ?? accounts[0]];
206
+ const usable = accounts.filter((account) => !passedOver?.(account));
207
+ return [usable.find((account) => account.instanceId === own) ?? usable[0] ?? accounts[0]];
202
208
  }
@@ -0,0 +1,33 @@
1
+ // Harness weights (docs/chibitek/engine-tiers.md, "Harness-aware order").
2
+ // A model's class comes from its leaderboard score alone; how well it works
3
+ // also depends on the harness that drives it (Erick, 2026-11-13: Grok Bot
4
+ // ran models graded below the frontier and did better work overall). Inside
5
+ // a class, ladders therefore order rungs by harness weight first, then by
6
+ // the model's rank. Classes are untouched.
7
+ //
8
+ // The weekly Chibitek rankings document may carry a `harnesses` block that
9
+ // replaces any of these without an app build (server/model-levels).
10
+ /** 0 to 1, by driver kind. A model maker's own agent harness is 1; an agent
11
+ * harness that drives many makers' models is a little lower; a plain API
12
+ * wrapper with no agent loop of its own is lowest. */
13
+ export const DEFAULT_HARNESS_WEIGHTS = {
14
+ claudeAgent: 1, codex: 1, grokAgent: 1, antigravityAgent: 1, museCode: 1, kimiAgent: 1, vibeAgent: 1, qwenAgent: 1,
15
+ hermesAgent: 0.9,
16
+ cursorAgent: 0.8, opencodeGo: 0.8, droidAgent: 0.8,
17
+ ollamaCloud: 0.5, "openai-compat": 0.5, mistral: 0.5, minimax: 0.5,
18
+ };
19
+ /** A harness nobody has weighed yet: between a multi-model harness and a plain wrapper. */
20
+ export const UNKNOWN_HARNESS_WEIGHT = 0.6;
21
+ /** The `harnesses` block of a published document: driver kind to a number
22
+ * from 0 to 1. Anything else in it is dropped; undefined when nothing is usable. */
23
+ export function parseHarnessWeights(value) {
24
+ if (!value || typeof value !== "object" || Array.isArray(value))
25
+ return undefined;
26
+ const out = {};
27
+ for (const [driverKind, weight] of Object.entries(value)) {
28
+ if (/^[A-Za-z0-9][\w.-]{0,199}$/.test(driverKind) && typeof weight === "number" && weight >= 0 && weight <= 1)
29
+ out[driverKind] = weight;
30
+ }
31
+ return Object.keys(out).length ? out : undefined;
32
+ }
33
+ export const harnessWeight = (driverKind, published) => published?.[driverKind] ?? DEFAULT_HARNESS_WEIGHTS[driverKind] ?? UNKNOWN_HARNESS_WEIGHT;
@@ -3,8 +3,8 @@ const keyed = (name, header, ...origins) => ({ name, origins, header, prefix: ""
3
3
  // Order matters where names overlap: the first match wins.
4
4
  export const API_PROVIDERS = [
5
5
  // Voice, video and media
6
- keyed(/\b(?:eleven\s*labs|11\s*labs)\b/i, "xi-api-key", "https://api.elevenlabs.io"),
7
- keyed(/\bheygen\b/i, "X-Api-Key", "https://api.heygen.com"),
6
+ { ...keyed(/\b(?:eleven\s*labs|11\s*labs)\b/i, "xi-api-key", "https://api.elevenlabs.io"), automatic: true },
7
+ { ...keyed(/\bheygen\b/i, "X-Api-Key", "https://api.heygen.com"), automatic: true },
8
8
  bearer(/\breplicate\b/i, "https://api.replicate.com"),
9
9
  // Model providers and routers
10
10
  bearer(/\bopen\s*router\b/i, "https://openrouter.ai"),
@@ -46,3 +46,17 @@ export const API_PROVIDERS = [
46
46
  export function apiProviderFor(name) {
47
47
  return API_PROVIDERS.find((provider) => provider.name.test(name));
48
48
  }
49
+ /** Match only verified HTTPS origins, never labels or host suffixes.
50
+ * Docs: https://elevenlabs.io/docs/api-reference/authentication
51
+ * https://www.heygen.com/integrations */
52
+ // Legacy items have no provenance. Only the exact former default pair is
53
+ // treated as automatic; non-default headers OR prefixes remain custom.
54
+ export function vaultAuthMode(saved) {
55
+ return saved.authMode ?? ((saved.header ?? "Authorization").toLowerCase() === "authorization" && (saved.prefix ?? "Bearer ") === "Bearer " ? "auto" : "custom");
56
+ }
57
+ export function apiAuthFor(destination, saved) {
58
+ if (vaultAuthMode(saved) === "custom")
59
+ return saved;
60
+ const origin = new URL(destination).origin;
61
+ return API_PROVIDERS.find((provider) => provider.automatic && provider.origins.includes(origin)) ?? saved;
62
+ }
@@ -49,7 +49,8 @@ export const vaultInputSchema = z.discriminatedUnion("kind", [
49
49
  // with no website): it is stored, and no bot can send it anywhere until
50
50
  // its owner adds an address.
51
51
  z.object({ ...base, kind: z.literal("apiKey"), origins: z.array(origin).max(50),
52
- header: z.string().regex(/^[A-Za-z0-9-]{1,64}$/), prefix: z.string().regex(/^[\x20-\x7E]{0,32}$/),
52
+ authMode: z.enum(["auto", "custom"]).optional(),
53
+ header: z.string().regex(/^[A-Za-z0-9-]{1,64}$/).default("Authorization"), prefix: z.string().regex(/^[\x20-\x7E]{0,32}$/).default("Bearer "),
53
54
  secret: z.string().regex(/^[\x21-\x7E]{1,8192}$/),
54
55
  }).strict(),
55
56
  ]);
@@ -62,7 +63,7 @@ export function vaultMetadata(item) {
62
63
  ...(item.kind === "login" ? { username: item.username } : {}),
63
64
  ...(item.kind === "card" ? { lastFour: item.number.slice(-4), expiryMonth: item.expiryMonth, expiryYear: item.expiryYear, billing: { ...item.billing } } : {}),
64
65
  ...(item.kind === "contact" ? { address: { ...item.address }, email: item.email, phone: item.phone } : {}),
65
- ...(item.kind === "apiKey" ? { header: item.header, prefix: item.prefix } : {}),
66
+ ...(item.kind === "apiKey" ? { header: item.header, prefix: item.prefix, ...(item.authMode ? { authMode: item.authMode } : {}) } : {}),
66
67
  createdAt: item.createdAt, updatedAt: item.updatedAt,
67
68
  };
68
69
  }