@chibitek/chibi 0.1.207 → 0.1.209

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 (95) hide show
  1. package/dist/assets/{TerminalPanel-Cqjxle8G.js → TerminalPanel-CHGq3udb.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-XB80WX43.js → abnfDiagram-O67JEVCF-BMaKhJ-b.js} +1 -1
  3. package/dist/assets/{arc-BERcgYDi.js → arc-CYAiNWN8.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-Dnc9s6SQ.js → architectureDiagram-NJMV4G6O-CxJFFlbO.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-Cxc21eYL.js → blockDiagram-BEXU5L5S-C7AbPjRB.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-CW-3gUcf.js → c4Diagram-YGBWAQC7-DfVnCJmT.js} +1 -1
  7. package/dist/assets/channel-DxL_mLhm.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-Bs484eiW.js → chunk-2Q5K7J3B-CzAUFkgv.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-qhnBgRDy.js → chunk-3FUC2YCW-BgeBXphm.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-CsCqAEkH.js → chunk-5VM5RSS4-DPRdTAXc.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-ChBgFjPw.js → chunk-GTNCS2PH-BS-_dIVl.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-Df5-WClq.js → chunk-GWA4HPMP-D6I7xMmd.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-BdMXRJhO.js → chunk-JWPE2WC7-BKSKe7C9.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-rmAqJ9nY.js → chunk-NETBCI7D-R48UYTRN.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-DYmTw4lw.js → chunk-WEXAMYUT-C8z4mL-2.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-C4o5SHm0.js → chunk-XXDRQBXY-Bml3ZRJ5.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-Bm-ZzDk5.js → classDiagram-v2-NBCMYWYE-w5wo22FO.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-CFMRSfMu.js → cose-bilkent-JH36ORCC-Cum9v--4.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-BDedZ5yW.js → cynefin-OW5HDTMX-BzN0-KsP.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-i7KARSqF.js → cynefinDiagram-VND7K2PF-CkOpm32D.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-CwWpV0i_.js → dagre-6A5THRUB-BItQkKZD.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-CWIMT3-K.js → diagram-22UHCM2B-BI0zDn7c.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-C7HGc_ap.js → diagram-3UASUU5V-jwcDxsu6.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-BeLM7ihN.js → diagram-ATOU4E4O-2RnY9egJ.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-CN1rVM-W.js → diagram-CDSNMT55-eVdEZmEF.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-CuLcsx4e.js → diagram-MLGK6HIB-BCDGCJJ0.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-Bie61r-h.js → diagram-MPIPVDR6-DtN5uO5w.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-ChMg86y3.js → ebnfDiagram-ZINNZB2B-B9GpXSEs.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-DG9xXwoW.js → elk-276RUBZZ-Bk_eaK4T.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-C9bl-nWK.js → erDiagram-OPXOYQCR-BiGoW6C6.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-DvdWxFI8.js → flowDiagram-KWPJA3E3-ZW5w0BaJ.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-DDCNSEYc.js → ganttDiagram-FUAMR5RP-yyrKgsx1.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-PFvmOSMd.js → gitGraphDiagram-X574FWY7-CeiDikzD.js} +1 -1
  34. package/dist/assets/{index-Ci2mINhA.js → index-CZGnshrJ.js} +83 -83
  35. package/dist/assets/{index-DnniNB7N.js → index-DUFlRZuA.js} +1 -1
  36. package/dist/assets/{infoDiagram-VRGFBTTK-HEZh-PnK.js → infoDiagram-VRGFBTTK-q2B-KJFm.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-P3mmCGAU.js → ishikawaDiagram-OU5B5YK6-D8gXFuc0.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-dKG4AQu2.js → journeyDiagram-ZHPQQLJL-BmHL2mbq.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-BeIHeQTt.js → kanban-definition-PNTS6WVX-B9Ll2WkA.js} +1 -1
  40. package/dist/assets/{linear-DnEqDr6r.js → linear-CMVGYrKx.js} +1 -1
  41. package/dist/assets/{mermaid.core-D7hz6n4u.js → mermaid.core-qO11n1kV.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-BxJ8p-DN.js → mindmap-definition-NLK3R4M7-CxLGFX45.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-CkQT2dHJ.js → pegDiagram-GJSIUBJH-CxK1MJG4.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-DmVVhYaY.js → pieDiagram-5QR66LMP-H5jiF5Eu.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-DsOz-qCY.js → quadrantDiagram-O4NWA36T-CKaqCruv.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-CeYfvaki.js → railroadDiagram-XR7U4H2S-BCzKiQOd.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-BCtM-2uN.js → requirementDiagram-PLB6GJNP-Cqtr43DT.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-Cu8ki35x.js → sankeyDiagram-IPEJSGJF-B2tQewX8.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-DKbS5Gcs.js → sequenceDiagram-PO4LG4MO-nggwQyrw.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-Ceut6PrE.js → sizeCapture-INFHLROL-qSPXJBv2.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-Bl5uMY2f.js → stateDiagram-v2-GCMORJYK-DraPbL2T.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-CoMPbJ2k.js → swimlanes-2SLR337P-C6HVkIDA.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-gQUGsELo.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-D0xkKp46.js → timeline-definition-EJHVYXUP-DZmPRTsx.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-BCCL6QIf.js → usecaseDiagram-POWQR4AR-CsVuROW_.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U-B7g3jK72.js → vennDiagram-UO4OBE2U-B9IRbuhp.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-DFhnqQKP.js → wardleyDiagram-VNRHLVJA-CGmVK53n.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-mIXMscRS.js → xychartDiagram-PMCCYNJV-BAw-x9Y1.js} +1 -1
  59. package/dist/index.html +1 -1
  60. package/dist-server/index.js +3160 -2743
  61. package/dist-server/openmausbot.js +831 -654
  62. package/dist-server/pair-cli.js +831 -654
  63. package/dist-server/server/connection-cap-failover.js +8 -6
  64. package/dist-server/server/drivers/acp/core.js +20 -47
  65. package/dist-server/server/drivers/acp/custom.js +5 -0
  66. package/dist-server/server/drivers/acp/hermes-hosts.js +9 -0
  67. package/dist-server/server/drivers/acp/hermes.js +7 -9
  68. package/dist-server/server/drivers/acp/kimi-turn-failure.js +68 -0
  69. package/dist-server/server/drivers/acp/kimi.js +7 -0
  70. package/dist-server/server/drivers/acp/mcp-limit.js +47 -0
  71. package/dist-server/server/drivers/acp/rpc-error.js +35 -0
  72. package/dist-server/server/drivers/acp/setup-failure.js +9 -0
  73. package/dist-server/server/drivers/acp/vibe.js +11 -5
  74. package/dist-server/server/drivers/chat-text-only.js +47 -0
  75. package/dist-server/server/drivers/openai-chat-protocol.js +15 -0
  76. package/dist-server/server/drivers/openai-chat.js +8 -18
  77. package/dist-server/server/drivers/turn-mcp.js +3 -0
  78. package/dist-server/server/drivers/vibe-login.js +17 -8
  79. package/dist-server/server/engine-failover.js +16 -29
  80. package/dist-server/server/engine-rest.js +4 -3
  81. package/dist-server/server/engine-tiers.js +12 -9
  82. package/dist-server/server/index.js +16 -15
  83. package/dist-server/server/injected-model-rest.js +17 -0
  84. package/dist-server/server/model-levels/aliases.js +243 -38
  85. package/dist-server/server/model-levels/chibitek-rankings.js +8 -8
  86. package/dist-server/server/model-levels/classes.js +106 -38
  87. package/dist-server/server/model-levels/index.js +26 -14
  88. package/dist-server/server/model-levels/model-ids.js +91 -0
  89. package/dist-server/server/model-levels/overrides.js +7 -4
  90. package/dist-server/server/model-levels/sources.js +4 -1
  91. package/dist-server/server/pay-per-use.js +13 -1
  92. package/dist-server/shared/engine-tiers.js +0 -12
  93. package/package.json +1 -1
  94. package/dist/assets/channel-DaeKCO76.js +0 -1
  95. package/dist/assets/swimlanesDiagram-TC7HE7FX-DLJq0mAR.js +0 -8
@@ -138,11 +138,11 @@ function isNodeScript(file2, host) {
138
138
  return /\.[cm]?js$/i.test(file2) || !extname(file2) && hasNodeShebang(file2, host);
139
139
  }
140
140
  function parseCmdShim(shim, host) {
141
- const text6 = host.readText(shim);
142
- if (text6 === null) return null;
141
+ const text7 = host.readText(shim);
142
+ if (text7 === null) return null;
143
143
  const dir = dirname(shim);
144
- const npmEntry = /^SET "NP[MX]_CLI_JS=%~dp0\\([^"]+)"/im.exec(text6);
145
- const targets = [...npmEntry ? [npmEntry] : [], ...text6.matchAll(/"%~?dp0%?\\?([^"]+)"/g)].map((m3) => join(dir, m3[1])).filter((p3) => host.isFile(p3) && basename(p3).toLowerCase() !== "node.exe");
144
+ const npmEntry = /^SET "NP[MX]_CLI_JS=%~dp0\\([^"]+)"/im.exec(text7);
145
+ const targets = [...npmEntry ? [npmEntry] : [], ...text7.matchAll(/"%~?dp0%?\\?([^"]+)"/g)].map((m3) => join(dir, m3[1])).filter((p3) => host.isFile(p3) && basename(p3).toLowerCase() !== "node.exe");
146
146
  const script = targets.find((p3) => isNodeScript(p3, host));
147
147
  if (script) return nodeLaunch(script, dir, host);
148
148
  const exe = targets.find((p3) => [".exe", ".com"].includes(extname(p3).toLowerCase()));
@@ -573,9 +573,9 @@ function runBounded(resolved, opts, cb) {
573
573
  const receive = (which) => (chunk) => {
574
574
  if (done) return;
575
575
  bytes += chunk.length;
576
- const text6 = chunk.toString("utf8");
577
- if (which === "out") stdout2 += text6;
578
- else stderr += text6;
576
+ const text7 = chunk.toString("utf8");
577
+ if (which === "out") stdout2 += text7;
578
+ else stderr += text7;
579
579
  if (bytes > maxBuffer) {
580
580
  stop(Object.assign(new Error(`${which === "out" ? "stdout" : "stderr"} maxBuffer length exceeded`), {
581
581
  code: "ERR_CHILD_PROCESS_STDIO_MAXBUFFER",
@@ -625,8 +625,8 @@ function probeCli(cli, args, options) {
625
625
  });
626
626
  });
627
627
  }
628
- function outputTail(text6, lines = 8, chars = 800) {
629
- return stripVTControlCharacters(text6).split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.trim()).slice(-lines).join("\n").slice(-chars);
628
+ function outputTail(text7, lines = 8, chars = 800) {
629
+ return stripVTControlCharacters(text7).split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.trim()).slice(-lines).join("\n").slice(-chars);
630
630
  }
631
631
  function describeProbeFailure(cli, args, probe) {
632
632
  const command = `\`${[cli, ...args].join(" ")}\``;
@@ -635,10 +635,10 @@ function describeProbeFailure(cli, args, probe) {
635
635
  else if (probe.launchError) head = `${command} could not start (${probe.launchError})`;
636
636
  else if (probe.timedOut) head = `${command} did not answer within ${Math.round(probe.ms / 1e3)} seconds and was stopped. An antivirus scan of a newly installed program can do this; try again in a minute`;
637
637
  else head = `${command} failed (exit code ${probe.exitCode ?? "unknown"})`;
638
- const tail2 = outputTail(`${probe.stderr}
638
+ const tail3 = outputTail(`${probe.stderr}
639
639
  ${probe.stdout}`);
640
- return tail2 ? `${head}:
641
- ${tail2}` : head;
640
+ return tail3 ? `${head}:
641
+ ${tail3}` : head;
642
642
  }
643
643
  function spawnCommand(command, args, opts = {}) {
644
644
  const resolved = resolveCommand(command, args, opts.env);
@@ -8205,8 +8205,8 @@ var capitalizeFirstCharacter, error28;
8205
8205
  var init_lt = __esm({
8206
8206
  "../atomic-harness-skills/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/lt.js"() {
8207
8207
  init_util();
8208
- capitalizeFirstCharacter = (text6) => {
8209
- return text6.charAt(0).toUpperCase() + text6.slice(1);
8208
+ capitalizeFirstCharacter = (text7) => {
8209
+ return text7.charAt(0).toUpperCase() + text7.slice(1);
8210
8210
  };
8211
8211
  error28 = () => {
8212
8212
  const Sizable = {
@@ -17491,16 +17491,16 @@ function isSecretName(name) {
17491
17491
  }
17492
17492
  function looksLikeSecretValue(value) {
17493
17493
  if (typeof value !== "string") return false;
17494
- const text6 = value.trim();
17495
- if (text6.length < 8 || text6.includes("${")) return false;
17496
- return AUTH_SCHEME.test(text6) || TOKEN_PREFIX.test(text6) || JWT.test(text6) || URL_PASSWORD.test(text6);
17494
+ const text7 = value.trim();
17495
+ if (text7.length < 8 || text7.includes("${")) return false;
17496
+ return AUTH_SCHEME.test(text7) || TOKEN_PREFIX.test(text7) || JWT.test(text7) || URL_PASSWORD.test(text7);
17497
17497
  }
17498
17498
  function isSecretEntry(name, value) {
17499
17499
  if (typeof value !== "string") return false;
17500
- const text6 = value.trim();
17501
- if (!text6 || text6 === MCP_SECRET_PLACEHOLDER || text6.includes("${")) return false;
17502
- if (looksLikeSecretValue(text6)) return true;
17503
- return isSecretName(name) && !PATH_OR_URL.test(text6) && !PLAIN_SETTING.test(text6);
17500
+ const text7 = value.trim();
17501
+ if (!text7 || text7 === MCP_SECRET_PLACEHOLDER || text7.includes("${")) return false;
17502
+ if (looksLikeSecretValue(text7)) return true;
17503
+ return isSecretName(name) && !PATH_OR_URL.test(text7) && !PLAIN_SETTING.test(text7);
17504
17504
  }
17505
17505
  function sanitizeMcpSecrets(value) {
17506
17506
  const out = {};
@@ -17688,8 +17688,8 @@ var init_mcp_secrets2 = __esm({
17688
17688
  });
17689
17689
 
17690
17690
  // server/schema.ts
17691
- function parseJson(text6) {
17692
- return JSON.parse(text6);
17691
+ function parseJson(text7) {
17692
+ return JSON.parse(text7);
17693
17693
  }
17694
17694
  function schemaIssue(error51, fallback) {
17695
17695
  const issue2 = error51.issues[0];
@@ -20879,9 +20879,9 @@ var require_main = __commonJS({
20879
20879
  });
20880
20880
 
20881
20881
  // shared/redact.ts
20882
- function redactSecretsInText(text6) {
20883
- if (!text6 || text6.length < 8) return text6;
20884
- let out = text6;
20882
+ function redactSecretsInText(text7) {
20883
+ if (!text7 || text7.length < 8) return text7;
20884
+ let out = text7;
20885
20885
  out = out.replace(PEM_BLOCK, (_m, open2, body, close) => `${open2}
20886
20886
  ${mask(body.trim())}
20887
20887
  ${close}`);
@@ -26540,9 +26540,9 @@ var init_local_inject = __esm({
26540
26540
 
26541
26541
  // server/drivers/prompt-shape.ts
26542
26542
  function permissionKindOfLabel(label) {
26543
- const text6 = label.trim();
26544
- if (REJECT_LABEL.test(text6)) return ALWAYS_LABEL.test(text6) ? "reject_always" : "reject_once";
26545
- if (ALLOW_LABEL.test(text6)) return ALWAYS_LABEL.test(text6) ? "allow_always" : "allow_once";
26543
+ const text7 = label.trim();
26544
+ if (REJECT_LABEL.test(text7)) return ALWAYS_LABEL.test(text7) ? "reject_always" : "reject_once";
26545
+ if (ALLOW_LABEL.test(text7)) return ALWAYS_LABEL.test(text7) ? "allow_always" : "allow_once";
26546
26546
  return null;
26547
26547
  }
26548
26548
  function isChoicePrompt(prompt) {
@@ -26722,10 +26722,10 @@ function toolDetailPreview(value) {
26722
26722
  return result;
26723
26723
  };
26724
26724
  const safe = redactSecrets(bounded(value));
26725
- const text6 = typeof safe === "string" ? safe : JSON.stringify(safe, null, 2);
26726
- if (!text6?.trim() || text6 === "{}" || text6 === "[]") return void 0;
26727
- return text6.length > 6e3 ? `${text6.slice(0, 6e3)}
26728
- [\u2026 preview shortened]` : text6;
26725
+ const text7 = typeof safe === "string" ? safe : JSON.stringify(safe, null, 2);
26726
+ if (!text7?.trim() || text7 === "{}" || text7 === "[]") return void 0;
26727
+ return text7.length > 6e3 ? `${text7.slice(0, 6e3)}
26728
+ [\u2026 preview shortened]` : text7;
26729
26729
  }
26730
26730
  function fieldsOf(input) {
26731
26731
  if (input === null || typeof input !== "object" || Array.isArray(input)) return void 0;
@@ -26742,8 +26742,8 @@ function askInputSummary(input) {
26742
26742
  if (typeof fields.question === "string") return cut(fields.question, QUESTION_LIMIT);
26743
26743
  if (typeof fields.command === "string") return cut(fields.command, LIMIT);
26744
26744
  if (typeof fields.url === "string") return cut(fields.url, LIMIT);
26745
- const text6 = JSON.stringify(fields);
26746
- return text6 === "{}" ? void 0 : cut(text6, LIMIT);
26745
+ const text7 = JSON.stringify(fields);
26746
+ return text7 === "{}" ? void 0 : cut(text7, LIMIT);
26747
26747
  }
26748
26748
  var QUESTION_LIMIT, LIMIT, cut;
26749
26749
  var init_tool_summary = __esm({
@@ -26752,7 +26752,7 @@ var init_tool_summary = __esm({
26752
26752
  init_redact2();
26753
26753
  QUESTION_LIMIT = 300;
26754
26754
  LIMIT = 200;
26755
- cut = (text6, limit) => redactSecretsInText(text6).trim().slice(0, limit);
26755
+ cut = (text7, limit) => redactSecretsInText(text7).trim().slice(0, limit);
26756
26756
  }
26757
26757
  });
26758
26758
 
@@ -26778,17 +26778,17 @@ var init_mcp_tool_images = __esm({
26778
26778
 
26779
26779
  // shared/mcp-tool-ref.ts
26780
26780
  function mcpToolRefFromLabel(label, servers) {
26781
- const text6 = label.trim();
26782
- if (!text6) return null;
26781
+ const text7 = label.trim();
26782
+ if (!text7) return null;
26783
26783
  const ordered = [...servers].sort((a2, b3) => b3.length - a2.length);
26784
26784
  const accept = (server, tool2) => MCP_TOOL_NAME.test(tool2) ? { server, tool: tool2 } : null;
26785
26785
  for (const server of ordered) {
26786
26786
  const claude = `mcp__${server}__`;
26787
- if (text6.startsWith(claude)) {
26788
- const hit = accept(server, text6.slice(claude.length));
26787
+ if (text7.startsWith(claude)) {
26788
+ const hit = accept(server, text7.slice(claude.length));
26789
26789
  if (hit) return hit;
26790
26790
  }
26791
- const display = new RegExp(`^(\\S+) \\(${server.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")} MCP Server\\)$`).exec(text6);
26791
+ const display = new RegExp(`^(\\S+) \\(${server.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")} MCP Server\\)$`).exec(text7);
26792
26792
  if (display) {
26793
26793
  const hit = accept(server, display[1]);
26794
26794
  if (hit) return hit;
@@ -26796,8 +26796,8 @@ function mcpToolRefFromLabel(label, servers) {
26796
26796
  }
26797
26797
  for (const separator of ["__", ":", ".", "/", "_"]) {
26798
26798
  for (const server of ordered) {
26799
- if (!text6.startsWith(`${server}${separator}`)) continue;
26800
- const hit = accept(server, text6.slice(server.length + separator.length));
26799
+ if (!text7.startsWith(`${server}${separator}`)) continue;
26800
+ const hit = accept(server, text7.slice(server.length + separator.length));
26801
26801
  if (hit) return hit;
26802
26802
  }
26803
26803
  }
@@ -26815,8 +26815,8 @@ var init_mcp_tool_ref = __esm({
26815
26815
  function isBrokenAntigravityCheckpoint(driverKind, message3) {
26816
26816
  return driverKind === "antigravityAgent" && message3.includes("could not find doneCh for checkpoint");
26817
26817
  }
26818
- function isAntigravityCheckpointReply(driverKind, text6) {
26819
- return driverKind === "antigravityAgent" && /^Agent execution error: could not find doneCh for checkpoint\s*$/.test(text6.trim());
26818
+ function isAntigravityCheckpointReply(driverKind, text7) {
26819
+ return driverKind === "antigravityAgent" && /^Agent execution error: could not find doneCh for checkpoint\s*$/.test(text7.trim());
26820
26820
  }
26821
26821
  var init_checkpoint_recovery = __esm({
26822
26822
  "server/checkpoint-recovery.ts"() {
@@ -26856,9 +26856,9 @@ var init_provider_safety = __esm({
26856
26856
  });
26857
26857
 
26858
26858
  // server/model-access-refusal.ts
26859
- function isModelAccessRefused(text6) {
26860
- if (!text6 || SIGN_IN_WORDS.test(text6)) return false;
26861
- return MODEL_ACCESS_REFUSED.some((pattern) => pattern.test(text6));
26859
+ function isModelAccessRefused(text7) {
26860
+ if (!text7 || SIGN_IN_WORDS.test(text7)) return false;
26861
+ return MODEL_ACCESS_REFUSED.some((pattern) => pattern.test(text7));
26862
26862
  }
26863
26863
  var AUTH_STATUS, MODEL_NAME, MODEL_ACCESS_REFUSED, SIGN_IN_WORDS;
26864
26864
  var init_model_access_refusal = __esm({
@@ -26894,14 +26894,14 @@ var init_model_access_refusal = __esm({
26894
26894
  });
26895
26895
 
26896
26896
  // server/engine-failure.ts
26897
- function statedReset(text6, now = Date.now()) {
26898
- const reset = parseReset(text6, now);
26897
+ function statedReset(text7, now = Date.now()) {
26898
+ const reset = parseReset(text7, now);
26899
26899
  if (reset) return { resetAt: reset.at, resetText: reset.text };
26900
- const windowMs = rollingWindowMs(text6);
26901
- return windowMs ? { windowMs, resetText: rollingWindowPhrase(text6) } : {};
26900
+ const windowMs = rollingWindowMs(text7);
26901
+ return windowMs ? { windowMs, resetText: rollingWindowPhrase(text7) } : {};
26902
26902
  }
26903
- function rollingWindowMs(text6) {
26904
- const m3 = ROLLING_WINDOW.exec(text6);
26903
+ function rollingWindowMs(text7) {
26904
+ const m3 = ROLLING_WINDOW.exec(text7);
26905
26905
  if (!m3) return void 0;
26906
26906
  const amount = Number(m3[1] ?? m3[3]);
26907
26907
  const unit = (m3[2] ?? m3[4]).toLowerCase();
@@ -26909,37 +26909,37 @@ function rollingWindowMs(text6) {
26909
26909
  const ms2 = amount * scale;
26910
26910
  return Number.isFinite(ms2) && ms2 > 0 ? Math.min(ms2, MAX_WINDOW_MS) : void 0;
26911
26911
  }
26912
- function rollingWindowPhrase(text6) {
26913
- const m3 = ROLLING_WINDOW.exec(text6);
26912
+ function rollingWindowPhrase(text7) {
26913
+ const m3 = ROLLING_WINDOW.exec(text7);
26914
26914
  if (!m3) return void 0;
26915
- const lead = /\b(?:usage\s+)?resets?\s+(?:over\s+)?(?:a\s+)?$/i.exec(text6.slice(Math.max(0, m3.index - 30), m3.index));
26915
+ const lead = /\b(?:usage\s+)?resets?\s+(?:over\s+)?(?:a\s+)?$/i.exec(text7.slice(Math.max(0, m3.index - 30), m3.index));
26916
26916
  return resetPhrase(`${lead ? lead[0] : ""}${m3[0]}`);
26917
26917
  }
26918
- function isCredentialDead(text6) {
26919
- return Boolean(text6) && CREDENTIAL_DEAD.some((pattern) => pattern.test(text6));
26918
+ function isCredentialDead(text7) {
26919
+ return Boolean(text7) && CREDENTIAL_DEAD.some((pattern) => pattern.test(text7));
26920
26920
  }
26921
26921
  function isOpaqueRequestRejection(message3) {
26922
26922
  return OPAQUE_REQUEST_REJECTION.test(message3);
26923
26923
  }
26924
- function classifyEngineFailure(text6, now = Date.now()) {
26925
- if (!text6) return null;
26926
- const tooFast = TOO_FAST.some((pattern) => pattern.test(text6));
26927
- if (USAGE_LIMITED.some((pattern) => pattern.test(text6)) || !tooFast && EXHAUSTED.some((pattern) => pattern.test(text6))) {
26928
- return { kind: "usage_limited", ...statedReset(text6, now) };
26929
- }
26930
- if (isCredentialDead(text6)) return { kind: "auth_failed", permanent: true };
26931
- if (isModelAccessRefused(text6)) return { kind: "request_rejected" };
26932
- if (AUTH_FAILED.some((pattern) => pattern.test(text6))) return { kind: "auth_failed" };
26933
- if (STALLED.some((pattern) => pattern.test(text6))) return { kind: "stalled" };
26934
- if (tooFast || RATE_LIMITED.some((pattern) => pattern.test(text6))) {
26935
- const reset = parseReset(text6, now);
26924
+ function classifyEngineFailure(text7, now = Date.now()) {
26925
+ if (!text7) return null;
26926
+ const tooFast = TOO_FAST.some((pattern) => pattern.test(text7));
26927
+ if (USAGE_LIMITED.some((pattern) => pattern.test(text7)) || !tooFast && EXHAUSTED.some((pattern) => pattern.test(text7))) {
26928
+ return { kind: "usage_limited", ...statedReset(text7, now) };
26929
+ }
26930
+ if (isCredentialDead(text7)) return { kind: "auth_failed", permanent: true };
26931
+ if (isModelAccessRefused(text7)) return { kind: "request_rejected" };
26932
+ if (AUTH_FAILED.some((pattern) => pattern.test(text7))) return { kind: "auth_failed" };
26933
+ if (STALLED.some((pattern) => pattern.test(text7))) return { kind: "stalled" };
26934
+ if (tooFast || RATE_LIMITED.some((pattern) => pattern.test(text7))) {
26935
+ const reset = parseReset(text7, now);
26936
26936
  return { kind: "rate_limited", ...reset ? { resetAt: reset.at, resetText: reset.text } : {} };
26937
26937
  }
26938
26938
  return null;
26939
26939
  }
26940
- function logAuthFailure(text6) {
26941
- if (!text6) return void 0;
26942
- for (const line of text6.split(/\r?\n/)) {
26940
+ function logAuthFailure(text7) {
26941
+ if (!text7) return void 0;
26942
+ for (const line of text7.split(/\r?\n/)) {
26943
26943
  if (LOG_AUTH_FAILED.some((pattern) => pattern.test(line))) return line.trim().slice(0, 300);
26944
26944
  }
26945
26945
  return void 0;
@@ -26955,13 +26955,13 @@ function engineFailureFromCodexInfo(info) {
26955
26955
  if (name === "unauthorized") return "auth_failed";
26956
26956
  return void 0;
26957
26957
  }
26958
- function parseResetAt(text6, now = Date.now()) {
26959
- return parseReset(text6, now)?.at;
26958
+ function parseResetAt(text7, now = Date.now()) {
26959
+ return parseReset(text7, now)?.at;
26960
26960
  }
26961
- function parseReset(text6, now = Date.now()) {
26962
- if (!text6) return void 0;
26961
+ function parseReset(text7, now = Date.now()) {
26962
+ if (!text7) return void 0;
26963
26963
  for (const read of RESET_READERS) {
26964
- for (const found of read(text6, now)) {
26964
+ for (const found of read(text7, now)) {
26965
26965
  if (Number.isFinite(found.at) && found.at > now && found.at - now <= MAX_RESET_AHEAD_MS) {
26966
26966
  return { at: Math.round(found.at), text: resetPhrase(found.phrase) };
26967
26967
  }
@@ -26988,27 +26988,27 @@ function resetHintFromData(data) {
26988
26988
  };
26989
26989
  return walk(data, 0);
26990
26990
  }
26991
- function durationMs(text6) {
26991
+ function durationMs(text7) {
26992
26992
  let total = 0;
26993
- for (const part of text6.matchAll(new RegExp(String.raw`(\d+(?:\.\d+)?)\s*(${UNIT})`, "gi"))) {
26993
+ for (const part of text7.matchAll(new RegExp(String.raw`(\d+(?:\.\d+)?)\s*(${UNIT})`, "gi"))) {
26994
26994
  const unit = part[2].toLowerCase();
26995
26995
  const scale = unit === "ms" || unit.startsWith("milli") ? 1 : unit[0] === "d" ? DAY_MS4 : unit[0] === "h" ? HOUR_MS : unit[0] === "m" ? MINUTE_MS : 1e3;
26996
26996
  total += Number(part[1]) * scale;
26997
26997
  }
26998
26998
  return total;
26999
26999
  }
27000
- function leadIn(text6, index) {
27001
- const before = text6.slice(Math.max(0, index - 30), index);
27000
+ function leadIn(text7, index) {
27001
+ const before = text7.slice(Math.max(0, index - 30), index);
27002
27002
  const lead = new RegExp(String.raw`${RESET_WORD}(?:\s+(?:at|on|in))?[\s:=∙·-]*$`, "i").exec(before);
27003
27003
  return lead ? index - (before.length - lead.index) : index;
27004
27004
  }
27005
- function readClock(text6, now) {
27005
+ function readClock(text7, now) {
27006
27006
  const reading = {};
27007
27007
  let i2 = 0;
27008
- const skipFiller = () => i2 += CLOCK_FILLER.exec(text6.slice(i2))[0].length;
27008
+ const skipFiller = () => i2 += CLOCK_FILLER.exec(text7.slice(i2))[0].length;
27009
27009
  skipFiller();
27010
27010
  for (let parts = 0; parts < 4; parts++) {
27011
- const rest = text6.slice(i2);
27011
+ const rest = text7.slice(i2);
27012
27012
  let m3;
27013
27013
  if (!reading.dayWord && reading.weekday === void 0 && !reading.date && (m3 = CLOCK_PARTS.dayWord.exec(rest))) {
27014
27014
  reading.dayWord = m3[1].toLowerCase();
@@ -27033,11 +27033,11 @@ function readClock(text6, now) {
27033
27033
  i2 += m3[0].length;
27034
27034
  const before = i2;
27035
27035
  skipFiller();
27036
- if (!Object.values(CLOCK_PARTS).some((part) => part.test(text6.slice(i2)))) i2 = before;
27036
+ if (!Object.values(CLOCK_PARTS).some((part) => part.test(text7.slice(i2)))) i2 = before;
27037
27037
  }
27038
27038
  if (reading.hour === void 0 || reading.hour > 23 || reading.minute > 59) return void 0;
27039
27039
  if (reading.date && (reading.date.month < 1 || reading.date.day < 1 || reading.date.day > 31)) return void 0;
27040
- const after = zoneAfter(text6.slice(i2));
27040
+ const after = zoneAfter(text7.slice(i2));
27041
27041
  const zone = after?.zone ?? localZone();
27042
27042
  const length = i2 + (after?.length ?? 0);
27043
27043
  const today = zonedToday(now, zone);
@@ -27059,21 +27059,21 @@ function readClock(text6, now) {
27059
27059
  return { at: found, length };
27060
27060
  }
27061
27061
  function parseZone(token) {
27062
- const text6 = token.trim();
27063
- const offset = /^(?:UTC|GMT)?\s*([+-])\s*(\d{1,2})(?::?(\d{2}))?$/i.exec(text6);
27062
+ const text7 = token.trim();
27063
+ const offset = /^(?:UTC|GMT)?\s*([+-])\s*(\d{1,2})(?::?(\d{2}))?$/i.exec(text7);
27064
27064
  if (offset) {
27065
27065
  const minutes = Number(offset[2]) * 60 + Number(offset[3] ?? 0);
27066
27066
  return minutes <= 14 * 60 ? { offsetMinutes: offset[1] === "-" ? -minutes : minutes } : void 0;
27067
27067
  }
27068
- const upper = text6.toUpperCase();
27068
+ const upper = text7.toUpperCase();
27069
27069
  if (upper in ZONE_ABBREVIATIONS) return { offsetMinutes: ZONE_ABBREVIATIONS[upper] };
27070
- return text6.includes("/") && validTimeZone(text6) ? { name: text6 } : void 0;
27070
+ return text7.includes("/") && validTimeZone(text7) ? { name: text7 } : void 0;
27071
27071
  }
27072
- function zoneAfter(text6) {
27073
- const bare = new RegExp(String.raw`^\s*,?\s*(${ZONE_TOKEN})(?![A-Za-z0-9/])`).exec(text6);
27072
+ function zoneAfter(text7) {
27073
+ const bare = new RegExp(String.raw`^\s*,?\s*(${ZONE_TOKEN})(?![A-Za-z0-9/])`).exec(text7);
27074
27074
  const bareZone = bare ? parseZone(bare[1]) : void 0;
27075
27075
  if (bare && bareZone) return { zone: bareZone, length: bare[0].length };
27076
- const paren = /^[^()\n]{0,20}\(([^()\n]{1,60})\)/.exec(text6);
27076
+ const paren = /^[^()\n]{0,20}\(([^()\n]{1,60})\)/.exec(text7);
27077
27077
  if (paren) {
27078
27078
  for (const token of paren[1].split(/[\s,;]+/).reverse()) {
27079
27079
  const zone = parseZone(token);
@@ -27124,8 +27124,8 @@ function wallToInstant(year, month, day, hour, minute, zone, extraMs = 0) {
27124
27124
  at2 = wall - offsetAt(at2);
27125
27125
  return at2;
27126
27126
  }
27127
- function resetPhrase(text6) {
27128
- const phrase = text6.replace(/\s+/g, " ").trim().replace(/^[\s|,;:∙·-]+|[\s,;:.∙·-]+$/g, "");
27127
+ function resetPhrase(text7) {
27128
+ const phrase = text7.replace(/\s+/g, " ").trim().replace(/^[\s|,;:∙·-]+|[\s,;:.∙·-]+$/g, "");
27129
27129
  return phrase.length > RESET_TEXT_MAX ? `${phrase.slice(0, RESET_TEXT_MAX - 1)}\u2026` : phrase;
27130
27130
  }
27131
27131
  var MAX_WINDOW_MS, ROLLING_WINDOW, USAGE_LIMITED, EXHAUSTED, TOO_FAST, RATE_LIMITED, CREDENTIAL_DEAD, LOGIN_EXPIRED_REPLY, AUTH_FAILED, STALLED, OPAQUE_REQUEST_REJECTION, LOG_AUTH_FAILED, MINUTE_MS, HOUR_MS, DAY_MS4, MAX_RESET_AHEAD_MS, RESET_TEXT_MAX, RESET_DATA_KEYS, UNIT, DURATION, RESET_WORD, RESET_READERS, MONTH, WEEKDAYS, CLOCK_FILLER, CLOCK_PARTS, monthIndex, ZONE_ABBREVIATIONS, ZONE_TOKEN, localZone;
@@ -27235,49 +27235,49 @@ var init_engine_failure = __esm({
27235
27235
  RESET_WORD = String.raw`\b(?:resets?|try again|retry|available again|renews?|refresh(?:es)?)\b`;
27236
27236
  RESET_READERS = [
27237
27237
  // Claude Code's "usage limit reached|1759348800".
27238
- function* epochPipe(text6) {
27239
- for (const m3 of text6.matchAll(/(?:usage limit reached\s*)?\|\s*(\d{10})(\d{3})?(?!\d)/gi)) {
27238
+ function* epochPipe(text7) {
27239
+ for (const m3 of text7.matchAll(/(?:usage limit reached\s*)?\|\s*(\d{10})(\d{3})?(?!\d)/gi)) {
27240
27240
  yield { at: Number(m3[1]) * 1e3, phrase: m3[0] };
27241
27241
  }
27242
27242
  },
27243
27243
  // A structured reset instant: Codex's "resets_at": 1759348800, a
27244
27244
  // "resetsAt", the unified rate-limit header.
27245
- function* epochField(text6) {
27246
- for (const m3 of text6.matchAll(/["']?\b(?:resets_at|resetsAt|reset_at|resetAt|ratelimit-unified-reset)["']?\s*[:=]\s*["']?(\d{10}|\d{13})(?!\d)/gi)) {
27245
+ function* epochField(text7) {
27246
+ for (const m3 of text7.matchAll(/["']?\b(?:resets_at|resetsAt|reset_at|resetAt|ratelimit-unified-reset)["']?\s*[:=]\s*["']?(\d{10}|\d{13})(?!\d)/gi)) {
27247
27247
  yield { at: m3[1].length === 13 ? Number(m3[1]) : Number(m3[1]) * 1e3, phrase: m3[0] };
27248
27248
  }
27249
27249
  },
27250
27250
  // "2026-09-25T18:00:00Z", "2026-10-03 09:00:00+02:00", "2026-08-08 00:00 UTC".
27251
- function* isoTimestamp(text6) {
27252
- for (const m3 of text6.matchAll(/\b(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:\s*(Z|UTC|GMT|[+-]\d{2}:?\d{2})\b)?/g)) {
27251
+ function* isoTimestamp(text7) {
27252
+ for (const m3 of text7.matchAll(/\b(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:\s*(Z|UTC|GMT|[+-]\d{2}:?\d{2})\b)?/g)) {
27253
27253
  const [, y, mo2, d, h2, mi2, sec, frac, zoneText] = m3;
27254
- const start = leadIn(text6, m3.index);
27254
+ const start = leadIn(text7, m3.index);
27255
27255
  if (!zoneText && start === m3.index) continue;
27256
- const after = zoneText ? void 0 : zoneAfter(text6.slice(m3.index + m3[0].length));
27256
+ const after = zoneText ? void 0 : zoneAfter(text7.slice(m3.index + m3[0].length));
27257
27257
  const zone = zoneText ? parseZone(zoneText) : after?.zone ?? localZone();
27258
27258
  if (!zone) continue;
27259
27259
  const ms2 = frac ? Math.round(Number(`0.${frac}`) * 1e3) : 0;
27260
27260
  const at2 = wallToInstant(Number(y), Number(mo2), Number(d), Number(h2), Number(mi2), zone, Number(sec ?? 0) * 1e3 + ms2);
27261
- yield { at: at2, phrase: text6.slice(start, m3.index + m3[0].length + (after?.length ?? 0)) };
27261
+ yield { at: at2, phrase: text7.slice(start, m3.index + m3[0].length + (after?.length ?? 0)) };
27262
27262
  }
27263
27263
  },
27264
27264
  // "Retry-After: 120", "retry after 3600 seconds".
27265
- function* retryAfter(text6, now) {
27266
- for (const m3 of text6.matchAll(new RegExp(String.raw`\bretry[- ]after:?\s*(\d+(?:\.\d+)?)\s*(${UNIT})?`, "gi"))) {
27265
+ function* retryAfter(text7, now) {
27266
+ for (const m3 of text7.matchAll(new RegExp(String.raw`\bretry[- ]after:?\s*(\d+(?:\.\d+)?)\s*(${UNIT})?`, "gi"))) {
27267
27267
  yield { at: now + (m3[2] ? durationMs(`${m3[1]}${m3[2]}`) : Number(m3[1]) * 1e3), phrase: m3[0] };
27268
27268
  }
27269
27269
  },
27270
27270
  // Structured durations: Gemini's "retryDelay": "41s", Codex's
27271
27271
  // "resets_in_seconds": 3600, a "retry_after": 30.
27272
- function* durationField(text6, now) {
27273
- for (const m3 of text6.matchAll(/["']?\b(retryDelay|retry_delay|retryAfter|retry_after(?:_seconds)?|resets_in_seconds|resetsInSeconds)["']?\s*[:=]\s*["']?(\d+(?:\.\d+)?)\s*(ms|s)?(?![a-z\d])/gi)) {
27272
+ function* durationField(text7, now) {
27273
+ for (const m3 of text7.matchAll(/["']?\b(retryDelay|retry_delay|retryAfter|retry_after(?:_seconds)?|resets_in_seconds|resetsInSeconds)["']?\s*[:=]\s*["']?(\d+(?:\.\d+)?)\s*(ms|s)?(?![a-z\d])/gi)) {
27274
27274
  yield { at: now + Number(m3[2]) * (m3[3]?.toLowerCase() === "ms" ? 1 : 1e3), phrase: m3[0] };
27275
27275
  }
27276
27276
  },
27277
27277
  // "try again in 2 days 4 hours 12 minutes", "resets in 37m", "Please
27278
27278
  // retry in 41.5s", "resets in 2d 4h 30m", Hermes's "resets in ~127h".
27279
- function* relative(text6, now) {
27280
- for (const m3 of text6.matchAll(new RegExp(String.raw`${RESET_WORD}\s+in\s+~?\s*(${DURATION})`, "gi"))) {
27279
+ function* relative(text7, now) {
27280
+ for (const m3 of text7.matchAll(new RegExp(String.raw`${RESET_WORD}\s+in\s+~?\s*(${DURATION})`, "gi"))) {
27281
27281
  const total = durationMs(m3[1]);
27282
27282
  if (total > 0) yield { at: now + total, phrase: m3[0] };
27283
27283
  }
@@ -27285,11 +27285,11 @@ var init_engine_failure = __esm({
27285
27285
  // A time of day, maybe with a date: "resets 3pm (America/New_York)",
27286
27286
  // "resets Oct 3, 9am", "try again tomorrow at 9:00", "resets Thursday
27287
27287
  // 9am", "Access resets at 3:45 PM EDT", "15:05 on 26 Sep 2026".
27288
- function* clock2(text6, now) {
27289
- for (const m3 of text6.matchAll(new RegExp(RESET_WORD, "gi"))) {
27288
+ function* clock2(text7, now) {
27289
+ for (const m3 of text7.matchAll(new RegExp(RESET_WORD, "gi"))) {
27290
27290
  const start = m3.index + m3[0].length;
27291
- const found = readClock(text6.slice(start, start + 120), now);
27292
- if (found) yield { at: found.at, phrase: text6.slice(m3.index, start + found.length) };
27291
+ const found = readClock(text7.slice(start, start + 120), now);
27292
+ if (found) yield { at: found.at, phrase: text7.slice(m3.index, start + found.length) };
27293
27293
  }
27294
27294
  }
27295
27295
  ];
@@ -27351,13 +27351,13 @@ function isModelRejection(error51, requested) {
27351
27351
  return MODEL_REJECTION.test(message3) || requested.length > 0 && message3.includes(requested) && /\bmodel\b/i.test(message3);
27352
27352
  }
27353
27353
  function classifyError(err) {
27354
- const text6 = messageOf(err);
27355
- if (isProviderSafetyBlock(text6)) return { transient: false, reason: "provider_safety" };
27356
- if (CREDENTIAL_REFRESH_CONFLICT.test(text6)) {
27354
+ const text7 = messageOf(err);
27355
+ if (isProviderSafetyBlock(text7)) return { transient: false, reason: "provider_safety" };
27356
+ if (CREDENTIAL_REFRESH_CONFLICT.test(text7)) {
27357
27357
  if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
27358
27358
  return { transient: true, reason: "credential_refresh" };
27359
27359
  }
27360
- const failure = classifyEngineFailure(text6);
27360
+ const failure = classifyEngineFailure(text7);
27361
27361
  if (failure?.kind === "rate_limited") {
27362
27362
  if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
27363
27363
  return { transient: true, reason: "rate_limited" };
@@ -27367,18 +27367,18 @@ function classifyError(err) {
27367
27367
  const { exitCode: code } = err;
27368
27368
  if (code !== null && code < 0) return { transient: false, reason: "interrupted" };
27369
27369
  for (const { pattern, reason } of TRANSIENT_PATTERNS) {
27370
- if (pattern.test(text6)) return { transient: true, reason };
27370
+ if (pattern.test(text7)) return { transient: true, reason };
27371
27371
  }
27372
27372
  for (const { pattern, reason } of TERMINAL_PATTERNS) {
27373
- if (pattern.test(text6)) return { transient: false, reason };
27373
+ if (pattern.test(text7)) return { transient: false, reason };
27374
27374
  }
27375
27375
  return { transient: false, reason: "terminal_exit" };
27376
27376
  }
27377
27377
  for (const { pattern, reason } of TERMINAL_PATTERNS) {
27378
- if (pattern.test(text6)) return { transient: false, reason };
27378
+ if (pattern.test(text7)) return { transient: false, reason };
27379
27379
  }
27380
27380
  for (const { pattern, reason } of TRANSIENT_PATTERNS) {
27381
- if (pattern.test(text6)) return { transient: true, reason };
27381
+ if (pattern.test(text7)) return { transient: true, reason };
27382
27382
  }
27383
27383
  return { transient: false, reason: "unknown" };
27384
27384
  }
@@ -27516,18 +27516,20 @@ function turnMcpServers(turn) {
27516
27516
  }
27517
27517
  return servers;
27518
27518
  }
27519
+ var ATOMIC_MCP_SERVERS;
27519
27520
  var init_turn_mcp = __esm({
27520
27521
  "server/drivers/turn-mcp.ts"() {
27521
27522
  "use strict";
27522
27523
  init_mcp_gate_config();
27524
+ ATOMIC_MCP_SERVERS = /* @__PURE__ */ new Set(["agents", "atomic_accounts", "browser", "computer"]);
27523
27525
  }
27524
27526
  });
27525
27527
 
27526
27528
  // server/drivers/volatile-notes.ts
27527
27529
  function volatileSectionsOf(turn) {
27528
27530
  if (turn.systemVolatileSections) return turn.systemVolatileSections.filter((section) => section.text.trim());
27529
- const text6 = turn.systemVolatile ?? "";
27530
- return text6.trim() ? [{ id: "volatile", label: "Notes", text: text6 }] : [];
27531
+ const text7 = turn.systemVolatile ?? "";
27532
+ return text7.trim() ? [{ id: "volatile", label: "Notes", text: text7 }] : [];
27531
27533
  }
27532
27534
  function volatileNote(sections, delivered, first) {
27533
27535
  const parts = [];
@@ -27552,11 +27554,11 @@ ${lead}
27552
27554
  ${parts.join("\n\n")}
27553
27555
  </system-reminder>`;
27554
27556
  }
27555
- function withNote(text6, note) {
27556
- if (!note) return text6;
27557
- return text6 ? `${note}
27557
+ function withNote(text7, note) {
27558
+ if (!note) return text7;
27559
+ return text7 ? `${note}
27558
27560
 
27559
- ${text6}` : note;
27561
+ ${text7}` : note;
27560
27562
  }
27561
27563
  var init_volatile_notes = __esm({
27562
27564
  "server/drivers/volatile-notes.ts"() {
@@ -27570,11 +27572,11 @@ function sanitizeToolLogValue(value, budget, depth = 0) {
27570
27572
  if (typeof value === "string") {
27571
27573
  if (/^data:image\//iu.test(value) || budget.text <= 0) return void 0;
27572
27574
  const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
27573
- const text6 = value.length <= limit ? value : `[Earlier output truncated]
27575
+ const text7 = value.length <= limit ? value : `[Earlier output truncated]
27574
27576
 
27575
27577
  ${value.slice(-limit)}`;
27576
- budget.text -= text6.length;
27577
- return text6;
27578
+ budget.text -= text7.length;
27579
+ return text7;
27578
27580
  }
27579
27581
  if (Array.isArray(value)) {
27580
27582
  return value.flatMap((entry) => {
@@ -27605,10 +27607,94 @@ var init_tool_log = __esm({
27605
27607
  }
27606
27608
  });
27607
27609
 
27610
+ // server/drivers/acp/rpc-error.ts
27611
+ function acpRpcError(value, method) {
27612
+ const raw = value && typeof value === "object" ? value : {};
27613
+ const message3 = typeof raw.message === "string" ? raw.message : "ACP request failed";
27614
+ const data = raw.data;
27615
+ const fields = data && typeof data === "object" ? data : {};
27616
+ const nested = fields.error && typeof fields.error === "object" ? fields.error : {};
27617
+ const detail = typeof data === "string" ? data : typeof fields.details === "string" ? fields.details : typeof fields.message === "string" ? fields.message : text4(nested.message);
27618
+ const context = [
27619
+ method,
27620
+ typeof fields.service === "string" ? `service: ${fields.service}` : "",
27621
+ text4(fields.errorName)
27622
+ ].filter(Boolean).join(", ");
27623
+ const said = detail && detail !== message3 ? `${message3}: ${detail}` : message3;
27624
+ const reset = parseResetAt(said) === void 0 ? resetHintFromData(data) : void 0;
27625
+ const diagnostic = `${said}${reset ? ` (${reset})` : ""} (${context})`;
27626
+ const error51 = new Error(redactSecretsInText(diagnostic).slice(0, 1500));
27627
+ return Object.assign(error51, {
27628
+ code: raw.code,
27629
+ data,
27630
+ // -32603 is JSON-RPC's internal error. Invalid params, unsupported
27631
+ // methods and auth refusals are user/configuration issues, not evidence
27632
+ // of a broken process. Preserve their session instead of retrying them.
27633
+ acpSessionFailure: raw.code === -32603
27634
+ });
27635
+ }
27636
+ var text4;
27637
+ var init_rpc_error = __esm({
27638
+ "server/drivers/acp/rpc-error.ts"() {
27639
+ "use strict";
27640
+ init_engine_failure();
27641
+ init_redact2();
27642
+ text4 = (value) => typeof value === "string" ? value : "";
27643
+ }
27644
+ });
27645
+
27646
+ // server/drivers/acp/mcp-limit.ts
27647
+ function mcpListBytes(servers) {
27648
+ return JSON.stringify(servers).replace(/[\u0080-\uffff]/g, "\\u0000").length;
27649
+ }
27650
+ function limitMcpServers(servers, limit) {
27651
+ if (!limit) return { kept: [...servers], left: [] };
27652
+ const kept = new Set(servers.filter((server) => ATOMIC_MCP_SERVERS.has(server.name)));
27653
+ const left = [];
27654
+ for (const server of servers) {
27655
+ if (kept.has(server)) continue;
27656
+ const fits = kept.size < limit.count && (limit.bytes === void 0 || mcpListBytes([...kept, server]) <= limit.bytes);
27657
+ if (fits) kept.add(server);
27658
+ else left.push(server.name);
27659
+ }
27660
+ return { kept: servers.filter((server) => kept.has(server)), left };
27661
+ }
27662
+ function sessionMcpServers(support12, servers, log = console.error) {
27663
+ const { kept, left } = limitMcpServers(servers, support12.mcpServerLimit);
27664
+ const key = `${support12.driverKind}
27665
+ ${left.join("\n")}`;
27666
+ if (left.length && !reported.has(key)) {
27667
+ reported.add(key);
27668
+ const cap = support12.mcpServerLimit;
27669
+ log(`[${support12.driverKind}] ${support12.displayName} takes at most ${cap.count} MCP servers per session${cap.bytes === void 0 ? "" : ` (${cap.bytes} bytes)`}: left out ${left.join(", ")}`);
27670
+ }
27671
+ return kept;
27672
+ }
27673
+ var reported;
27674
+ var init_mcp_limit = __esm({
27675
+ "server/drivers/acp/mcp-limit.ts"() {
27676
+ "use strict";
27677
+ init_turn_mcp();
27678
+ reported = /* @__PURE__ */ new Set();
27679
+ }
27680
+ });
27681
+
27682
+ // server/drivers/acp/setup-failure.ts
27683
+ function failureFields(setup, failure, message3) {
27684
+ const named = failure ?? (setup && !classifyEngineFailure(message3) ? "provider_error" : void 0);
27685
+ return { ...setup ? { setup: true } : {}, ...named ? { failure: named } : {} };
27686
+ }
27687
+ var init_setup_failure = __esm({
27688
+ "server/drivers/acp/setup-failure.ts"() {
27689
+ "use strict";
27690
+ init_engine_failure();
27691
+ }
27692
+ });
27693
+
27608
27694
  // shared/approval-readback.ts
27609
- function compareEffectiveMode(ladder, requested, reported) {
27610
- const want = text4(requested);
27611
- const got = text4(reported);
27695
+ function compareEffectiveMode(ladder, requested, reported2) {
27696
+ const want = text5(requested);
27697
+ const got = text5(reported2);
27612
27698
  const ranks = MODE_LADDERS[ladder];
27613
27699
  if (want === null || got === null) return { status: "unverified", requested: want, reported: got };
27614
27700
  const wantRank = ranks?.[want];
@@ -27621,14 +27707,14 @@ function compareEffectiveMode(ladder, requested, reported) {
27621
27707
  function looserModeMessage(engine, readback) {
27622
27708
  return `${engine} ran with looser permissions than requested (asked for "${readback.requested}", it reported "${readback.reported}"), so Atomic stopped the turn before it could act. Update ${engine}, check its own settings for a pinned mode, then try again.`;
27623
27709
  }
27624
- function assertEffectiveModeNotLooser(engine, ladder, requested, reported) {
27625
- const readback = compareEffectiveMode(ladder, requested, reported);
27710
+ function assertEffectiveModeNotLooser(engine, ladder, requested, reported2) {
27711
+ const readback = compareEffectiveMode(ladder, requested, reported2);
27626
27712
  if (readback.status === "looser") {
27627
27713
  throw Object.assign(new Error(looserModeMessage(engine, readback)), { code: "APPROVAL_MODE_LOOSER", readback });
27628
27714
  }
27629
27715
  return readback;
27630
27716
  }
27631
- var MODE_LADDERS, text4;
27717
+ var MODE_LADDERS, text5;
27632
27718
  var init_approval_readback = __esm({
27633
27719
  "shared/approval-readback.ts"() {
27634
27720
  "use strict";
@@ -27639,7 +27725,7 @@ var init_approval_readback = __esm({
27639
27725
  qwenAgent: { plan: 4, default: 3, "auto-edit": 2, autoEdit: 2, auto: 1, yolo: 0 },
27640
27726
  geminiAgent: { plan: 4, default: 3, autoEdit: 2, auto_edit: 2, "auto-edit": 2, yolo: 0 }
27641
27727
  };
27642
- text4 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
27728
+ text5 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
27643
27729
  }
27644
27730
  });
27645
27731
 
@@ -27661,10 +27747,10 @@ function noteModeUpdate(session, raw) {
27661
27747
  function forgetStaleModeReport(session, support12) {
27662
27748
  if (support12.approvalModeReadback?.setsModeOverWire) stateOf(session).reported = null;
27663
27749
  }
27664
- function approvalReadbackFor(support12, config2, turn, reported) {
27750
+ function approvalReadbackFor(support12, config2, turn, reported2) {
27665
27751
  const rules = support12.approvalModeReadback;
27666
- if (!rules) return { status: "unverified", requested: null, reported };
27667
- return compareEffectiveMode(rules.ladder, rules.expected(config2, turn), reported);
27752
+ if (!rules) return { status: "unverified", requested: null, reported: reported2 };
27753
+ return compareEffectiveMode(rules.ladder, rules.expected(config2, turn), reported2);
27668
27754
  }
27669
27755
  function armModeReadback(input) {
27670
27756
  const { support: support12, session, config: config2, turn } = input;
@@ -27701,28 +27787,6 @@ import { createHash as createHash5 } from "node:crypto";
27701
27787
  function skipSubscriptionAuthForLocalInject(model) {
27702
27788
  return Boolean(decodeInjectId(model));
27703
27789
  }
27704
- function acpRpcError(value, method) {
27705
- const message3 = typeof value?.message === "string" ? value.message : "ACP request failed";
27706
- const data = value?.data;
27707
- const detail = typeof data === "string" ? data : typeof data?.details === "string" ? data.details : typeof data?.message === "string" ? data.message : typeof data?.error?.message === "string" ? data.error.message : "";
27708
- const context = [
27709
- method,
27710
- typeof data?.service === "string" ? `service: ${data.service}` : "",
27711
- typeof data?.errorName === "string" ? data.errorName : ""
27712
- ].filter(Boolean).join(", ");
27713
- const said = detail && detail !== message3 ? `${message3}: ${detail}` : message3;
27714
- const reset = parseResetAt(said) === void 0 ? resetHintFromData(data) : void 0;
27715
- const diagnostic = `${said}${reset ? ` (${reset})` : ""} (${context})`;
27716
- const error51 = new Error(redactSecretsInText(diagnostic).slice(0, 1500));
27717
- return Object.assign(error51, {
27718
- code: value?.code,
27719
- data,
27720
- // -32603 is JSON-RPC's internal error. Invalid params, unsupported
27721
- // methods and auth refusals are user/configuration issues, not evidence
27722
- // of a broken process. Preserve their session instead of retrying them.
27723
- acpSessionFailure: value?.code === -32603
27724
- });
27725
- }
27726
27790
  function classifyAcpError(support12, error51) {
27727
27791
  const code = support12.classifyError?.(error51);
27728
27792
  if (code) return code;
@@ -27955,7 +28019,7 @@ function createAcpDriver(support12) {
27955
28019
  emit({
27956
28020
  ...base3(threadId, current.turnId),
27957
28021
  type: "runtime.error",
27958
- message: `${DRIVER_KIND8} ended the turn with no reply, image, or tool result`
28022
+ message: current.emptyReason ?? `${DRIVER_KIND8} ended the turn with no reply, image, or tool result`
27959
28023
  });
27960
28024
  }
27961
28025
  emit({ ...base3(threadId, current.turnId), type: "turn.completed", ok: finalOk, stopReason: finalStopReason, cost: null });
@@ -28376,11 +28440,8 @@ function createAcpDriver(support12) {
28376
28440
  session.dead = true;
28377
28441
  const current = session.current;
28378
28442
  if (current) {
28379
- emit({
28380
- ...base3(threadId, current.turnId),
28381
- type: "runtime.error",
28382
- message: `${DRIVER_KIND8} exited ${code} before the prompt result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`
28383
- });
28443
+ const message3 = `${DRIVER_KIND8} exited ${code} before the prompt result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`;
28444
+ emit({ ...base3(threadId, current.turnId), type: "runtime.error", message: message3, ...failureFields(!current.state.promptSent && !session.closing, void 0, message3) });
28384
28445
  settle(threadId, session, false, "exit_before_result");
28385
28446
  } else if (sessions.get(threadId) === session) {
28386
28447
  sessions.delete(threadId);
@@ -28481,11 +28542,11 @@ function createAcpDriver(support12) {
28481
28542
  return option;
28482
28543
  };
28483
28544
  const flushAssistantText = () => {
28484
- const text6 = state2.text;
28545
+ const text7 = state2.text;
28485
28546
  state2.text = "";
28486
- if (!text6.trim()) return;
28547
+ if (!text7.trim()) return;
28487
28548
  state2.producedItem = true;
28488
- emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text6 });
28549
+ emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
28489
28550
  };
28490
28551
  const current = {
28491
28552
  turnId,
@@ -28570,9 +28631,10 @@ function createAcpDriver(support12) {
28570
28631
  if (liveSessionId !== null && session.sessionKey === sessionKey && (cursor3 === null || cursor3 === liveSessionId)) {
28571
28632
  break;
28572
28633
  }
28573
- const sessionServers = mcpServers.filter((server) => !("type" in server) || init?.agentCapabilities?.mcpCapabilities?.[server.type] === true);
28634
+ const sessionServers = sessionMcpServers(support12, mcpServers.filter((server) => !("type" in server) || init?.agentCapabilities?.mcpCapabilities?.[server.type] === true));
28574
28635
  let loaded = false;
28575
- if (cursor3) {
28636
+ const fresh = support12.freshSessionForLocalModel === true && liveSessionId !== cursor3 && decodeInjectId(turn.model) !== null;
28637
+ if (cursor3 && !fresh) {
28576
28638
  try {
28577
28639
  await request(
28578
28640
  support12.resumeMethod === "resume" ? "session/resume" : "session/load",
@@ -28716,7 +28778,7 @@ function createAcpDriver(support12) {
28716
28778
  }
28717
28779
  emitSessionStarted();
28718
28780
  const instructed = promptWithInstructions(threadId, sessionId, createdNativeSession, promptTurn);
28719
- const text6 = support12.buildPromptText ? support12.buildPromptText(instructed) : instructed.system ? `${instructed.system}
28781
+ const text7 = support12.buildPromptText ? support12.buildPromptText(instructed) : instructed.system ? `${instructed.system}
28720
28782
 
28721
28783
  ${instructed.text}` : instructed.text;
28722
28784
  const imageBlocks = support12.images === true && runtimeAcceptsImages ? await readAcpImageBlocks(turn.images ?? []) : [];
@@ -28739,10 +28801,11 @@ ${instructed.text}` : instructed.text;
28739
28801
  }
28740
28802
  });
28741
28803
  state2.promptSent = true;
28804
+ const promptedAt = Date.now();
28742
28805
  const promptIdleMs = promptIdleTimeoutMs(support12, cliTurn.model);
28743
28806
  const result = await request(
28744
28807
  "session/prompt",
28745
- { sessionId, prompt: [{ type: "text", text: text6 }, ...imageBlocks] },
28808
+ { sessionId, prompt: [{ type: "text", text: text7 }, ...imageBlocks] },
28746
28809
  void 0,
28747
28810
  void 0,
28748
28811
  promptIdleMs,
@@ -28761,8 +28824,10 @@ ${instructed.text}` : instructed.text;
28761
28824
  });
28762
28825
  }
28763
28826
  const reason = result?.stopReason;
28764
- if (reason === "end_turn") settle(threadId, session, true, null);
28765
- else if (reason === "cancelled") settle(threadId, session, true, "cancelled");
28827
+ if (reason === "end_turn") {
28828
+ if (!state2.producedItem && !state2.text.trim()) current.emptyReason = await support12.explainEmptyTurn?.({ sessionId, since: promptedAt, env });
28829
+ settle(threadId, session, true, null);
28830
+ } else if (reason === "cancelled") settle(threadId, session, true, "cancelled");
28766
28831
  else {
28767
28832
  const errorMessage = typeof result?.error === "string" && result.error ? result.error : typeof result?.message === "string" && result.message ? result.message : `Model turn failed: ${reason ?? "unknown error"}`;
28768
28833
  emit({
@@ -28781,13 +28846,8 @@ ${instructed.text}` : instructed.text;
28781
28846
  const stalled = e?.acpPromptStall === true;
28782
28847
  const needsAuth = code === "invalid_credentials" || code === "inactive_subscription" || message3 === support12.loginNote || logAuth;
28783
28848
  const failure = needsAuth ? "auth_failed" : stalled ? "stalled" : engineFailureFromCode(code) ?? (isOpaqueRequestRejection(message3) ? "request_rejected" : void 0);
28784
- emit({
28785
- ...base3(threadId, turnId),
28786
- type: "runtime.error",
28787
- message: message3,
28788
- ...needsAuth ? { setup: true } : {},
28789
- ...failure ? { failure } : {}
28790
- });
28849
+ const setup = needsAuth || !state2.promptSent && !session.closing;
28850
+ emit({ ...base3(threadId, turnId), type: "runtime.error", message: message3, ...failureFields(setup, failure, message3) });
28791
28851
  if ((logAuth || !needsAuth && (stalled || isBrokenAntigravityCheckpoint(DRIVER_KIND8, message3) || e?.acpSessionFailure === true || code === "upstream_outage")) && session.child.exitCode === null && !session.closing) {
28792
28852
  closeSession(threadId, logAuth ? "provider-auth" : stalled ? "prompt-stall" : "rpc-failure");
28793
28853
  }
@@ -28879,7 +28939,6 @@ var init_core3 = __esm({
28879
28939
  init_tool_summary();
28880
28940
  init_mcp_tool_images();
28881
28941
  init_mcp_tool_ref();
28882
- init_redact2();
28883
28942
  init_checkpoint_recovery();
28884
28943
  init_resume_recovery();
28885
28944
  init_retry();
@@ -28887,6 +28946,9 @@ var init_core3 = __esm({
28887
28946
  init_turn_mcp();
28888
28947
  init_volatile_notes();
28889
28948
  init_tool_log();
28949
+ init_rpc_error();
28950
+ init_mcp_limit();
28951
+ init_setup_failure();
28890
28952
  init_mode_readback();
28891
28953
  envOr = (key, fallback) => Number(process.env[key] ?? fallback);
28892
28954
  INIT_TIMEOUT = envOr("OPENMAUS_ACP_INIT_TIMEOUT_MS", 3e5);
@@ -29638,25 +29700,25 @@ async function pinnedZipEntries(path4) {
29638
29700
  try {
29639
29701
  const info = await handle.stat();
29640
29702
  const tailBytes = Math.min(info.size, MAX_EOCD_BYTES);
29641
- const tail2 = Buffer.alloc(tailBytes);
29703
+ const tail3 = Buffer.alloc(tailBytes);
29642
29704
  const tailOffset = info.size - tailBytes;
29643
- if ((await handle.read(tail2, 0, tailBytes, tailOffset)).bytesRead !== tailBytes) {
29705
+ if ((await handle.read(tail3, 0, tailBytes, tailOffset)).bytesRead !== tailBytes) {
29644
29706
  throw new Error("The verified archive was truncated.");
29645
29707
  }
29646
29708
  let eocd = -1;
29647
- for (let cursor4 = tail2.length - 22; cursor4 >= 0; cursor4 -= 1) {
29648
- if (tail2.readUInt32LE(cursor4) === EOCD_SIGNATURE && cursor4 + 22 + tail2.readUInt16LE(cursor4 + 20) === tail2.length) {
29709
+ for (let cursor4 = tail3.length - 22; cursor4 >= 0; cursor4 -= 1) {
29710
+ if (tail3.readUInt32LE(cursor4) === EOCD_SIGNATURE && cursor4 + 22 + tail3.readUInt16LE(cursor4 + 20) === tail3.length) {
29649
29711
  eocd = cursor4;
29650
29712
  break;
29651
29713
  }
29652
29714
  }
29653
29715
  if (eocd < 0) throw new Error("The verified archive has no valid ZIP directory.");
29654
- const disk = tail2.readUInt16LE(eocd + 4);
29655
- const directoryDisk = tail2.readUInt16LE(eocd + 6);
29656
- const diskEntries = tail2.readUInt16LE(eocd + 8);
29657
- const entryCount = tail2.readUInt16LE(eocd + 10);
29658
- const directoryBytes = tail2.readUInt32LE(eocd + 12);
29659
- const directoryOffset = tail2.readUInt32LE(eocd + 16);
29716
+ const disk = tail3.readUInt16LE(eocd + 4);
29717
+ const directoryDisk = tail3.readUInt16LE(eocd + 6);
29718
+ const diskEntries = tail3.readUInt16LE(eocd + 8);
29719
+ const entryCount = tail3.readUInt16LE(eocd + 10);
29720
+ const directoryBytes = tail3.readUInt32LE(eocd + 12);
29721
+ const directoryOffset = tail3.readUInt32LE(eocd + 16);
29660
29722
  const eocdOffset = tailOffset + eocd;
29661
29723
  if (disk !== 0 || directoryDisk !== 0 || diskEntries !== entryCount || entryCount !== 2 || directoryBytes === 4294967295 || directoryOffset === 4294967295 || directoryOffset + directoryBytes > eocdOffset) throw new Error("The verified archive uses an unsupported ZIP layout.");
29662
29724
  const directory = Buffer.alloc(directoryBytes);
@@ -29793,7 +29855,7 @@ async function installOnce2(options) {
29793
29855
  const handle = await open(archivePath, "wx", 384);
29794
29856
  const hash2 = createHash7("sha256");
29795
29857
  let downloaded = 0;
29796
- let reported = 0;
29858
+ let reported2 = 0;
29797
29859
  options.onProgress?.({ phase: "downloading", received: 0, total: asset.archiveBytes, detail: `Downloading ${asset.url}` });
29798
29860
  try {
29799
29861
  for await (const raw of response.body) {
@@ -29809,8 +29871,8 @@ async function installOnce2(options) {
29809
29871
  }
29810
29872
  hash2.update(chunk);
29811
29873
  downloaded += chunk.length;
29812
- if (downloaded - reported >= 4 * 1024 * 1024 || downloaded === asset.archiveBytes) {
29813
- reported = downloaded;
29874
+ if (downloaded - reported2 >= 4 * 1024 * 1024 || downloaded === asset.archiveBytes) {
29875
+ reported2 = downloaded;
29814
29876
  options.onProgress?.({ phase: "downloading", received: downloaded, total: asset.archiveBytes });
29815
29877
  }
29816
29878
  }
@@ -30187,14 +30249,14 @@ var init_boxagent = __esm({
30187
30249
  let pendingText = "";
30188
30250
  let problem = null;
30189
30251
  const flushAssistantText = () => {
30190
- const text6 = pendingText;
30252
+ const text7 = pendingText;
30191
30253
  pendingText = "";
30192
- if (!text6.trim()) return;
30193
- emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text6 });
30254
+ if (!text7.trim()) return;
30255
+ emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
30194
30256
  };
30195
- const ingest = (text6) => {
30196
- const delta = text6.startsWith(lastText) ? text6.slice(lastText.length) : text6;
30197
- lastText = text6;
30257
+ const ingest = (text7) => {
30258
+ const delta = text7.startsWith(lastText) ? text7.slice(lastText.length) : text7;
30259
+ lastText = text7;
30198
30260
  if (!delta) return;
30199
30261
  pendingText += delta;
30200
30262
  emit({ ...base3(threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta });
@@ -30212,9 +30274,9 @@ var init_boxagent = __esm({
30212
30274
  seen.add(id);
30213
30275
  appendNative(threadId, { dir: "in", source: "box.events", msg: ev });
30214
30276
  const kind = String(ev.type ?? ev.kind ?? "");
30215
- const text6 = ev.text ?? ev.message ?? ev.data?.text ?? ev.data?.content ?? null;
30216
- if (/assistant|message|output|response/i.test(kind) && typeof text6 === "string" && text6.trim()) {
30217
- ingest(text6);
30277
+ const text7 = ev.text ?? ev.message ?? ev.data?.text ?? ev.data?.content ?? null;
30278
+ if (/assistant|message|output|response/i.test(kind) && typeof text7 === "string" && text7.trim()) {
30279
+ ingest(text7);
30218
30280
  } else if (/usage_limit|error|fail/i.test(kind)) {
30219
30281
  const why = ev.data?.summary ?? ev.data?.message ?? ev.data?.error ?? ev.message;
30220
30282
  if (typeof why === "string" && why.trim()) problem = why.trim();
@@ -30331,8 +30393,8 @@ function toolName(tool2) {
30331
30393
  function bareTool(tool2) {
30332
30394
  return toolName(tool2).toLowerCase();
30333
30395
  }
30334
- function collapse(text6) {
30335
- return text6.trim().replace(/\s+/g, " ");
30396
+ function collapse(text7) {
30397
+ return text7.trim().replace(/\s+/g, " ");
30336
30398
  }
30337
30399
  function isShellTool(tool2) {
30338
30400
  return SHELL_TOOL.test(bareTool(tool2));
@@ -30891,8 +30953,8 @@ var init_rtk_rewrite = __esm({
30891
30953
 
30892
30954
  // server/drivers/claude-stdin.ts
30893
30955
  import { readFileSync as readFileSync10 } from "node:fs";
30894
- function claudeUserMessage(text6, images) {
30895
- if (!images?.length) return { type: "user", message: { role: "user", content: text6 } };
30956
+ function claudeUserMessage(text7, images) {
30957
+ if (!images?.length) return { type: "user", message: { role: "user", content: text7 } };
30896
30958
  const content = images.map((image) => ({
30897
30959
  type: "image",
30898
30960
  source: {
@@ -30901,7 +30963,7 @@ function claudeUserMessage(text6, images) {
30901
30963
  data: readFileSync10(image.path).toString("base64")
30902
30964
  }
30903
30965
  }));
30904
- if (text6) content.push({ type: "text", text: text6 });
30966
+ if (text7) content.push({ type: "text", text: text7 });
30905
30967
  return { type: "user", message: { role: "user", content } };
30906
30968
  }
30907
30969
  function diagnosticClaudeUserMessage(message3) {
@@ -30941,9 +31003,9 @@ function isControl(char) {
30941
31003
  }
30942
31004
  function oneLine(value) {
30943
31005
  if (typeof value !== "string") return null;
30944
- const text6 = Array.from(value, (char) => isControl(char) ? " " : char).join("").replace(/\s+/g, " ").trim();
30945
- if (!text6) return null;
30946
- return text6.length > MAX_MESSAGE ? `${text6.slice(0, MAX_MESSAGE - 1)}\u2026` : text6;
31006
+ const text7 = Array.from(value, (char) => isControl(char) ? " " : char).join("").replace(/\s+/g, " ").trim();
31007
+ if (!text7) return null;
31008
+ return text7.length > MAX_MESSAGE ? `${text7.slice(0, MAX_MESSAGE - 1)}\u2026` : text7;
30947
31009
  }
30948
31010
  function yesValue(field) {
30949
31011
  if (field.type === "boolean") return true;
@@ -31061,7 +31123,7 @@ var init_claude_elicitation = __esm({
31061
31123
  });
31062
31124
 
31063
31125
  // shared/ask-question.ts
31064
- function text5(value, limit) {
31126
+ function text6(value, limit) {
31065
31127
  if (typeof value !== "string") return void 0;
31066
31128
  const trimmed = value.trim();
31067
31129
  return trimmed ? trimmed.slice(0, limit) : void 0;
@@ -31071,18 +31133,18 @@ function isRecord3(value) {
31071
31133
  }
31072
31134
  function parseOption(value) {
31073
31135
  if (typeof value === "string") {
31074
- const label2 = text5(value, MAX_LABEL);
31136
+ const label2 = text6(value, MAX_LABEL);
31075
31137
  return label2 ? { label: label2 } : null;
31076
31138
  }
31077
31139
  if (!isRecord3(value)) return null;
31078
- const label = text5(value.label, MAX_LABEL);
31140
+ const label = text6(value.label, MAX_LABEL);
31079
31141
  if (!label) return null;
31080
- const description = text5(value.description, MAX_DESCRIPTION);
31142
+ const description = text6(value.description, MAX_DESCRIPTION);
31081
31143
  return description ? { label, description } : { label };
31082
31144
  }
31083
31145
  function parseQuestion(value) {
31084
31146
  if (!isRecord3(value)) return null;
31085
- const question = text5(value.question, MAX_QUESTION_TEXT);
31147
+ const question = text6(value.question, MAX_QUESTION_TEXT);
31086
31148
  if (!question) return null;
31087
31149
  const options = [];
31088
31150
  const seen = /* @__PURE__ */ new Set();
@@ -31093,7 +31155,7 @@ function parseQuestion(value) {
31093
31155
  options.push(option);
31094
31156
  if (options.length === MAX_OPTIONS) break;
31095
31157
  }
31096
- const header = text5(value.header, MAX_LABEL);
31158
+ const header = text6(value.header, MAX_LABEL);
31097
31159
  return {
31098
31160
  question,
31099
31161
  ...header ? { header } : {},
@@ -31122,7 +31184,7 @@ function parseChoices(input, limit = MAX_CHOICES) {
31122
31184
  const choices = [];
31123
31185
  const seen = /* @__PURE__ */ new Set();
31124
31186
  for (const raw of input) {
31125
- const label = typeof raw === "string" ? text5(raw, MAX_LABEL) : isRecord3(raw) ? text5(raw.label, MAX_LABEL) : void 0;
31187
+ const label = typeof raw === "string" ? text6(raw, MAX_LABEL) : isRecord3(raw) ? text6(raw.label, MAX_LABEL) : void 0;
31126
31188
  if (!label || seen.has(label)) continue;
31127
31189
  seen.add(label);
31128
31190
  choices.push(label);
@@ -31179,19 +31241,19 @@ function resolveClaudeConfigDir(configDir2, env = process.env) {
31179
31241
  }
31180
31242
  return normalize(expanded);
31181
31243
  }
31182
- function claudeAuthFailure(frame, text6) {
31244
+ function claudeAuthFailure(frame, text7) {
31183
31245
  if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
31184
- return !isModelAccessRefused(text6) && (frame.error === "authentication_failed" || classifyError({ text: text6 }).reason === "auth_failed");
31246
+ return !isModelAccessRefused(text7) && (frame.error === "authentication_failed" || classifyError({ text: text7 }).reason === "auth_failed");
31185
31247
  }
31186
- function claudeCredentialRefreshConflict(frame, text6) {
31248
+ function claudeCredentialRefreshConflict(frame, text7) {
31187
31249
  if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
31188
- return CREDENTIAL_REFRESH_CONFLICT.test(text6);
31250
+ return CREDENTIAL_REFRESH_CONFLICT.test(text7);
31189
31251
  }
31190
31252
  function claudeResultStopReason(o) {
31191
- const text6 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
31192
- if (o.is_error !== true) return text6(o.stop_reason) ?? text6(o.terminal_reason);
31193
- const subtype = text6(o.subtype);
31194
- return text6(o.terminal_reason) ?? (subtype && subtype !== "success" ? subtype : null) ?? "error";
31253
+ const text7 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
31254
+ if (o.is_error !== true) return text7(o.stop_reason) ?? text7(o.terminal_reason);
31255
+ const subtype = text7(o.subtype);
31256
+ return text7(o.terminal_reason) ?? (subtype && subtype !== "success" ? subtype : null) ?? "error";
31195
31257
  }
31196
31258
  function claudeEnvironment(model, source2 = process.env, configDir2, instanceEnvironment = {}) {
31197
31259
  const env = { ...source2, PATH: augmentedPath(), NPM_CONFIG_LOGLEVEL: "error" };
@@ -32366,24 +32428,24 @@ var init_claude = __esm({
32366
32428
  level: typeof msg.model === "string" ? "response-reported" : "unknown"
32367
32429
  });
32368
32430
  }
32369
- const text6 = firstText(msg.content);
32370
- if (claudeAuthFailure(o, text6)) {
32431
+ const text7 = firstText(msg.content);
32432
+ if (claudeAuthFailure(o, text7)) {
32371
32433
  if (session.turn) session.turn.authFailed = true;
32372
- emit({ ...base3(threadId, currentTurnId()), type: "runtime.error", message: text6, setup: true, failure: "auth_failed" });
32434
+ emit({ ...base3(threadId, currentTurnId()), type: "runtime.error", message: text7, setup: true, failure: "auth_failed" });
32373
32435
  break;
32374
32436
  }
32375
- if (claudeCredentialRefreshConflict(o, text6)) {
32376
- if (session.turn) session.turn.refreshConflict = text6.trim();
32437
+ if (claudeCredentialRefreshConflict(o, text7)) {
32438
+ if (session.turn) session.turn.refreshConflict = text7.trim();
32377
32439
  break;
32378
32440
  }
32379
- if (text6.trim() && o.is_api_error_message !== true && typeof o.error !== "string" && session.turn) session.turn.produced = true;
32380
- if (text6.trim()) {
32441
+ if (text7.trim() && o.is_api_error_message !== true && typeof o.error !== "string" && session.turn) session.turn.produced = true;
32442
+ if (text7.trim()) {
32381
32443
  const synthetic = o.is_api_error_message === true || typeof o.error === "string" ? { synthetic: true } : {};
32382
32444
  if (!session.turn?.sawStreamDelta) {
32383
- emit({ ...base3(threadId, currentTurnId()), ...synthetic, type: "content.delta", streamKind: "assistant_text", delta: text6 });
32445
+ emit({ ...base3(threadId, currentTurnId()), ...synthetic, type: "content.delta", streamKind: "assistant_text", delta: text7 });
32384
32446
  }
32385
32447
  if (session.turn) session.turn.sawStreamDelta = false;
32386
- emit({ ...base3(threadId, currentTurnId()), ...synthetic, type: "item.completed", itemType: "assistant_text", text: text6 });
32448
+ emit({ ...base3(threadId, currentTurnId()), ...synthetic, type: "item.completed", itemType: "assistant_text", text: text7 });
32387
32449
  }
32388
32450
  for (const b3 of Array.isArray(msg.content) ? msg.content : []) {
32389
32451
  if (b3.type === "tool_use") {
@@ -32634,12 +32696,12 @@ var init_claude = __esm({
32634
32696
  }
32635
32697
  return { turnId };
32636
32698
  };
32637
- const steer = async (threadId, text6) => {
32699
+ const steer = async (threadId, text7) => {
32638
32700
  const s4 = sessions.get(threadId);
32639
32701
  if (!s4 || !s4.turn || s4.turn.settled || s4.closing || s4.child.exitCode !== null) return "refused";
32640
32702
  const turn = s4.turn;
32641
32703
  turn.pendingSteers = (turn.pendingSteers ?? 0) + 1;
32642
- if (await writeUser(s4, threadId, claudeUserMessage(text6, void 0))) return "steered";
32704
+ if (await writeUser(s4, threadId, claudeUserMessage(text7, void 0))) return "steered";
32643
32705
  turn.pendingSteers = Math.max(0, turn.pendingSteers - 1);
32644
32706
  return "refused";
32645
32707
  };
@@ -32874,42 +32936,42 @@ var init_codex_tool_surface = __esm({
32874
32936
  });
32875
32937
 
32876
32938
  // server/toml-lite.ts
32877
- function parseTomlLite(text6) {
32939
+ function parseTomlLite(text7) {
32878
32940
  const root = {};
32879
32941
  let current = root;
32880
32942
  let pos = 0;
32881
- const peek = () => text6[pos];
32943
+ const peek = () => text7[pos];
32882
32944
  const skipSpaces = () => {
32883
- while (pos < text6.length && (text6[pos] === " " || text6[pos] === " ")) pos += 1;
32945
+ while (pos < text7.length && (text7[pos] === " " || text7[pos] === " ")) pos += 1;
32884
32946
  };
32885
32947
  const skipComment = () => {
32886
- if (text6[pos] === "#") while (pos < text6.length && text6[pos] !== "\n") pos += 1;
32948
+ if (text7[pos] === "#") while (pos < text7.length && text7[pos] !== "\n") pos += 1;
32887
32949
  };
32888
32950
  const skipBlank = () => {
32889
32951
  for (; ; ) {
32890
32952
  const before = pos;
32891
- while (pos < text6.length && /[ \t\r\n]/.test(text6[pos])) pos += 1;
32953
+ while (pos < text7.length && /[ \t\r\n]/.test(text7[pos])) pos += 1;
32892
32954
  skipComment();
32893
32955
  if (pos === before) return;
32894
32956
  }
32895
32957
  };
32896
32958
  const skipLine = () => {
32897
- while (pos < text6.length && text6[pos] !== "\n") pos += 1;
32959
+ while (pos < text7.length && text7[pos] !== "\n") pos += 1;
32898
32960
  };
32899
32961
  const basicString = () => {
32900
- const multi = text6.startsWith('"""', pos);
32962
+ const multi = text7.startsWith('"""', pos);
32901
32963
  pos += multi ? 3 : 1;
32902
- if (multi && text6[pos] === "\n") pos += 1;
32964
+ if (multi && text7[pos] === "\n") pos += 1;
32903
32965
  let out = "";
32904
- while (pos < text6.length) {
32905
- if (multi ? text6.startsWith('"""', pos) : text6[pos] === '"') {
32966
+ while (pos < text7.length) {
32967
+ if (multi ? text7.startsWith('"""', pos) : text7[pos] === '"') {
32906
32968
  pos += multi ? 3 : 1;
32907
32969
  return out;
32908
32970
  }
32909
- const ch = text6[pos];
32971
+ const ch = text7[pos];
32910
32972
  if (!multi && ch === "\n") throw new TomlError("unterminated string");
32911
32973
  if (ch === "\\") {
32912
- const next = text6[pos + 1];
32974
+ const next = text7[pos + 1];
32913
32975
  pos += 2;
32914
32976
  if (next === "n") out += "\n";
32915
32977
  else if (next === "t") out += " ";
@@ -32917,10 +32979,10 @@ function parseTomlLite(text6) {
32917
32979
  else if (next === '"' || next === "\\") out += next;
32918
32980
  else if (next === "u" || next === "U") {
32919
32981
  const length = next === "u" ? 4 : 8;
32920
- out += String.fromCodePoint(parseInt(text6.slice(pos, pos + length), 16));
32982
+ out += String.fromCodePoint(parseInt(text7.slice(pos, pos + length), 16));
32921
32983
  pos += length;
32922
32984
  } else if (multi && next === "\n") {
32923
- while (pos < text6.length && /[ \t\r\n]/.test(text6[pos])) pos += 1;
32985
+ while (pos < text7.length && /[ \t\r\n]/.test(text7[pos])) pos += 1;
32924
32986
  } else out += next ?? "";
32925
32987
  continue;
32926
32988
  }
@@ -32930,12 +32992,12 @@ function parseTomlLite(text6) {
32930
32992
  throw new TomlError("unterminated string");
32931
32993
  };
32932
32994
  const literalString = () => {
32933
- const multi = text6.startsWith("'''", pos);
32995
+ const multi = text7.startsWith("'''", pos);
32934
32996
  pos += multi ? 3 : 1;
32935
- if (multi && text6[pos] === "\n") pos += 1;
32936
- const end = text6.indexOf(multi ? "'''" : "'", pos);
32997
+ if (multi && text7[pos] === "\n") pos += 1;
32998
+ const end = text7.indexOf(multi ? "'''" : "'", pos);
32937
32999
  if (end < 0) throw new TomlError("unterminated string");
32938
- const value2 = text6.slice(pos, end);
33000
+ const value2 = text7.slice(pos, end);
32939
33001
  if (!multi && value2.includes("\n")) throw new TomlError("unterminated string");
32940
33002
  pos = end + (multi ? 3 : 1);
32941
33003
  return value2;
@@ -32945,9 +33007,9 @@ function parseTomlLite(text6) {
32945
33007
  if (peek() === '"') return basicString();
32946
33008
  if (peek() === "'") return literalString();
32947
33009
  const start = pos;
32948
- while (pos < text6.length && /[A-Za-z0-9_-]/.test(text6[pos])) pos += 1;
33010
+ while (pos < text7.length && /[A-Za-z0-9_-]/.test(text7[pos])) pos += 1;
32949
33011
  if (pos === start) throw new TomlError("expected a key");
32950
- return text6.slice(start, pos);
33012
+ return text7.slice(start, pos);
32951
33013
  };
32952
33014
  const keyPath = () => {
32953
33015
  const parts = [key()];
@@ -32999,8 +33061,8 @@ function parseTomlLite(text6) {
32999
33061
  }
33000
33062
  }
33001
33063
  const start = pos;
33002
- while (pos < text6.length && !/[,\]}\r\n#]/.test(text6[pos])) pos += 1;
33003
- const raw = text6.slice(start, pos).trim();
33064
+ while (pos < text7.length && !/[,\]}\r\n#]/.test(text7[pos])) pos += 1;
33065
+ const raw = text7.slice(start, pos).trim();
33004
33066
  if (raw === "true") return true;
33005
33067
  if (raw === "false") return false;
33006
33068
  const number5 = Number(raw.replace(/_/g, ""));
@@ -33025,12 +33087,12 @@ function parseTomlLite(text6) {
33025
33087
  const parent = tableAt(base3, path4.slice(0, -1));
33026
33088
  parent[path4[path4.length - 1]] = item;
33027
33089
  }
33028
- while (pos < text6.length) {
33090
+ while (pos < text7.length) {
33029
33091
  skipBlank();
33030
- if (pos >= text6.length) break;
33092
+ if (pos >= text7.length) break;
33031
33093
  const lineStart = pos;
33032
33094
  try {
33033
- if (text6.startsWith("[[", pos)) {
33095
+ if (text7.startsWith("[[", pos)) {
33034
33096
  pos += 2;
33035
33097
  keyPath();
33036
33098
  current = {};
@@ -33636,7 +33698,7 @@ function unquote(raw) {
33636
33698
  }
33637
33699
  return value;
33638
33700
  }
33639
- function parseCodexToml(text6) {
33701
+ function parseCodexToml(text7) {
33640
33702
  const result = { providers: [] };
33641
33703
  const byId = /* @__PURE__ */ new Map();
33642
33704
  let section = "root";
@@ -33649,7 +33711,7 @@ function parseCodexToml(text6) {
33649
33711
  }
33650
33712
  return provider;
33651
33713
  };
33652
- for (const line of text6.split(/\r?\n/)) {
33714
+ for (const line of text7.split(/\r?\n/)) {
33653
33715
  const stripped = line.trim();
33654
33716
  if (!stripped || stripped.startsWith("#")) continue;
33655
33717
  if (stripped.startsWith("[") && stripped.endsWith("]")) {
@@ -34327,8 +34389,8 @@ function codexRetryHttpStatus(info) {
34327
34389
  function withCodexReset(message3, info) {
34328
34390
  const hint = parseResetAt(message3) === void 0 ? resetHintFromData(info) : void 0;
34329
34391
  if (!hint) return message3.slice(0, 400);
34330
- const tail2 = ` (${hint})`;
34331
- return `${message3.slice(0, 400 - tail2.length)}${tail2}`;
34392
+ const tail3 = ` (${hint})`;
34393
+ return `${message3.slice(0, 400 - tail3.length)}${tail3}`;
34332
34394
  }
34333
34395
  function missingNativeCodexThread(error51, cursor3) {
34334
34396
  return error51 instanceof CodexRpcError && error51.code === -32600 && error51.message === `no rollout found for thread id ${cursor3}`;
@@ -34910,14 +34972,14 @@ var init_codex = __esm({
34910
34972
  emit({ ...base3(threadId, turnId), type: "runtime.error", message: "codex did not shut down after termination was requested" });
34911
34973
  }
34912
34974
  };
34913
- const steerActiveTurn = async (text6) => {
34975
+ const steerActiveTurn = async (text7) => {
34914
34976
  if (state2.settled || abandoned || stopRequested || !codexThreadId || !codexTurnId) return "refused";
34915
34977
  if (child.exitCode !== null || child.signalCode !== null) return "refused";
34916
34978
  try {
34917
34979
  const steerTimeoutMs = Math.max(1, Number(process.env.FAKE_CODEX_STEER_TIMEOUT_MS ?? 1e4) || 1e4);
34918
34980
  await request("turn/steer", {
34919
34981
  threadId: codexThreadId,
34920
- input: [{ type: "text", text: text6 }],
34982
+ input: [{ type: "text", text: text7 }],
34921
34983
  expectedTurnId: codexTurnId
34922
34984
  }, steerTimeoutMs);
34923
34985
  return "steered";
@@ -35524,9 +35586,9 @@ ${status.stderr}`)) {
35524
35586
  interruptTurn: async (threadId) => {
35525
35587
  await active.get(threadId)?.stop();
35526
35588
  },
35527
- steer: async (threadId, text6) => {
35589
+ steer: async (threadId, text7) => {
35528
35590
  const turn = active.get(threadId);
35529
- return turn?.steer ? await turn.steer(text6) : "refused";
35591
+ return turn?.steer ? await turn.steer(text7) : "refused";
35530
35592
  },
35531
35593
  respondToRequest: async (threadId, requestId, decision) => {
35532
35594
  const turn = active.get(threadId);
@@ -38713,8 +38775,8 @@ var require_utils = __commonJS({
38713
38775
  }
38714
38776
  if (bestLength < 2) return hextets.join(":");
38715
38777
  const head = hextets.slice(0, bestStart).join(":");
38716
- const tail2 = hextets.slice(bestStart + bestLength).join(":");
38717
- return head + "::" + tail2;
38778
+ const tail3 = hextets.slice(bestStart + bestLength).join(":");
38779
+ return head + "::" + tail3;
38718
38780
  }
38719
38781
  function normalizeIPv6Address(input) {
38720
38782
  const compression = input.indexOf("::");
@@ -40147,7 +40209,7 @@ var require_core = __commonJS({
40147
40209
  errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
40148
40210
  if (!errors || errors.length === 0)
40149
40211
  return "No errors";
40150
- return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text6, msg) => text6 + separator + msg);
40212
+ return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text7, msg) => text7 + separator + msg);
40151
40213
  }
40152
40214
  $dataMetaSchema(metaSchema, keywordsJsonPointers) {
40153
40215
  const rules = this.RULES.all;
@@ -44671,7 +44733,7 @@ function boundedText(value) {
44671
44733
  [MCP result truncated at 50KB; request less output.]`;
44672
44734
  }
44673
44735
  function namesBlockedPath(args, roots, home = homedir17()) {
44674
- const slash = (text6) => text6.replaceAll("\\", "/").toLowerCase();
44736
+ const slash = (text7) => text7.replaceAll("\\", "/").toLowerCase();
44675
44737
  const needles = roots.flatMap((root) => {
44676
44738
  const full = slash(root).replace(/\/+$/, "");
44677
44739
  const base3 = slash(home).replace(/\/+$/, "");
@@ -45103,6 +45165,17 @@ var init_chat_tool_approval = __esm({
45103
45165
  function object3(value) {
45104
45166
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
45105
45167
  }
45168
+ function providerError(json2) {
45169
+ if (typeof json2.error === "string") return json2.error;
45170
+ const error51 = object3(json2.error);
45171
+ if (error51) return typeof error51.message === "string" ? error51.message : "unknown error";
45172
+ const code = json2.base_resp?.status_code;
45173
+ if (typeof code === "number" && code !== 0) {
45174
+ const msg = typeof json2.base_resp?.status_msg === "string" ? json2.base_resp.status_msg : "";
45175
+ return `upstream error ${code}${msg ? `: ${msg}` : ""}`;
45176
+ }
45177
+ return null;
45178
+ }
45106
45179
  var MAX_CHAT_TOOL_CALLS, MAX_ARGUMENT_CHARS, ChatProtocolError, ChatReasoningDetails, ChatToolCalls;
45107
45180
  var init_openai_chat_protocol = __esm({
45108
45181
  "server/drivers/openai-chat-protocol.ts"() {
@@ -45182,18 +45255,49 @@ var init_openai_chat_protocol = __esm({
45182
45255
  }
45183
45256
  });
45184
45257
 
45185
- // server/drivers/openai-chat.ts
45186
- function providerError(json2) {
45187
- if (typeof json2.error === "string") return json2.error;
45188
- const error51 = object3(json2.error);
45189
- if (error51) return typeof error51.message === "string" ? error51.message : "unknown error";
45190
- const code = json2.base_resp?.status_code;
45191
- if (typeof code === "number" && code !== 0) {
45192
- const msg = typeof json2.base_resp?.status_msg === "string" ? json2.base_resp.status_msg : "";
45193
- return `upstream error ${code}${msg ? `: ${msg}` : ""}`;
45194
- }
45195
- return null;
45258
+ // server/drivers/chat-text-only.ts
45259
+ function hasImageParts(messages) {
45260
+ return messages.some((message3) => Array.isArray(message3.content) && message3.content.some((part) => part.type === "image_url"));
45261
+ }
45262
+ function isImagePartRefusal(status, body) {
45263
+ return (status === 400 || status === 415 || status === 422) && REFUSALS.some((pattern) => pattern.test(body.slice(0, 4e3)));
45264
+ }
45265
+ function withoutImages(messages) {
45266
+ return messages.map((message3) => {
45267
+ if (!Array.isArray(message3.content) || !message3.content.some((part) => part.type === "image_url")) return message3;
45268
+ const text7 = message3.content.map((part) => part.type === "text" ? part.text : IMAGE_OMITTED_NOTE).join("\n");
45269
+ return { ...message3, content: text7 };
45270
+ });
45271
+ }
45272
+ function sendableMessages(apiUrl, model, messages) {
45273
+ return textOnly.has(keyOf(apiUrl, model)) && hasImageParts(messages) ? withoutImages(messages) : messages;
45196
45274
  }
45275
+ function learnTextOnly(apiUrl, model, status, body, sent) {
45276
+ if (!hasImageParts(sent) || !isImagePartRefusal(status, body)) return false;
45277
+ textOnly.add(keyOf(apiUrl, model));
45278
+ return true;
45279
+ }
45280
+ var IMAGE_OMITTED_NOTE, REFUSALS, textOnly, keyOf;
45281
+ var init_chat_text_only = __esm({
45282
+ "server/drivers/chat-text-only.ts"() {
45283
+ "use strict";
45284
+ IMAGE_OMITTED_NOTE = "[Image omitted: this model reads text only, so it cannot see the image.]";
45285
+ REFUSALS = [
45286
+ // Z.ai (GLM-5.3, 2026-11)
45287
+ /content\.type\b[^\n]{0,80}\ballowed values?\s*:\s*\[\s*['"]text['"]\s*\]/i,
45288
+ // OpenAI: "Invalid content type. image_url is only supported by certain models."
45289
+ /\bimage_url\b[^\n]{0,80}\b(?:only supported|not supported|unsupported)\b/i,
45290
+ // llama.cpp, vLLM, Mistral and others, in their several wordings
45291
+ /\b(?:does not|doesn't|do not|cannot|can't) (?:support|accept|process|handle) (?:image inputs?|images|vision|multimodal)\b/i,
45292
+ /\b(?:image|vision|multimodal) (?:input|inputs|content) (?:is|are) not supported\b/i
45293
+ ];
45294
+ textOnly = /* @__PURE__ */ new Set();
45295
+ keyOf = (apiUrl, model) => `${apiUrl}
45296
+ ${model}`;
45297
+ }
45298
+ });
45299
+
45300
+ // server/drivers/openai-chat.ts
45197
45301
  function createOpenAIChatRuntime(options) {
45198
45302
  const { input } = options;
45199
45303
  const listeners = /* @__PURE__ */ new Set();
@@ -45220,18 +45324,20 @@ function createOpenAIChatRuntime(options) {
45220
45324
  resetIdleTimer();
45221
45325
  try {
45222
45326
  const activeSignal = signal ? AbortSignal.any([signal, timeoutController.signal]) : timeoutController.signal;
45327
+ const sendable = sendableMessages(options.apiUrl, model, messages);
45223
45328
  const response = await fetch(`${options.apiUrl}/chat/completions`, {
45224
45329
  method: "POST",
45225
- ...messages.some((message3) => Array.isArray(message3.content) && message3.content.some((part) => part.type === "image_url")) ? { redirect: "error" } : {},
45330
+ ...hasImageParts(sendable) ? { redirect: "error" } : {},
45226
45331
  headers: { ...options.extraHeaders, authorization: `Bearer ${options.apiKey}`, "content-type": "application/json" },
45227
45332
  body: JSON.stringify({
45228
- ...options.requestBody(model, messages, stream),
45333
+ ...options.requestBody(model, sendable, stream),
45229
45334
  ...tools.length ? { tools } : {}
45230
45335
  }),
45231
45336
  signal: activeSignal
45232
45337
  });
45233
45338
  if (!response.ok) {
45234
45339
  const body = await response.text().catch(() => "");
45340
+ if (learnTextOnly(options.apiUrl, model, response.status, body, sendable)) return await complete(messages, model, stream, signal, onDelta, tools, onIdentity);
45235
45341
  throw new Error(`${options.httpErrorLabel} HTTP ${response.status}${body ? `: ${body.slice(0, 200)}` : ""}`);
45236
45342
  }
45237
45343
  if (!stream || response.headers.get("content-type")?.includes("application/json")) {
@@ -45264,7 +45370,7 @@ function createOpenAIChatRuntime(options) {
45264
45370
  if (!response.body) {
45265
45371
  throw new Error(options.noBodyError ?? `${options.httpErrorLabel} returned no response body`);
45266
45372
  }
45267
- let text6 = "";
45373
+ let text7 = "";
45268
45374
  let reasoning = "";
45269
45375
  let protocolReasoning = "";
45270
45376
  let usage = null;
@@ -45306,7 +45412,7 @@ function createOpenAIChatRuntime(options) {
45306
45412
  onDelta?.(reasoningDelta, "reasoning_text");
45307
45413
  }
45308
45414
  if (contentDelta) {
45309
- text6 += contentDelta;
45415
+ text7 += contentDelta;
45310
45416
  onDelta?.(contentDelta, "assistant_text");
45311
45417
  }
45312
45418
  if (chunk.usage) usage = usageFrom(chunk.usage);
@@ -45348,7 +45454,7 @@ function createOpenAIChatRuntime(options) {
45348
45454
  }
45349
45455
  activeSignal.throwIfAborted();
45350
45456
  if (!sawChoice) throw new ChatProtocolError("provider returned no streaming completion choice");
45351
- return { text: text6, reasoning, usage, toolCalls: calls.finish(finishReason, malformedFrame), finishReason, protocolReasoning, protocolReasoningDetails: details.blocks };
45457
+ return { text: text7, reasoning, usage, toolCalls: calls.finish(finishReason, malformedFrame), finishReason, protocolReasoning, protocolReasoningDetails: details.blocks };
45352
45458
  } finally {
45353
45459
  if (idleTimer) clearTimeout(idleTimer);
45354
45460
  }
@@ -45381,8 +45487,8 @@ function createOpenAIChatRuntime(options) {
45381
45487
  }
45382
45488
  }
45383
45489
  }
45384
- const safeText = (text6) => {
45385
- let safe = text6;
45490
+ const safeText = (text7) => {
45491
+ let safe = text7;
45386
45492
  for (const secret of secrets) if (secret) safe = safe.split(secret).join("[redacted]");
45387
45493
  return redactSecretsInText(safe);
45388
45494
  };
@@ -45439,8 +45545,8 @@ function createOpenAIChatRuntime(options) {
45439
45545
  for (; ; ) {
45440
45546
  let streamed = false;
45441
45547
  const pending = { assistant_text: "", reasoning_text: "" };
45442
- const delta = (text6, streamKind, flush = false) => {
45443
- let combined = pending[streamKind] + text6;
45548
+ const delta = (text7, streamKind, flush = false) => {
45549
+ let combined = pending[streamKind] + text7;
45444
45550
  for (const secret of secrets) if (secret) combined = combined.split(secret).join("[redacted]");
45445
45551
  let hold = 0;
45446
45552
  if (!flush) for (const secret of secrets) {
@@ -45459,9 +45565,9 @@ function createOpenAIChatRuntime(options) {
45459
45565
  const callId = newId();
45460
45566
  emit({ ...base3(turn.threadId, turnId), type: "model.call", callId });
45461
45567
  let previousIdentity = "";
45462
- completion = await complete(messages, model, true, abort.signal, (text6, streamKind) => {
45568
+ completion = await complete(messages, model, true, abort.signal, (text7, streamKind) => {
45463
45569
  streamed = true;
45464
- delta(text6, streamKind);
45570
+ delta(text7, streamKind);
45465
45571
  }, tools.definitions, (reportedModel, responseId) => {
45466
45572
  const identity2 = JSON.stringify([reportedModel, responseId]);
45467
45573
  if (identity2 === previousIdentity) return;
@@ -45562,11 +45668,11 @@ function createOpenAIChatRuntime(options) {
45562
45668
  result = { ok: false, text: abort.signal.aborted ? "Tool interrupted; an operation already dispatched may have taken effect. Verify its state before retrying." : safeText(asError(error51).message).slice(0, 2e3) };
45563
45669
  }
45564
45670
  if (!started) emit({ ...base3(turn.threadId, turnId), type: "item.started", itemType: "tool", itemId: call.id, title: call.function.name });
45565
- const text6 = safeText(result.text);
45566
- const output = preview({ ok: result.ok, result: text6 });
45671
+ const text7 = safeText(result.text);
45672
+ const output = preview({ ok: result.ok, result: text7 });
45567
45673
  emit({ ...base3(turn.threadId, turnId), type: "item.completed", itemType: "tool", itemId: call.id, ok: result.ok, output });
45568
45674
  if (!result.ok) toolFailed = true;
45569
- messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ ok: result.ok, result: text6 }) });
45675
+ messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ ok: result.ok, result: text7 }) });
45570
45676
  screenshotParts.push(...chatToolImages(call.id, result.images));
45571
45677
  abort.signal.throwIfAborted();
45572
45678
  if (fatal) throw fatal;
@@ -45658,9 +45764,9 @@ function createOpenAIChatRuntime(options) {
45658
45764
  },
45659
45765
  generateText: async (prompt, { signal } = {}) => {
45660
45766
  const model = options.generateModel?.() ?? options.models().default;
45661
- const { text: text6, reasoning, toolCalls } = await complete([{ role: "user", content: prompt }], model, false, signal);
45767
+ const { text: text7, reasoning, toolCalls } = await complete([{ role: "user", content: prompt }], model, false, signal);
45662
45768
  if (toolCalls.length) throw new ChatProtocolError("provider returned tool calls to a text-only helper");
45663
- return text6.trim() ? text6 : reasoning;
45769
+ return text7.trim() ? text7 : reasoning;
45664
45770
  },
45665
45771
  dispose: async () => {
45666
45772
  const turns = [...active.values()];
@@ -45682,6 +45788,7 @@ var init_openai_chat = __esm({
45682
45788
  init_chat_images();
45683
45789
  init_chat_tool_approval();
45684
45790
  init_openai_chat_protocol();
45791
+ init_chat_text_only();
45685
45792
  init_native();
45686
45793
  init_retry();
45687
45794
  usageFrom = (usage) => usage ? { input: usage.prompt_tokens ?? 0, output: usage.completion_tokens ?? 0 } : null;
@@ -45741,7 +45848,7 @@ var init_grok = __esm({
45741
45848
  nativeLog: {
45742
45849
  source: "xai.chat.completions",
45743
45850
  outgoing: (_turn, messages, model) => ({ model, messages }),
45744
- incoming: ({ text: text6, usage }) => ({ text: text6, usage })
45851
+ incoming: ({ text: text7, usage }) => ({ text: text7, usage })
45745
45852
  }
45746
45853
  });
45747
45854
  }
@@ -45753,12 +45860,12 @@ var init_grok = __esm({
45753
45860
  import { existsSync as existsSync17, readFileSync as readFileSync20, writeFileSync as writeFileSync13 } from "node:fs";
45754
45861
  import { homedir as homedir18 } from "node:os";
45755
45862
  import { join as join39 } from "node:path";
45756
- function decodeGrokModelText(text6) {
45757
- if (/\bnot authenticated\b/i.test(text6)) return null;
45863
+ function decodeGrokModelText(text7) {
45864
+ if (/\bnot authenticated\b/i.test(text7)) return null;
45758
45865
  const options = [];
45759
45866
  let listed = null;
45760
45867
  let stated = null;
45761
- for (const raw of text6.split(/\r?\n/)) {
45868
+ for (const raw of text7.split(/\r?\n/)) {
45762
45869
  const line = raw.trim();
45763
45870
  const header = /^default model:\s*(\S+)/i.exec(line);
45764
45871
  if (header) {
@@ -45797,9 +45904,9 @@ function unquote2(raw) {
45797
45904
  }
45798
45905
  function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
45799
45906
  const path4 = join39(grokHome(env), "config.toml");
45800
- let text6 = "";
45907
+ let text7 = "";
45801
45908
  try {
45802
- text6 = readFileSync20(path4, "utf8");
45909
+ text7 = readFileSync20(path4, "utf8");
45803
45910
  } catch {
45804
45911
  return base3;
45805
45912
  }
@@ -45817,7 +45924,7 @@ function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
45817
45924
  options.push({ id: current.slug, label: current.name || current.slug, custom: true });
45818
45925
  current = null;
45819
45926
  };
45820
- for (const line of text6.split(/\r?\n/)) {
45927
+ for (const line of text7.split(/\r?\n/)) {
45821
45928
  const stripped = line.trim();
45822
45929
  if (stripped === "[models]") {
45823
45930
  flush();
@@ -45853,8 +45960,8 @@ function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
45853
45960
  function classifyGrokError(error51) {
45854
45961
  const message3 = error51 instanceof Error ? error51.message : String(error51 ?? "");
45855
45962
  const data = error51 && typeof error51 === "object" ? error51.data : void 0;
45856
- const text6 = `${message3} ${typeof data === "string" ? data : data ? JSON.stringify(data) : ""}`;
45857
- return classifyEngineFailure(text6)?.kind === "usage_limited" ? "quota_or_region_restriction" : void 0;
45963
+ const text7 = `${message3} ${typeof data === "string" ? data : data ? JSON.stringify(data) : ""}`;
45964
+ return classifyEngineFailure(text7)?.kind === "usage_limited" ? "quota_or_region_restriction" : void 0;
45858
45965
  }
45859
45966
  function suggestGrokSlug(host, model, taken) {
45860
45967
  let base3 = `${host}-${model}`.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
@@ -45876,11 +45983,11 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
45876
45983
  const host = localHost(inject.host);
45877
45984
  if (!host) return modelId;
45878
45985
  const path4 = join39(grokHome(env), "config.toml");
45879
- let text6 = "";
45986
+ let text7 = "";
45880
45987
  try {
45881
- text6 = readFileSync20(path4, "utf8");
45988
+ text7 = readFileSync20(path4, "utf8");
45882
45989
  } catch {
45883
- text6 = "";
45990
+ text7 = "";
45884
45991
  }
45885
45992
  const taken = new Set(STATIC_GROK_MODELS.options.map((option) => option.id));
45886
45993
  let current = null;
@@ -45893,7 +46000,7 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
45893
46000
  current = null;
45894
46001
  };
45895
46002
  let found = null;
45896
- for (const line of text6.split(/\r?\n/)) {
46003
+ for (const line of text7.split(/\r?\n/)) {
45897
46004
  const stripped = line.trim();
45898
46005
  if (stripped.startsWith("[model.") && stripped.endsWith("]")) {
45899
46006
  flush();
@@ -45926,9 +46033,9 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
45926
46033
  `api_key = ${quoteToml(hostApiKey(host, env))}`,
45927
46034
  ""
45928
46035
  ].join("\n");
45929
- const next = text6 && !text6.endsWith("\n") ? `${text6}
46036
+ const next = text7 && !text7.endsWith("\n") ? `${text7}
45930
46037
 
45931
- ${block2}` : `${text6}${text6 ? "\n" : ""}${block2}`;
46038
+ ${block2}` : `${text7}${text7 ? "\n" : ""}${block2}`;
45932
46039
  writeFileSync13(path4, next);
45933
46040
  return slug;
45934
46041
  }
@@ -46115,18 +46222,69 @@ ${turn.text}` : turn.text
46115
46222
  }
46116
46223
  });
46117
46224
 
46225
+ // server/drivers/acp/kimi-turn-failure.ts
46226
+ import { closeSync as closeSync6, existsSync as existsSync19, fstatSync as fstatSync2, openSync as openSync6, readdirSync as readdirSync7, readSync as readSync3 } from "node:fs";
46227
+ import { join as join41 } from "node:path";
46228
+ function tail2(path4) {
46229
+ const file2 = openSync6(path4, "r");
46230
+ try {
46231
+ const size = fstatSync2(file2).size;
46232
+ const buffer = Buffer.alloc(Math.min(size, TAIL_BYTES));
46233
+ readSync3(file2, buffer, 0, buffer.length, size - buffer.length);
46234
+ return buffer.toString("utf8");
46235
+ } finally {
46236
+ closeSync6(file2);
46237
+ }
46238
+ }
46239
+ function kimiTurnFailure(dataRoot, sessionId, since) {
46240
+ try {
46241
+ if (!/^[\w-]+$/.test(sessionId)) return void 0;
46242
+ const sessions = join41(dataRoot, "sessions");
46243
+ const log = readdirSync7(sessions).map((workdir) => join41(sessions, workdir, sessionId, "logs", "kimi-code.log")).find((path4) => existsSync19(path4));
46244
+ if (!log) return void 0;
46245
+ const lines = tail2(log).split(/\r?\n/);
46246
+ for (let index = lines.length - 1; index >= 0; index--) {
46247
+ const record6 = FAILED_TURN.exec(lines[index]);
46248
+ if (!record6) continue;
46249
+ if (!(Date.parse(record6[1]) >= since)) return void 0;
46250
+ const error51 = JSON.parse(JSON.parse(record6[2]));
46251
+ const message3 = typeof error51.message === "string" ? error51.message.trim() : "";
46252
+ return message3 ? redactSecretsInText(message3).slice(0, 600) : void 0;
46253
+ }
46254
+ } catch {
46255
+ }
46256
+ return void 0;
46257
+ }
46258
+ async function awaitKimiTurnFailure(dataRoot, sessionId, since, waitMs = 1500) {
46259
+ const deadline = Date.now() + waitMs;
46260
+ for (; ; ) {
46261
+ const message3 = kimiTurnFailure(dataRoot, sessionId, since);
46262
+ if (message3 || Date.now() >= deadline) return message3;
46263
+ await new Promise((resolve14) => setTimeout(resolve14, 100));
46264
+ }
46265
+ }
46266
+ var FAILED_TURN, TAIL_BYTES;
46267
+ var init_kimi_turn_failure = __esm({
46268
+ "server/drivers/acp/kimi-turn-failure.ts"() {
46269
+ "use strict";
46270
+ init_redact2();
46271
+ FAILED_TURN = /^(\S+)\s+\w+\s+acp: turn ended with failed reason\s+error=("(?:[^"\\]|\\.)*")/;
46272
+ TAIL_BYTES = 256 * 1024;
46273
+ }
46274
+ });
46275
+
46118
46276
  // server/drivers/acp/kimi.ts
46119
- import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
46277
+ import { existsSync as existsSync20, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
46120
46278
  import { homedir as homedir20 } from "node:os";
46121
- import { join as join41 } from "node:path";
46279
+ import { join as join42 } from "node:path";
46122
46280
  function isLocalInjectAlias(slug) {
46123
46281
  return LOCAL_PROVIDER_PREFIXES.some((prefix) => slug.startsWith(prefix));
46124
46282
  }
46125
46283
  function kimiDataRoot(env) {
46126
- return env.KIMI_CODE_HOME || join41(env.HOME || env.USERPROFILE || homedir20(), ".kimi-code");
46284
+ return env.KIMI_CODE_HOME || join42(env.HOME || env.USERPROFILE || homedir20(), ".kimi-code");
46127
46285
  }
46128
46286
  function credentialsPath(env) {
46129
- return join41(kimiDataRoot(env), "credentials", "kimi-code.json");
46287
+ return join42(kimiDataRoot(env), "credentials", "kimi-code.json");
46130
46288
  }
46131
46289
  function quoteToml2(value) {
46132
46290
  return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
@@ -46152,18 +46310,18 @@ function stripTomlLineComment(line) {
46152
46310
  }
46153
46311
  return line;
46154
46312
  }
46155
- function takeTomlBasicEscape(text6, i2) {
46156
- const code = text6[i2 + 1];
46313
+ function takeTomlBasicEscape(text7, i2) {
46314
+ const code = text7[i2 + 1];
46157
46315
  if (code === void 0) return { ok: false };
46158
46316
  if (code === "u") {
46159
- const hex3 = text6.slice(i2 + 2, i2 + 6);
46317
+ const hex3 = text7.slice(i2 + 2, i2 + 6);
46160
46318
  if (!/^[0-9a-fA-F]{4}$/.test(hex3)) return { ok: false };
46161
46319
  const point = parseInt(hex3, 16);
46162
46320
  if (point >= 55296 && point <= 57343) return { ok: false };
46163
46321
  return { ok: true, value: String.fromCharCode(point), next: i2 + 6 };
46164
46322
  }
46165
46323
  if (code === "U") {
46166
- const hex3 = text6.slice(i2 + 2, i2 + 10);
46324
+ const hex3 = text7.slice(i2 + 2, i2 + 10);
46167
46325
  if (!/^[0-9a-fA-F]{8}$/.test(hex3)) return { ok: false };
46168
46326
  const point = parseInt(hex3, 16);
46169
46327
  if (point > 1114111 || point >= 55296 && point <= 57343) return { ok: false };
@@ -46235,14 +46393,14 @@ function tomlRowKey(row) {
46235
46393
  const eq = row.indexOf("=");
46236
46394
  return unquoteTomlKey(eq < 0 ? row : row.slice(0, eq));
46237
46395
  }
46238
- function tomlTables(text6) {
46396
+ function tomlTables(text7) {
46239
46397
  const headings = [];
46240
46398
  let mode = "out";
46241
46399
  let i2 = 0;
46242
- const atLineStart = (idx) => idx === 0 || text6[idx - 1] === "\n";
46243
- while (i2 < text6.length) {
46400
+ const atLineStart = (idx) => idx === 0 || text7[idx - 1] === "\n";
46401
+ while (i2 < text7.length) {
46244
46402
  if (mode === "mlbasic") {
46245
- if (text6.startsWith('"""', i2)) {
46403
+ if (text7.startsWith('"""', i2)) {
46246
46404
  mode = "out";
46247
46405
  i2 += 3;
46248
46406
  continue;
@@ -46251,7 +46409,7 @@ function tomlTables(text6) {
46251
46409
  continue;
46252
46410
  }
46253
46411
  if (mode === "mllit") {
46254
- if (text6.startsWith("'''", i2)) {
46412
+ if (text7.startsWith("'''", i2)) {
46255
46413
  mode = "out";
46256
46414
  i2 += 3;
46257
46415
  continue;
@@ -46260,61 +46418,61 @@ function tomlTables(text6) {
46260
46418
  continue;
46261
46419
  }
46262
46420
  if (mode === "basic") {
46263
- if (text6[i2] === "\n") {
46421
+ if (text7[i2] === "\n") {
46264
46422
  mode = "out";
46265
46423
  i2 += 1;
46266
46424
  continue;
46267
46425
  }
46268
- if (text6[i2] === "\\") {
46426
+ if (text7[i2] === "\\") {
46269
46427
  i2 += 2;
46270
46428
  continue;
46271
46429
  }
46272
- if (text6[i2] === '"') mode = "out";
46430
+ if (text7[i2] === '"') mode = "out";
46273
46431
  i2 += 1;
46274
46432
  continue;
46275
46433
  }
46276
46434
  if (mode === "literal") {
46277
- if (text6[i2] === "\n") {
46435
+ if (text7[i2] === "\n") {
46278
46436
  mode = "out";
46279
46437
  i2 += 1;
46280
46438
  continue;
46281
46439
  }
46282
- if (text6[i2] === "'") mode = "out";
46440
+ if (text7[i2] === "'") mode = "out";
46283
46441
  i2 += 1;
46284
46442
  continue;
46285
46443
  }
46286
- if (text6.startsWith('"""', i2)) {
46444
+ if (text7.startsWith('"""', i2)) {
46287
46445
  mode = "mlbasic";
46288
46446
  i2 += 3;
46289
46447
  continue;
46290
46448
  }
46291
- if (text6.startsWith("'''", i2)) {
46449
+ if (text7.startsWith("'''", i2)) {
46292
46450
  mode = "mllit";
46293
46451
  i2 += 3;
46294
46452
  continue;
46295
46453
  }
46296
- if (text6[i2] === '"') {
46454
+ if (text7[i2] === '"') {
46297
46455
  mode = "basic";
46298
46456
  i2 += 1;
46299
46457
  continue;
46300
46458
  }
46301
- if (text6[i2] === "'") {
46459
+ if (text7[i2] === "'") {
46302
46460
  mode = "literal";
46303
46461
  i2 += 1;
46304
46462
  continue;
46305
46463
  }
46306
- if (text6[i2] === "#") {
46307
- const nl = text6.indexOf("\n", i2);
46308
- i2 = nl < 0 ? text6.length : nl + 1;
46464
+ if (text7[i2] === "#") {
46465
+ const nl = text7.indexOf("\n", i2);
46466
+ i2 = nl < 0 ? text7.length : nl + 1;
46309
46467
  continue;
46310
46468
  }
46311
46469
  if (atLineStart(i2)) {
46312
46470
  let j2 = i2;
46313
- while (j2 < text6.length && (text6[j2] === " " || text6[j2] === " ")) j2 += 1;
46314
- if (text6[j2] === "[") {
46315
- const nl = text6.indexOf("\n", j2);
46316
- const lineEnd = nl < 0 ? text6.length : nl;
46317
- const raw = text6.slice(j2, lineEnd).replace(/\r$/, "");
46471
+ while (j2 < text7.length && (text7[j2] === " " || text7[j2] === " ")) j2 += 1;
46472
+ if (text7[j2] === "[") {
46473
+ const nl = text7.indexOf("\n", j2);
46474
+ const lineEnd = nl < 0 ? text7.length : nl;
46475
+ const raw = text7.slice(j2, lineEnd).replace(/\r$/, "");
46318
46476
  const stripped = stripTomlLineComment(raw).trim();
46319
46477
  const array2 = stripped.startsWith("[[");
46320
46478
  const name = array2 ? canonicalizeTomlHeading(`[${stripped.replace(/^\s*\[\[/, "").replace(/\]\]\s*$/, "")}]`) : canonicalizeTomlHeading(raw);
@@ -46327,11 +46485,11 @@ function tomlTables(text6) {
46327
46485
  }
46328
46486
  return headings.map((heading, index) => ({
46329
46487
  heading,
46330
- end: index + 1 < headings.length ? headings[index + 1].lineStart : text6.length
46488
+ end: index + 1 < headings.length ? headings[index + 1].lineStart : text7.length
46331
46489
  })).filter((entry) => entry.heading.patchable && entry.heading.name).map((entry) => ({
46332
46490
  name: entry.heading.name,
46333
46491
  headingStart: entry.heading.lineStart,
46334
- bodyStart: entry.heading.lineEnd + (text6[entry.heading.lineEnd] === "\n" ? 1 : 0),
46492
+ bodyStart: entry.heading.lineEnd + (text7[entry.heading.lineEnd] === "\n" ? 1 : 0),
46335
46493
  end: entry.end
46336
46494
  }));
46337
46495
  }
@@ -46387,22 +46545,22 @@ function tomlKeys(block2) {
46387
46545
  take(block2.length);
46388
46546
  return keys;
46389
46547
  }
46390
- function hasTomlTable(text6, heading) {
46548
+ function hasTomlTable(text7, heading) {
46391
46549
  const name = canonicalizeTomlHeading(heading);
46392
- return name !== null && tomlTables(text6).some((table) => table.name === name);
46550
+ return name !== null && tomlTables(text7).some((table) => table.name === name);
46393
46551
  }
46394
- function patchTomlTable(text6, heading, rows) {
46552
+ function patchTomlTable(text7, heading, rows) {
46395
46553
  const name = canonicalizeTomlHeading(heading);
46396
- if (!name) return text6;
46397
- const table = tomlTables(text6).find((entry) => entry.name === name);
46398
- if (!table) return text6;
46399
- const keys = tomlKeys(text6.slice(table.bodyStart, table.end));
46554
+ if (!name) return text7;
46555
+ const table = tomlTables(text7).find((entry) => entry.name === name);
46556
+ if (!table) return text7;
46557
+ const keys = tomlKeys(text7.slice(table.bodyStart, table.end));
46400
46558
  const missing = rows.filter((row) => !keys.has(tomlRowKey(row)));
46401
- if (!missing.length) return text6;
46559
+ if (!missing.length) return text7;
46402
46560
  let insertAt = table.end;
46403
- while (insertAt > table.bodyStart && (text6[insertAt - 1] === "\n" || text6[insertAt - 1] === "\r")) insertAt -= 1;
46404
- const before = text6.slice(0, insertAt);
46405
- const after = text6.slice(insertAt);
46561
+ while (insertAt > table.bodyStart && (text7[insertAt - 1] === "\n" || text7[insertAt - 1] === "\r")) insertAt -= 1;
46562
+ const before = text7.slice(0, insertAt);
46563
+ const after = text7.slice(insertAt);
46406
46564
  const pad = before.endsWith("\n") || before.length === 0 ? "" : "\n";
46407
46565
  return `${before}${pad}${missing.join("\n")}${after.startsWith("\n") ? "" : "\n"}${after}`;
46408
46566
  }
@@ -46414,18 +46572,18 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
46414
46572
  const alias = `${inject.host}/${inject.model.replace(/\//g, "-")}`;
46415
46573
  const dataRoot = kimiDataRoot(env);
46416
46574
  mkdirSync18(dataRoot, { recursive: true });
46417
- const path4 = join41(dataRoot, "config.toml");
46418
- let text6 = "";
46575
+ const path4 = join42(dataRoot, "config.toml");
46576
+ let text7 = "";
46419
46577
  try {
46420
- text6 = readFileSync22(path4, "utf8");
46578
+ text7 = readFileSync22(path4, "utf8");
46421
46579
  } catch {
46422
- text6 = "";
46580
+ text7 = "";
46423
46581
  }
46424
- const original = text6;
46582
+ const original = text7;
46425
46583
  const providerHeading = `[providers.${inject.host}]`;
46426
46584
  const modelHeading = `[models.${quoteTomlKey(alias)}]`;
46427
46585
  const blocks = [];
46428
- if (!hasTomlTable(text6, providerHeading)) {
46586
+ if (!hasTomlTable(text7, providerHeading)) {
46429
46587
  blocks.push(
46430
46588
  [
46431
46589
  providerHeading,
@@ -46436,8 +46594,8 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
46436
46594
  ].join("\n")
46437
46595
  );
46438
46596
  }
46439
- if (hasTomlTable(text6, modelHeading)) {
46440
- text6 = patchTomlTable(text6, modelHeading, [`protocol = "openai"`, `max_context_size = 262144`]);
46597
+ if (hasTomlTable(text7, modelHeading)) {
46598
+ text7 = patchTomlTable(text7, modelHeading, [`protocol = "openai"`, `max_context_size = 262144`]);
46441
46599
  } else {
46442
46600
  blocks.push(
46443
46601
  [
@@ -46451,13 +46609,13 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
46451
46609
  );
46452
46610
  }
46453
46611
  if (blocks.length) {
46454
- const prefix = text6 && !text6.endsWith("\n") ? `${text6}
46612
+ const prefix = text7 && !text7.endsWith("\n") ? `${text7}
46455
46613
 
46456
- ` : text6 ? `${text6}
46614
+ ` : text7 ? `${text7}
46457
46615
  ` : "";
46458
46616
  writeFileSync14(path4, `${prefix}${blocks.join("\n")}`);
46459
- } else if (text6 !== original) {
46460
- writeFileSync14(path4, text6);
46617
+ } else if (text7 !== original) {
46618
+ writeFileSync14(path4, text7);
46461
46619
  }
46462
46620
  return alias;
46463
46621
  }
@@ -46477,9 +46635,9 @@ function stripKimiModelEnv(env) {
46477
46635
  }
46478
46636
  function readKimiModelCatalog(env) {
46479
46637
  const dataRoot = kimiDataRoot(env);
46480
- let text6 = "";
46638
+ let text7 = "";
46481
46639
  try {
46482
- text6 = readFileSync22(join41(dataRoot, "config.toml"), "utf8");
46640
+ text7 = readFileSync22(join42(dataRoot, "config.toml"), "utf8");
46483
46641
  } catch {
46484
46642
  return STATIC_KIMI_MODELS;
46485
46643
  }
@@ -46495,7 +46653,7 @@ function readKimiModelCatalog(env) {
46495
46653
  options.push({ id: current.slug, label: current.name || current.slug, custom: true });
46496
46654
  current = null;
46497
46655
  };
46498
- for (const line of text6.split(/\r?\n/)) {
46656
+ for (const line of text7.split(/\r?\n/)) {
46499
46657
  const stripped = line.trim();
46500
46658
  if ((stripped.startsWith("[model.") || stripped.startsWith("[models.")) && stripped.endsWith("]")) {
46501
46659
  flush();
@@ -46527,6 +46685,7 @@ var init_kimi = __esm({
46527
46685
  "use strict";
46528
46686
  init_local_inject();
46529
46687
  init_core3();
46688
+ init_kimi_turn_failure();
46530
46689
  STATIC_KIMI_MODELS = {
46531
46690
  default: "kimi-code/k3",
46532
46691
  options: [
@@ -46597,7 +46756,7 @@ var init_kimi = __esm({
46597
46756
  authFailure: "continue",
46598
46757
  // Match the child CLI's own data-root precedence. A custom instance HOME or
46599
46758
  // KIMI_CODE_HOME must not be checked against the server user's home instead.
46600
- isAuthenticated: (env) => existsSync19(credentialsPath(env)),
46759
+ isAuthenticated: (env) => existsSync20(credentialsPath(env)),
46601
46760
  // Full rides Kimi's ACP session mode, not argv. `kimi acp` builds its
46602
46761
  // harness without the global -y/--yolo and --auto flags and starts every
46603
46762
  // ACP session in mode "default" (verified against kimi-code 0.28.1), so
@@ -46620,19 +46779,25 @@ var init_kimi = __esm({
46620
46779
  },
46621
46780
  buildPromptText: (turn) => turn.system ? `${turn.system}
46622
46781
 
46623
- ${turn.text}` : turn.text
46782
+ ${turn.text}` : turn.text,
46783
+ // Kimi answers end_turn with nothing when its provider refused the turn
46784
+ // (a 403 for a plan without Kimi Code access): the reason is in its log.
46785
+ explainEmptyTurn: async ({ sessionId, since, env }) => {
46786
+ const message3 = await awaitKimiTurnFailure(kimiDataRoot(env), sessionId, since);
46787
+ return message3 ? `Kimi: ${message3}` : void 0;
46788
+ }
46624
46789
  };
46625
46790
  KimiAgentDriver = createAcpDriver(support4);
46626
46791
  }
46627
46792
  });
46628
46793
 
46629
46794
  // server/drivers/acp/droid.ts
46630
- import { existsSync as existsSync20, mkdirSync as mkdirSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync15 } from "node:fs";
46795
+ import { existsSync as existsSync21, mkdirSync as mkdirSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync15 } from "node:fs";
46631
46796
  import { homedir as homedir21 } from "node:os";
46632
- import { join as join42 } from "node:path";
46797
+ import { join as join43 } from "node:path";
46633
46798
  function authFilePaths(env) {
46634
46799
  const home = env.FACTORY_HOME_OVERRIDE || env.HOME || homedir21();
46635
- return AUTH_FILES.map((name) => join42(home, ".factory", name));
46800
+ return AUTH_FILES.map((name) => join43(home, ".factory", name));
46636
46801
  }
46637
46802
  function droidInjectId(host, model) {
46638
46803
  const safe = `${host}-${model}`.replace(/[^a-zA-Z0-9._+-]+/g, "-").replace(/-+/g, "-");
@@ -46647,14 +46812,14 @@ function ensureDroidInjectModel(modelId, env = process.env) {
46647
46812
  const host = localHost(inject.host);
46648
46813
  if (!host) return modelId;
46649
46814
  const id = droidInjectId(inject.host, inject.model);
46650
- const dir = join42(factoryHome(env), ".factory");
46815
+ const dir = join43(factoryHome(env), ".factory");
46651
46816
  mkdirSync19(dir, { recursive: true });
46652
- const path4 = join42(dir, "settings.json");
46817
+ const path4 = join43(dir, "settings.json");
46653
46818
  let settings2 = {};
46654
46819
  try {
46655
46820
  settings2 = JSON.parse(readFileSync23(path4, "utf8"));
46656
46821
  } catch (error51) {
46657
- if (existsSync20(path4)) throw error51;
46822
+ if (existsSync21(path4)) throw error51;
46658
46823
  }
46659
46824
  const custom2 = Array.isArray(settings2.customModels) ? [...settings2.customModels] : [];
46660
46825
  const match = custom2.find(
@@ -46685,11 +46850,11 @@ function ensureDroidInjectModel(modelId, env = process.env) {
46685
46850
  function applyDroidLocalAuthEnv(env, modelId) {
46686
46851
  if (!decodeInjectId(modelId)) return;
46687
46852
  if (env.FACTORY_API_KEY?.trim()) return;
46688
- if (authFilePaths(env).some(existsSync20)) return;
46853
+ if (authFilePaths(env).some(existsSync21)) return;
46689
46854
  env.FACTORY_API_KEY = "openmausbot-local";
46690
46855
  }
46691
46856
  function readSettings(env) {
46692
- return JSON.parse(readFileSync23(join42(factoryHome(env), ".factory", "settings.json"), "utf8"));
46857
+ return JSON.parse(readFileSync23(join43(factoryHome(env), ".factory", "settings.json"), "utf8"));
46693
46858
  }
46694
46859
  async function resolveModels(env) {
46695
46860
  let catalog2 = MODELS3;
@@ -46777,7 +46942,7 @@ var init_droid = __esm({
46777
46942
  // The signed-in CLI is the primary source; FACTORY_API_KEY is the fallback
46778
46943
  // droid itself advertises, and it is checked last so an ambient key can
46779
46944
  // never be what makes an otherwise logged-out instance look ready.
46780
- isAuthenticated: (env) => authFilePaths(env).some(existsSync20) || Boolean(env.FACTORY_API_KEY),
46945
+ isAuthenticated: (env) => authFilePaths(env).some(existsSync21) || Boolean(env.FACTORY_API_KEY),
46781
46946
  resolveModels,
46782
46947
  resolveTurnModel: (model, env) => model ? ensureDroidInjectModel(model, env) : model,
46783
46948
  applyTurnEnv: (env, { requestedModel }) => {
@@ -46818,8 +46983,8 @@ function resolveCursorAcpModelId(available, wanted) {
46818
46983
  }
46819
46984
  return null;
46820
46985
  }
46821
- function firstJsonValue(text6) {
46822
- const trimmed = text6.trim();
46986
+ function firstJsonValue(text7) {
46987
+ const trimmed = text7.trim();
46823
46988
  if (!trimmed) return null;
46824
46989
  try {
46825
46990
  return JSON.parse(trimmed);
@@ -46893,12 +47058,12 @@ function stripModelMarkers(label) {
46893
47058
  }
46894
47059
  return { label: cleaned, isDefault, isCurrent };
46895
47060
  }
46896
- function decodeCursorModelText(text6) {
47061
+ function decodeCursorModelText(text7) {
46897
47062
  const options = [];
46898
47063
  const seen = /* @__PURE__ */ new Set();
46899
47064
  let markedDefault;
46900
47065
  let markedCurrent;
46901
- for (const raw of text6.split(/\r?\n/)) {
47066
+ for (const raw of text7.split(/\r?\n/)) {
46902
47067
  const line = raw.trim();
46903
47068
  if (!line || line.startsWith("#") || /^available\s+models?\b/i.test(line) || /^models?\b/i.test(line)) continue;
46904
47069
  const stripped = line.replace(/^[\s*•-]+\s*/, "");
@@ -46951,8 +47116,8 @@ function decodeCursorAuthStatus(payload) {
46951
47116
  }
46952
47117
  return null;
46953
47118
  }
46954
- function decodeCursorAuthText(text6) {
46955
- const normalized = text6.trim().toLowerCase();
47119
+ function decodeCursorAuthText(text7) {
47120
+ const normalized = text7.trim().toLowerCase();
46956
47121
  if (!normalized) return null;
46957
47122
  if (/not (?:logged|signed) in|not authenticated|unauthenticated|logged out/.test(normalized)) return false;
46958
47123
  if (/login successful|logged in|signed in|authenticated/.test(normalized)) return true;
@@ -47161,18 +47326,18 @@ import { createHash as createHash13 } from "node:crypto";
47161
47326
  function requestKey(id) {
47162
47327
  return `${typeof id === "number" ? "number" : "string"}:${String(id)}`;
47163
47328
  }
47164
- function utf8ByteLength(text6) {
47329
+ function utf8ByteLength(text7) {
47165
47330
  let bytes = 0;
47166
- for (const scalar of text6) {
47331
+ for (const scalar of text7) {
47167
47332
  const point = scalar.codePointAt(0);
47168
47333
  bytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
47169
47334
  }
47170
47335
  return bytes;
47171
47336
  }
47172
- function truncateToUtf8Bytes(text6, limitBytes) {
47337
+ function truncateToUtf8Bytes(text7, limitBytes) {
47173
47338
  let bytes = 0;
47174
47339
  let end = 0;
47175
- for (const scalar of text6) {
47340
+ for (const scalar of text7) {
47176
47341
  const point = scalar.codePointAt(0);
47177
47342
  const width = point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
47178
47343
  if (bytes + width > limitBytes)
@@ -47180,7 +47345,7 @@ function truncateToUtf8Bytes(text6, limitBytes) {
47180
47345
  bytes += width;
47181
47346
  end += scalar.length;
47182
47347
  }
47183
- return text6.slice(0, end);
47348
+ return text7.slice(0, end);
47184
47349
  }
47185
47350
  function canonical(value) {
47186
47351
  if (Array.isArray(value))
@@ -47421,10 +47586,10 @@ var init_connection = __esm({
47421
47586
  throw new ProtocolError("unreachable command retry state");
47422
47587
  }
47423
47588
  async close() {
47424
- const tail2 = this.#writeTail;
47589
+ const tail3 = this.#writeTail;
47425
47590
  if (this.#transport.close !== void 0) {
47426
47591
  await this.#transport.close(this.#submitTail);
47427
- await tail2;
47592
+ await tail3;
47428
47593
  } else {
47429
47594
  this.#finish(new ProtocolError("connection closed"));
47430
47595
  }
@@ -48576,14 +48741,14 @@ var init_muse_code_login = __esm({
48576
48741
  });
48577
48742
 
48578
48743
  // server/drivers/muse-code.ts
48579
- import { existsSync as existsSync21, mkdtempSync as mkdtempSync4, readFileSync as readFileSync24, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
48744
+ import { existsSync as existsSync22, mkdtempSync as mkdtempSync4, readFileSync as readFileSync24, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
48580
48745
  import { readFile as readFile4 } from "node:fs/promises";
48581
48746
  import { homedir as homedir22, tmpdir as tmpdir6 } from "node:os";
48582
- import { join as join43 } from "node:path";
48747
+ import { join as join44 } from "node:path";
48583
48748
  function museCredentialPath(env, platform = process.platform) {
48584
48749
  if (env.MUSE_AUTH_PATH?.trim()) return env.MUSE_AUTH_PATH.trim();
48585
48750
  const home = (platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir22();
48586
- return join43(env.XDG_CONFIG_HOME?.trim() || join43(home, ".config"), "muse", "auth.json");
48751
+ return join44(env.XDG_CONFIG_HOME?.trim() || join44(home, ".config"), "muse", "auth.json");
48587
48752
  }
48588
48753
  function museCredential(path4) {
48589
48754
  let raw;
@@ -48677,8 +48842,8 @@ function museToolStart(item) {
48677
48842
  }
48678
48843
  function museToolOutput(item) {
48679
48844
  const ok = item.status === "completed" && (item.exitCode === void 0 || item.exitCode === 0);
48680
- const text6 = item.visibleOutput ?? item.result?.summary ?? item.text ?? item.summary?.join("\n") ?? item.fallbackText ?? "";
48681
- const output = [item.status !== "completed" ? item.failureReason || `Muse reported ${item.status}.` : "", text6].filter(Boolean).join("\n");
48845
+ const text7 = item.visibleOutput ?? item.result?.summary ?? item.text ?? item.summary?.join("\n") ?? item.fallbackText ?? "";
48846
+ const output = [item.status !== "completed" ? item.failureReason || `Muse reported ${item.status}.` : "", text7].filter(Boolean).join("\n");
48682
48847
  return { ok, ...output ? { output: redactSecretsInText(output.slice(0, MAX_TOOL_OUTPUT)) } : {} };
48683
48848
  }
48684
48849
  function museQuestions(raw) {
@@ -48845,7 +49010,7 @@ var init_muse_code = __esm({
48845
49010
  lastRefresh = Date.now();
48846
49011
  });
48847
49012
  const listModels = async () => {
48848
- const cwd = mkdtempSync4(join43(tmpdir6(), "atomic-muse-models-"));
49013
+ const cwd = mkdtempSync4(join44(tmpdir6(), "atomic-muse-models-"));
48849
49014
  let host;
48850
49015
  try {
48851
49016
  host = await startHost(["serve", "--disable-shell", "--disable-write", "--no-session-log", "--contributor-mode", "off"], cwd, "models", false);
@@ -48946,12 +49111,12 @@ var init_muse_code = __esm({
48946
49111
  active.items.set(item.itemId, item);
48947
49112
  if (item.kind === "agentMessage") {
48948
49113
  if (item.status !== "completed" || item.retracted) return;
48949
- const text6 = item.text ?? "";
49114
+ const text7 = item.text ?? "";
48950
49115
  const streamed = active.streamed.get(item.itemId) ?? "";
48951
- if (text6.startsWith(streamed) && text6.length > streamed.length) {
48952
- emit({ type: "content.delta", threadId, turnId: active.turnId, itemId: item.itemId, streamKind: "assistant_text", delta: text6.slice(streamed.length) });
49116
+ if (text7.startsWith(streamed) && text7.length > streamed.length) {
49117
+ emit({ type: "content.delta", threadId, turnId: active.turnId, itemId: item.itemId, streamKind: "assistant_text", delta: text7.slice(streamed.length) });
48953
49118
  }
48954
- if (text6) emit({ type: "item.completed", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "assistant_text", text: text6 });
49119
+ if (text7) emit({ type: "item.completed", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "assistant_text", text: text7 });
48955
49120
  } else if (item.kind === "reasoning") {
48956
49121
  if (!seen) emit({ type: "item.started", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "reasoning" });
48957
49122
  } else if (TOOL_KINDS.has(item.kind)) {
@@ -49148,16 +49313,16 @@ var init_muse_code = __esm({
49148
49313
  const rebuilt = Boolean(resumeId && turn.recoveryText);
49149
49314
  return { text: rebuilt ? turn.recoveryText : turn.text, rebuilt, started: true };
49150
49315
  };
49151
- const withInstructions = (state2, turn, text6, started) => {
49316
+ const withInstructions = (state2, turn, text7, started) => {
49152
49317
  const sessionId = state2.sessionId;
49153
49318
  if (turn.systemStable === void 0) return turn.system && started ? `${turn.system}
49154
49319
 
49155
- ${text6}` : text6;
49320
+ ${text7}` : text7;
49156
49321
  let entry = state2.instructions;
49157
49322
  const resend = started || !entry || entry.sessionId !== sessionId || entry.stable !== turn.systemStable || entry.turns >= INSTRUCTIONS_REFRESH_TURNS;
49158
49323
  if (resend) entry = state2.instructions = { sessionId, stable: turn.systemStable, turns: 0, seen: /* @__PURE__ */ new Map() };
49159
49324
  entry.turns++;
49160
- const body = withNote(text6, volatileNote(volatileSectionsOf(turn), entry.seen, entry.seen.size === 0));
49325
+ const body = withNote(text7, volatileNote(volatileSectionsOf(turn), entry.seen, entry.seen.size === 0));
49161
49326
  return resend && turn.systemStable ? `${turn.systemStable}
49162
49327
 
49163
49328
  ${body}` : body;
@@ -49175,7 +49340,7 @@ ${body}` : body;
49175
49340
  await host.connection.command("session/setModel", { sessionId, model: { modelId: turn.model, providerId: config2.provider } });
49176
49341
  state2.model = turn.model;
49177
49342
  }
49178
- const text6 = withInstructions(state2, turn, session.text, session.started);
49343
+ const text7 = withInstructions(state2, turn, session.text, session.started);
49179
49344
  const images = turn.images?.length ? await Promise.all(turn.images.map(async (image) => ({
49180
49345
  type: "image",
49181
49346
  mediaType: image.mime,
@@ -49187,7 +49352,7 @@ ${body}` : body;
49187
49352
  active.nativeTurnId = host.connection.mintCommandId();
49188
49353
  await host.connection.command("turn/start", {
49189
49354
  sessionId,
49190
- input: [{ type: "text", text: text6 }, ...images],
49355
+ input: [{ type: "text", text: text7 }, ...images],
49191
49356
  ...effort ? { reasoningEffort: effort } : {}
49192
49357
  }, { commandId: active.nativeTurnId });
49193
49358
  } catch (error51) {
@@ -49267,7 +49432,7 @@ ${body}` : body;
49267
49432
  return "unavailable";
49268
49433
  }
49269
49434
  },
49270
- async steer(threadId, text6) {
49435
+ async steer(threadId, text7) {
49271
49436
  const state2 = threads.get(threadId);
49272
49437
  const active = state2?.active;
49273
49438
  if (!state2?.host || !state2.sessionId || !active?.nativeTurnId || active.finished) return "refused";
@@ -49275,7 +49440,7 @@ ${body}` : body;
49275
49440
  await state2.host.connection.command("turn/steer", {
49276
49441
  sessionId: state2.sessionId,
49277
49442
  expectedTurnId: active.nativeTurnId,
49278
- input: [{ type: "text", text: text6 }]
49443
+ input: [{ type: "text", text: text7 }]
49279
49444
  });
49280
49445
  return "steered";
49281
49446
  } catch (error51) {
@@ -49294,7 +49459,7 @@ ${body}` : body;
49294
49459
  return () => listeners.delete(listener);
49295
49460
  }
49296
49461
  };
49297
- if (existsSync21(credentialPath()) || existsSync21(config2.cli) || findCliCandidates(config2.cli).length) void refreshModels();
49462
+ if (existsSync22(credentialPath()) || existsSync22(config2.cli) || findCliCandidates(config2.cli).length) void refreshModels();
49298
49463
  return {
49299
49464
  instanceId,
49300
49465
  driverKind: MUSE_CODE_DRIVER,
@@ -49341,9 +49506,9 @@ ${body}` : body;
49341
49506
  });
49342
49507
 
49343
49508
  // server/drivers/acp/opencode-go.ts
49344
- import { existsSync as existsSync22, mkdirSync as mkdirSync20, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
49509
+ import { existsSync as existsSync23, mkdirSync as mkdirSync20, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
49345
49510
  import { homedir as homedir23 } from "node:os";
49346
- import { join as join44 } from "node:path";
49511
+ import { join as join45 } from "node:path";
49347
49512
  function labelForModel(id) {
49348
49513
  return id.split(/[-_.]+/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
49349
49514
  }
@@ -49446,7 +49611,7 @@ async function discoverOpenCodeModels(environment, cli = "opencode") {
49446
49611
  }
49447
49612
  function opencodeConfigDir(env) {
49448
49613
  const home = env.HOME || env.USERPROFILE || homedir23();
49449
- return join44(env.XDG_CONFIG_HOME || join44(home, ".config"), "opencode");
49614
+ return join45(env.XDG_CONFIG_HOME || join45(home, ".config"), "opencode");
49450
49615
  }
49451
49616
  function ensureOpenCodeInjectModel(modelId, env = process.env) {
49452
49617
  const inject = decodeInjectId(modelId);
@@ -49456,9 +49621,9 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
49456
49621
  const native = `${inject.host}/${inject.model}`;
49457
49622
  const dir = opencodeConfigDir(env);
49458
49623
  mkdirSync20(dir, { recursive: true });
49459
- const path4 = join44(dir, "opencode.json");
49624
+ const path4 = join45(dir, "opencode.json");
49460
49625
  let config2 = { $schema: "https://opencode.ai/config.json" };
49461
- if (existsSync22(path4)) {
49626
+ if (existsSync23(path4)) {
49462
49627
  try {
49463
49628
  config2 = JSON.parse(readFileSync25(path4, "utf8"));
49464
49629
  } catch {
@@ -49494,10 +49659,10 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
49494
49659
  function storedAuthPaths(env) {
49495
49660
  const home = env.HOME || env.USERPROFILE || homedir23();
49496
49661
  const roots = [
49497
- env.XDG_DATA_HOME || join44(home, ".local", "share"),
49498
- process.platform === "darwin" ? join44(home, "Library", "Application Support") : process.platform === "win32" ? env.LOCALAPPDATA || join44(home, "AppData", "Local") : ""
49662
+ env.XDG_DATA_HOME || join45(home, ".local", "share"),
49663
+ process.platform === "darwin" ? join45(home, "Library", "Application Support") : process.platform === "win32" ? env.LOCALAPPDATA || join45(home, "AppData", "Local") : ""
49499
49664
  ].filter(Boolean);
49500
- return [...new Set(roots)].map((root) => join44(root, "opencode", "auth.json"));
49665
+ return [...new Set(roots)].map((root) => join45(root, "opencode", "auth.json"));
49501
49666
  }
49502
49667
  function usableAuthEntry(parsed) {
49503
49668
  return Object.values(parsed).some((auth) => {
@@ -49653,13 +49818,13 @@ ${turn.text}` : turn.text
49653
49818
  });
49654
49819
 
49655
49820
  // server/drivers/acp/qwen.ts
49656
- import { chmodSync as chmodSync6, existsSync as existsSync23, mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "node:fs";
49821
+ import { chmodSync as chmodSync6, existsSync as existsSync24, mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "node:fs";
49657
49822
  import { createHash as createHash14 } from "node:crypto";
49658
49823
  import { homedir as homedir24 } from "node:os";
49659
- import { join as join45 } from "node:path";
49824
+ import { join as join46 } from "node:path";
49660
49825
  function qwenHome(env) {
49661
49826
  const home = process.platform === "win32" ? env.USERPROFILE || env.HOME || homedir24() : env.HOME || env.USERPROFILE || homedir24();
49662
- return join45(home, ".qwen");
49827
+ return join46(home, ".qwen");
49663
49828
  }
49664
49829
  function isRecord5(value) {
49665
49830
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
@@ -49671,7 +49836,7 @@ function qwenModelLabel(id, name) {
49671
49836
  function readQwenRoutes(env) {
49672
49837
  let settings2;
49673
49838
  try {
49674
- settings2 = JSON.parse(readFileSync26(join45(qwenHome(env), "settings.json"), "utf8"));
49839
+ settings2 = JSON.parse(readFileSync26(join46(qwenHome(env), "settings.json"), "utf8"));
49675
49840
  } catch {
49676
49841
  return [];
49677
49842
  }
@@ -49755,9 +49920,9 @@ function ensureQwenInjectModel(modelId, env = process.env) {
49755
49920
  if (!host) return modelId;
49756
49921
  const dir = qwenHome(env);
49757
49922
  mkdirSync21(dir, { recursive: true });
49758
- const path4 = join45(dir, "settings.json");
49923
+ const path4 = join46(dir, "settings.json");
49759
49924
  let settings2 = {};
49760
- if (existsSync23(path4)) {
49925
+ if (existsSync24(path4)) {
49761
49926
  try {
49762
49927
  settings2 = JSON.parse(readFileSync26(path4, "utf8"));
49763
49928
  } catch {
@@ -49900,29 +50065,32 @@ function mistralSignInLink(value) {
49900
50065
  return host === "mistral.ai" || host.endsWith(".mistral.ai") ? url2.href : null;
49901
50066
  }
49902
50067
  function vibeSignInFailure(error51) {
49903
- const text6 = error51 instanceof VibeRequestError ? error51.message : "";
49904
- if (/denied/i.test(text6)) return "The Mistral sign-in was declined. Start sign-in again to try another account.";
49905
- if (/expired|timed out/i.test(text6)) return "The Mistral sign-in expired. Start sign-in again.";
50068
+ const text7 = error51 instanceof VibeRequestError ? error51.message : "";
50069
+ if (/denied/i.test(text7)) return "The Mistral sign-in was declined. Start sign-in again to try another account.";
50070
+ if (/expired|timed out/i.test(text7)) return "The Mistral sign-in expired. Start sign-in again.";
49906
50071
  if (error51 instanceof Error && !(error51 instanceof VibeRequestError)) return error51.message;
49907
50072
  return "Mistral Vibe sign-in did not finish. Check this computer's connection and that Vibe is up to date, then try again.";
49908
50073
  }
49909
- async function vibeSignedIn(cli, env, timeoutMs = 2e4) {
50074
+ async function vibeSignInState(cli, env, timeoutMs = 2e4) {
49910
50075
  let client;
49911
50076
  try {
49912
50077
  client = new VibeAcpClient(cli, env);
49913
50078
  } catch {
49914
- return false;
50079
+ return "signed-out";
49915
50080
  }
49916
50081
  try {
49917
50082
  await client.initialize(timeoutMs);
49918
50083
  const status = await client.request("_auth/status", {}, timeoutMs);
49919
- return status?.authenticated === true;
50084
+ return status?.authenticated === true ? "signed-in" : "signed-out";
49920
50085
  } catch {
49921
- return false;
50086
+ return client.missing ? "missing" : "signed-out";
49922
50087
  } finally {
49923
50088
  client.close();
49924
50089
  }
49925
50090
  }
50091
+ async function vibeSignedIn(cli, env, timeoutMs = 2e4) {
50092
+ return await vibeSignInState(cli, env, timeoutMs) === "signed-in";
50093
+ }
49926
50094
  var MAX_LINE, DELEGATED, VibeAcpClient, VibeRequestError, VibeLoginController;
49927
50095
  var init_vibe_login = __esm({
49928
50096
  "server/drivers/vibe-login.ts"() {
@@ -49936,12 +50104,17 @@ var init_vibe_login = __esm({
49936
50104
  nextId = 1;
49937
50105
  buffer = "";
49938
50106
  closed = false;
50107
+ /** The command was not found: nothing is installed to sign in to. */
50108
+ missing = false;
49939
50109
  constructor(cli, env) {
49940
50110
  this.child = spawnCli(cli, [], { env, stdio: ["pipe", "pipe", "pipe"] });
49941
50111
  this.child.stderr?.resume();
49942
50112
  this.child.stdout?.on("data", (chunk) => this.receive(chunk.toString("utf8")));
49943
50113
  const fail = (message3) => this.close(new Error(message3));
49944
- this.child.once("error", (error51) => fail(error51.code === "ENOENT" ? "Mistral Vibe is not installed on this computer. Install it, then try again." : "Mistral Vibe could not start on this computer. Check its install, then try again."));
50114
+ this.child.once("error", (error51) => {
50115
+ this.missing = error51.code === "ENOENT";
50116
+ fail(this.missing ? "Mistral Vibe is not installed on this computer. Install it, then try again." : "Mistral Vibe could not start on this computer. Check its install, then try again.");
50117
+ });
49945
50118
  this.child.once("close", () => fail("Mistral Vibe stopped before it answered. Update Vibe and try again."));
49946
50119
  }
49947
50120
  /** initialize, opting in to the delegated browser sign-in. */
@@ -49977,8 +50150,8 @@ var init_vibe_login = __esm({
49977
50150
  }
49978
50151
  if (this.child.exitCode === null && this.child.signalCode === null) void killCliTree(this.child).catch(() => false);
49979
50152
  }
49980
- receive(text6) {
49981
- this.buffer += text6;
50153
+ receive(text7) {
50154
+ this.buffer += text7;
49982
50155
  if (this.buffer.length > MAX_LINE) {
49983
50156
  this.close(new Error("Mistral Vibe returned an unexpected answer. Update Vibe and try again."));
49984
50157
  return;
@@ -50151,7 +50324,7 @@ var init_vibe = __esm({
50151
50324
  models: MODELS4,
50152
50325
  defaultCli: "vibe-acp",
50153
50326
  nativeSource: "vibe.acp",
50154
- loginNote: "Mistral Vibe is not installed",
50327
+ loginNote: "Mistral Vibe is not signed in: choose Sign in with Mistral on its engine card",
50155
50328
  // Mistral's own installer (it installs uv, then mistral-vibe). Not a
50156
50329
  // vendorScript: mistral.ai redirects it to raw.githubusercontent.com, a host
50157
50330
  // vendor-install.ts cannot pin to Mistral. Mistral targets macOS and Linux;
@@ -50166,11 +50339,17 @@ var init_vibe = __esm({
50166
50339
  spawnArgs: () => [],
50167
50340
  selectModel: { configId: "model" },
50168
50341
  // Sign-in is the delegated browser flow on the engine card, never a
50169
- // prompt in the middle of a turn.
50342
+ // prompt in the middle of a turn: no authenticate call is made. The
50343
+ // sign-in gate is requireAuthenticationBeforeSpawn (Vibe's own
50344
+ // `_auth/status`), so the handshake continues without one; "fail" here
50345
+ // stopped every turn of a signed-in Vibe with loginNote.
50170
50346
  pickAuthMethod: () => null,
50171
- authFailure: "fail",
50347
+ authFailure: "continue",
50172
50348
  requireAuthenticationBeforeSpawn: true,
50173
- isAuthenticated: (env, config2, instanceId) => cachedSignedIn(`${instanceId}:${env.VIBE_HOME ?? ""}`, () => vibeSignedIn(config2.cli || "vibe-acp", env)),
50349
+ // A missing `vibe-acp` passes this gate on purpose: the spawn then says it
50350
+ // is not installed, where loginNote would have blamed the sign-in. The
50351
+ // engine list never asks here without a CLI (snapshot probes it first).
50352
+ isAuthenticated: (env, config2, instanceId) => cachedSignedIn(`${instanceId}:${env.VIBE_HOME ?? ""}`, async () => await vibeSignInState(config2.cli || "vibe-acp", env) !== "signed-out"),
50174
50353
  async configureSession({ request, sessionId, config: config2, turn }) {
50175
50354
  const value = vibeSessionMode(config2.fullAuto, turn.approvalMode);
50176
50355
  let reply;
@@ -50238,15 +50417,9 @@ var init_engine_tiers = __esm({
50238
50417
  { engine: "hermes", model: "nous:x-ai/grok-4.6" },
50239
50418
  { engine: "ollamaCloud", model: "glm-5.3" },
50240
50419
  { engine: "museCode", model: "muse-spark-1.2" },
50241
- { engine: "hermesAgent", model: "openai-codex:gpt-6-sol", modelClass: "Plata" },
50242
50420
  { engine: "antigravity", model: "gemini-3.8-flash-medium" },
50243
50421
  { engine: "cursorAgent", model: "auto" },
50244
- { engine: "hermesAgent", model: "huggingface:deepseek-ai/DeepSeek-R1-0528", modelClass: "Plata" },
50245
- { engine: "hermesAgent", model: "opencode-go:deepseek-v4-flash", modelClass: "Plata" },
50246
- { engine: "hermesAgent", model: "deepinfra:anthropic/claude-opus-5", modelClass: "Plata" },
50247
- { engine: "hermesAgent", model: "nous:meta/muse-spark-1.3", modelClass: "Plata" },
50248
- { engine: "hermesAgent", model: "openrouter:openai/gpt-6-sol", modelClass: "Plata" },
50249
- { engine: "hermesAgent", model: "openai-codex:gpt-6.1-sol", modelClass: "Plata" }
50422
+ { engine: "hermesAgent", model: "nous:meta/muse-spark-1.3", modelClass: "Plata" }
50250
50423
  ],
50251
50424
  engineering: [
50252
50425
  { ...ATOMIC_AUTO_RUNG },
@@ -50255,13 +50428,11 @@ var init_engine_tiers = __esm({
50255
50428
  { engine: "claudeAgent", model: "claude-opus-5-5" },
50256
50429
  { engine: "opencodeGo", model: "opencode-go/gemini-4-argon" },
50257
50430
  { engine: "ollamaCloud", model: "kimi-k3" },
50258
- { engine: "hermesAgent", model: "openai-codex:gpt-6-astra", modelClass: "Mezcal" },
50259
50431
  { engine: "grok", model: "grok-4.7" },
50260
50432
  { engine: "grokAgent", model: "grok-4.7" },
50261
50433
  { engine: "kimi", model: "kimi-code/k3" },
50262
50434
  { engine: "openai-compat", model: "qwen3.7-plus" },
50263
50435
  { engine: "hermesAgent", model: "nous:anthropic/claude-opus-5.5" },
50264
- { engine: "hermesAgent", model: "opencode-zen:claude-fable-5-1", modelClass: "Mezcal" },
50265
50436
  { engine: "cursorAgent", model: "auto" }
50266
50437
  ],
50267
50438
  research: [
@@ -50270,10 +50441,6 @@ var init_engine_tiers = __esm({
50270
50441
  { engine: "vibe", model: "mistral-medium-3.5" },
50271
50442
  { engine: "antigravityAgent", model: "gemini-3.8-flash-low" },
50272
50443
  { engine: "cursorAgent", model: "auto" },
50273
- { engine: "hermesAgent", model: "openrouter:x-ai/grok-4.7", modelClass: "Plata" },
50274
- { engine: "hermesAgent", model: "custom:local-(localhost:11434):deepseek-v4-pro:cloud" },
50275
- { engine: "hermesAgent", model: "openrouter:meta/muse-spark-1.3", modelClass: "Plata" },
50276
- { engine: "hermesAgent", model: "opencode-zen:muse-spark-1.3", modelClass: "Plata" },
50277
50444
  { engine: "claudeAgent", model: "claude-opus-5", modelClass: "Plata" },
50278
50445
  { engine: "cursorAgent", model: "claude-opus-5-high", modelClass: "Plata" },
50279
50446
  { engine: "opencodeGo", model: "opencode/claude-opus-5", modelClass: "Plata" }
@@ -50399,12 +50566,12 @@ var init_atomic_engine_local = __esm({
50399
50566
  // server/atomic-engine-accounts.ts
50400
50567
  import { mkdirSync as mkdirSync22, readFileSync as readFileSync27, writeFileSync as writeFileSync18 } from "node:fs";
50401
50568
  import { homedir as homedir25 } from "node:os";
50402
- import { join as join46 } from "node:path";
50569
+ import { join as join47 } from "node:path";
50403
50570
  function rawConfig2(entry) {
50404
50571
  return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config) ? entry.config : {};
50405
50572
  }
50406
50573
  function expandHome(path4) {
50407
- return path4 === "~" ? homedir25() : path4.startsWith("~/") ? join46(homedir25(), path4.slice(2)) : path4;
50574
+ return path4 === "~" ? homedir25() : path4.startsWith("~/") ? join47(homedir25(), path4.slice(2)) : path4;
50408
50575
  }
50409
50576
  function asAccount(id, entry) {
50410
50577
  if (entry.enabled === false) return null;
@@ -50436,7 +50603,7 @@ function asAccount(id, entry) {
50436
50603
  kind: "codex-cli",
50437
50604
  label,
50438
50605
  billing: "subscription",
50439
- home: home ? expandHome(home) : join46(homedir25(), ".codex"),
50606
+ home: home ? expandHome(home) : join47(homedir25(), ".codex"),
50440
50607
  model: FAILOVER_MODEL["openai-codex"]
50441
50608
  } };
50442
50609
  }
@@ -50515,16 +50682,16 @@ function atomicEngineAccounts(input) {
50515
50682
  }
50516
50683
  function writeAtomicEngineAccountsFile(engineHome, accounts) {
50517
50684
  const shareable = accounts.map(({ restingUntil: _resting, ...account }) => account);
50518
- const text6 = `${JSON.stringify({ version: 1, accounts: shareable }, null, 2)}
50685
+ const text7 = `${JSON.stringify({ version: 1, accounts: shareable }, null, 2)}
50519
50686
  `;
50520
- const path4 = join46(engineHome, ACCOUNTS_FILE);
50687
+ const path4 = join47(engineHome, ACCOUNTS_FILE);
50521
50688
  try {
50522
- if (readFileSync27(path4, "utf8") === text6) return;
50689
+ if (readFileSync27(path4, "utf8") === text7) return;
50523
50690
  } catch {
50524
50691
  }
50525
50692
  try {
50526
50693
  mkdirSync22(engineHome, { recursive: true, mode: 448 });
50527
- writeFileSync18(path4, text6, { mode: 384 });
50694
+ writeFileSync18(path4, text7, { mode: 384 });
50528
50695
  } catch (error51) {
50529
50696
  console.warn(`[atomic-engine] could not write ${path4}: ${error51.message}`);
50530
50697
  }
@@ -50609,31 +50776,31 @@ var init_atomic_engine_release = __esm({
50609
50776
 
50610
50777
  // server/atomic-engine-runtime.ts
50611
50778
  import { createHash as createHash15, randomUUID as randomUUID16 } from "node:crypto";
50612
- import { createWriteStream as createWriteStream2, existsSync as existsSync24, mkdirSync as mkdirSync23, readdirSync as readdirSync7, readFileSync as readFileSync28, rmSync as rmSync10, writeFileSync as writeFileSync19 } from "node:fs";
50613
- import { join as join47 } from "node:path";
50779
+ import { createWriteStream as createWriteStream2, existsSync as existsSync25, mkdirSync as mkdirSync23, readdirSync as readdirSync8, readFileSync as readFileSync28, rmSync as rmSync10, writeFileSync as writeFileSync19 } from "node:fs";
50780
+ import { join as join48 } from "node:path";
50614
50781
  import { Readable, Transform as Transform2 } from "node:stream";
50615
50782
  import { pipeline as pipeline2 } from "node:stream/promises";
50616
50783
  function atomicEngineHome(baseDir = DATA_DIR) {
50617
- return join47(baseDir, "tools", "atomic-engine");
50784
+ return join48(baseDir, "tools", "atomic-engine");
50618
50785
  }
50619
50786
  function atomicEnginePython(root, platform = process.platform) {
50620
- return platform === "win32" ? join47(root, "atomic-engine", "python", "python.exe") : join47(root, "atomic-engine", "python", "bin", "python3");
50787
+ return platform === "win32" ? join48(root, "atomic-engine", "python", "python.exe") : join48(root, "atomic-engine", "python", "bin", "python3");
50621
50788
  }
50622
50789
  function managedAtomicEngine(baseDir = DATA_DIR, asset = atomicEngineAsset(), platform = process.platform) {
50623
50790
  if (!asset) return null;
50624
- const root = join47(atomicEngineHome(baseDir), asset.version);
50791
+ const root = join48(atomicEngineHome(baseDir), asset.version);
50625
50792
  try {
50626
- if (readFileSync28(join47(root, MARKER2), "utf8").trim() !== asset.sha512) return null;
50793
+ if (readFileSync28(join48(root, MARKER2), "utf8").trim() !== asset.sha512) return null;
50627
50794
  } catch {
50628
50795
  return null;
50629
50796
  }
50630
50797
  const python = atomicEnginePython(root, platform);
50631
- return existsSync24(python) ? { version: asset.version, root, python } : null;
50798
+ return existsSync25(python) ? { version: asset.version, root, python } : null;
50632
50799
  }
50633
50800
  function systemTar(platform = process.platform) {
50634
50801
  if (platform !== "win32") return "/usr/bin/tar";
50635
50802
  const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT ?? "C:\\Windows";
50636
- return join47(systemRoot, "System32", "tar.exe");
50803
+ return join48(systemRoot, "System32", "tar.exe");
50637
50804
  }
50638
50805
  async function download(asset, file2, options) {
50639
50806
  let response;
@@ -50678,8 +50845,8 @@ async function installOnce3(options) {
50678
50845
  const home = atomicEngineHome(baseDir);
50679
50846
  mkdirSync23(home, { recursive: true });
50680
50847
  const id = randomUUID16();
50681
- const archive = join47(home, `.download-${id}.tar.gz`);
50682
- const staging = join47(home, `.staging-${id}`);
50848
+ const archive = join48(home, `.download-${id}.tar.gz`);
50849
+ const staging = join48(home, `.staging-${id}`);
50683
50850
  try {
50684
50851
  await download(asset, archive, options);
50685
50852
  options.onProgress?.({ phase: "installing" });
@@ -50689,8 +50856,8 @@ async function installOnce3(options) {
50689
50856
  } catch (error51) {
50690
50857
  throw new AtomicEngineInstallError("install", `Could not unpack Atomic Engine: ${error51 instanceof Error ? error51.message : String(error51)}`);
50691
50858
  }
50692
- if (!existsSync24(atomicEnginePython(staging))) throw new AtomicEngineInstallError("install", "The Atomic Engine package has no Python runtime for this computer");
50693
- const root = join47(home, asset.version);
50859
+ if (!existsSync25(atomicEnginePython(staging))) throw new AtomicEngineInstallError("install", "The Atomic Engine package has no Python runtime for this computer");
50860
+ const root = join48(home, asset.version);
50694
50861
  rmSync10(root, { recursive: true, force: true });
50695
50862
  await promoteDirectory(staging, root);
50696
50863
  const python = atomicEnginePython(root);
@@ -50701,10 +50868,10 @@ async function installOnce3(options) {
50701
50868
  await removeDirectoryQuietly(root, "Atomic Engine has no install marker there, so it is not used");
50702
50869
  throw new AtomicEngineInstallError("install", `Atomic Engine did not start after installing: ${error51 instanceof Error ? error51.message : String(error51)}`);
50703
50870
  }
50704
- writeFileSync19(join47(root, MARKER2), `${asset.sha512}
50871
+ writeFileSync19(join48(root, MARKER2), `${asset.sha512}
50705
50872
  `);
50706
- for (const name of readdirSync7(home)) {
50707
- if (name !== asset.version && !name.startsWith(".")) rmSync10(join47(home, name), { recursive: true, force: true });
50873
+ for (const name of readdirSync8(home)) {
50874
+ if (name !== asset.version && !name.startsWith(".")) rmSync10(join48(home, name), { recursive: true, force: true });
50708
50875
  }
50709
50876
  const installed = managedAtomicEngine(baseDir, asset);
50710
50877
  if (!installed) throw new AtomicEngineInstallError("install", "Atomic Engine did not install completely");
@@ -51663,14 +51830,14 @@ var init_stringifyComment = __esm({
51663
51830
  });
51664
51831
 
51665
51832
  // ../atomic-harness-skills/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
51666
- function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
51833
+ function foldFlowLines(text7, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
51667
51834
  if (!lineWidth || lineWidth < 0)
51668
- return text6;
51835
+ return text7;
51669
51836
  if (lineWidth < minContentWidth)
51670
51837
  minContentWidth = 0;
51671
51838
  const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
51672
- if (text6.length <= endStep)
51673
- return text6;
51839
+ if (text7.length <= endStep)
51840
+ return text7;
51674
51841
  const folds = [];
51675
51842
  const escapedFolds = {};
51676
51843
  let end = lineWidth - indent.length;
@@ -51687,14 +51854,14 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
51687
51854
  let escStart = -1;
51688
51855
  let escEnd = -1;
51689
51856
  if (mode === FOLD_BLOCK) {
51690
- i2 = consumeMoreIndentedLines(text6, i2, indent.length);
51857
+ i2 = consumeMoreIndentedLines(text7, i2, indent.length);
51691
51858
  if (i2 !== -1)
51692
51859
  end = i2 + endStep;
51693
51860
  }
51694
- for (let ch; ch = text6[i2 += 1]; ) {
51861
+ for (let ch; ch = text7[i2 += 1]; ) {
51695
51862
  if (mode === FOLD_QUOTED && ch === "\\") {
51696
51863
  escStart = i2;
51697
- switch (text6[i2 + 1]) {
51864
+ switch (text7[i2 + 1]) {
51698
51865
  case "x":
51699
51866
  i2 += 3;
51700
51867
  break;
@@ -51711,12 +51878,12 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
51711
51878
  }
51712
51879
  if (ch === "\n") {
51713
51880
  if (mode === FOLD_BLOCK)
51714
- i2 = consumeMoreIndentedLines(text6, i2, indent.length);
51881
+ i2 = consumeMoreIndentedLines(text7, i2, indent.length);
51715
51882
  end = i2 + indent.length + endStep;
51716
51883
  split = void 0;
51717
51884
  } else {
51718
51885
  if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
51719
- const next = text6[i2 + 1];
51886
+ const next = text7[i2 + 1];
51720
51887
  if (next && next !== " " && next !== "\n" && next !== " ")
51721
51888
  split = i2;
51722
51889
  }
@@ -51728,12 +51895,12 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
51728
51895
  } else if (mode === FOLD_QUOTED) {
51729
51896
  while (prev === " " || prev === " ") {
51730
51897
  prev = ch;
51731
- ch = text6[i2 += 1];
51898
+ ch = text7[i2 += 1];
51732
51899
  overflow = true;
51733
51900
  }
51734
51901
  const j2 = i2 > escEnd + 1 ? i2 - 2 : escStart - 1;
51735
51902
  if (escapedFolds[j2])
51736
- return text6;
51903
+ return text7;
51737
51904
  folds.push(j2);
51738
51905
  escapedFolds[j2] = true;
51739
51906
  end = j2 + endStep;
@@ -51748,39 +51915,39 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
51748
51915
  if (overflow && onOverflow)
51749
51916
  onOverflow();
51750
51917
  if (folds.length === 0)
51751
- return text6;
51918
+ return text7;
51752
51919
  if (onFold)
51753
51920
  onFold();
51754
- let res = text6.slice(0, folds[0]);
51921
+ let res = text7.slice(0, folds[0]);
51755
51922
  for (let i3 = 0; i3 < folds.length; ++i3) {
51756
51923
  const fold = folds[i3];
51757
- const end2 = folds[i3 + 1] || text6.length;
51924
+ const end2 = folds[i3 + 1] || text7.length;
51758
51925
  if (fold === 0)
51759
51926
  res = `
51760
- ${indent}${text6.slice(0, end2)}`;
51927
+ ${indent}${text7.slice(0, end2)}`;
51761
51928
  else {
51762
51929
  if (mode === FOLD_QUOTED && escapedFolds[fold])
51763
- res += `${text6[fold]}\\`;
51930
+ res += `${text7[fold]}\\`;
51764
51931
  res += `
51765
- ${indent}${text6.slice(fold + 1, end2)}`;
51932
+ ${indent}${text7.slice(fold + 1, end2)}`;
51766
51933
  }
51767
51934
  }
51768
51935
  return res;
51769
51936
  }
51770
- function consumeMoreIndentedLines(text6, i2, indent) {
51937
+ function consumeMoreIndentedLines(text7, i2, indent) {
51771
51938
  let end = i2;
51772
51939
  let start = i2 + 1;
51773
- let ch = text6[start];
51940
+ let ch = text7[start];
51774
51941
  while (ch === " " || ch === " ") {
51775
51942
  if (i2 < start + indent) {
51776
- ch = text6[++i2];
51943
+ ch = text7[++i2];
51777
51944
  } else {
51778
51945
  do {
51779
- ch = text6[++i2];
51946
+ ch = text7[++i2];
51780
51947
  } while (ch && ch !== "\n");
51781
51948
  end = i2;
51782
51949
  start = i2 + 1;
51783
- ch = text6[start];
51950
+ ch = text7[start];
51784
51951
  }
51785
51952
  }
51786
51953
  return end;
@@ -57627,8 +57794,8 @@ var init_memory_policy = __esm({
57627
57794
 
57628
57795
  // server/drivers/acp/hermes-memory-lock.ts
57629
57796
  import { createHash as createHash16 } from "node:crypto";
57630
- import { mkdirSync as mkdirSync24, readdirSync as readdirSync8, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
57631
- import { join as join48 } from "node:path";
57797
+ import { mkdirSync as mkdirSync24, readdirSync as readdirSync9, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
57798
+ import { join as join49 } from "node:path";
57632
57799
  function readText2(path4) {
57633
57800
  try {
57634
57801
  return readFileSync29(path4, "utf8");
@@ -57636,10 +57803,10 @@ function readText2(path4) {
57636
57803
  return null;
57637
57804
  }
57638
57805
  }
57639
- function parseYamlSafe(text6) {
57640
- if (text6 === null) return null;
57806
+ function parseYamlSafe(text7) {
57807
+ if (text7 === null) return null;
57641
57808
  try {
57642
- return parse3(text6);
57809
+ return parse3(text7);
57643
57810
  } catch {
57644
57811
  return null;
57645
57812
  }
@@ -57650,29 +57817,29 @@ function record3(value) {
57650
57817
  function memoryProviderPlugins(pluginsDir) {
57651
57818
  let dirs;
57652
57819
  try {
57653
- dirs = readdirSync8(pluginsDir);
57820
+ dirs = readdirSync9(pluginsDir);
57654
57821
  } catch {
57655
57822
  return [];
57656
57823
  }
57657
57824
  return dirs.flatMap((dir) => {
57658
- const source2 = (readText2(join48(pluginsDir, dir, "__init__.py")) ?? "").slice(0, 8192);
57825
+ const source2 = (readText2(join49(pluginsDir, dir, "__init__.py")) ?? "").slice(0, 8192);
57659
57826
  if (!source2.includes("register_memory_provider") && !source2.includes("MemoryProvider")) return [];
57660
- const name = record3(parseYamlSafe(readText2(join48(pluginsDir, dir, "plugin.yaml"))))?.name;
57827
+ const name = record3(parseYamlSafe(readText2(join49(pluginsDir, dir, "plugin.yaml"))))?.name;
57661
57828
  return typeof name === "string" && name.trim() && name.trim() !== dir ? [dir, name.trim()] : [dir];
57662
57829
  });
57663
57830
  }
57664
57831
  function lockHermesMemory(env, home, dataDir = DATA_DIR) {
57665
- const own = record3(record3(parseYamlSafe(readText2(join48(home, "config.yaml"))))?.plugins);
57832
+ const own = record3(record3(parseYamlSafe(readText2(join49(home, "config.yaml"))))?.plugins);
57666
57833
  const disabled = new Set(Array.isArray(own?.disabled) ? own.disabled.map(String) : []);
57667
- for (const name of memoryProviderPlugins(join48(home, "plugins"))) disabled.add(name);
57834
+ for (const name of memoryProviderPlugins(join49(home, "plugins"))) disabled.add(name);
57668
57835
  for (const name of BLOCKED_HERMES_MEMORY_PLUGINS) disabled.add(name);
57669
57836
  const overlay = stringify3({
57670
57837
  memory: { provider: "", memory_enabled: false, user_profile_enabled: false },
57671
57838
  plugins: { disabled: [...disabled].sort() }
57672
57839
  });
57673
- const dir = join48(dataDir, "hermes-managed", createHash16("sha256").update(home).digest("hex").slice(0, 16));
57840
+ const dir = join49(dataDir, "hermes-managed", createHash16("sha256").update(home).digest("hex").slice(0, 16));
57674
57841
  mkdirSync24(dir, { recursive: true });
57675
- const file2 = join48(dir, "config.yaml");
57842
+ const file2 = join49(dir, "config.yaml");
57676
57843
  if (readText2(file2) !== overlay) writeFileSync20(file2, overlay);
57677
57844
  env.HERMES_MANAGED_DIR = dir;
57678
57845
  return dir;
@@ -57686,11 +57853,22 @@ var init_hermes_memory_lock = __esm({
57686
57853
  }
57687
57854
  });
57688
57855
 
57856
+ // server/drivers/acp/hermes-hosts.ts
57857
+ var HERMES_HOSTS, hostOf, hermesOnlyHosts;
57858
+ var init_hermes_hosts = __esm({
57859
+ "server/drivers/acp/hermes-hosts.ts"() {
57860
+ "use strict";
57861
+ HERMES_HOSTS = /* @__PURE__ */ new Set(["nous"]);
57862
+ hostOf = (modelId) => /^([a-z0-9_-]+):/i.exec(modelId)?.[1]?.toLowerCase();
57863
+ hermesOnlyHosts = (options) => options.filter((option) => HERMES_HOSTS.has(hostOf(option.id) ?? option.provider ?? ""));
57864
+ }
57865
+ });
57866
+
57689
57867
  // server/drivers/acp/hermes.ts
57690
57868
  import { spawn as spawn7 } from "node:child_process";
57691
57869
  import { mkdirSync as mkdirSync25, readFileSync as readFileSync30, writeFileSync as writeFileSync21 } from "node:fs";
57692
57870
  import { homedir as homedir26 } from "node:os";
57693
- import { join as join49 } from "node:path";
57871
+ import { join as join50 } from "node:path";
57694
57872
  function bindHermesScreenshotCompat(env, modelId) {
57695
57873
  delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT];
57696
57874
  delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL];
@@ -57700,30 +57878,30 @@ function bindHermesScreenshotCompat(env, modelId) {
57700
57878
  env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL] = inject.model;
57701
57879
  }
57702
57880
  function hermesHome(env) {
57703
- return env.HERMES_HOME || join49(env.HOME || env.USERPROFILE || homedir26(), ".hermes");
57881
+ return env.HERMES_HOME || join50(env.HOME || env.USERPROFILE || homedir26(), ".hermes");
57704
57882
  }
57705
57883
  function quoteYaml(value) {
57706
57884
  if (/^[\w./:+-]+$/.test(value)) return value;
57707
57885
  return JSON.stringify(value);
57708
57886
  }
57709
- function upsertHermesProvider(text6, hostId, baseUrl, apiKey) {
57887
+ function upsertHermesProvider(text7, hostId, baseUrl, apiKey) {
57710
57888
  const block2 = [` ${hostId}:`, ` base_url: ${quoteYaml(baseUrl)}`, ` api_key: ${quoteYaml(apiKey)}`, ""].join(
57711
57889
  "\n"
57712
57890
  );
57713
- if (/^providers:\s*$/m.test(text6)) {
57714
- const replaced = replaceHermesHostBlock(text6, hostId, block2);
57891
+ if (/^providers:\s*$/m.test(text7)) {
57892
+ const replaced = replaceHermesHostBlock(text7, hostId, block2);
57715
57893
  if (replaced !== null) return replaced;
57716
- return text6.replace(/^providers:\s*$/m, `providers:
57894
+ return text7.replace(/^providers:\s*$/m, `providers:
57717
57895
  ${block2.trimEnd()}`);
57718
57896
  }
57719
- const prefix = text6 && !text6.endsWith("\n") ? `${text6}
57720
- ` : text6;
57897
+ const prefix = text7 && !text7.endsWith("\n") ? `${text7}
57898
+ ` : text7;
57721
57899
  return `${prefix}
57722
57900
  providers:
57723
57901
  ${block2}`;
57724
57902
  }
57725
- function replaceHermesHostBlock(text6, hostId, block2) {
57726
- const lines = text6.split("\n");
57903
+ function replaceHermesHostBlock(text7, hostId, block2) {
57904
+ const lines = text7.split("\n");
57727
57905
  const start = lines.findIndex((line) => line === ` ${hostId}:`);
57728
57906
  if (start < 0) return null;
57729
57907
  let end = start + 1;
@@ -57742,15 +57920,15 @@ function ensureHermesInjectProvider(modelId, env = process.env, home = hermesHom
57742
57920
  if (!host) return modelId;
57743
57921
  const dir = home;
57744
57922
  mkdirSync25(dir, { recursive: true });
57745
- const path4 = join49(dir, "config.yaml");
57746
- let text6 = "";
57923
+ const path4 = join50(dir, "config.yaml");
57924
+ let text7 = "";
57747
57925
  try {
57748
- text6 = readFileSync30(path4, "utf8");
57926
+ text7 = readFileSync30(path4, "utf8");
57749
57927
  } catch {
57750
- text6 = "";
57928
+ text7 = "";
57751
57929
  }
57752
- const next = upsertHermesProvider(text6, inject.host, host.baseUrl, hostApiKey(host, env));
57753
- if (next !== text6) writeFileSync21(path4, next);
57930
+ const next = upsertHermesProvider(text7, inject.host, host.baseUrl, hostApiKey(host, env));
57931
+ if (next !== text7) writeFileSync21(path4, next);
57754
57932
  return hermesAcpModelId(modelId) ?? modelId;
57755
57933
  }
57756
57934
  function hermesAcpModelId(modelId) {
@@ -57760,8 +57938,8 @@ function hermesAcpModelId(modelId) {
57760
57938
  if (native && !native.includes(INJECT_SEP) && /^[a-z0-9_-]+:[\w./:-]+$/i.test(native)) return native;
57761
57939
  return null;
57762
57940
  }
57763
- function nonEmptyDotenvValue(text6, name) {
57764
- const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(text6);
57941
+ function nonEmptyDotenvValue(text7, name) {
57942
+ const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(text7);
57765
57943
  if (!match) return null;
57766
57944
  const raw = match[1].trim();
57767
57945
  if (!raw || raw.startsWith("#")) return null;
@@ -57778,10 +57956,10 @@ function nonEmptyDotenvValue(text6, name) {
57778
57956
  function yamlString(value) {
57779
57957
  return typeof value === "string" ? value.trim() : "";
57780
57958
  }
57781
- function hermesConfigDefault(text6) {
57959
+ function hermesConfigDefault(text7) {
57782
57960
  let raw;
57783
57961
  try {
57784
- raw = parse3(text6);
57962
+ raw = parse3(text7);
57785
57963
  } catch {
57786
57964
  return null;
57787
57965
  }
@@ -57813,13 +57991,13 @@ function hermesConfiguredModel(env = process.env) {
57813
57991
  const dir = hermesHome(env);
57814
57992
  let secrets = "";
57815
57993
  try {
57816
- secrets = readFileSync30(join49(dir, ".env"), "utf8");
57994
+ secrets = readFileSync30(join50(dir, ".env"), "utf8");
57817
57995
  } catch {
57818
57996
  }
57819
57997
  const hasHostedProviderKey = HERMES_HOSTED_PROVIDER_KEYS.some((name) => nonEmptyDotenvValue(secrets, name));
57820
57998
  let configuredDefault = null;
57821
57999
  try {
57822
- configuredDefault = hermesConfigDefault(readFileSync30(join49(dir, "config.yaml"), "utf8"));
58000
+ configuredDefault = hermesConfigDefault(readFileSync30(join50(dir, "config.yaml"), "utf8"));
57823
58001
  } catch {
57824
58002
  }
57825
58003
  const configuredProvider = configuredDefault?.provider.toLowerCase() ?? "";
@@ -57864,7 +58042,7 @@ function oauthRowSignedIn(row, now) {
57864
58042
  return present(row.access_token) && notExpired(row, now);
57865
58043
  }
57866
58044
  function hermesSignedInProviders(env = process.env, now = Date.now()) {
57867
- const store = record4(readJson(join49(hermesHome(env), "auth.json")));
58045
+ const store = record4(readJson(join50(hermesHome(env), "auth.json")));
57868
58046
  const out = /* @__PURE__ */ new Set();
57869
58047
  if (!store) return out;
57870
58048
  const providers = record4(store.providers) ?? {};
@@ -57888,7 +58066,7 @@ function hermesZaiCodingPlan(env = process.env) {
57888
58066
  const dir = hermesHome(env);
57889
58067
  let secrets = "";
57890
58068
  try {
57891
- secrets = readFileSync30(join49(dir, ".env"), "utf8");
58069
+ secrets = readFileSync30(join50(dir, ".env"), "utf8");
57892
58070
  } catch {
57893
58071
  }
57894
58072
  const keyed2 = ["GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"].some((name) => present(env[name]) || nonEmptyDotenvValue(secrets, name));
@@ -57896,21 +58074,21 @@ function hermesZaiCodingPlan(env = process.env) {
57896
58074
  const coding = (url2) => typeof url2 === "string" && /\/api\/coding\/paas\//i.test(url2);
57897
58075
  const override = present(env.GLM_BASE_URL) ? env.GLM_BASE_URL : nonEmptyDotenvValue(secrets, "GLM_BASE_URL");
57898
58076
  if (override) return coding(override);
57899
- const detected = record4(record4(record4(record4(readJson(join49(dir, "auth.json")))?.providers)?.zai)?.detected_endpoint);
58077
+ const detected = record4(record4(record4(record4(readJson(join50(dir, "auth.json")))?.providers)?.zai)?.detected_endpoint);
57900
58078
  return coding(detected?.base_url);
57901
58079
  }
57902
58080
  function hermesZaiPlanHosts(options, codingPlan) {
57903
58081
  return codingPlan ? options.map((option) => option.provider === "zai" ? { ...option, provider: "zai-coding-plan" } : option) : [...options];
57904
58082
  }
57905
58083
  function hermesCachedModels(home, provider) {
57906
- const catalog2 = record4(record4(record4(readJson(join49(home, "cache", "model_catalog.json")))?.providers)?.[provider]);
58084
+ const catalog2 = record4(record4(record4(readJson(join50(home, "cache", "model_catalog.json")))?.providers)?.[provider]);
57907
58085
  const name = String(record4(catalog2?.metadata)?.display_name ?? "").trim() || provider;
57908
58086
  const rows = Array.isArray(catalog2?.models) ? catalog2.models.map(record4).filter((row) => row && present(row.id)) : [];
57909
58087
  if (rows.length) {
57910
58088
  const ordered = [...rows.filter((row) => row.default === true), ...rows.filter((row) => row.default !== true)];
57911
58089
  return { ids: ordered.map((row) => String(row.id).trim()), name };
57912
58090
  }
57913
- const cached3 = record4(record4(readJson(join49(home, "provider_models_cache.json")))?.[provider])?.models;
58091
+ const cached3 = record4(record4(readJson(join50(home, "provider_models_cache.json")))?.[provider])?.models;
57914
58092
  return { ids: Array.isArray(cached3) ? cached3.filter(present).map((id) => String(id).trim()) : [], name };
57915
58093
  }
57916
58094
  function hermesAuthStoreModels(env = process.env, now = Date.now()) {
@@ -57928,7 +58106,7 @@ function hermesConfiguredHostModel(env = process.env) {
57928
58106
  const home = hermesHome(env);
57929
58107
  let configured = null;
57930
58108
  try {
57931
- configured = hermesConfigDefault(readFileSync30(join49(home, "config.yaml"), "utf8"));
58109
+ configured = hermesConfigDefault(readFileSync30(join50(home, "config.yaml"), "utf8"));
57932
58110
  } catch {
57933
58111
  return null;
57934
58112
  }
@@ -58044,12 +58222,8 @@ async function resolveHermesModels(env, config2) {
58044
58222
  const listed = new Set(remote.map((o) => o.provider));
58045
58223
  const stored = signedIn.filter((o) => !listed.has(o.provider));
58046
58224
  const seen = /* @__PURE__ */ new Set();
58047
- const listedOptions = [...configured ? [configured] : [], ...hostDefault ? [hostDefault] : [], ...remote, ...stored, ...catalog2.options].filter((o) => {
58048
- if (seen.has(o.id)) return false;
58049
- seen.add(o.id);
58050
- return true;
58051
- });
58052
- const options = hermesZaiPlanHosts(listedOptions, hermesZaiCodingPlan(env));
58225
+ const listedOptions = [...configured ? [configured] : [], ...hostDefault ? [hostDefault] : [], ...remote, ...stored, ...catalog2.options].filter((o) => !seen.has(o.id) && Boolean(seen.add(o.id)));
58226
+ const options = hermesOnlyHosts(hermesZaiPlanHosts(listedOptions, hermesZaiCodingPlan(env)));
58053
58227
  return { default: options[0]?.id ?? "", options };
58054
58228
  }
58055
58229
  async function applySetting2(request, method, params, what) {
@@ -58068,6 +58242,7 @@ var init_hermes = __esm({
58068
58242
  init_spawn_command();
58069
58243
  init_local_inject();
58070
58244
  init_core3();
58245
+ init_hermes_hosts();
58071
58246
  init_hermes_memory_lock();
58072
58247
  EMPTY2 = { default: "", options: [] };
58073
58248
  HERMES_OPENMAUS_SCREENSHOT_COMPAT = "HERMES_OPENMAUS_SCREENSHOT_COMPAT";
@@ -58103,6 +58278,8 @@ var init_hermes = __esm({
58103
58278
  // a longer idle window than the default (a rejected key is caught sooner,
58104
58279
  // from its log, by the core's stderr check).
58105
58280
  promptIdleMs: 3e5,
58281
+ mcpServerLimit: { count: 16, bytes: 56e3 },
58282
+ // its gateway refuses a 17th, or 65536 bytes once it adds its own fields
58106
58283
  loginNote: "Hermes CLI is not installed",
58107
58284
  // No install command: setup never installs Hermes (Erick, 2026-11-08).
58108
58285
  // Nous Research signs in with a Nous Portal API key instead
@@ -58129,12 +58306,7 @@ var init_hermes = __esm({
58129
58306
  async configureSession({ request, sessionId, turn }) {
58130
58307
  const native = hermesAcpModelId(turn.model);
58131
58308
  if (!native) return;
58132
- await applySetting2(
58133
- request,
58134
- "session/set_model",
58135
- { sessionId, modelId: native },
58136
- `model "${native}"`
58137
- );
58309
+ await applySetting2(request, "session/set_model", { sessionId, modelId: native }, `model "${native}"`);
58138
58310
  },
58139
58311
  buildPromptText: (turn) => turn.system ? `${turn.system}
58140
58312
 
@@ -58146,7 +58318,7 @@ ${turn.text}` : turn.text
58146
58318
 
58147
58319
  // server/drivers/acp/custom.ts
58148
58320
  import { homedir as homedir27 } from "node:os";
58149
- import { basename as basename9, join as join50 } from "node:path";
58321
+ import { basename as basename9, join as join51 } from "node:path";
58150
58322
  function isAtomicEngine(instanceId, cli) {
58151
58323
  const program = (cli ?? "").trim().split(/\s+/)[0] ?? "";
58152
58324
  return instanceId === "atomic-engine" || basename9(program) === "atomic";
@@ -58171,7 +58343,7 @@ async function customAcpSnapshot(env, cli, instanceId) {
58171
58343
  return { state: "available", version: version2, authenticated: true };
58172
58344
  }
58173
58345
  function atomicEngineHome2(env) {
58174
- return env.HERMES_HOME || join50(env.HOME || env.USERPROFILE || homedir27(), ".atomic");
58346
+ return env.HERMES_HOME || join51(env.HOME || env.USERPROFILE || homedir27(), ".atomic");
58175
58347
  }
58176
58348
  function applyAtomicEngineAccounts(env, instanceId, cli, accounts = currentAtomicEngineAccounts) {
58177
58349
  if (!isAtomicEngine(instanceId, cli)) return;
@@ -58270,6 +58442,9 @@ var init_custom = __esm({
58270
58442
  throw new Error(`Atomic Engine rejected model "${modelId}" via session/set_model: ${error51.message}`);
58271
58443
  }
58272
58444
  },
58445
+ // A cold Atomic Engine restores a saved session without its local provider
58446
+ // and then posts the prompt to api.anthropic.com: never session/load there.
58447
+ freshSessionForLocalModel: true,
58273
58448
  defaultCli: "",
58274
58449
  nativeSource: "custom.acp",
58275
58450
  loginNote: CONFIGURE_HINT,
@@ -58296,6 +58471,8 @@ var init_custom = __esm({
58296
58471
  driverKind: "atomicEngine",
58297
58472
  displayName: "Atomic Engine",
58298
58473
  defaultCli: DEFAULT_ATOMIC_ENGINE_CLI,
58474
+ // It gives each account 180 s of silence before it moves to its next one, and says nothing over ACP while it does.
58475
+ promptIdleMs: 6e5,
58299
58476
  async configureSession(context) {
58300
58477
  await support11.configureSession?.(context);
58301
58478
  const modeId = context.turn.approvalMode === "plan" ? "atomic-plan-v1" : "default";
@@ -58407,7 +58584,7 @@ var init_ollama_cloud = __esm({
58407
58584
  nativeLog: {
58408
58585
  source: "ollama-cloud.chat.completions",
58409
58586
  outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
58410
- incoming: ({ text: text6, reasoning, usage }) => ({ textLength: text6.length, reasoningLength: reasoning.length, usage })
58587
+ incoming: ({ text: text7, reasoning, usage }) => ({ textLength: text7.length, reasoningLength: reasoning.length, usage })
58411
58588
  }
58412
58589
  });
58413
58590
  }
@@ -58563,8 +58740,8 @@ var init_openai_compat = __esm({
58563
58740
  nativeLog: {
58564
58741
  source: "openai-compat.chat.completions",
58565
58742
  outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
58566
- incoming: ({ text: text6, reasoning, usage }) => ({
58567
- textLength: text6.length,
58743
+ incoming: ({ text: text7, reasoning, usage }) => ({
58744
+ textLength: text7.length,
58568
58745
  reasoningLength: reasoning.length,
58569
58746
  usage
58570
58747
  })
@@ -58576,9 +58753,9 @@ var init_openai_compat = __esm({
58576
58753
  });
58577
58754
 
58578
58755
  // server/drivers/pi.ts
58579
- import { chmodSync as chmodSync7, existsSync as existsSync25, mkdirSync as mkdirSync26, mkdtempSync as mkdtempSync5, readFileSync as readFileSync31, rmSync as rmSync11, writeFileSync as writeFileSync22 } from "node:fs";
58756
+ import { chmodSync as chmodSync7, existsSync as existsSync26, mkdirSync as mkdirSync26, mkdtempSync as mkdtempSync5, readFileSync as readFileSync31, rmSync as rmSync11, writeFileSync as writeFileSync22 } from "node:fs";
58580
58757
  import { homedir as homedir28, tmpdir as tmpdir7 } from "node:os";
58581
- import { join as join51 } from "node:path";
58758
+ import { join as join52 } from "node:path";
58582
58759
  function readPiPromptImages(turn) {
58583
58760
  return (turn.images ?? []).map((image) => ({
58584
58761
  type: "image",
@@ -58700,7 +58877,7 @@ async function applyPiLocalCatalog(catalog2, env = process.env, fetchImpl = fetc
58700
58877
  return preferPiInjectRows(await mergeLocalInject(catalog2, env, fetchImpl));
58701
58878
  }
58702
58879
  function piAgentDir(env) {
58703
- return join51(env.HOME || env.USERPROFILE || homedir28(), ".pi", "agent");
58880
+ return join52(env.HOME || env.USERPROFILE || homedir28(), ".pi", "agent");
58704
58881
  }
58705
58882
  function ensurePiInjectModel(modelId, env = process.env) {
58706
58883
  const split = splitPiModel(modelId);
@@ -58711,9 +58888,9 @@ function ensurePiInjectModel(modelId, env = process.env) {
58711
58888
  if (!host) return split;
58712
58889
  const dir = piAgentDir(env);
58713
58890
  mkdirSync26(dir, { recursive: true });
58714
- const path4 = join51(dir, "models.json");
58891
+ const path4 = join52(dir, "models.json");
58715
58892
  let root = { providers: {} };
58716
- if (existsSync25(path4)) {
58893
+ if (existsSync26(path4)) {
58717
58894
  try {
58718
58895
  const parsed = JSON.parse(readFileSync31(path4, "utf8"));
58719
58896
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
@@ -58931,9 +59108,9 @@ var init_pi = __esm({
58931
59108
  const mcpServers = buildMcpServers(turn);
58932
59109
  let mcpTempDir = null;
58933
59110
  if (mcpServers) {
58934
- mcpTempDir = mkdtempSync5(join51(tmpdir7(), "omb-pi-mcp-"));
59111
+ mcpTempDir = mkdtempSync5(join52(tmpdir7(), "omb-pi-mcp-"));
58935
59112
  try {
58936
- writeFileSync22(join51(mcpTempDir, "mcp.json"), JSON.stringify({ mcpServers }), { mode: 384 });
59113
+ writeFileSync22(join52(mcpTempDir, "mcp.json"), JSON.stringify({ mcpServers }), { mode: 384 });
58937
59114
  } catch (err) {
58938
59115
  try {
58939
59116
  rmSync11(mcpTempDir, { recursive: true, force: true });
@@ -58952,7 +59129,7 @@ var init_pi = __esm({
58952
59129
  env: piEnvironment({
58953
59130
  ...process.env,
58954
59131
  ...input.environment,
58955
- ...mcpServers && mcpTempDir ? { OMB_MCP_CONFIG: join51(mcpTempDir, "mcp.json") } : {}
59132
+ ...mcpServers && mcpTempDir ? { OMB_MCP_CONFIG: join52(mcpTempDir, "mcp.json") } : {}
58956
59133
  })
58957
59134
  });
58958
59135
  } catch (err) {
@@ -58989,10 +59166,10 @@ var init_pi = __esm({
58989
59166
  child.stdin.write(JSON.stringify(obj) + "\n");
58990
59167
  };
58991
59168
  const flushAssistantText = () => {
58992
- const text6 = assistantText;
59169
+ const text7 = assistantText;
58993
59170
  assistantText = "";
58994
- if (!text6.trim()) return;
58995
- emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text6 });
59171
+ if (!text7.trim()) return;
59172
+ emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
58996
59173
  };
58997
59174
  const settle = (ok, stopReason, usage) => {
58998
59175
  if (settled) return;
@@ -59099,7 +59276,7 @@ var init_pi = __esm({
59099
59276
  const mcpTool = isQuestion ? null : piMcpToolRef(
59100
59277
  evt.title,
59101
59278
  customServerNames,
59102
- mcpTempDir ? join51(mcpTempDir, PI_TOOL_HINTS_FILE) : null
59279
+ mcpTempDir ? join52(mcpTempDir, PI_TOOL_HINTS_FILE) : null
59103
59280
  );
59104
59281
  emit({
59105
59282
  ...base3(threadId, turnId),
@@ -59423,7 +59600,7 @@ var init_mistral = __esm({
59423
59600
  nativeLog: {
59424
59601
  source: "mistral.chat.completions",
59425
59602
  outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
59426
- incoming: ({ text: text6, usage }) => ({ textLength: text6.length, usage })
59603
+ incoming: ({ text: text7, usage }) => ({ textLength: text7.length, usage })
59427
59604
  }
59428
59605
  });
59429
59606
  }
@@ -59434,14 +59611,14 @@ var init_mistral = __esm({
59434
59611
  // server/drivers/minimax.ts
59435
59612
  import { readFileSync as readFileSync32 } from "node:fs";
59436
59613
  import { homedir as homedir29 } from "node:os";
59437
- import { join as join52 } from "node:path";
59614
+ import { join as join53 } from "node:path";
59438
59615
  function normalizedApiUrl(value) {
59439
59616
  const root = value.trim().replace(/\/+$/, "");
59440
59617
  return root.endsWith("/v1") ? root : `${root}/v1`;
59441
59618
  }
59442
59619
  function loadLocalMiniMaxConfig(home = homedir29()) {
59443
59620
  try {
59444
- const raw = localConfigSchema.parse(JSON.parse(readFileSync32(join52(home, ".mmx", "config.json"), "utf8")));
59621
+ const raw = localConfigSchema.parse(JSON.parse(readFileSync32(join53(home, ".mmx", "config.json"), "utf8")));
59445
59622
  const configuredUrl = raw.base_url?.trim() ? raw.base_url : raw.region === "cn" ? CN_URL : DEFAULT_URL3;
59446
59623
  return {
59447
59624
  apiKey: raw.api_key?.trim() ?? "",
@@ -59537,7 +59714,7 @@ var init_minimax = __esm({
59537
59714
  nativeLog: {
59538
59715
  source: "minimax.chat.completions",
59539
59716
  outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
59540
- incoming: ({ text: text6, usage }) => ({ textLength: text6.length, usage })
59717
+ incoming: ({ text: text7, usage }) => ({ textLength: text7.length, usage })
59541
59718
  }
59542
59719
  });
59543
59720
  }
@@ -59548,7 +59725,7 @@ var init_minimax = __esm({
59548
59725
  // server/apple-intelligence.ts
59549
59726
  import { spawn as spawn8 } from "node:child_process";
59550
59727
  import { accessSync, constants as constants3 } from "node:fs";
59551
- import { join as join53 } from "node:path";
59728
+ import { join as join54 } from "node:path";
59552
59729
  function intelligenceErrorMessage(code) {
59553
59730
  return MESSAGES[code] ?? `Apple Intelligence failed (${code}).`;
59554
59731
  }
@@ -59556,9 +59733,9 @@ function resolveIntelligenceHelper(env = process.env, platform = process.platfor
59556
59733
  if (platform !== "darwin" || arch !== "arm64") return null;
59557
59734
  const candidates = [
59558
59735
  env.ATOMIC_INTELLIGENCE_HELPER,
59559
- env.OMB_RESOURCES_PATH && join53(env.OMB_RESOURCES_PATH, HELPER),
59560
- join53(serverRoot, "..", HELPER),
59561
- join53(serverRoot, "..", "dist-native", "arm64", HELPER)
59736
+ env.OMB_RESOURCES_PATH && join54(env.OMB_RESOURCES_PATH, HELPER),
59737
+ join54(serverRoot, "..", HELPER),
59738
+ join54(serverRoot, "..", "dist-native", "arm64", HELPER)
59562
59739
  ];
59563
59740
  for (const candidate of candidates) {
59564
59741
  if (!candidate) continue;
@@ -59746,7 +59923,7 @@ var init_apple_intelligence = __esm({
59746
59923
  "concurrent-requests": "Apple Intelligence is busy. Try again in a moment.",
59747
59924
  "timeout": "Apple Intelligence took too long to answer."
59748
59925
  };
59749
- HELPER = join53("Atomic Intelligence.app", "Contents", "MacOS", "intelligence-helper");
59926
+ HELPER = join54("Atomic Intelligence.app", "Contents", "MacOS", "intelligence-helper");
59750
59927
  }
59751
59928
  });
59752
59929
 
@@ -59816,9 +59993,9 @@ function createAppleIntelligenceInstance(input, deps = {}) {
59816
59993
  let failure;
59817
59994
  try {
59818
59995
  const request = shapeRequest(turn, inputBudget(availability.contextSize));
59819
- const text6 = await client.stream(request, (delta) => emit({ ...base3(turn.threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta }), abort.signal);
59820
- if (!text6.trim()) throw new Error("Apple Intelligence returned an empty response.");
59821
- emit({ ...base3(turn.threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text6 });
59996
+ const text7 = await client.stream(request, (delta) => emit({ ...base3(turn.threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta }), abort.signal);
59997
+ if (!text7.trim()) throw new Error("Apple Intelligence returned an empty response.");
59998
+ emit({ ...base3(turn.threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
59822
59999
  ok = true;
59823
60000
  } catch (error51) {
59824
60001
  failure = error51 instanceof Error ? error51.message : String(error51);
@@ -59895,10 +60072,10 @@ var init_apple_intelligence2 = __esm({
59895
60072
  INPUT_TOKEN_BUDGET = 6e3;
59896
60073
  REPLY_TOKENS = 1500;
59897
60074
  CHARS_PER_TOKEN = 4;
59898
- estimateTokens = (text6) => Math.ceil(text6.length / CHARS_PER_TOKEN);
59899
- clip = (text6, tokens) => {
60075
+ estimateTokens = (text7) => Math.ceil(text7.length / CHARS_PER_TOKEN);
60076
+ clip = (text7, tokens) => {
59900
60077
  const chars = Math.max(0, tokens * CHARS_PER_TOKEN);
59901
- return text6.length <= chars ? text6 : `${text6.slice(0, Math.max(0, chars - 1))}\u2026`;
60078
+ return text7.length <= chars ? text7 : `${text7.slice(0, Math.max(0, chars - 1))}\u2026`;
59902
60079
  };
59903
60080
  configSchema4 = external_exports.object({}).passthrough();
59904
60081
  AppleIntelligenceDriver = {
@@ -60105,7 +60282,7 @@ __export(cli_setup_exports, {
60105
60282
  });
60106
60283
  import { spawn as spawn9 } from "node:child_process";
60107
60284
  import { readFileSync as readFileSync33 } from "node:fs";
60108
- import { join as join54, resolve as resolve12 } from "node:path";
60285
+ import { join as join55, resolve as resolve12 } from "node:path";
60109
60286
  import { randomUUID as randomUUID17 } from "node:crypto";
60110
60287
  async function inspect2(id, entry) {
60111
60288
  const registry2 = new ProviderRegistry(BUILT_IN_DRIVERS);
@@ -60142,7 +60319,7 @@ function assertDataDir(dataDir) {
60142
60319
  }
60143
60320
  function checkStoredConfig(dataDir) {
60144
60321
  try {
60145
- parseStoredConfig(JSON.parse(readFileSync33(join54(dataDir, "config.json"), "utf8")));
60322
+ parseStoredConfig(JSON.parse(readFileSync33(join55(dataDir, "config.json"), "utf8")));
60146
60323
  } catch (error51) {
60147
60324
  if (error51.code === "ENOENT") return;
60148
60325
  throw new Error("Existing config.json could not be read or validated. Setup has not changed it; repair it before continuing.");
@@ -60554,9 +60731,9 @@ async function runTerminal(options, io2) {
60554
60731
  var import_qrcode_terminal = __toESM(require_main(), 1);
60555
60732
  import { spawn as spawn10 } from "node:child_process";
60556
60733
  import { randomBytes as randomBytes4 } from "node:crypto";
60557
- import { closeSync as closeSync6, existsSync as existsSync26, mkdirSync as mkdirSync27, openSync as openSync6, readFileSync as readFileSync34 } from "node:fs";
60734
+ import { closeSync as closeSync7, existsSync as existsSync27, mkdirSync as mkdirSync27, openSync as openSync7, readFileSync as readFileSync34 } from "node:fs";
60558
60735
  import { homedir as homedir30 } from "node:os";
60559
- import { dirname as dirname13, join as join55, resolve as resolve13 } from "node:path";
60736
+ import { dirname as dirname13, join as join56, resolve as resolve13 } from "node:path";
60560
60737
  import { createInterface as createInterface2 } from "node:readline/promises";
60561
60738
  import { fileURLToPath as fileURLToPath3 } from "node:url";
60562
60739
 
@@ -61189,10 +61366,10 @@ async function verifyHostedEndpoint(endpoint, { fetchImpl, timeoutSignal, timeou
61189
61366
  signal: cancellationSignal ? AbortSignal.any([requestSignal, cancellationSignal]) : requestSignal
61190
61367
  });
61191
61368
  if (!response.ok) return false;
61192
- const text6 = await response.text();
61193
- if (Buffer.byteLength(text6) > 4096) return false;
61369
+ const text7 = await response.text();
61370
+ if (Buffer.byteLength(text7) > 4096) return false;
61194
61371
  try {
61195
- return JSON.parse(text6)?.app === "openmausbot";
61372
+ return JSON.parse(text7)?.app === "openmausbot";
61196
61373
  } catch {
61197
61374
  return false;
61198
61375
  }
@@ -62105,8 +62282,8 @@ function isSecretParameter(name) {
62105
62282
  function keyLikeSegment(segment) {
62106
62283
  return (segment.match(/[A-Za-z0-9]{16,}/g) ?? []).some((run2) => /\d/.test(run2) && /[A-Za-z]/.test(run2));
62107
62284
  }
62108
- function maskUrlSecrets(text6) {
62109
- return text6.replace(/\b([a-z][\w+.-]*:\/\/)([^\s/?#]*)([^\s?#]*)([^\s]*)/gi, (_all, scheme, authority, path4, rest) => {
62285
+ function maskUrlSecrets(text7) {
62286
+ return text7.replace(/\b([a-z][\w+.-]*:\/\/)([^\s/?#]*)([^\s?#]*)([^\s]*)/gi, (_all, scheme, authority, path4, rest) => {
62110
62287
  const at2 = authority.lastIndexOf("@");
62111
62288
  const host = at2 >= 0 ? `${HIDDEN}@${authority.slice(at2 + 1)}` : authority;
62112
62289
  const maskedPath = path4.split("/").map((segment) => keyLikeSegment(segment) ? HIDDEN : segment).join("/");
@@ -62144,8 +62321,8 @@ function auditValues(values) {
62144
62321
  const last = segments.at(-1) ?? path4;
62145
62322
  const opaque = segments.slice(0, -1).some((segment) => OPAQUE_MAP.test(segment));
62146
62323
  const scrubbed = (isSecretName3(last) || opaque) && value !== void 0 && value !== null && value !== "" ? HIDDEN : scrub(value, 0, OPAQUE_MAP.test(last));
62147
- const text6 = JSON.stringify(scrubbed);
62148
- out[path4] = text6 !== void 0 && text6.length > MAX_VALUE_CHARS ? "[large value]" : scrubbed ?? null;
62324
+ const text7 = JSON.stringify(scrubbed);
62325
+ out[path4] = text7 !== void 0 && text7.length > MAX_VALUE_CHARS ? "[large value]" : scrubbed ?? null;
62149
62326
  }
62150
62327
  return out;
62151
62328
  }
@@ -62539,9 +62716,9 @@ async function startCaddy(options) {
62539
62716
  });
62540
62717
  let output = "";
62541
62718
  const receive = (chunk) => {
62542
- const text6 = chunk.toString("utf8");
62543
- if (output.length < 16384) output += text6;
62544
- for (const line of text6.split(/\r?\n/)) {
62719
+ const text7 = chunk.toString("utf8");
62720
+ if (output.length < 16384) output += text7;
62721
+ for (const line of text7.split(/\r?\n/)) {
62545
62722
  if (!line.trim()) continue;
62546
62723
  if (/"level":"(warn|error)"/.test(line) || /^\S+\s+(WARN|ERROR)/.test(line) || !line.startsWith("{")) options.log?.(`caddy: ${line.slice(0, 400)}`);
62547
62724
  }
@@ -62893,16 +63070,16 @@ var TEXT_COLORS = {
62893
63070
  dark: { accent: [[0, 179, 152], 36], gold: [[242, 169, 0], 214] },
62894
63071
  unknown: { accent: [[0, 128, 108], 30], gold: [[168, 100, 0], 130] }
62895
63072
  };
62896
- function paint(text6, role, depth, background, bold) {
62897
- if (depth === "none") return text6;
63073
+ function paint(text7, role, depth, background, bold) {
63074
+ if (depth === "none") return text7;
62898
63075
  const weight = bold ? "1;" : "";
62899
- if (depth === "16") return `\x1B[${weight}${role === "accent" ? 36 : 33}m${text6}\x1B[0m`;
63076
+ if (depth === "16") return `\x1B[${weight}${role === "accent" ? 36 : 33}m${text7}\x1B[0m`;
62900
63077
  const [triple, index] = TEXT_COLORS[background][role];
62901
- if (depth === "256") return `\x1B[${weight}38;5;${index}m${text6}\x1B[0m`;
62902
- return `\x1B[${weight}38;2;${triple.join(";")}m${text6}\x1B[0m`;
63078
+ if (depth === "256") return `\x1B[${weight}38;5;${index}m${text7}\x1B[0m`;
63079
+ return `\x1B[${weight}38;2;${triple.join(";")}m${text7}\x1B[0m`;
62903
63080
  }
62904
- function quiet(text6, depth) {
62905
- return depth === "none" ? text6 : `\x1B[2m${text6}\x1B[0m`;
63081
+ function quiet(text7, depth) {
63082
+ return depth === "none" ? text7 : `\x1B[2m${text7}\x1B[0m`;
62906
63083
  }
62907
63084
  function renderBanner(input) {
62908
63085
  const random = input.random ?? Math.random;
@@ -62910,7 +63087,7 @@ function renderBanner(input) {
62910
63087
  const greeting = pick2(GREETINGS);
62911
63088
  const tip = pick2(TIPS);
62912
63089
  const { depth, background } = input;
62913
- const text6 = [
63090
+ const text7 = [
62914
63091
  `${paint("Atomic", "accent", depth, background, true)} by Chibitek`,
62915
63092
  quiet(`Version ${input.version}`, depth),
62916
63093
  input.account ? `Signed in as ${input.account}` : quiet("Not signed in to an Atomic account", depth),
@@ -62919,19 +63096,19 @@ function renderBanner(input) {
62919
63096
  `${paint("Tip:", "gold", depth, background, true)} ${tip}`
62920
63097
  ];
62921
63098
  const columns = input.columns ?? 80;
62922
- if (columns < 20) return `${text6.join("\n")}
63099
+ if (columns < 20) return `${text7.join("\n")}
62923
63100
  `;
62924
63101
  const mark = chibiAnsiLines(depth, background === "light" ? "light" : "dark");
62925
63102
  const widest = Math.max(...[greeting, `Tip: ${tip}`, input.account ? `Signed in as ${input.account}` : ""].map((l) => l.length));
62926
63103
  if (columns < 16 + 3 + Math.min(widest, 44)) return `${mark.map((line) => line.trimEnd()).join("\n")}
62927
63104
 
62928
- ${text6.join("\n")}
63105
+ ${text7.join("\n")}
62929
63106
  `;
62930
- const rows = Math.max(mark.length, text6.length);
63107
+ const rows = Math.max(mark.length, text7.length);
62931
63108
  const lines = [];
62932
63109
  for (let i2 = 0; i2 < rows; i2 += 1) {
62933
63110
  const left = mark[i2] ?? " ".repeat(16);
62934
- const right = text6[i2] ?? "";
63111
+ const right = text7[i2] ?? "";
62935
63112
  lines.push(right ? `${left} ${right}` : left.trimEnd());
62936
63113
  }
62937
63114
  return `${lines.join("\n")}
@@ -63017,8 +63194,8 @@ function agentUnit(spec) {
63017
63194
  function emptyRegistry(domain2) {
63018
63195
  return { version: 1, domain: domain2, nextPort: FLEET_FIRST_PORT, workspaces: {} };
63019
63196
  }
63020
- function parseRegistry(text6) {
63021
- const value = JSON.parse(text6);
63197
+ function parseRegistry(text7) {
63198
+ const value = JSON.parse(text7);
63022
63199
  const record6 = value && typeof value === "object" ? value : null;
63023
63200
  if (!record6 || record6.version !== 1 || typeof record6.domain !== "string" || typeof record6.nextPort !== "number" || !record6.workspaces || typeof record6.workspaces !== "object") {
63024
63201
  throw new Error("fleet.json is not a fleet registry this version understands");
@@ -63623,14 +63800,14 @@ async function executePlan(steps, deps, io2) {
63623
63800
  }
63624
63801
  function failed(io2, what, output) {
63625
63802
  io2.error(`fleet: could not ${what}`);
63626
- const tail2 = output.trim().split("\n").slice(-6).join("\n");
63627
- if (tail2) io2.error(tail2);
63803
+ const tail3 = output.trim().split("\n").slice(-6).join("\n");
63804
+ if (tail3) io2.error(tail3);
63628
63805
  return 1;
63629
63806
  }
63630
63807
  function loadRegistry(layout, deps) {
63631
- const text6 = deps.readText(layout.registryFile);
63632
- if (text6 === null) throw new Error(`no fleet on this server yet: run \`chibi fleet init --domain your.domain\` first`);
63633
- return parseRegistry(text6);
63808
+ const text7 = deps.readText(layout.registryFile);
63809
+ if (text7 === null) throw new Error(`no fleet on this server yet: run \`chibi fleet init --domain your.domain\` first`);
63810
+ return parseRegistry(text7);
63634
63811
  }
63635
63812
  function planFleetAction(input, deps) {
63636
63813
  const layout = fleetLayout(input.root ?? "/");
@@ -63804,15 +63981,15 @@ import { dirname as dirname5 } from "node:path";
63804
63981
  var MAX_BODY = 256 * 1024;
63805
63982
  function readBody(req) {
63806
63983
  return new Promise((resolve14, reject) => {
63807
- let text6 = "";
63984
+ let text7 = "";
63808
63985
  req.on("data", (chunk) => {
63809
- text6 += chunk.toString("utf8");
63810
- if (text6.length > MAX_BODY) reject(Object.assign(new Error("request too large"), { status: 413 }));
63986
+ text7 += chunk.toString("utf8");
63987
+ if (text7.length > MAX_BODY) reject(Object.assign(new Error("request too large"), { status: 413 }));
63811
63988
  });
63812
63989
  req.on("end", () => {
63813
- if (!text6.trim()) return resolve14({});
63990
+ if (!text7.trim()) return resolve14({});
63814
63991
  try {
63815
- const value = JSON.parse(text6);
63992
+ const value = JSON.parse(text7);
63816
63993
  resolve14(value && typeof value === "object" && !Array.isArray(value) ? value : {});
63817
63994
  } catch {
63818
63995
  reject(Object.assign(new Error("body must be JSON"), { status: 400 }));
@@ -64029,8 +64206,8 @@ function tailnetNameBlocksHttps(name) {
64029
64206
 
64030
64207
  // server/tailscale.ts
64031
64208
  init_procs();
64032
- function classifyTailscaleStderr(text6) {
64033
- const t2 = text6.toLowerCase();
64209
+ function classifyTailscaleStderr(text7) {
64210
+ const t2 = text7.toLowerCase();
64034
64211
  if (/not logged in|logged out|needs login|please log in/.test(t2)) return "not-logged-in";
64035
64212
  if (/is tailscale running|tailscaled is not running|connection refused|failed to connect to local tailscaled/.test(t2)) return "not-running";
64036
64213
  if (/rejectedidentifier|reserved format|r-ldh/.test(t2)) return "reserved-name";
@@ -64485,7 +64662,7 @@ function parseArgs2(argv, env = process.env) {
64485
64662
  const options = {
64486
64663
  command: command === "--help" || command === "-h" ? "help" : command,
64487
64664
  port: Number(env.OMB_PORT || 8799),
64488
- dataDir: env.OMB_DATA_DIR || join55(homedir30(), ".atomic-app"),
64665
+ dataDir: env.OMB_DATA_DIR || join56(homedir30(), ".atomic-app"),
64489
64666
  tailscale: false,
64490
64667
  tunnel: false,
64491
64668
  client: false,
@@ -64626,7 +64803,7 @@ async function isWorkspaceRunning(options) {
64626
64803
  try {
64627
64804
  const { status, body } = await api(options.port, "/api/health");
64628
64805
  if (status !== 200 || body?.app !== "openmausbot") return false;
64629
- const expected = readFileSync34(join55(options.dataDir, "environment-id"), "utf8").trim();
64806
+ const expected = readFileSync34(join56(options.dataDir, "environment-id"), "utf8").trim();
64630
64807
  const descriptor = await api(options.port, "/.well-known/openmausbot/environment");
64631
64808
  return /^[0-9a-f-]{36}$/i.test(expected) && descriptor.status === 200 && descriptor.body?.environmentId === expected;
64632
64809
  } catch {
@@ -64738,9 +64915,9 @@ function originOf(link) {
64738
64915
  return null;
64739
64916
  }
64740
64917
  }
64741
- function qrToString(text6) {
64918
+ function qrToString(text7) {
64742
64919
  let out = "";
64743
- import_qrcode_terminal.default.generate(text6, { small: true }, (rendered) => {
64920
+ import_qrcode_terminal.default.generate(text7, { small: true }, (rendered) => {
64744
64921
  out = rendered;
64745
64922
  });
64746
64923
  return out;
@@ -64865,9 +65042,9 @@ async function runStatus(options, io2 = defaultIo()) {
64865
65042
  return code;
64866
65043
  }
64867
65044
  async function runAccess(options, io2 = defaultIo()) {
64868
- const file2 = join55(options.dataDir, "config.json");
65045
+ const file2 = join56(options.dataDir, "config.json");
64869
65046
  let raw = {};
64870
- if (existsSync26(file2)) {
65047
+ if (existsSync27(file2)) {
64871
65048
  try {
64872
65049
  const parsed = JSON.parse(readFileSync34(file2, "utf8"));
64873
65050
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("not an object");
@@ -64996,16 +65173,16 @@ async function runLogout(options, io2 = defaultIo()) {
64996
65173
  return 0;
64997
65174
  }
64998
65175
  function serverEntry(here = HERE2) {
64999
- const bundled = join55(here, "index.js");
65176
+ const bundled = join56(here, "index.js");
65000
65177
  const root = resolve13(here, "..");
65001
- if (existsSync26(bundled)) {
65002
- const staticDir2 = [join55(root, "dist"), join55(here, "..", "ui")].find((d) => existsSync26(join55(d, "index.html"))) ?? null;
65003
- const skillsDir = existsSync26(join55(root, "skills")) ? join55(root, "skills") : null;
65178
+ if (existsSync27(bundled)) {
65179
+ const staticDir2 = [join56(root, "dist"), join56(here, "..", "ui")].find((d) => existsSync27(join56(d, "index.html"))) ?? null;
65180
+ const skillsDir = existsSync27(join56(root, "skills")) ? join56(root, "skills") : null;
65004
65181
  return { command: process.execPath, args: [bundled], staticDir: staticDir2, skillsDir };
65005
65182
  }
65006
- const source2 = join55(here, "index.ts");
65007
- const staticDir = existsSync26(join55(root, "dist", "index.html")) ? join55(root, "dist") : null;
65008
- return { command: process.execPath, args: ["--experimental-strip-types", source2], staticDir, skillsDir: existsSync26(join55(root, "skills")) ? join55(root, "skills") : null };
65183
+ const source2 = join56(here, "index.ts");
65184
+ const staticDir = existsSync27(join56(root, "dist", "index.html")) ? join56(root, "dist") : null;
65185
+ return { command: process.execPath, args: ["--experimental-strip-types", source2], staticDir, skillsDir: existsSync27(join56(root, "skills")) ? join56(root, "skills") : null };
65009
65186
  }
65010
65187
  async function planTunnel(options, log) {
65011
65188
  let access2 = null;
@@ -65048,7 +65225,7 @@ async function runServe(options, log = console.log) {
65048
65225
  console.error(`something already answers on http://127.0.0.1:${options.port}; use \`chibi pair\` against it, or --port for a second server`);
65049
65226
  return 1;
65050
65227
  }
65051
- if (await reportBusyPort(options.port, options.dataDir === join55(homedir30(), ".atomic-app") ? "" : ` --data-dir ${options.dataDir}`)) return 1;
65228
+ if (await reportBusyPort(options.port, options.dataDir === join56(homedir30(), ".atomic-app") ? "" : ` --data-dir ${options.dataDir}`)) return 1;
65052
65229
  let publicUrl = options.publicUrl;
65053
65230
  let tailscale = null;
65054
65231
  if (options.tailscale) {
@@ -65110,10 +65287,10 @@ async function runServe(options, log = console.log) {
65110
65287
  let child;
65111
65288
  try {
65112
65289
  if (options.guided) {
65113
- const logsDir = join55(options.dataDir, "logs");
65290
+ const logsDir = join56(options.dataDir, "logs");
65114
65291
  mkdirSync27(logsDir, { recursive: true, mode: 448 });
65115
- logPath = join55(logsDir, `server-${Date.now()}-${process.pid}.log`);
65116
- logFd = openSync6(logPath, "wx", 384);
65292
+ logPath = join56(logsDir, `server-${Date.now()}-${process.pid}.log`);
65293
+ logFd = openSync7(logPath, "wx", 384);
65117
65294
  log("\nStarting your workspace\u2026");
65118
65295
  }
65119
65296
  if (tailscale) {
@@ -65144,7 +65321,7 @@ async function runServe(options, log = console.log) {
65144
65321
  }
65145
65322
  throw error51;
65146
65323
  } finally {
65147
- if (logFd !== void 0) closeSync6(logFd);
65324
+ if (logFd !== void 0) closeSync7(logFd);
65148
65325
  process.removeListener("SIGINT", cancelStartup);
65149
65326
  process.removeListener("SIGTERM", cancelStartup);
65150
65327
  }
@@ -65316,7 +65493,7 @@ async function runOnboardingCommand(options, io2 = defaultIo(), startServer = ru
65316
65493
  saveCliStartup2(options.dataDir, startupPreferences(launch));
65317
65494
  }
65318
65495
  if (options.command === "setup") {
65319
- const flags = [options.dataDir !== join55(homedir30(), ".atomic-app") && ` --data-dir ${options.dataDir}`, options.port !== 8799 && ` --port ${options.port}`].filter(Boolean).join("");
65496
+ const flags = [options.dataDir !== join56(homedir30(), ".atomic-app") && ` --data-dir ${options.dataDir}`, options.port !== 8799 && ` --port ${options.port}`].filter(Boolean).join("");
65320
65497
  io2.log(`
65321
65498
  All set. Start with: chibi${flags ? ` start${flags}` : ""} (or npx @chibitek/chibi without a global install).`);
65322
65499
  return 0;
@@ -65356,15 +65533,15 @@ ${welcomeBanner(options)}
65356
65533
  switch (options.command) {
65357
65534
  case "command":
65358
65535
  case "goal": {
65359
- const text6 = options.command === "goal" ? `/goal ${options.commandText}` : options.commandText;
65360
- const roomGoal = options.groupId ? /^\/goal(?:\s+([\s\S]*))?$/.exec(text6 ?? "") : null;
65536
+ const text7 = options.command === "goal" ? `/goal ${options.commandText}` : options.commandText;
65537
+ const roomGoal = options.groupId ? /^\/goal(?:\s+([\s\S]*))?$/.exec(text7 ?? "") : null;
65361
65538
  if (roomGoal && (!roomGoal[1]?.trim() || (roomGoal[1].startsWith("--") || /^(status|pause|resume|stop|help)(?:\s|$)/.test(roomGoal[1])))) {
65362
65539
  console.error("Room goals accept an objective. Personal goal controls and budgets require --bot.");
65363
65540
  return 2;
65364
65541
  }
65365
65542
  const result = await api(options.port, `/api/${options.groupId ? "groups" : "bots"}/${encodeURIComponent(options.groupId ?? options.botId)}/messages`, {
65366
65543
  method: "POST",
65367
- body: JSON.stringify({ threadId: options.threadId, text: roomGoal ? roomGoal[1] : text6, ...roomGoal ? { mode: "goal" } : {}, sendId: randomBytes4(16).toString("hex") })
65544
+ body: JSON.stringify({ threadId: options.threadId, text: roomGoal ? roomGoal[1] : text7, ...roomGoal ? { mode: "goal" } : {}, sendId: randomBytes4(16).toString("hex") })
65368
65545
  });
65369
65546
  if (result.status >= 400) {
65370
65547
  console.error(result.body.error ?? `Server returned ${result.status}`);