@chibitek/chibi 0.1.186 → 0.1.190

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 (110) hide show
  1. package/dist/assets/{abnfDiagram-O67JEVCF-T4rFqxxY.js → abnfDiagram-O67JEVCF-Bz3wlNsQ.js} +1 -1
  2. package/dist/assets/{arc-BE0n08tb.js → arc-CX0dJSa0.js} +1 -1
  3. package/dist/assets/{architectureDiagram-NJMV4G6O-W248FhnN.js → architectureDiagram-NJMV4G6O-APIM9yGf.js} +1 -1
  4. package/dist/assets/{blockDiagram-BEXU5L5S-YQUaYL76.js → blockDiagram-BEXU5L5S-DNmNNaVY.js} +1 -1
  5. package/dist/assets/{c4Diagram-YGBWAQC7-DvtNnJ7Q.js → c4Diagram-YGBWAQC7-CAPPUeMU.js} +1 -1
  6. package/dist/assets/channel-CnfDal05.js +1 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-r9zB0AN4.js → chunk-2Q5K7J3B-DfCDsQgU.js} +1 -1
  8. package/dist/assets/{chunk-3FUC2YCW-DcaWZ44l.js → chunk-3FUC2YCW-vdffwGmy.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-B9BoCCOM.js → chunk-5VM5RSS4-BazIL_2e.js} +1 -1
  10. package/dist/assets/{chunk-GTNCS2PH-jiyufqr5.js → chunk-GTNCS2PH-GpKjNZ-V.js} +1 -1
  11. package/dist/assets/{chunk-GWA4HPMP-86KjuKSi.js → chunk-GWA4HPMP-BuRq21LZ.js} +1 -1
  12. package/dist/assets/{chunk-JWPE2WC7-P-CZmlpX.js → chunk-JWPE2WC7-CqNGOyHV.js} +1 -1
  13. package/dist/assets/{chunk-NETBCI7D-DOwQkah7.js → chunk-NETBCI7D-B1DpzVCP.js} +1 -1
  14. package/dist/assets/{chunk-WEXAMYUT-BYpUWdau.js → chunk-WEXAMYUT-DcH1Euc6.js} +1 -1
  15. package/dist/assets/{chunk-XXDRQBXY-BNWicp85.js → chunk-XXDRQBXY-M1JLd_cm.js} +1 -1
  16. package/dist/assets/{classDiagram-v2-NBCMYWYE-DeSoK71a.js → classDiagram-v2-NBCMYWYE-C8mBZ7i2.js} +1 -1
  17. package/dist/assets/{cose-bilkent-JH36ORCC-DRvyy4x6.js → cose-bilkent-JH36ORCC-Cr3TqHDz.js} +1 -1
  18. package/dist/assets/{cynefin-OW5HDTMX-BPgTdM9o.js → cynefin-OW5HDTMX-BKPr6l0I.js} +1 -1
  19. package/dist/assets/{cynefinDiagram-VND7K2PF-CVqWmCzX.js → cynefinDiagram-VND7K2PF-Cbg5mrIM.js} +1 -1
  20. package/dist/assets/{dagre-6A5THRUB-C8Nn1Pd7.js → dagre-6A5THRUB-9I9X1J3r.js} +1 -1
  21. package/dist/assets/{diagram-22UHCM2B-BoFPCHMw.js → diagram-22UHCM2B-B43b8pqQ.js} +1 -1
  22. package/dist/assets/{diagram-3UASUU5V-Bw55J1mb.js → diagram-3UASUU5V-CIehgEkZ.js} +1 -1
  23. package/dist/assets/{diagram-ATOU4E4O-DGQrBqML.js → diagram-ATOU4E4O-gx8nkXLZ.js} +1 -1
  24. package/dist/assets/{diagram-CDSNMT55-COdY5ptf.js → diagram-CDSNMT55-BZzWgYHa.js} +1 -1
  25. package/dist/assets/{diagram-MLGK6HIB-BPZDoncY.js → diagram-MLGK6HIB-BqoCqkZD.js} +1 -1
  26. package/dist/assets/{diagram-MPIPVDR6-Fi29WkCR.js → diagram-MPIPVDR6-Bsc7x0UT.js} +1 -1
  27. package/dist/assets/{ebnfDiagram-ZINNZB2B-BXquz6x1.js → ebnfDiagram-ZINNZB2B-8HjdD_s8.js} +1 -1
  28. package/dist/assets/{elk-276RUBZZ-C_e9eijP.js → elk-276RUBZZ-bmxiEFtT.js} +1 -1
  29. package/dist/assets/{erDiagram-OPXOYQCR-C4PKtrfT.js → erDiagram-OPXOYQCR-BU-sRLe3.js} +1 -1
  30. package/dist/assets/{flowDiagram-KWPJA3E3-BlEulfZP.js → flowDiagram-KWPJA3E3-D45vn40U.js} +1 -1
  31. package/dist/assets/{ganttDiagram-FUAMR5RP-BksDszQx.js → ganttDiagram-FUAMR5RP-CArB98Hu.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-X574FWY7-EYJKMot5.js → gitGraphDiagram-X574FWY7-fPB1k-W7.js} +1 -1
  33. package/dist/assets/{index-Bf2yMkX_.js → index-QsXeEMxJ.js} +142 -142
  34. package/dist/assets/{index-Do0zrygp.js → index-u1wvoacp.js} +1 -1
  35. package/dist/assets/{infoDiagram-VRGFBTTK-BuX8YJRd.js → infoDiagram-VRGFBTTK-ZRVWXAr4.js} +1 -1
  36. package/dist/assets/{ishikawaDiagram-OU5B5YK6-BOOBBq5e.js → ishikawaDiagram-OU5B5YK6-DOaurRbX.js} +1 -1
  37. package/dist/assets/{journeyDiagram-ZHPQQLJL-2VfxHa4O.js → journeyDiagram-ZHPQQLJL-Ca9B-09w.js} +1 -1
  38. package/dist/assets/{kanban-definition-PNTS6WVX-DniBc17b.js → kanban-definition-PNTS6WVX-CA2XswEJ.js} +1 -1
  39. package/dist/assets/{linear-CrF1eGjn.js → linear-B-F7icip.js} +1 -1
  40. package/dist/assets/{mermaid.core-BL_dHjXO.js → mermaid.core-ymtCpbZ5.js} +5 -5
  41. package/dist/assets/{mindmap-definition-NLK3R4M7-DUGzdUse.js → mindmap-definition-NLK3R4M7-02vIazCi.js} +1 -1
  42. package/dist/assets/{pegDiagram-GJSIUBJH-CO3xT6J0.js → pegDiagram-GJSIUBJH-DRb7Pn72.js} +1 -1
  43. package/dist/assets/{pieDiagram-5QR66LMP-8gmuAKxu.js → pieDiagram-5QR66LMP-B2YwP3S_.js} +1 -1
  44. package/dist/assets/{quadrantDiagram-O4NWA36T-D0I0xUDm.js → quadrantDiagram-O4NWA36T-CbR573mu.js} +1 -1
  45. package/dist/assets/{railroadDiagram-XR7U4H2S-DY0BvxgQ.js → railroadDiagram-XR7U4H2S-CqHuDCnM.js} +1 -1
  46. package/dist/assets/{requirementDiagram-PLB6GJNP-DhGe1AaP.js → requirementDiagram-PLB6GJNP-BSeC-H1j.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-IPEJSGJF-CeCrbMFN.js → sankeyDiagram-IPEJSGJF-BMFuhoh1.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-PO4LG4MO-fWSeitKd.js → sequenceDiagram-PO4LG4MO-DRT_EI9u.js} +1 -1
  49. package/dist/assets/{sizeCapture-INFHLROL-Dtg_1bqe.js → sizeCapture-INFHLROL-BLFT4fV7.js} +1 -1
  50. package/dist/assets/{stateDiagram-v2-GCMORJYK-DGUAiQQE.js → stateDiagram-v2-GCMORJYK-C8vB_69H.js} +1 -1
  51. package/dist/assets/{swimlanes-2SLR337P-DebVwPYw.js → swimlanes-2SLR337P-T6BBolT8.js} +1 -1
  52. package/dist/assets/swimlanesDiagram-TC7HE7FX-BIY4fGCv.js +8 -0
  53. package/dist/assets/{timeline-definition-EJHVYXUP-Dg7oYgtr.js → timeline-definition-EJHVYXUP-DjdjBRQV.js} +1 -1
  54. package/dist/assets/{usecaseDiagram-POWQR4AR-uqTnPXSC.js → usecaseDiagram-POWQR4AR-CDGccZMN.js} +1 -1
  55. package/dist/assets/{vennDiagram-UO4OBE2U-CzMUwXwR.js → vennDiagram-UO4OBE2U-CgYSihtW.js} +1 -1
  56. package/dist/assets/{wardleyDiagram-VNRHLVJA-BsyaKB_7.js → wardleyDiagram-VNRHLVJA-Bub5ScM8.js} +1 -1
  57. package/dist/assets/{xychartDiagram-PMCCYNJV-7hUye0pF.js → xychartDiagram-PMCCYNJV-DK5iMX67.js} +1 -1
  58. package/dist/index.html +1 -1
  59. package/dist-server/drivers/agents-proxy.js +52 -2
  60. package/dist-server/index.js +4413 -3656
  61. package/dist-server/openmausbot.js +1432 -878
  62. package/dist-server/pair-cli.js +1432 -878
  63. package/dist-server/server/about-me-sync.js +16 -5
  64. package/dist-server/server/box.js +18 -14
  65. package/dist-server/server/browser-engine.js +4 -26
  66. package/dist-server/server/browser-runtime.js +41 -5
  67. package/dist-server/server/calendar-calls.js +2 -1
  68. package/dist-server/server/capped-body.js +26 -0
  69. package/dist-server/server/chibi-defaults.js +96 -0
  70. package/dist-server/server/cli-login.js +4 -0
  71. package/dist-server/server/connection-cap-failover.js +0 -2
  72. package/dist-server/server/container-computer.js +9 -9
  73. package/dist-server/server/drivers/agents-call.js +3 -3
  74. package/dist-server/server/drivers/agents-catalog.js +2 -2
  75. package/dist-server/server/drivers/agents-credential.js +6 -0
  76. package/dist-server/server/drivers/agents-vault.js +36 -0
  77. package/dist-server/server/engine-failover.js +6 -3
  78. package/dist-server/server/engine-tiers.js +8 -8
  79. package/dist-server/server/hidden-ai-text.js +56 -0
  80. package/dist-server/server/index.js +37 -41
  81. package/dist-server/server/local-vm-run.js +10 -0
  82. package/dist-server/server/model-levels/aliases.js +7 -2
  83. package/dist-server/server/model-levels/index.js +7 -0
  84. package/dist-server/server/request-auth.js +15 -18
  85. package/dist-server/server/routes/message-file.js +1 -1
  86. package/dist-server/server/routines.js +6 -6
  87. package/dist-server/server/store.js +1 -1
  88. package/dist-server/server/stream-tail.js +25 -0
  89. package/dist-server/server/system-prompt.js +17 -2
  90. package/dist-server/server/team-rooms/backend.js +9 -4
  91. package/dist-server/server/team-rooms/service.js +1 -1
  92. package/dist-server/server/team-rooms/testing/fake-rooms-backend.js +10 -4
  93. package/dist-server/server/vault/fill.js +338 -0
  94. package/dist-server/server/vault/request.js +178 -0
  95. package/dist-server/server/vault/routes.js +14 -2
  96. package/dist-server/server/vault/runtime.js +27 -3
  97. package/dist-server/server/vault/store.js +60 -5
  98. package/dist-server/server/vps-computer.js +12 -30
  99. package/dist-server/server/watch-along/budget.js +11 -3
  100. package/dist-server/server/watch-along/live.js +4 -2
  101. package/dist-server/shared/engine-tiers.js +23 -1
  102. package/dist-server/shared/provider-accounts.js +5 -3
  103. package/dist-server/shared/subscription-bots.js +14 -6
  104. package/dist-server/shared/vault-api-providers.js +48 -0
  105. package/dist-server/shared/vault-csv.js +62 -14
  106. package/dist-server/shared/vault.js +20 -2
  107. package/dist-server/vps-container-mcp.js +3 -1
  108. package/package.json +1 -1
  109. package/dist/assets/channel-DhsCc8Nd.js +0 -1
  110. package/dist/assets/swimlanesDiagram-TC7HE7FX-B5p2N9qd.js +0 -8
@@ -1,11 +1,13 @@
1
- // Native Vault persistence. No API/OAuth credentials are stored here.
2
- // The caller supplies a key from the trusted runtime; this module never
3
- // creates a plaintext key file or returns stored secrets to a model.
1
+ // Native Vault persistence. Atomic's own provider and OAuth credentials are
2
+ // not stored here. The caller supplies a key from the trusted runtime; this
3
+ // module never creates a plaintext key file or returns stored secrets to a
4
+ // model. `apiKeyFor` hands a saved API key to the trusted request executor
5
+ // only, after the grant, expiry and destination checks.
4
6
  import { createCipheriv, createDecipheriv, randomBytes, randomUUID } from "node:crypto";
5
7
  import { lstatSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
6
8
  import { join } from "node:path";
7
9
  import { z } from "zod";
8
- import { vaultInputSchema, vaultMetadata } from "../../shared/vault.js";
10
+ import { vaultGranted, vaultInputSchema, vaultMetadata, vaultUseAllowed } from "../../shared/vault.js";
9
11
  import { writeFileAtomic } from "../atomic.js";
10
12
  const MAX_BYTES = 16 * 1024 * 1024;
11
13
  const MAX_ITEMS = 3000;
@@ -129,6 +131,38 @@ export class VaultStore {
129
131
  owner(ownerId);
130
132
  return this.read().filter((item) => item.ownerId === ownerId).map(vaultMetadata);
131
133
  }
134
+ /** The API keys this bot may use now: granted to it and not expired. */
135
+ apiKeysFor(ownerId, botId, now) {
136
+ owner(ownerId);
137
+ return this.read().filter((item) => item.kind === "apiKey" && item.ownerId === ownerId && vaultGranted(item, botId)
138
+ && (item.expiresAt === null || now < item.expiresAt)).map(vaultMetadata);
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
+ }
156
+ /** The header to send for one use, or null when this bot may not use this
157
+ * item at this destination now. For the request executor only: the value
158
+ * must never reach a response, a log or a model. */
159
+ apiKeyFor(actor, id, now) {
160
+ owner(actor.ownerId);
161
+ const item = this.read().find((candidate) => candidate.id === id);
162
+ if (!item || item.kind !== "apiKey" || !vaultUseAllowed(item, actor, now))
163
+ return null;
164
+ return { header: item.header, value: item.prefix + item.secret, secret: item.secret };
165
+ }
132
166
  create(ownerId, input) {
133
167
  owner(ownerId);
134
168
  const parsed = vaultInputSchema.safeParse(input);
@@ -145,13 +179,34 @@ export class VaultStore {
145
179
  }
146
180
  /** Adds logins in one write. A login already saved for the same website
147
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
+ }
148
201
  importLogins(ownerId, logins) {
149
202
  owner(ownerId);
150
203
  const parsed = logins.map((input) => vaultInputSchema.safeParse(input));
151
204
  if (parsed.some((result) => !result.success))
152
205
  throw new VaultError("Invalid Vault item.");
153
206
  return this.mutate((items) => {
154
- 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}`;
155
210
  const seen = new Set(items.filter((item) => item.ownerId === ownerId).map(key));
156
211
  const now = Date.now();
157
212
  let added = 0;
@@ -9,6 +9,7 @@ import { DATA_DIR, isValidSshAlias, vpsSshAlias } from "./config.js";
9
9
  import { augmentedPath, resolveCliSpawn } from "./env-path.js";
10
10
  import { planOptions } from "./spawn-command.js";
11
11
  import { prepareVpsSsh } from "./vps-ssh.js";
12
+ import { tailCollector } from "./stream-tail.js";
12
13
  import { loadEnvironmentId } from "./environment.js";
13
14
  import { SPAWNED_PROXIES } from "./proxy-paths.js";
14
15
  export const VPS_IMAGE = CUA_IMAGE;
@@ -190,42 +191,18 @@ export function closeAllVpsDesktopTunnels() {
190
191
  for (const botId of desktopTunnels.keys())
191
192
  stopDesktopTunnel(botId);
192
193
  }
193
- const STREAM_CAP_CHARS = 16 * 1024 * 1024;
194
- /** Keeps the LAST 16MB of a stream without rebuilding one giant string per
195
- * chunk (a 10-minute `docker build` stream made that rebuild quadratic).
196
- * Chunks fall off the front as soon as the tail alone covers the cap; the
197
- * final slice preserves the exact cap semantics of the old accumulator. */
198
- function tailCollector() {
199
- const chunks = [];
200
- let total = 0;
201
- return {
202
- push(chunk) {
203
- chunks.push(chunk);
204
- total += chunk.length;
205
- for (;;) {
206
- const first = chunks[0];
207
- if (chunks.length < 2 || first === undefined || total - first.length < STREAM_CAP_CHARS)
208
- break;
209
- chunks.shift();
210
- total -= first.length;
211
- }
212
- },
213
- text() {
214
- return chunks.join("").slice(-STREAM_CAP_CHARS);
215
- },
216
- };
217
- }
218
194
  export function defaultRunner(args, options = {}) {
219
195
  return new Promise((resolve, reject) => {
220
196
  const command = resolveCliSpawn("docker", args);
221
197
  // docker's SSH transport runs the first `ssh` on PATH: the app's shim,
222
198
  // which shares one connection across every command of this VPS.
223
199
  const ssh = prepareVpsSsh(DATA_DIR, augmentedPath());
200
+ const env = { ...process.env, PATH: ssh.path, ...options.env };
224
201
  const child = spawn(command.command, command.args, {
225
202
  shell: false,
226
- env: { ...process.env, PATH: ssh.path },
203
+ env,
227
204
  stdio: ["pipe", "pipe", "pipe"],
228
- ...planOptions(command, { ...process.env, PATH: ssh.path }),
205
+ ...planOptions(command, env),
229
206
  });
230
207
  const stdout = tailCollector();
231
208
  const stderr = tailCollector();
@@ -684,7 +661,7 @@ export function vpsContainerRunArgs(containerName, imageRef = VPS_IMAGE, viewerS
684
661
  }
685
662
  if (!/^[A-Za-z0-9_-]{8,128}$/.test(viewerSecret))
686
663
  throw new Error("invalid managed VPS viewer secret");
687
- return [
664
+ const args = [
688
665
  "run",
689
666
  "-d",
690
667
  "--name",
@@ -735,10 +712,14 @@ export function vpsContainerRunArgs(containerName, imageRef = VPS_IMAGE, viewerS
735
712
  // which Atomic starts on demand and never at boot).
736
713
  "--restart",
737
714
  "unless-stopped",
715
+ // Bare -e: the docker CLI resolves the value from ITS OWN process
716
+ // environment (client side, so -H ssh:// still delivers it), keeping the
717
+ // secret out of local argv, which any user can read through `ps`.
738
718
  "-e",
739
- `VNC_PW=${viewerSecret}`,
719
+ "VNC_PW",
740
720
  imageRef,
741
721
  ];
722
+ return { args, env: { VNC_PW: viewerSecret } };
742
723
  }
743
724
  function assertUsableContainer(status) {
744
725
  if (!status.image ||
@@ -919,7 +900,8 @@ export async function vpsComputerAction(action, cfg, botId, runner = defaultRunn
919
900
  }
920
901
  if (!imageRef)
921
902
  throw Object.assign(new Error("The prepared VPS image could not be identified"), { status: 409 });
922
- await run(vpsContainerRunArgs(before.container_name, imageRef));
903
+ const containerRun = vpsContainerRunArgs(before.container_name, imageRef);
904
+ await runner(vpsDockerArgs(alias, containerRun.args), { timeoutMs: 2 * 60_000, env: containerRun.env });
923
905
  }
924
906
  else {
925
907
  assertUsableContainer(before);
@@ -62,13 +62,21 @@ export class SessionBudget {
62
62
  return verdict;
63
63
  }
64
64
  /** Give back a call that was booked but never sent (the engine refused it
65
- * before it started). */
66
- refund(kind) {
65
+ * before it started). `spentAtMs` is the time it was booked at, so its own
66
+ * per-minute slot is freed and not a newer call's. */
67
+ refund(kind, spentAtMs) {
67
68
  const field = FIELD[kind];
68
69
  if (this.used[field] > 0)
69
70
  this.used[field] -= 1;
70
- if (kind === "live")
71
+ if (kind !== "live")
72
+ return;
73
+ if (spentAtMs === undefined) {
71
74
  this.liveTimes.pop();
75
+ return;
76
+ }
77
+ const slot = this.liveTimes.indexOf(spentAtMs);
78
+ if (slot >= 0)
79
+ this.liveTimes.splice(slot, 1);
72
80
  }
73
81
  snapshot() {
74
82
  const share = (field) => this.limits[field] ? this.used[field] / this.limits[field] : 1;
@@ -155,9 +155,11 @@ export class WatchLiveSession {
155
155
  });
156
156
  this.deps.runComment(prompt, meta)
157
157
  .then((messages) => this.settle(messages, meta, window.text))
158
- .catch(() => this.budget.refund("live"))
158
+ .catch(() => this.budget.refund("live", now))
159
159
  .finally(() => {
160
- this.inFlightSince = null;
160
+ // A call let go at the timeout may settle while a newer one runs.
161
+ if (this.inFlightSince === now)
162
+ this.inFlightSince = null;
161
163
  this.pump();
162
164
  });
163
165
  }
@@ -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,14 @@ 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 (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) {
199
+ if (entry.anyAccount || accounts.length < 2 || accounts.some((account) => account.instanceId === entry.engine))
200
+ return accounts;
201
+ return [accounts.find((account) => !refused?.(account)) ?? accounts[0]];
202
+ }
@@ -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
  },
@@ -24,7 +24,12 @@ import { modelHost } from "./engine-choices.js";
24
24
  * - The Atomic Engine and the company connection (the Chibitek gateway):
25
25
  * they are Atomic's own routing, which these bots never use. */
26
26
  export const SUBSCRIPTION_PROVIDERS = Object.freeze([
27
- { id: "claude", name: "Claude", drivers: ["claudeAgent"], generic: ["claude", "claude code", "claude subscription", "anthropic"], signInUrl: "https://claude.ai/login" },
27
+ // Claude Code also lists models it can be pointed at (a leftover API slug,
28
+ // a settings.json custom model): only Anthropic's own count.
29
+ {
30
+ id: "claude", name: "Claude", drivers: ["claudeAgent"], generic: ["claude", "claude code", "claude subscription", "anthropic"],
31
+ ownModels: /^claude-/i, signInUrl: "https://claude.ai/login",
32
+ },
28
33
  { id: "chatgpt", name: "ChatGPT", drivers: ["codex"], generic: ["chatgpt", "codex", "chatgpt (codex)", "openai"], signInUrl: "https://chatgpt.com/auth/login" },
29
34
  {
30
35
  id: "gemini", name: "Gemini", drivers: ["antigravityAgent", "geminiAgent"], generic: ["gemini", "antigravity", "google", "google gemini"],
@@ -83,14 +88,17 @@ export function subscriptionProviderForEngine(engine) {
83
88
  return SUBSCRIPTION_PROVIDERS.find((provider) => provider.host && provider.drivers.includes(engine.driverKind)
84
89
  && engine.models.options.some((option) => modelHost(engine.driverKind, option) === provider.host));
85
90
  }
86
- /** Whether a model on this engine is the provider's own (always, except on
87
- * an engine that also serves other companies' models). */
91
+ /** Whether a model on this engine is the provider's own. A `host::model` id
92
+ * is another host's model run through the harness (a local inject: Ollama,
93
+ * Ollama Cloud, LM Studio), so it is never the provider's, whoever made the
94
+ * model: a Claude bot runs Anthropic's Claude, not Claude from another host
95
+ * (Erick, 2026-11-13). Otherwise always, except on an engine that also
96
+ * serves other companies' models (`ownModels`). */
88
97
  export function isProviderModel(provider, model) {
98
+ if (model.includes("::"))
99
+ return false;
89
100
  return provider.ownModels ? provider.ownModels.test(model) : true;
90
101
  }
91
- /** Turns one conversation of a company subscription bot may run on another
92
- * provider's subscription when its own has no account free (server/session-fallback.ts). */
93
- export const SESSION_FALLBACK_TURNS = 50;
94
102
  export function isSubscriptionBot(bot) {
95
103
  const value = bot?.subscription;
96
104
  return Boolean(value && typeof value.instanceId === "string" && subscriptionProvider(value.provider));
@@ -0,0 +1,48 @@
1
+ const bearer = (name, ...origins) => ({ name, origins, header: "Authorization", prefix: "Bearer " });
2
+ const keyed = (name, header, ...origins) => ({ name, origins, header, prefix: "" });
3
+ // Order matters where names overlap: the first match wins.
4
+ export const API_PROVIDERS = [
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"),
8
+ bearer(/\breplicate\b/i, "https://api.replicate.com"),
9
+ // Model providers and routers
10
+ bearer(/\bopen\s*router\b/i, "https://openrouter.ai"),
11
+ bearer(/\bollama\b/i, "https://ollama.com"),
12
+ bearer(/\b(?:hugging\s*face|hf)\b/i, "https://huggingface.co", "https://router.huggingface.co", "https://api-inference.huggingface.co"),
13
+ bearer(/\b(?:nous(?:\s*research)?|hermes)\b/i, "https://inference-api.nousresearch.com"),
14
+ keyed(/\b(?:anthropic|claude)\b/i, "x-api-key", "https://api.anthropic.com"),
15
+ keyed(/\b(?:gemini|google\s+ai|ai\s+studio)\b/i, "x-goog-api-key", "https://generativelanguage.googleapis.com"),
16
+ bearer(/\b(?:openai|chatgpt)\b/i, "https://api.openai.com"),
17
+ bearer(/\bgroq\b/i, "https://api.groq.com"),
18
+ bearer(/\bmistral\b/i, "https://api.mistral.ai"),
19
+ bearer(/\bdeepseek\b/i, "https://api.deepseek.com"),
20
+ bearer(/\b(?:xai|x\.ai|grok)\b/i, "https://api.x.ai"),
21
+ bearer(/\bperplexity\b/i, "https://api.perplexity.ai"),
22
+ bearer(/\b(?:kimi|moonshot)\b/i, "https://api.moonshot.ai"),
23
+ bearer(/\bminimax\b/i, "https://api.minimax.io"),
24
+ bearer(/\b(?:z\.ai|zai|zhipu|glm)\b/i, "https://api.z.ai"),
25
+ bearer(/\btogether(?:\s*ai)?\b/i, "https://api.together.xyz"),
26
+ bearer(/\bfireworks\b/i, "https://api.fireworks.ai"),
27
+ bearer(/\bcohere\b/i, "https://api.cohere.com"),
28
+ // Hosting and developer platforms
29
+ bearer(/\bvercel\b/i, "https://api.vercel.com"),
30
+ bearer(/\bsupabase\b/i, "https://api.supabase.com"),
31
+ bearer(/\brailway\b/i, "https://backboard.railway.com"),
32
+ bearer(/\bgithub\b/i, "https://api.github.com"),
33
+ bearer(/\bcloudflare\b/i, "https://api.cloudflare.com"),
34
+ // Business services
35
+ bearer(/\bstripe\b/i, "https://api.stripe.com"),
36
+ bearer(/\bresend\b/i, "https://api.resend.com"),
37
+ bearer(/\bsendgrid\b/i, "https://api.sendgrid.com"),
38
+ bearer(/\bnotion\b/i, "https://api.notion.com"),
39
+ bearer(/\bslack\b/i, "https://slack.com"),
40
+ // Search and web
41
+ bearer(/\btavily\b/i, "https://api.tavily.com"),
42
+ bearer(/\bfirecrawl\b/i, "https://api.firecrawl.dev"),
43
+ keyed(/\bbrave\b/i, "X-Subscription-Token", "https://api.search.brave.com"),
44
+ ];
45
+ /** The provider an item's name points at, or undefined. */
46
+ export function apiProviderFor(name) {
47
+ return API_PROVIDERS.find((provider) => provider.name.test(name));
48
+ }
@@ -1,3 +1,4 @@
1
+ import { apiProviderFor } from "./vault-api-providers.js";
1
2
  import { vaultOrigin } from "./vault.js";
2
3
  export class VaultCsvError extends Error {
3
4
  }
@@ -52,24 +53,48 @@ const COLUMNS = {
52
53
  password: ["password", "login_password", "pwd", "pass"],
53
54
  name: ["name", "title", "account"],
54
55
  type: ["type"],
56
+ // An API token: its own column, or a row whose type says so. `header` and
57
+ // `prefix` say how it is sent when that is not "Authorization: Bearer".
58
+ token: ["token", "api token", "api_token", "api key", "api_key", "apikey", "access token", "access_token", "credential", "secret", "key"],
59
+ header: ["header", "header name"],
60
+ prefix: ["prefix", "scheme"],
55
61
  // The vault, folder or tag a row was filed under, so an import can take one.
56
62
  group: ["vault", "folder", "grouping", "collections", "collection", "category", "tags"],
57
63
  };
58
- /** Logins from a password manager's CSV export. Notes, TOTP seeds and custom
59
- * fields are dropped: they can hold secrets and hints are not secret. Rows
60
- * without a website, username and password, or that are not logins, are
61
- * counted in `skipped`. Imported items are private to the person (no bots). */
64
+ /** A row's type that means an API token, not a login ("API Credential",
65
+ * "token", "secret key"). */
66
+ const TOKEN_TYPE = /api|token|key|credential|secret/;
67
+ const TOKEN_VALUE = /^[\x21-\x7E]{1,8192}$/;
68
+ const HEADER_NAME = /^[A-Za-z0-9-]{1,64}$/;
69
+ const PREFIX = /^[\x20-\x7E]{0,32}$/;
70
+ /** Logins and API tokens from a CSV export. Notes, TOTP seeds and custom
71
+ * fields are dropped: they can hold secrets and hints are not secret.
72
+ *
73
+ * A login needs a website, username and password. An API token is a row
74
+ * with a token: in a token column, in the password column when the row's
75
+ * type says it is a token, or a password saved under a name alone (no
76
+ * website and no username, how many people keep API keys). With a website
77
+ * it is bound to that website, sent as "Authorization: Bearer <token>"
78
+ * unless `header` and `prefix` columns say otherwise. With no website, a
79
+ * name Atomic knows (shared/vault-api-providers.ts) binds it to that
80
+ * provider's API with the header it asks for; any other is saved with no
81
+ * address, which no bot can use until the person adds one (`needAddress`
82
+ * counts those). Other rows are counted in `skipped`. Imported items may be
83
+ * used by every bot of the person (allBots). */
62
84
  export function vaultLoginsFromCsv(text, group) {
63
85
  const [header, ...rows] = parseCsv(text);
64
86
  if (!header)
65
- return { logins: [], skipped: 0 };
87
+ return { logins: [], apiKeys: [], skipped: 0, needAddress: 0 };
66
88
  const groupAt = columnIndex(header, "group");
67
89
  const col = (key) => columnIndex(header, key);
68
- const at = { url: col("url"), username: col("username"), password: col("password"), name: col("name"), type: col("type") };
69
- if (at.url < 0 || at.password < 0 || at.username < 0)
70
- throw new VaultCsvError("This CSV has no website, username and password columns.");
90
+ const at = { url: col("url"), username: col("username"), password: col("password"), name: col("name"), type: col("type"),
91
+ token: col("token"), header: col("header"), prefix: col("prefix") };
92
+ if (at.token < 0 && at.password < 0)
93
+ throw new VaultCsvError("This CSV has no password or token column.");
71
94
  const logins = [];
95
+ const apiKeys = [];
72
96
  let skipped = 0;
97
+ let needAddress = 0;
73
98
  for (const row of rows) {
74
99
  const cell = (index) => (index >= 0 ? row[index] ?? "" : "").trim();
75
100
  if (group && !groupsOf(cell(groupAt)).includes(group))
@@ -77,17 +102,40 @@ export function vaultLoginsFromCsv(text, group) {
77
102
  const type = cell(at.type).toLowerCase();
78
103
  const raw = cell(at.url).split(/[\s,]+/)[0] ?? "";
79
104
  // Old entries saved as http:// or a bare domain are filled over HTTPS.
80
- const website = vaultOrigin(/^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw.replace(/^http:\/\//i, "https://") : `https://${raw}`);
105
+ const website = raw ? vaultOrigin(/^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw.replace(/^http:\/\//i, "https://") : `https://${raw}`) : null;
81
106
  const username = cell(at.username);
82
- const password = row[at.password] ?? "";
83
- if ((type && type !== "login") || !raw || !website || !username || !password || username.length > 320 || password.length > 4096) {
107
+ const password = at.password >= 0 ? row[at.password] ?? "" : "";
108
+ const name = cell(at.name);
109
+ // A password kept under a name alone, with no website and no username, is an API key.
110
+ const nameOnly = !raw && !username && Boolean(name) && type !== "login";
111
+ const token = cell(at.token) || ((type !== "login" && TOKEN_TYPE.test(type)) || nameOnly ? password.trim() : "");
112
+ if (raw && !website) {
84
113
  skipped++;
85
114
  continue;
86
115
  }
87
- const label = (cell(at.name) || new URL(website).hostname).slice(0, 200);
88
- logins.push({ kind: "login", label, hints: "", botIds: [], expiresAt: null, website, username, password });
116
+ const label = (name || (website ? new URL(website).hostname : "")).slice(0, 200);
117
+ if (token) {
118
+ const known = website ? undefined : apiProviderFor(label);
119
+ const sentIn = cell(at.header) || known?.header || "Authorization";
120
+ // The prefix keeps its trailing space ("Bearer "), so it is not trimmed.
121
+ const prefix = at.prefix >= 0 ? row[at.prefix] ?? "" : cell(at.header) ? "" : known ? known.prefix : "Bearer ";
122
+ if (!label || !TOKEN_VALUE.test(token) || !HEADER_NAME.test(sentIn) || !PREFIX.test(prefix)) {
123
+ skipped++;
124
+ continue;
125
+ }
126
+ const origins = website ? [website] : known ? [...known.origins] : [];
127
+ if (!origins.length)
128
+ needAddress++;
129
+ apiKeys.push({ kind: "apiKey", label, hints: "", botIds: [], allBots: true, expiresAt: null, origins, header: sentIn, prefix, secret: token });
130
+ continue;
131
+ }
132
+ if (!website || (type && type !== "login") || !username || !password || username.length > 320 || password.length > 4096) {
133
+ skipped++;
134
+ continue;
135
+ }
136
+ logins.push({ kind: "login", label, hints: "", botIds: [], allBots: true, expiresAt: null, website, username, password });
89
137
  }
90
- return { logins, skipped };
138
+ return { logins, apiKeys, skipped, needAddress };
91
139
  }
92
140
  function columnIndex(header, key) {
93
141
  const names = header.map((cell) => cell.trim().toLowerCase());
@@ -23,6 +23,11 @@ const address = z.object({
23
23
  const base = {
24
24
  label: z.string().trim().min(1).max(200), hints: text(1000),
25
25
  botIds: z.array(z.string().uuid()).max(100).refine((ids) => new Set(ids).size === ids.length),
26
+ /** Every bot of the owner may use the item, including bots made later
27
+ * (Erick, 2026-11-13: no per-item setup). The default for a new or
28
+ * imported item; `botIds` then adds nothing. Absent on items saved before
29
+ * it existed, which keep their own list. */
30
+ allBots: z.boolean().optional(),
26
31
  expiresAt: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).nullable(),
27
32
  };
28
33
  /** Reject unknown fields rather than accidentally persisting secrets in
@@ -38,22 +43,35 @@ export const vaultInputSchema = z.discriminatedUnion("kind", [
38
43
  z.object({ ...base, kind: z.literal("contact"), origins: z.array(origin).min(1).max(50),
39
44
  address, email: z.union([z.literal(""), z.string().email().max(320)]), phone: text(80),
40
45
  }).strict(),
46
+ // An API key a granted bot may send, in one named header, to the listed
47
+ // origins. The value is visible ASCII only, so it can never split a header.
48
+ // A key may be saved with no origin yet (many are kept under a name alone,
49
+ // with no website): it is stored, and no bot can send it anywhere until
50
+ // its owner adds an address.
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}$/),
53
+ secret: z.string().regex(/^[\x21-\x7E]{1,8192}$/),
54
+ }).strict(),
41
55
  ]);
42
56
  /** Explicit allowlist. Never spread a stored item into a response. */
43
57
  export function vaultMetadata(item) {
44
58
  return {
45
59
  id: item.id, kind: item.kind, label: item.label, hints: item.hints,
46
- botIds: [...item.botIds], expiresAt: item.expiresAt,
60
+ botIds: [...item.botIds], allBots: item.allBots === true, expiresAt: item.expiresAt,
47
61
  origins: item.kind === "login" ? [item.website] : [...item.origins],
48
62
  ...(item.kind === "login" ? { username: item.username } : {}),
49
63
  ...(item.kind === "card" ? { lastFour: item.number.slice(-4), expiryMonth: item.expiryMonth, expiryYear: item.expiryYear, billing: { ...item.billing } } : {}),
50
64
  ...(item.kind === "contact" ? { address: { ...item.address }, email: item.email, phone: item.phone } : {}),
65
+ ...(item.kind === "apiKey" ? { header: item.header, prefix: item.prefix } : {}),
51
66
  createdAt: item.createdAt, updatedAt: item.updatedAt,
52
67
  };
53
68
  }
69
+ /** Whether this bot is one the owner let use the item: every bot, or one
70
+ * on its list. The owner, expiry and destination are checked apart. */
71
+ export const vaultGranted = (item, botId) => item.allBots === true || item.botIds.includes(botId);
54
72
  export function vaultUseAllowed(item, actor, now) {
55
73
  const destination = vaultOrigin(actor.destination);
56
- return Number.isSafeInteger(now) && now >= 0 && item.ownerId === actor.ownerId && item.botIds.includes(actor.botId)
74
+ return Number.isSafeInteger(now) && now >= 0 && item.ownerId === actor.ownerId && vaultGranted(item, actor.botId)
57
75
  && (item.expiresAt === null || now < item.expiresAt) && destination !== null
58
76
  && (item.kind === "login" ? item.website === destination : item.origins.includes(destination));
59
77
  }
@@ -17219,6 +17219,9 @@ function cuaExecArgs(args2, options = {}) {
17219
17219
  }
17220
17220
  var containerMcpPath = SPAWNED_PROXIES.containerMcp;
17221
17221
 
17222
+ // server/stream-tail.ts
17223
+ var STREAM_CAP_CHARS = 16 * 1024 * 1024;
17224
+
17222
17225
  // server/vps-computer.ts
17223
17226
  var CONTAINER_NAME = /^[a-zA-Z0-9][a-zA-Z0-9_.-]+$/;
17224
17227
  var CONTAINER_ID = /^[a-f0-9]{12,64}$/i;
@@ -17228,7 +17231,6 @@ function vpsDockerArgs(alias2, args2) {
17228
17231
  }
17229
17232
  return ["-H", `ssh://${alias2}`, ...args2];
17230
17233
  }
17231
- var STREAM_CAP_CHARS = 16 * 1024 * 1024;
17232
17234
  function vpsContainerMcpArgs(alias2, containerName2) {
17233
17235
  if (!isValidSshAlias(alias2) || !CONTAINER_NAME.test(containerName2) && !CONTAINER_ID.test(containerName2)) {
17234
17236
  throw new Error("invalid VPS MCP connection");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chibitek/chibi",
3
- "version": "0.1.186",
3
+ "version": "0.1.190",
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-BL_dHjXO.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-BlEulfZP.js";import{_ as a}from"./mermaid.core-BL_dHjXO.js";import"./chunk-5VM5RSS4-B9BoCCOM.js";import"./chunk-XXDRQBXY-BNWicp85.js";import"./chunk-WEXAMYUT-BYpUWdau.js";import"./chunk-GWA4HPMP-86KjuKSi.js";import"./channel-DhsCc8Nd.js";import"./index-Bf2yMkX_.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};