@chibitek/chibi 0.1.188 → 0.1.191

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 (121) hide show
  1. package/dist/assets/TerminalPanel-D8Eovq0F.js +10 -0
  2. package/dist/assets/TerminalPanel-DFuMZ0ql.css +1 -0
  3. package/dist/assets/{abnfDiagram-O67JEVCF-CKDXgnYw.js → abnfDiagram-O67JEVCF-CPvuUneJ.js} +1 -1
  4. package/dist/assets/{arc--VPK-xet.js → arc-aMP_0t5b.js} +1 -1
  5. package/dist/assets/{architectureDiagram-NJMV4G6O-DSVjpq7n.js → architectureDiagram-NJMV4G6O-yyXrFi66.js} +1 -1
  6. package/dist/assets/{blockDiagram-BEXU5L5S-BiQ1JgSl.js → blockDiagram-BEXU5L5S-BQN3ZvRc.js} +1 -1
  7. package/dist/assets/{c4Diagram-YGBWAQC7-kWWEc-NZ.js → c4Diagram-YGBWAQC7-BieilTo4.js} +1 -1
  8. package/dist/assets/channel-Bw54wjTR.js +1 -0
  9. package/dist/assets/{chunk-2Q5K7J3B-QJYqMtWJ.js → chunk-2Q5K7J3B-Df4lxXIM.js} +1 -1
  10. package/dist/assets/{chunk-3FUC2YCW-C7oGYTZS.js → chunk-3FUC2YCW-su_KXf5y.js} +2 -2
  11. package/dist/assets/{chunk-5VM5RSS4-MahQWTzh.js → chunk-5VM5RSS4-DL3rM5tY.js} +1 -1
  12. package/dist/assets/{chunk-GTNCS2PH-CQfOvr7l.js → chunk-GTNCS2PH-53Ovfw1t.js} +1 -1
  13. package/dist/assets/{chunk-GWA4HPMP-b0lt02Pi.js → chunk-GWA4HPMP-BkeiDfwS.js} +1 -1
  14. package/dist/assets/{chunk-JWPE2WC7-J1_ylbx8.js → chunk-JWPE2WC7-CvsdGjCO.js} +1 -1
  15. package/dist/assets/{chunk-NETBCI7D-AWcL9tld.js → chunk-NETBCI7D-BngSjMee.js} +1 -1
  16. package/dist/assets/{chunk-WEXAMYUT-DpTrAXJV.js → chunk-WEXAMYUT-DitKn6fq.js} +1 -1
  17. package/dist/assets/{chunk-XXDRQBXY-2_DCjtc9.js → chunk-XXDRQBXY-Czjvl52d.js} +1 -1
  18. package/dist/assets/{classDiagram-v2-NBCMYWYE-BBQMtHHs.js → classDiagram-v2-NBCMYWYE-COr4Qzpk.js} +1 -1
  19. package/dist/assets/{cose-bilkent-JH36ORCC-CmxRmDe8.js → cose-bilkent-JH36ORCC-Eg0tlzqp.js} +1 -1
  20. package/dist/assets/{cynefin-OW5HDTMX-DjlothXK.js → cynefin-OW5HDTMX-BjtG84WL.js} +1 -1
  21. package/dist/assets/{cynefinDiagram-VND7K2PF-D6HfzP26.js → cynefinDiagram-VND7K2PF-BzZtwDD4.js} +1 -1
  22. package/dist/assets/{dagre-6A5THRUB-BtzaxY50.js → dagre-6A5THRUB-TrLQ507j.js} +1 -1
  23. package/dist/assets/{diagram-22UHCM2B-DsyCiGJD.js → diagram-22UHCM2B-BDQDC-33.js} +1 -1
  24. package/dist/assets/{diagram-3UASUU5V-CjjvxIr3.js → diagram-3UASUU5V-Cm_mzSfE.js} +1 -1
  25. package/dist/assets/{diagram-ATOU4E4O-DDu2iVRb.js → diagram-ATOU4E4O-CAI_i4oy.js} +1 -1
  26. package/dist/assets/{diagram-CDSNMT55-BBTViw3h.js → diagram-CDSNMT55-9GjNyQXn.js} +1 -1
  27. package/dist/assets/{diagram-MLGK6HIB-D83j4C6w.js → diagram-MLGK6HIB-ETDg4UN-.js} +1 -1
  28. package/dist/assets/{diagram-MPIPVDR6-DTpmpL8Q.js → diagram-MPIPVDR6-8_8dZKgW.js} +1 -1
  29. package/dist/assets/{ebnfDiagram-ZINNZB2B-D3B4hz_Y.js → ebnfDiagram-ZINNZB2B-BiYh2ZYM.js} +1 -1
  30. package/dist/assets/{elk-276RUBZZ-CbNicGf_.js → elk-276RUBZZ-5u6sMYIg.js} +1 -1
  31. package/dist/assets/{erDiagram-OPXOYQCR-DeSwxwFC.js → erDiagram-OPXOYQCR-Dm6semJ3.js} +1 -1
  32. package/dist/assets/{flowDiagram-KWPJA3E3-3n_Hk-ZR.js → flowDiagram-KWPJA3E3-DbQ12CeV.js} +1 -1
  33. package/dist/assets/{ganttDiagram-FUAMR5RP-BsadEPTf.js → ganttDiagram-FUAMR5RP-C12s51S6.js} +1 -1
  34. package/dist/assets/{gitGraphDiagram-X574FWY7-DOvqN3Jh.js → gitGraphDiagram-X574FWY7-BhkwBL2T.js} +1 -1
  35. package/dist/assets/{index-BmYLMFD8.js → index-D4BfC2Zf.js} +1 -1
  36. package/dist/assets/index-DBOyvapT.css +1 -0
  37. package/dist/assets/{index-B9LCl5y3.js → index-WT8Xwc4G.js} +175 -174
  38. package/dist/assets/{infoDiagram-VRGFBTTK-CI3tfMt9.js → infoDiagram-VRGFBTTK-IvWqyiSM.js} +1 -1
  39. package/dist/assets/{ishikawaDiagram-OU5B5YK6-BE7AjZYf.js → ishikawaDiagram-OU5B5YK6-N2ZxLyoE.js} +1 -1
  40. package/dist/assets/{journeyDiagram-ZHPQQLJL-DplNZPox.js → journeyDiagram-ZHPQQLJL-UWy3ala_.js} +1 -1
  41. package/dist/assets/{kanban-definition-PNTS6WVX-Cos64we-.js → kanban-definition-PNTS6WVX-Cutk-kDA.js} +1 -1
  42. package/dist/assets/{linear-DDfQb-jo.js → linear-dPnV_-aA.js} +1 -1
  43. package/dist/assets/{mermaid.core-BekbnuLb.js → mermaid.core-QdldWb2L.js} +5 -5
  44. package/dist/assets/{mindmap-definition-NLK3R4M7-DJ0MbzMW.js → mindmap-definition-NLK3R4M7-pkXW8CYn.js} +1 -1
  45. package/dist/assets/{pegDiagram-GJSIUBJH-DZNZCZ4O.js → pegDiagram-GJSIUBJH-DhKkEQzV.js} +1 -1
  46. package/dist/assets/{pieDiagram-5QR66LMP-COD5v2yC.js → pieDiagram-5QR66LMP-DMehGrxw.js} +1 -1
  47. package/dist/assets/{quadrantDiagram-O4NWA36T-D4dlLWfv.js → quadrantDiagram-O4NWA36T-oNzYf4fg.js} +1 -1
  48. package/dist/assets/{railroadDiagram-XR7U4H2S-CEpVYFKl.js → railroadDiagram-XR7U4H2S-pkMOwYja.js} +1 -1
  49. package/dist/assets/{requirementDiagram-PLB6GJNP-DYD5GX0G.js → requirementDiagram-PLB6GJNP-J29GrlJj.js} +1 -1
  50. package/dist/assets/{sankeyDiagram-IPEJSGJF-C9bPeTfK.js → sankeyDiagram-IPEJSGJF-YuyCeGY6.js} +1 -1
  51. package/dist/assets/{sequenceDiagram-PO4LG4MO-eXpmPg9C.js → sequenceDiagram-PO4LG4MO-BjxLu0JW.js} +1 -1
  52. package/dist/assets/{sizeCapture-INFHLROL-DfqKWBhp.js → sizeCapture-INFHLROL-BESOD3ec.js} +1 -1
  53. package/dist/assets/{stateDiagram-v2-GCMORJYK-DkIf90iA.js → stateDiagram-v2-GCMORJYK-DF2yvbZA.js} +1 -1
  54. package/dist/assets/{swimlanes-2SLR337P-Ds64cQxN.js → swimlanes-2SLR337P-Bzp4ze7n.js} +1 -1
  55. package/dist/assets/swimlanesDiagram-TC7HE7FX-B6y4ZZ5q.js +8 -0
  56. package/dist/assets/{timeline-definition-EJHVYXUP-Ci3-31qT.js → timeline-definition-EJHVYXUP-CnLbXs4R.js} +1 -1
  57. package/dist/assets/{usecaseDiagram-POWQR4AR-DQUGgfBf.js → usecaseDiagram-POWQR4AR-nuJhbhCv.js} +1 -1
  58. package/dist/assets/{vennDiagram-UO4OBE2U-DV5_nmWl.js → vennDiagram-UO4OBE2U-D_hzVg9h.js} +1 -1
  59. package/dist/assets/{wardleyDiagram-VNRHLVJA-DatPTthc.js → wardleyDiagram-VNRHLVJA-hgmpI4iu.js} +1 -1
  60. package/dist/assets/{xychartDiagram-PMCCYNJV-ADaxt1QH.js → xychartDiagram-PMCCYNJV-DwnJWdDn.js} +1 -1
  61. package/dist/index.html +2 -2
  62. package/dist-server/container-mcp.js +3 -0
  63. package/dist-server/drivers/agents-proxy.js +14 -4
  64. package/dist-server/index.js +4802 -3806
  65. package/dist-server/openmausbot.js +1383 -846
  66. package/dist-server/pair-cli.js +1383 -846
  67. package/dist-server/server/browser-runtime.js +41 -5
  68. package/dist-server/server/chibi-defaults.js +96 -0
  69. package/dist-server/server/cli-login.js +4 -0
  70. package/dist-server/server/config.js +1 -1
  71. package/dist-server/server/connection-cap-failover.js +0 -2
  72. package/dist-server/server/drivers/agents-vault.js +4 -3
  73. package/dist-server/server/engine-failover.js +20 -7
  74. package/dist-server/server/engine-failure.js +5 -5
  75. package/dist-server/server/engine-tiers.js +14 -44
  76. package/dist-server/server/hermes-reply-failure.js +27 -0
  77. package/dist-server/server/hidden-ai-text.js +56 -0
  78. package/dist-server/server/index.js +47 -50
  79. package/dist-server/server/ladder-order.js +74 -0
  80. package/dist-server/server/model-levels/chibitek-rankings.js +8 -3
  81. package/dist-server/server/model-levels/index.js +3 -0
  82. package/dist-server/server/nexus-memory/backoff.js +27 -0
  83. package/dist-server/server/nexus-memory/index.js +12 -16
  84. package/dist-server/server/paw/nexus-sync.js +160 -0
  85. package/dist-server/server/paw/service.js +25 -3
  86. package/dist-server/server/paw/sync.js +19 -30
  87. package/dist-server/server/remote-desktop.js +1 -0
  88. package/dist-server/server/routes/terminal.js +72 -0
  89. package/dist-server/server/system-prompt.js +17 -2
  90. package/dist-server/server/terminal-places.js +63 -0
  91. package/dist-server/server/terminal.js +124 -0
  92. package/dist-server/server/vault/fill.js +338 -0
  93. package/dist-server/server/vault/request.js +6 -2
  94. package/dist-server/server/vault/routes.js +14 -2
  95. package/dist-server/server/vault/runtime.js +14 -0
  96. package/dist-server/server/vault/store.js +40 -3
  97. package/dist-server/shared/approval-mode.js +12 -2
  98. package/dist-server/shared/engine-choices.js +14 -0
  99. package/dist-server/shared/engine-tiers.js +29 -1
  100. package/dist-server/shared/harness-weights.js +33 -0
  101. package/dist-server/shared/provider-accounts.js +5 -3
  102. package/dist-server/shared/subscription-bots.js +14 -6
  103. package/dist-server/shared/vault-api-providers.js +48 -0
  104. package/dist-server/shared/vault-csv.js +62 -14
  105. package/dist-server/shared/vault.js +14 -3
  106. package/dist-server/vps-container-mcp.js +3 -0
  107. package/package.json +1 -1
  108. package/skills/build-paw/SKILL.md +53 -0
  109. package/skills/build-paw/VENDORED.md +4 -0
  110. package/skills/build-paw/manifest.json +10 -2
  111. package/skills/build-paw/references/roles.md +134 -0
  112. package/skills/build-paw/references/wiring.md +77 -0
  113. package/dist/assets/channel-CQdxuHwI.js +0 -1
  114. package/dist/assets/index-CI0vGAif.css +0 -1
  115. package/dist/assets/swimlanesDiagram-TC7HE7FX-bO3Klz6Z.js +0 -8
  116. package/skills/icm-workspace-builder/SKILL.md +0 -154
  117. package/skills/icm-workspace-builder/VENDORED.md +0 -14
  118. package/skills/icm-workspace-builder/manifest.json +0 -15
  119. package/skills/icm-workspace-builder/references/interview.md +0 -39
  120. package/skills/icm-workspace-builder/references/templates.md +0 -147
  121. package/skills/icm-workspace-builder/references/wiring.md +0 -69
@@ -0,0 +1,338 @@
1
+ // Trusted login fill for the built-in browser. A bot names a Vault login;
2
+ // Atomic checks the grant against the page's real address, finds the sign-in
3
+ // fields itself and types the username and password. The bot never receives
4
+ // the password, and for as long as that browser session lives every way it
5
+ // could read the page back is guarded:
6
+ //
7
+ // - page JavaScript (eval) and copy/cut shortcuts are refused;
8
+ // - the password is removed from every text result (snapshot, read, text,
9
+ // url, title), in plain and URL-encoded form;
10
+ // - a screenshot is withheld while the password is readable on the page,
11
+ // and is never written to a path the bot chose;
12
+ // - a password field the bot edited is emptied before anything else runs,
13
+ // so an edited copy of the password can never be shown and read;
14
+ // - while the password is readable on the page, only looking and clicking
15
+ // work, so it cannot be edited or probed there either.
16
+ //
17
+ // This guards Atomic's browser tools. An engine with a shell on this
18
+ // computer can reach the browser by other means; that is the limit the Vault
19
+ // spec states, not one this module removes.
20
+ import { randomBytes } from "node:crypto";
21
+ import { mkdirSync, readFileSync } from "node:fs";
22
+ import { dirname } from "node:path";
23
+ import { writeFileAtomic } from "../atomic.js";
24
+ import { vaultOrigin } from "../../shared/vault.js";
25
+ import { VaultError } from "./store.js";
26
+ export const VAULT_FILL_TOOL = "vault_fill_login";
27
+ export const vaultFillTool = {
28
+ name: VAULT_FILL_TOOL,
29
+ description: "Sign in with a login saved in the person's Atomic Vault. Atomic types the username and password into the sign-in form on the current page itself, so you never see the password. Open the site's sign-in page first; it must be on the item's website. Item ids come from vault_request with no arguments. Then click the sign-in button. After a fill, eval and copy shortcuts are off in this browser.",
30
+ inputSchema: {
31
+ type: "object",
32
+ properties: { item_id: { type: "string", description: "The login's id from vault_request." } },
33
+ required: ["item_id"],
34
+ additionalProperties: false,
35
+ },
36
+ };
37
+ /** Advertise the fill tool beside the engine's own. */
38
+ export function withVaultFillTool(list) {
39
+ if (!list || typeof list !== "object" || !Array.isArray(list.tools))
40
+ return list;
41
+ return { ...list, tools: [...list.tools, vaultFillTool] };
42
+ }
43
+ const REFUSED = "This bot may not use that Vault login on this page. vault_request with no arguments lists each login's website.";
44
+ const EVAL_OFF = "Page JavaScript is off in this browser because a Vault password was filled. Use snapshot, click, fill and the other browser tools, or close the browser to start clean.";
45
+ const COPY_OFF = "Copy and cut shortcuts are off in this browser because a Vault password was filled.";
46
+ const SHOT_WITHHELD = "Screenshot withheld: a Vault password is readable on this page. Hide the password field's text, or use snapshot, which has it removed.";
47
+ const VALUE_SELECTOR_OFF = "Selectors that match on a field's value are off in this browser because a Vault password was filled. Select by id, name, role or label.";
48
+ const VALUE_SELECTOR = /\[\s*value\b|@value\b/i;
49
+ export const SCREENSHOT_WITHHELD = { content: [{ type: "text", text: SHOT_WITHHELD }], isError: true };
50
+ const ALTERED = "The password field was changed after Atomic filled it, so Atomic emptied it. Call vault_fill_login again to sign in. Until this browser is closed, a password field on this site only accepts a Vault fill.";
51
+ const SHOWN = "A Vault password is readable on this page, so only looking and clicking work here: snapshot, get_text, click and scroll by @ref or CSS selector, navigation, tabs and close. Hide the password, sign in or leave the page to continue.";
52
+ const UNREADABLE = "Atomic could not check this page for a filled Vault password, so only looking and clicking work until it can: snapshot, get_text, click and scroll by @ref or CSS selector, navigation, tabs and close.";
53
+ /** What a bot may still call while the password is readable on the page.
54
+ * Nothing here types, presses a key or matches on the page's text. */
55
+ const LOOK_ONLY = new Set(["snapshot", "get_text", "get_url", "get_title", "click", "scroll", "wait_ms", "wait_for_selector", "wait_for_load", "open", "back", "forward", "reload", "tab_new", "tab_list", "tab_switch", "tab_close", "tools_profiles"].map((name) => `agent_browser_${name}`));
56
+ /** A selector that matches on text answers yes or no about what the page shows. */
57
+ const TEXT_SELECTOR = /text|contains\s*\(/i;
58
+ const STALE = "This browser still holds a Vault password from before Atomic restarted. Close the browser with agent_browser_close, then open the page again.";
59
+ const COPY_KEYS = /^(?:(?:meta|control|ctrl|cmd|command)\+(?:shift\+)?(?:c|x|insert)|copy|cut)$/i;
60
+ const text = (value, isError = false) => ({ content: [{ type: "text", text: value }], ...(isError ? { isError: true } : {}) });
61
+ const textOf = (result) => (Array.isArray(result.content) ? result.content : [])
62
+ .map((part) => part && typeof part === "object" && typeof part.text === "string" ? part.text : "").join("\n");
63
+ /** Run a script that reports through one base64 marker, so the answer reads
64
+ * the same however the engine quotes or wraps an eval result. */
65
+ async function pageReport(call, body) {
66
+ const script = `(() => { const report = (value) => "af1:" + btoa(encodeURIComponent(JSON.stringify(value))) + ":1fa"; try { ${body} } catch (error) { return report({ failed: true }); } })()`;
67
+ const result = await call("agent_browser_eval", { script });
68
+ if (result.isError)
69
+ return null;
70
+ const match = /af1:([A-Za-z0-9+/=]+):1fa/.exec(textOf(result));
71
+ if (!match)
72
+ return null;
73
+ try {
74
+ return JSON.parse(decodeURIComponent(Buffer.from(match[1], "base64").toString("latin1")));
75
+ }
76
+ catch {
77
+ return null;
78
+ }
79
+ }
80
+ /** Find the sign-in fields in the top document and tag them for one fill.
81
+ * Only a real password field receives the password: a bot cannot point it at
82
+ * a field whose text it could read. Fields inside frames are never used. */
83
+ const locate = (tag) => `
84
+ const visible = (el) => { const box = el.getBoundingClientRect(); const style = getComputedStyle(el);
85
+ return box.width > 0 && box.height > 0 && style.visibility !== "hidden" && style.display !== "none" && !el.disabled && !el.readOnly; };
86
+ const inputs = [...document.querySelectorAll("input")].filter(visible);
87
+ const named = (el) => (el.getAttribute("autocomplete") || "") + " " + (el.getAttribute("name") || "") + " " + (el.id || "");
88
+ const textual = (el) => ["text", "email", "tel", ""].includes((el.getAttribute("type") || "").toLowerCase());
89
+ const passwords = inputs.filter((el) => el.type === "password");
90
+ const password = passwords.length === 1 ? passwords[0] : null;
91
+ let user = null;
92
+ if (password) {
93
+ const scope = password.form ? [...password.form.querySelectorAll("input")].filter(visible) : inputs;
94
+ const before = scope.filter((el) => textual(el) && (el.compareDocumentPosition(password) & Node.DOCUMENT_POSITION_FOLLOWING));
95
+ user = before.find((el) => /username|email/i.test(el.getAttribute("autocomplete") || "")) || before[before.length - 1] || null;
96
+ } else if (passwords.length === 0) {
97
+ const candidates = inputs.filter(textual);
98
+ user = candidates.find((el) => /user|email|login|ident|account/i.test(named(el))) || (candidates.length === 1 ? candidates[0] : null);
99
+ }
100
+ const form = (password || user) ? (password || user).form : null;
101
+ let action = location.origin;
102
+ if (form && form.getAttribute("action")) { try { action = new URL(form.getAttribute("action"), location.href).origin; } catch (error) { action = "invalid"; } }
103
+ for (const el of document.querySelectorAll("[data-atomic-vault]")) el.removeAttribute("data-atomic-vault");
104
+ if (user) user.setAttribute("data-atomic-vault", ${JSON.stringify(`${tag}-u`)});
105
+ if (password) password.setAttribute("data-atomic-vault", ${JSON.stringify(`${tag}-p`)});
106
+ return report({ passwords: passwords.length, user: Boolean(user), password: Boolean(password), action, top: window.top === window });`;
107
+ const untag = `for (const el of document.querySelectorAll("[data-atomic-vault]")) el.removeAttribute("data-atomic-vault"); return report({ ok: true });`;
108
+ /** What Atomic reads from the page to judge it: everything a screenshot
109
+ * could show as readable text (the page's text and the values of fields that
110
+ * are not password fields), and the values held by the top document's
111
+ * password fields. The password is never sent into the page to be compared
112
+ * there, because a page the bot opened later could be built to catch it; the
113
+ * comparison happens in Atomic. */
114
+ const READABLE_CAP = 3_000_000;
115
+ const inspect = `
116
+ const out = []; const fields = []; let size = 0; let cut = false;
117
+ const add = (value) => { if (typeof value !== "string" || !value) return; size += value.length; if (size > ${READABLE_CAP}) { cut = true; return; } out.push(value); };
118
+ const scan = (doc) => {
119
+ for (const el of doc.querySelectorAll("input, textarea")) {
120
+ if (el.type !== "password") add(el.value);
121
+ else if (doc === document && el.value) fields.push(String(el.value).slice(0, 10000));
122
+ }
123
+ add(doc.documentElement ? doc.documentElement.innerText : "");
124
+ for (const frame of doc.querySelectorAll("iframe, frame")) { try { if (frame.contentDocument) scan(frame.contentDocument); } catch (error) { /* another origin */ } }
125
+ };
126
+ scan(document);
127
+ return report({ origin: location.origin, texts: out, fields, cut });`;
128
+ /** Empty every password field in the top document the way typing would, so
129
+ * a page that keeps its own copy of the value forgets it too. */
130
+ const empty = `
131
+ const set = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
132
+ for (const el of document.querySelectorAll("input")) {
133
+ if (el.type !== "password" || !el.value) continue;
134
+ set.call(el, "");
135
+ el.dispatchEvent(new Event("input", { bubbles: true }));
136
+ el.dispatchEvent(new Event("change", { bubbles: true }));
137
+ }
138
+ return report({ ok: true });`;
139
+ export class VaultFill {
140
+ /** Browser session → the passwords filled into it, kept in memory only. */
141
+ filled = new Map();
142
+ /** Browser session → the websites a password was filled on. */
143
+ origins = new Map();
144
+ stateFile;
145
+ /** `stateFile` names where tainted session names (never passwords) are
146
+ * kept, so a browser that outlives an Atomic crash stays guarded. */
147
+ constructor(stateFile = () => null) { this.stateFile = stateFile; }
148
+ remembered() {
149
+ const file = this.stateFile();
150
+ if (!file)
151
+ return [];
152
+ try {
153
+ const value = JSON.parse(readFileSync(file, "utf8"));
154
+ return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
155
+ }
156
+ catch {
157
+ return [];
158
+ }
159
+ }
160
+ remember(session, held) {
161
+ const file = this.stateFile();
162
+ if (!file)
163
+ return;
164
+ const sessions = new Set(this.remembered());
165
+ if (held === sessions.has(session))
166
+ return;
167
+ if (held)
168
+ sessions.add(session);
169
+ else
170
+ sessions.delete(session);
171
+ try {
172
+ mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
173
+ writeFileAtomic(file, JSON.stringify([...sessions]), { mode: 0o600 });
174
+ }
175
+ catch { /* The in-memory guard still holds for this run. */ }
176
+ }
177
+ tainted(session) { return this.filled.has(session) || this.remembered().includes(session); }
178
+ /** A password was filled before Atomic restarted and the browser may still
179
+ * hold it. Atomic no longer knows the value, so nothing can be checked. */
180
+ stale(session) { return !this.filled.has(session) && this.remembered().includes(session); }
181
+ /** The browser session ended: its pages, and the passwords in them, are gone. */
182
+ clear(session) { this.filled.delete(session); this.origins.delete(session); this.remember(session, false); }
183
+ /** Each filled password as a page or an address could carry it: as typed,
184
+ * percent-encoded, form-encoded with "+" or "%20" for a space, and escaped
185
+ * for JSON or HTML. */
186
+ secrets(session) {
187
+ const out = new Set();
188
+ for (const secret of this.filled.get(session) ?? []) {
189
+ if (!secret)
190
+ continue;
191
+ const form = new URLSearchParams({ v: secret }).toString().slice(2);
192
+ const html = secret.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
193
+ for (const variant of [secret, encodeURIComponent(secret), encodeURI(secret), form, form.replace(/\+/g, "%20"), JSON.stringify(secret).slice(1, -1),
194
+ html, html.replace(/"/g, "&quot;"), html.replace(/"/g, "&quot;").replace(/'/g, "&#39;")])
195
+ out.add(variant);
196
+ }
197
+ return [...out].sort((x, y) => y.length - x.length);
198
+ }
199
+ /** Before a bot's call reaches the engine: a refusal, or the arguments to send. */
200
+ before(session, name, args) {
201
+ if (!this.tainted(session))
202
+ return { args };
203
+ if (this.stale(session) && name !== "agent_browser_close")
204
+ return { refuse: text(STALE, true) };
205
+ if (name === "agent_browser_eval")
206
+ return { refuse: text(EVAL_OFF, true) };
207
+ if (name === "agent_browser_press" && typeof args.key === "string" && COPY_KEYS.test(args.key.replace(/\s+/g, "")))
208
+ return { refuse: text(COPY_OFF, true) };
209
+ // A selector that tests a field's value answers yes or no, which reads
210
+ // the password out one character at a time.
211
+ if (Object.entries(args).some(([key, value]) => /selector/i.test(key) && typeof value === "string" && VALUE_SELECTOR.test(value)))
212
+ return { refuse: text(VALUE_SELECTOR_OFF, true) };
213
+ if (name === "agent_browser_screenshot") {
214
+ const { path: _path, screenshotDir: _dir, ...rest } = args;
215
+ return { args: rest };
216
+ }
217
+ return { args };
218
+ }
219
+ /** Read the page and judge it. A password field on a filled website that
220
+ * holds anything but a filled password was edited: it is emptied here,
221
+ * before the bot's next call, because an edited copy would pass every
222
+ * comparison once the site showed it as text. */
223
+ async state(session, call) {
224
+ const report = await pageReport(call, inspect).catch(() => null);
225
+ if (!report || report.failed || report.cut || !Array.isArray(report.texts) || !Array.isArray(report.fields))
226
+ return "unknown";
227
+ const filled = this.filled.get(session) ?? new Set();
228
+ const here = typeof report.origin === "string" && this.origins.get(session)?.has(report.origin) === true;
229
+ const altered = here && report.fields.some((value) => typeof value !== "string" || !filled.has(value));
230
+ if (altered)
231
+ await pageReport(call, empty).catch(() => null);
232
+ const secrets = this.secrets(session);
233
+ const shown = report.texts.some((value) => typeof value === "string" && secrets.some((secret) => value.includes(secret)));
234
+ return shown ? "shown" : altered ? "altered" : "clean";
235
+ }
236
+ /** Before a bot's call reaches the engine, after `before`: a refusal when
237
+ * the page's state does not allow the call, or null to let it through. */
238
+ async guard(session, name, args, call) {
239
+ if (!this.tainted(session) || name === "agent_browser_close")
240
+ return null;
241
+ const state = await this.state(session, call);
242
+ if (state === "clean")
243
+ return null;
244
+ if (state === "altered")
245
+ return text(ALTERED, true);
246
+ if (name === "agent_browser_screenshot")
247
+ return SCREENSHOT_WITHHELD;
248
+ const probing = Object.entries(args).some(([key, value]) => /selector/i.test(key) && typeof value === "string" && TEXT_SELECTOR.test(value));
249
+ return LOOK_ONLY.has(name) && !probing ? null : text(state === "shown" ? SHOWN : UNREADABLE, true);
250
+ }
251
+ /** The result with every filled password removed from its text. Runs
252
+ * before a long result is cut to size, so a cut can never leave part of a
253
+ * password behind. */
254
+ scrub(session, result) {
255
+ if (!this.filled.has(session) || !result || typeof result !== "object" || !Array.isArray(result.content))
256
+ return result;
257
+ const secrets = this.secrets(session);
258
+ const clean = (value) => secrets.reduce((out, secret) => out.split(secret).join("[redacted]"), value);
259
+ return {
260
+ ...result,
261
+ content: result.content.map((part) => part && typeof part === "object" && typeof part.text === "string"
262
+ ? { ...part, text: clean(part.text) } : part),
263
+ };
264
+ }
265
+ /** After the engine answered a bot's call: the result the bot may see. */
266
+ async after(session, result, call) {
267
+ if (!this.tainted(session) || !result || typeof result !== "object")
268
+ return result;
269
+ const state = await this.state(session, call);
270
+ if (state === "altered")
271
+ return text(ALTERED, true);
272
+ const image = (Array.isArray(result.content) ? result.content : []).some((part) => part && typeof part === "object" && part.type !== "text");
273
+ if (image && state !== "clean")
274
+ return SCREENSHOT_WITHHELD;
275
+ return this.scrub(session, result);
276
+ }
277
+ /** The vault_fill_login tool. Every refusal about the item reads the same
278
+ * whether it is missing, not granted, expired, not a login or for another site. */
279
+ async fill(session, access, args, call, now = Date.now()) {
280
+ if (this.stale(session))
281
+ return text(STALE, true);
282
+ if (!access)
283
+ return text("Vault is locked on this computer. It unlocks when the Atomic desktop app is open.", true);
284
+ const itemId = typeof args.item_id === "string" ? args.item_id : "";
285
+ if (!/^[0-9a-f-]{36}$/.test(itemId))
286
+ return text("vault_fill_login needs item_id from vault_request.", true);
287
+ const pageOrigin = async () => vaultOrigin(textOf(await call("agent_browser_get_url", {})).match(/https:\/\/[^\s"'<>]+/)?.[0] ?? "");
288
+ const destination = await pageOrigin();
289
+ if (!destination)
290
+ return text("Open the site's sign-in page (an https:// address) before filling a login.", true);
291
+ let login;
292
+ try {
293
+ login = access.store.loginFor({ ownerId: access.ownerId, botId: access.botId, destination }, itemId, now);
294
+ }
295
+ catch (error) {
296
+ return text(error instanceof VaultError ? error.message : "Vault could not complete the request.", true);
297
+ }
298
+ if (!login)
299
+ return text(REFUSED, true);
300
+ const tag = randomBytes(8).toString("hex");
301
+ const found = await pageReport(call, locate(tag));
302
+ if (!found || found.failed)
303
+ return text("The sign-in form could not be read on this page.", true);
304
+ try {
305
+ if (!found.top)
306
+ return text("The sign-in form is inside a frame. Open the sign-in page directly.", true);
307
+ if (found.passwords > 1)
308
+ return text("This page has more than one password field, so it looks like a sign-up or change-password form. A saved login is only filled into a sign-in form.", true);
309
+ if (!found.user && !found.password)
310
+ return text("No sign-in field was found on this page. Open the sign-in form first.", true);
311
+ if (found.action !== destination)
312
+ return text("This form sends what is typed to a different website, so the login was not filled.", true);
313
+ if (found.user) {
314
+ const typed = await call("agent_browser_fill", { selector: `[data-atomic-vault="${tag}-u"]`, text: login.username });
315
+ if (typed.isError)
316
+ return text("The username field could not be filled.", true);
317
+ }
318
+ if (!found.password)
319
+ return text("Filled the username. Continue to the password step, then call vault_fill_login again.");
320
+ // The page may have moved while the username was typed.
321
+ if (await pageOrigin() !== destination)
322
+ return text("The page changed before the password was typed, so it was not filled.", true);
323
+ // From here the password is in the page: guard the session first.
324
+ const set = this.filled.get(session) ?? new Set();
325
+ set.add(login.password);
326
+ this.filled.set(session, set);
327
+ this.origins.set(session, (this.origins.get(session) ?? new Set()).add(destination));
328
+ this.remember(session, true);
329
+ const typed = await call("agent_browser_fill", { selector: `[data-atomic-vault="${tag}-p"]`, text: login.password });
330
+ if (typed.isError)
331
+ return text("The password field could not be filled.", true);
332
+ return text(found.user ? "Filled the username and password. Click the sign-in button to continue." : "Filled the password. Click the sign-in button to continue.");
333
+ }
334
+ finally {
335
+ await pageReport(call, untag).catch(() => null);
336
+ }
337
+ }
338
+ }
@@ -150,9 +150,13 @@ export function createVaultBotRoutes(deps) {
150
150
  return json(res, 503, { error: "Vault is locked on this computer. It unlocks when the Atomic desktop app is open." });
151
151
  try {
152
152
  if (path === "/api/internal/vault/keys" && method === "GET") {
153
- const items = store.apiKeysFor(ownerId, botId, (deps.now ?? Date.now)())
153
+ const now = (deps.now ?? Date.now)();
154
+ const items = store.apiKeysFor(ownerId, botId, now)
154
155
  .map(({ id, label, hints, origins, header, expiresAt }) => ({ id, label, hints, origins, header, expiresAt }));
155
- return json(res, 200, { items });
156
+ // Logins are filled by the browser's vault_fill_login tool, on their website only.
157
+ const logins = store.loginsFor(ownerId, botId, now)
158
+ .map(({ id, label, hints, origins, username, expiresAt }) => ({ id, label, hints, website: origins[0], username, expiresAt }));
159
+ return json(res, 200, { items, logins });
156
160
  }
157
161
  if (path === "/api/internal/vault/request" && method === "POST") {
158
162
  const body = await readBody(req, MAX_REQUEST_BODY + 200_000).catch(() => null);
@@ -23,8 +23,8 @@ export function createVaultRoutes(deps) {
23
23
  if (typeof body?.csv !== "string")
24
24
  return json(res, 400, { error: "Choose a CSV file exported from your password manager." });
25
25
  try {
26
- const { logins, skipped } = vaultLoginsFromCsv(body.csv, typeof body.group === "string" && body.group ? body.group : undefined);
27
- return json(res, 200, { ...store.importLogins(ownerId, logins), skipped });
26
+ const { logins, apiKeys, skipped, needAddress } = vaultLoginsFromCsv(body.csv, typeof body.group === "string" && body.group ? body.group : undefined);
27
+ return json(res, 200, { ...store.importLogins(ownerId, [...logins, ...apiKeys]), skipped, needAddress });
28
28
  }
29
29
  catch (error) {
30
30
  // Neither message echoes anything from a row.
@@ -33,6 +33,18 @@ export function createVaultRoutes(deps) {
33
33
  return json(res, 503, { error: "Vault could not complete the request." });
34
34
  }
35
35
  }
36
+ if (path === "/api/vault/allow-all-bots") {
37
+ if (method !== "POST")
38
+ return json(res, 405, { error: "Method not allowed." });
39
+ try {
40
+ return json(res, 200, { changed: store.allowAllBots(ownerId) });
41
+ }
42
+ catch (error) {
43
+ if (error instanceof VaultError)
44
+ return json(res, 400, { error: error.message });
45
+ return json(res, 503, { error: "Vault could not complete the request." });
46
+ }
47
+ }
36
48
  const item = /^\/api\/vault\/([0-9a-f-]{36})$/.exec(path);
37
49
  if (path !== "/api/vault" && !item)
38
50
  return json(res, 404, { error: "Vault item is unavailable." });
@@ -48,11 +48,25 @@ export class NativeVaultRuntime {
48
48
  * of a bot's own turn on this computer, never an external runtime. */
49
49
  export function installNativeVault(dataDir, port, desktopToken, caller) {
50
50
  const runtime = new NativeVaultRuntime(join(dataDir, "providers", "native-vault"));
51
+ installed = runtime;
52
+ fillState = join(dataDir, "providers", "native-vault", "filled-sessions.json");
51
53
  port?.on("message", (event) => { runtime.receive(event?.data); });
52
54
  ROUTES.push(createVaultRoutes({ store: () => runtime.store(), owner: (req, auth) => caller(req) ? null : runtime.owner(req, auth, desktopToken()) }));
53
55
  ROUTES.push(createVaultBotRoutes({ store: () => runtime.store(), ownerId: () => runtime.ownerId(),
54
56
  bot: (req) => vaultBot(caller(req)), downloadDir: (botId) => join(dataDir, "vault-downloads", botId) }));
55
57
  }
58
+ let fillState = null;
59
+ /** Where the browser sessions holding a filled password are remembered
60
+ * across a restart. Session names only, never a password. */
61
+ export function vaultFillStateFile() { return fillState; }
62
+ let installed = null;
63
+ /** The unlocked vault, for the browser's trusted login fill. Null while the
64
+ * vault is locked or this server has none. */
65
+ export function unlockedVault() {
66
+ const store = installed?.store();
67
+ const ownerId = installed?.ownerId();
68
+ return store && ownerId ? { store, ownerId } : null;
69
+ }
56
70
  export function vaultBot(caller) {
57
71
  return caller && caller.kind === "agents" && !caller.externalRuntime ? caller.botId : null;
58
72
  }
@@ -7,7 +7,7 @@ import { createCipheriv, createDecipheriv, randomBytes, randomUUID } from "node:
7
7
  import { lstatSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
8
8
  import { join } from "node:path";
9
9
  import { z } from "zod";
10
- import { vaultInputSchema, vaultMetadata, vaultUseAllowed } from "../../shared/vault.js";
10
+ import { vaultGranted, vaultInputSchema, vaultMetadata, vaultUseAllowed } from "../../shared/vault.js";
11
11
  import { writeFileAtomic } from "../atomic.js";
12
12
  const MAX_BYTES = 16 * 1024 * 1024;
13
13
  const MAX_ITEMS = 3000;
@@ -134,9 +134,25 @@ export class VaultStore {
134
134
  /** The API keys this bot may use now: granted to it and not expired. */
135
135
  apiKeysFor(ownerId, botId, now) {
136
136
  owner(ownerId);
137
- return this.read().filter((item) => item.kind === "apiKey" && item.ownerId === ownerId && item.botIds.includes(botId)
137
+ return this.read().filter((item) => item.kind === "apiKey" && item.ownerId === ownerId && vaultGranted(item, botId)
138
138
  && (item.expiresAt === null || now < item.expiresAt)).map(vaultMetadata);
139
139
  }
140
+ /** The logins this bot may have filled for it now. Never the password. */
141
+ loginsFor(ownerId, botId, now) {
142
+ owner(ownerId);
143
+ return this.read().filter((item) => item.kind === "login" && item.ownerId === ownerId && vaultGranted(item, botId)
144
+ && (item.expiresAt === null || now < item.expiresAt)).map(vaultMetadata);
145
+ }
146
+ /** The username and password for one fill, or null when this bot may not
147
+ * use this login on this website now. For the trusted fill only: the
148
+ * password must never reach a response, a log or a model. */
149
+ loginFor(actor, id, now) {
150
+ owner(actor.ownerId);
151
+ const item = this.read().find((candidate) => candidate.id === id);
152
+ if (!item || item.kind !== "login" || !vaultUseAllowed(item, actor, now))
153
+ return null;
154
+ return { username: item.username, password: item.password };
155
+ }
140
156
  /** The header to send for one use, or null when this bot may not use this
141
157
  * item at this destination now. For the request executor only: the value
142
158
  * must never reach a response, a log or a model. */
@@ -163,13 +179,34 @@ export class VaultStore {
163
179
  }
164
180
  /** Adds logins in one write. A login already saved for the same website
165
181
  * and username is left as it is and counted in `duplicates`. */
182
+ /** One click for items saved before "every bot" existed: every login and
183
+ * API key of this owner becomes usable by all of the owner's bots, still
184
+ * only on its own website or addresses. Cards and contact details are
185
+ * left alone (bots cannot use them). Returns how many changed. */
186
+ allowAllBots(ownerId) {
187
+ owner(ownerId);
188
+ return this.mutate((items) => {
189
+ const now = Date.now();
190
+ let changed = 0;
191
+ for (const item of items) {
192
+ if (item.ownerId !== ownerId || item.allBots === true || (item.kind !== "login" && item.kind !== "apiKey"))
193
+ continue;
194
+ item.allBots = true;
195
+ item.updatedAt = now;
196
+ changed++;
197
+ }
198
+ return changed;
199
+ });
200
+ }
166
201
  importLogins(ownerId, logins) {
167
202
  owner(ownerId);
168
203
  const parsed = logins.map((input) => vaultInputSchema.safeParse(input));
169
204
  if (parsed.some((result) => !result.success))
170
205
  throw new VaultError("Invalid Vault item.");
171
206
  return this.mutate((items) => {
172
- const key = (item) => item.kind === "login" ? `${item.website}\n${item.username}` : "";
207
+ // A login is the same login by website and username; an API token by where it is sent, how, and its name.
208
+ const key = (item) => item.kind === "login" ? `${item.website}\n${item.username}`
209
+ : item.kind === "apiKey" ? `key\n${item.origins.join(",")}\n${item.header.toLowerCase()}\n${item.label}` : `${item.kind}\n${item.label}`;
173
210
  const seen = new Set(items.filter((item) => item.ownerId === ownerId).map(key));
174
211
  const now = Date.now();
175
212
  let added = 0;
@@ -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();
@@ -47,8 +47,19 @@ export const DEFAULT_CLASS_BANDS = { Mezcal: 50, Plata: 44, Reposado: 38 };
47
47
  * ("claude-<uuid>") reduced to its driver kind so a fresh install matches
48
48
  * whatever account it has (matchesEngine); the exact engine+model
49
49
  * duplicates that collapse created are dropped. */
50
+ /** Chibi's default on every install (Erick, 2026-11-13): Automatic, the
51
+ * Plata class, starting on Claude Sonnet 5.5. It is the first rung of the
52
+ * Orchestrator's ladder, hand-written or generated, and the model Chibi is
53
+ * made on. The rung carries its class, so failover treats it as Plata
54
+ * whatever a leaderboard scores it. */
55
+ export const CHIBI_DEFAULT_RUNG = Object.freeze({ engine: "claudeAgent", model: "claude-sonnet-5-5", modelClass: "Plata" });
56
+ /** Raised whenever Chibi's default changes: each install whose Chibi holds
57
+ * an older number is put back on the default once, whatever it was set to
58
+ * (BotRecord.chibiDefaults, server/store.ts applyChibiDefaults). */
59
+ export const CHIBI_DEFAULTS_VERSION = 1;
50
60
  export const DEFAULT_LADDERS = {
51
61
  orchestrator: [
62
+ { ...CHIBI_DEFAULT_RUNG },
52
63
  { engine: "claudeAgent", model: "claude-opus-5-5", modelClass: "Plata" },
53
64
  { engine: "codex", model: "gpt-6-sol" },
54
65
  { engine: "opencodeGo", model: "opencode-go/gemini-4-argon" },
@@ -122,7 +133,7 @@ export function classForScore(score, bands = DEFAULT_CLASS_BANDS) {
122
133
  * Settings (config.json `engineTiers.classes`). */
123
134
  export const DEFAULT_TIER_CLASSES = {
124
135
  // Chibi runs on Claude at Plata (Erick, 2026-10-13); server/engine-tiers.ts
125
- // puts Claude's rungs first in its ladder.
136
+ // puts CHIBI_DEFAULT_RUNG, then Claude's other rungs, first in its ladder.
126
137
  orchestrator: "Plata",
127
138
  engineering: "Mezcal",
128
139
  // Research and Routine ask for the cheapest class (Erick, 2026-10-25).
@@ -178,3 +189,20 @@ export function effortShort(effort) {
178
189
  default: return undefined;
179
190
  }
180
191
  }
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) {
204
+ if (entry.anyAccount || accounts.length < 2 || accounts.some((account) => account.instanceId === entry.engine))
205
+ return accounts;
206
+ const usable = accounts.filter((account) => !passedOver?.(account));
207
+ return [usable.find((account) => account.instanceId === own) ?? usable[0] ?? accounts[0]];
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;
@@ -65,9 +65,11 @@ export const ACCOUNT_PROVIDERS = [
65
65
  config: {}, keyTest: { provider: "ollamaCloud" }, keyUrl: "https://ollama.com/settings/keys", signupUrl: "https://ollama.com/pricing",
66
66
  },
67
67
  {
68
- // Nous Portal's OpenAI-compatible API, signed in with a portal key. No
69
- // Hermes needed (Erick, 2026-11-08).
70
- id: "nous", kind: "apiKey", label: "Nous Research", billing: "subscription", driver: "openai-compat", envVar: "NOUS_API_KEY",
68
+ // Nous Portal's OpenAI-compatible API with a portal key: no Hermes needed
69
+ // (Erick, 2026-11-08). Charged per use: Nous Portal states that API keys
70
+ // always use credits, never the plan's included usage (checked
71
+ // 2026-11-13). The subscription is the sign-in, through Hermes.
72
+ id: "nous", kind: "apiKey", label: "Nous Research", billing: "payPerUse", driver: "openai-compat", envVar: "NOUS_API_KEY",
71
73
  config: { url: "https://inference-api.nousresearch.com/v1", apiKeyEnv: "NOUS_API_KEY", model: "Hermes-4-405B", provider: "" },
72
74
  keyTest: { provider: "openaiCompat", url: "https://inference-api.nousresearch.com/v1" }, keyUrl: "https://portal.nousresearch.com/", signupUrl: "https://portal.nousresearch.com/",
73
75
  },