openmausbot 0.1.86 → 0.1.88

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 (216) hide show
  1. package/README.md +4 -3
  2. package/dist/assets/{abnfDiagram-O67JEVCF-DpUZNnFD.js → abnfDiagram-O67JEVCF-qd9VD3GV.js} +1 -1
  3. package/dist/assets/{arc-DW7mrI4p.js → arc-3RwkUjRe.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-CyeZ5WLZ.js → architectureDiagram-NJMV4G6O-CFKSJS7a.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-CBVaNjO7.js → blockDiagram-BEXU5L5S-CG1rEfWD.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-sf8d41uT.js → c4Diagram-YGBWAQC7-CBW9N664.js} +1 -1
  7. package/dist/assets/channel-CnRnO3tF.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-BOGvy7Y_.js → chunk-2Q5K7J3B-2mRfTksB.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-BiF9zyiz.js → chunk-3FUC2YCW-Cv1dpErj.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-EFuZ1SBZ.js → chunk-5VM5RSS4-B7IACJp-.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-pJLNSAT7.js → chunk-GTNCS2PH-An0hZtYa.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-Cb-3_3IT.js → chunk-GWA4HPMP-BcJB2nEm.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-DAf5aogn.js → chunk-JWPE2WC7-CV_W7TN7.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-DR3kiwZz.js → chunk-NETBCI7D-Bcs_kwnA.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-BmU8PeyM.js → chunk-WEXAMYUT-lrx_DxFP.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-Buh8g8OT.js → chunk-XXDRQBXY-DabHlLGM.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-BurfmMWM.js → classDiagram-v2-NBCMYWYE-BnHj6P7d.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-KkGZUEkU.js → cose-bilkent-JH36ORCC-CfLp6UDi.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-C3PpV96d.js → cynefin-OW5HDTMX-Dm4dbVA1.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-Dt8JwJaI.js → cynefinDiagram-VND7K2PF-B9mH-PID.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-DkjN8266.js → dagre-6A5THRUB-DDc_NVQJ.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-DUAJS0JV.js → diagram-22UHCM2B-lwr8Ip8-.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-Dw4KhF1a.js → diagram-3UASUU5V-BLLe6dmI.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-Dd1gmQqf.js → diagram-ATOU4E4O-6eUIq4lz.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-CjwGs0Yw.js → diagram-CDSNMT55-O-pRN7VQ.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-BL-69Zrq.js → diagram-MLGK6HIB-BietvGAI.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-5Zi2N7wo.js → diagram-MPIPVDR6-Bd2Cl62X.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-D9NekWUX.js → ebnfDiagram-ZINNZB2B-B6iDy69W.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-CkaSQjxw.js → elk-276RUBZZ-DQVHfKe0.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-CdAVBV8-.js → erDiagram-OPXOYQCR-BWdVp2tQ.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-Bm_lWWH7.js → flowDiagram-KWPJA3E3-WLE6rKB4.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-FZ8ejYWJ.js → ganttDiagram-FUAMR5RP-BbjS-4gn.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-Dlv9rizZ.js → gitGraphDiagram-X574FWY7-Dpy2QSGq.js} +1 -1
  34. package/dist/assets/index-BIMdIbaw.css +1 -0
  35. package/dist/assets/index-CHnODCr2.js +583 -0
  36. package/dist/assets/{index-h9FFNwTu.js → index-CIaHn5NS.js} +1 -1
  37. package/dist/assets/{infoDiagram-VRGFBTTK-BdQ_gW5B.js → infoDiagram-VRGFBTTK-D_jKWlKe.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-OU5B5YK6-EwssEp2X.js → ishikawaDiagram-OU5B5YK6-DLJohSuK.js} +1 -1
  39. package/dist/assets/{journeyDiagram-ZHPQQLJL-BX1G1vOd.js → journeyDiagram-ZHPQQLJL-DPOFj0qN.js} +1 -1
  40. package/dist/assets/{kanban-definition-PNTS6WVX-BB4kAsyC.js → kanban-definition-PNTS6WVX-BI7v-xpK.js} +1 -1
  41. package/dist/assets/{linear-3su2TG93.js → linear-C2pWPSxO.js} +1 -1
  42. package/dist/assets/{mermaid.core-CDD1E0s9.js → mermaid.core-CR-j5WQU.js} +5 -5
  43. package/dist/assets/{mindmap-definition-NLK3R4M7-Ba50MsNK.js → mindmap-definition-NLK3R4M7-lz9GvXRh.js} +1 -1
  44. package/dist/assets/{pegDiagram-GJSIUBJH-DZLkkZlM.js → pegDiagram-GJSIUBJH-Dl4_ia61.js} +1 -1
  45. package/dist/assets/{pieDiagram-5QR66LMP-DaTz77Uq.js → pieDiagram-5QR66LMP-DWuT3n88.js} +1 -1
  46. package/dist/assets/{quadrantDiagram-O4NWA36T-CpaiidpR.js → quadrantDiagram-O4NWA36T-DXWe9Jx7.js} +1 -1
  47. package/dist/assets/{railroadDiagram-XR7U4H2S-mN4JrMeI.js → railroadDiagram-XR7U4H2S-COY1IBVY.js} +1 -1
  48. package/dist/assets/{requirementDiagram-PLB6GJNP-BSNDRpg7.js → requirementDiagram-PLB6GJNP-DnyVuhsQ.js} +1 -1
  49. package/dist/assets/{sankeyDiagram-IPEJSGJF-FngzGNug.js → sankeyDiagram-IPEJSGJF-BSc4NdGK.js} +1 -1
  50. package/dist/assets/{sequenceDiagram-PO4LG4MO-CM4pCC3L.js → sequenceDiagram-PO4LG4MO-kqEU2EGq.js} +1 -1
  51. package/dist/assets/{sizeCapture-INFHLROL-CRICHXkw.js → sizeCapture-INFHLROL-BvB4bkWD.js} +1 -1
  52. package/dist/assets/{stateDiagram-v2-GCMORJYK-oyTWpxH2.js → stateDiagram-v2-GCMORJYK-BIrqNv7y.js} +1 -1
  53. package/dist/assets/{swimlanes-2SLR337P-D9h9mPBq.js → swimlanes-2SLR337P-CFnalQUE.js} +1 -1
  54. package/dist/assets/swimlanesDiagram-TC7HE7FX-C4a8qNGj.js +8 -0
  55. package/dist/assets/{timeline-definition-EJHVYXUP-BJUlN9bW.js → timeline-definition-EJHVYXUP-CsSWJnSQ.js} +1 -1
  56. package/dist/assets/{usecaseDiagram-POWQR4AR-3uBNkbAb.js → usecaseDiagram-POWQR4AR-DkAmJ1EE.js} +1 -1
  57. package/dist/assets/{vennDiagram-UO4OBE2U-D2odalzT.js → vennDiagram-UO4OBE2U-C3vd9drL.js} +1 -1
  58. package/dist/assets/{wardleyDiagram-VNRHLVJA-DHgFaB9S.js → wardleyDiagram-VNRHLVJA-j26CM-pi.js} +1 -1
  59. package/dist/assets/{xychartDiagram-PMCCYNJV-w5GYM2h0.js → xychartDiagram-PMCCYNJV-BYu1Q_at.js} +1 -1
  60. package/dist/index.html +2 -2
  61. package/dist-server/browser-proxy.js +2 -1
  62. package/dist-server/companion/src/routes.js +8 -1
  63. package/dist-server/connector-proxy.js +105 -1
  64. package/dist-server/container-mcp.js +1032 -165
  65. package/dist-server/drivers/agents-proxy.js +338 -29
  66. package/dist-server/drivers/phone-proxy.js +33 -2
  67. package/dist-server/index.js +40590 -31811
  68. package/dist-server/local-computer-proxy.js +5 -3
  69. package/dist-server/local-computer.js +53 -17
  70. package/dist-server/mcp-gate.js +2 -0
  71. package/dist-server/mcp-server.js +5 -3
  72. package/dist-server/message-search.worker.js +52 -0
  73. package/dist-server/openmausbot.js +4457 -1399
  74. package/dist-server/pair-cli.js +4457 -1399
  75. package/dist-server/permission-proxy.js +29 -9
  76. package/dist-server/server/admission.js +81 -0
  77. package/dist-server/server/aside-queue.js +294 -0
  78. package/dist-server/server/attachments.js +98 -1
  79. package/dist-server/server/auto-approve.js +4 -3
  80. package/dist-server/server/auto-vm-claims.js +1 -0
  81. package/dist-server/server/bot-attachment.js +107 -0
  82. package/dist-server/server/bot-overview.js +19 -0
  83. package/dist-server/server/bot-package.js +18 -292
  84. package/dist-server/server/bot-profile.js +5 -17
  85. package/dist-server/server/box-create-idempotency.js +3 -3
  86. package/dist-server/server/box.js +57 -55
  87. package/dist-server/server/browser-proxy.js +3 -2
  88. package/dist-server/server/browser-runtime.js +37 -1
  89. package/dist-server/server/cli-api-setup.js +1 -0
  90. package/dist-server/server/cli.js +2 -2
  91. package/dist-server/server/command-allowlist.js +154 -0
  92. package/dist-server/server/composio.js +297 -1
  93. package/dist-server/server/computer-wait.js +22 -9
  94. package/dist-server/server/config.js +84 -12
  95. package/dist-server/server/connector-advertisement.js +165 -0
  96. package/dist-server/server/connector-proxy.js +14 -2
  97. package/dist-server/server/connector-verdict.js +168 -0
  98. package/dist-server/server/container-computer.js +61 -1
  99. package/dist-server/server/contracts.js +22 -0
  100. package/dist-server/server/default-model-selection.js +9 -0
  101. package/dist-server/server/delegations.js +85 -34
  102. package/dist-server/server/drivers/acp/core.js +80 -20
  103. package/dist-server/server/drivers/acp/cursor.js +3 -7
  104. package/dist-server/server/drivers/acp/droid.js +4 -7
  105. package/dist-server/server/drivers/acp/gemini.js +4 -4
  106. package/dist-server/server/drivers/acp/grok.js +4 -9
  107. package/dist-server/server/drivers/acp/hermes.js +3 -5
  108. package/dist-server/server/drivers/acp/opencode-go.js +2 -5
  109. package/dist-server/server/drivers/acp/qwen.js +9 -15
  110. package/dist-server/server/drivers/agents-call.js +179 -13
  111. package/dist-server/server/drivers/agents-catalog.js +134 -10
  112. package/dist-server/server/drivers/boxagent.js +160 -36
  113. package/dist-server/server/drivers/builtIn.js +2 -0
  114. package/dist-server/server/drivers/chat-box-tools.js +90 -0
  115. package/dist-server/server/drivers/chat-images.js +54 -0
  116. package/dist-server/server/drivers/chat-mcp-tools.js +38 -8
  117. package/dist-server/server/drivers/chat-tool-approval.js +70 -18
  118. package/dist-server/server/drivers/claude.js +38 -19
  119. package/dist-server/server/drivers/codex-catalog.js +14 -6
  120. package/dist-server/server/drivers/codex-identity.js +2 -1
  121. package/dist-server/server/drivers/codex-instructions.js +48 -6
  122. package/dist-server/server/drivers/codex-release.js +48 -0
  123. package/dist-server/server/drivers/codex-tool-surface.js +20 -0
  124. package/dist-server/server/drivers/codex.js +102 -55
  125. package/dist-server/server/drivers/mistral.js +115 -0
  126. package/dist-server/server/drivers/openai-chat.js +180 -33
  127. package/dist-server/server/drivers/openai-compat.js +1 -0
  128. package/dist-server/server/drivers/permission-command.js +35 -0
  129. package/dist-server/server/drivers/phone-proxy.js +47 -2
  130. package/dist-server/server/drivers/pi.js +306 -28
  131. package/dist-server/server/drivers/prompt-split.js +110 -0
  132. package/dist-server/server/drivers/session-idle.js +29 -0
  133. package/dist-server/server/env-path.js +15 -0
  134. package/dist-server/server/fleet.js +1 -1
  135. package/dist-server/server/group-thread-usage.js +103 -0
  136. package/dist-server/server/guarded-requests.js +2 -2
  137. package/dist-server/server/harness/registry.js +1 -0
  138. package/dist-server/server/harness-capabilities.js +46 -0
  139. package/dist-server/server/hosted-models.js +1 -1
  140. package/dist-server/server/index.js +2396 -505
  141. package/dist-server/server/local-computer.js +72 -23
  142. package/dist-server/server/managed-desktop.js +1 -1
  143. package/dist-server/server/mcp-bridge.js +6 -6
  144. package/dist-server/server/message-db.js +22 -42
  145. package/dist-server/server/message-file.js +9 -1
  146. package/dist-server/server/message-search-query.js +43 -0
  147. package/dist-server/server/message-search-worker.js +80 -0
  148. package/dist-server/server/message-search.worker.js +21 -0
  149. package/dist-server/server/model-requests.js +248 -0
  150. package/dist-server/server/new-bot-defaults.js +115 -0
  151. package/dist-server/server/options-card.js +21 -0
  152. package/dist-server/server/org-library.js +1065 -0
  153. package/dist-server/server/package-export.js +627 -39
  154. package/dist-server/server/package-import.js +458 -0
  155. package/dist-server/server/package-parts.js +87 -0
  156. package/dist-server/server/peer-approval.js +16 -7
  157. package/dist-server/server/peer-delivery.js +60 -0
  158. package/dist-server/server/peer-roster.js +67 -0
  159. package/dist-server/server/presets.js +492 -0
  160. package/dist-server/server/profile-requests.js +66 -39
  161. package/dist-server/server/profile-revision.js +9 -1
  162. package/dist-server/server/profile-versions.js +6 -3
  163. package/dist-server/server/provider-key-check.js +3 -2
  164. package/dist-server/server/published-teams.js +80 -0
  165. package/dist-server/server/room-handoffs.js +19 -3
  166. package/dist-server/server/routes/bot-presets.js +25 -0
  167. package/dist-server/server/routine-requests.js +35 -10
  168. package/dist-server/server/routines.js +41 -1
  169. package/dist-server/server/section-context.js +10 -0
  170. package/dist-server/server/skill-fetch.js +72 -14
  171. package/dist-server/server/skills.js +35 -61
  172. package/dist-server/server/steer-queue.js +3 -2
  173. package/dist-server/server/store.js +291 -17
  174. package/dist-server/server/surface.js +10 -4
  175. package/dist-server/server/system-prompt.js +38 -6
  176. package/dist-server/server/team-backup.js +6 -2
  177. package/dist-server/server/team-computers.js +10 -0
  178. package/dist-server/server/team-library.js +6 -2
  179. package/dist-server/server/team-manifest.js +4 -3
  180. package/dist-server/server/team-setup-requests.js +139 -27
  181. package/dist-server/server/thread-events.js +20 -2
  182. package/dist-server/server/tightening-requests.js +405 -0
  183. package/dist-server/server/tts/chatterbox.js +27 -5
  184. package/dist-server/server/turn-context.js +2 -0
  185. package/dist-server/server/turn-watchdog.js +12 -3
  186. package/dist-server/server/usage-ledger.js +19 -2
  187. package/dist-server/server/vps-computer.js +139 -51
  188. package/dist-server/server/vps-container-mcp.js +7 -0
  189. package/dist-server/server/vps-ssh.js +36 -7
  190. package/dist-server/server/workspace-backup-policy.js +12 -0
  191. package/dist-server/server/workspace-backup.js +42 -5
  192. package/dist-server/server/workspace-backup.worker.js +10 -0
  193. package/dist-server/server/workspace.js +1 -1
  194. package/dist-server/shared/approval-mode.js +1 -1
  195. package/dist-server/shared/ask-question.js +207 -12
  196. package/dist-server/shared/bot-profile.js +15 -0
  197. package/dist-server/shared/command-allowlist.js +1 -0
  198. package/dist-server/shared/credential-request.js +6 -2
  199. package/dist-server/shared/line-diff.js +23 -0
  200. package/dist-server/shared/model-request.js +1 -0
  201. package/dist-server/shared/options-card.js +51 -0
  202. package/dist-server/shared/package-format.js +967 -0
  203. package/dist-server/shared/profile-request.js +5 -4
  204. package/dist-server/shared/skill-md.js +64 -0
  205. package/dist-server/shared/team-backup.js +7 -0
  206. package/dist-server/shared/tightening-request.js +87 -0
  207. package/dist-server/shared/wire.js +4 -0
  208. package/dist-server/src/lib/composer-attachments.js +25 -3
  209. package/dist-server/vps-container-mcp.js +1132 -171
  210. package/dist-server/workspace-backup.worker.js +19474 -0
  211. package/enterprise/README.md +1 -1
  212. package/package.json +1 -1
  213. package/dist/assets/channel-BXFkgus9.js +0 -1
  214. package/dist/assets/index-BGgqlWPJ.css +0 -1
  215. package/dist/assets/index-BtHo8ZKl.js +0 -577
  216. package/dist/assets/swimlanesDiagram-TC7HE7FX-BWrvB2ak.js +0 -8
@@ -85,7 +85,7 @@ import { basename, delimiter, dirname, extname, join } from "node:path";
85
85
  function nvmBinDirs() {
86
86
  try {
87
87
  const base = join(homedir(), ".nvm", "versions", "node");
88
- return readdirSync(base).filter((v) => v.startsWith("v")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true })).map((v) => join(base, v, "bin"));
88
+ return readdirSync(base).filter((v2) => v2.startsWith("v")).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true })).map((v2) => join(base, v2, "bin"));
89
89
  } catch {
90
90
  return [];
91
91
  }
@@ -112,6 +112,8 @@ function knownDirs() {
112
112
  join(home, ".volta", "bin"),
113
113
  join(home, ".bun", "bin"),
114
114
  join(home, ".asdf", "shims"),
115
+ join(home, ".local", "share", "mise", "shims"),
116
+ // mise installer
115
117
  join(home, ".deno", "bin"),
116
118
  join(home, "bin"),
117
119
  ...nvmBinDirs()
@@ -175,10 +177,10 @@ function probeLoginShellPath() {
175
177
  { timeout: 5e3 },
176
178
  (err, stdout) => {
177
179
  if (err || !stdout) return;
178
- const m = /__OMB_PATH__([^\n]*)/.exec(stdout);
179
- if (!m || !m[1]) return;
180
- loginShellPath = m[1];
181
- cached = mergePaths([...(cached ?? "").split(delimiter), ...m[1].split(delimiter)]);
180
+ const m2 = /__OMB_PATH__([^\n]*)/.exec(stdout);
181
+ if (!m2 || !m2[1]) return;
182
+ loginShellPath = m2[1];
183
+ cached = mergePaths([...(cached ?? "").split(delimiter), ...m2[1].split(delimiter)]);
182
184
  }
183
185
  );
184
186
  }
@@ -266,25 +268,25 @@ function createToolListNormalizer() {
266
268
  // server/mcp-bridge.ts
267
269
  var BRIDGE_INACTIVITY_MS = 45e3;
268
270
  var PROBE_TIMEOUT_MS = 1e4;
269
- function runLivenessProbe(probe, timeoutMs = PROBE_TIMEOUT_MS) {
270
- return new Promise((resolve2) => {
271
+ function runLivenessProbe(probe, timeoutMs = PROBE_TIMEOUT_MS, env) {
272
+ return new Promise((resolve3) => {
271
273
  const child = spawn(probe.command, probe.args, {
272
274
  shell: false,
273
- env: { ...process.env, PATH: augmentedPath() },
275
+ env: env ?? { ...process.env, PATH: augmentedPath() },
274
276
  stdio: ["ignore", "ignore", "ignore"]
275
277
  });
276
278
  const timer = setTimeout(() => {
277
279
  child.kill("SIGKILL");
278
- resolve2(false);
280
+ resolve3(false);
279
281
  }, timeoutMs);
280
282
  timer.unref?.();
281
283
  child.on("error", () => {
282
284
  clearTimeout(timer);
283
- resolve2(false);
285
+ resolve3(false);
284
286
  });
285
287
  child.on("close", (code) => {
286
288
  clearTimeout(timer);
287
- resolve2(code === 0);
289
+ resolve3(code === 0);
288
290
  });
289
291
  });
290
292
  }
@@ -457,7 +459,7 @@ function runMcpBridge(options) {
457
459
  const liveness = options.liveness;
458
460
  watchdog = createInactivityWatchdog({
459
461
  inactivityMs: BRIDGE_INACTIVITY_MS,
460
- probe: () => runLivenessProbe(liveness),
462
+ probe: () => runLivenessProbe(liveness, PROBE_TIMEOUT_MS, options.env),
461
463
  onDead: () => {
462
464
  process.stderr.write(
463
465
  `${options.label} transport went silent and stopped answering liveness probes; ending the bridge
@@ -1037,7 +1039,7 @@ function $constructor(name, initializer3, params) {
1037
1039
  Object.defineProperty(inst, "_zod", {
1038
1040
  value: {
1039
1041
  def,
1040
- constr: _,
1042
+ constr: _2,
1041
1043
  traits: /* @__PURE__ */ new Set()
1042
1044
  },
1043
1045
  enumerable: false
@@ -1048,12 +1050,12 @@ function $constructor(name, initializer3, params) {
1048
1050
  }
1049
1051
  inst._zod.traits.add(name);
1050
1052
  initializer3(inst, def);
1051
- const proto = _.prototype;
1053
+ const proto = _2.prototype;
1052
1054
  const keys = Object.keys(proto);
1053
1055
  for (let i = 0; i < keys.length; i++) {
1054
- const k = keys[i];
1055
- if (!(k in inst)) {
1056
- inst[k] = proto[k].bind(inst);
1056
+ const k2 = keys[i];
1057
+ if (!(k2 in inst)) {
1058
+ inst[k2] = proto[k2].bind(inst);
1057
1059
  }
1058
1060
  }
1059
1061
  }
@@ -1061,7 +1063,7 @@ function $constructor(name, initializer3, params) {
1061
1063
  class Definition extends Parent {
1062
1064
  }
1063
1065
  Object.defineProperty(Definition, "name", { value: name });
1064
- function _(def) {
1066
+ function _2(def) {
1065
1067
  var _a3;
1066
1068
  const inst = params?.Parent ? new Definition() : this;
1067
1069
  init(inst, def);
@@ -1071,16 +1073,16 @@ function $constructor(name, initializer3, params) {
1071
1073
  }
1072
1074
  return inst;
1073
1075
  }
1074
- Object.defineProperty(_, "init", { value: init });
1075
- Object.defineProperty(_, Symbol.hasInstance, {
1076
+ Object.defineProperty(_2, "init", { value: init });
1077
+ Object.defineProperty(_2, Symbol.hasInstance, {
1076
1078
  value: (inst) => {
1077
1079
  if (params?.Parent && inst instanceof params.Parent)
1078
1080
  return true;
1079
1081
  return inst?._zod?.traits?.has(name);
1080
1082
  }
1081
1083
  });
1082
- Object.defineProperty(_, "name", { value: name });
1083
- return _;
1084
+ Object.defineProperty(_2, "name", { value: name });
1085
+ return _2;
1084
1086
  }
1085
1087
  var $brand = /* @__PURE__ */ Symbol("zod_brand");
1086
1088
  var $ZodAsyncError = class extends Error {
@@ -1180,17 +1182,17 @@ function assertIs(_arg) {
1180
1182
  function assertNever(_x) {
1181
1183
  throw new Error("Unexpected value in exhaustive check");
1182
1184
  }
1183
- function assert(_) {
1185
+ function assert(_2) {
1184
1186
  }
1185
1187
  function getEnumValues(entries) {
1186
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
1187
- const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
1188
+ const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
1189
+ const values = Object.entries(entries).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v2]) => v2);
1188
1190
  return values;
1189
1191
  }
1190
1192
  function joinValues(array2, separator = "|") {
1191
1193
  return array2.map((val) => stringifyPrimitive(val)).join(separator);
1192
1194
  }
1193
- function jsonStringifyReplacer(_, value) {
1195
+ function jsonStringifyReplacer(_2, value) {
1194
1196
  if (typeof value === "bigint")
1195
1197
  return value.toString();
1196
1198
  return value;
@@ -1238,9 +1240,9 @@ function defineLazy(object2, key, getter) {
1238
1240
  }
1239
1241
  return value;
1240
1242
  },
1241
- set(v) {
1243
+ set(v2) {
1242
1244
  Object.defineProperty(object2, key, {
1243
- value: v
1245
+ value: v2
1244
1246
  // configurable: true,
1245
1247
  });
1246
1248
  },
@@ -1315,7 +1317,7 @@ var allowsEval = /* @__PURE__ */ cached2(() => {
1315
1317
  const F = Function;
1316
1318
  new F("");
1317
1319
  return true;
1318
- } catch (_) {
1320
+ } catch (_2) {
1319
1321
  return false;
1320
1322
  }
1321
1323
  });
@@ -1436,31 +1438,31 @@ function normalizeParams(_params) {
1436
1438
  function createTransparentProxy(getter) {
1437
1439
  let target;
1438
1440
  return new Proxy({}, {
1439
- get(_, prop, receiver) {
1441
+ get(_2, prop, receiver) {
1440
1442
  target ?? (target = getter());
1441
1443
  return Reflect.get(target, prop, receiver);
1442
1444
  },
1443
- set(_, prop, value, receiver) {
1445
+ set(_2, prop, value, receiver) {
1444
1446
  target ?? (target = getter());
1445
1447
  return Reflect.set(target, prop, value, receiver);
1446
1448
  },
1447
- has(_, prop) {
1449
+ has(_2, prop) {
1448
1450
  target ?? (target = getter());
1449
1451
  return Reflect.has(target, prop);
1450
1452
  },
1451
- deleteProperty(_, prop) {
1453
+ deleteProperty(_2, prop) {
1452
1454
  target ?? (target = getter());
1453
1455
  return Reflect.deleteProperty(target, prop);
1454
1456
  },
1455
- ownKeys(_) {
1457
+ ownKeys(_2) {
1456
1458
  target ?? (target = getter());
1457
1459
  return Reflect.ownKeys(target);
1458
1460
  },
1459
- getOwnPropertyDescriptor(_, prop) {
1461
+ getOwnPropertyDescriptor(_2, prop) {
1460
1462
  target ?? (target = getter());
1461
1463
  return Reflect.getOwnPropertyDescriptor(target, prop);
1462
1464
  },
1463
- defineProperty(_, prop, descriptor) {
1465
+ defineProperty(_2, prop, descriptor) {
1464
1466
  target ?? (target = getter());
1465
1467
  return Reflect.defineProperty(target, prop, descriptor);
1466
1468
  }
@@ -1474,8 +1476,8 @@ function stringifyPrimitive(value) {
1474
1476
  return `${value}`;
1475
1477
  }
1476
1478
  function optionalKeys(shape) {
1477
- return Object.keys(shape).filter((k) => {
1478
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
1479
+ return Object.keys(shape).filter((k2) => {
1480
+ return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
1479
1481
  });
1480
1482
  }
1481
1483
  var NUMBER_FORMAT_RANGES = {
@@ -1575,20 +1577,20 @@ function safeExtend(schema, shape) {
1575
1577
  });
1576
1578
  return clone(schema, def);
1577
1579
  }
1578
- function merge(a, b) {
1580
+ function merge(a, b2) {
1579
1581
  if (a._zod.def.checks?.length) {
1580
1582
  throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
1581
1583
  }
1582
1584
  const def = mergeDefs(a._zod.def, {
1583
1585
  get shape() {
1584
- const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
1586
+ const _shape = { ...a._zod.def.shape, ...b2._zod.def.shape };
1585
1587
  assignProp(this, "shape", _shape);
1586
1588
  return _shape;
1587
1589
  },
1588
1590
  get catchall() {
1589
- return b._zod.def.catchall;
1591
+ return b2._zod.def.catchall;
1590
1592
  },
1591
- checks: b._zod.def.checks ?? []
1593
+ checks: b2._zod.def.checks ?? []
1592
1594
  });
1593
1595
  return clone(a, def);
1594
1596
  }
@@ -1661,21 +1663,21 @@ function required(Class2, schema, mask) {
1661
1663
  });
1662
1664
  return clone(schema, def);
1663
1665
  }
1664
- function aborted(x, startIndex = 0) {
1665
- if (x.aborted === true)
1666
+ function aborted(x2, startIndex = 0) {
1667
+ if (x2.aborted === true)
1666
1668
  return true;
1667
- for (let i = startIndex; i < x.issues.length; i++) {
1668
- if (x.issues[i]?.continue !== true) {
1669
+ for (let i = startIndex; i < x2.issues.length; i++) {
1670
+ if (x2.issues[i]?.continue !== true) {
1669
1671
  return true;
1670
1672
  }
1671
1673
  }
1672
1674
  return false;
1673
1675
  }
1674
- function explicitlyAborted(x, startIndex = 0) {
1675
- if (x.aborted === true)
1676
+ function explicitlyAborted(x2, startIndex = 0) {
1677
+ if (x2.aborted === true)
1676
1678
  return true;
1677
- for (let i = startIndex; i < x.issues.length; i++) {
1678
- if (x.issues[i]?.continue === false) {
1679
+ for (let i = startIndex; i < x2.issues.length; i++) {
1680
+ if (x2.issues[i]?.continue === false) {
1679
1681
  return true;
1680
1682
  }
1681
1683
  }
@@ -1752,8 +1754,8 @@ function issue(...args2) {
1752
1754
  return { ...iss };
1753
1755
  }
1754
1756
  function cleanEnum(obj) {
1755
- return Object.entries(obj).filter(([k, _]) => {
1756
- return Number.isNaN(Number.parseInt(k, 10));
1757
+ return Object.entries(obj).filter(([k2, _2]) => {
1758
+ return Number.isNaN(Number.parseInt(k2, 10));
1757
1759
  }).map((el) => el[1]);
1758
1760
  }
1759
1761
  function base64ToUint8Array(base643) {
@@ -1791,7 +1793,7 @@ function hexToUint8Array(hex3) {
1791
1793
  return bytes;
1792
1794
  }
1793
1795
  function uint8ArrayToHex(bytes) {
1794
- return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
1796
+ return Array.from(bytes).map((b2) => b2.toString(16).padStart(2, "0")).join("");
1795
1797
  }
1796
1798
  var Class = class {
1797
1799
  constructor(..._args) {
@@ -1928,7 +1930,7 @@ function toDotPath(_path) {
1928
1930
  }
1929
1931
  function prettifyError(error51) {
1930
1932
  const lines = [];
1931
- const issues = [...error51.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
1933
+ const issues = [...error51.issues].sort((a, b2) => (a.path ?? []).length - (b2.path ?? []).length);
1932
1934
  for (const issue2 of issues) {
1933
1935
  lines.push(`\u2716 ${issue2.message}`);
1934
1936
  if (issue2.path?.length)
@@ -2117,8 +2119,8 @@ function emoji() {
2117
2119
  }
2118
2120
  var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
2119
2121
  var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
2120
- var mac = (delimiter2) => {
2121
- const escapedDelim = escapeRegex(delimiter2 ?? ":");
2122
+ var mac = (delimiter3) => {
2123
+ const escapedDelim = escapeRegex(delimiter3 ?? ":");
2122
2124
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
2123
2125
  };
2124
2126
  var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
@@ -2752,9 +2754,9 @@ var Doc = class {
2752
2754
  return;
2753
2755
  }
2754
2756
  const content = arg;
2755
- const lines = content.split("\n").filter((x) => x);
2756
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
2757
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
2757
+ const lines = content.split("\n").filter((x2) => x2);
2758
+ const minIndent = Math.min(...lines.map((x2) => x2.length - x2.trimStart().length));
2759
+ const dedented = lines.map((x2) => x2.slice(minIndent)).map((x2) => " ".repeat(this.indent * 2) + x2);
2758
2760
  for (const line of dedented) {
2759
2761
  this.content.push(line);
2760
2762
  }
@@ -2763,7 +2765,7 @@ var Doc = class {
2763
2765
  const F = Function;
2764
2766
  const args2 = this?.args;
2765
2767
  const content = this?.content ?? [``];
2766
- const lines = [...content.map((x) => ` ${x}`)];
2768
+ const lines = [...content.map((x2) => ` ${x2}`)];
2767
2769
  return new F(...args2, lines.join("\n"));
2768
2770
  }
2769
2771
  };
@@ -2811,13 +2813,13 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
2811
2813
  continue;
2812
2814
  }
2813
2815
  const currLen = payload.issues.length;
2814
- const _ = ch._zod.check(payload);
2815
- if (_ instanceof Promise && ctx?.async === false) {
2816
+ const _2 = ch._zod.check(payload);
2817
+ if (_2 instanceof Promise && ctx?.async === false) {
2816
2818
  throw new $ZodAsyncError();
2817
2819
  }
2818
- if (asyncResult || _ instanceof Promise) {
2820
+ if (asyncResult || _2 instanceof Promise) {
2819
2821
  asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
2820
- await _;
2822
+ await _2;
2821
2823
  const nextLen = payload.issues.length;
2822
2824
  if (nextLen === currLen)
2823
2825
  return;
@@ -2879,7 +2881,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
2879
2881
  try {
2880
2882
  const r = safeParse(inst, value);
2881
2883
  return r.success ? { value: r.data } : { issues: r.error?.issues };
2882
- } catch (_) {
2884
+ } catch (_2) {
2883
2885
  return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
2884
2886
  }
2885
2887
  },
@@ -2890,11 +2892,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
2890
2892
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
2891
2893
  $ZodType.init(inst, def);
2892
2894
  inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
2893
- inst._zod.parse = (payload, _) => {
2895
+ inst._zod.parse = (payload, _2) => {
2894
2896
  if (def.coerce)
2895
2897
  try {
2896
2898
  payload.value = String(payload.value);
2897
- } catch (_2) {
2899
+ } catch (_3) {
2898
2900
  }
2899
2901
  if (typeof payload.value === "string")
2900
2902
  return payload;
@@ -2927,10 +2929,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
2927
2929
  v7: 7,
2928
2930
  v8: 8
2929
2931
  };
2930
- const v = versionMap[def.version];
2931
- if (v === void 0)
2932
+ const v2 = versionMap[def.version];
2933
+ if (v2 === void 0)
2932
2934
  throw new Error(`Invalid UUID version: "${def.version}"`);
2933
- def.pattern ?? (def.pattern = uuid(v));
2935
+ def.pattern ?? (def.pattern = uuid(v2));
2934
2936
  } else
2935
2937
  def.pattern ?? (def.pattern = uuid());
2936
2938
  $ZodStringFormat.init(inst, def);
@@ -2992,7 +2994,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
2992
2994
  payload.value = trimmed;
2993
2995
  }
2994
2996
  return;
2995
- } catch (_) {
2997
+ } catch (_2) {
2996
2998
  payload.issues.push({
2997
2999
  code: "invalid_format",
2998
3000
  format: "url",
@@ -3219,7 +3221,7 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
3219
3221
  if (def.coerce)
3220
3222
  try {
3221
3223
  payload.value = Number(payload.value);
3222
- } catch (_) {
3224
+ } catch (_2) {
3223
3225
  }
3224
3226
  const input = payload.value;
3225
3227
  if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
@@ -3247,7 +3249,7 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
3247
3249
  if (def.coerce)
3248
3250
  try {
3249
3251
  payload.value = Boolean(payload.value);
3250
- } catch (_) {
3252
+ } catch (_2) {
3251
3253
  }
3252
3254
  const input = payload.value;
3253
3255
  if (typeof input === "boolean")
@@ -3268,7 +3270,7 @@ var $ZodBigInt = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) => {
3268
3270
  if (def.coerce)
3269
3271
  try {
3270
3272
  payload.value = BigInt(payload.value);
3271
- } catch (_) {
3273
+ } catch (_2) {
3272
3274
  }
3273
3275
  if (typeof payload.value === "bigint")
3274
3276
  return payload;
@@ -3461,9 +3463,9 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
3461
3463
  }
3462
3464
  function normalizeDef(def) {
3463
3465
  const keys = Object.keys(def.shape);
3464
- for (const k of keys) {
3465
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
3466
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
3466
+ for (const k2 of keys) {
3467
+ if (!def.shape?.[k2]?._zod?.traits?.has("$ZodType")) {
3468
+ throw new Error(`Invalid element at key "${k2}": expected a Zod schema`);
3467
3469
  }
3468
3470
  }
3469
3471
  const okeys = optionalKeys(def.shape);
@@ -3535,8 +3537,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3535
3537
  const field = shape[key]._zod;
3536
3538
  if (field.values) {
3537
3539
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
3538
- for (const v of field.values)
3539
- propValues[key].add(v);
3540
+ for (const v2 of field.values)
3541
+ propValues[key].add(v2);
3540
3542
  }
3541
3543
  }
3542
3544
  return propValues;
@@ -3584,8 +3586,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3584
3586
  const doc = new Doc(["shape", "payload", "ctx"]);
3585
3587
  const normalized = _normalized.value;
3586
3588
  const parseStr = (key) => {
3587
- const k = esc(key);
3588
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
3589
+ const k2 = esc(key);
3590
+ return `shape[${k2}]._zod.run({ value: input[${k2}], issues: [] }, ctx)`;
3589
3591
  };
3590
3592
  doc.write(`const input = payload.value;`);
3591
3593
  const ids = /* @__PURE__ */ Object.create(null);
@@ -3596,7 +3598,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3596
3598
  doc.write(`const newResult = {};`);
3597
3599
  for (const key of normalized.keys) {
3598
3600
  const id = ids[key];
3599
- const k = esc(key);
3601
+ const k2 = esc(key);
3600
3602
  const schema = shape[key];
3601
3603
  const isOptionalIn = schema?._zod?.optin === "optional";
3602
3604
  const isOptionalOut = schema?._zod?.optout === "optional";
@@ -3604,30 +3606,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3604
3606
  if (isOptionalIn && isOptionalOut) {
3605
3607
  doc.write(`
3606
3608
  if (${id}.issues.length) {
3607
- if (${k} in input) {
3609
+ if (${k2} in input) {
3608
3610
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3609
3611
  ...iss,
3610
- path: iss.path ? [${k}, ...iss.path] : [${k}]
3612
+ path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3611
3613
  })));
3612
3614
  }
3613
3615
  }
3614
3616
 
3615
3617
  if (${id}.value === undefined) {
3616
- if (${k} in input) {
3617
- newResult[${k}] = undefined;
3618
+ if (${k2} in input) {
3619
+ newResult[${k2}] = undefined;
3618
3620
  }
3619
3621
  } else {
3620
- newResult[${k}] = ${id}.value;
3622
+ newResult[${k2}] = ${id}.value;
3621
3623
  }
3622
3624
 
3623
3625
  `);
3624
3626
  } else if (!isOptionalIn) {
3625
3627
  doc.write(`
3626
- const ${id}_present = ${k} in input;
3628
+ const ${id}_present = ${k2} in input;
3627
3629
  if (${id}.issues.length) {
3628
3630
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3629
3631
  ...iss,
3630
- path: iss.path ? [${k}, ...iss.path] : [${k}]
3632
+ path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3631
3633
  })));
3632
3634
  }
3633
3635
  if (!${id}_present && !${id}.issues.length) {
@@ -3635,15 +3637,15 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3635
3637
  code: "invalid_type",
3636
3638
  expected: "nonoptional",
3637
3639
  input: undefined,
3638
- path: [${k}]
3640
+ path: [${k2}]
3639
3641
  });
3640
3642
  }
3641
3643
 
3642
3644
  if (${id}_present) {
3643
3645
  if (${id}.value === undefined) {
3644
- newResult[${k}] = undefined;
3646
+ newResult[${k2}] = undefined;
3645
3647
  } else {
3646
- newResult[${k}] = ${id}.value;
3648
+ newResult[${k2}] = ${id}.value;
3647
3649
  }
3648
3650
  }
3649
3651
 
@@ -3653,16 +3655,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3653
3655
  if (${id}.issues.length) {
3654
3656
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3655
3657
  ...iss,
3656
- path: iss.path ? [${k}, ...iss.path] : [${k}]
3658
+ path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3657
3659
  })));
3658
3660
  }
3659
3661
 
3660
3662
  if (${id}.value === undefined) {
3661
- if (${k} in input) {
3662
- newResult[${k}] = undefined;
3663
+ if (${k2} in input) {
3664
+ newResult[${k2}] = undefined;
3663
3665
  }
3664
3666
  } else {
3665
- newResult[${k}] = ${id}.value;
3667
+ newResult[${k2}] = ${id}.value;
3666
3668
  }
3667
3669
 
3668
3670
  `);
@@ -3736,7 +3738,7 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
3736
3738
  defineLazy(inst._zod, "pattern", () => {
3737
3739
  if (def.options.every((o) => o._zod.pattern)) {
3738
3740
  const patterns = def.options.map((o) => o._zod.pattern);
3739
- return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
3741
+ return new RegExp(`^(${patterns.map((p2) => cleanRegex(p2.source)).join("|")})$`);
3740
3742
  }
3741
3743
  return void 0;
3742
3744
  });
@@ -3831,11 +3833,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3831
3833
  const pv = option._zod.propValues;
3832
3834
  if (!pv || Object.keys(pv).length === 0)
3833
3835
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
3834
- for (const [k, v] of Object.entries(pv)) {
3835
- if (!propValues[k])
3836
- propValues[k] = /* @__PURE__ */ new Set();
3837
- for (const val of v) {
3838
- propValues[k].add(val);
3836
+ for (const [k2, v2] of Object.entries(pv)) {
3837
+ if (!propValues[k2])
3838
+ propValues[k2] = /* @__PURE__ */ new Set();
3839
+ for (const val of v2) {
3840
+ propValues[k2].add(val);
3839
3841
  }
3840
3842
  }
3841
3843
  }
@@ -3848,11 +3850,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3848
3850
  const values = o._zod.propValues?.[def.discriminator];
3849
3851
  if (!values || values.size === 0)
3850
3852
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
3851
- for (const v of values) {
3852
- if (map2.has(v)) {
3853
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
3853
+ for (const v2 of values) {
3854
+ if (map2.has(v2)) {
3855
+ throw new Error(`Duplicate discriminator value "${String(v2)}"`);
3854
3856
  }
3855
- map2.set(v, o);
3857
+ map2.set(v2, o);
3856
3858
  }
3857
3859
  }
3858
3860
  return map2;
@@ -3903,19 +3905,19 @@ var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, d
3903
3905
  return handleIntersectionResults(payload, left, right);
3904
3906
  };
3905
3907
  });
3906
- function mergeValues(a, b) {
3907
- if (a === b) {
3908
+ function mergeValues(a, b2) {
3909
+ if (a === b2) {
3908
3910
  return { valid: true, data: a };
3909
3911
  }
3910
- if (a instanceof Date && b instanceof Date && +a === +b) {
3912
+ if (a instanceof Date && b2 instanceof Date && +a === +b2) {
3911
3913
  return { valid: true, data: a };
3912
3914
  }
3913
- if (isPlainObject(a) && isPlainObject(b)) {
3914
- const bKeys = Object.keys(b);
3915
+ if (isPlainObject(a) && isPlainObject(b2)) {
3916
+ const bKeys = Object.keys(b2);
3915
3917
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
3916
- const newObj = { ...a, ...b };
3918
+ const newObj = { ...a, ...b2 };
3917
3919
  for (const key of sharedKeys) {
3918
- const sharedValue = mergeValues(a[key], b[key]);
3920
+ const sharedValue = mergeValues(a[key], b2[key]);
3919
3921
  if (!sharedValue.valid) {
3920
3922
  return {
3921
3923
  valid: false,
@@ -3926,14 +3928,14 @@ function mergeValues(a, b) {
3926
3928
  }
3927
3929
  return { valid: true, data: newObj };
3928
3930
  }
3929
- if (Array.isArray(a) && Array.isArray(b)) {
3930
- if (a.length !== b.length) {
3931
+ if (Array.isArray(a) && Array.isArray(b2)) {
3932
+ if (a.length !== b2.length) {
3931
3933
  return { valid: false, mergeErrorPath: [] };
3932
3934
  }
3933
3935
  const newArray = [];
3934
3936
  for (let index = 0; index < a.length; index++) {
3935
3937
  const itemA = a[index];
3936
- const itemB = b[index];
3938
+ const itemB = b2[index];
3937
3939
  const sharedValue = mergeValues(itemA, itemB);
3938
3940
  if (!sharedValue.valid) {
3939
3941
  return {
@@ -3953,10 +3955,10 @@ function handleIntersectionResults(result, left, right) {
3953
3955
  for (const iss of left.issues) {
3954
3956
  if (iss.code === "unrecognized_keys") {
3955
3957
  unrecIssue ?? (unrecIssue = iss);
3956
- for (const k of iss.keys) {
3957
- if (!unrecKeys.has(k))
3958
- unrecKeys.set(k, {});
3959
- unrecKeys.get(k).l = true;
3958
+ for (const k2 of iss.keys) {
3959
+ if (!unrecKeys.has(k2))
3960
+ unrecKeys.set(k2, {});
3961
+ unrecKeys.get(k2).l = true;
3960
3962
  }
3961
3963
  } else {
3962
3964
  result.issues.push(iss);
@@ -3964,16 +3966,16 @@ function handleIntersectionResults(result, left, right) {
3964
3966
  }
3965
3967
  for (const iss of right.issues) {
3966
3968
  if (iss.code === "unrecognized_keys") {
3967
- for (const k of iss.keys) {
3968
- if (!unrecKeys.has(k))
3969
- unrecKeys.set(k, {});
3970
- unrecKeys.get(k).r = true;
3969
+ for (const k2 of iss.keys) {
3970
+ if (!unrecKeys.has(k2))
3971
+ unrecKeys.set(k2, {});
3972
+ unrecKeys.get(k2).r = true;
3971
3973
  }
3972
3974
  } else {
3973
3975
  result.issues.push(iss);
3974
3976
  }
3975
3977
  }
3976
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
3978
+ const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([k2]) => k2);
3977
3979
  if (bothKeys.length && unrecIssue) {
3978
3980
  result.issues.push({ ...unrecIssue, keys: bothKeys });
3979
3981
  }
@@ -4317,7 +4319,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
4317
4319
  const values = getEnumValues(def.entries);
4318
4320
  const valuesSet = new Set(values);
4319
4321
  inst._zod.values = valuesSet;
4320
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
4322
+ inst._zod.pattern = new RegExp(`^(${values.filter((k2) => propertyKeyTypes.has(typeof k2)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
4321
4323
  inst._zod.parse = (payload, _ctx) => {
4322
4324
  const input = payload.value;
4323
4325
  if (valuesSet.has(input)) {
@@ -4491,8 +4493,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
4491
4493
  var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
4492
4494
  $ZodType.init(inst, def);
4493
4495
  defineLazy(inst._zod, "values", () => {
4494
- const v = def.innerType._zod.values;
4495
- return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
4496
+ const v2 = def.innerType._zod.values;
4497
+ return v2 ? new Set([...v2].filter((x2) => x2 !== void 0)) : void 0;
4496
4498
  });
4497
4499
  inst._zod.parse = (payload, ctx) => {
4498
4500
  const result = def.innerType._zod.run(payload, ctx);
@@ -4837,7 +4839,7 @@ var $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
4837
4839
  var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
4838
4840
  $ZodCheck.init(inst, def);
4839
4841
  $ZodType.init(inst, def);
4840
- inst._zod.parse = (payload, _) => {
4842
+ inst._zod.parse = (payload, _2) => {
4841
4843
  return payload;
4842
4844
  };
4843
4845
  inst._zod.check = (payload) => {
@@ -6889,7 +6891,7 @@ var error17 = () => {
6889
6891
  if (issue2.values.length === 1) {
6890
6892
  return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${stringifyPrimitive(issue2.values[0])}`;
6891
6893
  }
6892
- const stringified = issue2.values.map((v) => stringifyPrimitive(v));
6894
+ const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
6893
6895
  if (issue2.values.length === 2) {
6894
6896
  return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${stringified[0]} \u05D0\u05D5 ${stringified[1]}`;
6895
6897
  }
@@ -10854,12 +10856,12 @@ var $ZodRegistry = class {
10854
10856
  return this;
10855
10857
  }
10856
10858
  get(schema) {
10857
- const p = schema._zod.parent;
10858
- if (p) {
10859
- const pm = { ...this.get(p) ?? {} };
10859
+ const p2 = schema._zod.parent;
10860
+ if (p2) {
10861
+ const pm = { ...this.get(p2) ?? {} };
10860
10862
  delete pm.id;
10861
- const f = { ...pm, ...this._map.get(schema) };
10862
- return Object.keys(f).length ? f : void 0;
10863
+ const f2 = { ...pm, ...this._map.get(schema) };
10864
+ return Object.keys(f2).length ? f2 : void 0;
10863
10865
  }
10864
10866
  return this._map.get(schema);
10865
10867
  }
@@ -11644,7 +11646,7 @@ function _set(Class2, valueType, params) {
11644
11646
  }
11645
11647
  // @__NO_SIDE_EFFECTS__
11646
11648
  function _enum(Class2, values, params) {
11647
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
11649
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
11648
11650
  return new Class2({
11649
11651
  type: "enum",
11650
11652
  entries,
@@ -11849,8 +11851,8 @@ function _stringbool(Classes, _params) {
11849
11851
  let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
11850
11852
  let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
11851
11853
  if (params.case !== "sensitive") {
11852
- truthyArray = truthyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
11853
- falsyArray = falsyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
11854
+ truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
11855
+ falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
11854
11856
  }
11855
11857
  const truthySet = new Set(truthyArray);
11856
11858
  const falsySet = new Set(falsyArray);
@@ -12392,9 +12394,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
12392
12394
  var enumProcessor = (schema, _ctx, json2, _params) => {
12393
12395
  const def = schema._zod.def;
12394
12396
  const values = getEnumValues(def.entries);
12395
- if (values.every((v) => typeof v === "number"))
12397
+ if (values.every((v2) => typeof v2 === "number"))
12396
12398
  json2.type = "number";
12397
- if (values.every((v) => typeof v === "string"))
12399
+ if (values.every((v2) => typeof v2 === "string"))
12398
12400
  json2.type = "string";
12399
12401
  json2.enum = values;
12400
12402
  };
@@ -12427,13 +12429,13 @@ var literalProcessor = (schema, ctx, json2, _params) => {
12427
12429
  json2.const = val;
12428
12430
  }
12429
12431
  } else {
12430
- if (vals.every((v) => typeof v === "number"))
12432
+ if (vals.every((v2) => typeof v2 === "number"))
12431
12433
  json2.type = "number";
12432
- if (vals.every((v) => typeof v === "string"))
12434
+ if (vals.every((v2) => typeof v2 === "string"))
12433
12435
  json2.type = "string";
12434
- if (vals.every((v) => typeof v === "boolean"))
12436
+ if (vals.every((v2) => typeof v2 === "boolean"))
12435
12437
  json2.type = "boolean";
12436
- if (vals.every((v) => v === null))
12438
+ if (vals.every((v2) => v2 === null))
12437
12439
  json2.type = "null";
12438
12440
  json2.enum = vals;
12439
12441
  }
@@ -12469,7 +12471,7 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
12469
12471
  Object.assign(_json, file2);
12470
12472
  } else {
12471
12473
  Object.assign(_json, file2);
12472
- _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
12474
+ _json.anyOf = mime.map((m2) => ({ contentMediaType: m2 }));
12473
12475
  }
12474
12476
  } else {
12475
12477
  Object.assign(_json, file2);
@@ -12531,11 +12533,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
12531
12533
  }
12532
12534
  const allKeys = new Set(Object.keys(shape));
12533
12535
  const requiredKeys = new Set([...allKeys].filter((key) => {
12534
- const v = def.shape[key]._zod;
12536
+ const v2 = def.shape[key]._zod;
12535
12537
  if (ctx.io === "input") {
12536
- return v.optin === void 0;
12538
+ return v2.optin === void 0;
12537
12539
  } else {
12538
- return v.optout === void 0;
12540
+ return v2.optout === void 0;
12539
12541
  }
12540
12542
  }));
12541
12543
  if (requiredKeys.size > 0) {
@@ -12556,7 +12558,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
12556
12558
  var unionProcessor = (schema, ctx, json2, params) => {
12557
12559
  const def = schema._zod.def;
12558
12560
  const isExclusive = def.inclusive === false;
12559
- const options = def.options.map((x, i) => process2(x, ctx, {
12561
+ const options = def.options.map((x2, i) => process2(x2, ctx, {
12560
12562
  ...params,
12561
12563
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
12562
12564
  }));
@@ -12572,14 +12574,14 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
12572
12574
  ...params,
12573
12575
  path: [...params.path, "allOf", 0]
12574
12576
  });
12575
- const b = process2(def.right, ctx, {
12577
+ const b2 = process2(def.right, ctx, {
12576
12578
  ...params,
12577
12579
  path: [...params.path, "allOf", 1]
12578
12580
  });
12579
12581
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
12580
12582
  const allOf = [
12581
12583
  ...isSimpleIntersection(a) ? a.allOf : [a],
12582
- ...isSimpleIntersection(b) ? b.allOf : [b]
12584
+ ...isSimpleIntersection(b2) ? b2.allOf : [b2]
12583
12585
  ];
12584
12586
  json2.allOf = allOf;
12585
12587
  };
@@ -12589,7 +12591,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
12589
12591
  json2.type = "array";
12590
12592
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
12591
12593
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
12592
- const prefixItems = def.items.map((x, i) => process2(x, ctx, {
12594
+ const prefixItems = def.items.map((x2, i) => process2(x2, ctx, {
12593
12595
  ...params,
12594
12596
  path: [...params.path, prefixPath, i]
12595
12597
  }));
@@ -12655,7 +12657,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
12655
12657
  }
12656
12658
  const keyValues = keyType._zod.values;
12657
12659
  if (keyValues) {
12658
- const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
12660
+ const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
12659
12661
  if (validKeyValues.length > 0) {
12660
12662
  json2.required = validKeyValues;
12661
12663
  }
@@ -12786,7 +12788,7 @@ function toJSONSchema(input, params) {
12786
12788
  const ctx2 = initializeContext({ ...params, processors: allProcessors });
12787
12789
  const defs = {};
12788
12790
  for (const entry of registry2._idmap.entries()) {
12789
- const [_, schema] = entry;
12791
+ const [_2, schema] = entry;
12790
12792
  process2(schema, ctx2);
12791
12793
  }
12792
12794
  const schemas = {};
@@ -12885,7 +12887,7 @@ var JSONSchemaGenerator = class {
12885
12887
  }
12886
12888
  extractDefs(this.ctx, schema);
12887
12889
  const result = finalize(this.ctx, schema);
12888
- const { "~standard": _, ...plainResult } = result;
12890
+ const { "~standard": _2, ...plainResult } = result;
12889
12891
  return plainResult;
12890
12892
  }
12891
12893
  };
@@ -13220,12 +13222,12 @@ function _installLazyMethods(inst, group, methods) {
13220
13222
  });
13221
13223
  return bound;
13222
13224
  },
13223
- set(v) {
13225
+ set(v2) {
13224
13226
  Object.defineProperty(this, key, {
13225
13227
  configurable: true,
13226
13228
  writable: true,
13227
13229
  enumerable: true,
13228
- value: v
13230
+ value: v2
13229
13231
  });
13230
13232
  }
13231
13233
  });
@@ -14021,11 +14023,11 @@ function record(keyType, valueType, params) {
14021
14023
  });
14022
14024
  }
14023
14025
  function partialRecord(keyType, valueType, params) {
14024
- const k = clone(keyType);
14025
- k._zod.values = void 0;
14026
+ const k2 = clone(keyType);
14027
+ k2._zod.values = void 0;
14026
14028
  return new ZodRecord({
14027
14029
  type: "record",
14028
- keyType: k,
14030
+ keyType: k2,
14029
14031
  valueType,
14030
14032
  ...util_exports.normalizeParams(params)
14031
14033
  });
@@ -14113,7 +14115,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
14113
14115
  };
14114
14116
  });
14115
14117
  function _enum2(values, params) {
14116
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
14118
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
14117
14119
  return new ZodEnum({
14118
14120
  type: "enum",
14119
14121
  entries,
@@ -14667,10 +14669,10 @@ function convertBaseSchema(schema, ctx) {
14667
14669
  if (enumValues.length === 1) {
14668
14670
  return z.literal(enumValues[0]);
14669
14671
  }
14670
- if (enumValues.every((v) => typeof v === "string")) {
14672
+ if (enumValues.every((v2) => typeof v2 === "string")) {
14671
14673
  return z.enum(enumValues);
14672
14674
  }
14673
- const literalSchemas = enumValues.map((v) => z.literal(v));
14675
+ const literalSchemas = enumValues.map((v2) => z.literal(v2));
14674
14676
  if (literalSchemas.length < 2) {
14675
14677
  return literalSchemas[0];
14676
14678
  }
@@ -14910,12 +14912,12 @@ function convertSchema(schema, ctx) {
14910
14912
  let baseSchema = convertBaseSchema(schema, ctx);
14911
14913
  const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
14912
14914
  if (schema.anyOf && Array.isArray(schema.anyOf)) {
14913
- const options = schema.anyOf.map((s) => convertSchema(s, ctx));
14915
+ const options = schema.anyOf.map((s2) => convertSchema(s2, ctx));
14914
14916
  const anyOfUnion = z.union(options);
14915
14917
  baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
14916
14918
  }
14917
14919
  if (schema.oneOf && Array.isArray(schema.oneOf)) {
14918
- const options = schema.oneOf.map((s) => convertSchema(s, ctx));
14920
+ const options = schema.oneOf.map((s2) => convertSchema(s2, ctx));
14919
14921
  const oneOfUnion = z.xor(options);
14920
14922
  baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
14921
14923
  }
@@ -15036,6 +15038,52 @@ function normalizeImageGenerationUrl(value) {
15036
15038
  return url2.toString().replace(/\/+$/, "");
15037
15039
  }
15038
15040
 
15041
+ // shared/bot-avatar.ts
15042
+ var BOT_AVATAR_CROPS = ["mascot", "circle", "rounded", "square"];
15043
+ var botAvatarCropSchema = external_exports.enum(BOT_AVATAR_CROPS);
15044
+ var botAvatarUrlSchema = external_exports.string().regex(
15045
+ /^\/api\/attachments\/[A-Za-z0-9-]+\.(?:png|jpg|gif|webp)$/,
15046
+ "must be a stored PNG, JPEG, GIF, or WebP attachment"
15047
+ );
15048
+
15049
+ // shared/bot-profile.ts
15050
+ var BOT_PROFILE_LIMITS = {
15051
+ name: 100,
15052
+ title: 200,
15053
+ description: 4e3,
15054
+ voice: 200,
15055
+ soul: 24e3
15056
+ };
15057
+ function fitsOnOneLine(value) {
15058
+ for (let i = 0; i < value.length; i += 1) {
15059
+ const code = value.charCodeAt(i);
15060
+ if (code < 32 || code >= 127 && code <= 159 || code === 8232 || code === 8233) return false;
15061
+ }
15062
+ return true;
15063
+ }
15064
+
15065
+ // shared/mascot-bodies.ts
15066
+ var MASCOT_BODY_IDS = ["cursor", "blob", "circle", "squircle", "capsule", "drop", "shield", "hexagon", "diamond", "star"];
15067
+ var mascotBodySchema = external_exports.enum(MASCOT_BODY_IDS);
15068
+
15069
+ // server/bot-profile.ts
15070
+ var profilePatchSchema = external_exports.object({
15071
+ name: external_exports.string({ error: "name must be a string" }).max(BOT_PROFILE_LIMITS.name, { error: "name must be at most 100 characters" }).refine((value) => Boolean(value.trim()), { error: "name must not be empty" }).refine(fitsOnOneLine, { error: "name must fit on one line" }).optional(),
15072
+ title: external_exports.string({ error: "title must be a string" }).max(BOT_PROFILE_LIMITS.title, { error: "title must be at most 200 characters" }).refine(fitsOnOneLine, { error: "title must fit on one line" }).optional(),
15073
+ description: external_exports.string({ error: "description must be a string" }).max(BOT_PROFILE_LIMITS.description, { error: "description must be at most 4000 characters" }).optional(),
15074
+ soul: external_exports.string({ error: "soul must be a string" }).refine((value) => Buffer.byteLength(value, "utf8") <= BOT_PROFILE_LIMITS.soul, {
15075
+ error: "standing instructions must be at most 24000 bytes"
15076
+ }).optional(),
15077
+ notifications: external_exports.boolean({ error: "notifications must be true or false" }).optional(),
15078
+ avatarUrl: external_exports.union([botAvatarUrlSchema, external_exports.literal(""), external_exports.null()], {
15079
+ error: "avatarUrl must be a stored PNG, JPEG, GIF, or WebP attachment"
15080
+ }).optional(),
15081
+ avatarCrop: botAvatarCropSchema.optional(),
15082
+ mascotBody: mascotBodySchema.optional(),
15083
+ voice: external_exports.string({ error: "voice must be a string" }).max(BOT_PROFILE_LIMITS.voice, { error: "voice must be at most 200 characters" }).optional(),
15084
+ speakReplies: external_exports.boolean({ error: "speakReplies must be true or false" }).optional()
15085
+ });
15086
+
15039
15087
  // shared/wire.ts
15040
15088
  var EFFORT_LEVELS = ["none", "low", "medium", "high", "xhigh", "max"];
15041
15089
 
@@ -15044,6 +15092,815 @@ function isModelVariant(value) {
15044
15092
  return typeof value === "string" && value.length > 0 && value.length <= 256 && value.trim() === value && !new RegExp("\\p{Cc}", "u").test(value);
15045
15093
  }
15046
15094
 
15095
+ // node_modules/.pnpm/croner@10.0.1/node_modules/croner/dist/croner.js
15096
+ function T(s2) {
15097
+ return Date.UTC(s2.y, s2.m - 1, s2.d, s2.h, s2.i, s2.s);
15098
+ }
15099
+ function D(s2, e) {
15100
+ return s2.y === e.y && s2.m === e.m && s2.d === e.d && s2.h === e.h && s2.i === e.i && s2.s === e.s;
15101
+ }
15102
+ function A(s2, e) {
15103
+ let t = new Date(Date.parse(s2));
15104
+ if (isNaN(t)) throw new Error("Invalid ISO8601 passed to timezone parser.");
15105
+ let r = s2.substring(9);
15106
+ return r.includes("Z") || r.includes("+") || r.includes("-") ? b(t.getUTCFullYear(), t.getUTCMonth() + 1, t.getUTCDate(), t.getUTCHours(), t.getUTCMinutes(), t.getUTCSeconds(), "Etc/UTC") : b(t.getFullYear(), t.getMonth() + 1, t.getDate(), t.getHours(), t.getMinutes(), t.getSeconds(), e);
15107
+ }
15108
+ function v(s2, e, t) {
15109
+ return k(A(s2, e), t);
15110
+ }
15111
+ function k(s2, e) {
15112
+ let t = new Date(T(s2)), r = g(t, s2.tz), n = T(s2), i = T(r), a = n - i, o = new Date(t.getTime() + a), h = g(o, s2.tz);
15113
+ if (D(h, s2)) {
15114
+ let u = new Date(o.getTime() - 36e5), d = g(u, s2.tz);
15115
+ return D(d, s2) ? u : o;
15116
+ }
15117
+ let l = new Date(o.getTime() + T(s2) - T(h)), y = g(l, s2.tz);
15118
+ if (D(y, s2)) return l;
15119
+ if (e) throw new Error("Invalid date passed to fromTZ()");
15120
+ return o.getTime() > l.getTime() ? o : l;
15121
+ }
15122
+ function g(s2, e) {
15123
+ let t, r;
15124
+ try {
15125
+ t = new Intl.DateTimeFormat("en-US", { timeZone: e, year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric", hour12: false }), r = t.formatToParts(s2);
15126
+ } catch (i) {
15127
+ let a = i instanceof Error ? i.message : String(i);
15128
+ throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`);
15129
+ }
15130
+ let n = { year: 0, month: 0, day: 0, hour: 0, minute: 0, second: 0 };
15131
+ for (let i of r) (i.type === "year" || i.type === "month" || i.type === "day" || i.type === "hour" || i.type === "minute" || i.type === "second") && (n[i.type] = parseInt(i.value, 10));
15132
+ if (isNaN(n.year) || isNaN(n.month) || isNaN(n.day) || isNaN(n.hour) || isNaN(n.minute) || isNaN(n.second)) throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(n)}`);
15133
+ return n.hour === 24 && (n.hour = 0), { y: n.year, m: n.month, d: n.day, h: n.hour, i: n.minute, s: n.second, tz: e };
15134
+ }
15135
+ function b(s2, e, t, r, n, i, a) {
15136
+ return { y: s2, m: e, d: t, h: r, i: n, s: i, tz: a };
15137
+ }
15138
+ var O = [1, 2, 4, 8, 16];
15139
+ var C = class {
15140
+ pattern;
15141
+ timezone;
15142
+ mode;
15143
+ alternativeWeekdays;
15144
+ sloppyRanges;
15145
+ second;
15146
+ minute;
15147
+ hour;
15148
+ day;
15149
+ month;
15150
+ dayOfWeek;
15151
+ year;
15152
+ lastDayOfMonth;
15153
+ lastWeekday;
15154
+ nearestWeekdays;
15155
+ starDOM;
15156
+ starDOW;
15157
+ starYear;
15158
+ useAndLogic;
15159
+ constructor(e, t, r) {
15160
+ this.pattern = e, this.timezone = t, this.mode = r?.mode ?? "auto", this.alternativeWeekdays = r?.alternativeWeekdays ?? false, this.sloppyRanges = r?.sloppyRanges ?? false, this.second = Array(60).fill(0), this.minute = Array(60).fill(0), this.hour = Array(24).fill(0), this.day = Array(31).fill(0), this.month = Array(12).fill(0), this.dayOfWeek = Array(7).fill(0), this.year = Array(1e4).fill(0), this.lastDayOfMonth = false, this.lastWeekday = false, this.nearestWeekdays = Array(31).fill(0), this.starDOM = false, this.starDOW = false, this.starYear = false, this.useAndLogic = false, this.parse();
15161
+ }
15162
+ parse() {
15163
+ if (!(typeof this.pattern == "string" || this.pattern instanceof String)) throw new TypeError("CronPattern: Pattern has to be of type string.");
15164
+ this.pattern.indexOf("@") >= 0 && (this.pattern = this.handleNicknames(this.pattern).trim());
15165
+ let e = this.pattern.match(/\S+/g) || [""], t = e.length;
15166
+ if (e.length < 5 || e.length > 7) throw new TypeError("CronPattern: invalid configuration format ('" + this.pattern + "'), exactly five, six, or seven space separated parts are required.");
15167
+ if (this.mode !== "auto") {
15168
+ let n;
15169
+ switch (this.mode) {
15170
+ case "5-part":
15171
+ n = 5;
15172
+ break;
15173
+ case "6-part":
15174
+ n = 6;
15175
+ break;
15176
+ case "7-part":
15177
+ n = 7;
15178
+ break;
15179
+ case "5-or-6-parts":
15180
+ n = [5, 6];
15181
+ break;
15182
+ case "6-or-7-parts":
15183
+ n = [6, 7];
15184
+ break;
15185
+ default:
15186
+ n = 0;
15187
+ }
15188
+ if (!(Array.isArray(n) ? n.includes(t) : t === n)) {
15189
+ let a = Array.isArray(n) ? n.join(" or ") : n.toString();
15190
+ throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${a} parts, but pattern '${this.pattern}' has ${t} parts.`);
15191
+ }
15192
+ }
15193
+ if (e.length === 5 && e.unshift("0"), e.length === 6 && e.push("*"), e[3].toUpperCase() === "LW" ? (this.lastWeekday = true, e[3] = "") : e[3].toUpperCase().indexOf("L") >= 0 && (e[3] = e[3].replace(/L/gi, ""), this.lastDayOfMonth = true), e[3] == "*" && (this.starDOM = true), e[6] == "*" && (this.starYear = true), e[4].length >= 3 && (e[4] = this.replaceAlphaMonths(e[4])), e[5].length >= 3 && (e[5] = this.alternativeWeekdays ? this.replaceAlphaDaysQuartz(e[5]) : this.replaceAlphaDays(e[5])), e[5].startsWith("+") && (this.useAndLogic = true, e[5] = e[5].substring(1), e[5] === "")) throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");
15194
+ switch (e[5] == "*" && (this.starDOW = true), this.pattern.indexOf("?") >= 0 && (e[0] = e[0].replace(/\?/g, "*"), e[1] = e[1].replace(/\?/g, "*"), e[2] = e[2].replace(/\?/g, "*"), e[3] = e[3].replace(/\?/g, "*"), e[4] = e[4].replace(/\?/g, "*"), e[5] = e[5].replace(/\?/g, "*"), e[6] && (e[6] = e[6].replace(/\?/g, "*"))), this.mode) {
15195
+ case "5-part":
15196
+ e[0] = "0", e[6] = "*";
15197
+ break;
15198
+ case "6-part":
15199
+ e[6] = "*";
15200
+ break;
15201
+ case "5-or-6-parts":
15202
+ e[6] = "*";
15203
+ break;
15204
+ case "6-or-7-parts":
15205
+ break;
15206
+ case "7-part":
15207
+ case "auto":
15208
+ break;
15209
+ }
15210
+ this.throwAtIllegalCharacters(e), this.partToArray("second", e[0], 0, 1), this.partToArray("minute", e[1], 0, 1), this.partToArray("hour", e[2], 0, 1), this.partToArray("day", e[3], -1, 1), this.partToArray("month", e[4], -1, 1);
15211
+ let r = this.alternativeWeekdays ? -1 : 0;
15212
+ this.partToArray("dayOfWeek", e[5], r, 63), this.partToArray("year", e[6], 0, 1), !this.alternativeWeekdays && this.dayOfWeek[7] && (this.dayOfWeek[0] = this.dayOfWeek[7]);
15213
+ }
15214
+ partToArray(e, t, r, n) {
15215
+ let i = this[e], a = e === "day" && this.lastDayOfMonth, o = e === "day" && this.lastWeekday;
15216
+ if (t === "" && !a && !o) throw new TypeError("CronPattern: configuration entry " + e + " (" + t + ") is empty, check for trailing spaces.");
15217
+ if (t === "*") return i.fill(n);
15218
+ let h = t.split(",");
15219
+ if (h.length > 1) for (let l = 0; l < h.length; l++) this.partToArray(e, h[l], r, n);
15220
+ else t.indexOf("-") !== -1 && t.indexOf("/") !== -1 ? this.handleRangeWithStepping(t, e, r, n) : t.indexOf("-") !== -1 ? this.handleRange(t, e, r, n) : t.indexOf("/") !== -1 ? this.handleStepping(t, e, r, n) : t !== "" && this.handleNumber(t, e, r, n);
15221
+ }
15222
+ throwAtIllegalCharacters(e) {
15223
+ for (let t = 0; t < e.length; t++) if ((t === 3 ? /[^/*0-9,\-WwLl]+/ : t === 5 ? /[^/*0-9,\-#Ll]+/ : /[^/*0-9,\-]+/).test(e[t])) throw new TypeError("CronPattern: configuration entry " + t + " (" + e[t] + ") contains illegal characters.");
15224
+ }
15225
+ handleNumber(e, t, r, n) {
15226
+ let i = this.extractNth(e, t), a = e.toUpperCase().includes("W");
15227
+ if (t !== "day" && a) throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");
15228
+ a && (t = "nearestWeekdays");
15229
+ let o = parseInt(i[0], 10) + r;
15230
+ if (isNaN(o)) throw new TypeError("CronPattern: " + t + " is not a number: '" + e + "'");
15231
+ this.setPart(t, o, i[1] || n);
15232
+ }
15233
+ setPart(e, t, r) {
15234
+ if (!Object.prototype.hasOwnProperty.call(this, e)) throw new TypeError("CronPattern: Invalid part specified: " + e);
15235
+ if (e === "dayOfWeek") {
15236
+ if (t === 7 && (t = 0), t < 0 || t > 6) throw new RangeError("CronPattern: Invalid value for dayOfWeek: " + t);
15237
+ this.setNthWeekdayOfMonth(t, r);
15238
+ return;
15239
+ }
15240
+ if (e === "second" || e === "minute") {
15241
+ if (t < 0 || t >= 60) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
15242
+ } else if (e === "hour") {
15243
+ if (t < 0 || t >= 24) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
15244
+ } else if (e === "day" || e === "nearestWeekdays") {
15245
+ if (t < 0 || t >= 31) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
15246
+ } else if (e === "month") {
15247
+ if (t < 0 || t >= 12) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
15248
+ } else if (e === "year" && (t < 1 || t >= 1e4)) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t + " (supported range: 1-9999)");
15249
+ this[e][t] = r;
15250
+ }
15251
+ validateNotNaN(e, t) {
15252
+ if (isNaN(e)) throw new TypeError(t);
15253
+ }
15254
+ validateRange(e, t, r, n, i) {
15255
+ if (e > t) throw new TypeError("CronPattern: From value is larger than to value: '" + i + "'");
15256
+ if (r !== void 0) {
15257
+ if (r === 0) throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");
15258
+ if (r > this[n].length) throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part (" + this[n].length + ")");
15259
+ }
15260
+ }
15261
+ handleRangeWithStepping(e, t, r, n) {
15262
+ if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");
15263
+ let i = this.extractNth(e, t), a = i[0].match(/^(\d+)-(\d+)\/(\d+)$/);
15264
+ if (a === null) throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '" + e + "'");
15265
+ let [, o, h, l] = a, y = parseInt(o, 10) + r, u = parseInt(h, 10) + r, d = parseInt(l, 10);
15266
+ this.validateNotNaN(y, "CronPattern: Syntax error, illegal lower range (NaN)"), this.validateNotNaN(u, "CronPattern: Syntax error, illegal upper range (NaN)"), this.validateNotNaN(d, "CronPattern: Syntax error, illegal stepping: (NaN)"), this.validateRange(y, u, d, t, e);
15267
+ for (let c = y; c <= u; c += d) this.setPart(t, c, i[1] || n);
15268
+ }
15269
+ extractNth(e, t) {
15270
+ let r = e, n;
15271
+ if (r.includes("#")) {
15272
+ if (t !== "dayOfWeek") throw new Error("CronPattern: nth (#) only allowed in day-of-week field");
15273
+ n = r.split("#")[1], r = r.split("#")[0];
15274
+ } else if (r.toUpperCase().endsWith("L")) {
15275
+ if (t !== "dayOfWeek") throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");
15276
+ n = "L", r = r.slice(0, -1);
15277
+ }
15278
+ return [r, n];
15279
+ }
15280
+ handleRange(e, t, r, n) {
15281
+ if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");
15282
+ let i = this.extractNth(e, t), a = i[0].split("-");
15283
+ if (a.length !== 2) throw new TypeError("CronPattern: Syntax error, illegal range: '" + e + "'");
15284
+ let o = parseInt(a[0], 10) + r, h = parseInt(a[1], 10) + r;
15285
+ this.validateNotNaN(o, "CronPattern: Syntax error, illegal lower range (NaN)"), this.validateNotNaN(h, "CronPattern: Syntax error, illegal upper range (NaN)"), this.validateRange(o, h, void 0, t, e);
15286
+ for (let l = o; l <= h; l++) this.setPart(t, l, i[1] || n);
15287
+ }
15288
+ handleStepping(e, t, r, n) {
15289
+ if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");
15290
+ let i = this.extractNth(e, t), a = i[0].split("/");
15291
+ if (a.length !== 2) throw new TypeError("CronPattern: Syntax error, illegal stepping: '" + e + "'");
15292
+ if (this.sloppyRanges) a[0] === "" && (a[0] = "*");
15293
+ else {
15294
+ if (a[0] === "") throw new TypeError("CronPattern: Syntax error, stepping with missing prefix ('" + e + "') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");
15295
+ if (a[0] !== "*") throw new TypeError("CronPattern: Syntax error, stepping with numeric prefix ('" + e + "') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");
15296
+ }
15297
+ let o = 0;
15298
+ a[0] !== "*" && (o = parseInt(a[0], 10) + r);
15299
+ let h = parseInt(a[1], 10);
15300
+ this.validateNotNaN(h, "CronPattern: Syntax error, illegal stepping: (NaN)"), this.validateRange(0, this[t].length - 1, h, t, e);
15301
+ for (let l = o; l < this[t].length; l += h) this.setPart(t, l, i[1] || n);
15302
+ }
15303
+ replaceAlphaDays(e) {
15304
+ return e.replace(/-sun/gi, "-7").replace(/sun/gi, "0").replace(/mon/gi, "1").replace(/tue/gi, "2").replace(/wed/gi, "3").replace(/thu/gi, "4").replace(/fri/gi, "5").replace(/sat/gi, "6");
15305
+ }
15306
+ replaceAlphaDaysQuartz(e) {
15307
+ return e.replace(/sun/gi, "1").replace(/mon/gi, "2").replace(/tue/gi, "3").replace(/wed/gi, "4").replace(/thu/gi, "5").replace(/fri/gi, "6").replace(/sat/gi, "7");
15308
+ }
15309
+ replaceAlphaMonths(e) {
15310
+ return e.replace(/jan/gi, "1").replace(/feb/gi, "2").replace(/mar/gi, "3").replace(/apr/gi, "4").replace(/may/gi, "5").replace(/jun/gi, "6").replace(/jul/gi, "7").replace(/aug/gi, "8").replace(/sep/gi, "9").replace(/oct/gi, "10").replace(/nov/gi, "11").replace(/dec/gi, "12");
15311
+ }
15312
+ handleNicknames(e) {
15313
+ let t = e.trim().toLowerCase();
15314
+ if (t === "@yearly" || t === "@annually") return "0 0 1 1 *";
15315
+ if (t === "@monthly") return "0 0 1 * *";
15316
+ if (t === "@weekly") return "0 0 * * 0";
15317
+ if (t === "@daily" || t === "@midnight") return "0 0 * * *";
15318
+ if (t === "@hourly") return "0 * * * *";
15319
+ if (t === "@reboot") throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");
15320
+ return e;
15321
+ }
15322
+ setNthWeekdayOfMonth(e, t) {
15323
+ if (typeof t != "number" && t.toUpperCase() === "L") this.dayOfWeek[e] = this.dayOfWeek[e] | 32;
15324
+ else if (t === 63) this.dayOfWeek[e] = 63;
15325
+ else if (t < 6 && t > 0) this.dayOfWeek[e] = this.dayOfWeek[e] | O[t - 1];
15326
+ else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`);
15327
+ }
15328
+ };
15329
+ var P = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
15330
+ var f = [["month", "year", 0], ["day", "month", -1], ["hour", "day", 0], ["minute", "hour", 0], ["second", "minute", 0]];
15331
+ var m = class s {
15332
+ tz;
15333
+ ms;
15334
+ second;
15335
+ minute;
15336
+ hour;
15337
+ day;
15338
+ month;
15339
+ year;
15340
+ constructor(e, t) {
15341
+ if (this.tz = t, e && e instanceof Date) if (!isNaN(e)) this.fromDate(e);
15342
+ else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");
15343
+ else if (e == null) this.fromDate(/* @__PURE__ */ new Date());
15344
+ else if (e && typeof e == "string") this.fromString(e);
15345
+ else if (e instanceof s) this.fromCronDate(e);
15346
+ else throw new TypeError("CronDate: Invalid type (" + typeof e + ") passed to CronDate constructor");
15347
+ }
15348
+ getLastDayOfMonth(e, t) {
15349
+ return t !== 1 ? P[t] : new Date(Date.UTC(e, t + 1, 0)).getUTCDate();
15350
+ }
15351
+ getLastWeekday(e, t) {
15352
+ let r = this.getLastDayOfMonth(e, t), i = new Date(Date.UTC(e, t, r)).getUTCDay();
15353
+ return i === 0 ? r - 2 : i === 6 ? r - 1 : r;
15354
+ }
15355
+ getNearestWeekday(e, t, r) {
15356
+ let n = this.getLastDayOfMonth(e, t);
15357
+ if (r > n) return -1;
15358
+ let a = new Date(Date.UTC(e, t, r)).getUTCDay();
15359
+ return a === 0 ? r === n ? r - 2 : r + 1 : a === 6 ? r === 1 ? r + 2 : r - 1 : r;
15360
+ }
15361
+ isNthWeekdayOfMonth(e, t, r, n) {
15362
+ let a = new Date(Date.UTC(e, t, r)).getUTCDay(), o = 0;
15363
+ for (let h = 1; h <= r; h++) new Date(Date.UTC(e, t, h)).getUTCDay() === a && o++;
15364
+ if (n & 63 && O[o - 1] & n) return true;
15365
+ if (n & 32) {
15366
+ let h = this.getLastDayOfMonth(e, t);
15367
+ for (let l = r + 1; l <= h; l++) if (new Date(Date.UTC(e, t, l)).getUTCDay() === a) return false;
15368
+ return true;
15369
+ }
15370
+ return false;
15371
+ }
15372
+ fromDate(e) {
15373
+ if (this.tz !== void 0) if (typeof this.tz == "number") this.ms = e.getUTCMilliseconds(), this.second = e.getUTCSeconds(), this.minute = e.getUTCMinutes() + this.tz, this.hour = e.getUTCHours(), this.day = e.getUTCDate(), this.month = e.getUTCMonth(), this.year = e.getUTCFullYear(), this.apply();
15374
+ else try {
15375
+ let t = g(e, this.tz);
15376
+ this.ms = e.getMilliseconds(), this.second = t.s, this.minute = t.i, this.hour = t.h, this.day = t.d, this.month = t.m - 1, this.year = t.y;
15377
+ } catch (t) {
15378
+ let r = t instanceof Error ? t.message : String(t);
15379
+ throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`);
15380
+ }
15381
+ else this.ms = e.getMilliseconds(), this.second = e.getSeconds(), this.minute = e.getMinutes(), this.hour = e.getHours(), this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear();
15382
+ }
15383
+ fromCronDate(e) {
15384
+ this.tz = e.tz, this.year = e.year, this.month = e.month, this.day = e.day, this.hour = e.hour, this.minute = e.minute, this.second = e.second, this.ms = e.ms;
15385
+ }
15386
+ apply() {
15387
+ if (this.month > 11 || this.month < 0 || this.day > P[this.month] || this.day < 1 || this.hour > 59 || this.minute > 59 || this.second > 59 || this.hour < 0 || this.minute < 0 || this.second < 0) {
15388
+ let e = new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms));
15389
+ return this.ms = e.getUTCMilliseconds(), this.second = e.getUTCSeconds(), this.minute = e.getUTCMinutes(), this.hour = e.getUTCHours(), this.day = e.getUTCDate(), this.month = e.getUTCMonth(), this.year = e.getUTCFullYear(), true;
15390
+ } else return false;
15391
+ }
15392
+ fromString(e) {
15393
+ if (typeof this.tz == "number") {
15394
+ let t = v(e);
15395
+ this.ms = t.getUTCMilliseconds(), this.second = t.getUTCSeconds(), this.minute = t.getUTCMinutes(), this.hour = t.getUTCHours(), this.day = t.getUTCDate(), this.month = t.getUTCMonth(), this.year = t.getUTCFullYear(), this.apply();
15396
+ } else return this.fromDate(v(e, this.tz));
15397
+ }
15398
+ findNext(e, t, r, n) {
15399
+ return this._findMatch(e, t, r, n, 1);
15400
+ }
15401
+ _findMatch(e, t, r, n, i) {
15402
+ let a = this[t], o;
15403
+ r.lastDayOfMonth && (o = this.getLastDayOfMonth(this.year, this.month));
15404
+ let h = !r.starDOW && t == "day" ? new Date(Date.UTC(this.year, this.month, 1, 0, 0, 0, 0)).getUTCDay() : void 0, l = this[t] + n, y = i === 1 ? (u) => u < r[t].length : (u) => u >= 0;
15405
+ for (let u = l; y(u); u += i) {
15406
+ let d = r[t][u];
15407
+ if (t === "day" && !d) {
15408
+ for (let c = 0; c < r.nearestWeekdays.length; c++) if (r.nearestWeekdays[c]) {
15409
+ let M = this.getNearestWeekday(this.year, this.month, c - n);
15410
+ if (M === -1) continue;
15411
+ if (M === u - n) {
15412
+ d = 1;
15413
+ break;
15414
+ }
15415
+ }
15416
+ }
15417
+ if (t === "day" && r.lastWeekday) {
15418
+ let c = this.getLastWeekday(this.year, this.month);
15419
+ u - n === c && (d = 1);
15420
+ }
15421
+ if (t === "day" && r.lastDayOfMonth && u - n == o && (d = 1), t === "day" && !r.starDOW) {
15422
+ let c = r.dayOfWeek[(h + (u - n - 1)) % 7];
15423
+ if (c && c & 63) c = this.isNthWeekdayOfMonth(this.year, this.month, u - n, c) ? 1 : 0;
15424
+ else if (c) throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${c}`);
15425
+ r.useAndLogic ? d = d && c : !e.domAndDow && !r.starDOM ? d = d || c : d = d && c;
15426
+ }
15427
+ if (d) return this[t] = u - n, a !== this[t] ? 2 : 1;
15428
+ }
15429
+ return 3;
15430
+ }
15431
+ recurse(e, t, r) {
15432
+ if (r === 0 && !e.starYear) {
15433
+ if (this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0) {
15434
+ let i = -1;
15435
+ for (let a = this.year + 1; a < e.year.length && a < 1e4; a++) if (e.year[a] === 1) {
15436
+ i = a;
15437
+ break;
15438
+ }
15439
+ if (i === -1) return null;
15440
+ this.year = i, this.month = 0, this.day = 1, this.hour = 0, this.minute = 0, this.second = 0, this.ms = 0;
15441
+ }
15442
+ if (this.year >= 1e4) return null;
15443
+ }
15444
+ let n = this.findNext(t, f[r][0], e, f[r][2]);
15445
+ if (n > 1) {
15446
+ let i = r + 1;
15447
+ for (; i < f.length; ) this[f[i][0]] = -f[i][2], i++;
15448
+ if (n === 3) {
15449
+ if (this[f[r][1]]++, this[f[r][0]] = -f[r][2], this.apply(), r === 0 && !e.starYear) {
15450
+ for (; this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0 && this.year < 1e4; ) this.year++;
15451
+ if (this.year >= 1e4 || this.year >= e.year.length) return null;
15452
+ }
15453
+ return this.recurse(e, t, 0);
15454
+ } else if (this.apply()) return this.recurse(e, t, r - 1);
15455
+ }
15456
+ return r += 1, r >= f.length ? this : (e.starYear ? this.year >= 3e3 : this.year >= 1e4) ? null : this.recurse(e, t, r);
15457
+ }
15458
+ increment(e, t, r) {
15459
+ return this.second += t.interval !== void 0 && t.interval > 1 && r ? t.interval : 1, this.ms = 0, this.apply(), this.recurse(e, t, 0);
15460
+ }
15461
+ decrement(e, t) {
15462
+ return this.second -= t.interval !== void 0 && t.interval > 1 ? t.interval : 1, this.ms = 0, this.apply(), this.recurseBackward(e, t, 0, 0);
15463
+ }
15464
+ recurseBackward(e, t, r, n = 0) {
15465
+ if (n > 1e4) return null;
15466
+ if (r === 0 && !e.starYear) {
15467
+ if (this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0) {
15468
+ let a = -1;
15469
+ for (let o = this.year - 1; o >= 0; o--) if (e.year[o] === 1) {
15470
+ a = o;
15471
+ break;
15472
+ }
15473
+ if (a === -1) return null;
15474
+ this.year = a, this.month = 11, this.day = 31, this.hour = 23, this.minute = 59, this.second = 59, this.ms = 0;
15475
+ }
15476
+ if (this.year < 0) return null;
15477
+ }
15478
+ let i = this.findPrevious(t, f[r][0], e, f[r][2]);
15479
+ if (i > 1) {
15480
+ let a = r + 1;
15481
+ for (; a < f.length; ) {
15482
+ let o = f[a][0], h = f[a][2], l = this.getMaxPatternValue(o, e, h);
15483
+ this[o] = l, a++;
15484
+ }
15485
+ if (i === 3) {
15486
+ if (this[f[r][1]]--, r === 0) {
15487
+ let y = this.getLastDayOfMonth(this.year, this.month);
15488
+ this.day > y && (this.day = y);
15489
+ }
15490
+ if (r === 1) if (this.day <= 0) this.day = 1;
15491
+ else {
15492
+ let y = this.year, u = this.month;
15493
+ for (; u < 0; ) u += 12, y--;
15494
+ for (; u > 11; ) u -= 12, y++;
15495
+ let d = u !== 1 ? P[u] : new Date(Date.UTC(y, u + 1, 0)).getUTCDate();
15496
+ this.day > d && (this.day = d);
15497
+ }
15498
+ this.apply();
15499
+ let o = f[r][0], h = f[r][2], l = this.getMaxPatternValue(o, e, h);
15500
+ if (o === "day") {
15501
+ let y = this.getLastDayOfMonth(this.year, this.month);
15502
+ this[o] = Math.min(l, y);
15503
+ } else this[o] = l;
15504
+ if (this.apply(), r === 0) {
15505
+ let y = f[1][2], u = this.getMaxPatternValue("day", e, y), d = this.getLastDayOfMonth(this.year, this.month), c = Math.min(u, d);
15506
+ c !== this.day && (this.day = c, this.hour = this.getMaxPatternValue("hour", e, f[2][2]), this.minute = this.getMaxPatternValue("minute", e, f[3][2]), this.second = this.getMaxPatternValue("second", e, f[4][2]));
15507
+ }
15508
+ if (r === 0 && !e.starYear) {
15509
+ for (; this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0; ) this.year--;
15510
+ if (this.year < 0) return null;
15511
+ }
15512
+ return this.recurseBackward(e, t, 0, n + 1);
15513
+ } else if (this.apply()) return this.recurseBackward(e, t, r - 1, n + 1);
15514
+ }
15515
+ return r += 1, r >= f.length ? this : this.year < 0 ? null : this.recurseBackward(e, t, r, n + 1);
15516
+ }
15517
+ getMaxPatternValue(e, t, r) {
15518
+ if (e === "day" && t.lastDayOfMonth) return this.getLastDayOfMonth(this.year, this.month);
15519
+ if (e === "day" && !t.starDOW) return this.getLastDayOfMonth(this.year, this.month);
15520
+ for (let n = t[e].length - 1; n >= 0; n--) if (t[e][n]) return n - r;
15521
+ return t[e].length - 1 - r;
15522
+ }
15523
+ findPrevious(e, t, r, n) {
15524
+ return this._findMatch(e, t, r, n, -1);
15525
+ }
15526
+ getDate(e) {
15527
+ return e || this.tz === void 0 ? new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms) : typeof this.tz == "number" ? new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute - this.tz, this.second, this.ms)) : k(b(this.year, this.month + 1, this.day, this.hour, this.minute, this.second, this.tz), false);
15528
+ }
15529
+ getTime() {
15530
+ return this.getDate(false).getTime();
15531
+ }
15532
+ match(e, t) {
15533
+ if (!e.starYear && (this.year < 0 || this.year >= e.year.length || e.year[this.year] === 0)) return false;
15534
+ for (let r = 0; r < f.length; r++) {
15535
+ let n = f[r][0], i = f[r][2], a = this[n];
15536
+ if (a + i < 0 || a + i >= e[n].length) return false;
15537
+ let o = e[n][a + i];
15538
+ if (n === "day") {
15539
+ if (!o) {
15540
+ for (let h = 0; h < e.nearestWeekdays.length; h++) if (e.nearestWeekdays[h]) {
15541
+ let l = this.getNearestWeekday(this.year, this.month, h - i);
15542
+ if (l !== -1 && l === a) {
15543
+ o = 1;
15544
+ break;
15545
+ }
15546
+ }
15547
+ }
15548
+ if (e.lastWeekday) {
15549
+ let h = this.getLastWeekday(this.year, this.month);
15550
+ a === h && (o = 1);
15551
+ }
15552
+ if (e.lastDayOfMonth) {
15553
+ let h = this.getLastDayOfMonth(this.year, this.month);
15554
+ a === h && (o = 1);
15555
+ }
15556
+ if (!e.starDOW) {
15557
+ let h = new Date(Date.UTC(this.year, this.month, 1, 0, 0, 0, 0)).getUTCDay(), l = e.dayOfWeek[(h + (a - 1)) % 7];
15558
+ l && l & 63 && (l = this.isNthWeekdayOfMonth(this.year, this.month, a, l) ? 1 : 0), e.useAndLogic ? o = o && l : !t.domAndDow && !e.starDOM ? o = o || l : o = o && l;
15559
+ }
15560
+ }
15561
+ if (!o) return false;
15562
+ }
15563
+ return true;
15564
+ }
15565
+ };
15566
+ function R(s2) {
15567
+ if (s2 === void 0 && (s2 = {}), delete s2.name, s2.legacyMode !== void 0 && s2.domAndDow === void 0 ? s2.domAndDow = !s2.legacyMode : s2.domAndDow === void 0 && (s2.domAndDow = false), s2.legacyMode = !s2.domAndDow, s2.paused = s2.paused === void 0 ? false : s2.paused, s2.maxRuns = s2.maxRuns === void 0 ? 1 / 0 : s2.maxRuns, s2.catch = s2.catch === void 0 ? false : s2.catch, s2.interval = s2.interval === void 0 ? 0 : parseInt(s2.interval.toString(), 10), s2.utcOffset = s2.utcOffset === void 0 ? void 0 : parseInt(s2.utcOffset.toString(), 10), s2.dayOffset = s2.dayOffset === void 0 ? 0 : parseInt(s2.dayOffset.toString(), 10), s2.unref = s2.unref === void 0 ? false : s2.unref, s2.mode = s2.mode === void 0 ? "auto" : s2.mode, s2.alternativeWeekdays = s2.alternativeWeekdays === void 0 ? false : s2.alternativeWeekdays, s2.sloppyRanges = s2.sloppyRanges === void 0 ? false : s2.sloppyRanges, !["auto", "5-part", "6-part", "7-part", "5-or-6-parts", "6-or-7-parts"].includes(s2.mode)) throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");
15568
+ if (s2.startAt && (s2.startAt = new m(s2.startAt, s2.timezone)), s2.stopAt && (s2.stopAt = new m(s2.stopAt, s2.timezone)), s2.interval !== null) {
15569
+ if (isNaN(s2.interval)) throw new Error("CronOptions: Supplied value for interval is not a number");
15570
+ if (s2.interval < 0) throw new Error("CronOptions: Supplied value for interval can not be negative");
15571
+ }
15572
+ if (s2.utcOffset !== void 0) {
15573
+ if (isNaN(s2.utcOffset)) throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");
15574
+ if (s2.utcOffset < -870 || s2.utcOffset > 870) throw new Error("CronOptions: utcOffset out of bounds.");
15575
+ if (s2.utcOffset !== void 0 && s2.timezone) throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.");
15576
+ }
15577
+ if (s2.unref !== true && s2.unref !== false) throw new Error("CronOptions: Unref should be either true, false or undefined(false).");
15578
+ if (s2.dayOffset !== void 0 && s2.dayOffset !== 0 && isNaN(s2.dayOffset)) throw new Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");
15579
+ return s2;
15580
+ }
15581
+ function p(s2) {
15582
+ return Object.prototype.toString.call(s2) === "[object Function]" || typeof s2 == "function" || s2 instanceof Function;
15583
+ }
15584
+ function _(s2) {
15585
+ return p(s2);
15586
+ }
15587
+ function x(s2) {
15588
+ typeof Deno < "u" && typeof Deno.unrefTimer < "u" ? Deno.unrefTimer(s2) : s2 && typeof s2.unref < "u" && s2.unref();
15589
+ }
15590
+ var W = 30 * 1e3;
15591
+ var w = [];
15592
+ var E = class {
15593
+ name;
15594
+ options;
15595
+ _states;
15596
+ fn;
15597
+ getTz() {
15598
+ return this.options.timezone || this.options.utcOffset;
15599
+ }
15600
+ applyDayOffset(e) {
15601
+ if (this.options.dayOffset !== void 0 && this.options.dayOffset !== 0) {
15602
+ let t = this.options.dayOffset * 24 * 60 * 60 * 1e3;
15603
+ return new Date(e.getTime() + t);
15604
+ }
15605
+ return e;
15606
+ }
15607
+ constructor(e, t, r) {
15608
+ let n, i;
15609
+ if (p(t)) i = t;
15610
+ else if (typeof t == "object") n = t;
15611
+ else if (t !== void 0) throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");
15612
+ if (p(r)) i = r;
15613
+ else if (typeof r == "object") n = r;
15614
+ else if (r !== void 0) throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");
15615
+ if (this.name = n?.name, this.options = R(n), this._states = { kill: false, blocking: false, previousRun: void 0, currentRun: void 0, once: void 0, currentTimeout: void 0, maxRuns: n ? n.maxRuns : void 0, paused: n ? n.paused : false, pattern: new C("* * * * *", void 0, { mode: "auto" }) }, e && (e instanceof Date || typeof e == "string" && e.indexOf(":") > 0) ? this._states.once = new m(e, this.getTz()) : this._states.pattern = new C(e, this.options.timezone, { mode: this.options.mode, alternativeWeekdays: this.options.alternativeWeekdays, sloppyRanges: this.options.sloppyRanges }), this.name) {
15616
+ if (w.find((o) => o.name === this.name)) throw new Error("Cron: Tried to initialize new named job '" + this.name + "', but name already taken.");
15617
+ w.push(this);
15618
+ }
15619
+ return i !== void 0 && _(i) && (this.fn = i, this.schedule()), this;
15620
+ }
15621
+ nextRun(e) {
15622
+ let t = this._next(e);
15623
+ return t ? this.applyDayOffset(t.getDate(false)) : null;
15624
+ }
15625
+ nextRuns(e, t) {
15626
+ this._states.maxRuns !== void 0 && e > this._states.maxRuns && (e = this._states.maxRuns);
15627
+ let r = t || this._states.currentRun || void 0;
15628
+ return this._enumerateRuns(e, r, "next");
15629
+ }
15630
+ previousRuns(e, t) {
15631
+ return this._enumerateRuns(e, t || void 0, "previous");
15632
+ }
15633
+ _enumerateRuns(e, t, r) {
15634
+ let n = [], i = t ? new m(t, this.getTz()) : null, a = r === "next" ? this._next : this._previous;
15635
+ for (; e--; ) {
15636
+ let o = a.call(this, i);
15637
+ if (!o) break;
15638
+ let h = o.getDate(false);
15639
+ n.push(this.applyDayOffset(h)), i = o;
15640
+ }
15641
+ return n;
15642
+ }
15643
+ match(e) {
15644
+ if (this._states.once) {
15645
+ let r = new m(e, this.getTz());
15646
+ r.ms = 0;
15647
+ let n = new m(this._states.once, this.getTz());
15648
+ return n.ms = 0, r.getTime() === n.getTime();
15649
+ }
15650
+ let t = new m(e, this.getTz());
15651
+ return t.ms = 0, t.match(this._states.pattern, this.options);
15652
+ }
15653
+ getPattern() {
15654
+ if (!this._states.once) return this._states.pattern ? this._states.pattern.pattern : void 0;
15655
+ }
15656
+ getOnce() {
15657
+ return this._states.once ? this._states.once.getDate() : null;
15658
+ }
15659
+ isRunning() {
15660
+ let e = this.nextRun(this._states.currentRun), t = !this._states.paused, r = this.fn !== void 0, n = !this._states.kill;
15661
+ return t && r && n && e !== null;
15662
+ }
15663
+ isStopped() {
15664
+ return this._states.kill;
15665
+ }
15666
+ isBusy() {
15667
+ return this._states.blocking;
15668
+ }
15669
+ currentRun() {
15670
+ return this._states.currentRun ? this._states.currentRun.getDate() : null;
15671
+ }
15672
+ previousRun() {
15673
+ return this._states.previousRun ? this._states.previousRun.getDate() : null;
15674
+ }
15675
+ msToNext(e) {
15676
+ let t = this._next(e);
15677
+ return t ? e instanceof m || e instanceof Date ? t.getTime() - e.getTime() : t.getTime() - new m(e).getTime() : null;
15678
+ }
15679
+ stop() {
15680
+ this._states.kill = true, this._states.currentTimeout && clearTimeout(this._states.currentTimeout);
15681
+ let e = w.indexOf(this);
15682
+ e >= 0 && w.splice(e, 1);
15683
+ }
15684
+ pause() {
15685
+ return this._states.paused = true, !this._states.kill;
15686
+ }
15687
+ resume() {
15688
+ return this._states.paused = false, !this._states.kill;
15689
+ }
15690
+ schedule(e) {
15691
+ if (e && this.fn) throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");
15692
+ e && (this.fn = e);
15693
+ let t = this.msToNext(), r = this.nextRun(this._states.currentRun);
15694
+ return t == null || isNaN(t) || r === null ? this : (t > W && (t = W), this._states.currentTimeout = setTimeout(() => this._checkTrigger(r), t), this._states.currentTimeout && this.options.unref && x(this._states.currentTimeout), this);
15695
+ }
15696
+ async _trigger(e) {
15697
+ this._states.blocking = true, this._states.currentRun = new m(void 0, this.getTz());
15698
+ try {
15699
+ if (this.options.catch) try {
15700
+ this.fn !== void 0 && await this.fn(this, this.options.context);
15701
+ } catch (t) {
15702
+ if (p(this.options.catch)) try {
15703
+ this.options.catch(t, this);
15704
+ } catch {
15705
+ }
15706
+ }
15707
+ else this.fn !== void 0 && await this.fn(this, this.options.context);
15708
+ } finally {
15709
+ this._states.previousRun = new m(e, this.getTz()), this._states.blocking = false;
15710
+ }
15711
+ }
15712
+ async trigger() {
15713
+ await this._trigger();
15714
+ }
15715
+ runsLeft() {
15716
+ return this._states.maxRuns;
15717
+ }
15718
+ _checkTrigger(e) {
15719
+ let t = /* @__PURE__ */ new Date(), r = !this._states.paused && t.getTime() >= e.getTime(), n = this._states.blocking && this.options.protect;
15720
+ r && !n ? (this._states.maxRuns !== void 0 && this._states.maxRuns--, this._trigger()) : r && n && p(this.options.protect) && setTimeout(() => this.options.protect(this), 0), this.schedule();
15721
+ }
15722
+ _next(e) {
15723
+ let t = !!(e || this._states.currentRun), r = false;
15724
+ !e && this.options.startAt && this.options.interval && ([e, t] = this._calculatePreviousRun(e, t), r = !e), e = new m(e, this.getTz()), this.options.startAt && e && e.getTime() < this.options.startAt.getTime() && (e = this.options.startAt);
15725
+ let n = this._states.once || new m(e, this.getTz());
15726
+ return !r && n !== this._states.once && (n = n.increment(this._states.pattern, this.options, t)), this._states.once && this._states.once.getTime() <= e.getTime() || n === null || this._states.maxRuns !== void 0 && this._states.maxRuns <= 0 || this._states.kill || this.options.stopAt && n.getTime() >= this.options.stopAt.getTime() ? null : n;
15727
+ }
15728
+ _previous(e) {
15729
+ let t = new m(e, this.getTz());
15730
+ this.options.stopAt && t.getTime() > this.options.stopAt.getTime() && (t = this.options.stopAt);
15731
+ let r = new m(t, this.getTz());
15732
+ return this._states.once ? this._states.once.getTime() < t.getTime() ? this._states.once : null : (r = r.decrement(this._states.pattern, this.options), r === null || this.options.startAt && r.getTime() < this.options.startAt.getTime() ? null : r);
15733
+ }
15734
+ _calculatePreviousRun(e, t) {
15735
+ let r = new m(void 0, this.getTz()), n = e;
15736
+ if (this.options.startAt.getTime() <= r.getTime()) {
15737
+ n = this.options.startAt;
15738
+ let i = n.getTime() + this.options.interval * 1e3;
15739
+ for (; i <= r.getTime(); ) n = new m(n, this.getTz()).increment(this._states.pattern, this.options, true), i = n.getTime() + this.options.interval * 1e3;
15740
+ t = true;
15741
+ }
15742
+ return n === null && (n = void 0), [n, t];
15743
+ }
15744
+ };
15745
+
15746
+ // shared/routine-schedule.ts
15747
+ var MAX_EXPRESSION_LENGTH = 256;
15748
+ function cronCalculator(value) {
15749
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Choose a valid cron schedule");
15750
+ const input = value;
15751
+ if (input.type !== "cron" || typeof input.expression !== "string") throw new Error("Choose a valid cron schedule");
15752
+ if (Object.keys(input).some((key) => !["type", "expression", "timeZone"].includes(key))) {
15753
+ throw new Error("Cron schedules accept only type, expression and timeZone; start/end dates and other restrictions are not supported");
15754
+ }
15755
+ const expression = input.expression.trim().replace(/\s+/g, " ");
15756
+ if (expression.length > MAX_EXPRESSION_LENGTH || expression.split(" ").length !== 5 || expression.includes("@")) {
15757
+ throw new Error("Cron must have five fields: minute hour day-of-month month weekday (no seconds, year, or macros)");
15758
+ }
15759
+ const timeZone = typeof input.timeZone === "string" ? input.timeZone.trim() : "";
15760
+ if (timeZone.length > 128 || !(timeZone === "UTC" || /^[A-Za-z][A-Za-z0-9_+-]*(?:\/[A-Za-z0-9_+-]+)+$/.test(timeZone))) {
15761
+ throw new Error("Choose an IANA timezone such as America/New_York, Asia/Kolkata, or UTC");
15762
+ }
15763
+ try {
15764
+ new Intl.DateTimeFormat("en-US", { timeZone }).format(0);
15765
+ } catch {
15766
+ throw new Error("Choose a valid IANA timezone such as America/New_York, Asia/Kolkata, or UTC");
15767
+ }
15768
+ try {
15769
+ const cron = new E(expression, { timezone: timeZone, mode: "5-part", paused: true });
15770
+ return { schedule: { type: "cron", expression, timeZone }, cron };
15771
+ } catch (error51) {
15772
+ throw new Error(`Invalid cron expression: ${error51.message}`);
15773
+ }
15774
+ }
15775
+ function calculationDate(after) {
15776
+ const date5 = new Date(after);
15777
+ if (!Number.isFinite(after) || !Number.isFinite(date5.getTime())) throw new Error("Choose a valid cron preview date");
15778
+ return date5;
15779
+ }
15780
+ function futureRuns(cron, after, count) {
15781
+ const from = calculationDate(after);
15782
+ const maximum = count + 1440;
15783
+ let requested = count;
15784
+ while (true) {
15785
+ const candidates = cron.nextRuns(requested, from);
15786
+ const runs = [];
15787
+ for (const date5 of candidates) {
15788
+ const at = date5.getTime();
15789
+ if (!Number.isFinite(at)) throw new Error("The cron schedule produced an invalid date");
15790
+ if (at > (runs.at(-1) ?? after)) runs.push(at);
15791
+ if (runs.length === count) return runs;
15792
+ }
15793
+ if (candidates.length < requested || requested === maximum) return runs;
15794
+ requested = Math.min(maximum, requested * 2);
15795
+ }
15796
+ }
15797
+ function normalizeCronSchedule(value, after = Date.now()) {
15798
+ const { schedule, cron } = cronCalculator(value);
15799
+ if (!futureRuns(cron, after, 1).length) throw new Error("This cron expression has no future runs. Choose dates that exist.");
15800
+ return schedule;
15801
+ }
15802
+
15803
+ // server/new-bot-defaults.ts
15804
+ var strings = (max, length) => external_exports.array(external_exports.string().max(length)).max(max);
15805
+ var clock = external_exports.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/);
15806
+ var weekdays = external_exports.array(external_exports.number().int().min(0).max(6)).min(1).max(7);
15807
+ var timestamp = external_exports.number().int().nonnegative().max(864e13);
15808
+ var botDefaultModelSchema = external_exports.object({
15809
+ instanceId: external_exports.string().trim().min(1).max(200),
15810
+ model: external_exports.string().trim().min(1).max(500),
15811
+ effort: external_exports.enum(EFFORT_LEVELS).optional(),
15812
+ variant: external_exports.string().refine(isModelVariant, "invalid model variant").optional()
15813
+ }).strict().refine(
15814
+ (value) => value.effort === void 0 || value.variant === void 0,
15815
+ "choose either a model variant or an effort level"
15816
+ );
15817
+ var botDefaultsProfileSchema = profilePatchSchema.extend({
15818
+ name: external_exports.string().max(100).refine(fitsOnOneLine, "name must fit on one line").optional(),
15819
+ section: external_exports.string().trim().max(60).optional(),
15820
+ color: external_exports.enum(["green", "blue", "red", "orange", "purple", "cyan", "pink", "yellow", "teal", "coral"]).optional(),
15821
+ mascotExpression: external_exports.string().max(60).nullable().optional(),
15822
+ modelSelection: botDefaultModelSchema.optional(),
15823
+ computer: external_exports.enum(["cloud", "vm", "local", "browser", "off"]).nullable().optional(),
15824
+ cloudBackend: external_exports.enum(["box", "vps"]).optional(),
15825
+ autoStartVps: external_exports.boolean().optional(),
15826
+ cwd: external_exports.string().max(4096).nullable().optional(),
15827
+ approvalMode: external_exports.enum(["ask", "auto", "full", "custom"]).optional(),
15828
+ alwaysAllow: strings(200, 500).optional(),
15829
+ chiefOfStaff: external_exports.boolean().optional(),
15830
+ managedSections: strings(100, 60).optional(),
15831
+ approvePeerComms: external_exports.boolean().optional(),
15832
+ peers: strings(1e3, 100).nullable().optional(),
15833
+ composio: external_exports.boolean().optional(),
15834
+ browser: external_exports.boolean().optional(),
15835
+ browserProfile: external_exports.string().max(100).nullable().optional(),
15836
+ mcpServers: strings(100, 100).nullable().optional(),
15837
+ parkDirectMessages: external_exports.boolean().optional()
15838
+ }).strict();
15839
+ var scheduleSchema = external_exports.discriminatedUnion("type", [
15840
+ external_exports.object({ type: external_exports.literal("once"), at: timestamp }).strict(),
15841
+ external_exports.object({ type: external_exports.literal("daily"), time: clock, weekdays }).strict(),
15842
+ external_exports.object({
15843
+ type: external_exports.literal("interval"),
15844
+ everyMinutes: external_exports.number().int().min(5).max(1440),
15845
+ anchorAt: timestamp,
15846
+ weekdays: weekdays.nullable().optional(),
15847
+ window: external_exports.object({ start: clock, end: clock }).strict().nullable().optional(),
15848
+ endsAt: timestamp.nullable().optional()
15849
+ }).strict(),
15850
+ external_exports.object({ type: external_exports.literal("cron"), expression: external_exports.string().max(256), timeZone: external_exports.string().max(128) }).strict()
15851
+ ]).superRefine((value, ctx) => {
15852
+ if (value.type === "cron") {
15853
+ try {
15854
+ normalizeCronSchedule(value);
15855
+ } catch (error51) {
15856
+ ctx.addIssue({ code: "custom", message: String(error51) });
15857
+ }
15858
+ }
15859
+ if (value.type === "interval" && value.window) {
15860
+ const minutes = (time3) => Number(time3.slice(0, 2)) * 60 + Number(time3.slice(3));
15861
+ if (minutes(value.window.end) - minutes(value.window.start) < value.everyMinutes) {
15862
+ ctx.addIssue({ code: "custom", message: "The interval must fit inside its time window" });
15863
+ }
15864
+ }
15865
+ });
15866
+ var botRoutineTemplateSchema = external_exports.object({
15867
+ name: external_exports.string().trim().min(1).max(80),
15868
+ prompt: external_exports.string().trim().min(1).max(2e4),
15869
+ schedule: scheduleSchema,
15870
+ enabled: external_exports.boolean().optional(),
15871
+ runOn: external_exports.enum(["maus", "cloud"]).optional(),
15872
+ durationMinutes: external_exports.number().int().min(5).max(240).optional(),
15873
+ timeoutMinutes: external_exports.number().min(1).max(1440).nullable().optional(),
15874
+ overlap: external_exports.enum(["skip", "queue"]).optional(),
15875
+ attachments: external_exports.array(external_exports.object({
15876
+ id: external_exports.string().min(1).max(200),
15877
+ kind: external_exports.enum(["file", "image"]),
15878
+ name: external_exports.string().min(1).max(255),
15879
+ path: external_exports.string().min(1).max(4096),
15880
+ size: external_exports.number().nonnegative()
15881
+ }).strict()).max(50).optional()
15882
+ }).strict();
15883
+ var botSkillTemplateSchema = external_exports.object({
15884
+ name: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
15885
+ description: external_exports.string().max(1024),
15886
+ warnings: strings(100, 2e3).default([]),
15887
+ source: external_exports.string().min(1).max(2e3),
15888
+ text: external_exports.string().refine((value) => Buffer.byteLength(value, "utf8") <= 262144, "Skill exceeds 256 KiB"),
15889
+ enabled: external_exports.boolean()
15890
+ }).strict();
15891
+ var newBotDefaultsSchema = external_exports.object({
15892
+ profile: botDefaultsProfileSchema.default({}),
15893
+ memory: external_exports.record(
15894
+ external_exports.string().regex(/^(?:MEMORY\.md|memory\/[a-zA-Z0-9_-]+\.md)$/),
15895
+ external_exports.string().refine((value) => Buffer.byteLength(value, "utf8") <= 262144, "Memory file exceeds 256 KiB")
15896
+ ).refine((value) => Object.keys(value).length <= 100, "At most 100 memory files").default({}),
15897
+ skills: external_exports.array(botSkillTemplateSchema).max(100).default([]),
15898
+ routines: external_exports.array(botRoutineTemplateSchema).max(100).default([])
15899
+ }).strict().refine(
15900
+ (value) => Buffer.byteLength(JSON.stringify(value), "utf8") <= 9e5,
15901
+ "Bot defaults must fit within 900 KB"
15902
+ );
15903
+
15047
15904
  // shared/provider-icon.ts
15048
15905
  var PROVIDER_ICON_PRESETS = [
15049
15906
  "openai",
@@ -15171,7 +16028,7 @@ var MAX_CONCURRENT_BOT_THREADS = 10;
15171
16028
  var MIN_THREAD_EVENT_LOG_BYTES = 256 * 1024;
15172
16029
  var MAX_THREAD_EVENT_LOG_BYTES = 4 * 1024 * 1024 * 1024;
15173
16030
  var MIN_LOCAL_VM_MAX_INSTANCES = 1;
15174
- var MAX_LOCAL_VM_MAX_INSTANCES = 4;
16031
+ var MAX_LOCAL_VM_MAX_INSTANCES = 8;
15175
16032
  function isValidSshAlias(value) {
15176
16033
  return typeof value === "string" && SSH_ALIAS.test(value);
15177
16034
  }
@@ -15364,8 +16221,8 @@ var instanceConfigSchema = external_exports.object({
15364
16221
  });
15365
16222
  var instanceConfigMapSchema = external_exports.record(external_exports.string(), instanceConfigSchema);
15366
16223
  var defaultModelSelectionSchema = external_exports.object({
15367
- instanceId: external_exports.string().trim().min(1),
15368
- model: external_exports.string().trim().min(1),
16224
+ instanceId: external_exports.string().trim().min(1).max(200),
16225
+ model: external_exports.string().trim().min(1).max(500),
15369
16226
  effort: external_exports.enum(EFFORT_LEVELS).optional(),
15370
16227
  variant: external_exports.string().refine(isModelVariant, "invalid model variant").optional()
15371
16228
  }).refine(
@@ -15381,6 +16238,13 @@ var threadsConfigSchema = external_exports.object({
15381
16238
  * Absent keeps them forever. */
15382
16239
  eventLogRetentionDays: external_exports.number().int().min(1).max(3650).optional()
15383
16240
  }).strict();
16241
+ var newBotsConfigSchema = external_exports.object({
16242
+ /** Effort for a new bot whose model selection names none. */
16243
+ effort: external_exports.enum(EFFORT_LEVELS).optional()
16244
+ }).strict();
16245
+ var newBotsPatchSchema = external_exports.object({
16246
+ effort: newBotsConfigSchema.shape.effort.nullable()
16247
+ }).strict();
15384
16248
  var threadsPatchSchema = threadsConfigSchema.extend({
15385
16249
  maxConcurrentPerBot: threadsConfigSchema.shape.maxConcurrentPerBot.optional(),
15386
16250
  eventLogMaxBytes: threadsConfigSchema.shape.eventLogMaxBytes.nullable(),
@@ -15393,12 +16257,15 @@ var appConfigSchema = external_exports.object({
15393
16257
  * addresses or `@domain` entries; admins get every scope, members chat only. */
15394
16258
  signIn: external_exports.object({ admins: external_exports.array(external_exports.string().max(320)).max(500).optional(), members: external_exports.array(external_exports.string().max(320)).max(5e3).optional() }).optional(),
15395
16259
  defaultModelSelection: defaultModelSelectionSchema.optional(),
16260
+ newBotDefaults: newBotDefaultsSchema.optional(),
16261
+ newBots: newBotsConfigSchema.optional(),
15396
16262
  /** CLI-only launch preferences. Never enable remote access implicitly. */
15397
16263
  cliStartup: external_exports.object({
15398
16264
  access: external_exports.enum(["local", "tunnel", "tailscale", "public-url"]),
15399
16265
  publicUrl: external_exports.string().url().optional(),
15400
16266
  phone: external_exports.enum(["ios", "android"]).optional()
15401
16267
  }).optional(),
16268
+ mistral: external_exports.object({ key: optionalText }).optional(),
15402
16269
  xai: external_exports.object({ key: optionalText, url: optionalText }).optional(),
15403
16270
  /** Anthropic API key for Claude Code billed per token, handed only to
15404
16271
  * Claude instances; `url` only for a proxy or a test double. Never a
@@ -15467,8 +16334,8 @@ var appConfigSchema = external_exports.object({
15467
16334
  "Use a model ID without control characters"
15468
16335
  ).optional()
15469
16336
  }).optional(),
15470
- /** Non-secret profile details shown in the sidebar. */
15471
- profile: external_exports.object({ name: optionalText, email: optionalText }).optional(),
16337
+ /** Non-secret profile details; aboutMe is shared with every bot. */
16338
+ profile: external_exports.object({ name: optionalText, email: optionalText, aboutMe: external_exports.string().max(24e3).optional() }).optional(),
15472
16339
  /** UI language override (BCP-47, lowercase). Empty/absent = follow the
15473
16340
  * system language. Unknown tags degrade to English in the renderer. */
15474
16341
  language: optionalText,
@@ -15498,7 +16365,7 @@ var appConfigSchema = external_exports.object({
15498
16365
  var storedAppConfigSchema = appConfigSchema.extend({
15499
16366
  browserProfiles: storedBrowserProfilesSchema.optional()
15500
16367
  });
15501
- var appConfigPatchSchema = appConfigSchema.omit({ instances: true, mcpServers: true, cliStartup: true, customDomain: true }).extend({ threads: threadsPatchSchema.optional() });
16368
+ var appConfigPatchSchema = appConfigSchema.omit({ instances: true, mcpServers: true, cliStartup: true, customDomain: true }).extend({ threads: threadsPatchSchema.optional(), newBots: newBotsPatchSchema.optional() });
15502
16369
  var jsonObjectSchema = external_exports.record(external_exports.string(), external_exports.json());
15503
16370
  var DATA_DIR = process.env.OMB_DATA_DIR ?? join2(homedir2(), ".openmausbot");
15504
16371
  var LEGACY_DATA_DIR = join2(homedir2(), ".opengrokbot");
@@ -15569,9 +16436,99 @@ function cuaExecArgs(args2, options = {}) {
15569
16436
  }
15570
16437
  var containerMcpPath = SPAWNED_PROXIES.containerMcp;
15571
16438
 
16439
+ // server/vps-ssh.ts
16440
+ import { createHash } from "node:crypto";
16441
+ import { chmodSync, existsSync as existsSync3, lstatSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync2, writeFileSync } from "node:fs";
16442
+ import { homedir as homedir3 } from "node:os";
16443
+ import { delimiter as delimiter2, join as join5, resolve as resolve2 } from "node:path";
16444
+ var VPS_SSH_DIR = "ssh";
16445
+ function shellQuote(value) {
16446
+ return `'${value.replace(/'/g, "'\\''")}'`;
16447
+ }
16448
+ function controlDirectory(sshDir) {
16449
+ if (Buffer.byteLength(join5(sshDir, `cm-${"0".repeat(40)}`)) <= 80) return sshDir;
16450
+ const uid = process.getuid();
16451
+ const id = createHash("sha256").update(resolve2(sshDir)).digest("hex").slice(0, 12);
16452
+ const dir = `/tmp/omb-ssh-${uid}-${id}`;
16453
+ try {
16454
+ mkdirSync(dir, { mode: 448 });
16455
+ } catch (error51) {
16456
+ if (error51.code !== "EEXIST") throw error51;
16457
+ }
16458
+ const stat = lstatSync(dir);
16459
+ if (!stat.isDirectory() || stat.uid !== uid) throw new Error("The VPS SSH control directory is not private to this user");
16460
+ chmodSync(dir, 448);
16461
+ return dir;
16462
+ }
16463
+ function findExecutable(name, pathValue, exclude) {
16464
+ for (const dir of pathValue.split(delimiter2)) {
16465
+ if (!dir || dir === exclude) continue;
16466
+ const candidate = join5(dir, name);
16467
+ try {
16468
+ const stat = statSync2(candidate);
16469
+ if (stat.isFile() && (stat.mode & 73) !== 0) return candidate;
16470
+ } catch {
16471
+ }
16472
+ }
16473
+ return null;
16474
+ }
16475
+ function writeIfChanged(path, content, mode) {
16476
+ try {
16477
+ if (readFileSync2(path, "utf8") === content) {
16478
+ chmodSync(path, mode);
16479
+ return;
16480
+ }
16481
+ } catch {
16482
+ }
16483
+ const temp = `${path}.${process.pid}.tmp`;
16484
+ writeFileSync(temp, content, { mode });
16485
+ renameSync(temp, path);
16486
+ }
16487
+ function vpsSshConfigText(sshDir, userConfig = join5(homedir3(), ".ssh", "config"), systemConfig = "/etc/ssh/ssh_config") {
16488
+ return [
16489
+ "# Written by OpenMausBot for its VPS computer connections. Do not edit;",
16490
+ "# it is regenerated. Your own ~/.ssh/config is included first and wins.",
16491
+ ...existsSync3(userConfig) ? [`Include ${JSON.stringify(userConfig)}`] : [],
16492
+ "Host *",
16493
+ " ControlMaster auto",
16494
+ ` ControlPath ${JSON.stringify(join5(sshDir.replace(/%/g, "%%"), "cm-%C"))}`,
16495
+ " ControlPersist 10m",
16496
+ " ServerAliveInterval 15",
16497
+ " ServerAliveCountMax 3",
16498
+ " ConnectTimeout 10",
16499
+ ...existsSync3(systemConfig) ? [`Include ${JSON.stringify(systemConfig)}`] : [],
16500
+ ""
16501
+ ].join("\n");
16502
+ }
16503
+ function prepareVpsSsh(dataDir, pathValue, platform = process.platform) {
16504
+ if (platform === "win32") return { configPath: null, path: pathValue };
16505
+ const sshDir = join5(dataDir, VPS_SSH_DIR);
16506
+ const binDir = join5(sshDir, "bin");
16507
+ mkdirSync(binDir, { recursive: true, mode: 448 });
16508
+ chmodSync(sshDir, 448);
16509
+ const configPath = join5(sshDir, "config");
16510
+ writeIfChanged(configPath, vpsSshConfigText(controlDirectory(sshDir)), 384);
16511
+ const realSsh = findExecutable("ssh", pathValue, binDir);
16512
+ if (!realSsh) return { configPath, path: pathValue };
16513
+ const shim = [
16514
+ "#!/bin/sh",
16515
+ "# Written by OpenMausBot. docker's SSH transport finds this ssh first, so",
16516
+ "# every VPS command shares one connection whether or not the alias says so.",
16517
+ `exec ${shellQuote(realSsh)} -F ${shellQuote(configPath)} "$@"`,
16518
+ ""
16519
+ ].join("\n");
16520
+ writeIfChanged(join5(binDir, "ssh"), shim, 448);
16521
+ return { configPath, path: `${binDir}${delimiter2}${pathValue}` };
16522
+ }
16523
+
15572
16524
  // server/vps-computer.ts
16525
+ var COMMAND_TIMEOUT_TERM_GRACE_MS = 5e3;
16526
+ var COMMAND_TIMEOUT_KILL_GRACE_MS = COMMAND_TIMEOUT_TERM_GRACE_MS + 1e3;
15573
16527
  var CONTAINER_NAME = /^[a-zA-Z0-9][a-zA-Z0-9_.-]+$/;
15574
16528
  var CONTAINER_ID = /^[a-f0-9]{12,64}$/i;
16529
+ var LOCK_ACQUIRE_TIMEOUT_MS = 5e3;
16530
+ var SCREENSHOT_BUDGET_MS = 45e3;
16531
+ var PREPARATION_LOCK_TIMEOUT_MS = SCREENSHOT_BUDGET_MS + LOCK_ACQUIRE_TIMEOUT_MS;
15575
16532
  function vpsDockerArgs(alias2, args2) {
15576
16533
  if (!isValidSshAlias(alias2)) {
15577
16534
  throw new Error("invalid VPS SSH config alias");
@@ -15601,9 +16558,13 @@ try {
15601
16558
  }
15602
16559
  var controlUrl = process.env.OMB_CONTROL_URL ?? "";
15603
16560
  var controlToken = process.env.OMB_CONTROL_TOKEN ?? "";
16561
+ var ssh = prepareVpsSsh(DATA_DIR, augmentedPath());
15604
16562
  runMcpBridge({
15605
16563
  command: "docker",
15606
16564
  args,
16565
+ // Keep tool calls and the watchdog on the same bounded, shared transport
16566
+ // as startup and previews; otherwise only the panel gets the SSH defaults.
16567
+ env: { ...process.env, PATH: ssh.path },
15607
16568
  label: "VPS Cua Driver",
15608
16569
  // The probe checks the TRANSPORT (SSH + daemon), deliberately not the
15609
16570
  // driver: a busy desktop mid-tool-call must never look dead, while an