@chibitek/chibi 0.1.161 → 0.1.168

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 (100) hide show
  1. package/dist/assets/{abnfDiagram-O67JEVCF-Bb-Unz3V.js → abnfDiagram-O67JEVCF-DUyzT6Xq.js} +1 -1
  2. package/dist/assets/{arc-HBMH7B4K.js → arc-B4-kO642.js} +1 -1
  3. package/dist/assets/{architectureDiagram-NJMV4G6O-CYwkb2PE.js → architectureDiagram-NJMV4G6O-DgKdnNL2.js} +1 -1
  4. package/dist/assets/{blockDiagram-BEXU5L5S-DPYYNxBH.js → blockDiagram-BEXU5L5S-B6oV3kDr.js} +1 -1
  5. package/dist/assets/{c4Diagram-YGBWAQC7-DZ9hKDlA.js → c4Diagram-YGBWAQC7-Dp0E43jx.js} +1 -1
  6. package/dist/assets/channel-BidDehbw.js +1 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-OKrUlts6.js → chunk-2Q5K7J3B-Cfv1WVUo.js} +1 -1
  8. package/dist/assets/{chunk-3FUC2YCW-Tuur0lqz.js → chunk-3FUC2YCW-_-STY2yO.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-BL8QOZeP.js → chunk-5VM5RSS4-C6MZm1cm.js} +1 -1
  10. package/dist/assets/{chunk-GTNCS2PH-DMi8-ixt.js → chunk-GTNCS2PH-C__aVIJy.js} +1 -1
  11. package/dist/assets/{chunk-GWA4HPMP-Dd7yNJ0G.js → chunk-GWA4HPMP-fSrARJuB.js} +1 -1
  12. package/dist/assets/{chunk-JWPE2WC7-g2dOoIMX.js → chunk-JWPE2WC7-CJioJB6h.js} +1 -1
  13. package/dist/assets/{chunk-NETBCI7D-Cum7feOh.js → chunk-NETBCI7D-o6MBGCq_.js} +1 -1
  14. package/dist/assets/{chunk-WEXAMYUT-BzCC1jc4.js → chunk-WEXAMYUT-O-TFLbdc.js} +1 -1
  15. package/dist/assets/{chunk-XXDRQBXY-Ck63jUMo.js → chunk-XXDRQBXY-DYS9CQbl.js} +1 -1
  16. package/dist/assets/{classDiagram-v2-NBCMYWYE-DFSuRVMZ.js → classDiagram-v2-NBCMYWYE-BC4bSH09.js} +1 -1
  17. package/dist/assets/{cose-bilkent-JH36ORCC-CegRj_kY.js → cose-bilkent-JH36ORCC-7NKuC3-C.js} +1 -1
  18. package/dist/assets/{cynefin-OW5HDTMX-cZS_kt1A.js → cynefin-OW5HDTMX-CuWv5cOw.js} +1 -1
  19. package/dist/assets/{cynefinDiagram-VND7K2PF-DfQa9Rht.js → cynefinDiagram-VND7K2PF-D_l_JrG5.js} +1 -1
  20. package/dist/assets/{dagre-6A5THRUB-DJ9qftJu.js → dagre-6A5THRUB-D7eucSmr.js} +1 -1
  21. package/dist/assets/{diagram-22UHCM2B-KXUGUahJ.js → diagram-22UHCM2B-CADR5v1e.js} +1 -1
  22. package/dist/assets/{diagram-3UASUU5V-BudCYrCp.js → diagram-3UASUU5V-DF_fBOZn.js} +1 -1
  23. package/dist/assets/{diagram-ATOU4E4O-Du2O03NS.js → diagram-ATOU4E4O-DE5p59WH.js} +1 -1
  24. package/dist/assets/{diagram-CDSNMT55-DXybXGYf.js → diagram-CDSNMT55-vthvYooA.js} +1 -1
  25. package/dist/assets/{diagram-MLGK6HIB-DfrknXGE.js → diagram-MLGK6HIB-ByMHy4S-.js} +1 -1
  26. package/dist/assets/{diagram-MPIPVDR6-C29FmaJm.js → diagram-MPIPVDR6-C9hKBUnO.js} +1 -1
  27. package/dist/assets/{ebnfDiagram-ZINNZB2B-BF9wS0Nz.js → ebnfDiagram-ZINNZB2B-Djv6hWEl.js} +1 -1
  28. package/dist/assets/{elk-276RUBZZ-B2Fah1VF.js → elk-276RUBZZ-CmUjf18z.js} +1 -1
  29. package/dist/assets/{erDiagram-OPXOYQCR-Di3q4bpF.js → erDiagram-OPXOYQCR-DkmXQUok.js} +1 -1
  30. package/dist/assets/{flowDiagram-KWPJA3E3-D1UiqwbF.js → flowDiagram-KWPJA3E3-6pz2poYn.js} +1 -1
  31. package/dist/assets/{ganttDiagram-FUAMR5RP-BjZqMt7o.js → ganttDiagram-FUAMR5RP-Cx9Fbw75.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-X574FWY7-DiZtdip7.js → gitGraphDiagram-X574FWY7-BR5MsYkP.js} +1 -1
  33. package/dist/assets/{index-dbQveHan.js → index-BoF5cGZq.js} +1 -1
  34. package/dist/assets/index-COwCaN7p.css +1 -0
  35. package/dist/assets/{index-XFwW09vd.js → index-Ckv52eaP.js} +191 -192
  36. package/dist/assets/{infoDiagram-VRGFBTTK-BJUJCgio.js → infoDiagram-VRGFBTTK-DoF183Am.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-BX0XdHUx.js → ishikawaDiagram-OU5B5YK6-4T_-hM1-.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-Bg904IIx.js → journeyDiagram-ZHPQQLJL-Ca0T3Ngd.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-hkZMFMHZ.js → kanban-definition-PNTS6WVX-DNp_DAr9.js} +1 -1
  40. package/dist/assets/{linear-Bh29RTbQ.js → linear-COUoS2bF.js} +1 -1
  41. package/dist/assets/{mermaid.core-aqB1jW_w.js → mermaid.core-DQHowMIV.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-D5GMV-Zd.js → mindmap-definition-NLK3R4M7-CMgO1Mkh.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-7_wFtkFH.js → pegDiagram-GJSIUBJH-BCVCZbsq.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-DXtZBQ4f.js → pieDiagram-5QR66LMP-DxaMlX62.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-C1v3ydTF.js → quadrantDiagram-O4NWA36T-qUD0pkur.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-CLmhiOXg.js → railroadDiagram-XR7U4H2S-Dc6rcAJB.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-BKxI2rh_.js → requirementDiagram-PLB6GJNP-DMTfI_lR.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-gKK-Qs7b.js → sankeyDiagram-IPEJSGJF-B0BWZys8.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-BT94Uowp.js → sequenceDiagram-PO4LG4MO-DZVt17mL.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-RDJL6sCM.js → sizeCapture-INFHLROL-BFQztpNW.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-DqHMzv-J.js → stateDiagram-v2-GCMORJYK-GeFCVCDr.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-B-NN0ql6.js → swimlanes-2SLR337P-DTqQXTvP.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-CRQqFEdH.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-C51S9tpN.js → timeline-definition-EJHVYXUP-BoiNrkP7.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-DyfNMmhq.js → usecaseDiagram-POWQR4AR-CdfsSO2g.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U-D924r33S.js → vennDiagram-UO4OBE2U-CHc_Fn1O.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-DXSfsjUr.js → wardleyDiagram-VNRHLVJA-Bv3KWVEF.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-mYX9tnBU.js → xychartDiagram-PMCCYNJV-CQFknLPS.js} +1 -1
  59. package/dist/handbook/atomic-handbook.html +5 -0
  60. package/dist/index.html +2 -2
  61. package/dist-server/container-mcp.js +12 -6
  62. package/dist-server/drivers/agents-proxy.js +65 -41
  63. package/dist-server/index.js +5302 -4653
  64. package/dist-server/openmausbot.js +506 -288
  65. package/dist-server/pair-cli.js +506 -288
  66. package/dist-server/server/auto-approve.js +4 -1
  67. package/dist-server/server/brand.js +11 -0
  68. package/dist-server/server/config.js +19 -24
  69. package/dist-server/server/connection-credential.js +59 -0
  70. package/dist-server/server/container-computer.js +5 -26
  71. package/dist-server/server/credential-card-request.js +52 -0
  72. package/dist-server/server/dictation.js +6 -3
  73. package/dist-server/server/drivers/agents-call.js +3 -23
  74. package/dist-server/server/drivers/agents-catalog.js +2 -20
  75. package/dist-server/server/drivers/agents-credential.js +57 -0
  76. package/dist-server/server/drivers/builtIn.js +9 -1
  77. package/dist-server/server/drivers/claude-elicitation.js +76 -0
  78. package/dist-server/server/drivers/claude-stdin.js +47 -0
  79. package/dist-server/server/drivers/claude.js +23 -39
  80. package/dist-server/server/drivers/codex-elicitation.js +93 -0
  81. package/dist-server/server/drivers/codex.js +41 -107
  82. package/dist-server/server/engine-platform-fleet.js +32 -0
  83. package/dist-server/server/external-room.js +24 -0
  84. package/dist-server/server/index.js +105 -116
  85. package/dist-server/server/mcp-elicitation.js +120 -0
  86. package/dist-server/server/mcp-http.js +52 -2
  87. package/dist-server/server/mcp-probe.js +3 -0
  88. package/dist-server/server/peer-roster.js +43 -0
  89. package/dist-server/server/phone-secret.js +12 -4
  90. package/dist-server/server/routes/dictation.js +6 -1
  91. package/dist-server/server/routine-mochii-sync.js +252 -0
  92. package/dist-server/server/system-prompt.js +1 -1
  93. package/dist-server/server/text-actions.js +25 -0
  94. package/dist-server/shared/credential-request.js +15 -6
  95. package/dist-server/shared/engine-platforms.js +19 -0
  96. package/dist-server/vps-container-mcp.js +12 -6
  97. package/package.json +1 -1
  98. package/dist/assets/channel-Nx85fHZ4.js +0 -1
  99. package/dist/assets/index-B2fJMh8N.css +0 -1
  100. package/dist/assets/swimlanesDiagram-TC7HE7FX-BO2gR34z.js +0 -8
@@ -18471,9 +18471,9 @@ var init_image_generation = __esm({
18471
18471
  });
18472
18472
 
18473
18473
  // shared/removed-integration.ts
18474
- function withoutRemovedKey(record5) {
18475
- if (!isRecord(record5) || !Object.hasOwn(record5, REMOVED_INTEGRATION_KEY)) return record5;
18476
- const { [REMOVED_INTEGRATION_KEY]: _removed, ...rest } = record5;
18474
+ function withoutRemovedKey(record6) {
18475
+ if (!isRecord(record6) || !Object.hasOwn(record6, REMOVED_INTEGRATION_KEY)) return record6;
18476
+ const { [REMOVED_INTEGRATION_KEY]: _removed, ...rest } = record6;
18477
18477
  return rest;
18478
18478
  }
18479
18479
  function configWithoutRemovedIntegration(document) {
@@ -20072,6 +20072,37 @@ var init_schema = __esm({
20072
20072
  }
20073
20073
  });
20074
20074
 
20075
+ // shared/engine-platforms.ts
20076
+ function engineOnPlatform(driverKind, platform) {
20077
+ return !(ENGINES_OFF_BY_PLATFORM[platform] ?? []).includes(driverKind);
20078
+ }
20079
+ var ENGINES_OFF_BY_PLATFORM;
20080
+ var init_engine_platforms = __esm({
20081
+ "shared/engine-platforms.ts"() {
20082
+ "use strict";
20083
+ ENGINES_OFF_BY_PLATFORM = Object.freeze({
20084
+ win32: Object.freeze(["qwenAgent"])
20085
+ });
20086
+ }
20087
+ });
20088
+
20089
+ // server/engine-platform-fleet.ts
20090
+ function onDeviceFleet(platform = process.platform, arch = process.arch) {
20091
+ return platform === "darwin" && arch === "arm64" ? { appleIntelligence: { driver: "appleIntelligence", displayName: "Apple Intelligence (on this Mac)" } } : {};
20092
+ }
20093
+ function dropEnginesOffPlatform(map3, platform) {
20094
+ for (const [id, entry] of Object.entries(map3)) {
20095
+ if (!engineOnPlatform(entry.driver, platform)) delete map3[id];
20096
+ }
20097
+ return map3;
20098
+ }
20099
+ var init_engine_platform_fleet = __esm({
20100
+ "server/engine-platform-fleet.ts"() {
20101
+ "use strict";
20102
+ init_engine_platforms();
20103
+ }
20104
+ });
20105
+
20075
20106
  // server/config.ts
20076
20107
  import { readFileSync as readFileSync4, mkdirSync as mkdirSync6, existsSync as existsSync8, renameSync as renameSync3 } from "node:fs";
20077
20108
  import { homedir as homedir5 } from "node:os";
@@ -20217,7 +20248,9 @@ function loadConfig() {
20217
20248
  let cfg = {};
20218
20249
  try {
20219
20250
  cfg = parseStoredConfig(parseJson(readFileSync4(join12(DATA_DIR, "config.json"), "utf8")));
20220
- } catch {
20251
+ } catch (error51) {
20252
+ if (error51.code !== "ENOENT")
20253
+ throw new Error("Saved Atomic settings could not be read; config.json has been left untouched.", { cause: error51 });
20221
20254
  }
20222
20255
  if (cfg.mcpServers) cfg.mcpServers = hydrateMcpServers(cfg.mcpServers);
20223
20256
  cfg.mistral = { ...cfg.mistral };
@@ -20268,9 +20301,10 @@ function saveConfig(patch, options = {}) {
20268
20301
  const p3 = join12(DATA_DIR, "config.json");
20269
20302
  let disk = {};
20270
20303
  try {
20271
- const parsed = jsonObjectSchema.safeParse(parseJson(readFileSync4(p3, "utf8")));
20272
- if (parsed.success) disk = configWithoutRemovedIntegration(parsed.data).document;
20273
- } catch {
20304
+ disk = configWithoutRemovedIntegration(jsonObjectSchema.parse(parseJson(readFileSync4(p3, "utf8")))).document;
20305
+ } catch (error51) {
20306
+ if (error51.code !== "ENOENT")
20307
+ throw new Error("Cannot save over unreadable Atomic settings; config.json has been left untouched.", { cause: error51 });
20274
20308
  }
20275
20309
  const checkedPatch = appConfigSchema.partial().extend({ threads: threadsPatchSchema.optional(), newBots: newBotsPatchSchema.optional() }).parse(patch);
20276
20310
  const before = configSaveListeners.size ? structuredClone(disk) : disk;
@@ -20399,9 +20433,6 @@ function injectedEnvironment(cfg, driver) {
20399
20433
  if (driver === "opencodeGo" && cfg.opencodeGo?.apiKey) environment.set("OPENCODE_API_KEY", cfg.opencodeGo.apiKey);
20400
20434
  return environment;
20401
20435
  }
20402
- function onDeviceFleet(platform = process.platform, arch = process.arch) {
20403
- return platform === "darwin" && arch === "arm64" ? { appleIntelligence: { driver: "appleIntelligence", displayName: "Apple Intelligence (on this Mac)" } } : {};
20404
- }
20405
20436
  function plainObject2(value) {
20406
20437
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
20407
20438
  }
@@ -20422,7 +20453,7 @@ function separateClaudeLogin(instanceId, entry) {
20422
20453
  const configDir2 = plainObject2(entry.config)?.configDir;
20423
20454
  return typeof configDir2 === "string" && configDir2.trim() !== "";
20424
20455
  }
20425
- function instanceConfigs(cfg, onDevice = onDeviceFleet(), accountKeys = instanceKeys()) {
20456
+ function instanceConfigs(cfg, onDevice = onDeviceFleet(), accountKeys = instanceKeys(), platform = process.platform) {
20426
20457
  const DEFAULT_FLEET = {
20427
20458
  grok: { driver: "grokAgent" },
20428
20459
  kimi: { driver: "kimiAgent" },
@@ -20468,6 +20499,7 @@ function instanceConfigs(cfg, onDevice = onDeviceFleet(), accountKeys = instance
20468
20499
  for (const [id, fallback] of Object.entries(ATOMIC_FLEET)) {
20469
20500
  if (Object.hasOwn(map3, id)) map3[id] = withFleetDefaults(map3[id], fallback);
20470
20501
  }
20502
+ dropEnginesOffPlatform(map3, platform);
20471
20503
  for (const [id, sourceEntry] of Object.entries(map3)) {
20472
20504
  const entry = { ...sourceEntry };
20473
20505
  map3[id] = entry;
@@ -20517,6 +20549,7 @@ var init_config = __esm({
20517
20549
  init_mcp_secrets2();
20518
20550
  init_mcp_secrets();
20519
20551
  init_schema();
20552
+ init_engine_platform_fleet();
20520
20553
  optionalText = external_exports.string().optional();
20521
20554
  SSH_ALIAS = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/;
20522
20555
  LEGACY_BROWSER_PROFILE_ID = /^[A-Za-z0-9_-]{1,40}$/;
@@ -20622,18 +20655,19 @@ var init_config = __esm({
20622
20655
  * marketplace checks) and personal skills (~/.agents/skills,
20623
20656
  * $CODEX_HOME/skills). */
20624
20657
  codexUserMcp: external_exports.boolean().optional(),
20625
- /** LLM-generated titles for new bot threads. Off until explicitly
20626
- * enabled; a one-shot that fails or answers junk leaves the first-message
20627
- * snippet in place — see llmThreadTitlesEnabled. */
20658
+ /** LLM-generated titles for new bot threads. Off until explicitly enabled; a one-shot
20659
+ * that fails or answers junk leaves the first-message snippet in place — see llmThreadTitlesEnabled. */
20628
20660
  llmThreadTitles: external_exports.boolean().optional(),
20629
- /** Small internal jobs (thread titles) run on Apple Intelligence on this
20630
- * Mac when it is available. On unless set to false. */
20631
- onDeviceHelpers: external_exports.boolean().optional()
20661
+ /** Small internal jobs (thread titles) run on Apple Intelligence on this Mac when available. On unless false. */
20662
+ onDeviceHelpers: external_exports.boolean().optional(),
20663
+ /** Mirror routines into private Mochii tasks (server/routine-mochii-sync.ts). Off unless true; no Settings toggle. */
20664
+ routineMochiiSync: external_exports.boolean().optional()
20632
20665
  });
20633
20666
  addonsConfigSchema = external_exports.object(
20634
20667
  Object.fromEntries(ADDONS.map((addon) => [addon.id, external_exports.boolean().optional()]))
20635
20668
  ).strict();
20636
20669
  setupProgressSchema = external_exports.object({
20670
+ foundationRoles: external_exports.array(external_exports.enum(["assistant", "inbox", "research", "coder", "community", "ops"])).max(3).optional(),
20637
20671
  picks: external_exports.array(external_exports.string().trim().min(1).max(40)).max(20).optional(),
20638
20672
  chibitek: external_exports.boolean().optional(),
20639
20673
  steps: external_exports.record(external_exports.string().trim().min(1).max(60), external_exports.enum(["done", "skipped"])).refine((steps) => Object.keys(steps).length <= 60, "too many setup steps").optional(),
@@ -21017,14 +21051,14 @@ function parseRecord(path4, invalidMessage, validate) {
21017
21051
  if (error51?.code === "ENOENT") return null;
21018
21052
  throw leaseError("Atomic cannot read the data-directory lease; refusing to start to protect its state.", error51);
21019
21053
  }
21020
- let record5;
21054
+ let record6;
21021
21055
  try {
21022
- record5 = JSON.parse(raw);
21056
+ record6 = JSON.parse(raw);
21023
21057
  } catch (error51) {
21024
21058
  throw leaseError(invalidMessage, error51);
21025
21059
  }
21026
- if (!validate(record5)) throw leaseError(invalidMessage);
21027
- return record5;
21060
+ if (!validate(record6)) throw leaseError(invalidMessage);
21061
+ return record6;
21028
21062
  }
21029
21063
  function readOwner(path4) {
21030
21064
  return parseRecord(
@@ -21104,10 +21138,10 @@ function unlinkExact(path4, message2) {
21104
21138
  if (error51?.code !== "ENOENT") throw leaseError(message2, error51);
21105
21139
  }
21106
21140
  }
21107
- function publishRecord(path4, record5, prepareMessage, acquireMessage) {
21108
- const candidatePath = `${path4}.candidate-${record5.pid}-${record5.token}`;
21141
+ function publishRecord(path4, record6, prepareMessage, acquireMessage) {
21142
+ const candidatePath = `${path4}.candidate-${record6.pid}-${record6.token}`;
21109
21143
  try {
21110
- writeFileSync4(candidatePath, `${JSON.stringify(record5)}
21144
+ writeFileSync4(candidatePath, `${JSON.stringify(record6)}
21111
21145
  `, { flag: "wx", mode: 384, flush: true });
21112
21146
  } catch (error51) {
21113
21147
  throw leaseError(prepareMessage, error51);
@@ -24985,10 +25019,10 @@ function readUnslothKey(env) {
24985
25019
  }
24986
25020
  function idsFromModelsPayload(payload) {
24987
25021
  const records = Array.isArray(payload) ? payload : payload && typeof payload === "object" && Array.isArray(payload.data) ? payload.data : payload && typeof payload === "object" && Array.isArray(payload.models) ? payload.models : [];
24988
- return records.flatMap((record5) => {
24989
- if (typeof record5 === "string") return MODEL_ID.test(record5) ? [record5] : [];
24990
- if (!record5 || typeof record5 !== "object") return [];
24991
- const id = record5.id ?? record5.name;
25022
+ return records.flatMap((record6) => {
25023
+ if (typeof record6 === "string") return MODEL_ID.test(record6) ? [record6] : [];
25024
+ if (!record6 || typeof record6 !== "object") return [];
25025
+ const id = record6.id ?? record6.name;
24992
25026
  if (typeof id !== "string" || !MODEL_ID.test(id)) return [];
24993
25027
  const low = id.toLowerCase();
24994
25028
  if (low.includes("embed") || low.includes("bge-") || low.includes("nomic")) return [];
@@ -26257,9 +26291,9 @@ ${value.slice(-limit)}`;
26257
26291
  });
26258
26292
  }
26259
26293
  if (!value || typeof value !== "object") return value;
26260
- const record5 = value;
26261
- return Object.fromEntries(Object.entries(record5).flatMap(([key, entry]) => {
26262
- if (record5.type === "image" && (key === "data" || key === "blob") || key === "blob" && typeof record5.mimeType === "string" && record5.mimeType.startsWith("image/")) return [];
26294
+ const record6 = value;
26295
+ return Object.fromEntries(Object.entries(record6).flatMap(([key, entry]) => {
26296
+ if (record6.type === "image" && (key === "data" || key === "blob") || key === "blob" && typeof record6.mimeType === "string" && record6.mimeType.startsWith("image/")) return [];
26263
26297
  const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
26264
26298
  return sanitized === void 0 ? [] : [[key, sanitized]];
26265
26299
  }));
@@ -28061,8 +28095,8 @@ async function executableFile(path4, bytes) {
28061
28095
  }
28062
28096
  async function completedRelease(directory, asset) {
28063
28097
  try {
28064
- const record5 = JSON.parse(await readFile3(join21(directory, INSTALL_RECORD), "utf8"));
28065
- if (record5.sha256 !== asset.sha256 || record5.version !== asset.version || record5.executable.name !== asset.executable.name || record5.executable.bytes !== asset.executable.bytes || record5.harness.name !== asset.harness.name || record5.harness.bytes !== asset.harness.bytes) return null;
28098
+ const record6 = JSON.parse(await readFile3(join21(directory, INSTALL_RECORD), "utf8"));
28099
+ if (record6.sha256 !== asset.sha256 || record6.version !== asset.version || record6.executable.name !== asset.executable.name || record6.executable.bytes !== asset.executable.bytes || record6.harness.name !== asset.harness.name || record6.harness.bytes !== asset.harness.bytes) return null;
28066
28100
  const executablePath = join21(directory, asset.executable.name);
28067
28101
  const harnessPath = join21(directory, asset.harness.name);
28068
28102
  if (!await executableFile(executablePath, asset.executable.bytes)) return null;
@@ -28332,13 +28366,13 @@ async function installOnce2(options) {
28332
28366
  await removeQuietly(destination);
28333
28367
  throw error51;
28334
28368
  }
28335
- const record5 = {
28369
+ const record6 = {
28336
28370
  sha256: asset.sha256,
28337
28371
  version: asset.version,
28338
28372
  executable: asset.executable,
28339
28373
  harness: asset.harness
28340
28374
  };
28341
- await writeFile2(join21(destination, INSTALL_RECORD), `${JSON.stringify(record5)}
28375
+ await writeFile2(join21(destination, INSTALL_RECORD), `${JSON.stringify(record6)}
28342
28376
  `, { flag: "wx", mode: 384 });
28343
28377
  const installed = await completedRelease(destination, asset);
28344
28378
  if (!installed) throw new Error("The installed Antigravity runtime is incomplete.");
@@ -29295,6 +29329,177 @@ var init_rtk_rewrite = __esm({
29295
29329
  }
29296
29330
  });
29297
29331
 
29332
+ // server/drivers/claude-stdin.ts
29333
+ import { readFileSync as readFileSync9 } from "node:fs";
29334
+ function claudeUserMessage(text4, images) {
29335
+ if (!images?.length) return { type: "user", message: { role: "user", content: text4 } };
29336
+ const content = images.map((image) => ({
29337
+ type: "image",
29338
+ source: {
29339
+ type: "base64",
29340
+ media_type: image.mime,
29341
+ data: readFileSync9(image.path).toString("base64")
29342
+ }
29343
+ }));
29344
+ if (text4) content.push({ type: "text", text: text4 });
29345
+ return { type: "user", message: { role: "user", content } };
29346
+ }
29347
+ function diagnosticClaudeUserMessage(message2) {
29348
+ if (!Array.isArray(message2.message.content)) return message2;
29349
+ return {
29350
+ ...message2,
29351
+ message: {
29352
+ ...message2.message,
29353
+ content: message2.message.content.map(
29354
+ (block2) => block2.type === "image" ? {
29355
+ ...block2,
29356
+ source: {
29357
+ ...block2.source,
29358
+ data: `[image data: ${block2.source.data.length} base64 chars]`
29359
+ }
29360
+ } : block2
29361
+ )
29362
+ }
29363
+ };
29364
+ }
29365
+ function claudeControlResponse(requestId, response) {
29366
+ return { type: "control_response", response: { subtype: "success", request_id: requestId, response } };
29367
+ }
29368
+ var init_claude_stdin = __esm({
29369
+ "server/drivers/claude-stdin.ts"() {
29370
+ "use strict";
29371
+ }
29372
+ });
29373
+
29374
+ // server/mcp-elicitation.ts
29375
+ function record2(value) {
29376
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
29377
+ }
29378
+ function isControl(char) {
29379
+ const code = char.codePointAt(0) ?? 0;
29380
+ return code < 32 || code === 127;
29381
+ }
29382
+ function oneLine(value) {
29383
+ if (typeof value !== "string") return null;
29384
+ const text4 = Array.from(value, (char) => isControl(char) ? " " : char).join("").replace(/\s+/g, " ").trim();
29385
+ if (!text4) return null;
29386
+ return text4.length > MAX_MESSAGE ? `${text4.slice(0, MAX_MESSAGE - 1)}\u2026` : text4;
29387
+ }
29388
+ function yesValue(field) {
29389
+ if (field.type === "boolean") return true;
29390
+ if (field.type !== "string") return void 0;
29391
+ const options = Array.isArray(field.enum) ? field.enum : Array.isArray(field.oneOf) ? field.oneOf.map((option) => record2(option)?.const) : [];
29392
+ const strings3 = options.filter((option) => typeof option === "string");
29393
+ if (strings3.length < 1 || strings3.length > 4) return void 0;
29394
+ const yes = strings3.filter((option) => YES.test(option.trim()));
29395
+ return yes.length === 1 ? yes[0] : void 0;
29396
+ }
29397
+ function elicitationConfirm(params) {
29398
+ const request = record2(params);
29399
+ if (!request) return null;
29400
+ if (request.mode !== void 0 && request.mode !== "form") return null;
29401
+ const message2 = oneLine(request.message);
29402
+ if (!message2) return null;
29403
+ const rawSchema = request.requestedSchema ?? request.requested_schema;
29404
+ if (rawSchema === void 0 || rawSchema === null) return { message: message2, content: {} };
29405
+ const schema4 = record2(rawSchema);
29406
+ if (!schema4 || schema4.type !== void 0 && schema4.type !== "object") return null;
29407
+ const properties = schema4.properties === void 0 ? {} : record2(schema4.properties);
29408
+ if (!properties) return null;
29409
+ const names = Object.keys(properties);
29410
+ if (names.length === 0) return { message: message2, content: {} };
29411
+ if (names.length !== 1) return null;
29412
+ const name = names[0];
29413
+ const field = record2(properties[name]);
29414
+ if (!field) return null;
29415
+ const yes = yesValue(field);
29416
+ return yes === void 0 ? null : { message: message2, content: { [name]: yes } };
29417
+ }
29418
+ function elicitationAnswer(confirm2, allowed) {
29419
+ return allowed ? { action: "accept", content: confirm2.content } : { action: "decline" };
29420
+ }
29421
+ function elicitationSummary(server, confirm2) {
29422
+ const name = oneLine(server);
29423
+ return name ? `${name} asks: ${confirm2.message}` : confirm2.message;
29424
+ }
29425
+ function elicitationTool(server) {
29426
+ return `${ELICITATION_TOOL_PREFIX}${oneLine(server)?.replace(/\s+/g, "_") ?? "mcp"}`;
29427
+ }
29428
+ var MAX_MESSAGE, YES, ELICITATION_TOOL_PREFIX;
29429
+ var init_mcp_elicitation = __esm({
29430
+ "server/mcp-elicitation.ts"() {
29431
+ "use strict";
29432
+ MAX_MESSAGE = 600;
29433
+ YES = /^(yes|y|true|confirm|confirmed|approve|approved|accept|accepted|allow|proceed|continue|ok)$/i;
29434
+ ELICITATION_TOOL_PREFIX = "mcp_elicitation__";
29435
+ }
29436
+ });
29437
+
29438
+ // server/drivers/claude-elicitation.ts
29439
+ function createClaudeElicitations(deps) {
29440
+ const open2 = /* @__PURE__ */ new Map();
29441
+ return {
29442
+ /** A control_request frame from the CLI's stdout. True when it was an
29443
+ * elicitation (answered now or once the person decides). */
29444
+ handle(frame, ctx) {
29445
+ const o = frame;
29446
+ if (!o || o.request?.subtype !== "elicitation") return false;
29447
+ if (typeof o.request_id !== "string") return true;
29448
+ const controlId = o.request_id;
29449
+ const reply = (result) => ctx.write(claudeControlResponse(controlId, result));
29450
+ const confirm2 = elicitationConfirm(o.request);
29451
+ if (!confirm2 || ctx.closing) {
29452
+ reply({ action: "cancel" });
29453
+ return true;
29454
+ }
29455
+ const server = typeof o.request.mcp_server_name === "string" ? o.request.mcp_server_name : void 0;
29456
+ const requestId = newId();
29457
+ const finish = (allowed, source2) => {
29458
+ if (!open2.delete(requestId)) return;
29459
+ clearTimeout(timer);
29460
+ reply(allowed === null ? { action: "cancel" } : elicitationAnswer(confirm2, allowed));
29461
+ deps.emit({ ...deps.base(ctx.threadId, ctx.turnId), type: "request.resolved", requestId, behavior: allowed ? "allow" : "deny", source: source2 });
29462
+ };
29463
+ const timer = setTimeout(() => finish(null, "timeout"), deps.timeoutMs ?? ELICITATION_TIMEOUT_MS);
29464
+ timer.unref?.();
29465
+ open2.set(requestId, { threadId: ctx.threadId, finish });
29466
+ deps.emit({
29467
+ ...deps.base(ctx.threadId, ctx.turnId),
29468
+ type: "request.opened",
29469
+ requestId,
29470
+ requestType: "permission",
29471
+ tool: elicitationTool(server),
29472
+ summary: elicitationSummary(server, confirm2),
29473
+ requiresExplicitApproval: true
29474
+ });
29475
+ return true;
29476
+ },
29477
+ /** The person's answer to a card, or null when the card is not one of these. */
29478
+ respond(threadId, requestId, decision) {
29479
+ const entry = open2.get(requestId);
29480
+ if (!entry) return null;
29481
+ if (entry.threadId !== threadId) return "unavailable";
29482
+ const allowed = decision.behavior === "allow";
29483
+ entry.finish(allowed, "user");
29484
+ return allowed ? "allowed-once" : "rejected";
29485
+ },
29486
+ /** The session ended: every open question goes back as "no answer". */
29487
+ endThread(threadId) {
29488
+ for (const entry of Array.from(open2.values())) if (entry.threadId === threadId) entry.finish(null, "system");
29489
+ }
29490
+ };
29491
+ }
29492
+ var ELICITATION_TIMEOUT_MS;
29493
+ var init_claude_elicitation = __esm({
29494
+ "server/drivers/claude-elicitation.ts"() {
29495
+ "use strict";
29496
+ init_contracts();
29497
+ init_mcp_elicitation();
29498
+ init_claude_stdin();
29499
+ ELICITATION_TIMEOUT_MS = 15 * 6e4;
29500
+ }
29501
+ });
29502
+
29298
29503
  // shared/ask-question.ts
29299
29504
  function text3(value, limit) {
29300
29505
  if (typeof value !== "string") return void 0;
@@ -29401,7 +29606,7 @@ var init_ask_question = __esm({
29401
29606
 
29402
29607
  // server/drivers/claude.ts
29403
29608
  import { createHash as createHash7, randomBytes as randomBytes2 } from "node:crypto";
29404
- import { chmodSync as chmodSync4, existsSync as existsSync13, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync3, readFileSync as readFileSync9, rmSync as rmSync6, unlinkSync as unlinkSync3, writeFileSync as writeFileSync7 } from "node:fs";
29609
+ import { chmodSync as chmodSync4, existsSync as existsSync13, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync3, readFileSync as readFileSync10, rmSync as rmSync6, unlinkSync as unlinkSync3, writeFileSync as writeFileSync7 } from "node:fs";
29405
29610
  import { createServer as createNetServer } from "node:net";
29406
29611
  import { homedir as homedir9, tmpdir as tmpdir3 } from "node:os";
29407
29612
  import { join as join23, dirname as dirname9, isAbsolute as isAbsolute4, normalize } from "node:path";
@@ -29460,7 +29665,7 @@ function claudeInheritWarning(env) {
29460
29665
  function readClaudeAuthSettings(env, instanceEnvironment = {}) {
29461
29666
  if (CLAUDE_ACCOUNT_ENV_KEYS.some((key) => instanceEnvironment[key])) return {};
29462
29667
  try {
29463
- const settings2 = JSON.parse(readFileSync9(join23(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
29668
+ const settings2 = JSON.parse(readFileSync10(join23(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
29464
29669
  const authEnv = {};
29465
29670
  for (const key of CLAUDE_ACCOUNT_ENV_KEYS) {
29466
29671
  if (!key.endsWith("_FILE_DESCRIPTOR") && typeof settings2?.env?.[key] === "string") {
@@ -29478,7 +29683,7 @@ function readClaudeAuthSettings(env, instanceEnvironment = {}) {
29478
29683
  function projectMcpServers(cwd) {
29479
29684
  let parsed;
29480
29685
  try {
29481
- parsed = JSON.parse(readFileSync9(join23(cwd, ".mcp.json"), "utf8"));
29686
+ parsed = JSON.parse(readFileSync10(join23(cwd, ".mcp.json"), "utf8"));
29482
29687
  } catch {
29483
29688
  return {};
29484
29689
  }
@@ -29551,7 +29756,7 @@ function extrasFromUnknown(value) {
29551
29756
  function readClaudeModelCatalog(env = process.env) {
29552
29757
  let settings2 = {};
29553
29758
  try {
29554
- settings2 = JSON.parse(readFileSync9(join23(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
29759
+ settings2 = JSON.parse(readFileSync10(join23(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
29555
29760
  } catch {
29556
29761
  settings2 = {};
29557
29762
  }
@@ -29836,37 +30041,6 @@ function decodeConfig2(raw) {
29836
30041
  ...disallowedTools !== void 0 ? { disallowedTools } : {}
29837
30042
  };
29838
30043
  }
29839
- function claudeUserMessage(text4, images) {
29840
- if (!images?.length) return { type: "user", message: { role: "user", content: text4 } };
29841
- const content = images.map((image) => ({
29842
- type: "image",
29843
- source: {
29844
- type: "base64",
29845
- media_type: image.mime,
29846
- data: readFileSync9(image.path).toString("base64")
29847
- }
29848
- }));
29849
- if (text4) content.push({ type: "text", text: text4 });
29850
- return { type: "user", message: { role: "user", content } };
29851
- }
29852
- function diagnosticClaudeUserMessage(message2) {
29853
- if (!Array.isArray(message2.message.content)) return message2;
29854
- return {
29855
- ...message2,
29856
- message: {
29857
- ...message2.message,
29858
- content: message2.message.content.map(
29859
- (block2) => block2.type === "image" ? {
29860
- ...block2,
29861
- source: {
29862
- ...block2.source,
29863
- data: `[image data: ${block2.source.data.length} base64 chars]`
29864
- }
29865
- } : block2
29866
- )
29867
- }
29868
- };
29869
- }
29870
30044
  var CONNECTOR_CACHE_MS, CLAUDE_ACCOUNT_ENV_KEYS, DEFAULT_AUTOCOMPACT_TOKENS, CLAUDE_FLAG_FLOORS, CLAUDE_CONTEXT_CONTROL_MIN_VERSION, DRIVER_KIND2, HARNESS_REPLACED_BUILTINS, STATIC_CLAUDE_MODELS, CLAUDE_MODEL_ID, PERM_PROXY_PATH, DWEB_PROXY_PATH, HOOK_HELPER_PATH, RTK_HOOK_PATH, NODE_ENV_FLAG, DENY_TIMEOUT_NOTE, QUESTION_TIMEOUT_NOTE, DUPLICATE_ASK_ID_NOTE, NEXUS_PRIVATE_SCOPE_TOOLS, ClaudeDriver;
29871
30045
  var init_claude = __esm({
29872
30046
  "server/drivers/claude.ts"() {
@@ -29891,6 +30065,8 @@ var init_claude = __esm({
29891
30065
  init_rtk_rewrite();
29892
30066
  init_volatile_notes();
29893
30067
  init_mcp_tool_images();
30068
+ init_claude_stdin();
30069
+ init_claude_elicitation();
29894
30070
  init_ask_question();
29895
30071
  CONNECTOR_CACHE_MS = 5 * 60 * 1e3;
29896
30072
  CLAUDE_ACCOUNT_ENV_KEYS = [
@@ -30006,6 +30182,7 @@ var init_claude = __esm({
30006
30182
  const sumCost = (a2, b3) => a2 === null ? b3 : b3 === null ? a2 : a2 + b3;
30007
30183
  const STEER_FOLLOWUP_MS = 1500;
30008
30184
  const sessions = /* @__PURE__ */ new Map();
30185
+ const elicitations = createClaudeElicitations({ emit: (event) => emit(event), base: (threadId, turnId) => base3(threadId, turnId) });
30009
30186
  const sessionAllows = /* @__PURE__ */ new Map();
30010
30187
  const deliveredVolatile = /* @__PURE__ */ new Map();
30011
30188
  const volatileNoteFor = (threadId, sessionId, turn) => {
@@ -30030,6 +30207,7 @@ var init_claude = __esm({
30030
30207
  const s4 = sessions.get(threadId);
30031
30208
  if (!s4 || s4.closing) return;
30032
30209
  s4.closing = true;
30210
+ elicitations.endThread(threadId);
30033
30211
  if (s4.idleTimer) clearTimeout(s4.idleTimer);
30034
30212
  const broker = s4.broker;
30035
30213
  s4.broker = void 0;
@@ -30659,6 +30837,20 @@ var init_claude = __esm({
30659
30837
  }
30660
30838
  break;
30661
30839
  }
30840
+ case "control_request":
30841
+ elicitations.handle(o, {
30842
+ threadId,
30843
+ turnId: currentTurnId(),
30844
+ closing: session.closing,
30845
+ write: (frame) => {
30846
+ try {
30847
+ if (session.child.stdin.writable && !session.child.stdin.destroyed) session.child.stdin.write(JSON.stringify(frame) + "\n");
30848
+ appendNative(threadId, { dir: "out", source: "claude.sdk.message", msg: frame });
30849
+ } catch {
30850
+ }
30851
+ }
30852
+ });
30853
+ break;
30662
30854
  case "user":
30663
30855
  for (const b3 of Array.isArray(o.message?.content) ? o.message.content : []) {
30664
30856
  if (b3.type === "tool_result") {
@@ -31007,6 +31199,8 @@ var init_claude = __esm({
31007
31199
  steer,
31008
31200
  interruptTurn: async (threadId) => active.get(threadId)?.stop(),
31009
31201
  respondToRequest: async (threadId, requestId, decision) => {
31202
+ const confirmation = elicitations.respond(threadId, requestId, decision);
31203
+ if (confirmation) return confirmation;
31010
31204
  const broker = sessions.get(threadId)?.broker ?? active.get(threadId)?.broker;
31011
31205
  if (!broker) return "unavailable";
31012
31206
  const behavior = decision.behavior === "answer" ? "answer" : decision.behavior;
@@ -31263,7 +31457,7 @@ var init_toml_lite = __esm({
31263
31457
  });
31264
31458
 
31265
31459
  // server/mcp-auth-signal.ts
31266
- import { mkdirSync as mkdirSync12, readFileSync as readFileSync10, readdirSync as readdirSync3, renameSync as renameSync7, rmSync as rmSync7, writeFileSync as writeFileSync8 } from "node:fs";
31460
+ import { mkdirSync as mkdirSync12, readFileSync as readFileSync11, readdirSync as readdirSync3, renameSync as renameSync7, rmSync as rmSync7, writeFileSync as writeFileSync8 } from "node:fs";
31267
31461
  import { join as join24 } from "node:path";
31268
31462
  function writeMcpAuthSignal(dir, signal) {
31269
31463
  if (!dir) return;
@@ -31286,7 +31480,7 @@ var init_mcp_auth_signal = __esm({
31286
31480
  });
31287
31481
 
31288
31482
  // server/drivers/codex-mcp-names.ts
31289
- import { readFileSync as readFileSync11 } from "node:fs";
31483
+ import { readFileSync as readFileSync12 } from "node:fs";
31290
31484
  import { homedir as homedir10 } from "node:os";
31291
31485
  import { isAbsolute as isAbsolute5, join as join25, resolve as resolve7 } from "node:path";
31292
31486
  function mcpServerNamesInToml(toml) {
@@ -31320,7 +31514,7 @@ function codexHomeFor(env, cwd) {
31320
31514
  }
31321
31515
  function codexConfigMcpServers(env, cwd) {
31322
31516
  try {
31323
- return mcpServersInToml(readFileSync11(join25(codexHomeFor(env, cwd), "config.toml"), "utf8"));
31517
+ return mcpServersInToml(readFileSync12(join25(codexHomeFor(env, cwd), "config.toml"), "utf8"));
31324
31518
  } catch {
31325
31519
  return /* @__PURE__ */ new Map();
31326
31520
  }
@@ -31566,10 +31760,10 @@ var init_mcp_remote_bridge = __esm({
31566
31760
  // server/mcp-tool-hints.ts
31567
31761
  function toolAnnotations(raw) {
31568
31762
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
31569
- const record5 = raw;
31763
+ const record6 = raw;
31570
31764
  const out = {};
31571
31765
  for (const key of HINT_KEYS) {
31572
- const value = record5[key] ?? record5[SNAKE[key]];
31766
+ const value = record6[key] ?? record6[SNAKE[key]];
31573
31767
  if (typeof value === "boolean") out[key] = value;
31574
31768
  }
31575
31769
  return Object.keys(out).length ? out : void 0;
@@ -31593,8 +31787,76 @@ var init_mcp_tool_hints = __esm({
31593
31787
  }
31594
31788
  });
31595
31789
 
31790
+ // server/drivers/codex-elicitation.ts
31791
+ function boundedLabel(value) {
31792
+ if (typeof value !== "string") return null;
31793
+ const label = value.trim();
31794
+ return label && label.length <= 160 && !containsControlCharacter(label) ? label : null;
31795
+ }
31796
+ function ordinaryApprovalValue(value) {
31797
+ const normalized = value.trim().toLowerCase();
31798
+ if (/session|always|permanent|forever|persistent/.test(normalized)) return false;
31799
+ return normalized === "once" || /^(?:accept|approve|allow)(?:ed|[-_]?once)?$/.test(normalized);
31800
+ }
31801
+ function mcpAppApprovalForm(params) {
31802
+ const request = plainRecord(params);
31803
+ if (!request || request.mode !== "form") return null;
31804
+ const metadata = plainRecord(request._meta);
31805
+ const target = plainRecord(metadata?.target);
31806
+ const toolParams = plainRecord(metadata?.tool_params);
31807
+ const message2 = boundedLabel(request.message) ?? "App access requested";
31808
+ const appName = [
31809
+ metadata?.app_name,
31810
+ metadata?.appName,
31811
+ metadata?.app,
31812
+ target?.app,
31813
+ target?.name,
31814
+ toolParams?.app_name,
31815
+ toolParams?.app,
31816
+ metadata?.connector_name,
31817
+ metadata?.connectorName
31818
+ ].map(boundedLabel).find(Boolean) ?? message2.match(/^Allow ChatGPT to use (.+?)\?$/i)?.[1]?.trim();
31819
+ if (!appName) return null;
31820
+ const schema4 = plainRecord(request.requestedSchema);
31821
+ const properties = plainRecord(schema4?.properties);
31822
+ const required2 = schema4?.required;
31823
+ if (!properties || !Array.isArray(required2) || required2.length === 0 || required2.length > 8 || !required2.every((key) => typeof key === "string" && key.length > 0 && key.length <= 100)) return null;
31824
+ const content = {};
31825
+ for (const key of required2) {
31826
+ const field = plainRecord(properties[key]);
31827
+ if (!field) return null;
31828
+ const enumValues = Array.isArray(field.enum) ? field.enum.filter((value) => typeof value === "string") : [];
31829
+ const oneOfValues = Array.isArray(field.oneOf) ? field.oneOf.map((option) => boundedLabel(plainRecord(option)?.const)).filter((value) => Boolean(value)) : [];
31830
+ const chosen = [...oneOfValues, ...enumValues].find(ordinaryApprovalValue);
31831
+ if (!chosen) return null;
31832
+ content[key] = chosen;
31833
+ }
31834
+ const tool2 = boundedLabel(appName) ?? boundedLabel(request.serverName) ?? "app_access";
31835
+ return { tool: tool2, summary: message2, allowResult: { action: "accept", content } };
31836
+ }
31837
+ function codexServerConfirm(params, customByMountName) {
31838
+ const serverName = plainRecord(params)?.serverName;
31839
+ if (typeof serverName !== "string" || !customByMountName.has(serverName)) return null;
31840
+ return elicitationConfirm(params);
31841
+ }
31842
+ var plainRecord, containsControlCharacter;
31843
+ var init_codex_elicitation = __esm({
31844
+ "server/drivers/codex-elicitation.ts"() {
31845
+ "use strict";
31846
+ init_mcp_elicitation();
31847
+ plainRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
31848
+ containsControlCharacter = (value) => {
31849
+ for (const character of value) {
31850
+ const code = character.charCodeAt(0);
31851
+ if (code <= 31 || code === 127) return true;
31852
+ }
31853
+ return false;
31854
+ };
31855
+ }
31856
+ });
31857
+
31596
31858
  // server/drivers/codex-catalog.ts
31597
- import { readdirSync as readdirSync5, readFileSync as readFileSync12 } from "node:fs";
31859
+ import { readdirSync as readdirSync5, readFileSync as readFileSync13 } from "node:fs";
31598
31860
  import { homedir as homedir12 } from "node:os";
31599
31861
  import { basename as basename7, join as join28 } from "node:path";
31600
31862
  function encodeCodexSelection(provider, model) {
@@ -31775,7 +32037,7 @@ function parseCodexToml(text4) {
31775
32037
  }
31776
32038
  function readText(path4) {
31777
32039
  try {
31778
- return readFileSync12(path4, "utf8");
32040
+ return readFileSync13(path4, "utf8");
31779
32041
  } catch {
31780
32042
  return null;
31781
32043
  }
@@ -31811,9 +32073,9 @@ function collectCatalogNames(home) {
31811
32073
  continue;
31812
32074
  }
31813
32075
  const records = Array.isArray(parsed) ? parsed : parsed && typeof parsed === "object" && Array.isArray(parsed.models) ? parsed.models : parsed && typeof parsed === "object" && Array.isArray(parsed.data) ? parsed.data : [];
31814
- for (const record5 of records) {
31815
- if (!record5 || typeof record5 !== "object") continue;
31816
- const row = record5;
32076
+ for (const record6 of records) {
32077
+ if (!record6 || typeof record6 !== "object") continue;
32078
+ const row = record6;
31817
32079
  const slug = typeof row.slug === "string" ? row.slug : typeof row.id === "string" ? row.id : "";
31818
32080
  if (!MODEL_ID2.test(slug)) continue;
31819
32081
  const label = typeof row.display_name === "string" ? row.display_name : typeof row.name === "string" ? row.name : "";
@@ -31824,10 +32086,10 @@ function collectCatalogNames(home) {
31824
32086
  }
31825
32087
  function idsFromModelsPayload2(payload) {
31826
32088
  const records = Array.isArray(payload) ? payload : payload && typeof payload === "object" && Array.isArray(payload.data) ? payload.data : payload && typeof payload === "object" && Array.isArray(payload.models) ? payload.models : [];
31827
- return records.flatMap((record5) => {
31828
- if (typeof record5 === "string") return MODEL_ID2.test(record5) ? [record5] : [];
31829
- if (!record5 || typeof record5 !== "object") return [];
31830
- const id = record5.id ?? record5.slug;
32089
+ return records.flatMap((record6) => {
32090
+ if (typeof record6 === "string") return MODEL_ID2.test(record6) ? [record6] : [];
32091
+ if (!record6 || typeof record6 !== "object") return [];
32092
+ const id = record6.id ?? record6.slug;
31831
32093
  return typeof id === "string" && MODEL_ID2.test(id) ? [id] : [];
31832
32094
  });
31833
32095
  }
@@ -31935,7 +32197,7 @@ var init_codex_catalog = __esm({
31935
32197
 
31936
32198
  // server/drivers/codex-instructions.ts
31937
32199
  import { createHash as createHash8 } from "node:crypto";
31938
- import { mkdirSync as mkdirSync13, readFileSync as readFileSync13 } from "node:fs";
32200
+ import { mkdirSync as mkdirSync13, readFileSync as readFileSync14 } from "node:fs";
31939
32201
  import { join as join29 } from "node:path";
31940
32202
  function codexDeveloperInstructions(config2, botInstructions) {
31941
32203
  if (!config2 || typeof config2 !== "object" || Array.isArray(config2)) {
@@ -31955,7 +32217,7 @@ async function syncCodexInstructions(key, nativeThreadId, instructions, resumed,
31955
32217
  const fingerprint2 = digest(instructions);
31956
32218
  let previous;
31957
32219
  try {
31958
- previous = readFileSync13(path4, "utf8");
32220
+ previous = readFileSync14(path4, "utf8");
31959
32221
  } catch (error51) {
31960
32222
  if (error51.code !== "ENOENT") throw error51;
31961
32223
  }
@@ -32513,52 +32775,6 @@ function additionalPermissionSummary(permissions, reason) {
32513
32775
  const prefix = typeof reason === "string" && reason.trim() ? `${reason.trim()} \u2014 ` : "";
32514
32776
  return `${prefix}Requested permissions: ${exact}`;
32515
32777
  }
32516
- function boundedLabel(value) {
32517
- if (typeof value !== "string") return null;
32518
- const label = value.trim();
32519
- return label && label.length <= 160 && !containsControlCharacter(label) ? label : null;
32520
- }
32521
- function ordinaryApprovalValue(value) {
32522
- const normalized = value.trim().toLowerCase();
32523
- if (/session|always|permanent|forever|persistent/.test(normalized)) return false;
32524
- return normalized === "once" || /^(?:accept|approve|allow)(?:ed|[-_]?once)?$/.test(normalized);
32525
- }
32526
- function mcpAppApprovalForm(params) {
32527
- const request = plainRecord(params);
32528
- if (!request || request.mode !== "form") return null;
32529
- const metadata = plainRecord(request._meta);
32530
- const target = plainRecord(metadata?.target);
32531
- const toolParams = plainRecord(metadata?.tool_params);
32532
- const message2 = boundedLabel(request.message) ?? "App access requested";
32533
- const appName = [
32534
- metadata?.app_name,
32535
- metadata?.appName,
32536
- metadata?.app,
32537
- target?.app,
32538
- target?.name,
32539
- toolParams?.app_name,
32540
- toolParams?.app,
32541
- metadata?.connector_name,
32542
- metadata?.connectorName
32543
- ].map(boundedLabel).find(Boolean) ?? message2.match(/^Allow ChatGPT to use (.+?)\?$/i)?.[1]?.trim();
32544
- if (!appName) return null;
32545
- const schema4 = plainRecord(request.requestedSchema);
32546
- const properties = plainRecord(schema4?.properties);
32547
- const required2 = schema4?.required;
32548
- if (!properties || !Array.isArray(required2) || required2.length === 0 || required2.length > 8 || !required2.every((key) => typeof key === "string" && key.length > 0 && key.length <= 100)) return null;
32549
- const content = {};
32550
- for (const key of required2) {
32551
- const field = plainRecord(properties[key]);
32552
- if (!field) return null;
32553
- const enumValues = Array.isArray(field.enum) ? field.enum.filter((value) => typeof value === "string") : [];
32554
- const oneOfValues = Array.isArray(field.oneOf) ? field.oneOf.map((option) => boundedLabel(plainRecord(option)?.const)).filter((value) => Boolean(value)) : [];
32555
- const chosen = [...oneOfValues, ...enumValues].find(ordinaryApprovalValue);
32556
- if (!chosen) return null;
32557
- content[key] = chosen;
32558
- }
32559
- const tool2 = boundedLabel(appName) ?? boundedLabel(request.serverName) ?? "app_access";
32560
- return { tool: tool2, summary: message2, allowResult: { action: "accept", content } };
32561
- }
32562
32778
  function namedApprovalParams(mode) {
32563
32779
  if (mode === "full") {
32564
32780
  return {
@@ -32589,15 +32805,15 @@ function namedApprovalParams(mode) {
32589
32805
  }
32590
32806
  function withWritableRoots(turnParams, dirs) {
32591
32807
  if (!dirs?.length) return turnParams;
32592
- const policy = plainRecord(turnParams.sandboxPolicy);
32808
+ const policy = plainRecord2(turnParams.sandboxPolicy);
32593
32809
  if (!policy || policy.type !== "workspaceWrite") return turnParams;
32594
32810
  const existing = Array.isArray(policy.writableRoots) ? policy.writableRoots.filter((root) => typeof root === "string") : [];
32595
32811
  return { ...turnParams, sandboxPolicy: { ...policy, writableRoots: [.../* @__PURE__ */ new Set([...existing, ...dirs])] } };
32596
32812
  }
32597
32813
  function withResolvedSandbox(params, session) {
32598
- const requested = plainRecord(params.turn.sandboxPolicy);
32814
+ const requested = plainRecord2(params.turn.sandboxPolicy);
32599
32815
  if (!requested) return params;
32600
- const sandbox = plainRecord(plainRecord(session)?.sandbox);
32816
+ const sandbox = plainRecord2(plainRecord2(session)?.sandbox);
32601
32817
  if (!sandbox || typeof sandbox.type !== "string") {
32602
32818
  throw new Error("Codex did not return its resolved sandbox policy. Update Codex, then retry; the turn was not started because its permissions could not be verified.");
32603
32819
  }
@@ -32608,7 +32824,7 @@ function withResolvedSandbox(params, session) {
32608
32824
  }
32609
32825
  function effectiveApprovalPolicy(value) {
32610
32826
  if (value === "untrusted" || value === "on-request" || value === "never") return value;
32611
- const granular = plainRecord(plainRecord(value)?.granular);
32827
+ const granular = plainRecord2(plainRecord2(value)?.granular);
32612
32828
  if (granular && typeof granular.mcp_elicitations === "boolean" && typeof granular.rules === "boolean" && typeof granular.sandbox_approval === "boolean" && (granular.request_permissions === void 0 || typeof granular.request_permissions === "boolean") && (granular.skill_approval === void 0 || typeof granular.skill_approval === "boolean")) {
32613
32829
  return {
32614
32830
  granular: {
@@ -32671,20 +32887,20 @@ function permissionProfileUnsupported(error51) {
32671
32887
  }
32672
32888
  function codexNativeLogMessage(message2) {
32673
32889
  if (!message2 || typeof message2 !== "object" || Array.isArray(message2)) return message2;
32674
- const record5 = message2;
32675
- const params = record5.params;
32890
+ const record6 = message2;
32891
+ const params = record6.params;
32676
32892
  if (!params || typeof params !== "object" || Array.isArray(params)) return message2;
32677
- if (record5.method === "thread/start" || record5.method === "thread/resume") {
32678
- return { ...record5, params: { ...params, developerInstructions: "[developer instructions omitted]" } };
32893
+ if (record6.method === "thread/start" || record6.method === "thread/resume") {
32894
+ return { ...record6, params: { ...params, developerInstructions: "[developer instructions omitted]" } };
32679
32895
  }
32680
- if (record5.method === "thread/inject_items") {
32681
- return { ...record5, params: { ...params, items: "[developer instruction update omitted]" } };
32896
+ if (record6.method === "thread/inject_items") {
32897
+ return { ...record6, params: { ...params, items: "[developer instruction update omitted]" } };
32682
32898
  }
32683
- if (record5.method !== "turn/start") return message2;
32899
+ if (record6.method !== "turn/start") return message2;
32684
32900
  const input = params.input;
32685
32901
  if (!Array.isArray(input)) return message2;
32686
32902
  return {
32687
- ...record5,
32903
+ ...record6,
32688
32904
  params: {
32689
32905
  ...params,
32690
32906
  input: input.map((item) => {
@@ -32755,7 +32971,7 @@ function mountMcpServer(appServerArgs, env, name, server, preApproved = true) {
32755
32971
  appServerArgs.push("-c", `${prefix}.default_tools_approval_mode="auto"`);
32756
32972
  }
32757
32973
  }
32758
- var DRIVER_KIND3, ASTRA_MODEL_ID, ASTRA_MIN_CODEX_VERSION, CodexRpcError, QUESTION_TIMEOUT_NOTE2, DENY_TIMEOUT_NOTE2, notedMcpServers, plainRecord, containsControlCharacter, CodexDriver;
32974
+ var DRIVER_KIND3, ASTRA_MODEL_ID, ASTRA_MIN_CODEX_VERSION, CodexRpcError, QUESTION_TIMEOUT_NOTE2, DENY_TIMEOUT_NOTE2, notedMcpServers, plainRecord2, CodexDriver;
32759
32975
  var init_codex = __esm({
32760
32976
  "server/drivers/codex.ts"() {
32761
32977
  "use strict";
@@ -32768,6 +32984,8 @@ var init_codex = __esm({
32768
32984
  init_setup_log();
32769
32985
  init_mcp_registry();
32770
32986
  init_mcp_tool_hints();
32987
+ init_mcp_elicitation();
32988
+ init_codex_elicitation();
32771
32989
  init_contracts();
32772
32990
  init_codex_catalog();
32773
32991
  init_local_inject();
@@ -32796,14 +33014,7 @@ var init_codex = __esm({
32796
33014
  QUESTION_TIMEOUT_NOTE2 = "No answer was given \u2014 use your best judgment.";
32797
33015
  DENY_TIMEOUT_NOTE2 = "Atomic: nobody answered this permission request in time. Skip this action and finish what you can without it.";
32798
33016
  notedMcpServers = /* @__PURE__ */ new Set();
32799
- plainRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
32800
- containsControlCharacter = (value) => {
32801
- for (const character of value) {
32802
- const code = character.charCodeAt(0);
32803
- if (code <= 31 || code === 127) return true;
32804
- }
32805
- return false;
32806
- };
33017
+ plainRecord2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
32807
33018
  CodexDriver = {
32808
33019
  driverKind: DRIVER_KIND3,
32809
33020
  metadata: { displayName: "Codex", supportsMultipleInstances: true },
@@ -33103,7 +33314,8 @@ var init_codex = __esm({
33103
33314
  const isMcpElicitation = method === "mcpServer/elicitation/request";
33104
33315
  const isLegacyMcpPermission = method === "mcpServer/elicitation/request" && params?._meta?.codex_approval_kind === "mcp_tool_call";
33105
33316
  const mcpAppApproval = isMcpElicitation ? mcpAppApprovalForm(params) : null;
33106
- const isMcpPermission = isLegacyMcpPermission || mcpAppApproval !== null;
33317
+ const serverConfirm = isMcpElicitation && !isLegacyMcpPermission && !mcpAppApproval ? codexServerConfirm(params, customByMountName) : null;
33318
+ const isMcpPermission = isLegacyMcpPermission || mcpAppApproval !== null || serverConfirm !== null;
33107
33319
  const isQuestion = method === "item/tool/requestUserInput";
33108
33320
  const isAdditionalPermission = method === "item/permissions/requestApproval";
33109
33321
  const isPermission = legacy || isMcpPermission || isAdditionalPermission || method === "item/commandExecution/requestApproval" || method === "item/fileChange/requestApproval";
@@ -33134,9 +33346,9 @@ var init_codex = __esm({
33134
33346
  const mcpTool = isLegacyMcpPermission ? (typeof params?._meta?.tool_name === "string" ? params._meta.tool_name : void 0) ?? String(params.message ?? "").match(/tool "([^"]+)"/)?.[1] : void 0;
33135
33347
  const customServer = isLegacyMcpPermission && typeof params.serverName === "string" ? customByMountName.get(params.serverName) : void 0;
33136
33348
  const mcpToolRef = customServer && mcpTool ? { server: customServer, tool: mcpTool, ...toolAnnotations(params?._meta?.annotations) ? { annotations: toolAnnotations(params._meta.annotations) } : {} } : void 0;
33137
- const tool2 = mcpAppApproval ? mcpAppApproval.tool : isLegacyMcpPermission ? mcpTool ?? "mcp" : isAdditionalPermission ? "permissions" : method === "item/fileChange/requestApproval" || method === "applyPatchApproval" ? "edit" : isQuestion ? "ask_user" : "shell";
33138
- const permissionResult = (allow) => isMcpPermission ? allow ? mcpAppApproval?.allowResult ?? { action: "accept", content: {} } : { action: "decline" } : isAdditionalPermission ? { permissions: allow ? grantedPermissions(params.permissions) : {}, scope: "turn" } : { decision: allow ? legacy ? "approved" : "accept" : legacy ? "denied" : "decline" };
33139
- if (autoAcceptPermissions && isPermission) {
33349
+ const tool2 = serverConfirm ? elicitationTool(customByMountName.get(params.serverName)) : mcpAppApproval ? mcpAppApproval.tool : isLegacyMcpPermission ? mcpTool ?? "mcp" : isAdditionalPermission ? "permissions" : method === "item/fileChange/requestApproval" || method === "applyPatchApproval" ? "edit" : isQuestion ? "ask_user" : "shell";
33350
+ const permissionResult = (allow) => serverConfirm ? elicitationAnswer(serverConfirm, allow) : isMcpPermission ? allow ? mcpAppApproval?.allowResult ?? { action: "accept", content: {} } : { action: "decline" } : isAdditionalPermission ? { permissions: allow ? grantedPermissions(params.permissions) : {}, scope: "turn" } : { decision: allow ? legacy ? "approved" : "accept" : legacy ? "denied" : "decline" };
33351
+ if (autoAcceptPermissions && isPermission && !serverConfirm) {
33140
33352
  return send({
33141
33353
  jsonrpc: "2.0",
33142
33354
  id: msg.id,
@@ -33144,7 +33356,7 @@ var init_codex = __esm({
33144
33356
  });
33145
33357
  }
33146
33358
  const requestId = newId();
33147
- const summary = isAdditionalPermission ? additionalPermissionSummary(params.permissions, params.reason) : isMcpPermission ? mcpAppApproval?.summary ?? (typeof params.message === "string" ? params.message : "MCP access requested") : typeof params.command === "string" ? params.command : Array.isArray(params.questions) ? params.questions.map((q2) => q2.question ?? q2.header).filter(Boolean).join(" \xB7 ") : typeof params.reason === "string" ? params.reason : tool2;
33359
+ const summary = isAdditionalPermission ? additionalPermissionSummary(params.permissions, params.reason) : serverConfirm ? elicitationSummary(customByMountName.get(params.serverName), serverConfirm) : isMcpPermission ? mcpAppApproval?.summary ?? (typeof params.message === "string" ? params.message : "MCP access requested") : typeof params.command === "string" ? params.command : Array.isArray(params.questions) ? params.questions.map((q2) => q2.question ?? q2.header).filter(Boolean).join(" \xB7 ") : typeof params.reason === "string" ? params.reason : tool2;
33148
33360
  const choices = isQuestion ? (params.questions?.[0]?.options ?? []).map((o) => o.label).slice(0, 5) : void 0;
33149
33361
  const finish = (behavior, message2, source2 = "user") => {
33150
33362
  if (!asks.delete(requestId)) return;
@@ -33159,7 +33371,8 @@ var init_codex = __esm({
33159
33371
  send({
33160
33372
  jsonrpc: "2.0",
33161
33373
  id: msg.id,
33162
- result: permissionResult(behavior === "allow")
33374
+ // a server's question nobody answered is "no answer", not a no
33375
+ result: serverConfirm && source2 !== "user" ? { action: "cancel" } : permissionResult(behavior === "allow")
33163
33376
  });
33164
33377
  }
33165
33378
  emit({ ...base3(threadId, turnId), type: "request.resolved", requestId, behavior, source: source2 });
@@ -33179,7 +33392,7 @@ var init_codex = __esm({
33179
33392
  summary,
33180
33393
  choices,
33181
33394
  approvalScope: controlsHost ? "local-computer" : void 0,
33182
- requiresExplicitApproval: isAdditionalPermission || void 0,
33395
+ requiresExplicitApproval: isAdditionalPermission || serverConfirm !== null || void 0,
33183
33396
  ...mcpToolRef ? { mcpTool: mcpToolRef } : {}
33184
33397
  });
33185
33398
  };
@@ -41708,7 +41921,7 @@ var require_dist = __commonJS({
41708
41921
  });
41709
41922
 
41710
41923
  // server/drivers/chat-images.ts
41711
- import { readFileSync as readFileSync14, statSync as statSync4 } from "node:fs";
41924
+ import { readFileSync as readFileSync15, statSync as statSync4 } from "node:fs";
41712
41925
  function chatImageBudget() {
41713
41926
  let used = 0;
41714
41927
  return (parts) => {
@@ -41740,7 +41953,7 @@ function chatUserContent(turn) {
41740
41953
  const budget = chatImageBudget();
41741
41954
  return [{ type: "text", text: turn.text }, ...turn.images.map((image) => {
41742
41955
  if (statSync4(image.path).size > IMAGE_BYTES) throw new Error("Image exceeds 20 MB");
41743
- const part = chatImage({ mimeType: image.mime, data: readFileSync14(image.path).toString("base64") });
41956
+ const part = chatImage({ mimeType: image.mime, data: readFileSync15(image.path).toString("base64") });
41744
41957
  budget([part]);
41745
41958
  return part;
41746
41959
  })];
@@ -41766,7 +41979,7 @@ import {
41766
41979
  linkSync as linkSync2,
41767
41980
  mkdirSync as mkdirSync14,
41768
41981
  openSync as openSync5,
41769
- readFileSync as readFileSync15,
41982
+ readFileSync as readFileSync16,
41770
41983
  unlinkSync as unlinkSync4,
41771
41984
  writeFileSync as writeFileSync9
41772
41985
  } from "node:fs";
@@ -41777,7 +41990,7 @@ function hasCode(error51, code) {
41777
41990
  function readEnvironmentId(file2) {
41778
41991
  let contents;
41779
41992
  try {
41780
- contents = readFileSync15(file2, "utf8");
41993
+ contents = readFileSync16(file2, "utf8");
41781
41994
  } catch (error51) {
41782
41995
  if (hasCode(error51, "ENOENT")) return void 0;
41783
41996
  throw new Error(`Cannot read the existing environment identity at ${file2}; refusing to replace it.`, {
@@ -41833,7 +42046,7 @@ var init_environment = __esm({
41833
42046
 
41834
42047
  // server/box-create-idempotency.ts
41835
42048
  import { createHash as createHash9, randomUUID as randomUUID11 } from "node:crypto";
41836
- import { linkSync as linkSync3, mkdirSync as mkdirSync15, readFileSync as readFileSync16, unlinkSync as unlinkSync5, writeFileSync as writeFileSync10 } from "node:fs";
42049
+ import { linkSync as linkSync3, mkdirSync as mkdirSync15, readFileSync as readFileSync17, unlinkSync as unlinkSync5, writeFileSync as writeFileSync10 } from "node:fs";
41837
42050
  import { join as join33 } from "node:path";
41838
42051
  function isRequest(value) {
41839
42052
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
@@ -41851,7 +42064,7 @@ function recoveryStateError(detail, cause) {
41851
42064
  function loadFresh() {
41852
42065
  let raw;
41853
42066
  try {
41854
- raw = JSON.parse(readFileSync16(FILE, "utf8"));
42067
+ raw = JSON.parse(readFileSync17(FILE, "utf8"));
41855
42068
  } catch (error51) {
41856
42069
  if (error51?.code === "ENOENT") return [];
41857
42070
  throw recoveryStateError("unreadable", error51);
@@ -41890,7 +42103,7 @@ function isLockOwner(value) {
41890
42103
  function readLockOwner() {
41891
42104
  let raw;
41892
42105
  try {
41893
- raw = readFileSync16(LOCK_FILE, "utf8");
42106
+ raw = readFileSync17(LOCK_FILE, "utf8");
41894
42107
  } catch (error51) {
41895
42108
  if (error51?.code === "ENOENT") return null;
41896
42109
  throw recoveryStateError("lock is unreadable", error51);
@@ -41907,7 +42120,7 @@ function readLockOwner() {
41907
42120
  function readReaperOwner(path4, targetToken) {
41908
42121
  let raw;
41909
42122
  try {
41910
- raw = readFileSync16(path4, "utf8");
42123
+ raw = readFileSync17(path4, "utf8");
41911
42124
  } catch (error51) {
41912
42125
  if (error51?.code === "ENOENT") return null;
41913
42126
  throw recoveryStateError("stale-lock recovery record is unreadable", error51);
@@ -42109,7 +42322,7 @@ var init_box_create_idempotency = __esm({
42109
42322
 
42110
42323
  // server/box-delete-journal.ts
42111
42324
  import { createHash as createHash10, randomUUID as randomUUID12 } from "node:crypto";
42112
- import { linkSync as linkSync4, mkdirSync as mkdirSync16, readFileSync as readFileSync17, unlinkSync as unlinkSync6, writeFileSync as writeFileSync11 } from "node:fs";
42325
+ import { linkSync as linkSync4, mkdirSync as mkdirSync16, readFileSync as readFileSync18, unlinkSync as unlinkSync6, writeFileSync as writeFileSync11 } from "node:fs";
42113
42326
  import { join as join34 } from "node:path";
42114
42327
  function validTimestamp(value) {
42115
42328
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
@@ -42119,13 +42332,13 @@ function validName(value) {
42119
42332
  }
42120
42333
  function isRecord4(value) {
42121
42334
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
42122
- const record5 = value;
42123
- if (typeof record5.boxId !== "string" || !BOX_ID2.test(record5.boxId) || !validName(record5.name) || !(record5.ownerBotId === null || typeof record5.ownerBotId === "string" && BOT_ID2.test(record5.ownerBotId)) || !["prepared", "accepted", "blocked"].includes(record5.phase) || !validTimestamp(record5.requestedAt) || !validTimestamp(record5.updatedAt) || record5.updatedAt < record5.requestedAt || !(record5.operationId === void 0 || typeof record5.operationId === "string" && OPERATION_ID.test(record5.operationId)) || !(record5.status === void 0 || typeof record5.status === "string" && PROVIDER_STATUSES.has(record5.status))) return false;
42124
- if (record5.phase === "prepared") return record5.operationId === void 0 && record5.status === void 0;
42125
- if (record5.phase === "accepted") {
42126
- return typeof record5.operationId === "string" && (record5.status === "pending" || record5.status === "processing" || record5.status === "completed");
42335
+ const record6 = value;
42336
+ if (typeof record6.boxId !== "string" || !BOX_ID2.test(record6.boxId) || !validName(record6.name) || !(record6.ownerBotId === null || typeof record6.ownerBotId === "string" && BOT_ID2.test(record6.ownerBotId)) || !["prepared", "accepted", "blocked"].includes(record6.phase) || !validTimestamp(record6.requestedAt) || !validTimestamp(record6.updatedAt) || record6.updatedAt < record6.requestedAt || !(record6.operationId === void 0 || typeof record6.operationId === "string" && OPERATION_ID.test(record6.operationId)) || !(record6.status === void 0 || typeof record6.status === "string" && PROVIDER_STATUSES.has(record6.status))) return false;
42337
+ if (record6.phase === "prepared") return record6.operationId === void 0 && record6.status === void 0;
42338
+ if (record6.phase === "accepted") {
42339
+ return typeof record6.operationId === "string" && (record6.status === "pending" || record6.status === "processing" || record6.status === "completed");
42127
42340
  }
42128
- return record5.status === "blocked";
42341
+ return record6.status === "blocked";
42129
42342
  }
42130
42343
  function stateError(detail, cause) {
42131
42344
  return Object.assign(
@@ -42135,13 +42348,13 @@ function stateError(detail, cause) {
42135
42348
  { status: 503, cause }
42136
42349
  );
42137
42350
  }
42138
- function clone2(record5) {
42139
- return { ...record5 };
42351
+ function clone2(record6) {
42352
+ return { ...record6 };
42140
42353
  }
42141
42354
  function loadFresh2() {
42142
42355
  let raw;
42143
42356
  try {
42144
- raw = JSON.parse(readFileSync17(FILE2, "utf8"));
42357
+ raw = JSON.parse(readFileSync18(FILE2, "utf8"));
42145
42358
  } catch (error51) {
42146
42359
  if (error51?.code === "ENOENT") return [];
42147
42360
  throw stateError("unreadable", error51);
@@ -42150,12 +42363,12 @@ function loadFresh2() {
42150
42363
  if (!journal || typeof journal !== "object" || Array.isArray(journal) || journal.version !== 1 || !Array.isArray(journal.records) || journal.records.length > MAX_RECORDS || !journal.records.every(isRecord4)) throw stateError("invalid");
42151
42364
  const boxIds = /* @__PURE__ */ new Set();
42152
42365
  const operationIds = /* @__PURE__ */ new Set();
42153
- for (const record5 of journal.records) {
42154
- if (boxIds.has(record5.boxId)) throw stateError("invalid");
42155
- boxIds.add(record5.boxId);
42156
- if (record5.operationId) {
42157
- if (operationIds.has(record5.operationId)) throw stateError("invalid");
42158
- operationIds.add(record5.operationId);
42366
+ for (const record6 of journal.records) {
42367
+ if (boxIds.has(record6.boxId)) throw stateError("invalid");
42368
+ boxIds.add(record6.boxId);
42369
+ if (record6.operationId) {
42370
+ if (operationIds.has(record6.operationId)) throw stateError("invalid");
42371
+ operationIds.add(record6.operationId);
42159
42372
  }
42160
42373
  }
42161
42374
  return journal.records.map(clone2);
@@ -42168,7 +42381,7 @@ function isLockOwner2(value) {
42168
42381
  function readLockOwner2() {
42169
42382
  let raw;
42170
42383
  try {
42171
- raw = readFileSync17(LOCK_FILE2, "utf8");
42384
+ raw = readFileSync18(LOCK_FILE2, "utf8");
42172
42385
  } catch (error51) {
42173
42386
  if (error51?.code === "ENOENT") return null;
42174
42387
  throw stateError("lock is unreadable", error51);
@@ -42205,7 +42418,7 @@ function unlinkCandidate2(path4) {
42205
42418
  function readReaperOwner2(path4, targetToken) {
42206
42419
  let raw;
42207
42420
  try {
42208
- raw = readFileSync17(path4, "utf8");
42421
+ raw = readFileSync18(path4, "utf8");
42209
42422
  } catch (error51) {
42210
42423
  if (error51?.code === "ENOENT") return null;
42211
42424
  throw stateError("stale-lock recovery record is unreadable", error51);
@@ -42344,13 +42557,13 @@ function withJournalLock2(operation) {
42344
42557
  function getBoxDeletion(boxId) {
42345
42558
  if (!BOX_ID2.test(boxId)) throw new Error("invalid cloud computer id for deletion");
42346
42559
  return withJournalLock2((records) => {
42347
- const record5 = records.find((candidate) => candidate.boxId === boxId);
42348
- return record5 ? clone2(record5) : null;
42560
+ const record6 = records.find((candidate) => candidate.boxId === boxId);
42561
+ return record6 ? clone2(record6) : null;
42349
42562
  });
42350
42563
  }
42351
42564
  function hasPendingBoxDeletionForBot(botId) {
42352
42565
  if (!BOT_ID2.test(botId)) throw new Error("invalid bot id for cloud computer deletion");
42353
- return withJournalLock2((records) => records.some((record5) => record5.ownerBotId === botId));
42566
+ return withJournalLock2((records) => records.some((record6) => record6.ownerBotId === botId));
42354
42567
  }
42355
42568
  var FILE2, LOCK_FILE2, MAX_RECORDS, LOCK_WAIT_MS2, LOCK_RETRY_MS2, MAX_REAPER_GENERATIONS3, UUID4, BOT_ID2, BOX_ID2, OPERATION_ID, PROVIDER_STATUSES, lockWait2;
42356
42569
  var init_box_delete_journal = __esm({
@@ -43891,7 +44104,7 @@ var init_grok = __esm({
43891
44104
  });
43892
44105
 
43893
44106
  // server/drivers/acp/grok.ts
43894
- import { existsSync as existsSync16, readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "node:fs";
44107
+ import { existsSync as existsSync16, readFileSync as readFileSync19, writeFileSync as writeFileSync12 } from "node:fs";
43895
44108
  import { homedir as homedir16 } from "node:os";
43896
44109
  import { join as join35 } from "node:path";
43897
44110
  function decodeGrokModelText(text4) {
@@ -43940,7 +44153,7 @@ function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
43940
44153
  const path4 = join35(grokHome(env), "config.toml");
43941
44154
  let text4 = "";
43942
44155
  try {
43943
- text4 = readFileSync18(path4, "utf8");
44156
+ text4 = readFileSync19(path4, "utf8");
43944
44157
  } catch {
43945
44158
  return base3;
43946
44159
  }
@@ -44019,7 +44232,7 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
44019
44232
  const path4 = join35(grokHome(env), "config.toml");
44020
44233
  let text4 = "";
44021
44234
  try {
44022
- text4 = readFileSync18(path4, "utf8");
44235
+ text4 = readFileSync19(path4, "utf8");
44023
44236
  } catch {
44024
44237
  text4 = "";
44025
44238
  }
@@ -44185,12 +44398,12 @@ ${turn.text}` : turn.text
44185
44398
  });
44186
44399
 
44187
44400
  // server/drivers/acp/gemini.ts
44188
- import { existsSync as existsSync17, readFileSync as readFileSync19 } from "node:fs";
44401
+ import { existsSync as existsSync17, readFileSync as readFileSync20 } from "node:fs";
44189
44402
  import { homedir as homedir17 } from "node:os";
44190
44403
  import { join as join36 } from "node:path";
44191
44404
  function liveOauthCredential() {
44192
44405
  try {
44193
- const creds = JSON.parse(readFileSync19(join36(homedir17(), ".gemini", "oauth_creds.json"), "utf8"));
44406
+ const creds = JSON.parse(readFileSync20(join36(homedir17(), ".gemini", "oauth_creds.json"), "utf8"));
44194
44407
  if (typeof creds.access_token !== "string" || creds.access_token.trim().length === 0) return false;
44195
44408
  const hasRefresh = typeof creds.refresh_token === "string" && creds.refresh_token.trim().length > 0;
44196
44409
  if (creds.expiry_date !== void 0) {
@@ -44250,7 +44463,7 @@ ${turn.text}` : turn.text
44250
44463
  });
44251
44464
 
44252
44465
  // server/drivers/acp/kimi.ts
44253
- import { existsSync as existsSync18, mkdirSync as mkdirSync17, readFileSync as readFileSync20, writeFileSync as writeFileSync13 } from "node:fs";
44466
+ import { existsSync as existsSync18, mkdirSync as mkdirSync17, readFileSync as readFileSync21, writeFileSync as writeFileSync13 } from "node:fs";
44254
44467
  import { homedir as homedir18 } from "node:os";
44255
44468
  import { join as join37 } from "node:path";
44256
44469
  function isLocalInjectAlias(slug) {
@@ -44551,7 +44764,7 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
44551
44764
  const path4 = join37(dataRoot, "config.toml");
44552
44765
  let text4 = "";
44553
44766
  try {
44554
- text4 = readFileSync20(path4, "utf8");
44767
+ text4 = readFileSync21(path4, "utf8");
44555
44768
  } catch {
44556
44769
  text4 = "";
44557
44770
  }
@@ -44613,7 +44826,7 @@ function readKimiModelCatalog(env) {
44613
44826
  const dataRoot = kimiDataRoot(env);
44614
44827
  let text4 = "";
44615
44828
  try {
44616
- text4 = readFileSync20(join37(dataRoot, "config.toml"), "utf8");
44829
+ text4 = readFileSync21(join37(dataRoot, "config.toml"), "utf8");
44617
44830
  } catch {
44618
44831
  return STATIC_KIMI_MODELS;
44619
44832
  }
@@ -44760,7 +44973,7 @@ ${turn.text}` : turn.text
44760
44973
  });
44761
44974
 
44762
44975
  // server/drivers/acp/droid.ts
44763
- import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync21, writeFileSync as writeFileSync14 } from "node:fs";
44976
+ import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
44764
44977
  import { homedir as homedir19 } from "node:os";
44765
44978
  import { join as join38 } from "node:path";
44766
44979
  function authFilePaths(env) {
@@ -44785,7 +44998,7 @@ function ensureDroidInjectModel(modelId, env = process.env) {
44785
44998
  const path4 = join38(dir, "settings.json");
44786
44999
  let settings2 = {};
44787
45000
  try {
44788
- settings2 = JSON.parse(readFileSync21(path4, "utf8"));
45001
+ settings2 = JSON.parse(readFileSync22(path4, "utf8"));
44789
45002
  } catch (error51) {
44790
45003
  if (existsSync19(path4)) throw error51;
44791
45004
  }
@@ -44822,7 +45035,7 @@ function applyDroidLocalAuthEnv(env, modelId) {
44822
45035
  env.FACTORY_API_KEY = "openmausbot-local";
44823
45036
  }
44824
45037
  function readSettings(env) {
44825
- return JSON.parse(readFileSync21(join38(factoryHome(env), ".factory", "settings.json"), "utf8"));
45038
+ return JSON.parse(readFileSync22(join38(factoryHome(env), ".factory", "settings.json"), "utf8"));
44826
45039
  }
44827
45040
  async function resolveModels(env) {
44828
45041
  let catalog2 = MODELS3;
@@ -46708,7 +46921,7 @@ var init_muse_code_login = __esm({
46708
46921
  });
46709
46922
 
46710
46923
  // server/drivers/muse-code.ts
46711
- import { existsSync as existsSync20, mkdtempSync as mkdtempSync4, readFileSync as readFileSync22, rmSync as rmSync8, statSync as statSync5 } from "node:fs";
46924
+ import { existsSync as existsSync20, mkdtempSync as mkdtempSync4, readFileSync as readFileSync23, rmSync as rmSync8, statSync as statSync5 } from "node:fs";
46712
46925
  import { readFile as readFile4 } from "node:fs/promises";
46713
46926
  import { homedir as homedir20, tmpdir as tmpdir5 } from "node:os";
46714
46927
  import { join as join39 } from "node:path";
@@ -46721,7 +46934,7 @@ function museCredential(path4) {
46721
46934
  let raw;
46722
46935
  try {
46723
46936
  if (statSync5(path4).size > 1024 * 1024) return { signedIn: false };
46724
- raw = readFileSync22(path4, "utf8");
46937
+ raw = readFileSync23(path4, "utf8");
46725
46938
  } catch {
46726
46939
  return { signedIn: false };
46727
46940
  }
@@ -46763,8 +46976,8 @@ function museCatalog(result, preferred) {
46763
46976
  return { default: preferred ?? listedDefault ?? options[0].id, options };
46764
46977
  }
46765
46978
  function museListedFromAccount(result) {
46766
- const record5 = result ?? {};
46767
- return record5.source !== "bundledCatalog" && Array.isArray(record5.models) && record5.models.length > 0;
46979
+ const record6 = result ?? {};
46980
+ return record6.source !== "bundledCatalog" && Array.isArray(record6.models) && record6.models.length > 0;
46768
46981
  }
46769
46982
  function museApprovalMode(mode) {
46770
46983
  return mode === "full" ? "allowAll" : mode === "auto" ? "onRequest" : "promptUnmatched";
@@ -47473,7 +47686,7 @@ ${body}` : body;
47473
47686
  });
47474
47687
 
47475
47688
  // server/drivers/acp/opencode-go.ts
47476
- import { existsSync as existsSync21, mkdirSync as mkdirSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync15 } from "node:fs";
47689
+ import { existsSync as existsSync21, mkdirSync as mkdirSync19, readFileSync as readFileSync24, writeFileSync as writeFileSync15 } from "node:fs";
47477
47690
  import { homedir as homedir21 } from "node:os";
47478
47691
  import { join as join40 } from "node:path";
47479
47692
  function labelForModel(id) {
@@ -47490,8 +47703,8 @@ function validModelSlug(value) {
47490
47703
  if (separator <= 0 || separator >= value.length - 1 || /\s/u.test(value)) return false;
47491
47704
  return [...value].every((character) => (character.codePointAt(0) ?? 0) > 31);
47492
47705
  }
47493
- function localModelRecord(record5) {
47494
- const api2 = record5.api && typeof record5.api === "object" && !Array.isArray(record5.api) ? record5.api : {};
47706
+ function localModelRecord(record6) {
47707
+ const api2 = record6.api && typeof record6.api === "object" && !Array.isArray(record6.api) ? record6.api : {};
47495
47708
  if (typeof api2.url !== "string") return false;
47496
47709
  try {
47497
47710
  const host = new URL(api2.url).hostname.replace(/^\[|\]$/gu, "");
@@ -47510,27 +47723,27 @@ function parseOpenCodeModelsOutput(stdout2) {
47510
47723
  const separator = slug.indexOf("/");
47511
47724
  const provider = slug.slice(0, separator);
47512
47725
  const model = slug.slice(separator + 1);
47513
- let record5 = {};
47726
+ let record6 = {};
47514
47727
  const raw = jsonLines.join("\n").trim();
47515
47728
  if (raw) {
47516
47729
  try {
47517
47730
  const parsed = JSON.parse(raw);
47518
47731
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
47519
- record5 = parsed;
47732
+ record6 = parsed;
47520
47733
  }
47521
47734
  } catch {
47522
47735
  }
47523
47736
  }
47524
- if (record5.status === "deprecated") return;
47525
- const name = typeof record5.name === "string" && record5.name.trim() ? record5.name.trim() : labelForModel(model);
47526
- const limit = record5.limit && typeof record5.limit === "object" && !Array.isArray(record5.limit) ? record5.limit : {};
47737
+ if (record6.status === "deprecated") return;
47738
+ const name = typeof record6.name === "string" && record6.name.trim() ? record6.name.trim() : labelForModel(model);
47739
+ const limit = record6.limit && typeof record6.limit === "object" && !Array.isArray(record6.limit) ? record6.limit : {};
47527
47740
  const contextWindow = typeof limit.context === "number" && Number.isFinite(limit.context) && limit.context > 0 ? Math.floor(limit.context) : void 0;
47528
- const variants = record5.variants && typeof record5.variants === "object" && !Array.isArray(record5.variants) ? Object.entries(record5.variants).filter(([, settings2]) => settings2 && typeof settings2 === "object" && !Array.isArray(settings2) && settings2.disabled !== true).map(([id]) => ({ id, label: labelForModel(id) })) : void 0;
47741
+ const variants = record6.variants && typeof record6.variants === "object" && !Array.isArray(record6.variants) ? Object.entries(record6.variants).filter(([, settings2]) => settings2 && typeof settings2 === "object" && !Array.isArray(settings2) && settings2.disabled !== true).map(([id]) => ({ id, label: labelForModel(id) })) : void 0;
47529
47742
  seen.add(slug);
47530
47743
  options.push({
47531
47744
  id: slug,
47532
47745
  label: `${providerLabel(provider)} \xB7 ${name}`,
47533
- ...localModelRecord(record5) ? { custom: true, loaded: true } : {},
47746
+ ...localModelRecord(record6) ? { custom: true, loaded: true } : {},
47534
47747
  ...contextWindow ? { contextWindow } : {},
47535
47748
  ...variants ? { variants } : {}
47536
47749
  });
@@ -47592,7 +47805,7 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
47592
47805
  let config2 = { $schema: "https://opencode.ai/config.json" };
47593
47806
  if (existsSync21(path4)) {
47594
47807
  try {
47595
- config2 = JSON.parse(readFileSync23(path4, "utf8"));
47808
+ config2 = JSON.parse(readFileSync24(path4, "utf8"));
47596
47809
  } catch {
47597
47810
  }
47598
47811
  }
@@ -47643,7 +47856,7 @@ function hasStoredOpenCodeAuth(env) {
47643
47856
  if (env.OPENCODE_AUTH_CONTENT) candidates.push(env.OPENCODE_AUTH_CONTENT);
47644
47857
  for (const path4 of storedAuthPaths(env)) {
47645
47858
  try {
47646
- candidates.push(readFileSync23(path4, "utf8"));
47859
+ candidates.push(readFileSync24(path4, "utf8"));
47647
47860
  } catch {
47648
47861
  }
47649
47862
  }
@@ -47785,7 +47998,7 @@ ${turn.text}` : turn.text
47785
47998
  });
47786
47999
 
47787
48000
  // server/drivers/acp/qwen.ts
47788
- import { chmodSync as chmodSync5, existsSync as existsSync22, mkdirSync as mkdirSync20, readFileSync as readFileSync24, writeFileSync as writeFileSync16 } from "node:fs";
48001
+ import { chmodSync as chmodSync5, existsSync as existsSync22, mkdirSync as mkdirSync20, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
47789
48002
  import { createHash as createHash13 } from "node:crypto";
47790
48003
  import { homedir as homedir22 } from "node:os";
47791
48004
  import { join as join41 } from "node:path";
@@ -47803,7 +48016,7 @@ function qwenModelLabel(id, name) {
47803
48016
  function readQwenRoutes(env) {
47804
48017
  let settings2;
47805
48018
  try {
47806
- settings2 = JSON.parse(readFileSync24(join41(qwenHome(env), "settings.json"), "utf8"));
48019
+ settings2 = JSON.parse(readFileSync25(join41(qwenHome(env), "settings.json"), "utf8"));
47807
48020
  } catch {
47808
48021
  return [];
47809
48022
  }
@@ -47891,7 +48104,7 @@ function ensureQwenInjectModel(modelId, env = process.env) {
47891
48104
  let settings2 = {};
47892
48105
  if (existsSync22(path4)) {
47893
48106
  try {
47894
- settings2 = JSON.parse(readFileSync24(path4, "utf8"));
48107
+ settings2 = JSON.parse(readFileSync25(path4, "utf8"));
47895
48108
  } catch {
47896
48109
  }
47897
48110
  }
@@ -48374,7 +48587,7 @@ var init_claude_accounts = __esm({
48374
48587
  });
48375
48588
 
48376
48589
  // server/atomic-engine-accounts.ts
48377
- import { mkdirSync as mkdirSync21, readFileSync as readFileSync25, writeFileSync as writeFileSync17 } from "node:fs";
48590
+ import { mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "node:fs";
48378
48591
  import { homedir as homedir23 } from "node:os";
48379
48592
  import { join as join42 } from "node:path";
48380
48593
  function rawConfig2(entry) {
@@ -48477,7 +48690,7 @@ function writeAtomicEngineAccountsFile(engineHome, accounts) {
48477
48690
  `;
48478
48691
  const path4 = join42(engineHome, ACCOUNTS_FILE);
48479
48692
  try {
48480
- if (readFileSync25(path4, "utf8") === text4) return;
48693
+ if (readFileSync26(path4, "utf8") === text4) return;
48481
48694
  } catch {
48482
48695
  }
48483
48696
  try {
@@ -48551,7 +48764,7 @@ var init_atomic_engine_release = __esm({
48551
48764
 
48552
48765
  // server/atomic-engine-runtime.ts
48553
48766
  import { createHash as createHash14, randomUUID as randomUUID15 } from "node:crypto";
48554
- import { createWriteStream as createWriteStream2, existsSync as existsSync23, mkdirSync as mkdirSync22, readdirSync as readdirSync6, readFileSync as readFileSync26, rmSync as rmSync9, writeFileSync as writeFileSync18 } from "node:fs";
48767
+ import { createWriteStream as createWriteStream2, existsSync as existsSync23, mkdirSync as mkdirSync22, readdirSync as readdirSync6, readFileSync as readFileSync27, rmSync as rmSync9, writeFileSync as writeFileSync18 } from "node:fs";
48555
48768
  import { join as join43 } from "node:path";
48556
48769
  import { Readable, Transform as Transform2 } from "node:stream";
48557
48770
  import { pipeline as pipeline2 } from "node:stream/promises";
@@ -48565,7 +48778,7 @@ function managedAtomicEngine(baseDir = DATA_DIR, asset = atomicEngineAsset(), pl
48565
48778
  if (!asset) return null;
48566
48779
  const root = join43(atomicEngineHome(baseDir), asset.version);
48567
48780
  try {
48568
- if (readFileSync26(join43(root, MARKER2), "utf8").trim() !== asset.sha512) return null;
48781
+ if (readFileSync27(join43(root, MARKER2), "utf8").trim() !== asset.sha512) return null;
48569
48782
  } catch {
48570
48783
  return null;
48571
48784
  }
@@ -55569,11 +55782,11 @@ var init_memory_policy = __esm({
55569
55782
 
55570
55783
  // server/drivers/acp/hermes-memory-lock.ts
55571
55784
  import { createHash as createHash15 } from "node:crypto";
55572
- import { mkdirSync as mkdirSync23, readdirSync as readdirSync7, readFileSync as readFileSync27, writeFileSync as writeFileSync19 } from "node:fs";
55785
+ import { mkdirSync as mkdirSync23, readdirSync as readdirSync7, readFileSync as readFileSync28, writeFileSync as writeFileSync19 } from "node:fs";
55573
55786
  import { join as join44 } from "node:path";
55574
55787
  function readText2(path4) {
55575
55788
  try {
55576
- return readFileSync27(path4, "utf8");
55789
+ return readFileSync28(path4, "utf8");
55577
55790
  } catch {
55578
55791
  return null;
55579
55792
  }
@@ -55586,7 +55799,7 @@ function parseYamlSafe(text4) {
55586
55799
  return null;
55587
55800
  }
55588
55801
  }
55589
- function record2(value) {
55802
+ function record3(value) {
55590
55803
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
55591
55804
  }
55592
55805
  function memoryProviderPlugins(pluginsDir) {
@@ -55599,12 +55812,12 @@ function memoryProviderPlugins(pluginsDir) {
55599
55812
  return dirs.flatMap((dir) => {
55600
55813
  const source2 = (readText2(join44(pluginsDir, dir, "__init__.py")) ?? "").slice(0, 8192);
55601
55814
  if (!source2.includes("register_memory_provider") && !source2.includes("MemoryProvider")) return [];
55602
- const name = record2(parseYamlSafe(readText2(join44(pluginsDir, dir, "plugin.yaml"))))?.name;
55815
+ const name = record3(parseYamlSafe(readText2(join44(pluginsDir, dir, "plugin.yaml"))))?.name;
55603
55816
  return typeof name === "string" && name.trim() && name.trim() !== dir ? [dir, name.trim()] : [dir];
55604
55817
  });
55605
55818
  }
55606
55819
  function lockHermesMemory(env, home, dataDir = DATA_DIR) {
55607
- const own = record2(record2(parseYamlSafe(readText2(join44(home, "config.yaml"))))?.plugins);
55820
+ const own = record3(record3(parseYamlSafe(readText2(join44(home, "config.yaml"))))?.plugins);
55608
55821
  const disabled = new Set(Array.isArray(own?.disabled) ? own.disabled.map(String) : []);
55609
55822
  for (const name of memoryProviderPlugins(join44(home, "plugins"))) disabled.add(name);
55610
55823
  for (const name of BLOCKED_HERMES_MEMORY_PLUGINS) disabled.add(name);
@@ -55630,7 +55843,7 @@ var init_hermes_memory_lock = __esm({
55630
55843
 
55631
55844
  // server/drivers/acp/hermes.ts
55632
55845
  import { spawn as spawn7 } from "node:child_process";
55633
- import { mkdirSync as mkdirSync24, readFileSync as readFileSync28, writeFileSync as writeFileSync20 } from "node:fs";
55846
+ import { mkdirSync as mkdirSync24, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
55634
55847
  import { homedir as homedir24 } from "node:os";
55635
55848
  import { join as join45 } from "node:path";
55636
55849
  function bindHermesScreenshotCompat(env, modelId) {
@@ -55687,7 +55900,7 @@ function ensureHermesInjectProvider(modelId, env = process.env, home = hermesHom
55687
55900
  const path4 = join45(dir, "config.yaml");
55688
55901
  let text4 = "";
55689
55902
  try {
55690
- text4 = readFileSync28(path4, "utf8");
55903
+ text4 = readFileSync29(path4, "utf8");
55691
55904
  } catch {
55692
55905
  text4 = "";
55693
55906
  }
@@ -55755,13 +55968,13 @@ function hermesConfiguredModel(env = process.env) {
55755
55968
  const dir = hermesHome(env);
55756
55969
  let secrets = "";
55757
55970
  try {
55758
- secrets = readFileSync28(join45(dir, ".env"), "utf8");
55971
+ secrets = readFileSync29(join45(dir, ".env"), "utf8");
55759
55972
  } catch {
55760
55973
  }
55761
55974
  const hasHostedProviderKey = HERMES_HOSTED_PROVIDER_KEYS.some((name) => nonEmptyDotenvValue(secrets, name));
55762
55975
  let configuredDefault = null;
55763
55976
  try {
55764
- configuredDefault = hermesConfigDefault(readFileSync28(join45(dir, "config.yaml"), "utf8"));
55977
+ configuredDefault = hermesConfigDefault(readFileSync29(join45(dir, "config.yaml"), "utf8"));
55765
55978
  } catch {
55766
55979
  }
55767
55980
  const configuredProvider = configuredDefault?.provider.toLowerCase() ?? "";
@@ -55786,12 +55999,12 @@ function hermesModelProvider(modelId) {
55786
55999
  }
55787
56000
  function readJson(path4) {
55788
56001
  try {
55789
- return JSON.parse(readFileSync28(path4, "utf8"));
56002
+ return JSON.parse(readFileSync29(path4, "utf8"));
55790
56003
  } catch {
55791
56004
  return null;
55792
56005
  }
55793
56006
  }
55794
- function record3(value) {
56007
+ function record4(value) {
55795
56008
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
55796
56009
  }
55797
56010
  function notExpired(row, now) {
@@ -55806,18 +56019,18 @@ function oauthRowSignedIn(row, now) {
55806
56019
  return present(row.access_token) && notExpired(row, now);
55807
56020
  }
55808
56021
  function hermesSignedInProviders(env = process.env, now = Date.now()) {
55809
- const store = record3(readJson(join45(hermesHome(env), "auth.json")));
56022
+ const store = record4(readJson(join45(hermesHome(env), "auth.json")));
55810
56023
  const out = /* @__PURE__ */ new Set();
55811
56024
  if (!store) return out;
55812
- const providers = record3(store.providers) ?? {};
56025
+ const providers = record4(store.providers) ?? {};
55813
56026
  for (const [id, state2] of Object.entries(providers)) {
55814
- const row = record3(state2);
56027
+ const row = record4(state2);
55815
56028
  if (row && oauthRowSignedIn(row, now)) out.add(id.toLowerCase());
55816
56029
  }
55817
- for (const [id, rows] of Object.entries(record3(store.credential_pool) ?? {})) {
56030
+ for (const [id, rows] of Object.entries(record4(store.credential_pool) ?? {})) {
55818
56031
  if (id in providers || !Array.isArray(rows)) continue;
55819
56032
  const signedIn = rows.some((value) => {
55820
- const row = record3(value);
56033
+ const row = record4(value);
55821
56034
  if (!row) return false;
55822
56035
  const oauth = String(row.auth_type ?? "").toLowerCase().startsWith("oauth") || present(row.refresh_token);
55823
56036
  return oauth && present(row.access_token) && oauthRowSignedIn(row, now);
@@ -55830,7 +56043,7 @@ function hermesZaiCodingPlan(env = process.env) {
55830
56043
  const dir = hermesHome(env);
55831
56044
  let secrets = "";
55832
56045
  try {
55833
- secrets = readFileSync28(join45(dir, ".env"), "utf8");
56046
+ secrets = readFileSync29(join45(dir, ".env"), "utf8");
55834
56047
  } catch {
55835
56048
  }
55836
56049
  const keyed = ["GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"].some((name) => present(env[name]) || nonEmptyDotenvValue(secrets, name));
@@ -55838,21 +56051,21 @@ function hermesZaiCodingPlan(env = process.env) {
55838
56051
  const coding = (url2) => typeof url2 === "string" && /\/api\/coding\/paas\//i.test(url2);
55839
56052
  const override = present(env.GLM_BASE_URL) ? env.GLM_BASE_URL : nonEmptyDotenvValue(secrets, "GLM_BASE_URL");
55840
56053
  if (override) return coding(override);
55841
- const detected = record3(record3(record3(record3(readJson(join45(dir, "auth.json")))?.providers)?.zai)?.detected_endpoint);
56054
+ const detected = record4(record4(record4(record4(readJson(join45(dir, "auth.json")))?.providers)?.zai)?.detected_endpoint);
55842
56055
  return coding(detected?.base_url);
55843
56056
  }
55844
56057
  function hermesZaiPlanHosts(options, codingPlan) {
55845
56058
  return codingPlan ? options.map((option) => option.provider === "zai" ? { ...option, provider: "zai-coding-plan" } : option) : [...options];
55846
56059
  }
55847
56060
  function hermesCachedModels(home, provider) {
55848
- const catalog2 = record3(record3(record3(readJson(join45(home, "cache", "model_catalog.json")))?.providers)?.[provider]);
55849
- const name = String(record3(catalog2?.metadata)?.display_name ?? "").trim() || provider;
55850
- const rows = Array.isArray(catalog2?.models) ? catalog2.models.map(record3).filter((row) => row && present(row.id)) : [];
56061
+ const catalog2 = record4(record4(record4(readJson(join45(home, "cache", "model_catalog.json")))?.providers)?.[provider]);
56062
+ const name = String(record4(catalog2?.metadata)?.display_name ?? "").trim() || provider;
56063
+ const rows = Array.isArray(catalog2?.models) ? catalog2.models.map(record4).filter((row) => row && present(row.id)) : [];
55851
56064
  if (rows.length) {
55852
56065
  const ordered = [...rows.filter((row) => row.default === true), ...rows.filter((row) => row.default !== true)];
55853
56066
  return { ids: ordered.map((row) => String(row.id).trim()), name };
55854
56067
  }
55855
- const cached3 = record3(record3(readJson(join45(home, "provider_models_cache.json")))?.[provider])?.models;
56068
+ const cached3 = record4(record4(readJson(join45(home, "provider_models_cache.json")))?.[provider])?.models;
55856
56069
  return { ids: Array.isArray(cached3) ? cached3.filter(present).map((id) => String(id).trim()) : [], name };
55857
56070
  }
55858
56071
  function hermesAuthStoreModels(env = process.env, now = Date.now()) {
@@ -55870,7 +56083,7 @@ function hermesConfiguredHostModel(env = process.env) {
55870
56083
  const home = hermesHome(env);
55871
56084
  let configured = null;
55872
56085
  try {
55873
- configured = hermesConfigDefault(readFileSync28(join45(home, "config.yaml"), "utf8"));
56086
+ configured = hermesConfigDefault(readFileSync29(join45(home, "config.yaml"), "utf8"));
55874
56087
  } catch {
55875
56088
  return null;
55876
56089
  }
@@ -56244,8 +56457,8 @@ function decodeConfig5(raw) {
56244
56457
  return config2;
56245
56458
  }
56246
56459
  function ollamaCloudCatalog(body, configuredModel) {
56247
- const record5 = body && typeof body === "object" && !Array.isArray(body) ? body : null;
56248
- const rows = Array.isArray(body) ? body : Array.isArray(record5?.data) ? record5.data : [];
56460
+ const record6 = body && typeof body === "object" && !Array.isArray(body) ? body : null;
56461
+ const rows = Array.isArray(body) ? body : Array.isArray(record6?.data) ? record6.data : [];
56249
56462
  const options = [];
56250
56463
  const seen = /* @__PURE__ */ new Set();
56251
56464
  for (const row of rows) {
@@ -56501,13 +56714,13 @@ var init_openai_compat = __esm({
56501
56714
  });
56502
56715
 
56503
56716
  // server/drivers/pi.ts
56504
- import { chmodSync as chmodSync6, existsSync as existsSync24, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync5, readFileSync as readFileSync29, rmSync as rmSync10, writeFileSync as writeFileSync21 } from "node:fs";
56717
+ import { chmodSync as chmodSync6, existsSync as existsSync24, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync5, readFileSync as readFileSync30, rmSync as rmSync10, writeFileSync as writeFileSync21 } from "node:fs";
56505
56718
  import { homedir as homedir26, tmpdir as tmpdir6 } from "node:os";
56506
56719
  import { join as join47 } from "node:path";
56507
56720
  function readPiPromptImages(turn) {
56508
56721
  return (turn.images ?? []).map((image) => ({
56509
56722
  type: "image",
56510
- data: readFileSync29(image.path).toString("base64"),
56723
+ data: readFileSync30(image.path).toString("base64"),
56511
56724
  mimeType: image.mime
56512
56725
  }));
56513
56726
  }
@@ -56564,7 +56777,7 @@ function piMcpToolRef(title, customServers, hintsPath) {
56564
56777
  const tool2 = match[2];
56565
56778
  if (!hintsPath) return { server, tool: tool2 };
56566
56779
  try {
56567
- const hints = JSON.parse(readFileSync29(hintsPath, "utf8"));
56780
+ const hints = JSON.parse(readFileSync30(hintsPath, "utf8"));
56568
56781
  const known = hints?.[server]?.[tool2];
56569
56782
  return known && typeof known === "object" ? { server, tool: tool2, annotations: known } : { server, tool: tool2 };
56570
56783
  } catch {
@@ -56640,7 +56853,7 @@ function ensurePiInjectModel(modelId, env = process.env) {
56640
56853
  let root = { providers: {} };
56641
56854
  if (existsSync24(path4)) {
56642
56855
  try {
56643
- const parsed = JSON.parse(readFileSync29(path4, "utf8"));
56856
+ const parsed = JSON.parse(readFileSync30(path4, "utf8"));
56644
56857
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
56645
56858
  root = parsed;
56646
56859
  } else {
@@ -56692,7 +56905,7 @@ function ensurePiInjectModel(modelId, env = process.env) {
56692
56905
  function readPiDefaultModel(env) {
56693
56906
  const home = env.HOME || env.USERPROFILE || homedir26();
56694
56907
  try {
56695
- const s4 = JSON.parse(readFileSync29(`${home}/.pi/agent/settings.json`, "utf8"));
56908
+ const s4 = JSON.parse(readFileSync30(`${home}/.pi/agent/settings.json`, "utf8"));
56696
56909
  return s4.defaultProvider && s4.defaultModel ? `${s4.defaultProvider}/${s4.defaultModel}` : "";
56697
56910
  } catch {
56698
56911
  return "";
@@ -57357,7 +57570,7 @@ var init_mistral = __esm({
57357
57570
  });
57358
57571
 
57359
57572
  // server/drivers/minimax.ts
57360
- import { readFileSync as readFileSync30 } from "node:fs";
57573
+ import { readFileSync as readFileSync31 } from "node:fs";
57361
57574
  import { homedir as homedir27 } from "node:os";
57362
57575
  import { join as join48 } from "node:path";
57363
57576
  function normalizedApiUrl(value) {
@@ -57366,7 +57579,7 @@ function normalizedApiUrl(value) {
57366
57579
  }
57367
57580
  function loadLocalMiniMaxConfig(home = homedir27()) {
57368
57581
  try {
57369
- const raw = localConfigSchema.parse(JSON.parse(readFileSync30(join48(home, ".mmx", "config.json"), "utf8")));
57582
+ const raw = localConfigSchema.parse(JSON.parse(readFileSync31(join48(home, ".mmx", "config.json"), "utf8")));
57370
57583
  const configuredUrl = raw.base_url?.trim() ? raw.base_url : raw.region === "cn" ? CN_URL : DEFAULT_URL3;
57371
57584
  return {
57372
57585
  apiKey: raw.api_key?.trim() ?? "",
@@ -57842,10 +58055,14 @@ var init_apple_intelligence2 = __esm({
57842
58055
  });
57843
58056
 
57844
58057
  // server/drivers/builtIn.ts
57845
- var BUILT_IN_DRIVERS;
58058
+ function builtInDriversFor(platform) {
58059
+ return ALL_BUILT_IN_DRIVERS.filter((driver) => engineOnPlatform(driver.driverKind, platform));
58060
+ }
58061
+ var ALL_BUILT_IN_DRIVERS, BUILT_IN_DRIVERS;
57846
58062
  var init_builtIn = __esm({
57847
58063
  "server/drivers/builtIn.ts"() {
57848
58064
  "use strict";
58065
+ init_engine_platforms();
57849
58066
  init_antigravity();
57850
58067
  init_boxagent();
57851
58068
  init_claude();
@@ -57868,7 +58085,7 @@ var init_builtIn = __esm({
57868
58085
  init_minimax();
57869
58086
  init_ollama_cloud();
57870
58087
  init_apple_intelligence2();
57871
- BUILT_IN_DRIVERS = [
58088
+ ALL_BUILT_IN_DRIVERS = [
57872
58089
  GrokDriver,
57873
58090
  GrokAgentDriver,
57874
58091
  GeminiAgentDriver,
@@ -57892,6 +58109,7 @@ var init_builtIn = __esm({
57892
58109
  OllamaCloudDriver,
57893
58110
  AppleIntelligenceDriver
57894
58111
  ];
58112
+ BUILT_IN_DRIVERS = builtInDriversFor(process.platform);
57895
58113
  }
57896
58114
  });
57897
58115
 
@@ -57969,10 +58187,10 @@ async function setupJson(url2, key, body) {
57969
58187
  }
57970
58188
  }
57971
58189
  async function fetchSetupModels(url2, key) {
57972
- const json2 = record4(await setupJson(url2, key));
58190
+ const json2 = record5(await setupJson(url2, key));
57973
58191
  const models2 = /* @__PURE__ */ new Map();
57974
58192
  for (const entry of Array.isArray(json2?.data) ? json2.data : []) {
57975
- const item = record4(entry);
58193
+ const item = record5(entry);
57976
58194
  const id = typeof item?.id === "string" ? item.id.trim() : "";
57977
58195
  if (!id || /[\u0000-\u001f\u007f]/u.test(id) || models2.has(id)) continue;
57978
58196
  const name = typeof item?.name === "string" ? item.name.replace(/[\u0000-\u001f\u007f]/gu, "").trim() : "";
@@ -57986,19 +58204,19 @@ async function verifySetupCompletion(url2, key, model, provider) {
57986
58204
  if (!id || /[\u0000-\u001f\u007f]/u.test(id)) throw new SetupApiError("Choose a non-empty model ID without control characters.");
57987
58205
  const host = new URL(normalizeApiUrl(url2)).hostname.toLowerCase();
57988
58206
  const pinProvider = provider && (host === "openrouter.ai" || host.endsWith(".openrouter.ai"));
57989
- const json2 = record4(await setupJson(url2, key, {
58207
+ const json2 = record5(await setupJson(url2, key, {
57990
58208
  model: id,
57991
58209
  messages: [{ role: "user", content: "Reply with exactly OK." }],
57992
58210
  stream: false,
57993
58211
  ...pinProvider ? { provider: { order: [provider], allow_fallbacks: false } } : {}
57994
58212
  }));
57995
- const choice = record4(Array.isArray(json2?.choices) ? json2.choices[0] : void 0);
57996
- const message2 = record4(choice?.message);
58213
+ const choice = record5(Array.isArray(json2?.choices) ? json2.choices[0] : void 0);
58214
+ const message2 = record5(choice?.message);
57997
58215
  if (message2?.role !== "assistant" || typeof message2.content !== "string" || !message2.content.trim()) {
57998
58216
  throw new SetupApiError("The API did not return an assistant text reply. Choose a model that supports Chat Completions, then try again.");
57999
58217
  }
58000
58218
  }
58001
- var API_ENDPOINTS, SetupApiError, record4;
58219
+ var API_ENDPOINTS, SetupApiError, record5;
58002
58220
  var init_cli_api_setup = __esm({
58003
58221
  "server/cli-api-setup.ts"() {
58004
58222
  "use strict";
@@ -58009,7 +58227,7 @@ var init_cli_api_setup = __esm({
58009
58227
  ];
58010
58228
  SetupApiError = class extends Error {
58011
58229
  };
58012
- record4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
58230
+ record5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
58013
58231
  }
58014
58232
  });
58015
58233
 
@@ -58023,7 +58241,7 @@ __export(cli_setup_exports, {
58023
58241
  saveCliStartup: () => saveCliStartup
58024
58242
  });
58025
58243
  import { spawn as spawn9 } from "node:child_process";
58026
- import { readFileSync as readFileSync31 } from "node:fs";
58244
+ import { readFileSync as readFileSync32 } from "node:fs";
58027
58245
  import { join as join50, resolve as resolve11 } from "node:path";
58028
58246
  import { randomUUID as randomUUID16 } from "node:crypto";
58029
58247
  async function inspect(id, entry) {
@@ -58061,7 +58279,7 @@ function assertDataDir(dataDir) {
58061
58279
  }
58062
58280
  function checkStoredConfig(dataDir) {
58063
58281
  try {
58064
- parseStoredConfig(JSON.parse(readFileSync31(join50(dataDir, "config.json"), "utf8")));
58282
+ parseStoredConfig(JSON.parse(readFileSync32(join50(dataDir, "config.json"), "utf8")));
58065
58283
  } catch (error51) {
58066
58284
  if (error51.code === "ENOENT") return;
58067
58285
  throw new Error("Existing config.json could not be read or validated. Setup has not changed it; repair it before continuing.");
@@ -58471,7 +58689,7 @@ __export(browser_engine_exports, {
58471
58689
  resolveAgentBrowserBinary: () => resolveAgentBrowserBinary
58472
58690
  });
58473
58691
  import { createHash as createHash16, randomBytes as randomBytes3, randomUUID as randomUUID17 } from "node:crypto";
58474
- import { chmodSync as chmodSync7, constants as constants3, copyFileSync, existsSync as existsSync25, mkdirSync as mkdirSync26, readFileSync as readFileSync32, readdirSync as readdirSync8, renameSync as renameSync8, rmSync as rmSync11, statSync as statSync6, unlinkSync as unlinkSync7, writeFileSync as writeFileSync22 } from "node:fs";
58692
+ import { chmodSync as chmodSync7, constants as constants3, copyFileSync, existsSync as existsSync25, mkdirSync as mkdirSync26, readFileSync as readFileSync33, readdirSync as readdirSync8, renameSync as renameSync8, rmSync as rmSync11, statSync as statSync6, unlinkSync as unlinkSync7, writeFileSync as writeFileSync22 } from "node:fs";
58475
58693
  import { homedir as homedir28, tmpdir as tmpdir7 } from "node:os";
58476
58694
  import { delimiter as delimiter7, dirname as dirname12, join as join53, resolve as resolve12 } from "node:path";
58477
58695
  function browserRestoreKey(session) {
@@ -58495,7 +58713,7 @@ function ensureManagedBrowserConfig(env) {
58495
58713
  writeFileSync22(path4, "{}\n", { flag: "wx", mode: 384 });
58496
58714
  } catch (error51) {
58497
58715
  if (error51.code !== "EEXIST") throw error51;
58498
- if (readFileSync32(path4, "utf8").trim() !== "{}") throw new Error("The managed browser configuration was changed. Restore it to an empty JSON object before connecting.");
58716
+ if (readFileSync33(path4, "utf8").trim() !== "{}") throw new Error("The managed browser configuration was changed. Restore it to an empty JSON object before connecting.");
58499
58717
  }
58500
58718
  return path4;
58501
58719
  }
@@ -58751,12 +58969,12 @@ function ensureChrome(binaryPath, options = {}) {
58751
58969
  return new Promise((done, fail) => {
58752
58970
  const child = spawnCommand(binaryPath, args, { env: options.env ?? process.env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
58753
58971
  let output = "";
58754
- const record5 = (chunk) => {
58972
+ const record6 = (chunk) => {
58755
58973
  output += String(chunk);
58756
58974
  if (output.length > 262144) output = output.slice(-262144);
58757
58975
  };
58758
- child.stdout?.on("data", record5);
58759
- child.stderr?.on("data", record5);
58976
+ child.stdout?.on("data", record6);
58977
+ child.stderr?.on("data", record6);
58760
58978
  let timedOut = false;
58761
58979
  let exited = false;
58762
58980
  const timer = setTimeout(() => {
@@ -58790,7 +59008,7 @@ function ensureChrome(binaryPath, options = {}) {
58790
59008
  function browserEngineEncryptionKey(dataDir = DATA_DIR) {
58791
59009
  const file2 = join53(dataDir, KEY_FILE);
58792
59010
  try {
58793
- const existing = readFileSync32(file2, "utf8").trim();
59011
+ const existing = readFileSync33(file2, "utf8").trim();
58794
59012
  if (/^[0-9a-f]{64}$/u.test(existing)) return existing;
58795
59013
  } catch {
58796
59014
  }
@@ -58871,7 +59089,7 @@ function agentBrowserFrame(input) {
58871
59089
  fail(error51);
58872
59090
  return;
58873
59091
  }
58874
- settle({ png: readFileSync32(file2).toString("base64"), format: "png" });
59092
+ settle({ png: readFileSync33(file2).toString("base64"), format: "png" });
58875
59093
  } catch {
58876
59094
  fail(new Error("the browser reported a picture it did not write"));
58877
59095
  } finally {
@@ -59036,7 +59254,7 @@ Or run without a global install: \`npx @chibitek/chibi\`. Node 24+ is required.
59036
59254
  var import_qrcode_terminal = __toESM(require_main(), 1);
59037
59255
  import { spawn as spawn10 } from "node:child_process";
59038
59256
  import { randomBytes as randomBytes4 } from "node:crypto";
59039
- import { closeSync as closeSync6, existsSync as existsSync26, mkdirSync as mkdirSync27, openSync as openSync6, readFileSync as readFileSync33 } from "node:fs";
59257
+ import { closeSync as closeSync6, existsSync as existsSync26, mkdirSync as mkdirSync27, openSync as openSync6, readFileSync as readFileSync34 } from "node:fs";
59040
59258
  import { homedir as homedir29 } from "node:os";
59041
59259
  import { dirname as dirname13, join as join54, resolve as resolve13 } from "node:path";
59042
59260
  import { createInterface as createInterface2 } from "node:readline/promises";
@@ -59061,18 +59279,18 @@ var isPlainRecord = (value) => {
59061
59279
  };
59062
59280
  var plainObject = (value) => {
59063
59281
  if (!isPlainRecord(value)) return null;
59064
- const record5 = {};
59282
+ const record6 = {};
59065
59283
  try {
59066
59284
  for (const key of Reflect.ownKeys(value)) {
59067
59285
  if (!Object.prototype.propertyIsEnumerable.call(value, key)) continue;
59068
59286
  if (typeof key !== "string") return null;
59069
59287
  if (key === "__proto__") continue;
59070
- record5[key] = value[key];
59288
+ record6[key] = value[key];
59071
59289
  }
59072
59290
  } catch {
59073
59291
  return null;
59074
59292
  }
59075
- return record5;
59293
+ return record6;
59076
59294
  };
59077
59295
  var validClientInstance = (value) => {
59078
59296
  const input = stringValue(value);
@@ -60552,14 +60770,14 @@ async function writeRow(dataDir, row) {
60552
60770
  }
60553
60771
  }
60554
60772
  function appendAdminAction(dataDir, row) {
60555
- const record5 = {
60773
+ const record6 = {
60556
60774
  ...row,
60557
60775
  at: row.at ?? (/* @__PURE__ */ new Date()).toISOString(),
60558
60776
  ...row.before ? { before: auditValues(row.before) } : {},
60559
60777
  ...row.after ? { after: auditValues(row.after) } : {}
60560
60778
  };
60561
60779
  const previous = writeQueues.get(dataDir) ?? Promise.resolve();
60562
- const queued = previous.then(() => writeRow(dataDir, record5)).catch(() => {
60780
+ const queued = previous.then(() => writeRow(dataDir, record6)).catch(() => {
60563
60781
  });
60564
60782
  writeQueues.set(dataDir, queued);
60565
60783
  void queued.finally(() => {
@@ -61292,16 +61510,16 @@ function emptyRegistry(domain2) {
61292
61510
  }
61293
61511
  function parseRegistry(text4) {
61294
61512
  const value = JSON.parse(text4);
61295
- const record5 = value && typeof value === "object" ? value : null;
61296
- if (!record5 || record5.version !== 1 || typeof record5.domain !== "string" || typeof record5.nextPort !== "number" || !record5.workspaces || typeof record5.workspaces !== "object") {
61513
+ const record6 = value && typeof value === "object" ? value : null;
61514
+ if (!record6 || record6.version !== 1 || typeof record6.domain !== "string" || typeof record6.nextPort !== "number" || !record6.workspaces || typeof record6.workspaces !== "object") {
61297
61515
  throw new Error("fleet.json is not a fleet registry this version understands");
61298
61516
  }
61299
61517
  return {
61300
61518
  version: 1,
61301
- domain: record5.domain,
61302
- nextPort: record5.nextPort,
61303
- ...typeof record5.operator === "string" ? { operator: record5.operator } : {},
61304
- workspaces: { ...record5.workspaces }
61519
+ domain: record6.domain,
61520
+ nextPort: record6.nextPort,
61521
+ ...typeof record6.operator === "string" ? { operator: record6.operator } : {},
61522
+ workspaces: { ...record6.workspaces }
61305
61523
  };
61306
61524
  }
61307
61525
  function fleetUser(slug) {
@@ -62866,7 +63084,7 @@ function defaultIo() {
62866
63084
  }
62867
63085
  function serverVersion(here = HERE2) {
62868
63086
  try {
62869
- const parsed = JSON.parse(readFileSync33(resolve13(here, "..", "package.json"), "utf8"));
63087
+ const parsed = JSON.parse(readFileSync34(resolve13(here, "..", "package.json"), "utf8"));
62870
63088
  const version2 = typeof parsed === "object" && parsed !== null ? Reflect.get(parsed, "version") : void 0;
62871
63089
  return typeof version2 === "string" && version2 ? version2 : "0.0.0";
62872
63090
  } catch {
@@ -62897,7 +63115,7 @@ async function isWorkspaceRunning(options) {
62897
63115
  try {
62898
63116
  const { status, body } = await api(options.port, "/api/health");
62899
63117
  if (status !== 200 || body?.app !== "openmausbot") return false;
62900
- const expected = readFileSync33(join54(options.dataDir, "environment-id"), "utf8").trim();
63118
+ const expected = readFileSync34(join54(options.dataDir, "environment-id"), "utf8").trim();
62901
63119
  const descriptor = await api(options.port, "/.well-known/openmausbot/environment");
62902
63120
  return /^[0-9a-f-]{36}$/i.test(expected) && descriptor.status === 200 && descriptor.body?.environmentId === expected;
62903
63121
  } catch {
@@ -63140,7 +63358,7 @@ async function runAccess(options, io2 = defaultIo()) {
63140
63358
  let raw = {};
63141
63359
  if (existsSync26(file2)) {
63142
63360
  try {
63143
- const parsed = JSON.parse(readFileSync33(file2, "utf8"));
63361
+ const parsed = JSON.parse(readFileSync34(file2, "utf8"));
63144
63362
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("not an object");
63145
63363
  raw = Object.fromEntries(Object.entries(parsed));
63146
63364
  } catch (error51) {