openmausbot 0.1.85 → 0.1.87

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 (262) hide show
  1. package/README.md +2 -2
  2. package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  3. package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  4. package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  5. package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  6. package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  7. package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  8. package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  9. package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  10. package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  11. package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  12. package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  13. package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  14. package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  15. package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  16. package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  17. package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  18. package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  19. package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  20. package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  21. package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  22. package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  23. package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  24. package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  25. package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  26. package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  27. package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  28. package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  29. package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  30. package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  31. package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  32. package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  33. package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  34. package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  35. package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  36. package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  37. package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  38. package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  39. package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  40. package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  41. package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  42. package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  43. package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  44. package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  45. package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  46. package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  47. package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  48. package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  49. package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  50. package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  51. package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  52. package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  53. package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  54. package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  55. package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  56. package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  57. package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  58. package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  59. package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  60. package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  61. package/dist/assets/abnfDiagram-O67JEVCF-BTiuL79F.js +1 -0
  62. package/dist/assets/arc-C88Blc2v.js +1 -0
  63. package/dist/assets/architectureDiagram-NJMV4G6O-BZsJIZrb.js +36 -0
  64. package/dist/assets/blockDiagram-BEXU5L5S-CVeMe9Ah.js +140 -0
  65. package/dist/assets/c4Diagram-YGBWAQC7-Cedk3Bhx.js +38 -0
  66. package/dist/assets/channel-taCNRlUU.js +1 -0
  67. package/dist/assets/chunk-2Q5K7J3B-D-VRqzTB.js +1 -0
  68. package/dist/assets/chunk-3FUC2YCW-BChov01Y.js +2 -0
  69. package/dist/assets/chunk-5VM5RSS4-C-TfwvHy.js +15 -0
  70. package/dist/assets/chunk-GTNCS2PH-Db7CGj5Y.js +88 -0
  71. package/dist/assets/chunk-GWA4HPMP-CNvIfqKT.js +1 -0
  72. package/dist/assets/chunk-JWPE2WC7-C_bEp5tq.js +1 -0
  73. package/dist/assets/chunk-NETBCI7D-Coi4BOls.js +1 -0
  74. package/dist/assets/chunk-WEXAMYUT-CzylEuL3.js +1 -0
  75. package/dist/assets/chunk-XXDRQBXY-m7p7ztaD.js +1 -0
  76. package/dist/assets/classDiagram-v2-NBCMYWYE-BMy6o9x2.js +217 -0
  77. package/dist/assets/cose-bilkent-JH36ORCC-BDQ__0_J.js +1 -0
  78. package/dist/assets/cynefin-OW5HDTMX-Djv4ghUb.js +166 -0
  79. package/dist/assets/cynefinDiagram-VND7K2PF-BULrlGYH.js +62 -0
  80. package/dist/assets/cytoscape.esm-BB4DxJjf.js +321 -0
  81. package/dist/assets/dagre-6A5THRUB-D-jrT_hU.js +4 -0
  82. package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  83. package/dist/assets/diagram-22UHCM2B-p2UhQmfL.js +200 -0
  84. package/dist/assets/diagram-3UASUU5V-DHvGWZ7q.js +24 -0
  85. package/dist/assets/diagram-ATOU4E4O-ChhKDot-.js +3 -0
  86. package/dist/assets/diagram-CDSNMT55-B-T7A43R.js +30 -0
  87. package/dist/assets/diagram-MLGK6HIB-CJm8ENNY.js +24 -0
  88. package/dist/assets/diagram-MPIPVDR6-510tlza8.js +41 -0
  89. package/dist/assets/ebnfDiagram-ZINNZB2B-PkvRPHel.js +1 -0
  90. package/dist/assets/elk-276RUBZZ-BVBVPoX3.js +27 -0
  91. package/dist/assets/erDiagram-OPXOYQCR-BgYMVm7L.js +99 -0
  92. package/dist/assets/flowDiagram-KWPJA3E3-BGqsnc_3.js +213 -0
  93. package/dist/assets/ganttDiagram-FUAMR5RP-D_-UeReH.js +292 -0
  94. package/dist/assets/gitGraphDiagram-X574FWY7-D0uooONx.js +106 -0
  95. package/dist/assets/graph-D8UmR1vK.js +1 -0
  96. package/dist/assets/index-BwdMAQ6p.css +1 -0
  97. package/dist/assets/index-ByJennr7.js +581 -0
  98. package/dist/assets/{index-CTNNoqSJ.js → index-zRsJERGJ.js} +1 -1
  99. package/dist/assets/infoDiagram-VRGFBTTK-B9e1z77f.js +2 -0
  100. package/dist/assets/init-Gi6I4Gst.js +1 -0
  101. package/dist/assets/ishikawaDiagram-OU5B5YK6-BB4vNwvD.js +70 -0
  102. package/dist/assets/journeyDiagram-ZHPQQLJL-DpkosOTB.js +139 -0
  103. package/dist/assets/kanban-definition-PNTS6WVX-DbDP4kUu.js +89 -0
  104. package/dist/assets/linear-DBJGPmjT.js +1 -0
  105. package/dist/assets/mermaid.core-DWPRi-ue.js +311 -0
  106. package/dist/assets/mindmap-definition-NLK3R4M7-nszBbJmx.js +96 -0
  107. package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  108. package/dist/assets/pegDiagram-GJSIUBJH-CWykJWu_.js +1 -0
  109. package/dist/assets/pieDiagram-5QR66LMP-g3Da-Vnv.js +39 -0
  110. package/dist/assets/quadrantDiagram-O4NWA36T-Wzrlpzgh.js +7 -0
  111. package/dist/assets/railroadDiagram-XR7U4H2S-moHTFMC0.js +1 -0
  112. package/dist/assets/requirementDiagram-PLB6GJNP-CwfXdFH8.js +84 -0
  113. package/dist/assets/sankeyDiagram-IPEJSGJF-3ZROYvnq.js +40 -0
  114. package/dist/assets/sequenceDiagram-PO4LG4MO-E1TBebP8.js +169 -0
  115. package/dist/assets/sizeCapture-INFHLROL-DHKEU5pu.js +1 -0
  116. package/dist/assets/stateDiagram-v2-GCMORJYK-BguEj09D.js +291 -0
  117. package/dist/assets/swimlanes-2SLR337P-C7IDYnhd.js +1 -0
  118. package/dist/assets/swimlanesDiagram-TC7HE7FX-BpEdoB2e.js +8 -0
  119. package/dist/assets/timeline-definition-EJHVYXUP-DCW-F5PW.js +120 -0
  120. package/dist/assets/usecaseDiagram-POWQR4AR-xBMFtWYV.js +370 -0
  121. package/dist/assets/vennDiagram-UO4OBE2U-B5nIkuH8.js +34 -0
  122. package/dist/assets/wardleyDiagram-VNRHLVJA-DYFAhdbr.js +78 -0
  123. package/dist/assets/xychartDiagram-PMCCYNJV-DeXwX6Cz.js +7 -0
  124. package/dist/index.html +2 -2
  125. package/dist-server/browser-proxy.js +2 -1
  126. package/dist-server/container-mcp.js +1047 -173
  127. package/dist-server/drivers/agents-proxy.js +16121 -1504
  128. package/dist-server/drivers/phone-proxy.js +33 -2
  129. package/dist-server/enterprise/LICENSE +32 -0
  130. package/dist-server/enterprise/server/index.js +5 -5
  131. package/dist-server/index.js +16134 -7446
  132. package/dist-server/local-computer-proxy.js +3 -3
  133. package/dist-server/local-computer.js +53 -17
  134. package/dist-server/mcp-server.js +3 -1
  135. package/dist-server/openmausbot.js +9353 -6124
  136. package/dist-server/pair-cli.js +9353 -6124
  137. package/dist-server/permission-proxy.js +29 -9
  138. package/dist-server/server/admin-activity.js +410 -0
  139. package/dist-server/server/attachments.js +55 -0
  140. package/dist-server/server/auto-approve.js +4 -3
  141. package/dist-server/server/auto-vm-claims.js +1 -0
  142. package/dist-server/server/bot-package.js +18 -292
  143. package/dist-server/server/bot-profile.js +5 -17
  144. package/dist-server/server/bot-visibility.js +462 -0
  145. package/dist-server/server/box-create-idempotency.js +3 -3
  146. package/dist-server/server/box.js +59 -56
  147. package/dist-server/server/browser-proxy.js +3 -2
  148. package/dist-server/server/browser-runtime.js +38 -2
  149. package/dist-server/server/channel-queue.js +2 -0
  150. package/dist-server/server/cli-prompts.js +24 -2
  151. package/dist-server/server/cli.js +81 -12
  152. package/dist-server/server/command-allowlist.js +154 -0
  153. package/dist-server/server/composio.js +49 -11
  154. package/dist-server/server/computer-wait.js +22 -9
  155. package/dist-server/server/config.js +133 -17
  156. package/dist-server/server/connector-verdict.js +141 -0
  157. package/dist-server/server/container-computer.js +1 -1
  158. package/dist-server/server/decision-log.js +209 -48
  159. package/dist-server/server/default-model-selection.js +29 -3
  160. package/dist-server/server/delegations.js +97 -44
  161. package/dist-server/server/drivers/acp/core.js +163 -33
  162. package/dist-server/server/drivers/acp/grok.js +4 -3
  163. package/dist-server/server/drivers/agents-call.js +1162 -0
  164. package/dist-server/server/drivers/agents-catalog.js +689 -0
  165. package/dist-server/server/drivers/agents-client.js +28 -0
  166. package/dist-server/server/drivers/agents-proxy.js +18 -1722
  167. package/dist-server/server/drivers/boxagent.js +174 -36
  168. package/dist-server/server/drivers/builtIn.js +2 -0
  169. package/dist-server/server/drivers/chat-box-tools.js +90 -0
  170. package/dist-server/server/drivers/chat-images.js +54 -0
  171. package/dist-server/server/drivers/chat-mcp-tools.js +55 -10
  172. package/dist-server/server/drivers/chat-tool-approval.js +70 -18
  173. package/dist-server/server/drivers/claude.js +28 -8
  174. package/dist-server/server/drivers/codex-instructions.js +48 -6
  175. package/dist-server/server/drivers/codex-mcp-names.js +44 -0
  176. package/dist-server/server/drivers/codex-tool-surface.js +20 -0
  177. package/dist-server/server/drivers/codex.js +121 -34
  178. package/dist-server/server/drivers/grok.js +2 -1
  179. package/dist-server/server/drivers/mistral.js +115 -0
  180. package/dist-server/server/drivers/openai-chat.js +155 -32
  181. package/dist-server/server/drivers/openai-compat.js +16 -8
  182. package/dist-server/server/drivers/permission-command.js +35 -0
  183. package/dist-server/server/drivers/phone-proxy.js +47 -2
  184. package/dist-server/server/drivers/pi.js +75 -4
  185. package/dist-server/server/drivers/prompt-split.js +87 -0
  186. package/dist-server/server/enterprise.js +97 -16
  187. package/dist-server/server/external-runtime.js +83 -0
  188. package/dist-server/server/fleet.js +1 -1
  189. package/dist-server/server/group-thread-usage.js +103 -0
  190. package/dist-server/server/guarded-requests.js +60 -0
  191. package/dist-server/server/harness/http.js +61 -0
  192. package/dist-server/server/harness/registry.js +1 -0
  193. package/dist-server/server/hosted-models.js +151 -0
  194. package/dist-server/server/hosted-slack.js +11 -0
  195. package/dist-server/server/index.js +3091 -658
  196. package/dist-server/server/local-computer.js +72 -23
  197. package/dist-server/server/managed-desktop.js +79 -14
  198. package/dist-server/server/managed-policy.js +153 -0
  199. package/dist-server/server/mcp-bridge.js +6 -6
  200. package/dist-server/server/message-db.js +28 -0
  201. package/dist-server/server/model-context-window.js +7 -0
  202. package/dist-server/server/model-prices.js +121 -0
  203. package/dist-server/server/new-bot-defaults.js +115 -0
  204. package/dist-server/server/notify.js +10 -1
  205. package/dist-server/server/org-library.js +1051 -0
  206. package/dist-server/server/package-export.js +627 -39
  207. package/dist-server/server/package-import.js +458 -0
  208. package/dist-server/server/package-parts.js +87 -0
  209. package/dist-server/server/peer-approval.js +16 -7
  210. package/dist-server/server/peer-roster.js +23 -2
  211. package/dist-server/server/presets.js +492 -0
  212. package/dist-server/server/provider-key-check.js +3 -2
  213. package/dist-server/server/published-teams.js +80 -0
  214. package/dist-server/server/recent-work.js +15 -0
  215. package/dist-server/server/request-auth.js +96 -0
  216. package/dist-server/server/room-handoffs.js +44 -14
  217. package/dist-server/server/routes/bot-presets.js +25 -0
  218. package/dist-server/server/routes/hosted-slack.js +20 -0
  219. package/dist-server/server/routes/table.js +14 -0
  220. package/dist-server/server/routine-requests.js +6 -3
  221. package/dist-server/server/routines.js +63 -1
  222. package/dist-server/server/section-context.js +10 -0
  223. package/dist-server/server/skills.js +34 -61
  224. package/dist-server/server/spend.js +111 -16
  225. package/dist-server/server/steer-queue.js +9 -3
  226. package/dist-server/server/store.js +550 -35
  227. package/dist-server/server/surface.js +10 -4
  228. package/dist-server/server/system-prompt.js +12 -4
  229. package/dist-server/server/team-backup.js +16 -3
  230. package/dist-server/server/team-computers.js +10 -0
  231. package/dist-server/server/team-library.js +6 -2
  232. package/dist-server/server/team-manifest.js +4 -3
  233. package/dist-server/server/team-setup-requests.js +16 -5
  234. package/dist-server/server/thread-events.js +17 -1
  235. package/dist-server/server/thread-starters.js +53 -0
  236. package/dist-server/server/turn-context.js +2 -0
  237. package/dist-server/server/turn-watchdog.js +12 -3
  238. package/dist-server/server/usage-ledger.js +43 -9
  239. package/dist-server/server/vps-computer.js +139 -51
  240. package/dist-server/server/vps-container-mcp.js +7 -0
  241. package/dist-server/server/vps-ssh.js +36 -7
  242. package/dist-server/server/workspace-backup-policy.js +21 -2
  243. package/dist-server/server/workspace-backup.js +7 -4
  244. package/dist-server/server/workspace.js +1 -1
  245. package/dist-server/shared/approval-mode.js +1 -1
  246. package/dist-server/shared/ask-question.js +188 -12
  247. package/dist-server/shared/bot-profile.js +15 -0
  248. package/dist-server/shared/command-allowlist.js +1 -0
  249. package/dist-server/shared/credential-request.js +1 -1
  250. package/dist-server/shared/mention-boundary.js +15 -0
  251. package/dist-server/shared/package-format.js +967 -0
  252. package/dist-server/shared/routines.js +7 -1
  253. package/dist-server/shared/skill-md.js +64 -0
  254. package/dist-server/shared/team-backup.js +9 -0
  255. package/dist-server/shared/wire.js +4 -0
  256. package/dist-server/src/lib/composer-attachments.js +16 -0
  257. package/dist-server/vps-container-mcp.js +1147 -179
  258. package/enterprise/README.md +33 -12
  259. package/enterprise/server/index.js +5 -5
  260. package/package.json +1 -1
  261. package/dist/assets/index-Ba9G44HI.js +0 -310
  262. package/dist/assets/index-CkRNp7wX.css +0 -1
@@ -17,7 +17,7 @@ import { basename, delimiter, dirname, extname, join } from "node:path";
17
17
  function nvmBinDirs() {
18
18
  try {
19
19
  const base = join(homedir(), ".nvm", "versions", "node");
20
- return readdirSync(base).filter((v) => v.startsWith("v")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true })).map((v) => join(base, v, "bin"));
20
+ return readdirSync(base).filter((v2) => v2.startsWith("v")).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true })).map((v2) => join(base, v2, "bin"));
21
21
  } catch {
22
22
  return [];
23
23
  }
@@ -107,10 +107,10 @@ function probeLoginShellPath() {
107
107
  { timeout: 5e3 },
108
108
  (err, stdout) => {
109
109
  if (err || !stdout) return;
110
- const m = /__OMB_PATH__([^\n]*)/.exec(stdout);
111
- if (!m || !m[1]) return;
112
- loginShellPath = m[1];
113
- cached = mergePaths([...(cached ?? "").split(delimiter), ...m[1].split(delimiter)]);
110
+ const m2 = /__OMB_PATH__([^\n]*)/.exec(stdout);
111
+ if (!m2 || !m2[1]) return;
112
+ loginShellPath = m2[1];
113
+ cached = mergePaths([...(cached ?? "").split(delimiter), ...m2[1].split(delimiter)]);
114
114
  }
115
115
  );
116
116
  }
@@ -653,7 +653,7 @@ function $constructor(name, initializer3, params) {
653
653
  Object.defineProperty(inst, "_zod", {
654
654
  value: {
655
655
  def,
656
- constr: _,
656
+ constr: _2,
657
657
  traits: /* @__PURE__ */ new Set()
658
658
  },
659
659
  enumerable: false
@@ -664,12 +664,12 @@ function $constructor(name, initializer3, params) {
664
664
  }
665
665
  inst._zod.traits.add(name);
666
666
  initializer3(inst, def);
667
- const proto = _.prototype;
667
+ const proto = _2.prototype;
668
668
  const keys = Object.keys(proto);
669
669
  for (let i = 0; i < keys.length; i++) {
670
- const k = keys[i];
671
- if (!(k in inst)) {
672
- inst[k] = proto[k].bind(inst);
670
+ const k2 = keys[i];
671
+ if (!(k2 in inst)) {
672
+ inst[k2] = proto[k2].bind(inst);
673
673
  }
674
674
  }
675
675
  }
@@ -677,7 +677,7 @@ function $constructor(name, initializer3, params) {
677
677
  class Definition extends Parent {
678
678
  }
679
679
  Object.defineProperty(Definition, "name", { value: name });
680
- function _(def) {
680
+ function _2(def) {
681
681
  var _a3;
682
682
  const inst = params?.Parent ? new Definition() : this;
683
683
  init(inst, def);
@@ -687,16 +687,16 @@ function $constructor(name, initializer3, params) {
687
687
  }
688
688
  return inst;
689
689
  }
690
- Object.defineProperty(_, "init", { value: init });
691
- Object.defineProperty(_, Symbol.hasInstance, {
690
+ Object.defineProperty(_2, "init", { value: init });
691
+ Object.defineProperty(_2, Symbol.hasInstance, {
692
692
  value: (inst) => {
693
693
  if (params?.Parent && inst instanceof params.Parent)
694
694
  return true;
695
695
  return inst?._zod?.traits?.has(name);
696
696
  }
697
697
  });
698
- Object.defineProperty(_, "name", { value: name });
699
- return _;
698
+ Object.defineProperty(_2, "name", { value: name });
699
+ return _2;
700
700
  }
701
701
  var $brand = /* @__PURE__ */ Symbol("zod_brand");
702
702
  var $ZodAsyncError = class extends Error {
@@ -796,17 +796,17 @@ function assertIs(_arg) {
796
796
  function assertNever(_x) {
797
797
  throw new Error("Unexpected value in exhaustive check");
798
798
  }
799
- function assert(_) {
799
+ function assert(_2) {
800
800
  }
801
801
  function getEnumValues(entries) {
802
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
803
- const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
802
+ const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
803
+ const values = Object.entries(entries).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v2]) => v2);
804
804
  return values;
805
805
  }
806
806
  function joinValues(array2, separator = "|") {
807
807
  return array2.map((val) => stringifyPrimitive(val)).join(separator);
808
808
  }
809
- function jsonStringifyReplacer(_, value) {
809
+ function jsonStringifyReplacer(_2, value) {
810
810
  if (typeof value === "bigint")
811
811
  return value.toString();
812
812
  return value;
@@ -854,9 +854,9 @@ function defineLazy(object2, key, getter) {
854
854
  }
855
855
  return value;
856
856
  },
857
- set(v) {
857
+ set(v2) {
858
858
  Object.defineProperty(object2, key, {
859
- value: v
859
+ value: v2
860
860
  // configurable: true,
861
861
  });
862
862
  },
@@ -931,7 +931,7 @@ var allowsEval = /* @__PURE__ */ cached2(() => {
931
931
  const F = Function;
932
932
  new F("");
933
933
  return true;
934
- } catch (_) {
934
+ } catch (_2) {
935
935
  return false;
936
936
  }
937
937
  });
@@ -1052,31 +1052,31 @@ function normalizeParams(_params) {
1052
1052
  function createTransparentProxy(getter) {
1053
1053
  let target;
1054
1054
  return new Proxy({}, {
1055
- get(_, prop, receiver) {
1055
+ get(_2, prop, receiver) {
1056
1056
  target ?? (target = getter());
1057
1057
  return Reflect.get(target, prop, receiver);
1058
1058
  },
1059
- set(_, prop, value, receiver) {
1059
+ set(_2, prop, value, receiver) {
1060
1060
  target ?? (target = getter());
1061
1061
  return Reflect.set(target, prop, value, receiver);
1062
1062
  },
1063
- has(_, prop) {
1063
+ has(_2, prop) {
1064
1064
  target ?? (target = getter());
1065
1065
  return Reflect.has(target, prop);
1066
1066
  },
1067
- deleteProperty(_, prop) {
1067
+ deleteProperty(_2, prop) {
1068
1068
  target ?? (target = getter());
1069
1069
  return Reflect.deleteProperty(target, prop);
1070
1070
  },
1071
- ownKeys(_) {
1071
+ ownKeys(_2) {
1072
1072
  target ?? (target = getter());
1073
1073
  return Reflect.ownKeys(target);
1074
1074
  },
1075
- getOwnPropertyDescriptor(_, prop) {
1075
+ getOwnPropertyDescriptor(_2, prop) {
1076
1076
  target ?? (target = getter());
1077
1077
  return Reflect.getOwnPropertyDescriptor(target, prop);
1078
1078
  },
1079
- defineProperty(_, prop, descriptor) {
1079
+ defineProperty(_2, prop, descriptor) {
1080
1080
  target ?? (target = getter());
1081
1081
  return Reflect.defineProperty(target, prop, descriptor);
1082
1082
  }
@@ -1090,8 +1090,8 @@ function stringifyPrimitive(value) {
1090
1090
  return `${value}`;
1091
1091
  }
1092
1092
  function optionalKeys(shape) {
1093
- return Object.keys(shape).filter((k) => {
1094
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
1093
+ return Object.keys(shape).filter((k2) => {
1094
+ return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
1095
1095
  });
1096
1096
  }
1097
1097
  var NUMBER_FORMAT_RANGES = {
@@ -1191,20 +1191,20 @@ function safeExtend(schema, shape) {
1191
1191
  });
1192
1192
  return clone(schema, def);
1193
1193
  }
1194
- function merge(a, b) {
1194
+ function merge(a, b2) {
1195
1195
  if (a._zod.def.checks?.length) {
1196
1196
  throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
1197
1197
  }
1198
1198
  const def = mergeDefs(a._zod.def, {
1199
1199
  get shape() {
1200
- const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
1200
+ const _shape = { ...a._zod.def.shape, ...b2._zod.def.shape };
1201
1201
  assignProp(this, "shape", _shape);
1202
1202
  return _shape;
1203
1203
  },
1204
1204
  get catchall() {
1205
- return b._zod.def.catchall;
1205
+ return b2._zod.def.catchall;
1206
1206
  },
1207
- checks: b._zod.def.checks ?? []
1207
+ checks: b2._zod.def.checks ?? []
1208
1208
  });
1209
1209
  return clone(a, def);
1210
1210
  }
@@ -1277,21 +1277,21 @@ function required(Class2, schema, mask) {
1277
1277
  });
1278
1278
  return clone(schema, def);
1279
1279
  }
1280
- function aborted(x, startIndex = 0) {
1281
- if (x.aborted === true)
1280
+ function aborted(x2, startIndex = 0) {
1281
+ if (x2.aborted === true)
1282
1282
  return true;
1283
- for (let i = startIndex; i < x.issues.length; i++) {
1284
- if (x.issues[i]?.continue !== true) {
1283
+ for (let i = startIndex; i < x2.issues.length; i++) {
1284
+ if (x2.issues[i]?.continue !== true) {
1285
1285
  return true;
1286
1286
  }
1287
1287
  }
1288
1288
  return false;
1289
1289
  }
1290
- function explicitlyAborted(x, startIndex = 0) {
1291
- if (x.aborted === true)
1290
+ function explicitlyAborted(x2, startIndex = 0) {
1291
+ if (x2.aborted === true)
1292
1292
  return true;
1293
- for (let i = startIndex; i < x.issues.length; i++) {
1294
- if (x.issues[i]?.continue === false) {
1293
+ for (let i = startIndex; i < x2.issues.length; i++) {
1294
+ if (x2.issues[i]?.continue === false) {
1295
1295
  return true;
1296
1296
  }
1297
1297
  }
@@ -1368,8 +1368,8 @@ function issue(...args) {
1368
1368
  return { ...iss };
1369
1369
  }
1370
1370
  function cleanEnum(obj) {
1371
- return Object.entries(obj).filter(([k, _]) => {
1372
- return Number.isNaN(Number.parseInt(k, 10));
1371
+ return Object.entries(obj).filter(([k2, _2]) => {
1372
+ return Number.isNaN(Number.parseInt(k2, 10));
1373
1373
  }).map((el) => el[1]);
1374
1374
  }
1375
1375
  function base64ToUint8Array(base643) {
@@ -1407,7 +1407,7 @@ function hexToUint8Array(hex3) {
1407
1407
  return bytes;
1408
1408
  }
1409
1409
  function uint8ArrayToHex(bytes) {
1410
- return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
1410
+ return Array.from(bytes).map((b2) => b2.toString(16).padStart(2, "0")).join("");
1411
1411
  }
1412
1412
  var Class = class {
1413
1413
  constructor(..._args) {
@@ -1544,7 +1544,7 @@ function toDotPath(_path) {
1544
1544
  }
1545
1545
  function prettifyError(error51) {
1546
1546
  const lines = [];
1547
- const issues = [...error51.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
1547
+ const issues = [...error51.issues].sort((a, b2) => (a.path ?? []).length - (b2.path ?? []).length);
1548
1548
  for (const issue2 of issues) {
1549
1549
  lines.push(`\u2716 ${issue2.message}`);
1550
1550
  if (issue2.path?.length)
@@ -2368,9 +2368,9 @@ var Doc = class {
2368
2368
  return;
2369
2369
  }
2370
2370
  const content = arg;
2371
- const lines = content.split("\n").filter((x) => x);
2372
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
2373
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
2371
+ const lines = content.split("\n").filter((x2) => x2);
2372
+ const minIndent = Math.min(...lines.map((x2) => x2.length - x2.trimStart().length));
2373
+ const dedented = lines.map((x2) => x2.slice(minIndent)).map((x2) => " ".repeat(this.indent * 2) + x2);
2374
2374
  for (const line of dedented) {
2375
2375
  this.content.push(line);
2376
2376
  }
@@ -2379,7 +2379,7 @@ var Doc = class {
2379
2379
  const F = Function;
2380
2380
  const args = this?.args;
2381
2381
  const content = this?.content ?? [``];
2382
- const lines = [...content.map((x) => ` ${x}`)];
2382
+ const lines = [...content.map((x2) => ` ${x2}`)];
2383
2383
  return new F(...args, lines.join("\n"));
2384
2384
  }
2385
2385
  };
@@ -2427,13 +2427,13 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
2427
2427
  continue;
2428
2428
  }
2429
2429
  const currLen = payload.issues.length;
2430
- const _ = ch._zod.check(payload);
2431
- if (_ instanceof Promise && ctx?.async === false) {
2430
+ const _2 = ch._zod.check(payload);
2431
+ if (_2 instanceof Promise && ctx?.async === false) {
2432
2432
  throw new $ZodAsyncError();
2433
2433
  }
2434
- if (asyncResult || _ instanceof Promise) {
2434
+ if (asyncResult || _2 instanceof Promise) {
2435
2435
  asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
2436
- await _;
2436
+ await _2;
2437
2437
  const nextLen = payload.issues.length;
2438
2438
  if (nextLen === currLen)
2439
2439
  return;
@@ -2495,7 +2495,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
2495
2495
  try {
2496
2496
  const r = safeParse(inst, value);
2497
2497
  return r.success ? { value: r.data } : { issues: r.error?.issues };
2498
- } catch (_) {
2498
+ } catch (_2) {
2499
2499
  return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
2500
2500
  }
2501
2501
  },
@@ -2506,11 +2506,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
2506
2506
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
2507
2507
  $ZodType.init(inst, def);
2508
2508
  inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
2509
- inst._zod.parse = (payload, _) => {
2509
+ inst._zod.parse = (payload, _2) => {
2510
2510
  if (def.coerce)
2511
2511
  try {
2512
2512
  payload.value = String(payload.value);
2513
- } catch (_2) {
2513
+ } catch (_3) {
2514
2514
  }
2515
2515
  if (typeof payload.value === "string")
2516
2516
  return payload;
@@ -2543,10 +2543,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
2543
2543
  v7: 7,
2544
2544
  v8: 8
2545
2545
  };
2546
- const v = versionMap[def.version];
2547
- if (v === void 0)
2546
+ const v2 = versionMap[def.version];
2547
+ if (v2 === void 0)
2548
2548
  throw new Error(`Invalid UUID version: "${def.version}"`);
2549
- def.pattern ?? (def.pattern = uuid(v));
2549
+ def.pattern ?? (def.pattern = uuid(v2));
2550
2550
  } else
2551
2551
  def.pattern ?? (def.pattern = uuid());
2552
2552
  $ZodStringFormat.init(inst, def);
@@ -2608,7 +2608,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
2608
2608
  payload.value = trimmed;
2609
2609
  }
2610
2610
  return;
2611
- } catch (_) {
2611
+ } catch (_2) {
2612
2612
  payload.issues.push({
2613
2613
  code: "invalid_format",
2614
2614
  format: "url",
@@ -2835,7 +2835,7 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
2835
2835
  if (def.coerce)
2836
2836
  try {
2837
2837
  payload.value = Number(payload.value);
2838
- } catch (_) {
2838
+ } catch (_2) {
2839
2839
  }
2840
2840
  const input = payload.value;
2841
2841
  if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
@@ -2863,7 +2863,7 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
2863
2863
  if (def.coerce)
2864
2864
  try {
2865
2865
  payload.value = Boolean(payload.value);
2866
- } catch (_) {
2866
+ } catch (_2) {
2867
2867
  }
2868
2868
  const input = payload.value;
2869
2869
  if (typeof input === "boolean")
@@ -2884,7 +2884,7 @@ var $ZodBigInt = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) => {
2884
2884
  if (def.coerce)
2885
2885
  try {
2886
2886
  payload.value = BigInt(payload.value);
2887
- } catch (_) {
2887
+ } catch (_2) {
2888
2888
  }
2889
2889
  if (typeof payload.value === "bigint")
2890
2890
  return payload;
@@ -3077,9 +3077,9 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
3077
3077
  }
3078
3078
  function normalizeDef(def) {
3079
3079
  const keys = Object.keys(def.shape);
3080
- for (const k of keys) {
3081
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
3082
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
3080
+ for (const k2 of keys) {
3081
+ if (!def.shape?.[k2]?._zod?.traits?.has("$ZodType")) {
3082
+ throw new Error(`Invalid element at key "${k2}": expected a Zod schema`);
3083
3083
  }
3084
3084
  }
3085
3085
  const okeys = optionalKeys(def.shape);
@@ -3151,8 +3151,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3151
3151
  const field = shape[key]._zod;
3152
3152
  if (field.values) {
3153
3153
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
3154
- for (const v of field.values)
3155
- propValues[key].add(v);
3154
+ for (const v2 of field.values)
3155
+ propValues[key].add(v2);
3156
3156
  }
3157
3157
  }
3158
3158
  return propValues;
@@ -3200,8 +3200,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3200
3200
  const doc = new Doc(["shape", "payload", "ctx"]);
3201
3201
  const normalized = _normalized.value;
3202
3202
  const parseStr = (key) => {
3203
- const k = esc(key);
3204
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
3203
+ const k2 = esc(key);
3204
+ return `shape[${k2}]._zod.run({ value: input[${k2}], issues: [] }, ctx)`;
3205
3205
  };
3206
3206
  doc.write(`const input = payload.value;`);
3207
3207
  const ids = /* @__PURE__ */ Object.create(null);
@@ -3212,7 +3212,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3212
3212
  doc.write(`const newResult = {};`);
3213
3213
  for (const key of normalized.keys) {
3214
3214
  const id = ids[key];
3215
- const k = esc(key);
3215
+ const k2 = esc(key);
3216
3216
  const schema = shape[key];
3217
3217
  const isOptionalIn = schema?._zod?.optin === "optional";
3218
3218
  const isOptionalOut = schema?._zod?.optout === "optional";
@@ -3220,30 +3220,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3220
3220
  if (isOptionalIn && isOptionalOut) {
3221
3221
  doc.write(`
3222
3222
  if (${id}.issues.length) {
3223
- if (${k} in input) {
3223
+ if (${k2} in input) {
3224
3224
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3225
3225
  ...iss,
3226
- path: iss.path ? [${k}, ...iss.path] : [${k}]
3226
+ path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3227
3227
  })));
3228
3228
  }
3229
3229
  }
3230
3230
 
3231
3231
  if (${id}.value === undefined) {
3232
- if (${k} in input) {
3233
- newResult[${k}] = undefined;
3232
+ if (${k2} in input) {
3233
+ newResult[${k2}] = undefined;
3234
3234
  }
3235
3235
  } else {
3236
- newResult[${k}] = ${id}.value;
3236
+ newResult[${k2}] = ${id}.value;
3237
3237
  }
3238
3238
 
3239
3239
  `);
3240
3240
  } else if (!isOptionalIn) {
3241
3241
  doc.write(`
3242
- const ${id}_present = ${k} in input;
3242
+ const ${id}_present = ${k2} in input;
3243
3243
  if (${id}.issues.length) {
3244
3244
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3245
3245
  ...iss,
3246
- path: iss.path ? [${k}, ...iss.path] : [${k}]
3246
+ path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3247
3247
  })));
3248
3248
  }
3249
3249
  if (!${id}_present && !${id}.issues.length) {
@@ -3251,15 +3251,15 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3251
3251
  code: "invalid_type",
3252
3252
  expected: "nonoptional",
3253
3253
  input: undefined,
3254
- path: [${k}]
3254
+ path: [${k2}]
3255
3255
  });
3256
3256
  }
3257
3257
 
3258
3258
  if (${id}_present) {
3259
3259
  if (${id}.value === undefined) {
3260
- newResult[${k}] = undefined;
3260
+ newResult[${k2}] = undefined;
3261
3261
  } else {
3262
- newResult[${k}] = ${id}.value;
3262
+ newResult[${k2}] = ${id}.value;
3263
3263
  }
3264
3264
  }
3265
3265
 
@@ -3269,16 +3269,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3269
3269
  if (${id}.issues.length) {
3270
3270
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3271
3271
  ...iss,
3272
- path: iss.path ? [${k}, ...iss.path] : [${k}]
3272
+ path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3273
3273
  })));
3274
3274
  }
3275
3275
 
3276
3276
  if (${id}.value === undefined) {
3277
- if (${k} in input) {
3278
- newResult[${k}] = undefined;
3277
+ if (${k2} in input) {
3278
+ newResult[${k2}] = undefined;
3279
3279
  }
3280
3280
  } else {
3281
- newResult[${k}] = ${id}.value;
3281
+ newResult[${k2}] = ${id}.value;
3282
3282
  }
3283
3283
 
3284
3284
  `);
@@ -3352,7 +3352,7 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
3352
3352
  defineLazy(inst._zod, "pattern", () => {
3353
3353
  if (def.options.every((o) => o._zod.pattern)) {
3354
3354
  const patterns = def.options.map((o) => o._zod.pattern);
3355
- return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
3355
+ return new RegExp(`^(${patterns.map((p2) => cleanRegex(p2.source)).join("|")})$`);
3356
3356
  }
3357
3357
  return void 0;
3358
3358
  });
@@ -3447,11 +3447,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3447
3447
  const pv = option._zod.propValues;
3448
3448
  if (!pv || Object.keys(pv).length === 0)
3449
3449
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
3450
- for (const [k, v] of Object.entries(pv)) {
3451
- if (!propValues[k])
3452
- propValues[k] = /* @__PURE__ */ new Set();
3453
- for (const val of v) {
3454
- propValues[k].add(val);
3450
+ for (const [k2, v2] of Object.entries(pv)) {
3451
+ if (!propValues[k2])
3452
+ propValues[k2] = /* @__PURE__ */ new Set();
3453
+ for (const val of v2) {
3454
+ propValues[k2].add(val);
3455
3455
  }
3456
3456
  }
3457
3457
  }
@@ -3464,11 +3464,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3464
3464
  const values = o._zod.propValues?.[def.discriminator];
3465
3465
  if (!values || values.size === 0)
3466
3466
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
3467
- for (const v of values) {
3468
- if (map2.has(v)) {
3469
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
3467
+ for (const v2 of values) {
3468
+ if (map2.has(v2)) {
3469
+ throw new Error(`Duplicate discriminator value "${String(v2)}"`);
3470
3470
  }
3471
- map2.set(v, o);
3471
+ map2.set(v2, o);
3472
3472
  }
3473
3473
  }
3474
3474
  return map2;
@@ -3519,19 +3519,19 @@ var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, d
3519
3519
  return handleIntersectionResults(payload, left, right);
3520
3520
  };
3521
3521
  });
3522
- function mergeValues(a, b) {
3523
- if (a === b) {
3522
+ function mergeValues(a, b2) {
3523
+ if (a === b2) {
3524
3524
  return { valid: true, data: a };
3525
3525
  }
3526
- if (a instanceof Date && b instanceof Date && +a === +b) {
3526
+ if (a instanceof Date && b2 instanceof Date && +a === +b2) {
3527
3527
  return { valid: true, data: a };
3528
3528
  }
3529
- if (isPlainObject(a) && isPlainObject(b)) {
3530
- const bKeys = Object.keys(b);
3529
+ if (isPlainObject(a) && isPlainObject(b2)) {
3530
+ const bKeys = Object.keys(b2);
3531
3531
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
3532
- const newObj = { ...a, ...b };
3532
+ const newObj = { ...a, ...b2 };
3533
3533
  for (const key of sharedKeys) {
3534
- const sharedValue = mergeValues(a[key], b[key]);
3534
+ const sharedValue = mergeValues(a[key], b2[key]);
3535
3535
  if (!sharedValue.valid) {
3536
3536
  return {
3537
3537
  valid: false,
@@ -3542,14 +3542,14 @@ function mergeValues(a, b) {
3542
3542
  }
3543
3543
  return { valid: true, data: newObj };
3544
3544
  }
3545
- if (Array.isArray(a) && Array.isArray(b)) {
3546
- if (a.length !== b.length) {
3545
+ if (Array.isArray(a) && Array.isArray(b2)) {
3546
+ if (a.length !== b2.length) {
3547
3547
  return { valid: false, mergeErrorPath: [] };
3548
3548
  }
3549
3549
  const newArray = [];
3550
3550
  for (let index = 0; index < a.length; index++) {
3551
3551
  const itemA = a[index];
3552
- const itemB = b[index];
3552
+ const itemB = b2[index];
3553
3553
  const sharedValue = mergeValues(itemA, itemB);
3554
3554
  if (!sharedValue.valid) {
3555
3555
  return {
@@ -3569,10 +3569,10 @@ function handleIntersectionResults(result, left, right) {
3569
3569
  for (const iss of left.issues) {
3570
3570
  if (iss.code === "unrecognized_keys") {
3571
3571
  unrecIssue ?? (unrecIssue = iss);
3572
- for (const k of iss.keys) {
3573
- if (!unrecKeys.has(k))
3574
- unrecKeys.set(k, {});
3575
- unrecKeys.get(k).l = true;
3572
+ for (const k2 of iss.keys) {
3573
+ if (!unrecKeys.has(k2))
3574
+ unrecKeys.set(k2, {});
3575
+ unrecKeys.get(k2).l = true;
3576
3576
  }
3577
3577
  } else {
3578
3578
  result.issues.push(iss);
@@ -3580,16 +3580,16 @@ function handleIntersectionResults(result, left, right) {
3580
3580
  }
3581
3581
  for (const iss of right.issues) {
3582
3582
  if (iss.code === "unrecognized_keys") {
3583
- for (const k of iss.keys) {
3584
- if (!unrecKeys.has(k))
3585
- unrecKeys.set(k, {});
3586
- unrecKeys.get(k).r = true;
3583
+ for (const k2 of iss.keys) {
3584
+ if (!unrecKeys.has(k2))
3585
+ unrecKeys.set(k2, {});
3586
+ unrecKeys.get(k2).r = true;
3587
3587
  }
3588
3588
  } else {
3589
3589
  result.issues.push(iss);
3590
3590
  }
3591
3591
  }
3592
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
3592
+ const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([k2]) => k2);
3593
3593
  if (bothKeys.length && unrecIssue) {
3594
3594
  result.issues.push({ ...unrecIssue, keys: bothKeys });
3595
3595
  }
@@ -3933,7 +3933,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
3933
3933
  const values = getEnumValues(def.entries);
3934
3934
  const valuesSet = new Set(values);
3935
3935
  inst._zod.values = valuesSet;
3936
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
3936
+ inst._zod.pattern = new RegExp(`^(${values.filter((k2) => propertyKeyTypes.has(typeof k2)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
3937
3937
  inst._zod.parse = (payload, _ctx) => {
3938
3938
  const input = payload.value;
3939
3939
  if (valuesSet.has(input)) {
@@ -4107,8 +4107,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
4107
4107
  var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
4108
4108
  $ZodType.init(inst, def);
4109
4109
  defineLazy(inst._zod, "values", () => {
4110
- const v = def.innerType._zod.values;
4111
- return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
4110
+ const v2 = def.innerType._zod.values;
4111
+ return v2 ? new Set([...v2].filter((x2) => x2 !== void 0)) : void 0;
4112
4112
  });
4113
4113
  inst._zod.parse = (payload, ctx) => {
4114
4114
  const result = def.innerType._zod.run(payload, ctx);
@@ -4453,7 +4453,7 @@ var $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
4453
4453
  var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
4454
4454
  $ZodCheck.init(inst, def);
4455
4455
  $ZodType.init(inst, def);
4456
- inst._zod.parse = (payload, _) => {
4456
+ inst._zod.parse = (payload, _2) => {
4457
4457
  return payload;
4458
4458
  };
4459
4459
  inst._zod.check = (payload) => {
@@ -6505,7 +6505,7 @@ var error17 = () => {
6505
6505
  if (issue2.values.length === 1) {
6506
6506
  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])}`;
6507
6507
  }
6508
- const stringified = issue2.values.map((v) => stringifyPrimitive(v));
6508
+ const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
6509
6509
  if (issue2.values.length === 2) {
6510
6510
  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]}`;
6511
6511
  }
@@ -10470,12 +10470,12 @@ var $ZodRegistry = class {
10470
10470
  return this;
10471
10471
  }
10472
10472
  get(schema) {
10473
- const p = schema._zod.parent;
10474
- if (p) {
10475
- const pm = { ...this.get(p) ?? {} };
10473
+ const p2 = schema._zod.parent;
10474
+ if (p2) {
10475
+ const pm = { ...this.get(p2) ?? {} };
10476
10476
  delete pm.id;
10477
- const f = { ...pm, ...this._map.get(schema) };
10478
- return Object.keys(f).length ? f : void 0;
10477
+ const f2 = { ...pm, ...this._map.get(schema) };
10478
+ return Object.keys(f2).length ? f2 : void 0;
10479
10479
  }
10480
10480
  return this._map.get(schema);
10481
10481
  }
@@ -11260,7 +11260,7 @@ function _set(Class2, valueType, params) {
11260
11260
  }
11261
11261
  // @__NO_SIDE_EFFECTS__
11262
11262
  function _enum(Class2, values, params) {
11263
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
11263
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
11264
11264
  return new Class2({
11265
11265
  type: "enum",
11266
11266
  entries,
@@ -11465,8 +11465,8 @@ function _stringbool(Classes, _params) {
11465
11465
  let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
11466
11466
  let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
11467
11467
  if (params.case !== "sensitive") {
11468
- truthyArray = truthyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
11469
- falsyArray = falsyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
11468
+ truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
11469
+ falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
11470
11470
  }
11471
11471
  const truthySet = new Set(truthyArray);
11472
11472
  const falsySet = new Set(falsyArray);
@@ -12008,9 +12008,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
12008
12008
  var enumProcessor = (schema, _ctx, json2, _params) => {
12009
12009
  const def = schema._zod.def;
12010
12010
  const values = getEnumValues(def.entries);
12011
- if (values.every((v) => typeof v === "number"))
12011
+ if (values.every((v2) => typeof v2 === "number"))
12012
12012
  json2.type = "number";
12013
- if (values.every((v) => typeof v === "string"))
12013
+ if (values.every((v2) => typeof v2 === "string"))
12014
12014
  json2.type = "string";
12015
12015
  json2.enum = values;
12016
12016
  };
@@ -12043,13 +12043,13 @@ var literalProcessor = (schema, ctx, json2, _params) => {
12043
12043
  json2.const = val;
12044
12044
  }
12045
12045
  } else {
12046
- if (vals.every((v) => typeof v === "number"))
12046
+ if (vals.every((v2) => typeof v2 === "number"))
12047
12047
  json2.type = "number";
12048
- if (vals.every((v) => typeof v === "string"))
12048
+ if (vals.every((v2) => typeof v2 === "string"))
12049
12049
  json2.type = "string";
12050
- if (vals.every((v) => typeof v === "boolean"))
12050
+ if (vals.every((v2) => typeof v2 === "boolean"))
12051
12051
  json2.type = "boolean";
12052
- if (vals.every((v) => v === null))
12052
+ if (vals.every((v2) => v2 === null))
12053
12053
  json2.type = "null";
12054
12054
  json2.enum = vals;
12055
12055
  }
@@ -12085,7 +12085,7 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
12085
12085
  Object.assign(_json, file2);
12086
12086
  } else {
12087
12087
  Object.assign(_json, file2);
12088
- _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
12088
+ _json.anyOf = mime.map((m2) => ({ contentMediaType: m2 }));
12089
12089
  }
12090
12090
  } else {
12091
12091
  Object.assign(_json, file2);
@@ -12147,11 +12147,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
12147
12147
  }
12148
12148
  const allKeys = new Set(Object.keys(shape));
12149
12149
  const requiredKeys = new Set([...allKeys].filter((key) => {
12150
- const v = def.shape[key]._zod;
12150
+ const v2 = def.shape[key]._zod;
12151
12151
  if (ctx.io === "input") {
12152
- return v.optin === void 0;
12152
+ return v2.optin === void 0;
12153
12153
  } else {
12154
- return v.optout === void 0;
12154
+ return v2.optout === void 0;
12155
12155
  }
12156
12156
  }));
12157
12157
  if (requiredKeys.size > 0) {
@@ -12172,7 +12172,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
12172
12172
  var unionProcessor = (schema, ctx, json2, params) => {
12173
12173
  const def = schema._zod.def;
12174
12174
  const isExclusive = def.inclusive === false;
12175
- const options = def.options.map((x, i) => process2(x, ctx, {
12175
+ const options = def.options.map((x2, i) => process2(x2, ctx, {
12176
12176
  ...params,
12177
12177
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
12178
12178
  }));
@@ -12188,14 +12188,14 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
12188
12188
  ...params,
12189
12189
  path: [...params.path, "allOf", 0]
12190
12190
  });
12191
- const b = process2(def.right, ctx, {
12191
+ const b2 = process2(def.right, ctx, {
12192
12192
  ...params,
12193
12193
  path: [...params.path, "allOf", 1]
12194
12194
  });
12195
12195
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
12196
12196
  const allOf = [
12197
12197
  ...isSimpleIntersection(a) ? a.allOf : [a],
12198
- ...isSimpleIntersection(b) ? b.allOf : [b]
12198
+ ...isSimpleIntersection(b2) ? b2.allOf : [b2]
12199
12199
  ];
12200
12200
  json2.allOf = allOf;
12201
12201
  };
@@ -12205,7 +12205,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
12205
12205
  json2.type = "array";
12206
12206
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
12207
12207
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
12208
- const prefixItems = def.items.map((x, i) => process2(x, ctx, {
12208
+ const prefixItems = def.items.map((x2, i) => process2(x2, ctx, {
12209
12209
  ...params,
12210
12210
  path: [...params.path, prefixPath, i]
12211
12211
  }));
@@ -12271,7 +12271,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
12271
12271
  }
12272
12272
  const keyValues = keyType._zod.values;
12273
12273
  if (keyValues) {
12274
- const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
12274
+ const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
12275
12275
  if (validKeyValues.length > 0) {
12276
12276
  json2.required = validKeyValues;
12277
12277
  }
@@ -12402,7 +12402,7 @@ function toJSONSchema(input, params) {
12402
12402
  const ctx2 = initializeContext({ ...params, processors: allProcessors });
12403
12403
  const defs = {};
12404
12404
  for (const entry of registry2._idmap.entries()) {
12405
- const [_, schema] = entry;
12405
+ const [_2, schema] = entry;
12406
12406
  process2(schema, ctx2);
12407
12407
  }
12408
12408
  const schemas = {};
@@ -12501,7 +12501,7 @@ var JSONSchemaGenerator = class {
12501
12501
  }
12502
12502
  extractDefs(this.ctx, schema);
12503
12503
  const result = finalize(this.ctx, schema);
12504
- const { "~standard": _, ...plainResult } = result;
12504
+ const { "~standard": _2, ...plainResult } = result;
12505
12505
  return plainResult;
12506
12506
  }
12507
12507
  };
@@ -12836,12 +12836,12 @@ function _installLazyMethods(inst, group, methods) {
12836
12836
  });
12837
12837
  return bound;
12838
12838
  },
12839
- set(v) {
12839
+ set(v2) {
12840
12840
  Object.defineProperty(this, key, {
12841
12841
  configurable: true,
12842
12842
  writable: true,
12843
12843
  enumerable: true,
12844
- value: v
12844
+ value: v2
12845
12845
  });
12846
12846
  }
12847
12847
  });
@@ -13637,11 +13637,11 @@ function record(keyType, valueType, params) {
13637
13637
  });
13638
13638
  }
13639
13639
  function partialRecord(keyType, valueType, params) {
13640
- const k = clone(keyType);
13641
- k._zod.values = void 0;
13640
+ const k2 = clone(keyType);
13641
+ k2._zod.values = void 0;
13642
13642
  return new ZodRecord({
13643
13643
  type: "record",
13644
- keyType: k,
13644
+ keyType: k2,
13645
13645
  valueType,
13646
13646
  ...util_exports.normalizeParams(params)
13647
13647
  });
@@ -13729,7 +13729,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
13729
13729
  };
13730
13730
  });
13731
13731
  function _enum2(values, params) {
13732
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
13732
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
13733
13733
  return new ZodEnum({
13734
13734
  type: "enum",
13735
13735
  entries,
@@ -14283,10 +14283,10 @@ function convertBaseSchema(schema, ctx) {
14283
14283
  if (enumValues.length === 1) {
14284
14284
  return z.literal(enumValues[0]);
14285
14285
  }
14286
- if (enumValues.every((v) => typeof v === "string")) {
14286
+ if (enumValues.every((v2) => typeof v2 === "string")) {
14287
14287
  return z.enum(enumValues);
14288
14288
  }
14289
- const literalSchemas = enumValues.map((v) => z.literal(v));
14289
+ const literalSchemas = enumValues.map((v2) => z.literal(v2));
14290
14290
  if (literalSchemas.length < 2) {
14291
14291
  return literalSchemas[0];
14292
14292
  }
@@ -14526,12 +14526,12 @@ function convertSchema(schema, ctx) {
14526
14526
  let baseSchema = convertBaseSchema(schema, ctx);
14527
14527
  const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
14528
14528
  if (schema.anyOf && Array.isArray(schema.anyOf)) {
14529
- const options = schema.anyOf.map((s) => convertSchema(s, ctx));
14529
+ const options = schema.anyOf.map((s2) => convertSchema(s2, ctx));
14530
14530
  const anyOfUnion = z.union(options);
14531
14531
  baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
14532
14532
  }
14533
14533
  if (schema.oneOf && Array.isArray(schema.oneOf)) {
14534
- const options = schema.oneOf.map((s) => convertSchema(s, ctx));
14534
+ const options = schema.oneOf.map((s2) => convertSchema(s2, ctx));
14535
14535
  const oneOfUnion = z.xor(options);
14536
14536
  baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
14537
14537
  }
@@ -14652,6 +14652,52 @@ function normalizeImageGenerationUrl(value) {
14652
14652
  return url2.toString().replace(/\/+$/, "");
14653
14653
  }
14654
14654
 
14655
+ // shared/bot-avatar.ts
14656
+ var BOT_AVATAR_CROPS = ["mascot", "circle", "rounded", "square"];
14657
+ var botAvatarCropSchema = external_exports.enum(BOT_AVATAR_CROPS);
14658
+ var botAvatarUrlSchema = external_exports.string().regex(
14659
+ /^\/api\/attachments\/[A-Za-z0-9-]+\.(?:png|jpg|gif|webp)$/,
14660
+ "must be a stored PNG, JPEG, GIF, or WebP attachment"
14661
+ );
14662
+
14663
+ // shared/bot-profile.ts
14664
+ var BOT_PROFILE_LIMITS = {
14665
+ name: 100,
14666
+ title: 200,
14667
+ description: 4e3,
14668
+ voice: 200,
14669
+ soul: 24e3
14670
+ };
14671
+ function fitsOnOneLine(value) {
14672
+ for (let i = 0; i < value.length; i += 1) {
14673
+ const code = value.charCodeAt(i);
14674
+ if (code < 32 || code >= 127 && code <= 159 || code === 8232 || code === 8233) return false;
14675
+ }
14676
+ return true;
14677
+ }
14678
+
14679
+ // shared/mascot-bodies.ts
14680
+ var MASCOT_BODY_IDS = ["cursor", "blob", "circle", "squircle", "capsule", "drop", "shield", "hexagon", "diamond", "star"];
14681
+ var mascotBodySchema = external_exports.enum(MASCOT_BODY_IDS);
14682
+
14683
+ // server/bot-profile.ts
14684
+ var profilePatchSchema = external_exports.object({
14685
+ 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(),
14686
+ 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(),
14687
+ description: external_exports.string({ error: "description must be a string" }).max(BOT_PROFILE_LIMITS.description, { error: "description must be at most 4000 characters" }).optional(),
14688
+ soul: external_exports.string({ error: "soul must be a string" }).refine((value) => Buffer.byteLength(value, "utf8") <= BOT_PROFILE_LIMITS.soul, {
14689
+ error: "standing instructions must be at most 24000 bytes"
14690
+ }).optional(),
14691
+ notifications: external_exports.boolean({ error: "notifications must be true or false" }).optional(),
14692
+ avatarUrl: external_exports.union([botAvatarUrlSchema, external_exports.literal(""), external_exports.null()], {
14693
+ error: "avatarUrl must be a stored PNG, JPEG, GIF, or WebP attachment"
14694
+ }).optional(),
14695
+ avatarCrop: botAvatarCropSchema.optional(),
14696
+ mascotBody: mascotBodySchema.optional(),
14697
+ voice: external_exports.string({ error: "voice must be a string" }).max(BOT_PROFILE_LIMITS.voice, { error: "voice must be at most 200 characters" }).optional(),
14698
+ speakReplies: external_exports.boolean({ error: "speakReplies must be true or false" }).optional()
14699
+ });
14700
+
14655
14701
  // shared/wire.ts
14656
14702
  var EFFORT_LEVELS = ["none", "low", "medium", "high", "xhigh", "max"];
14657
14703
 
@@ -14660,6 +14706,815 @@ function isModelVariant(value) {
14660
14706
  return typeof value === "string" && value.length > 0 && value.length <= 256 && value.trim() === value && !new RegExp("\\p{Cc}", "u").test(value);
14661
14707
  }
14662
14708
 
14709
+ // node_modules/.pnpm/croner@10.0.1/node_modules/croner/dist/croner.js
14710
+ function T(s2) {
14711
+ return Date.UTC(s2.y, s2.m - 1, s2.d, s2.h, s2.i, s2.s);
14712
+ }
14713
+ function D(s2, e) {
14714
+ 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;
14715
+ }
14716
+ function A(s2, e) {
14717
+ let t = new Date(Date.parse(s2));
14718
+ if (isNaN(t)) throw new Error("Invalid ISO8601 passed to timezone parser.");
14719
+ let r = s2.substring(9);
14720
+ 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);
14721
+ }
14722
+ function v(s2, e, t) {
14723
+ return k(A(s2, e), t);
14724
+ }
14725
+ function k(s2, e) {
14726
+ 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);
14727
+ if (D(h, s2)) {
14728
+ let u = new Date(o.getTime() - 36e5), d = g(u, s2.tz);
14729
+ return D(d, s2) ? u : o;
14730
+ }
14731
+ let l = new Date(o.getTime() + T(s2) - T(h)), y = g(l, s2.tz);
14732
+ if (D(y, s2)) return l;
14733
+ if (e) throw new Error("Invalid date passed to fromTZ()");
14734
+ return o.getTime() > l.getTime() ? o : l;
14735
+ }
14736
+ function g(s2, e) {
14737
+ let t, r;
14738
+ try {
14739
+ 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);
14740
+ } catch (i) {
14741
+ let a = i instanceof Error ? i.message : String(i);
14742
+ 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}`);
14743
+ }
14744
+ let n = { year: 0, month: 0, day: 0, hour: 0, minute: 0, second: 0 };
14745
+ 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));
14746
+ 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)}`);
14747
+ 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 };
14748
+ }
14749
+ function b(s2, e, t, r, n, i, a) {
14750
+ return { y: s2, m: e, d: t, h: r, i: n, s: i, tz: a };
14751
+ }
14752
+ var O = [1, 2, 4, 8, 16];
14753
+ var C = class {
14754
+ pattern;
14755
+ timezone;
14756
+ mode;
14757
+ alternativeWeekdays;
14758
+ sloppyRanges;
14759
+ second;
14760
+ minute;
14761
+ hour;
14762
+ day;
14763
+ month;
14764
+ dayOfWeek;
14765
+ year;
14766
+ lastDayOfMonth;
14767
+ lastWeekday;
14768
+ nearestWeekdays;
14769
+ starDOM;
14770
+ starDOW;
14771
+ starYear;
14772
+ useAndLogic;
14773
+ constructor(e, t, r) {
14774
+ 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();
14775
+ }
14776
+ parse() {
14777
+ if (!(typeof this.pattern == "string" || this.pattern instanceof String)) throw new TypeError("CronPattern: Pattern has to be of type string.");
14778
+ this.pattern.indexOf("@") >= 0 && (this.pattern = this.handleNicknames(this.pattern).trim());
14779
+ let e = this.pattern.match(/\S+/g) || [""], t = e.length;
14780
+ 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.");
14781
+ if (this.mode !== "auto") {
14782
+ let n;
14783
+ switch (this.mode) {
14784
+ case "5-part":
14785
+ n = 5;
14786
+ break;
14787
+ case "6-part":
14788
+ n = 6;
14789
+ break;
14790
+ case "7-part":
14791
+ n = 7;
14792
+ break;
14793
+ case "5-or-6-parts":
14794
+ n = [5, 6];
14795
+ break;
14796
+ case "6-or-7-parts":
14797
+ n = [6, 7];
14798
+ break;
14799
+ default:
14800
+ n = 0;
14801
+ }
14802
+ if (!(Array.isArray(n) ? n.includes(t) : t === n)) {
14803
+ let a = Array.isArray(n) ? n.join(" or ") : n.toString();
14804
+ throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${a} parts, but pattern '${this.pattern}' has ${t} parts.`);
14805
+ }
14806
+ }
14807
+ 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.");
14808
+ 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) {
14809
+ case "5-part":
14810
+ e[0] = "0", e[6] = "*";
14811
+ break;
14812
+ case "6-part":
14813
+ e[6] = "*";
14814
+ break;
14815
+ case "5-or-6-parts":
14816
+ e[6] = "*";
14817
+ break;
14818
+ case "6-or-7-parts":
14819
+ break;
14820
+ case "7-part":
14821
+ case "auto":
14822
+ break;
14823
+ }
14824
+ 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);
14825
+ let r = this.alternativeWeekdays ? -1 : 0;
14826
+ 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]);
14827
+ }
14828
+ partToArray(e, t, r, n) {
14829
+ let i = this[e], a = e === "day" && this.lastDayOfMonth, o = e === "day" && this.lastWeekday;
14830
+ if (t === "" && !a && !o) throw new TypeError("CronPattern: configuration entry " + e + " (" + t + ") is empty, check for trailing spaces.");
14831
+ if (t === "*") return i.fill(n);
14832
+ let h = t.split(",");
14833
+ if (h.length > 1) for (let l = 0; l < h.length; l++) this.partToArray(e, h[l], r, n);
14834
+ 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);
14835
+ }
14836
+ throwAtIllegalCharacters(e) {
14837
+ 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.");
14838
+ }
14839
+ handleNumber(e, t, r, n) {
14840
+ let i = this.extractNth(e, t), a = e.toUpperCase().includes("W");
14841
+ if (t !== "day" && a) throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");
14842
+ a && (t = "nearestWeekdays");
14843
+ let o = parseInt(i[0], 10) + r;
14844
+ if (isNaN(o)) throw new TypeError("CronPattern: " + t + " is not a number: '" + e + "'");
14845
+ this.setPart(t, o, i[1] || n);
14846
+ }
14847
+ setPart(e, t, r) {
14848
+ if (!Object.prototype.hasOwnProperty.call(this, e)) throw new TypeError("CronPattern: Invalid part specified: " + e);
14849
+ if (e === "dayOfWeek") {
14850
+ if (t === 7 && (t = 0), t < 0 || t > 6) throw new RangeError("CronPattern: Invalid value for dayOfWeek: " + t);
14851
+ this.setNthWeekdayOfMonth(t, r);
14852
+ return;
14853
+ }
14854
+ if (e === "second" || e === "minute") {
14855
+ if (t < 0 || t >= 60) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
14856
+ } else if (e === "hour") {
14857
+ if (t < 0 || t >= 24) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
14858
+ } else if (e === "day" || e === "nearestWeekdays") {
14859
+ if (t < 0 || t >= 31) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
14860
+ } else if (e === "month") {
14861
+ if (t < 0 || t >= 12) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
14862
+ } else if (e === "year" && (t < 1 || t >= 1e4)) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t + " (supported range: 1-9999)");
14863
+ this[e][t] = r;
14864
+ }
14865
+ validateNotNaN(e, t) {
14866
+ if (isNaN(e)) throw new TypeError(t);
14867
+ }
14868
+ validateRange(e, t, r, n, i) {
14869
+ if (e > t) throw new TypeError("CronPattern: From value is larger than to value: '" + i + "'");
14870
+ if (r !== void 0) {
14871
+ if (r === 0) throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");
14872
+ if (r > this[n].length) throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part (" + this[n].length + ")");
14873
+ }
14874
+ }
14875
+ handleRangeWithStepping(e, t, r, n) {
14876
+ if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");
14877
+ let i = this.extractNth(e, t), a = i[0].match(/^(\d+)-(\d+)\/(\d+)$/);
14878
+ if (a === null) throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '" + e + "'");
14879
+ let [, o, h, l] = a, y = parseInt(o, 10) + r, u = parseInt(h, 10) + r, d = parseInt(l, 10);
14880
+ 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);
14881
+ for (let c = y; c <= u; c += d) this.setPart(t, c, i[1] || n);
14882
+ }
14883
+ extractNth(e, t) {
14884
+ let r = e, n;
14885
+ if (r.includes("#")) {
14886
+ if (t !== "dayOfWeek") throw new Error("CronPattern: nth (#) only allowed in day-of-week field");
14887
+ n = r.split("#")[1], r = r.split("#")[0];
14888
+ } else if (r.toUpperCase().endsWith("L")) {
14889
+ if (t !== "dayOfWeek") throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");
14890
+ n = "L", r = r.slice(0, -1);
14891
+ }
14892
+ return [r, n];
14893
+ }
14894
+ handleRange(e, t, r, n) {
14895
+ if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");
14896
+ let i = this.extractNth(e, t), a = i[0].split("-");
14897
+ if (a.length !== 2) throw new TypeError("CronPattern: Syntax error, illegal range: '" + e + "'");
14898
+ let o = parseInt(a[0], 10) + r, h = parseInt(a[1], 10) + r;
14899
+ 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);
14900
+ for (let l = o; l <= h; l++) this.setPart(t, l, i[1] || n);
14901
+ }
14902
+ handleStepping(e, t, r, n) {
14903
+ if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");
14904
+ let i = this.extractNth(e, t), a = i[0].split("/");
14905
+ if (a.length !== 2) throw new TypeError("CronPattern: Syntax error, illegal stepping: '" + e + "'");
14906
+ if (this.sloppyRanges) a[0] === "" && (a[0] = "*");
14907
+ else {
14908
+ 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.");
14909
+ 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.");
14910
+ }
14911
+ let o = 0;
14912
+ a[0] !== "*" && (o = parseInt(a[0], 10) + r);
14913
+ let h = parseInt(a[1], 10);
14914
+ this.validateNotNaN(h, "CronPattern: Syntax error, illegal stepping: (NaN)"), this.validateRange(0, this[t].length - 1, h, t, e);
14915
+ for (let l = o; l < this[t].length; l += h) this.setPart(t, l, i[1] || n);
14916
+ }
14917
+ replaceAlphaDays(e) {
14918
+ 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");
14919
+ }
14920
+ replaceAlphaDaysQuartz(e) {
14921
+ 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");
14922
+ }
14923
+ replaceAlphaMonths(e) {
14924
+ 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");
14925
+ }
14926
+ handleNicknames(e) {
14927
+ let t = e.trim().toLowerCase();
14928
+ if (t === "@yearly" || t === "@annually") return "0 0 1 1 *";
14929
+ if (t === "@monthly") return "0 0 1 * *";
14930
+ if (t === "@weekly") return "0 0 * * 0";
14931
+ if (t === "@daily" || t === "@midnight") return "0 0 * * *";
14932
+ if (t === "@hourly") return "0 * * * *";
14933
+ 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.");
14934
+ return e;
14935
+ }
14936
+ setNthWeekdayOfMonth(e, t) {
14937
+ if (typeof t != "number" && t.toUpperCase() === "L") this.dayOfWeek[e] = this.dayOfWeek[e] | 32;
14938
+ else if (t === 63) this.dayOfWeek[e] = 63;
14939
+ else if (t < 6 && t > 0) this.dayOfWeek[e] = this.dayOfWeek[e] | O[t - 1];
14940
+ else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`);
14941
+ }
14942
+ };
14943
+ var P = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
14944
+ var f = [["month", "year", 0], ["day", "month", -1], ["hour", "day", 0], ["minute", "hour", 0], ["second", "minute", 0]];
14945
+ var m = class s {
14946
+ tz;
14947
+ ms;
14948
+ second;
14949
+ minute;
14950
+ hour;
14951
+ day;
14952
+ month;
14953
+ year;
14954
+ constructor(e, t) {
14955
+ if (this.tz = t, e && e instanceof Date) if (!isNaN(e)) this.fromDate(e);
14956
+ else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");
14957
+ else if (e == null) this.fromDate(/* @__PURE__ */ new Date());
14958
+ else if (e && typeof e == "string") this.fromString(e);
14959
+ else if (e instanceof s) this.fromCronDate(e);
14960
+ else throw new TypeError("CronDate: Invalid type (" + typeof e + ") passed to CronDate constructor");
14961
+ }
14962
+ getLastDayOfMonth(e, t) {
14963
+ return t !== 1 ? P[t] : new Date(Date.UTC(e, t + 1, 0)).getUTCDate();
14964
+ }
14965
+ getLastWeekday(e, t) {
14966
+ let r = this.getLastDayOfMonth(e, t), i = new Date(Date.UTC(e, t, r)).getUTCDay();
14967
+ return i === 0 ? r - 2 : i === 6 ? r - 1 : r;
14968
+ }
14969
+ getNearestWeekday(e, t, r) {
14970
+ let n = this.getLastDayOfMonth(e, t);
14971
+ if (r > n) return -1;
14972
+ let a = new Date(Date.UTC(e, t, r)).getUTCDay();
14973
+ return a === 0 ? r === n ? r - 2 : r + 1 : a === 6 ? r === 1 ? r + 2 : r - 1 : r;
14974
+ }
14975
+ isNthWeekdayOfMonth(e, t, r, n) {
14976
+ let a = new Date(Date.UTC(e, t, r)).getUTCDay(), o = 0;
14977
+ for (let h = 1; h <= r; h++) new Date(Date.UTC(e, t, h)).getUTCDay() === a && o++;
14978
+ if (n & 63 && O[o - 1] & n) return true;
14979
+ if (n & 32) {
14980
+ let h = this.getLastDayOfMonth(e, t);
14981
+ for (let l = r + 1; l <= h; l++) if (new Date(Date.UTC(e, t, l)).getUTCDay() === a) return false;
14982
+ return true;
14983
+ }
14984
+ return false;
14985
+ }
14986
+ fromDate(e) {
14987
+ 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();
14988
+ else try {
14989
+ let t = g(e, this.tz);
14990
+ 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;
14991
+ } catch (t) {
14992
+ let r = t instanceof Error ? t.message : String(t);
14993
+ throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`);
14994
+ }
14995
+ 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();
14996
+ }
14997
+ fromCronDate(e) {
14998
+ 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;
14999
+ }
15000
+ apply() {
15001
+ 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) {
15002
+ let e = new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms));
15003
+ 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;
15004
+ } else return false;
15005
+ }
15006
+ fromString(e) {
15007
+ if (typeof this.tz == "number") {
15008
+ let t = v(e);
15009
+ 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();
15010
+ } else return this.fromDate(v(e, this.tz));
15011
+ }
15012
+ findNext(e, t, r, n) {
15013
+ return this._findMatch(e, t, r, n, 1);
15014
+ }
15015
+ _findMatch(e, t, r, n, i) {
15016
+ let a = this[t], o;
15017
+ r.lastDayOfMonth && (o = this.getLastDayOfMonth(this.year, this.month));
15018
+ 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;
15019
+ for (let u = l; y(u); u += i) {
15020
+ let d = r[t][u];
15021
+ if (t === "day" && !d) {
15022
+ for (let c = 0; c < r.nearestWeekdays.length; c++) if (r.nearestWeekdays[c]) {
15023
+ let M = this.getNearestWeekday(this.year, this.month, c - n);
15024
+ if (M === -1) continue;
15025
+ if (M === u - n) {
15026
+ d = 1;
15027
+ break;
15028
+ }
15029
+ }
15030
+ }
15031
+ if (t === "day" && r.lastWeekday) {
15032
+ let c = this.getLastWeekday(this.year, this.month);
15033
+ u - n === c && (d = 1);
15034
+ }
15035
+ if (t === "day" && r.lastDayOfMonth && u - n == o && (d = 1), t === "day" && !r.starDOW) {
15036
+ let c = r.dayOfWeek[(h + (u - n - 1)) % 7];
15037
+ if (c && c & 63) c = this.isNthWeekdayOfMonth(this.year, this.month, u - n, c) ? 1 : 0;
15038
+ else if (c) throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${c}`);
15039
+ r.useAndLogic ? d = d && c : !e.domAndDow && !r.starDOM ? d = d || c : d = d && c;
15040
+ }
15041
+ if (d) return this[t] = u - n, a !== this[t] ? 2 : 1;
15042
+ }
15043
+ return 3;
15044
+ }
15045
+ recurse(e, t, r) {
15046
+ if (r === 0 && !e.starYear) {
15047
+ if (this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0) {
15048
+ let i = -1;
15049
+ for (let a = this.year + 1; a < e.year.length && a < 1e4; a++) if (e.year[a] === 1) {
15050
+ i = a;
15051
+ break;
15052
+ }
15053
+ if (i === -1) return null;
15054
+ this.year = i, this.month = 0, this.day = 1, this.hour = 0, this.minute = 0, this.second = 0, this.ms = 0;
15055
+ }
15056
+ if (this.year >= 1e4) return null;
15057
+ }
15058
+ let n = this.findNext(t, f[r][0], e, f[r][2]);
15059
+ if (n > 1) {
15060
+ let i = r + 1;
15061
+ for (; i < f.length; ) this[f[i][0]] = -f[i][2], i++;
15062
+ if (n === 3) {
15063
+ if (this[f[r][1]]++, this[f[r][0]] = -f[r][2], this.apply(), r === 0 && !e.starYear) {
15064
+ for (; this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0 && this.year < 1e4; ) this.year++;
15065
+ if (this.year >= 1e4 || this.year >= e.year.length) return null;
15066
+ }
15067
+ return this.recurse(e, t, 0);
15068
+ } else if (this.apply()) return this.recurse(e, t, r - 1);
15069
+ }
15070
+ return r += 1, r >= f.length ? this : (e.starYear ? this.year >= 3e3 : this.year >= 1e4) ? null : this.recurse(e, t, r);
15071
+ }
15072
+ increment(e, t, r) {
15073
+ return this.second += t.interval !== void 0 && t.interval > 1 && r ? t.interval : 1, this.ms = 0, this.apply(), this.recurse(e, t, 0);
15074
+ }
15075
+ decrement(e, t) {
15076
+ return this.second -= t.interval !== void 0 && t.interval > 1 ? t.interval : 1, this.ms = 0, this.apply(), this.recurseBackward(e, t, 0, 0);
15077
+ }
15078
+ recurseBackward(e, t, r, n = 0) {
15079
+ if (n > 1e4) return null;
15080
+ if (r === 0 && !e.starYear) {
15081
+ if (this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0) {
15082
+ let a = -1;
15083
+ for (let o = this.year - 1; o >= 0; o--) if (e.year[o] === 1) {
15084
+ a = o;
15085
+ break;
15086
+ }
15087
+ if (a === -1) return null;
15088
+ this.year = a, this.month = 11, this.day = 31, this.hour = 23, this.minute = 59, this.second = 59, this.ms = 0;
15089
+ }
15090
+ if (this.year < 0) return null;
15091
+ }
15092
+ let i = this.findPrevious(t, f[r][0], e, f[r][2]);
15093
+ if (i > 1) {
15094
+ let a = r + 1;
15095
+ for (; a < f.length; ) {
15096
+ let o = f[a][0], h = f[a][2], l = this.getMaxPatternValue(o, e, h);
15097
+ this[o] = l, a++;
15098
+ }
15099
+ if (i === 3) {
15100
+ if (this[f[r][1]]--, r === 0) {
15101
+ let y = this.getLastDayOfMonth(this.year, this.month);
15102
+ this.day > y && (this.day = y);
15103
+ }
15104
+ if (r === 1) if (this.day <= 0) this.day = 1;
15105
+ else {
15106
+ let y = this.year, u = this.month;
15107
+ for (; u < 0; ) u += 12, y--;
15108
+ for (; u > 11; ) u -= 12, y++;
15109
+ let d = u !== 1 ? P[u] : new Date(Date.UTC(y, u + 1, 0)).getUTCDate();
15110
+ this.day > d && (this.day = d);
15111
+ }
15112
+ this.apply();
15113
+ let o = f[r][0], h = f[r][2], l = this.getMaxPatternValue(o, e, h);
15114
+ if (o === "day") {
15115
+ let y = this.getLastDayOfMonth(this.year, this.month);
15116
+ this[o] = Math.min(l, y);
15117
+ } else this[o] = l;
15118
+ if (this.apply(), r === 0) {
15119
+ let y = f[1][2], u = this.getMaxPatternValue("day", e, y), d = this.getLastDayOfMonth(this.year, this.month), c = Math.min(u, d);
15120
+ 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]));
15121
+ }
15122
+ if (r === 0 && !e.starYear) {
15123
+ for (; this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0; ) this.year--;
15124
+ if (this.year < 0) return null;
15125
+ }
15126
+ return this.recurseBackward(e, t, 0, n + 1);
15127
+ } else if (this.apply()) return this.recurseBackward(e, t, r - 1, n + 1);
15128
+ }
15129
+ return r += 1, r >= f.length ? this : this.year < 0 ? null : this.recurseBackward(e, t, r, n + 1);
15130
+ }
15131
+ getMaxPatternValue(e, t, r) {
15132
+ if (e === "day" && t.lastDayOfMonth) return this.getLastDayOfMonth(this.year, this.month);
15133
+ if (e === "day" && !t.starDOW) return this.getLastDayOfMonth(this.year, this.month);
15134
+ for (let n = t[e].length - 1; n >= 0; n--) if (t[e][n]) return n - r;
15135
+ return t[e].length - 1 - r;
15136
+ }
15137
+ findPrevious(e, t, r, n) {
15138
+ return this._findMatch(e, t, r, n, -1);
15139
+ }
15140
+ getDate(e) {
15141
+ 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);
15142
+ }
15143
+ getTime() {
15144
+ return this.getDate(false).getTime();
15145
+ }
15146
+ match(e, t) {
15147
+ if (!e.starYear && (this.year < 0 || this.year >= e.year.length || e.year[this.year] === 0)) return false;
15148
+ for (let r = 0; r < f.length; r++) {
15149
+ let n = f[r][0], i = f[r][2], a = this[n];
15150
+ if (a + i < 0 || a + i >= e[n].length) return false;
15151
+ let o = e[n][a + i];
15152
+ if (n === "day") {
15153
+ if (!o) {
15154
+ for (let h = 0; h < e.nearestWeekdays.length; h++) if (e.nearestWeekdays[h]) {
15155
+ let l = this.getNearestWeekday(this.year, this.month, h - i);
15156
+ if (l !== -1 && l === a) {
15157
+ o = 1;
15158
+ break;
15159
+ }
15160
+ }
15161
+ }
15162
+ if (e.lastWeekday) {
15163
+ let h = this.getLastWeekday(this.year, this.month);
15164
+ a === h && (o = 1);
15165
+ }
15166
+ if (e.lastDayOfMonth) {
15167
+ let h = this.getLastDayOfMonth(this.year, this.month);
15168
+ a === h && (o = 1);
15169
+ }
15170
+ if (!e.starDOW) {
15171
+ let h = new Date(Date.UTC(this.year, this.month, 1, 0, 0, 0, 0)).getUTCDay(), l = e.dayOfWeek[(h + (a - 1)) % 7];
15172
+ 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;
15173
+ }
15174
+ }
15175
+ if (!o) return false;
15176
+ }
15177
+ return true;
15178
+ }
15179
+ };
15180
+ function R(s2) {
15181
+ 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'.");
15182
+ if (s2.startAt && (s2.startAt = new m(s2.startAt, s2.timezone)), s2.stopAt && (s2.stopAt = new m(s2.stopAt, s2.timezone)), s2.interval !== null) {
15183
+ if (isNaN(s2.interval)) throw new Error("CronOptions: Supplied value for interval is not a number");
15184
+ if (s2.interval < 0) throw new Error("CronOptions: Supplied value for interval can not be negative");
15185
+ }
15186
+ if (s2.utcOffset !== void 0) {
15187
+ if (isNaN(s2.utcOffset)) throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");
15188
+ if (s2.utcOffset < -870 || s2.utcOffset > 870) throw new Error("CronOptions: utcOffset out of bounds.");
15189
+ if (s2.utcOffset !== void 0 && s2.timezone) throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.");
15190
+ }
15191
+ if (s2.unref !== true && s2.unref !== false) throw new Error("CronOptions: Unref should be either true, false or undefined(false).");
15192
+ 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.");
15193
+ return s2;
15194
+ }
15195
+ function p(s2) {
15196
+ return Object.prototype.toString.call(s2) === "[object Function]" || typeof s2 == "function" || s2 instanceof Function;
15197
+ }
15198
+ function _(s2) {
15199
+ return p(s2);
15200
+ }
15201
+ function x(s2) {
15202
+ typeof Deno < "u" && typeof Deno.unrefTimer < "u" ? Deno.unrefTimer(s2) : s2 && typeof s2.unref < "u" && s2.unref();
15203
+ }
15204
+ var W = 30 * 1e3;
15205
+ var w = [];
15206
+ var E = class {
15207
+ name;
15208
+ options;
15209
+ _states;
15210
+ fn;
15211
+ getTz() {
15212
+ return this.options.timezone || this.options.utcOffset;
15213
+ }
15214
+ applyDayOffset(e) {
15215
+ if (this.options.dayOffset !== void 0 && this.options.dayOffset !== 0) {
15216
+ let t = this.options.dayOffset * 24 * 60 * 60 * 1e3;
15217
+ return new Date(e.getTime() + t);
15218
+ }
15219
+ return e;
15220
+ }
15221
+ constructor(e, t, r) {
15222
+ let n, i;
15223
+ if (p(t)) i = t;
15224
+ else if (typeof t == "object") n = t;
15225
+ else if (t !== void 0) throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");
15226
+ if (p(r)) i = r;
15227
+ else if (typeof r == "object") n = r;
15228
+ else if (r !== void 0) throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");
15229
+ 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) {
15230
+ if (w.find((o) => o.name === this.name)) throw new Error("Cron: Tried to initialize new named job '" + this.name + "', but name already taken.");
15231
+ w.push(this);
15232
+ }
15233
+ return i !== void 0 && _(i) && (this.fn = i, this.schedule()), this;
15234
+ }
15235
+ nextRun(e) {
15236
+ let t = this._next(e);
15237
+ return t ? this.applyDayOffset(t.getDate(false)) : null;
15238
+ }
15239
+ nextRuns(e, t) {
15240
+ this._states.maxRuns !== void 0 && e > this._states.maxRuns && (e = this._states.maxRuns);
15241
+ let r = t || this._states.currentRun || void 0;
15242
+ return this._enumerateRuns(e, r, "next");
15243
+ }
15244
+ previousRuns(e, t) {
15245
+ return this._enumerateRuns(e, t || void 0, "previous");
15246
+ }
15247
+ _enumerateRuns(e, t, r) {
15248
+ let n = [], i = t ? new m(t, this.getTz()) : null, a = r === "next" ? this._next : this._previous;
15249
+ for (; e--; ) {
15250
+ let o = a.call(this, i);
15251
+ if (!o) break;
15252
+ let h = o.getDate(false);
15253
+ n.push(this.applyDayOffset(h)), i = o;
15254
+ }
15255
+ return n;
15256
+ }
15257
+ match(e) {
15258
+ if (this._states.once) {
15259
+ let r = new m(e, this.getTz());
15260
+ r.ms = 0;
15261
+ let n = new m(this._states.once, this.getTz());
15262
+ return n.ms = 0, r.getTime() === n.getTime();
15263
+ }
15264
+ let t = new m(e, this.getTz());
15265
+ return t.ms = 0, t.match(this._states.pattern, this.options);
15266
+ }
15267
+ getPattern() {
15268
+ if (!this._states.once) return this._states.pattern ? this._states.pattern.pattern : void 0;
15269
+ }
15270
+ getOnce() {
15271
+ return this._states.once ? this._states.once.getDate() : null;
15272
+ }
15273
+ isRunning() {
15274
+ let e = this.nextRun(this._states.currentRun), t = !this._states.paused, r = this.fn !== void 0, n = !this._states.kill;
15275
+ return t && r && n && e !== null;
15276
+ }
15277
+ isStopped() {
15278
+ return this._states.kill;
15279
+ }
15280
+ isBusy() {
15281
+ return this._states.blocking;
15282
+ }
15283
+ currentRun() {
15284
+ return this._states.currentRun ? this._states.currentRun.getDate() : null;
15285
+ }
15286
+ previousRun() {
15287
+ return this._states.previousRun ? this._states.previousRun.getDate() : null;
15288
+ }
15289
+ msToNext(e) {
15290
+ let t = this._next(e);
15291
+ return t ? e instanceof m || e instanceof Date ? t.getTime() - e.getTime() : t.getTime() - new m(e).getTime() : null;
15292
+ }
15293
+ stop() {
15294
+ this._states.kill = true, this._states.currentTimeout && clearTimeout(this._states.currentTimeout);
15295
+ let e = w.indexOf(this);
15296
+ e >= 0 && w.splice(e, 1);
15297
+ }
15298
+ pause() {
15299
+ return this._states.paused = true, !this._states.kill;
15300
+ }
15301
+ resume() {
15302
+ return this._states.paused = false, !this._states.kill;
15303
+ }
15304
+ schedule(e) {
15305
+ if (e && this.fn) throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");
15306
+ e && (this.fn = e);
15307
+ let t = this.msToNext(), r = this.nextRun(this._states.currentRun);
15308
+ 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);
15309
+ }
15310
+ async _trigger(e) {
15311
+ this._states.blocking = true, this._states.currentRun = new m(void 0, this.getTz());
15312
+ try {
15313
+ if (this.options.catch) try {
15314
+ this.fn !== void 0 && await this.fn(this, this.options.context);
15315
+ } catch (t) {
15316
+ if (p(this.options.catch)) try {
15317
+ this.options.catch(t, this);
15318
+ } catch {
15319
+ }
15320
+ }
15321
+ else this.fn !== void 0 && await this.fn(this, this.options.context);
15322
+ } finally {
15323
+ this._states.previousRun = new m(e, this.getTz()), this._states.blocking = false;
15324
+ }
15325
+ }
15326
+ async trigger() {
15327
+ await this._trigger();
15328
+ }
15329
+ runsLeft() {
15330
+ return this._states.maxRuns;
15331
+ }
15332
+ _checkTrigger(e) {
15333
+ let t = /* @__PURE__ */ new Date(), r = !this._states.paused && t.getTime() >= e.getTime(), n = this._states.blocking && this.options.protect;
15334
+ 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();
15335
+ }
15336
+ _next(e) {
15337
+ let t = !!(e || this._states.currentRun), r = false;
15338
+ !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);
15339
+ let n = this._states.once || new m(e, this.getTz());
15340
+ 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;
15341
+ }
15342
+ _previous(e) {
15343
+ let t = new m(e, this.getTz());
15344
+ this.options.stopAt && t.getTime() > this.options.stopAt.getTime() && (t = this.options.stopAt);
15345
+ let r = new m(t, this.getTz());
15346
+ 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);
15347
+ }
15348
+ _calculatePreviousRun(e, t) {
15349
+ let r = new m(void 0, this.getTz()), n = e;
15350
+ if (this.options.startAt.getTime() <= r.getTime()) {
15351
+ n = this.options.startAt;
15352
+ let i = n.getTime() + this.options.interval * 1e3;
15353
+ for (; i <= r.getTime(); ) n = new m(n, this.getTz()).increment(this._states.pattern, this.options, true), i = n.getTime() + this.options.interval * 1e3;
15354
+ t = true;
15355
+ }
15356
+ return n === null && (n = void 0), [n, t];
15357
+ }
15358
+ };
15359
+
15360
+ // shared/routine-schedule.ts
15361
+ var MAX_EXPRESSION_LENGTH = 256;
15362
+ function cronCalculator(value) {
15363
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Choose a valid cron schedule");
15364
+ const input = value;
15365
+ if (input.type !== "cron" || typeof input.expression !== "string") throw new Error("Choose a valid cron schedule");
15366
+ if (Object.keys(input).some((key) => !["type", "expression", "timeZone"].includes(key))) {
15367
+ throw new Error("Cron schedules accept only type, expression and timeZone; start/end dates and other restrictions are not supported");
15368
+ }
15369
+ const expression = input.expression.trim().replace(/\s+/g, " ");
15370
+ if (expression.length > MAX_EXPRESSION_LENGTH || expression.split(" ").length !== 5 || expression.includes("@")) {
15371
+ throw new Error("Cron must have five fields: minute hour day-of-month month weekday (no seconds, year, or macros)");
15372
+ }
15373
+ const timeZone = typeof input.timeZone === "string" ? input.timeZone.trim() : "";
15374
+ if (timeZone.length > 128 || !(timeZone === "UTC" || /^[A-Za-z][A-Za-z0-9_+-]*(?:\/[A-Za-z0-9_+-]+)+$/.test(timeZone))) {
15375
+ throw new Error("Choose an IANA timezone such as America/New_York, Asia/Kolkata, or UTC");
15376
+ }
15377
+ try {
15378
+ new Intl.DateTimeFormat("en-US", { timeZone }).format(0);
15379
+ } catch {
15380
+ throw new Error("Choose a valid IANA timezone such as America/New_York, Asia/Kolkata, or UTC");
15381
+ }
15382
+ try {
15383
+ const cron = new E(expression, { timezone: timeZone, mode: "5-part", paused: true });
15384
+ return { schedule: { type: "cron", expression, timeZone }, cron };
15385
+ } catch (error51) {
15386
+ throw new Error(`Invalid cron expression: ${error51.message}`);
15387
+ }
15388
+ }
15389
+ function calculationDate(after) {
15390
+ const date5 = new Date(after);
15391
+ if (!Number.isFinite(after) || !Number.isFinite(date5.getTime())) throw new Error("Choose a valid cron preview date");
15392
+ return date5;
15393
+ }
15394
+ function futureRuns(cron, after, count) {
15395
+ const from = calculationDate(after);
15396
+ const maximum = count + 1440;
15397
+ let requested = count;
15398
+ while (true) {
15399
+ const candidates = cron.nextRuns(requested, from);
15400
+ const runs = [];
15401
+ for (const date5 of candidates) {
15402
+ const at = date5.getTime();
15403
+ if (!Number.isFinite(at)) throw new Error("The cron schedule produced an invalid date");
15404
+ if (at > (runs.at(-1) ?? after)) runs.push(at);
15405
+ if (runs.length === count) return runs;
15406
+ }
15407
+ if (candidates.length < requested || requested === maximum) return runs;
15408
+ requested = Math.min(maximum, requested * 2);
15409
+ }
15410
+ }
15411
+ function normalizeCronSchedule(value, after = Date.now()) {
15412
+ const { schedule, cron } = cronCalculator(value);
15413
+ if (!futureRuns(cron, after, 1).length) throw new Error("This cron expression has no future runs. Choose dates that exist.");
15414
+ return schedule;
15415
+ }
15416
+
15417
+ // server/new-bot-defaults.ts
15418
+ var strings = (max, length) => external_exports.array(external_exports.string().max(length)).max(max);
15419
+ var clock = external_exports.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/);
15420
+ var weekdays = external_exports.array(external_exports.number().int().min(0).max(6)).min(1).max(7);
15421
+ var timestamp = external_exports.number().int().nonnegative().max(864e13);
15422
+ var botDefaultModelSchema = external_exports.object({
15423
+ instanceId: external_exports.string().trim().min(1).max(200),
15424
+ model: external_exports.string().trim().min(1).max(500),
15425
+ effort: external_exports.enum(EFFORT_LEVELS).optional(),
15426
+ variant: external_exports.string().refine(isModelVariant, "invalid model variant").optional()
15427
+ }).strict().refine(
15428
+ (value) => value.effort === void 0 || value.variant === void 0,
15429
+ "choose either a model variant or an effort level"
15430
+ );
15431
+ var botDefaultsProfileSchema = profilePatchSchema.extend({
15432
+ name: external_exports.string().max(100).refine(fitsOnOneLine, "name must fit on one line").optional(),
15433
+ section: external_exports.string().trim().max(60).optional(),
15434
+ color: external_exports.enum(["green", "blue", "red", "orange", "purple", "cyan", "pink", "yellow", "teal", "coral"]).optional(),
15435
+ mascotExpression: external_exports.string().max(60).nullable().optional(),
15436
+ modelSelection: botDefaultModelSchema.optional(),
15437
+ computer: external_exports.enum(["cloud", "vm", "local", "browser", "off"]).nullable().optional(),
15438
+ cloudBackend: external_exports.enum(["box", "vps"]).optional(),
15439
+ autoStartVps: external_exports.boolean().optional(),
15440
+ cwd: external_exports.string().max(4096).nullable().optional(),
15441
+ approvalMode: external_exports.enum(["ask", "auto", "full", "custom"]).optional(),
15442
+ alwaysAllow: strings(200, 500).optional(),
15443
+ chiefOfStaff: external_exports.boolean().optional(),
15444
+ managedSections: strings(100, 60).optional(),
15445
+ approvePeerComms: external_exports.boolean().optional(),
15446
+ peers: strings(1e3, 100).nullable().optional(),
15447
+ composio: external_exports.boolean().optional(),
15448
+ browser: external_exports.boolean().optional(),
15449
+ browserProfile: external_exports.string().max(100).nullable().optional(),
15450
+ mcpServers: strings(100, 100).nullable().optional(),
15451
+ parkDirectMessages: external_exports.boolean().optional()
15452
+ }).strict();
15453
+ var scheduleSchema = external_exports.discriminatedUnion("type", [
15454
+ external_exports.object({ type: external_exports.literal("once"), at: timestamp }).strict(),
15455
+ external_exports.object({ type: external_exports.literal("daily"), time: clock, weekdays }).strict(),
15456
+ external_exports.object({
15457
+ type: external_exports.literal("interval"),
15458
+ everyMinutes: external_exports.number().int().min(5).max(1440),
15459
+ anchorAt: timestamp,
15460
+ weekdays: weekdays.nullable().optional(),
15461
+ window: external_exports.object({ start: clock, end: clock }).strict().nullable().optional(),
15462
+ endsAt: timestamp.nullable().optional()
15463
+ }).strict(),
15464
+ external_exports.object({ type: external_exports.literal("cron"), expression: external_exports.string().max(256), timeZone: external_exports.string().max(128) }).strict()
15465
+ ]).superRefine((value, ctx) => {
15466
+ if (value.type === "cron") {
15467
+ try {
15468
+ normalizeCronSchedule(value);
15469
+ } catch (error51) {
15470
+ ctx.addIssue({ code: "custom", message: String(error51) });
15471
+ }
15472
+ }
15473
+ if (value.type === "interval" && value.window) {
15474
+ const minutes = (time3) => Number(time3.slice(0, 2)) * 60 + Number(time3.slice(3));
15475
+ if (minutes(value.window.end) - minutes(value.window.start) < value.everyMinutes) {
15476
+ ctx.addIssue({ code: "custom", message: "The interval must fit inside its time window" });
15477
+ }
15478
+ }
15479
+ });
15480
+ var botRoutineTemplateSchema = external_exports.object({
15481
+ name: external_exports.string().trim().min(1).max(80),
15482
+ prompt: external_exports.string().trim().min(1).max(2e4),
15483
+ schedule: scheduleSchema,
15484
+ enabled: external_exports.boolean().optional(),
15485
+ runOn: external_exports.enum(["maus", "cloud"]).optional(),
15486
+ durationMinutes: external_exports.number().int().min(5).max(240).optional(),
15487
+ timeoutMinutes: external_exports.number().min(1).max(1440).nullable().optional(),
15488
+ overlap: external_exports.enum(["skip", "queue"]).optional(),
15489
+ attachments: external_exports.array(external_exports.object({
15490
+ id: external_exports.string().min(1).max(200),
15491
+ kind: external_exports.enum(["file", "image"]),
15492
+ name: external_exports.string().min(1).max(255),
15493
+ path: external_exports.string().min(1).max(4096),
15494
+ size: external_exports.number().nonnegative()
15495
+ }).strict()).max(50).optional()
15496
+ }).strict();
15497
+ var botSkillTemplateSchema = external_exports.object({
15498
+ name: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
15499
+ description: external_exports.string().max(1024),
15500
+ warnings: strings(100, 2e3).default([]),
15501
+ source: external_exports.string().min(1).max(2e3),
15502
+ text: external_exports.string().refine((value) => Buffer.byteLength(value, "utf8") <= 262144, "Skill exceeds 256 KiB"),
15503
+ enabled: external_exports.boolean()
15504
+ }).strict();
15505
+ var newBotDefaultsSchema = external_exports.object({
15506
+ profile: botDefaultsProfileSchema.default({}),
15507
+ memory: external_exports.record(
15508
+ external_exports.string().regex(/^(?:MEMORY\.md|memory\/[a-zA-Z0-9_-]+\.md)$/),
15509
+ external_exports.string().refine((value) => Buffer.byteLength(value, "utf8") <= 262144, "Memory file exceeds 256 KiB")
15510
+ ).refine((value) => Object.keys(value).length <= 100, "At most 100 memory files").default({}),
15511
+ skills: external_exports.array(botSkillTemplateSchema).max(100).default([]),
15512
+ routines: external_exports.array(botRoutineTemplateSchema).max(100).default([])
15513
+ }).strict().refine(
15514
+ (value) => Buffer.byteLength(JSON.stringify(value), "utf8") <= 9e5,
15515
+ "Bot defaults must fit within 900 KB"
15516
+ );
15517
+
14663
15518
  // shared/provider-icon.ts
14664
15519
  var PROVIDER_ICON_PRESETS = [
14665
15520
  "openai",
@@ -14980,14 +15835,35 @@ var instanceConfigSchema = external_exports.object({
14980
15835
  });
14981
15836
  var instanceConfigMapSchema = external_exports.record(external_exports.string(), instanceConfigSchema);
14982
15837
  var defaultModelSelectionSchema = external_exports.object({
14983
- instanceId: external_exports.string().trim().min(1),
14984
- model: external_exports.string().trim().min(1),
15838
+ instanceId: external_exports.string().trim().min(1).max(200),
15839
+ model: external_exports.string().trim().min(1).max(500),
14985
15840
  effort: external_exports.enum(EFFORT_LEVELS).optional(),
14986
15841
  variant: external_exports.string().refine(isModelVariant, "invalid model variant").optional()
14987
15842
  }).refine(
14988
15843
  (selection) => selection.variant === void 0 || selection.effort === void 0,
14989
15844
  "choose either a model variant or an effort level"
14990
15845
  );
15846
+ var threadsConfigSchema = external_exports.object({
15847
+ maxConcurrentPerBot: external_exports.number().int().min(1).max(MAX_CONCURRENT_BOT_THREADS),
15848
+ /** Cap each per-thread events/ and native/ NDJSON log at this many
15849
+ * bytes; absent (the default) keeps today's unbounded growth (#1280). */
15850
+ eventLogMaxBytes: external_exports.number().int().min(MIN_THREAD_EVENT_LOG_BYTES).max(MAX_THREAD_EVENT_LOG_BYTES).optional(),
15851
+ /** Days a closed or archived thread's event logs survive (#1280).
15852
+ * Absent keeps them forever. */
15853
+ eventLogRetentionDays: external_exports.number().int().min(1).max(3650).optional()
15854
+ }).strict();
15855
+ var newBotsConfigSchema = external_exports.object({
15856
+ /** Effort for a new bot whose model selection names none. */
15857
+ effort: external_exports.enum(EFFORT_LEVELS).optional()
15858
+ }).strict();
15859
+ var newBotsPatchSchema = external_exports.object({
15860
+ effort: newBotsConfigSchema.shape.effort.nullable()
15861
+ }).strict();
15862
+ var threadsPatchSchema = threadsConfigSchema.extend({
15863
+ maxConcurrentPerBot: threadsConfigSchema.shape.maxConcurrentPerBot.optional(),
15864
+ eventLogMaxBytes: threadsConfigSchema.shape.eventLogMaxBytes.nullable(),
15865
+ eventLogRetentionDays: threadsConfigSchema.shape.eventLogRetentionDays.nullable()
15866
+ });
14991
15867
  var appConfigSchema = external_exports.object({
14992
15868
  /** Verified by the dedicated domain endpoint, never a generic config patch. */
14993
15869
  customDomain: external_exports.string().optional(),
@@ -14995,12 +15871,15 @@ var appConfigSchema = external_exports.object({
14995
15871
  * addresses or `@domain` entries; admins get every scope, members chat only. */
14996
15872
  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(),
14997
15873
  defaultModelSelection: defaultModelSelectionSchema.optional(),
15874
+ newBotDefaults: newBotDefaultsSchema.optional(),
15875
+ newBots: newBotsConfigSchema.optional(),
14998
15876
  /** CLI-only launch preferences. Never enable remote access implicitly. */
14999
15877
  cliStartup: external_exports.object({
15000
15878
  access: external_exports.enum(["local", "tunnel", "tailscale", "public-url"]),
15001
15879
  publicUrl: external_exports.string().url().optional(),
15002
15880
  phone: external_exports.enum(["ios", "android"]).optional()
15003
15881
  }).optional(),
15882
+ mistral: external_exports.object({ key: optionalText }).optional(),
15004
15883
  xai: external_exports.object({ key: optionalText, url: optionalText }).optional(),
15005
15884
  /** Anthropic API key for Claude Code billed per token, handed only to
15006
15885
  * Claude instances; `url` only for a proxy or a test double. Never a
@@ -15069,8 +15948,8 @@ var appConfigSchema = external_exports.object({
15069
15948
  "Use a model ID without control characters"
15070
15949
  ).optional()
15071
15950
  }).optional(),
15072
- /** Non-secret profile details shown in the sidebar. */
15073
- profile: external_exports.object({ name: optionalText, email: optionalText }).optional(),
15951
+ /** Non-secret profile details; aboutMe is shared with every bot. */
15952
+ profile: external_exports.object({ name: optionalText, email: optionalText, aboutMe: external_exports.string().max(24e3).optional() }).optional(),
15074
15953
  /** UI language override (BCP-47, lowercase). Empty/absent = follow the
15075
15954
  * system language. Unknown tags degrade to English in the renderer. */
15076
15955
  language: optionalText,
@@ -15080,15 +15959,10 @@ var appConfigSchema = external_exports.object({
15080
15959
  compactAt: external_exports.number().positive().max(1e7).optional(),
15081
15960
  autoCompact: external_exports.boolean().optional()
15082
15961
  }).optional(),
15083
- threads: external_exports.object({
15084
- maxConcurrentPerBot: external_exports.number().int().min(1).max(MAX_CONCURRENT_BOT_THREADS),
15085
- /** Cap each per-thread events/ and native/ NDJSON log at this many
15086
- * bytes; absent (the default) keeps today's unbounded growth (#1280). */
15087
- eventLogMaxBytes: external_exports.number().int().min(MIN_THREAD_EVENT_LOG_BYTES).max(MAX_THREAD_EVENT_LOG_BYTES).optional(),
15088
- /** Days a closed or archived thread's event logs survive (#1280).
15089
- * Absent keeps them forever. */
15090
- eventLogRetentionDays: external_exports.number().int().min(1).max(3650).optional()
15091
- }).strict().optional(),
15962
+ threads: threadsConfigSchema.optional(),
15963
+ /** The authorization decision log (server/decision-log.ts): days of month
15964
+ * files kept, at least; OMB_DECISION_RETENTION_DAYS wins when set. */
15965
+ decisions: external_exports.object({ retentionDays: external_exports.number().int().min(1).max(3650).optional() }).strict().optional(),
15092
15966
  localVm: localVmConfigSchema.optional(),
15093
15967
  features: featureConfigSchema.optional(),
15094
15968
  onboarding: onboardingConfigSchema.optional(),
@@ -15105,7 +15979,7 @@ var appConfigSchema = external_exports.object({
15105
15979
  var storedAppConfigSchema = appConfigSchema.extend({
15106
15980
  browserProfiles: storedBrowserProfilesSchema.optional()
15107
15981
  });
15108
- var appConfigPatchSchema = appConfigSchema.omit({ instances: true, mcpServers: true, cliStartup: true, customDomain: true });
15982
+ var appConfigPatchSchema = appConfigSchema.omit({ instances: true, mcpServers: true, cliStartup: true, customDomain: true }).extend({ threads: threadsPatchSchema.optional(), newBots: newBotsPatchSchema.optional() });
15109
15983
  var jsonObjectSchema = external_exports.record(external_exports.string(), external_exports.json());
15110
15984
  var DATA_DIR = process.env.OMB_DATA_DIR ?? join2(homedir2(), ".openmausbot");
15111
15985
  var LEGACY_DATA_DIR = join2(homedir2(), ".opengrokbot");
@@ -15331,11 +16205,11 @@ function createToolListNormalizer() {
15331
16205
  // server/mcp-bridge.ts
15332
16206
  var BRIDGE_INACTIVITY_MS = 45e3;
15333
16207
  var PROBE_TIMEOUT_MS = 1e4;
15334
- function runLivenessProbe(probe, timeoutMs = PROBE_TIMEOUT_MS) {
16208
+ function runLivenessProbe(probe, timeoutMs = PROBE_TIMEOUT_MS, env) {
15335
16209
  return new Promise((resolve2) => {
15336
16210
  const child = spawn(probe.command, probe.args, {
15337
16211
  shell: false,
15338
- env: { ...process.env, PATH: augmentedPath() },
16212
+ env: env ?? { ...process.env, PATH: augmentedPath() },
15339
16213
  stdio: ["ignore", "ignore", "ignore"]
15340
16214
  });
15341
16215
  const timer = setTimeout(() => {
@@ -15522,7 +16396,7 @@ function runMcpBridge(options) {
15522
16396
  const liveness = options.liveness;
15523
16397
  watchdog = createInactivityWatchdog({
15524
16398
  inactivityMs: BRIDGE_INACTIVITY_MS,
15525
- probe: () => runLivenessProbe(liveness),
16399
+ probe: () => runLivenessProbe(liveness, PROBE_TIMEOUT_MS, options.env),
15526
16400
  onDead: () => {
15527
16401
  process.stderr.write(
15528
16402
  `${options.label} transport went silent and stopped answering liveness probes; ending the bridge