@chibitek/chibi 0.1.197 → 0.1.199

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 (78) hide show
  1. package/dist/assets/{TerminalPanel--bJ8KdIX.js → TerminalPanel-BD8tgP0L.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-B9FTFZ6n.js → abnfDiagram-O67JEVCF-nJPyKFj_.js} +1 -1
  3. package/dist/assets/{arc-CVbauXMY.js → arc-B27uNTWr.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-R_L6cEaF.js → architectureDiagram-NJMV4G6O-1g_zkN0g.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-BXc2RYLr.js → blockDiagram-BEXU5L5S-B94wHtES.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-Bii05url.js → c4Diagram-YGBWAQC7-BURkZEQS.js} +1 -1
  7. package/dist/assets/channel-BBCt_i2t.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-YimysqOo.js → chunk-2Q5K7J3B-CwYChOa9.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-CrHKZRq7.js → chunk-3FUC2YCW-D2NA_sYk.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-3y2fUHet.js → chunk-5VM5RSS4-7v_eBXTK.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-YSoI0G8B.js → chunk-GTNCS2PH-Ck73ze4k.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-DsIbENvB.js → chunk-GWA4HPMP-BsOQoPsv.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-6s37yBqm.js → chunk-JWPE2WC7-DjQCd7nq.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-ezv6I2Jw.js → chunk-NETBCI7D-jsNR61zL.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-BYg3YNuR.js → chunk-WEXAMYUT-iYv-JXOK.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-ia5t27ll.js → chunk-XXDRQBXY-6hDTxNh3.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-CjKSkyGp.js → classDiagram-v2-NBCMYWYE-CqYfoIdc.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-CG8y2L2j.js → cose-bilkent-JH36ORCC-BFoBUYoI.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-DZkEKzBB.js → cynefin-OW5HDTMX-C8beDmoE.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-DnowKsJ-.js → cynefinDiagram-VND7K2PF-B14Y6q3s.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-CMtfQGlI.js → dagre-6A5THRUB-Bxfl4ARR.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-Bk94047z.js → diagram-22UHCM2B-C0Y9Gxes.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-Ui5qVUoC.js → diagram-3UASUU5V-CT665UIR.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-C2yF8mt5.js → diagram-ATOU4E4O-DGXaVJI8.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-Csj1m-Qs.js → diagram-CDSNMT55-B-k11v8T.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-W3uwKf9S.js → diagram-MLGK6HIB-DQd_tGlF.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-CrF8_LWl.js → diagram-MPIPVDR6-CookmvAU.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-FG0V0Pck.js → ebnfDiagram-ZINNZB2B-koVtdZMh.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-BnptZiPT.js → elk-276RUBZZ-CCULrKTu.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-DQ9QNt66.js → erDiagram-OPXOYQCR-7tX_DN1F.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-BSQCaJJS.js → flowDiagram-KWPJA3E3-BP9lx54W.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-DNhPCPBz.js → ganttDiagram-FUAMR5RP-DrD3pdCf.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-Bwziujo8.js → gitGraphDiagram-X574FWY7-CGoBra5o.js} +1 -1
  34. package/dist/assets/{index-kIcmWTVM.js → index-0ryDWs_U.js} +1 -1
  35. package/dist/assets/{index-C1MRa2jb.js → index-DUPDb_l5.js} +189 -189
  36. package/dist/assets/{infoDiagram-VRGFBTTK-BoeGC6R0.js → infoDiagram-VRGFBTTK-TBE6eo6e.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-MqJALuN6.js → ishikawaDiagram-OU5B5YK6-CXFR0VYe.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-CDmYfmBD.js → journeyDiagram-ZHPQQLJL-0i24WNpp.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-BncCNuev.js → kanban-definition-PNTS6WVX-BVO7zH5N.js} +1 -1
  40. package/dist/assets/{linear-D7y9LlCy.js → linear-CJa9b6Jv.js} +1 -1
  41. package/dist/assets/{mermaid.core-C-8HBWdK.js → mermaid.core-Cr_zJcfI.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-CVY8yI8k.js → mindmap-definition-NLK3R4M7-DGOtBRni.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-RAHytJwr.js → pegDiagram-GJSIUBJH-a4X1U2M6.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-DVdUiz7U.js → pieDiagram-5QR66LMP-C6YKVkOM.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-BgrtWShT.js → quadrantDiagram-O4NWA36T-tthWiJZV.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-DipM2y3J.js → railroadDiagram-XR7U4H2S-BaCi4bjC.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-hS3TxvWM.js → requirementDiagram-PLB6GJNP-B1gkcVzT.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-BC280MpB.js → sankeyDiagram-IPEJSGJF-Q6NzlkZ1.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-ewNIiNrD.js → sequenceDiagram-PO4LG4MO-DXkHQxwi.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-MhMinfv2.js → sizeCapture-INFHLROL-DFiBxWwr.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-BDlA_ZR7.js → stateDiagram-v2-GCMORJYK-CWi-jeEW.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-H8P8RCKC.js → swimlanes-2SLR337P-DEMqxNj4.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-BebBq0sX.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-DMyIeQ7T.js → timeline-definition-EJHVYXUP-CutULAnt.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-DRvphcF6.js → usecaseDiagram-POWQR4AR-Dbvwnx98.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U-m4Q4kbA5.js → vennDiagram-UO4OBE2U-HSO7dMBn.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-CeX5n3Zi.js → wardleyDiagram-VNRHLVJA-ShLPdgOQ.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-CpJZkSHf.js → xychartDiagram-PMCCYNJV-DCdsZ7i5.js} +1 -1
  59. package/dist/index.html +1 -1
  60. package/dist-server/companion/src/routes.js +13 -5
  61. package/dist-server/container-mcp.js +4 -4
  62. package/dist-server/index.js +273 -265
  63. package/dist-server/openmausbot.js +77 -32
  64. package/dist-server/pair-cli.js +77 -32
  65. package/dist-server/server/approval-grants.js +1 -1
  66. package/dist-server/server/atomic-engine-release.js +9 -16
  67. package/dist-server/server/config.js +7 -7
  68. package/dist-server/server/drivers/claude.js +1 -19
  69. package/dist-server/server/drivers/session-allow-key.js +27 -0
  70. package/dist-server/server/index.js +1 -1
  71. package/dist-server/server/oauth-account-tools.js +1 -1
  72. package/dist-server/server/routes/accounts.js +1 -1
  73. package/dist-server/server/system-prompt.js +1 -1
  74. package/dist-server/shared/oauth-account-grants.js +4 -4
  75. package/dist-server/vps-container-mcp.js +4 -4
  76. package/package.json +1 -1
  77. package/dist/assets/channel-NejqmlD6.js +0 -1
  78. package/dist/assets/swimlanesDiagram-TC7HE7FX-0B8do8GC.js +0 -8
@@ -32524,6 +32524,216 @@ function shouldCompact(input) {
32524
32524
  return size >= threshold;
32525
32525
  }
32526
32526
 
32527
+ // server/approval-grants.ts
32528
+ import { readFileSync as readFileSync4 } from "node:fs";
32529
+
32530
+ // server/contracts.ts
32531
+ function isModelVariant(value) {
32532
+ return typeof value === "string" && value.length > 0 && value.length <= 256 && value.trim() === value && !new RegExp("\\p{Cc}", "u").test(value);
32533
+ }
32534
+ var eventCounter = 0;
32535
+ var newEventId = () => `ev-${Date.now().toString(36)}-${(eventCounter++).toString(36)}`;
32536
+ var newId = () => crypto.randomUUID();
32537
+
32538
+ // server/approval-grants.ts
32539
+ var ONCE_GRANT_TTL_MS = 60 * 6e4;
32540
+ var ALWAYS_GRANT_TTL_MS = 8 * 60 * 6e4;
32541
+ var MAX_GRANTS = 500;
32542
+ var MAX_CARRIES = 50;
32543
+ var ASKS_A_PERSON = /* @__PURE__ */ new Set(["askuserquestion", "ask_user"]);
32544
+ var CREDENTIAL_WORDS = /(?:^|[^a-z])(?:passwords?|passwd|passphrases?|secrets?|credentials?|api[_\s-]?keys?|private[_\s-]?keys?|tokens?|keychain|1password)(?:$|[^a-z])/i;
32545
+ var CREDENTIAL_COMMANDS = /(?:^|[\s;&|(])(?:op\s+(?:read|item|inject|run|signin|whoami)|security\s+(?:find|add|delete)-(?:generic|internet)-password|gh\s+auth\s+token|printenv|env\s*$|aws\s+configure|gcloud\s+auth\s+print)/i;
32546
+ var SPEND_WORDS = /* @__PURE__ */ new Set([
32547
+ "pay",
32548
+ "payment",
32549
+ "payments",
32550
+ "purchase",
32551
+ "purchases",
32552
+ "buy",
32553
+ "checkout",
32554
+ "charge",
32555
+ "charges",
32556
+ "refund",
32557
+ "refunds",
32558
+ "payout",
32559
+ "payouts",
32560
+ "transfer",
32561
+ "transfers",
32562
+ "invoice",
32563
+ "invoices",
32564
+ "billing",
32565
+ "subscribe",
32566
+ "subscription",
32567
+ "spend",
32568
+ "wire"
32569
+ ]);
32570
+ var SHELL_TOOL = /(?:^|_)(?:bash|shell|sh|zsh|terminal|exec|exec_command|run_terminal_cmd|run_shell_command|local_shell|command|execute)$/i;
32571
+ var SHELL_META = /[;&|`<>\n\r]|\$\(|\$\{/;
32572
+ function toolKey(tool2) {
32573
+ return tool2.trim().toLowerCase();
32574
+ }
32575
+ function toolName(tool2) {
32576
+ return tool2.trim().replace(/^mcp__.+?__/i, "");
32577
+ }
32578
+ function bareTool(tool2) {
32579
+ return toolName(tool2).toLowerCase();
32580
+ }
32581
+ function words(tool2) {
32582
+ return toolName(tool2).replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
32583
+ }
32584
+ function collapse(text19) {
32585
+ return text19.trim().replace(/\s+/g, " ");
32586
+ }
32587
+ function isShellTool(tool2) {
32588
+ return SHELL_TOOL.test(bareTool(tool2));
32589
+ }
32590
+ function ungrantable(request4) {
32591
+ if (ASKS_A_PERSON.has(bareTool(request4.tool))) return "question";
32592
+ if (request4.requiresExplicitApproval) return "sandbox";
32593
+ if (request4.approvalScope === "local-computer") return "local-computer";
32594
+ if (request4.destructive) return "destructive";
32595
+ if (CREDENTIAL_WORDS.test(bareTool(request4.tool)) || CREDENTIAL_WORDS.test(request4.summary) || CREDENTIAL_COMMANDS.test(request4.summary)) {
32596
+ return "credential";
32597
+ }
32598
+ if (words(request4.tool).some((word2) => SPEND_WORDS.has(word2))) return "spend";
32599
+ return null;
32600
+ }
32601
+ function commandPrefix(summary) {
32602
+ const command = collapse(summary).replace(/^\$\s*/, "");
32603
+ if (!command || SHELL_META.test(command)) return null;
32604
+ const [program, sub2] = command.split(" ");
32605
+ if (!program) return null;
32606
+ return sub2 && /^[a-z][\w-]*$/.test(sub2) ? `${program} ${sub2}` : program;
32607
+ }
32608
+ function grantScopeFor(request4, always) {
32609
+ if (ungrantable(request4)) return null;
32610
+ const tool2 = toolKey(request4.tool);
32611
+ const summary = collapse(request4.summary);
32612
+ if (!tool2) return null;
32613
+ if (!always) return { kind: "action", tool: tool2, summary };
32614
+ if (!isShellTool(tool2)) return { kind: "tool", tool: tool2 };
32615
+ const prefix = commandPrefix(summary);
32616
+ return prefix ? { kind: "tool", tool: tool2, commandPrefix: prefix } : { kind: "action", tool: tool2, summary };
32617
+ }
32618
+ function scopeCovers(scope, request4) {
32619
+ if (toolKey(request4.tool) !== scope.tool) return false;
32620
+ const summary = collapse(request4.summary);
32621
+ if (scope.kind === "action") return summary === scope.summary;
32622
+ if (!scope.commandPrefix) return true;
32623
+ const command = summary.replace(/^\$\s*/, "");
32624
+ return !SHELL_META.test(command) && (command === scope.commandPrefix || command.startsWith(`${scope.commandPrefix} `));
32625
+ }
32626
+ function matchGrant(grants, carried, request4, boundary, now = Date.now()) {
32627
+ if (!carried || !carried.ids.length) return null;
32628
+ if (!boundary.senderIsChief || boundary.personalLine || boundary.hipaa || boundary.othersAsked) return null;
32629
+ if (ungrantable(request4)) return null;
32630
+ for (const grant of grants) {
32631
+ if (!carried.ids.includes(grant.id) || grant.chiefBotId !== carried.chiefBotId) continue;
32632
+ if (grant.expiresAt <= now || grant.maxUses !== void 0 && grant.uses >= grant.maxUses) continue;
32633
+ const here = grant.carriedTo.some((carry) => carry.botId === carried.botId && carry.threadId === carried.threadId && carry.handoffId === carried.handoffId);
32634
+ if (!here) continue;
32635
+ if (scopeCovers(grant.scope, request4)) return grant;
32636
+ }
32637
+ return null;
32638
+ }
32639
+ function describeScope(scope) {
32640
+ if (scope.kind === "action") return `${scope.tool}: ${scope.summary.slice(0, 120)}`;
32641
+ return scope.commandPrefix ? `${scope.tool}: ${scope.commandPrefix} \u2026` : `${scope.tool} (always)`;
32642
+ }
32643
+ function isGrant(value) {
32644
+ if (!value || typeof value !== "object") return false;
32645
+ const grant = value;
32646
+ return typeof grant.id === "string" && typeof grant.chiefBotId === "string" && typeof grant.sourceThreadId === "string" && typeof grant.expiresAt === "number" && typeof grant.uses === "number" && Array.isArray(grant.carriedTo) && Boolean(grant.scope && typeof grant.scope === "object" && typeof grant.scope.tool === "string") && Boolean(grant.approvedBy && typeof grant.approvedBy === "object");
32647
+ }
32648
+ var ApprovalGrantStore = class {
32649
+ grants = [];
32650
+ file;
32651
+ now;
32652
+ constructor(file2, now = Date.now) {
32653
+ this.file = file2;
32654
+ this.now = now;
32655
+ if (!file2) return;
32656
+ try {
32657
+ const raw = JSON.parse(readFileSync4(file2, "utf8"));
32658
+ if (Array.isArray(raw)) this.grants = raw.filter(isGrant).filter((grant) => grant.expiresAt > this.now());
32659
+ } catch {
32660
+ }
32661
+ }
32662
+ save() {
32663
+ const now = this.now();
32664
+ this.grants = this.grants.filter((grant) => grant.expiresAt > now).slice(-MAX_GRANTS);
32665
+ if (!this.file) return;
32666
+ try {
32667
+ writeFileAtomic(this.file, JSON.stringify(this.grants, null, 2), { mode: 384 });
32668
+ } catch (error51) {
32669
+ console.error("approval-grants: could not persist grants", error51);
32670
+ }
32671
+ }
32672
+ create(input) {
32673
+ const scope = grantScopeFor(input.request, input.always);
32674
+ if (!scope) return null;
32675
+ const createdAt = this.now();
32676
+ const once = scope.kind === "action" && !input.always;
32677
+ const grant = {
32678
+ id: newId(),
32679
+ approvedBy: input.approvedBy,
32680
+ personName: input.personName,
32681
+ chiefBotId: input.chiefBotId,
32682
+ sourceThreadId: input.sourceThreadId,
32683
+ sourceRequestId: input.sourceRequestId,
32684
+ ...input.sourceTurnId ? { sourceTurnId: input.sourceTurnId } : {},
32685
+ scope,
32686
+ createdAt,
32687
+ expiresAt: createdAt + (input.always ? ALWAYS_GRANT_TTL_MS : ONCE_GRANT_TTL_MS),
32688
+ ...once ? { maxUses: 1 } : {},
32689
+ uses: 0,
32690
+ carriedTo: []
32691
+ };
32692
+ this.grants.push(grant);
32693
+ this.save();
32694
+ return grant;
32695
+ }
32696
+ /** Carry every live grant from a Chief's conversation into one delegated
32697
+ * turn, and return their ids for the handoff to hold. */
32698
+ carry(chiefBotId, sourceThreadId, target) {
32699
+ const now = this.now();
32700
+ const live2 = this.grants.filter((grant) => grant.chiefBotId === chiefBotId && grant.sourceThreadId === sourceThreadId && grant.expiresAt > now && (grant.maxUses === void 0 || grant.uses < grant.maxUses));
32701
+ if (!live2.length) return [];
32702
+ for (const grant of live2) {
32703
+ grant.carriedTo = [...grant.carriedTo, { ...target, at: now }].slice(-MAX_CARRIES);
32704
+ }
32705
+ this.save();
32706
+ return live2.map((grant) => grant.id);
32707
+ }
32708
+ /** The grants carried into one coordinate_bots handoff. */
32709
+ carriedToHandoff(botId, threadId, handoffId) {
32710
+ return this.grants.filter((grant) => grant.carriedTo.some((carry) => carry.botId === botId && carry.threadId === threadId && carry.handoffId === handoffId)).map((grant) => grant.id);
32711
+ }
32712
+ /** Every grant still held. matchGrant does the deciding. */
32713
+ all() {
32714
+ return this.grants;
32715
+ }
32716
+ /** Count one use. Called before the approval is delivered, so a failed
32717
+ * delivery spends the use rather than letting it be replayed. */
32718
+ consume(id) {
32719
+ const grant = this.grants.find((candidate) => candidate.id === id);
32720
+ if (!grant) return;
32721
+ grant.uses += 1;
32722
+ this.save();
32723
+ }
32724
+ };
32725
+
32726
+ // server/drivers/session-allow-key.ts
32727
+ function sessionAllowKey(ask2) {
32728
+ const tool2 = typeof ask2.tool === "string" ? ask2.tool.trim() : "";
32729
+ if (!tool2) return null;
32730
+ if (tool2.startsWith("mcp__")) return JSON.stringify(["tool", tool2]);
32731
+ const command = isShellTool(tool2) && typeof ask2.input?.command === "string" ? commandPrefix(ask2.input.command) : null;
32732
+ if (command) return JSON.stringify(["command", tool2, command]);
32733
+ const stable2 = (value) => Array.isArray(value) ? value.map(stable2) : value && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((key5) => [key5, stable2(value[key5])])) : value;
32734
+ return JSON.stringify(["input", tool2, stable2(ask2.input ?? {})]);
32735
+ }
32736
+
32527
32737
  // server/plan-policy.ts
32528
32738
  var PLAN_READ_TOOLS = ["Read", "Glob", "Grep"];
32529
32739
  var PLAN_REFUSAL = "Plan mode blocked this action. Review the plan and approve it in Atomic before making changes.";
@@ -32547,13 +32757,13 @@ function firstText(content3) {
32547
32757
 
32548
32758
  // server/drivers/claude.ts
32549
32759
  import { createHash as createHash3, randomBytes } from "node:crypto";
32550
- import { chmodSync, existsSync as existsSync6, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync9, rmSync as rmSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
32760
+ import { chmodSync, existsSync as existsSync6, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync10, rmSync as rmSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
32551
32761
  import { createServer as createNetServer } from "node:net";
32552
32762
  import { homedir as homedir6, tmpdir } from "node:os";
32553
32763
  import { join as join14, dirname as dirname4, isAbsolute as isAbsolute4, normalize } from "node:path";
32554
32764
 
32555
32765
  // server/config.ts
32556
- import { readFileSync as readFileSync5, mkdirSync as mkdirSync3, existsSync as existsSync2, renameSync as renameSync2 } from "node:fs";
32766
+ import { readFileSync as readFileSync6, mkdirSync as mkdirSync3, existsSync as existsSync2, renameSync as renameSync2 } from "node:fs";
32557
32767
  import { homedir as homedir2 } from "node:os";
32558
32768
  import { join as join4 } from "node:path";
32559
32769
 
@@ -32727,14 +32937,6 @@ function isEffortLevel(value) {
32727
32937
  return typeof value === "string" && EFFORT_LEVELS.includes(value);
32728
32938
  }
32729
32939
 
32730
- // server/contracts.ts
32731
- function isModelVariant(value) {
32732
- return typeof value === "string" && value.length > 0 && value.length <= 256 && value.trim() === value && !new RegExp("\\p{Cc}", "u").test(value);
32733
- }
32734
- var eventCounter = 0;
32735
- var newEventId = () => `ev-${Date.now().toString(36)}-${(eventCounter++).toString(36)}`;
32736
- var newId = () => crypto.randomUUID();
32737
-
32738
32940
  // ../../../workspace/Atomic/atomic-release-0.1.183/node_modules/.pnpm/croner@10.0.1/node_modules/croner/dist/croner.js
32739
32941
  function T(s4) {
32740
32942
  return Date.UTC(s4.y, s4.m - 1, s4.d, s4.h, s4.i, s4.s);
@@ -34111,7 +34313,7 @@ function isNewerVersion(candidate, current4) {
34111
34313
  }
34112
34314
 
34113
34315
  // server/instance-keys.ts
34114
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, rmSync } from "node:fs";
34316
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, rmSync } from "node:fs";
34115
34317
  import { join as join3 } from "node:path";
34116
34318
  var INSTANCE_KEYS_ENV = "OMB_INSTANCE_KEYS";
34117
34319
  var INSTANCE_KEYS_FILE = "instance-keys.json";
@@ -34138,7 +34340,7 @@ function loadInstanceKeys(directory, env = process.env) {
34138
34340
  live.clear();
34139
34341
  fileBacked.clear();
34140
34342
  try {
34141
- for (const [id, key5] of decode4(readFileSync4(join3(directory, INSTANCE_KEYS_FILE), "utf8"))) fileBacked.set(id, key5);
34343
+ for (const [id, key5] of decode4(readFileSync5(join3(directory, INSTANCE_KEYS_FILE), "utf8"))) fileBacked.set(id, key5);
34142
34344
  } catch {
34143
34345
  }
34144
34346
  for (const [id, key5] of fileBacked) live.set(id, key5);
@@ -34827,10 +35029,10 @@ var appConfigSchema = external_exports.object({
34827
35029
  * outrank it. Written only through /api/hipaa, never a generic config patch. */
34828
35030
  hipaa: external_exports.object({ enabled: external_exports.boolean().optional() }).optional(),
34829
35031
  /** How company bots receive Google and Microsoft accounts connected under
34830
- * Settings → Accounts. Code default is opt-in; intended mode after merge is
34831
- * all-company-bots (Erick 2026-10-15): every non-personal connected account
34832
- * for every company bot (explicit bot.accounts still restricts). Never
34833
- * touches how refresh tokens are stored. */
35032
+ * Settings → Accounts. Default is all-company-bots (Erick 2026-10-15):
35033
+ * every non-personal connected account works for every company bot, while
35034
+ * an explicit bot.accounts list still restricts. "opt-in" keeps the legacy
35035
+ * per-bot Access toggle. Never touches how refresh tokens are stored. */
34834
35036
  oauthAccounts: external_exports.object({
34835
35037
  botGrant: external_exports.enum(["opt-in", "all-company-bots"]).optional()
34836
35038
  }).strict().optional(),
@@ -34896,7 +35098,7 @@ function parseStoredConfig(value) {
34896
35098
  function loadBrowserProfileIdAliases() {
34897
35099
  try {
34898
35100
  const document3 = external_exports.object({ browserProfiles: legacyBrowserProfilesSchema.optional() }).safeParse(
34899
- parseJson(readFileSync5(join4(DATA_DIR, "config.json"), "utf8"))
35101
+ parseJson(readFileSync6(join4(DATA_DIR, "config.json"), "utf8"))
34900
35102
  );
34901
35103
  if (!document3.success || !document3.data.browserProfiles) return /* @__PURE__ */ new Map();
34902
35104
  return migrateStoredBrowserProfiles(document3.data.browserProfiles).aliases;
@@ -34967,7 +35169,7 @@ function teamRoomsEnabled(cfg2) {
34967
35169
  return env === "1" || env !== "0" && cfg2.features?.teamRooms !== false;
34968
35170
  }
34969
35171
  function accountBotGrantPolicy(cfg2) {
34970
- return cfg2.oauthAccounts?.botGrant === "all-company-bots" ? "all-company-bots" : "opt-in";
35172
+ return cfg2.oauthAccounts?.botGrant === "opt-in" ? "opt-in" : "all-company-bots";
34971
35173
  }
34972
35174
  function claudeUserMcpEnabled(cfg2) {
34973
35175
  return cfg2.features?.claudeUserMcp === true;
@@ -35032,7 +35234,7 @@ function migrateRemovedIntegration() {
35032
35234
  const p3 = join4(DATA_DIR, "config.json");
35033
35235
  try {
35034
35236
  if (!existsSync2(p3)) return;
35035
- const disk = jsonObjectSchema.safeParse(parseJson(readFileSync5(p3, "utf8")));
35237
+ const disk = jsonObjectSchema.safeParse(parseJson(readFileSync6(p3, "utf8")));
35036
35238
  if (!disk.success) return;
35037
35239
  const { document: document3, changed: changed2 } = configWithoutRemovedIntegration(disk.data);
35038
35240
  if (!changed2) return;
@@ -35046,7 +35248,7 @@ function migrateLegacyFeatureFlags() {
35046
35248
  const p3 = join4(DATA_DIR, "config.json");
35047
35249
  try {
35048
35250
  if (!existsSync2(p3)) return;
35049
- const disk = jsonObjectSchema.safeParse(parseJson(readFileSync5(p3, "utf8")));
35251
+ const disk = jsonObjectSchema.safeParse(parseJson(readFileSync6(p3, "utf8")));
35050
35252
  if (!disk.success) return;
35051
35253
  const features = jsonObjectSchema.safeParse(disk.data.features);
35052
35254
  if (!features.success) return;
@@ -35076,7 +35278,7 @@ function migrateLegacyFeatureFlags() {
35076
35278
  function loadConfig() {
35077
35279
  let cfg2 = {};
35078
35280
  try {
35079
- cfg2 = parseStoredConfig(parseJson(readFileSync5(join4(DATA_DIR, "config.json"), "utf8")));
35281
+ cfg2 = parseStoredConfig(parseJson(readFileSync6(join4(DATA_DIR, "config.json"), "utf8")));
35080
35282
  } catch (error51) {
35081
35283
  if (error51.code !== "ENOENT")
35082
35284
  throw new Error("Saved Atomic settings could not be read; config.json has been left untouched.", { cause: error51 });
@@ -35216,7 +35418,7 @@ function saveConfig(patch, options = {}) {
35216
35418
  const p3 = join4(DATA_DIR, "config.json");
35217
35419
  let disk = {};
35218
35420
  try {
35219
- disk = configWithoutRemovedIntegration(jsonObjectSchema.parse(parseJson(readFileSync5(p3, "utf8")))).document;
35421
+ disk = configWithoutRemovedIntegration(jsonObjectSchema.parse(parseJson(readFileSync6(p3, "utf8")))).document;
35220
35422
  } catch (error51) {
35221
35423
  if (error51.code !== "ENOENT")
35222
35424
  throw new Error("Cannot save over unreadable Atomic settings; config.json has been left untouched.", { cause: error51 });
@@ -35225,7 +35427,7 @@ function saveConfig(patch, options = {}) {
35225
35427
  const before = configSaveListeners.size ? structuredClone(disk) : disk;
35226
35428
  const storedProfiles = storedBrowserProfilesSchema.safeParse(disk.browserProfiles);
35227
35429
  if (storedProfiles.success) disk.browserProfiles = storedProfiles.data;
35228
- for (const key5 of ["xai", "anthropic", "mistral", "ollamaCloud", "openaiCompat", "box", "opencodeGo", "tts", "imageGen", "profile", "icm", "nexusMemory", "paw", "rooms", "threads", "context", "localVm", "features", "addons", "budgets", "billing", "decisions", "onboarding", "browserEngine", "newBots"]) {
35430
+ for (const key5 of ["xai", "anthropic", "mistral", "ollamaCloud", "openaiCompat", "box", "opencodeGo", "tts", "imageGen", "profile", "icm", "nexusMemory", "paw", "rooms", "threads", "context", "localVm", "features", "addons", "budgets", "billing", "decisions", "onboarding", "browserEngine", "newBots", "oauthAccounts"]) {
35229
35431
  const section3 = checkedPatch[key5];
35230
35432
  if (!section3) continue;
35231
35433
  const current4 = jsonObjectSchema.safeParse(disk[key5]);
@@ -35520,7 +35722,7 @@ import { execFile } from "node:child_process";
35520
35722
  import { existsSync as existsSync4, readdirSync as readdirSync3 } from "node:fs";
35521
35723
 
35522
35724
  // server/spawn-command.ts
35523
- import { closeSync as closeSync3, existsSync as existsSync3, openSync as openSync3, readdirSync as readdirSync2, readFileSync as readFileSync6, readSync as readSync2, statSync } from "node:fs";
35725
+ import { closeSync as closeSync3, existsSync as existsSync3, openSync as openSync3, readdirSync as readdirSync2, readFileSync as readFileSync7, readSync as readSync2, statSync } from "node:fs";
35524
35726
  import { win32 as win322 } from "node:path";
35525
35727
  var electronNodeRequire = null;
35526
35728
  function registerElectronNodeRequire(script) {
@@ -35536,7 +35738,7 @@ function isFileOnDisk(path2) {
35536
35738
  function readTextFromDisk(path2, bytes2) {
35537
35739
  if (bytes2 === void 0) {
35538
35740
  try {
35539
- return readFileSync6(path2, "utf8");
35741
+ return readFileSync7(path2, "utf8");
35540
35742
  } catch {
35541
35743
  return null;
35542
35744
  }
@@ -37561,7 +37763,7 @@ function interruptibleDelay(ms2, signal) {
37561
37763
  }
37562
37764
 
37563
37765
  // server/drivers/local-inject.ts
37564
- import { readFileSync as readFileSync7 } from "node:fs";
37766
+ import { readFileSync as readFileSync8 } from "node:fs";
37565
37767
  import { homedir as homedir5 } from "node:os";
37566
37768
  import { join as join12 } from "node:path";
37567
37769
 
@@ -37720,7 +37922,7 @@ function firstUnslothToken(row) {
37720
37922
  function readUnslothKey(env) {
37721
37923
  const home = env.HOME || env.USERPROFILE || homedir5();
37722
37924
  try {
37723
- const raw = JSON.parse(readFileSync7(join12(home, ".unsloth", "studio", "auth", "agent_api_key.json"), "utf8"));
37925
+ const raw = JSON.parse(readFileSync8(join12(home, ".unsloth", "studio", "auth", "agent_api_key.json"), "utf8"));
37724
37926
  if (raw.servers && typeof raw.servers === "object") {
37725
37927
  const servers = raw.servers;
37726
37928
  for (const url2 of ["http://127.0.0.1:8888", "http://localhost:8888"]) {
@@ -38065,7 +38267,7 @@ function extractMcpImages(value) {
38065
38267
  }
38066
38268
 
38067
38269
  // server/drivers/claude-stdin.ts
38068
- import { readFileSync as readFileSync8 } from "node:fs";
38270
+ import { readFileSync as readFileSync9 } from "node:fs";
38069
38271
  function claudeUserMessage(text19, images) {
38070
38272
  if (!images?.length) return { type: "user", message: { role: "user", content: text19 } };
38071
38273
  const content3 = images.map((image2) => ({
@@ -38073,7 +38275,7 @@ function claudeUserMessage(text19, images) {
38073
38275
  source: {
38074
38276
  type: "base64",
38075
38277
  media_type: image2.mime,
38076
- data: readFileSync8(image2.path).toString("base64")
38278
+ data: readFileSync9(image2.path).toString("base64")
38077
38279
  }
38078
38280
  }));
38079
38281
  if (text19) content3.push({ type: "text", text: text19 });
@@ -38394,7 +38596,7 @@ function claudeInheritWarning(env) {
38394
38596
  function readClaudeAuthSettings(env, instanceEnvironment = {}) {
38395
38597
  if (CLAUDE_ACCOUNT_ENV_KEYS.some((key5) => instanceEnvironment[key5])) return {};
38396
38598
  try {
38397
- const settings = JSON.parse(readFileSync9(join14(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
38599
+ const settings = JSON.parse(readFileSync10(join14(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
38398
38600
  const authEnv = {};
38399
38601
  for (const key5 of CLAUDE_ACCOUNT_ENV_KEYS) {
38400
38602
  if (!key5.endsWith("_FILE_DESCRIPTOR") && typeof settings?.env?.[key5] === "string") {
@@ -38412,7 +38614,7 @@ function readClaudeAuthSettings(env, instanceEnvironment = {}) {
38412
38614
  function projectMcpServers(cwd) {
38413
38615
  let parsed;
38414
38616
  try {
38415
- parsed = JSON.parse(readFileSync9(join14(cwd, ".mcp.json"), "utf8"));
38617
+ parsed = JSON.parse(readFileSync10(join14(cwd, ".mcp.json"), "utf8"));
38416
38618
  } catch {
38417
38619
  return {};
38418
38620
  }
@@ -38515,7 +38717,7 @@ function extrasFromUnknown(value) {
38515
38717
  function readClaudeModelCatalog(env = process.env) {
38516
38718
  let settings = {};
38517
38719
  try {
38518
- settings = JSON.parse(readFileSync9(join14(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
38720
+ settings = JSON.parse(readFileSync10(join14(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
38519
38721
  } catch {
38520
38722
  settings = {};
38521
38723
  }
@@ -38553,13 +38755,6 @@ function removePrivateTempDir(filePath) {
38553
38755
  var DENY_TIMEOUT_NOTE = "Atomic: nobody answered this permission request in time. Skip this action and finish what you can without it.";
38554
38756
  var QUESTION_TIMEOUT_NOTE = "Atomic: nobody answered in time. Use your best judgment and continue.";
38555
38757
  var DUPLICATE_ASK_ID_NOTE = "Atomic: duplicate ask id \u2014 skipping this request.";
38556
- function sessionAllowKey(ask2) {
38557
- const tool2 = typeof ask2.tool === "string" ? ask2.tool.trim() : "";
38558
- if (!tool2) return null;
38559
- if (tool2.startsWith("mcp__")) return JSON.stringify(["tool", tool2]);
38560
- const stable2 = (value) => Array.isArray(value) ? value.map(stable2) : value && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((key5) => [key5, stable2(value[key5])])) : value;
38561
- return JSON.stringify(["input", tool2, stable2(ask2.input ?? {})]);
38562
- }
38563
38758
  function systemEndedReply(kind) {
38564
38759
  return kind === "question" ? { behavior: "answer", message: "Atomic: the turn is ending \u2014 wrap up." } : { behavior: "deny", message: "Atomic: the turn ended" };
38565
38760
  }
@@ -40126,7 +40321,7 @@ var SharedComputerControl = class {
40126
40321
 
40127
40322
  // server/room-handoffs.ts
40128
40323
  import { randomUUID as randomUUID9 } from "node:crypto";
40129
- import { readFileSync as readFileSync10 } from "node:fs";
40324
+ import { readFileSync as readFileSync11 } from "node:fs";
40130
40325
  var nodeSchema = external_exports.object({
40131
40326
  id: external_exports.string(),
40132
40327
  rootId: external_exports.string(),
@@ -40172,7 +40367,7 @@ var RoomHandoffs = class {
40172
40367
  this.now = now;
40173
40368
  this.limits = { ...ROOM_HANDOFF_LIMITS, ...limits };
40174
40369
  try {
40175
- const saved = external_exports.array(nodeSchema).max(1e4).parse(JSON.parse(readFileSync10(file2, "utf8")));
40370
+ const saved = external_exports.array(nodeSchema).max(1e4).parse(JSON.parse(readFileSync11(file2, "utf8")));
40176
40371
  const ids2 = new Map(saved.map((n) => [n.id, n]));
40177
40372
  if (ids2.size !== saved.length || saved.some((n) => !ids2.has(n.rootId) || ids2.get(n.rootId)?.parentId || n.parentId && (!ids2.has(n.parentId) || ids2.get(n.parentId)?.rootId !== n.rootId))) throw new Error("Invalid room handoff tree");
40178
40373
  for (const n of saved) {
@@ -40858,9 +41053,9 @@ function approvalModeForOrigin(mode, origin2) {
40858
41053
  function delegationInheritsFullAccess(input) {
40859
41054
  return input.senderIsChief && input.senderHasFullAccess && !input.sameBot && supportsApprovalMode(input.recipientDriverKind, "full");
40860
41055
  }
40861
- var ASKS_A_PERSON = /* @__PURE__ */ new Set(["askuserquestion", "ask_user"]);
41056
+ var ASKS_A_PERSON2 = /* @__PURE__ */ new Set(["askuserquestion", "ask_user"]);
40862
41057
  function autoVerdict(mode, tool2, context) {
40863
- if (isElicitationTool(tool2) || ASKS_A_PERSON.has(tool2.replace(/^mcp__[^_]+__/, "").toLowerCase())) {
41058
+ if (isElicitationTool(tool2) || ASKS_A_PERSON2.has(tool2.replace(/^mcp__[^_]+__/, "").toLowerCase())) {
40864
41059
  return { approve: null, source: "no-grant" };
40865
41060
  }
40866
41061
  if (context?.godMode) return { approve: `approved ${tool2} (GOD MODE)`, source: "god-mode" };
@@ -41365,7 +41560,7 @@ function choiceEngineOf(instance) {
41365
41560
 
41366
41561
  // server/browser-lifecycle-cleanup.ts
41367
41562
  import { randomUUID as randomUUID11 } from "node:crypto";
41368
- import { readFileSync as readFileSync11 } from "node:fs";
41563
+ import { readFileSync as readFileSync12 } from "node:fs";
41369
41564
  var BOT_ID = /^[A-Za-z0-9_-]{1,120}$/;
41370
41565
  var PROFILE_ID = /^[a-z0-9_-]{1,40}$/;
41371
41566
  var PROFILE_PARTITION_ID = /^[A-Za-z0-9_-]{1,40}$/;
@@ -41469,7 +41664,7 @@ var BrowserCleanupCoordinator = class {
41469
41664
  }
41470
41665
  #load() {
41471
41666
  try {
41472
- const raw = JSON.parse(readFileSync11(this.#file, "utf8"));
41667
+ const raw = JSON.parse(readFileSync12(this.#file, "utf8"));
41473
41668
  const journal = browserCleanupJournalSchema.safeParse(raw);
41474
41669
  if (!journal.success) {
41475
41670
  throw new Error(`invalid browser cleanup journal: ${journal.error.issues[0]?.message ?? "invalid entry"}`);
@@ -41990,7 +42185,7 @@ async function restore(botId, cwd, hash4) {
41990
42185
  }
41991
42186
 
41992
42187
  // server/message-db.ts
41993
- import { chmodSync as chmodSync2, closeSync as closeSync5, existsSync as existsSync9, mkdirSync as mkdirSync6, openSync as openSync5, readFileSync as readFileSync13, renameSync as renameSync4 } from "node:fs";
42188
+ import { chmodSync as chmodSync2, closeSync as closeSync5, existsSync as existsSync9, mkdirSync as mkdirSync6, openSync as openSync5, readFileSync as readFileSync14, renameSync as renameSync4 } from "node:fs";
41994
42189
  import { join as join18 } from "node:path";
41995
42190
  import { DatabaseSync } from "node:sqlite";
41996
42191
 
@@ -42134,7 +42329,7 @@ function personalTime(at2) {
42134
42329
  }
42135
42330
 
42136
42331
  // server/personal-bot.ts
42137
- import { readFileSync as readFileSync12 } from "node:fs";
42332
+ import { readFileSync as readFileSync13 } from "node:fs";
42138
42333
 
42139
42334
  // electron/managed-prefs.mjs
42140
42335
  import { execFile as execFile3 } from "node:child_process";
@@ -42765,7 +42960,7 @@ async function defaultRead() {
42765
42960
  const file2 = process.env.OMB_TEST_MANAGED_PREFS_FILE;
42766
42961
  if (file2) {
42767
42962
  try {
42768
- return parseManagedPreferences(JSON.parse(readFileSync12(file2, "utf8")));
42963
+ return parseManagedPreferences(JSON.parse(readFileSync13(file2, "utf8")));
42769
42964
  } catch {
42770
42965
  return parseManagedPreferences({});
42771
42966
  }
@@ -43311,7 +43506,7 @@ function importLegacy(threadId, legacyFile) {
43311
43506
  let activeLeafId = null;
43312
43507
  let raw;
43313
43508
  try {
43314
- raw = JSON.parse(readFileSync13(legacyFile, "utf8"));
43509
+ raw = JSON.parse(readFileSync14(legacyFile, "utf8"));
43315
43510
  } catch {
43316
43511
  return { messages, activeLeafId };
43317
43512
  }
@@ -43714,12 +43909,12 @@ function fitBytes(text19, max) {
43714
43909
 
43715
43910
  // server/decision-log.ts
43716
43911
  import { AsyncLocalStorage } from "node:async_hooks";
43717
- import { readdirSync as readdirSync4, readFileSync as readFileSync15 } from "node:fs";
43912
+ import { readdirSync as readdirSync4, readFileSync as readFileSync16 } from "node:fs";
43718
43913
  import { appendFile as appendFile2, mkdir as mkdir2, readdir, stat as stat3, unlink } from "node:fs/promises";
43719
43914
  import { basename as basename5, join as join20 } from "node:path";
43720
43915
 
43721
43916
  // server/usage-ledger.ts
43722
- import { readFileSync as readFileSync14 } from "node:fs";
43917
+ import { readFileSync as readFileSync15 } from "node:fs";
43723
43918
  import { appendFile, mkdir } from "node:fs/promises";
43724
43919
  import { join as join19 } from "node:path";
43725
43920
 
@@ -43811,7 +44006,7 @@ function readUsage(dataDir2, range2) {
43811
44006
  for (const key5 of monthsBetween(range2.from, range2.to)) {
43812
44007
  let text19;
43813
44008
  try {
43814
- text19 = readFileSync14(join19(dataDir2, DIR, `${key5}.jsonl`), "utf8");
44009
+ text19 = readFileSync15(join19(dataDir2, DIR, `${key5}.jsonl`), "utf8");
43815
44010
  } catch {
43816
44011
  continue;
43817
44012
  }
@@ -44049,7 +44244,7 @@ var isDecisionRow = (value) => typeof value === "object" && value !== null && ty
44049
44244
  function readRows(path2) {
44050
44245
  let text19;
44051
44246
  try {
44052
- text19 = readFileSync15(path2, "utf8");
44247
+ text19 = readFileSync16(path2, "utf8");
44053
44248
  } catch {
44054
44249
  return [];
44055
44250
  }
@@ -44128,195 +44323,6 @@ function decisionsCsv(rows) {
44128
44323
  return lines.join("\n") + "\n";
44129
44324
  }
44130
44325
 
44131
- // server/approval-grants.ts
44132
- import { readFileSync as readFileSync16 } from "node:fs";
44133
- var ONCE_GRANT_TTL_MS = 60 * 6e4;
44134
- var ALWAYS_GRANT_TTL_MS = 8 * 60 * 6e4;
44135
- var MAX_GRANTS = 500;
44136
- var MAX_CARRIES = 50;
44137
- var ASKS_A_PERSON2 = /* @__PURE__ */ new Set(["askuserquestion", "ask_user"]);
44138
- var CREDENTIAL_WORDS = /(?:^|[^a-z])(?:passwords?|passwd|passphrases?|secrets?|credentials?|api[_\s-]?keys?|private[_\s-]?keys?|tokens?|keychain|1password)(?:$|[^a-z])/i;
44139
- var CREDENTIAL_COMMANDS = /(?:^|[\s;&|(])(?:op\s+(?:read|item|inject|run|signin|whoami)|security\s+(?:find|add|delete)-(?:generic|internet)-password|gh\s+auth\s+token|printenv|env\s*$|aws\s+configure|gcloud\s+auth\s+print)/i;
44140
- var SPEND_WORDS = /* @__PURE__ */ new Set([
44141
- "pay",
44142
- "payment",
44143
- "payments",
44144
- "purchase",
44145
- "purchases",
44146
- "buy",
44147
- "checkout",
44148
- "charge",
44149
- "charges",
44150
- "refund",
44151
- "refunds",
44152
- "payout",
44153
- "payouts",
44154
- "transfer",
44155
- "transfers",
44156
- "invoice",
44157
- "invoices",
44158
- "billing",
44159
- "subscribe",
44160
- "subscription",
44161
- "spend",
44162
- "wire"
44163
- ]);
44164
- var SHELL_TOOL = /(?:^|_)(?:bash|shell|sh|zsh|terminal|exec|exec_command|run_terminal_cmd|run_shell_command|local_shell|command|execute)$/i;
44165
- var SHELL_META = /[;&|`<>\n\r]|\$\(|\$\{/;
44166
- function toolKey(tool2) {
44167
- return tool2.trim().toLowerCase();
44168
- }
44169
- function toolName(tool2) {
44170
- return tool2.trim().replace(/^mcp__.+?__/i, "");
44171
- }
44172
- function bareTool(tool2) {
44173
- return toolName(tool2).toLowerCase();
44174
- }
44175
- function words(tool2) {
44176
- return toolName(tool2).replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
44177
- }
44178
- function collapse(text19) {
44179
- return text19.trim().replace(/\s+/g, " ");
44180
- }
44181
- function isShellTool(tool2) {
44182
- return SHELL_TOOL.test(bareTool(tool2));
44183
- }
44184
- function ungrantable(request4) {
44185
- if (ASKS_A_PERSON2.has(bareTool(request4.tool))) return "question";
44186
- if (request4.requiresExplicitApproval) return "sandbox";
44187
- if (request4.approvalScope === "local-computer") return "local-computer";
44188
- if (request4.destructive) return "destructive";
44189
- if (CREDENTIAL_WORDS.test(bareTool(request4.tool)) || CREDENTIAL_WORDS.test(request4.summary) || CREDENTIAL_COMMANDS.test(request4.summary)) {
44190
- return "credential";
44191
- }
44192
- if (words(request4.tool).some((word2) => SPEND_WORDS.has(word2))) return "spend";
44193
- return null;
44194
- }
44195
- function commandPrefix(summary) {
44196
- const command = collapse(summary).replace(/^\$\s*/, "");
44197
- if (!command || SHELL_META.test(command)) return null;
44198
- const [program, sub2] = command.split(" ");
44199
- if (!program) return null;
44200
- return sub2 && /^[a-z][\w-]*$/.test(sub2) ? `${program} ${sub2}` : program;
44201
- }
44202
- function grantScopeFor(request4, always) {
44203
- if (ungrantable(request4)) return null;
44204
- const tool2 = toolKey(request4.tool);
44205
- const summary = collapse(request4.summary);
44206
- if (!tool2) return null;
44207
- if (!always) return { kind: "action", tool: tool2, summary };
44208
- if (!isShellTool(tool2)) return { kind: "tool", tool: tool2 };
44209
- const prefix = commandPrefix(summary);
44210
- return prefix ? { kind: "tool", tool: tool2, commandPrefix: prefix } : { kind: "action", tool: tool2, summary };
44211
- }
44212
- function scopeCovers(scope, request4) {
44213
- if (toolKey(request4.tool) !== scope.tool) return false;
44214
- const summary = collapse(request4.summary);
44215
- if (scope.kind === "action") return summary === scope.summary;
44216
- if (!scope.commandPrefix) return true;
44217
- const command = summary.replace(/^\$\s*/, "");
44218
- return !SHELL_META.test(command) && (command === scope.commandPrefix || command.startsWith(`${scope.commandPrefix} `));
44219
- }
44220
- function matchGrant(grants, carried, request4, boundary, now = Date.now()) {
44221
- if (!carried || !carried.ids.length) return null;
44222
- if (!boundary.senderIsChief || boundary.personalLine || boundary.hipaa || boundary.othersAsked) return null;
44223
- if (ungrantable(request4)) return null;
44224
- for (const grant of grants) {
44225
- if (!carried.ids.includes(grant.id) || grant.chiefBotId !== carried.chiefBotId) continue;
44226
- if (grant.expiresAt <= now || grant.maxUses !== void 0 && grant.uses >= grant.maxUses) continue;
44227
- const here = grant.carriedTo.some((carry) => carry.botId === carried.botId && carry.threadId === carried.threadId && carry.handoffId === carried.handoffId);
44228
- if (!here) continue;
44229
- if (scopeCovers(grant.scope, request4)) return grant;
44230
- }
44231
- return null;
44232
- }
44233
- function describeScope(scope) {
44234
- if (scope.kind === "action") return `${scope.tool}: ${scope.summary.slice(0, 120)}`;
44235
- return scope.commandPrefix ? `${scope.tool}: ${scope.commandPrefix} \u2026` : `${scope.tool} (always)`;
44236
- }
44237
- function isGrant(value) {
44238
- if (!value || typeof value !== "object") return false;
44239
- const grant = value;
44240
- return typeof grant.id === "string" && typeof grant.chiefBotId === "string" && typeof grant.sourceThreadId === "string" && typeof grant.expiresAt === "number" && typeof grant.uses === "number" && Array.isArray(grant.carriedTo) && Boolean(grant.scope && typeof grant.scope === "object" && typeof grant.scope.tool === "string") && Boolean(grant.approvedBy && typeof grant.approvedBy === "object");
44241
- }
44242
- var ApprovalGrantStore = class {
44243
- grants = [];
44244
- file;
44245
- now;
44246
- constructor(file2, now = Date.now) {
44247
- this.file = file2;
44248
- this.now = now;
44249
- if (!file2) return;
44250
- try {
44251
- const raw = JSON.parse(readFileSync16(file2, "utf8"));
44252
- if (Array.isArray(raw)) this.grants = raw.filter(isGrant).filter((grant) => grant.expiresAt > this.now());
44253
- } catch {
44254
- }
44255
- }
44256
- save() {
44257
- const now = this.now();
44258
- this.grants = this.grants.filter((grant) => grant.expiresAt > now).slice(-MAX_GRANTS);
44259
- if (!this.file) return;
44260
- try {
44261
- writeFileAtomic(this.file, JSON.stringify(this.grants, null, 2), { mode: 384 });
44262
- } catch (error51) {
44263
- console.error("approval-grants: could not persist grants", error51);
44264
- }
44265
- }
44266
- create(input) {
44267
- const scope = grantScopeFor(input.request, input.always);
44268
- if (!scope) return null;
44269
- const createdAt = this.now();
44270
- const once = scope.kind === "action" && !input.always;
44271
- const grant = {
44272
- id: newId(),
44273
- approvedBy: input.approvedBy,
44274
- personName: input.personName,
44275
- chiefBotId: input.chiefBotId,
44276
- sourceThreadId: input.sourceThreadId,
44277
- sourceRequestId: input.sourceRequestId,
44278
- ...input.sourceTurnId ? { sourceTurnId: input.sourceTurnId } : {},
44279
- scope,
44280
- createdAt,
44281
- expiresAt: createdAt + (input.always ? ALWAYS_GRANT_TTL_MS : ONCE_GRANT_TTL_MS),
44282
- ...once ? { maxUses: 1 } : {},
44283
- uses: 0,
44284
- carriedTo: []
44285
- };
44286
- this.grants.push(grant);
44287
- this.save();
44288
- return grant;
44289
- }
44290
- /** Carry every live grant from a Chief's conversation into one delegated
44291
- * turn, and return their ids for the handoff to hold. */
44292
- carry(chiefBotId, sourceThreadId, target) {
44293
- const now = this.now();
44294
- const live2 = this.grants.filter((grant) => grant.chiefBotId === chiefBotId && grant.sourceThreadId === sourceThreadId && grant.expiresAt > now && (grant.maxUses === void 0 || grant.uses < grant.maxUses));
44295
- if (!live2.length) return [];
44296
- for (const grant of live2) {
44297
- grant.carriedTo = [...grant.carriedTo, { ...target, at: now }].slice(-MAX_CARRIES);
44298
- }
44299
- this.save();
44300
- return live2.map((grant) => grant.id);
44301
- }
44302
- /** The grants carried into one coordinate_bots handoff. */
44303
- carriedToHandoff(botId, threadId, handoffId) {
44304
- return this.grants.filter((grant) => grant.carriedTo.some((carry) => carry.botId === botId && carry.threadId === threadId && carry.handoffId === handoffId)).map((grant) => grant.id);
44305
- }
44306
- /** Every grant still held. matchGrant does the deciding. */
44307
- all() {
44308
- return this.grants;
44309
- }
44310
- /** Count one use. Called before the approval is delivered, so a failed
44311
- * delivery spends the use rather than letting it be replayed. */
44312
- consume(id) {
44313
- const grant = this.grants.find((candidate) => candidate.id === id);
44314
- if (!grant) return;
44315
- grant.uses += 1;
44316
- this.save();
44317
- }
44318
- };
44319
-
44320
44326
  // server/bot-cwd.ts
44321
44327
  import { statSync as statSync4 } from "node:fs";
44322
44328
  import { homedir as homedir8 } from "node:os";
@@ -72471,25 +72477,18 @@ var ATOMIC_AUTO_MODEL = "atomic/auto";
72471
72477
  // server/atomic-engine-release.ts
72472
72478
  var ASSETS = [
72473
72479
  {
72474
- version: "0.21.4-4cc340e",
72480
+ version: "0.21.4-68432dd",
72475
72481
  platform: "darwin-arm64",
72476
- url: "https://ugmbfkqvogfuvufzjxtb.supabase.co/storage/v1/object/public/atomic-updates/atomic/K_5FMcrZFZ5AE2K-Lydn-Tis/atomic-engine-0.21.4-4cc340e-darwin-arm64.tar.gz",
72477
- bytes: 115631334,
72478
- sha512: "666626a535dce48f22087e26f7c14702dda4028b2c6759952017cffa73f37d86b16f5d8b6f81fb0efb535cb285ba4ddb6a5da3fd7e709ea0aa8b2b8c783e0c17"
72482
+ url: "https://ugmbfkqvogfuvufzjxtb.supabase.co/storage/v1/object/public/atomic-updates/atomic/K_5FMcrZFZ5AE2K-Lydn-Tis/atomic-engine-0.21.4-68432dd-darwin-arm64.tar.gz",
72483
+ bytes: 115629976,
72484
+ sha512: "b62d873aadd43655bd3f51af4027104a54462e74774182276783ba55d1824b05b193e839765cd5523b6f2bbe4fe3f47f780da32c2be94ac51b46d25f1fa3a83c"
72479
72485
  },
72480
72486
  {
72481
- version: "0.21.4-4cc340e",
72487
+ version: "0.21.4-68432dd",
72482
72488
  platform: "win32-x64",
72483
- url: "https://ugmbfkqvogfuvufzjxtb.supabase.co/storage/v1/object/public/atomic-updates/atomic/K_5FMcrZFZ5AE2K-Lydn-Tis/atomic-engine-0.21.4-4cc340e-win32-x64.tar.gz",
72484
- bytes: 103355479,
72485
- sha512: "4a074d1d2254ce697ed7ddf794b6d56e1f62374d1ae5f533f7fea12c7f18af46f47f33fd38f9e09d3ca048ef027882b6b271dd229f40a9ffcb7f3f23db5d1bb0"
72486
- },
72487
- {
72488
- version: "0.21.4-4cc340e",
72489
- platform: "darwin-x64",
72490
- url: "https://ugmbfkqvogfuvufzjxtb.supabase.co/storage/v1/object/public/atomic-updates/atomic/K_5FMcrZFZ5AE2K-Lydn-Tis/atomic-engine-0.21.4-4cc340e-darwin-x64.tar.gz",
72491
- bytes: 92883251,
72492
- sha512: "eec5fcbbcdbe44db76f938cb3dd98fedfc6c644cc054c75d0ad3daaf66e39f60dc6b75fa3f8cdbbc2cc3760a2ea7d3fc608a1cf7a42c4a020e6cd4d6dc823df0"
72489
+ url: "https://ugmbfkqvogfuvufzjxtb.supabase.co/storage/v1/object/public/atomic-updates/atomic/K_5FMcrZFZ5AE2K-Lydn-Tis/atomic-engine-0.21.4-68432dd-win32-x64.tar.gz",
72490
+ bytes: 103356325,
72491
+ sha512: "a2bb1c23194ca63168a855daee719a851d5213c79b6db083ca676b0aaff26ac55f0e2086e36395f86a677379e8cc0cf53113122b6695b841e12e3619857fc08c"
72493
72492
  }
72494
72493
  ];
72495
72494
  function atomicEngineAsset(platform = process.platform, arch = process.arch) {
@@ -87547,7 +87546,7 @@ function computerPrompt(kind) {
87547
87546
  return COMPUTER_PARAGRAPH[kind] + SIGN_IN_PROMPT;
87548
87547
  }
87549
87548
  function accountsPrompt(emails) {
87550
- if (emails.length === 0) return " Use atomic_accounts.list_accounts for Google and Microsoft access status. No accounts are currently granted to this bot; ask the person to enable one in this bot\u2019s Settings \u2192 Access \u2192 Google and Microsoft accounts. Do not use LLM account connectors for these services.";
87549
+ if (emails.length === 0) return " Use atomic_accounts.list_accounts for Google and Microsoft access status. No account is available to this bot right now: if none is connected, ask the person to connect one in Settings \u2192 Accounts (a connected account works in every bot by default); if one is connected, the person's restriction on this bot's Settings \u2192 Access list is in effect. Do not use LLM account connectors for these services.";
87551
87550
  const list3 = emails.map((email3) => `"${email3}"`).join(", ");
87552
87551
  return ` You can use the user's ${emails.length === 1 ? "account" : "accounts"} ${list3} through atomic_accounts (mail, calendar and files). Use list_accounts to check granted permissions. Do not use LLM account connectors for Google or Microsoft services. Pass the email as \`account\` when more than one account of that provider is listed. Save messages as drafts and send only when the user asked you to send.`;
87553
87552
  }
@@ -105652,13 +105651,21 @@ var ALLOWED = [
105652
105651
  { method: "GET", path: /^\/api\/threads\/[\w-]+\/export$/ },
105653
105652
  { method: "POST", path: /^\/api\/threads\/[\w-]+\/respond$/ },
105654
105653
  { method: "GET", path: /^\/api\/search$/ },
105655
- // Team Rooms through the paired computer (docs/chibitek/team-room-plan.md,
105656
- // Section 8): read rooms, reply, keep the read position. Creating rooms,
105657
- // invite links and joining stay on the desktop in v1; approvals are the
105658
- // bot's own cards, answered through /respond above.
105654
+ // Team Rooms and Channels through the paired computer
105655
+ // (docs/chibitek/team-room-plan.md, Section 8): read, reply, keep the read
105656
+ // position, make a room or channel, invite links, join from a link, add or
105657
+ // remove bots, remove people, leave or close, save to Nexus. The computer's
105658
+ // Chibitek sign-in does every one of these and the server checks who may.
105659
+ // A bot's share settings stay on the computer, like the rest of a bot's
105660
+ // settings; approvals are the bot's own cards, answered through /respond.
105659
105661
  { method: "GET", path: /^\/api\/team-rooms$/ },
105662
+ { method: "POST", path: /^\/api\/team-rooms$/ },
105663
+ { method: "POST", path: /^\/api\/team-rooms\/join(?:\/preview)?$/ },
105664
+ { method: "DELETE", path: /^\/api\/team-rooms\/(?:invites|bots)\/[0-9a-f-]{36}$/ },
105660
105665
  { method: "GET", path: /^\/api\/team-rooms\/[0-9a-f-]{36}$/ },
105661
- { method: "POST", path: /^\/api\/team-rooms\/[0-9a-f-]{36}\/(?:messages|read)$/ },
105666
+ { method: "POST", path: /^\/api\/team-rooms\/[0-9a-f-]{36}\/(?:messages|read|archive|leave|invites|bots|save-to-nexus)$/ },
105667
+ { method: "GET", path: /^\/api\/team-rooms\/[0-9a-f-]{36}\/invites$/ },
105668
+ { method: "DELETE", path: /^\/api\/team-rooms\/[0-9a-f-]{36}\/members\/[0-9a-f-]{36}$/ },
105662
105669
  // App-owned profile images. Upload is image-only and capped at 10 MB by
105663
105670
  // the harness; GET is a single bare generated filename, never a path.
105664
105671
  { method: "POST", path: /^\/api\/attachments$/ },
@@ -115653,7 +115660,7 @@ function createAccountRoutes(deps) {
115653
115660
  }
115654
115661
  if (path2 === "/api/accounts") {
115655
115662
  if (method !== "GET") return json5(res, 405, { error: "method not allowed" });
115656
- return json5(res, 200, deps.accounts.status());
115663
+ return json5(res, 200, { ...deps.accounts.status(), botGrant: deps.grantPolicy() });
115657
115664
  }
115658
115665
  if (path2 === "/api/accounts/connect") {
115659
115666
  if (method !== "POST") return json5(res, 405, { error: "method not allowed" });
@@ -116835,7 +116842,7 @@ async function runAccountTool(ctx, name2, rawArgs) {
116835
116842
  missing: missingFamilies(account3.provider, account3.scopes)
116836
116843
  })),
116837
116844
  ...!ctx.allowed.length ? {
116838
- guidance: "No accounts are granted to this bot. In this bot\u2019s Settings \u2192 Access \u2192 Google and Microsoft accounts, enable a connected account. Do not use an LLM account\u2019s connectors instead."
116845
+ guidance: "This bot cannot use any Google or Microsoft account right now. If none is connected, ask the person to connect one in Settings \u2192 Accounts; a connected account works in every bot by default. If one is connected but this bot still sees none, the bot's own Settings \u2192 Access list is restricting it. Do not use an LLM account\u2019s connectors instead."
116839
116846
  } : {}
116840
116847
  }),
116841
116848
  isError: false
@@ -139254,6 +139261,7 @@ setTimeout(() => void describeInstances().catch(() => {
139254
139261
  }), 0).unref?.();
139255
139262
  ROUTES.push(createAccountRoutes({
139256
139263
  accounts: oauthAccounts,
139264
+ grantPolicy: () => accountBotGrantPolicy(cfg),
139257
139265
  removedFromBots: (accountId) => {
139258
139266
  for (const bot of store.bots) {
139259
139267
  const ids2 = botAccountIds(bot);