@covro/covro 0.7.0-beta.1 → 0.7.1-dev.1

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 (137) hide show
  1. package/README.md +10 -10
  2. package/README.zh-CN.md +10 -10
  3. package/dist/cli/background.js +10 -7
  4. package/dist/cli/background.js.map +2 -2
  5. package/dist/cli/daemon.js +3 -1
  6. package/dist/cli/daemon.js.map +2 -2
  7. package/dist/cli/launch-environment.js +5 -2
  8. package/dist/cli/launch-environment.js.map +2 -2
  9. package/dist/cli/launchd.js +14 -8
  10. package/dist/cli/launchd.js.map +2 -2
  11. package/dist/cli/runtime-launch.js +108 -0
  12. package/dist/cli/runtime-launch.js.map +7 -0
  13. package/dist/cli/runtime.js +12 -0
  14. package/dist/cli/runtime.js.map +7 -0
  15. package/dist/cli/service.js +7 -4
  16. package/dist/cli/service.js.map +2 -2
  17. package/dist/codex/account-usage.js +132 -0
  18. package/dist/codex/account-usage.js.map +7 -0
  19. package/dist/codex/adapter.js +45 -4
  20. package/dist/codex/adapter.js.map +2 -2
  21. package/dist/codex/mapping.js +3 -2
  22. package/dist/codex/mapping.js.map +2 -2
  23. package/dist/server/http.js +8 -0
  24. package/dist/server/http.js.map +2 -2
  25. package/dist/server/service.js +71 -1
  26. package/dist/server/service.js.map +2 -2
  27. package/dist/server/workspaces.js +6 -0
  28. package/dist/server/workspaces.js.map +2 -2
  29. package/dist/shared/account-usage.js +1 -0
  30. package/dist/shared/account-usage.js.map +7 -0
  31. package/dist/shared/skills.js +25 -0
  32. package/dist/shared/skills.js.map +7 -0
  33. package/dist/shared/thread-summary.js +4 -0
  34. package/dist/shared/thread-summary.js.map +2 -2
  35. package/dist/shared/updates.js.map +2 -2
  36. package/dist/shared/validation.js +18 -1
  37. package/dist/shared/validation.js.map +2 -2
  38. package/dist/update-worker.cjs +1111 -754
  39. package/dist/updates/manager.js +89 -8
  40. package/dist/updates/manager.js.map +2 -2
  41. package/dist/updates/registry.js +7 -6
  42. package/dist/updates/registry.js.map +2 -2
  43. package/dist/updates/runtime.js +183 -0
  44. package/dist/updates/runtime.js.map +7 -0
  45. package/dist/updates/transaction.js +8 -4
  46. package/dist/updates/transaction.js.map +2 -2
  47. package/dist/updates/worker.js +177 -112
  48. package/dist/updates/worker.js.map +3 -3
  49. package/dist/web/assets/{abnfDiagram-WEYOIA3C-DPrSyxx5.js → abnfDiagram-WEYOIA3C-Ct5ChZBc.js} +1 -1
  50. package/dist/web/assets/{arc-4B8zsDlv.js → arc-BXRV0CVi.js} +1 -1
  51. package/dist/web/assets/{architecture-WOLXFQ4H-DzDNYcvm.js → architecture-WOLXFQ4H-CPBgJhsO.js} +1 -1
  52. package/dist/web/assets/{architectureDiagram-ZHVYKT53-CJ9tt7RD.js → architectureDiagram-ZHVYKT53-CLEC3Xoj.js} +1 -1
  53. package/dist/web/assets/{blockDiagram-RJAE7QA3-C9ljbm6J.js → blockDiagram-RJAE7QA3-BmLPHgTS.js} +1 -1
  54. package/dist/web/assets/{c4Diagram-XDPPPE54-Sd9QMUQp.js → c4Diagram-XDPPPE54-CR-FGGI9.js} +1 -1
  55. package/dist/web/assets/channel-B8Z0MEpl.js +1 -0
  56. package/dist/web/assets/{chunk-2E7WHVMD-DsUWsTrf.js → chunk-2E7WHVMD-CAKelRoz.js} +1 -1
  57. package/dist/web/assets/{chunk-4EMNKR2T-Bh91FySB.js → chunk-4EMNKR2T-CzHhqgrM.js} +1 -1
  58. package/dist/web/assets/{chunk-55XCU76K-BRxH4G9N.js → chunk-55XCU76K-BXdn9HRo.js} +1 -1
  59. package/dist/web/assets/{chunk-7S6XSTFO-DbTYm4kS.js → chunk-7S6XSTFO-iQXMs5VF.js} +1 -1
  60. package/dist/web/assets/{chunk-AQDTSKZB-D1NiDG4T.js → chunk-AQDTSKZB-BTLhVc8_.js} +1 -1
  61. package/dist/web/assets/{chunk-DSNLSHJZ-C0LQPoI8.js → chunk-DSNLSHJZ-MjR5Eo7J.js} +1 -1
  62. package/dist/web/assets/{chunk-HAGFOTED-DRrIOJjB.js → chunk-HAGFOTED-Bma7AjUx.js} +1 -1
  63. package/dist/web/assets/{chunk-HNE4Q36P-Bok-UYL9.js → chunk-HNE4Q36P-B-TPWEoT.js} +1 -1
  64. package/dist/web/assets/{chunk-NQOKRVIF-D1zmT8gY.js → chunk-NQOKRVIF-BnVBL0oP.js} +1 -1
  65. package/dist/web/assets/{chunk-UHW7PFBP-BDwjuCRk.js → chunk-UHW7PFBP-BrCzpTQe.js} +1 -1
  66. package/dist/web/assets/{chunk-VQ5W62QI-DAHWoS2u.js → chunk-VQ5W62QI-SVCda4i-.js} +1 -1
  67. package/dist/web/assets/{chunk-WQQL4CDK-ggfsBWta.js → chunk-WQQL4CDK-CFa1_xXP.js} +1 -1
  68. package/dist/web/assets/{chunk-XXDRQBXY-DBRGTT6L.js → chunk-XXDRQBXY-BrTjiUzN.js} +1 -1
  69. package/dist/web/assets/{chunk-YZO67HFG-BCM-hzbV.js → chunk-YZO67HFG-BqM0aDwN.js} +1 -1
  70. package/dist/web/assets/{chunk-ZAUX2LTX-MnMFUU_S.js → chunk-ZAUX2LTX-BAhm5jhj.js} +1 -1
  71. package/dist/web/assets/{chunk-ZCHMQSOR-ClT-_dGN.js → chunk-ZCHMQSOR-Cip7n8Sg.js} +1 -1
  72. package/dist/web/assets/{classDiagram-v2-4MYWR3UA-CPV9IWEk.js → classDiagram-v2-4MYWR3UA-D7N6Uj0X.js} +1 -1
  73. package/dist/web/assets/{cose-bilkent-JH36ORCC-DqgOWzoX.js → cose-bilkent-JH36ORCC-By_XO8JA.js} +1 -1
  74. package/dist/web/assets/{cynefin-EF2NZ3EQ-Dkit62ND.js → cynefin-EF2NZ3EQ-D4tmIqN2.js} +1 -1
  75. package/dist/web/assets/{cynefinDiagram-WF24UDRP-DSiF7XN6.js → cynefinDiagram-WF24UDRP-BiBX9g64.js} +1 -1
  76. package/dist/web/assets/{dagre-NK4GIZVX-DPMP_fYv.js → dagre-NK4GIZVX-BGoSiF2R.js} +1 -1
  77. package/dist/web/assets/{diagram-CBK3MWTC-CyMSNHt0.js → diagram-CBK3MWTC-CcFPBcEd.js} +1 -1
  78. package/dist/web/assets/{diagram-I5XIIV2D-tQ2bMi8B.js → diagram-I5XIIV2D-DehB2F5t.js} +1 -1
  79. package/dist/web/assets/{diagram-ODIL2UCW-BGZKonG-.js → diagram-ODIL2UCW-V8fUY3mq.js} +1 -1
  80. package/dist/web/assets/{diagram-PFBEJUXE-ChscR483.js → diagram-PFBEJUXE-BHHEFVnW.js} +1 -1
  81. package/dist/web/assets/{diagram-RJA3I4VV-frBsA7DX.js → diagram-RJA3I4VV-D2exArjj.js} +1 -1
  82. package/dist/web/assets/{diagram-TYUNFSNR-B8qZBREp.js → diagram-TYUNFSNR-BdtGXIpi.js} +1 -1
  83. package/dist/web/assets/{dist-7U4_LxsV.js → dist-DaQz3nkD.js} +1 -1
  84. package/dist/web/assets/{ebnfDiagram-V4P3TTPT-CfnjkhXT.js → ebnfDiagram-V4P3TTPT-Cggzc5yD.js} +1 -1
  85. package/dist/web/assets/{elk-QONTBCTQ-D6KBNmbF.js → elk-QONTBCTQ-DDC0zLrS.js} +1 -1
  86. package/dist/web/assets/{erDiagram-KYQIGQAA-Sx8YaD42.js → erDiagram-KYQIGQAA-DfypQFgb.js} +1 -1
  87. package/dist/web/assets/{eventmodeling-K75KTNOO-DgI4Zm6z.js → eventmodeling-K75KTNOO-D8qBsuC_.js} +1 -1
  88. package/dist/web/assets/flowDiagram-IUGLLWBU-GpPr3WFa.js +1 -0
  89. package/dist/web/assets/{ganttDiagram-R7GPNTJY-FN9ghlFf.js → ganttDiagram-R7GPNTJY-CENwnE1B.js} +1 -1
  90. package/dist/web/assets/{gitGraph-VSP46ZUC-B6RMx5nS.js → gitGraph-VSP46ZUC-BVF17ADV.js} +1 -1
  91. package/dist/web/assets/{gitGraphDiagram-PDYL7XHY-BUfDV32d.js → gitGraphDiagram-PDYL7XHY-C1qi9iCy.js} +1 -1
  92. package/dist/web/assets/index-2ms-LtOu.css +1 -0
  93. package/dist/web/assets/index-C-VE9GLc.js +158 -0
  94. package/dist/web/assets/{info-OHQRW6UA-i9U_Vjx9.js → info-OHQRW6UA-LgFb_2F-.js} +1 -1
  95. package/dist/web/assets/{infoDiagram-MVDRKAX5-BcIiBHfp.js → infoDiagram-MVDRKAX5-17P2DCcG.js} +1 -1
  96. package/dist/web/assets/{ishikawaDiagram-HPEHV2GE-CBq8uWqz.js → ishikawaDiagram-HPEHV2GE-YI3XteWz.js} +1 -1
  97. package/dist/web/assets/{journeyDiagram-BOSHW7O7-BoH8zvhM.js → journeyDiagram-BOSHW7O7-DqIEkafR.js} +1 -1
  98. package/dist/web/assets/{kanban-definition-FNSA4HC5-DqWoSu__.js → kanban-definition-FNSA4HC5-CMQ9DCXo.js} +1 -1
  99. package/dist/web/assets/{line-mJzmbB6p.js → line-BzaaPKlk.js} +1 -1
  100. package/dist/web/assets/{linear-BwkmaM-M.js → linear-8o2E18fD.js} +1 -1
  101. package/dist/web/assets/{mermaid-parser.core-DwFqVvpp.js → mermaid-parser.core-kGccWBJU.js} +3 -3
  102. package/dist/web/assets/{mermaid.core-DcF8gYr_.js → mermaid.core-BSQidwq_.js} +4 -4
  103. package/dist/web/assets/{mindmap-definition-6OY57UG3-D4XGBbWO.js → mindmap-definition-6OY57UG3-D-FFEmUv.js} +1 -1
  104. package/dist/web/assets/{packet-JDAUHWVQ-Da_cMCDo.js → packet-JDAUHWVQ-DJhUFf1j.js} +1 -1
  105. package/dist/web/assets/{pegDiagram-ECIUJNBX-CVgVmFmC.js → pegDiagram-ECIUJNBX-CmIOvdbf.js} +1 -1
  106. package/dist/web/assets/{pie-XZMESJXO-7pec9CJT.js → pie-XZMESJXO-CSrWK9rU.js} +1 -1
  107. package/dist/web/assets/{pieDiagram-GNMPY74T-97N9EH_E.js → pieDiagram-GNMPY74T-tvVSdXH-.js} +1 -1
  108. package/dist/web/assets/{quadrantDiagram-D57K4MC3-FJDGQ0ZC.js → quadrantDiagram-D57K4MC3-CGK1kRkp.js} +1 -1
  109. package/dist/web/assets/{radar-ABXABTNO-DsWXE4id.js → radar-ABXABTNO-MDz1NYHf.js} +1 -1
  110. package/dist/web/assets/{railroad-I3PHUGI6-Cs3NR5Rp.js → railroad-I3PHUGI6-CiLd87KR.js} +1 -1
  111. package/dist/web/assets/{railroad-abnf-LNEFI6M7-fn-KtM-H.js → railroad-abnf-LNEFI6M7-RY_WYJN6.js} +1 -1
  112. package/dist/web/assets/{railroad-ebnf-DWYD2UWJ-BuexEj3O.js → railroad-ebnf-DWYD2UWJ-B4ZEET0K.js} +1 -1
  113. package/dist/web/assets/{railroad-peg-JR7BVNR7-C59VHWhm.js → railroad-peg-JR7BVNR7-9DbLhbQQ.js} +1 -1
  114. package/dist/web/assets/{railroadDiagram-Y72NRBL7-Dwpn4kqo.js → railroadDiagram-Y72NRBL7-onpNqRG_.js} +1 -1
  115. package/dist/web/assets/{requirementDiagram-EQYSW5RA-BE9cDXG8.js → requirementDiagram-EQYSW5RA-Bk6XTcPp.js} +1 -1
  116. package/dist/web/assets/{sankeyDiagram-SY24JHO5-BiPoxRoH.js → sankeyDiagram-SY24JHO5-K4434mnD.js} +1 -1
  117. package/dist/web/assets/{sequenceDiagram-BLEHNHQU-OHewZwiU.js → sequenceDiagram-BLEHNHQU-DQiu1tXe.js} +1 -1
  118. package/dist/web/assets/{src-CAqT2rVv.js → src-PYZv1Xmx.js} +1 -1
  119. package/dist/web/assets/{stateDiagram-v2-A6IESKWZ-BHul6PGu.js → stateDiagram-v2-A6IESKWZ-BVNOf4hf.js} +1 -1
  120. package/dist/web/assets/{swimlanes-B3ENRKFQ-BBjoKZII.js → swimlanes-B3ENRKFQ-Sr8zlNgH.js} +1 -1
  121. package/dist/web/assets/swimlanesDiagram-AYQRV4AK-Cxqy1i01.js +8 -0
  122. package/dist/web/assets/{timeline-definition-JXYKGLGB-D7reGFUV.js → timeline-definition-JXYKGLGB-D3UD0on6.js} +1 -1
  123. package/dist/web/assets/{treeView-D4JQ5SDB-BC4PBy2z.js → treeView-D4JQ5SDB-DMkXgni_.js} +1 -1
  124. package/dist/web/assets/{treemap-SAJKECNS-C-L3y3B0.js → treemap-SAJKECNS-BFVUPZHm.js} +1 -1
  125. package/dist/web/assets/{usecaseDiagram-WPOLBNNX-DqReWsLT.js → usecaseDiagram-WPOLBNNX-BY0Ux9fE.js} +1 -1
  126. package/dist/web/assets/{vennDiagram-Q3Y3IDCW-RB21WgMG.js → vennDiagram-Q3Y3IDCW-DTSz-zyI.js} +1 -1
  127. package/dist/web/assets/{wardley-7MLQ67FV-CAGdvTyZ.js → wardley-7MLQ67FV-DEoiPn37.js} +1 -1
  128. package/dist/web/assets/{wardleyDiagram-IVAIDKWA-DXN5Mh5B.js → wardleyDiagram-IVAIDKWA-CJWnMB5u.js} +1 -1
  129. package/dist/web/assets/{xychartDiagram-4URNHDU4-Y2Tpnzwb.js → xychartDiagram-4URNHDU4-X8rgPB9G.js} +1 -1
  130. package/dist/web/index.html +2 -2
  131. package/dist/web/notification-worker.js +33 -0
  132. package/package.json +4 -4
  133. package/dist/web/assets/channel-DKYuZv8c.js +0 -1
  134. package/dist/web/assets/flowDiagram-IUGLLWBU-AdTZW4EM.js +0 -1
  135. package/dist/web/assets/index-BayHb2le.js +0 -156
  136. package/dist/web/assets/index-qYBdGqKM.css +0 -1
  137. package/dist/web/assets/swimlanesDiagram-AYQRV4AK-Cp-6Y0VO.js +0 -8
@@ -36,7 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  // node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
37
37
  var require_polyfills = __commonJS({
38
38
  "node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js"(exports2, module2) {
39
- var constants3 = require("constants");
39
+ var constants4 = require("constants");
40
40
  var origCwd = process.cwd;
41
41
  var cwd = null;
42
42
  var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
@@ -60,7 +60,7 @@ var require_polyfills = __commonJS({
60
60
  var chdir;
61
61
  module2.exports = patch;
62
62
  function patch(fs) {
63
- if (constants3.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
63
+ if (constants4.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
64
64
  patchLchmod(fs);
65
65
  }
66
66
  if (!fs.lutimes) {
@@ -162,7 +162,7 @@ var require_polyfills = __commonJS({
162
162
  fs2.lchmod = function(path, mode, callback) {
163
163
  fs2.open(
164
164
  path,
165
- constants3.O_WRONLY | constants3.O_SYMLINK,
165
+ constants4.O_WRONLY | constants4.O_SYMLINK,
166
166
  mode,
167
167
  function(err, fd) {
168
168
  if (err) {
@@ -178,7 +178,7 @@ var require_polyfills = __commonJS({
178
178
  );
179
179
  };
180
180
  fs2.lchmodSync = function(path, mode) {
181
- var fd = fs2.openSync(path, constants3.O_WRONLY | constants3.O_SYMLINK, mode);
181
+ var fd = fs2.openSync(path, constants4.O_WRONLY | constants4.O_SYMLINK, mode);
182
182
  var threw = true;
183
183
  var ret;
184
184
  try {
@@ -198,9 +198,9 @@ var require_polyfills = __commonJS({
198
198
  };
199
199
  }
200
200
  function patchLutimes(fs2) {
201
- if (constants3.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
201
+ if (constants4.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
202
202
  fs2.lutimes = function(path, at, mt, cb) {
203
- fs2.open(path, constants3.O_SYMLINK, function(er, fd) {
203
+ fs2.open(path, constants4.O_SYMLINK, function(er, fd) {
204
204
  if (er) {
205
205
  if (cb) cb(er);
206
206
  return;
@@ -213,7 +213,7 @@ var require_polyfills = __commonJS({
213
213
  });
214
214
  };
215
215
  fs2.lutimesSync = function(path, at, mt) {
216
- var fd = fs2.openSync(path, constants3.O_SYMLINK);
216
+ var fd = fs2.openSync(path, constants4.O_SYMLINK);
217
217
  var ret;
218
218
  var threw = true;
219
219
  try {
@@ -525,8 +525,8 @@ var require_graceful_fs = __commonJS({
525
525
  fs2.createReadStream = createReadStream2;
526
526
  fs2.createWriteStream = createWriteStream;
527
527
  var fs$readFile = fs2.readFile;
528
- fs2.readFile = readFile3;
529
- function readFile3(path, options, cb) {
528
+ fs2.readFile = readFile5;
529
+ function readFile5(path, options, cb) {
530
530
  if (typeof options === "function")
531
531
  cb = options, options = null;
532
532
  return go$readFile(path, options, cb);
@@ -542,8 +542,8 @@ var require_graceful_fs = __commonJS({
542
542
  }
543
543
  }
544
544
  var fs$writeFile = fs2.writeFile;
545
- fs2.writeFile = writeFile2;
546
- function writeFile2(path, data, options, cb) {
545
+ fs2.writeFile = writeFile3;
546
+ function writeFile3(path, data, options, cb) {
547
547
  if (typeof options === "function")
548
548
  cb = options, options = null;
549
549
  return go$writeFile(path, data, options, cb);
@@ -1235,7 +1235,7 @@ var require_mtime_precision = __commonJS({
1235
1235
  "node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js"(exports2, module2) {
1236
1236
  "use strict";
1237
1237
  var cacheSymbol = /* @__PURE__ */ Symbol();
1238
- function probe(file2, fs, callback) {
1238
+ function probe2(file2, fs, callback) {
1239
1239
  const cachedPrecision = fs[cacheSymbol];
1240
1240
  if (cachedPrecision) {
1241
1241
  return fs.stat(file2, (err, stat) => {
@@ -1267,7 +1267,7 @@ var require_mtime_precision = __commonJS({
1267
1267
  }
1268
1268
  return new Date(now);
1269
1269
  }
1270
- module2.exports.probe = probe;
1270
+ module2.exports.probe = probe2;
1271
1271
  module2.exports.getMtime = getMtime;
1272
1272
  }
1273
1273
  });
@@ -1532,12 +1532,12 @@ var require_adapter = __commonJS({
1532
1532
  return newFs;
1533
1533
  }
1534
1534
  function toPromise(method) {
1535
- return (...args) => new Promise((resolve3, reject) => {
1535
+ return (...args) => new Promise((resolve4, reject) => {
1536
1536
  args.push((err, result) => {
1537
1537
  if (err) {
1538
1538
  reject(err);
1539
1539
  } else {
1540
- resolve3(result);
1540
+ resolve4(result);
1541
1541
  }
1542
1542
  });
1543
1543
  method(...args);
@@ -2277,7 +2277,7 @@ function assertNotEqual(val) {
2277
2277
  return val;
2278
2278
  }
2279
2279
  function toZod() {
2280
- return (schema) => schema;
2280
+ return (schema2) => schema2;
2281
2281
  }
2282
2282
  function assertIs(_arg) {
2283
2283
  }
@@ -2370,8 +2370,8 @@ function rawShape(def) {
2370
2370
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
2371
2371
  return desc?.get ? desc.get.raw : desc?.value;
2372
2372
  }
2373
- function sourceShape(schema) {
2374
- return rawShape(schema._zod.def) ?? schema._zod.def.shape;
2373
+ function sourceShape(schema2) {
2374
+ return rawShape(schema2._zod.def) ?? schema2._zod.def.shape;
2375
2375
  }
2376
2376
  function deferProp(target, key, getter) {
2377
2377
  Object.defineProperty(target, key, {
@@ -2424,8 +2424,8 @@ function mergeDefs(...defs) {
2424
2424
  }
2425
2425
  return Object.defineProperties({}, mergedDescriptors);
2426
2426
  }
2427
- function cloneDef(schema) {
2428
- return mergeDefs(schema._zod.def);
2427
+ function cloneDef(schema2) {
2428
+ return mergeDefs(schema2._zod.def);
2429
2429
  }
2430
2430
  function getElementAtPath(obj, path) {
2431
2431
  if (!path)
@@ -2647,19 +2647,19 @@ var BIGINT_FORMAT_RANGES = {
2647
2647
  int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
2648
2648
  uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
2649
2649
  };
2650
- function pick(schema, mask) {
2651
- const currDef = schema._zod.def;
2650
+ function pick(schema2, mask) {
2651
+ const currDef = schema2._zod.def;
2652
2652
  const checks = currDef.checks;
2653
2653
  const hasChecks = checks && checks.length > 0;
2654
2654
  if (hasChecks) {
2655
2655
  throw new Error(".pick() cannot be used on object schemas containing refinements");
2656
2656
  }
2657
2657
  const newShape = {};
2658
- mirrorShape(newShape, schema, maskedKeys(schema, mask));
2659
- return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
2658
+ mirrorShape(newShape, schema2, maskedKeys(schema2, mask));
2659
+ return clone(schema2, mergeDefs(currDef, { shape: newShape, checks: [] }));
2660
2660
  }
2661
- function maskedKeys(schema, mask) {
2662
- const raw = sourceShape(schema);
2661
+ function maskedKeys(schema2, mask) {
2662
+ const raw = sourceShape(schema2);
2663
2663
  const keys = [];
2664
2664
  for (const key of Reflect.ownKeys(mask)) {
2665
2665
  if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
@@ -2670,45 +2670,45 @@ function maskedKeys(schema, mask) {
2670
2670
  }
2671
2671
  return keys;
2672
2672
  }
2673
- function omit(schema, mask) {
2674
- const currDef = schema._zod.def;
2673
+ function omit(schema2, mask) {
2674
+ const currDef = schema2._zod.def;
2675
2675
  const checks = currDef.checks;
2676
2676
  const hasChecks = checks && checks.length > 0;
2677
2677
  if (hasChecks) {
2678
2678
  throw new Error(".omit() cannot be used on object schemas containing refinements");
2679
2679
  }
2680
- const omitted = new Set(maskedKeys(schema, mask));
2680
+ const omitted = new Set(maskedKeys(schema2, mask));
2681
2681
  const newShape = {};
2682
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
2683
- return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
2682
+ mirrorShape(newShape, schema2, Reflect.ownKeys(sourceShape(schema2)).filter((key) => !omitted.has(key)));
2683
+ return clone(schema2, mergeDefs(currDef, { shape: newShape, checks: [] }));
2684
2684
  }
2685
- function extend(schema, shape) {
2685
+ function extend(schema2, shape) {
2686
2686
  if (!isPlainObject(shape)) {
2687
2687
  throw new Error("Invalid input to extend: expected a plain object");
2688
2688
  }
2689
- const checks = schema._zod.def.checks;
2689
+ const checks = schema2._zod.def.checks;
2690
2690
  const hasChecks = checks && checks.length > 0;
2691
2691
  if (hasChecks) {
2692
- const existingShape = sourceShape(schema);
2692
+ const existingShape = sourceShape(schema2);
2693
2693
  for (const key of Reflect.ownKeys(shape)) {
2694
2694
  if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
2695
2695
  throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
2696
2696
  }
2697
2697
  }
2698
2698
  }
2699
- return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
2699
+ return clone(schema2, mergeDefs(schema2._zod.def, { shape: extended(schema2, shape) }));
2700
2700
  }
2701
- function extended(schema, shape) {
2701
+ function extended(schema2, shape) {
2702
2702
  const newShape = {};
2703
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
2703
+ mirrorShape(newShape, schema2, Reflect.ownKeys(sourceShape(schema2)));
2704
2704
  mirrorProps(newShape, shape);
2705
2705
  return newShape;
2706
2706
  }
2707
- function safeExtend(schema, shape) {
2707
+ function safeExtend(schema2, shape) {
2708
2708
  if (!isPlainObject(shape)) {
2709
2709
  throw new Error("Invalid input to safeExtend: expected a plain object");
2710
2710
  }
2711
- return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
2711
+ return clone(schema2, mergeDefs(schema2._zod.def, { shape: extended(schema2, shape) }));
2712
2712
  }
2713
2713
  function merge(a, b) {
2714
2714
  if (!b?._zod?.def) {
@@ -2729,26 +2729,26 @@ function merge(a, b) {
2729
2729
  });
2730
2730
  return clone(a, def);
2731
2731
  }
2732
- function partial(Class2, schema, mask, name = "partial") {
2733
- const currDef = schema._zod.def;
2732
+ function partial(Class2, schema2, mask, name = "partial") {
2733
+ const currDef = schema2._zod.def;
2734
2734
  const checks = currDef.checks;
2735
2735
  const hasChecks = checks && checks.length > 0;
2736
2736
  if (hasChecks) {
2737
2737
  throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
2738
2738
  }
2739
- const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
2739
+ const selected = mask ? new Set(maskedKeys(schema2, mask)) : void 0;
2740
2740
  const newShape = {};
2741
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value, key) => selected && !selected.has(key) ? value : new Class2({ type: "optional", innerType: value })));
2742
- return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
2741
+ mirrorShape(newShape, schema2, Reflect.ownKeys(sourceShape(schema2)), Class2 && ((value, key) => selected && !selected.has(key) ? value : new Class2({ type: "optional", innerType: value })));
2742
+ return clone(schema2, mergeDefs(schema2._zod.def, { shape: newShape, checks: [] }));
2743
2743
  }
2744
- function required(Class2, schema, mask) {
2745
- const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
2744
+ function required(Class2, schema2, mask) {
2745
+ const selected = mask ? new Set(maskedKeys(schema2, mask)) : void 0;
2746
2746
  const newShape = {};
2747
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => (
2747
+ mirrorShape(newShape, schema2, Reflect.ownKeys(sourceShape(schema2)), (value, key) => (
2748
2748
  // overwrite with non-optional
2749
2749
  selected && !selected.has(key) ? value : new Class2({ type: "nonoptional", innerType: value })
2750
2750
  ));
2751
- return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
2751
+ return clone(schema2, mergeDefs(schema2._zod.def, { shape: newShape }));
2752
2752
  }
2753
2753
  function aborted(x, startIndex = 0) {
2754
2754
  if (x.aborted === true)
@@ -3365,9 +3365,9 @@ function finalizeParams(callee, params) {
3365
3365
  return { callee: params?.callee ?? callee, Err: params?.Err };
3366
3366
  }
3367
3367
  var _parse = (_Err) => {
3368
- const fn = (schema, value, _ctx, _params) => {
3368
+ const fn = (schema2, value, _ctx, _params) => {
3369
3369
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
3370
- const result = schema._zod.run({ value, issues: [] }, ctx);
3370
+ const result = schema2._zod.run({ value, issues: [] }, ctx);
3371
3371
  if (result instanceof Promise) {
3372
3372
  throw new $ZodAsyncError();
3373
3373
  }
@@ -3382,9 +3382,9 @@ var _parse = (_Err) => {
3382
3382
  };
3383
3383
  var parse = /* @__PURE__ */ _parse($ZodRealError);
3384
3384
  var _parseAsync = (_Err) => {
3385
- const fn = async (schema, value, _ctx, params) => {
3385
+ const fn = async (schema2, value, _ctx, params) => {
3386
3386
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
3387
- let result = schema._zod.run({ value, issues: [] }, ctx);
3387
+ let result = schema2._zod.run({ value, issues: [] }, ctx);
3388
3388
  if (result instanceof Promise)
3389
3389
  result = await result;
3390
3390
  if (result.issues.length) {
@@ -3397,9 +3397,9 @@ var _parseAsync = (_Err) => {
3397
3397
  return fn;
3398
3398
  };
3399
3399
  var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
3400
- var _safeParse = (_Err) => (schema, value, _ctx) => {
3400
+ var _safeParse = (_Err) => (schema2, value, _ctx) => {
3401
3401
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
3402
- const result = schema._zod.run({ value, issues: [] }, ctx);
3402
+ const result = schema2._zod.run({ value, issues: [] }, ctx);
3403
3403
  if (result instanceof Promise) {
3404
3404
  throw new $ZodAsyncError();
3405
3405
  }
@@ -3425,9 +3425,9 @@ function failure(Err, issues, ctx) {
3425
3425
  }
3426
3426
  };
3427
3427
  }
3428
- var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
3428
+ var _safeParseAsync = (_Err) => async (schema2, value, _ctx) => {
3429
3429
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
3430
- let result = schema._zod.run({ value, issues: [] }, ctx);
3430
+ let result = schema2._zod.run({ value, issues: [] }, ctx);
3431
3431
  if (result instanceof Promise)
3432
3432
  result = await result;
3433
3433
  return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
@@ -3435,88 +3435,88 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
3435
3435
  var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
3436
3436
  var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
3437
3437
  var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
3438
- var validate = ((schema, value, _ctx) => {
3439
- const validator = schema._zod.bag.validator;
3438
+ var validate = ((schema2, value, _ctx) => {
3439
+ const validator = schema2._zod.bag.validator;
3440
3440
  if (validator !== void 0) {
3441
3441
  if (validator(value) !== COMPILE_INVALID)
3442
3442
  return true;
3443
3443
  if (validator.definite === true && _ctx === void 0)
3444
3444
  return false;
3445
3445
  }
3446
- return validateFallback(schema, value, _ctx);
3446
+ return validateFallback(schema2, value, _ctx);
3447
3447
  });
3448
- function validateFallback(schema, value, _ctx) {
3448
+ function validateFallback(schema2, value, _ctx) {
3449
3449
  const ctx = _ctx ? { ..._ctx, async: false, abortEarly: true } : { async: false, abortEarly: true };
3450
- const fallbackRun = schema._zod.bag.fallbackRun;
3450
+ const fallbackRun = schema2._zod.bag.fallbackRun;
3451
3451
  let result;
3452
3452
  if (fallbackRun) {
3453
3453
  ctx[COMPILE_FALLBACK] = true;
3454
3454
  result = fallbackRun({ value, issues: [] }, ctx);
3455
3455
  } else {
3456
- result = schema._zod.run({ value, issues: [] }, ctx);
3456
+ result = schema2._zod.run({ value, issues: [] }, ctx);
3457
3457
  }
3458
3458
  if (result instanceof Promise) {
3459
3459
  throw new $ZodAsyncError();
3460
3460
  }
3461
3461
  return result.issues.length === 0;
3462
3462
  }
3463
- var validateAsync = async (schema, value, _ctx) => {
3463
+ var validateAsync = async (schema2, value, _ctx) => {
3464
3464
  const ctx = _ctx ? { ..._ctx, async: true, abortEarly: true } : { async: true, abortEarly: true };
3465
- let result = schema._zod.run({ value, issues: [] }, ctx);
3465
+ let result = schema2._zod.run({ value, issues: [] }, ctx);
3466
3466
  if (result instanceof Promise)
3467
3467
  result = await result;
3468
3468
  return result.issues.length === 0;
3469
3469
  };
3470
3470
  var _encode = (_Err) => {
3471
3471
  const parse3 = _parse(_Err);
3472
- const fn = (schema, value, _ctx, _params) => {
3472
+ const fn = (schema2, value, _ctx, _params) => {
3473
3473
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
3474
- return parse3(schema, value, ctx, finalizeParams(fn, _params));
3474
+ return parse3(schema2, value, ctx, finalizeParams(fn, _params));
3475
3475
  };
3476
3476
  return fn;
3477
3477
  };
3478
3478
  var encode = /* @__PURE__ */ _encode($ZodRealError);
3479
3479
  var _decode = (_Err) => {
3480
3480
  const parse3 = _parse(_Err);
3481
- const fn = (schema, value, _ctx, _params) => {
3482
- return parse3(schema, value, _ctx, finalizeParams(fn, _params));
3481
+ const fn = (schema2, value, _ctx, _params) => {
3482
+ return parse3(schema2, value, _ctx, finalizeParams(fn, _params));
3483
3483
  };
3484
3484
  return fn;
3485
3485
  };
3486
3486
  var decode = /* @__PURE__ */ _decode($ZodRealError);
3487
3487
  var _encodeAsync = (_Err) => {
3488
3488
  const parseAsync3 = _parseAsync(_Err);
3489
- const fn = async (schema, value, _ctx, _params) => {
3489
+ const fn = async (schema2, value, _ctx, _params) => {
3490
3490
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
3491
- return await parseAsync3(schema, value, ctx, finalizeParams(fn, _params));
3491
+ return await parseAsync3(schema2, value, ctx, finalizeParams(fn, _params));
3492
3492
  };
3493
3493
  return fn;
3494
3494
  };
3495
3495
  var encodeAsync = /* @__PURE__ */ _encodeAsync($ZodRealError);
3496
3496
  var _decodeAsync = (_Err) => {
3497
3497
  const parseAsync3 = _parseAsync(_Err);
3498
- const fn = async (schema, value, _ctx, _params) => {
3499
- return await parseAsync3(schema, value, _ctx, finalizeParams(fn, _params));
3498
+ const fn = async (schema2, value, _ctx, _params) => {
3499
+ return await parseAsync3(schema2, value, _ctx, finalizeParams(fn, _params));
3500
3500
  };
3501
3501
  return fn;
3502
3502
  };
3503
3503
  var decodeAsync = /* @__PURE__ */ _decodeAsync($ZodRealError);
3504
- var _safeEncode = (_Err) => (schema, value, _ctx) => {
3504
+ var _safeEncode = (_Err) => (schema2, value, _ctx) => {
3505
3505
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
3506
- return _safeParse(_Err)(schema, value, ctx);
3506
+ return _safeParse(_Err)(schema2, value, ctx);
3507
3507
  };
3508
3508
  var safeEncode = /* @__PURE__ */ _safeEncode($ZodRealError);
3509
- var _safeDecode = (_Err) => (schema, value, _ctx) => {
3510
- return _safeParse(_Err)(schema, value, _ctx);
3509
+ var _safeDecode = (_Err) => (schema2, value, _ctx) => {
3510
+ return _safeParse(_Err)(schema2, value, _ctx);
3511
3511
  };
3512
3512
  var safeDecode = /* @__PURE__ */ _safeDecode($ZodRealError);
3513
- var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
3513
+ var _safeEncodeAsync = (_Err) => async (schema2, value, _ctx) => {
3514
3514
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
3515
- return _safeParseAsync(_Err)(schema, value, ctx);
3515
+ return _safeParseAsync(_Err)(schema2, value, ctx);
3516
3516
  };
3517
3517
  var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
3518
- var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
3519
- return _safeParseAsync(_Err)(schema, value, _ctx);
3518
+ var _safeDecodeAsync = (_Err) => async (schema2, value, _ctx) => {
3519
+ return _safeParseAsync(_Err)(schema2, value, _ctx);
3520
3520
  };
3521
3521
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
3522
3522
 
@@ -3620,8 +3620,8 @@ function emoji() {
3620
3620
  }
3621
3621
  var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
3622
3622
  var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
3623
- var mac = (delimiter) => {
3624
- const escapedDelim = escapeRegex(delimiter ?? ":");
3623
+ var mac = (delimiter2) => {
3624
+ const escapedDelim = escapeRegex(delimiter2 ?? ":");
3625
3625
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
3626
3626
  };
3627
3627
  var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
@@ -4132,8 +4132,8 @@ var $ZodCheckProperties = /* @__PURE__ */ $constructor("$ZodCheckProperties", (i
4132
4132
  entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
4133
4133
  const input2 = payload.value;
4134
4134
  let proms;
4135
- for (const [key, schema] of entries) {
4136
- const result = schema._zod.run({ value: input2[key], issues: [] }, {});
4135
+ for (const [key, schema2] of entries) {
4136
+ const result = schema2._zod.run({ value: input2[key], issues: [] }, {});
4137
4137
  if (result instanceof Promise) {
4138
4138
  proms ?? (proms = []);
4139
4139
  proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload, key)));
@@ -5253,10 +5253,10 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
5253
5253
  const id = ids[key];
5254
5254
  const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
5255
5255
  const isPresent = `${k} in input`;
5256
- const schema = shape[key];
5257
- const optin = schema?._zod?.optin;
5256
+ const schema2 = shape[key];
5257
+ const optin = schema2?._zod?.optin;
5258
5258
  const isOptionalIn = optin !== void 0;
5259
- const isOptionalOut = schema?._zod?.optout === "optional";
5259
+ const isOptionalOut = schema2?._zod?.optout === "optional";
5260
5260
  doc.write(`const ${id} = ${parseStr(k)};`);
5261
5261
  if (isOptionalIn && isOptionalOut) {
5262
5262
  const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
@@ -6437,8 +6437,8 @@ function handleReadonlyResult(payload) {
6437
6437
  payload.value = Object.freeze(payload.value);
6438
6438
  return payload;
6439
6439
  }
6440
- function leafPattern(schema) {
6441
- const def = schema._zod.def;
6440
+ function leafPattern(schema2) {
6441
+ const def = schema2._zod.def;
6442
6442
  let pattern = def.pattern;
6443
6443
  let isInt = !!def.format?.includes("int");
6444
6444
  let minimum;
@@ -6461,13 +6461,13 @@ function leafPattern(schema) {
6461
6461
  return "(?!)";
6462
6462
  if (minimum !== void 0 || maximum !== void 0)
6463
6463
  return string({ minimum, maximum }).source;
6464
- const own2 = schema._zod.pattern;
6464
+ const own2 = schema2._zod.pattern;
6465
6465
  return (isInt && own2 === number ? integer : own2)?.source;
6466
6466
  }
6467
- function partPattern(schema) {
6468
- const def = schema._zod.def;
6469
- const own2 = schema._zod.pattern?.source;
6470
- const inner = def.innerType ?? schema._zod.innerType;
6467
+ function partPattern(schema2) {
6468
+ const def = schema2._zod.def;
6469
+ const own2 = schema2._zod.pattern?.source;
6470
+ const inner = def.innerType ?? schema2._zod.innerType;
6471
6471
  if (inner) {
6472
6472
  const before = inner._zod.pattern?.source;
6473
6473
  const after = partPattern(inner);
@@ -6481,7 +6481,7 @@ function partPattern(schema) {
6481
6481
  if (sources2.every(Boolean))
6482
6482
  return `^(${sources2.map((s) => cleanRegex(s)).join("|")})$`;
6483
6483
  }
6484
- return leafPattern(schema);
6484
+ return leafPattern(schema2);
6485
6485
  }
6486
6486
  var $ZodTemplateLiteral = /* @__PURE__ */ $constructor("$ZodTemplateLiteral", (inst, def) => {
6487
6487
  $ZodType.init(inst, def);
@@ -6677,7 +6677,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
6677
6677
  var NONE = 0;
6678
6678
  var ASSUMED = 1;
6679
6679
  var PROVEN = 2;
6680
- function isRecursive(inst, stack, resolve3) {
6680
+ function isRecursive(inst, stack, resolve4) {
6681
6681
  const cached2 = recursive.get(inst);
6682
6682
  if (cached2 !== void 0)
6683
6683
  return cached2 ? PROVEN : NONE;
@@ -6687,7 +6687,7 @@ function isRecursive(inst, stack, resolve3) {
6687
6687
  let result = NONE;
6688
6688
  const check2 = (child) => {
6689
6689
  if (result !== PROVEN && child?._zod) {
6690
- const answer = isRecursive(child, stack, resolve3);
6690
+ const answer = isRecursive(child, stack, resolve4);
6691
6691
  if (answer > result)
6692
6692
  result = answer;
6693
6693
  }
@@ -6698,7 +6698,7 @@ function isRecursive(inst, stack, resolve3) {
6698
6698
  const desc = Object.getOwnPropertyDescriptor(sh, key);
6699
6699
  if (spread && !desc.enumerable)
6700
6700
  continue;
6701
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve3) : NONE;
6701
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve4) : NONE;
6702
6702
  if (child > answer)
6703
6703
  answer = child;
6704
6704
  }
@@ -6762,7 +6762,7 @@ function isRecursive(inst, stack, resolve3) {
6762
6762
  break;
6763
6763
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
6764
6764
  case "lazy": {
6765
- const inner = def._cachedInner ?? (resolve3 ? inst._zod.innerType : void 0);
6765
+ const inner = def._cachedInner ?? (resolve4 ? inst._zod.innerType : void 0);
6766
6766
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
6767
6767
  break;
6768
6768
  }
@@ -14511,11 +14511,11 @@ var $ZodRegistry = class {
14511
14511
  this._map = /* @__PURE__ */ new WeakMap();
14512
14512
  this._idmap = /* @__PURE__ */ new Map();
14513
14513
  }
14514
- add(schema, ..._meta) {
14514
+ add(schema2, ..._meta) {
14515
14515
  const meta3 = _meta[0];
14516
- this._map.set(schema, meta3);
14516
+ this._map.set(schema2, meta3);
14517
14517
  if (meta3 && typeof meta3 === "object" && "id" in meta3) {
14518
- this._idmap.set(meta3.id, schema);
14518
+ this._idmap.set(meta3.id, schema2);
14519
14519
  }
14520
14520
  return this;
14521
14521
  }
@@ -14524,26 +14524,26 @@ var $ZodRegistry = class {
14524
14524
  this._idmap = /* @__PURE__ */ new Map();
14525
14525
  return this;
14526
14526
  }
14527
- remove(schema) {
14528
- const meta3 = this._map.get(schema);
14527
+ remove(schema2) {
14528
+ const meta3 = this._map.get(schema2);
14529
14529
  if (meta3 && typeof meta3 === "object" && "id" in meta3) {
14530
14530
  this._idmap.delete(meta3.id);
14531
14531
  }
14532
- this._map.delete(schema);
14532
+ this._map.delete(schema2);
14533
14533
  return this;
14534
14534
  }
14535
- get(schema) {
14536
- const p = schema._zod.parent;
14535
+ get(schema2) {
14536
+ const p = schema2._zod.parent;
14537
14537
  if (p) {
14538
14538
  const pm = { ...this.get(p) ?? {} };
14539
14539
  delete pm.id;
14540
- const f = { ...pm, ...this._map.get(schema) };
14540
+ const f = { ...pm, ...this._map.get(schema2) };
14541
14541
  return Object.keys(f).length ? f : void 0;
14542
14542
  }
14543
- return this._map.get(schema);
14543
+ return this._map.get(schema2);
14544
14544
  }
14545
- has(schema) {
14546
- return this._map.has(schema);
14545
+ has(schema2) {
14546
+ return this._map.has(schema2);
14547
14547
  }
14548
14548
  };
14549
14549
  function registry() {
@@ -14568,31 +14568,31 @@ var ZodCompileUnsupportedError = class extends Error {
14568
14568
  this.islandable = islandable;
14569
14569
  }
14570
14570
  };
14571
- function compileValidator(schema, parser) {
14571
+ function compileValidator(schema2, parser) {
14572
14572
  try {
14573
- return compileFn(schema, { assertOnly: true });
14573
+ return compileFn(schema2, { assertOnly: true });
14574
14574
  } catch {
14575
14575
  return parser;
14576
14576
  }
14577
14577
  }
14578
- function compile(schema, options) {
14578
+ function compile(schema2, options) {
14579
14579
  try {
14580
- const parser = compileFn(schema);
14581
- const clone2 = withParser(schema, parser);
14582
- clone2._zod.bag.validator = compileValidator(schema, parser);
14580
+ const parser = compileFn(schema2);
14581
+ const clone2 = withParser(schema2, parser);
14582
+ clone2._zod.bag.validator = compileValidator(schema2, parser);
14583
14583
  return clone2;
14584
14584
  } catch (err) {
14585
14585
  if (options?.strict)
14586
14586
  throw err;
14587
- return schema;
14587
+ return schema2;
14588
14588
  }
14589
14589
  }
14590
- function withParser(schema, parser) {
14591
- if (isRecursiveSchema(schema)) {
14590
+ function withParser(schema2, parser) {
14591
+ if (isRecursiveSchema(schema2)) {
14592
14592
  throw new ZodCompileUnsupportedError("a schema whose subtree contains a reference cycle");
14593
14593
  }
14594
- const clone2 = clone(schema);
14595
- const liveRun = schema._zod.run;
14594
+ const clone2 = clone(schema2);
14595
+ const liveRun = schema2._zod.run;
14596
14596
  const originalRun = liveRun.__originalRun ?? liveRun;
14597
14597
  const wrapped = (payload, ctx) => {
14598
14598
  if (ctx?.async || ctx?.direction === "backward" || ctx?.skipChecks || ctx?.[FALLBACK_FLAG]) {
@@ -14615,7 +14615,7 @@ function withParser(schema, parser) {
14615
14615
  clone2._zod.bag.validator = parser;
14616
14616
  clone2._zod.run = wrapped;
14617
14617
  if (!liveRun.__originalRun)
14618
- installCompiledUserMethods(clone2, schema, parser);
14618
+ installCompiledUserMethods(clone2, schema2, parser);
14619
14619
  return clone2;
14620
14620
  }
14621
14621
  function installCompiledUserMethods(target, source, parser) {
@@ -14642,10 +14642,10 @@ function installCompiledUserMethods(target, source, parser) {
14642
14642
  };
14643
14643
  }
14644
14644
  }
14645
- function compileFn(schema, options) {
14645
+ function compileFn(schema2, options) {
14646
14646
  let recursive2 = true;
14647
14647
  try {
14648
- recursive2 = isRecursiveSchema(schema);
14648
+ recursive2 = isRecursiveSchema(schema2);
14649
14649
  } catch {
14650
14650
  }
14651
14651
  if (recursive2) {
@@ -14658,7 +14658,7 @@ function compileFn(schema, options) {
14658
14658
  definite: true
14659
14659
  };
14660
14660
  const doc = new Doc(["input"]);
14661
- const outputAccessor = generateCheck(doc, ctx, schema, "input", !options?.assertOnly);
14661
+ const outputAccessor = generateCheck(doc, ctx, schema2, "input", !options?.assertOnly);
14662
14662
  doc.write(outputAccessor === null ? `return true;` : `return ${outputAccessor};`);
14663
14663
  const constantNames = ["INVALID", ...ctx.constants.keys()];
14664
14664
  const constantValues = [INVALID, ...ctx.constants.values()];
@@ -14698,20 +14698,20 @@ function addUserConstant(ctx, fn) {
14698
14698
  function newVar(ctx) {
14699
14699
  return `v${ctx.varCounter++}`;
14700
14700
  }
14701
- function runtimeRun(schema, value) {
14702
- const result = schema._zod.run({ value, issues: [] }, {});
14701
+ function runtimeRun(schema2, value) {
14702
+ const result = schema2._zod.run({ value, issues: [] }, {});
14703
14703
  if (result && typeof result.then === "function")
14704
14704
  return INVALID;
14705
14705
  const r = result;
14706
14706
  return r.issues.length === 0 ? r.value : INVALID;
14707
14707
  }
14708
- function compileChild(doc, ctx, schema, accessor, needsValue = true) {
14708
+ function compileChild(doc, ctx, schema2, accessor, needsValue = true) {
14709
14709
  const contentLen = doc.content.length;
14710
14710
  const constantCount = ctx.constants.size;
14711
14711
  const constantCounter = ctx.constantCounter;
14712
14712
  const varCounter = ctx.varCounter;
14713
14713
  try {
14714
- return generateCheck(doc, ctx, schema, accessor, needsValue);
14714
+ return generateCheck(doc, ctx, schema2, accessor, needsValue);
14715
14715
  } catch (err) {
14716
14716
  if (!(err instanceof ZodCompileUnsupportedError) || !err.islandable)
14717
14717
  throw err;
@@ -14723,12 +14723,12 @@ function compileChild(doc, ctx, schema, accessor, needsValue = true) {
14723
14723
  }
14724
14724
  ctx.constantCounter = constantCounter;
14725
14725
  ctx.varCounter = varCounter;
14726
- return emitRuntimeIsland(doc, ctx, schema, accessor);
14726
+ return emitRuntimeIsland(doc, ctx, schema2, accessor);
14727
14727
  }
14728
14728
  }
14729
- function emitRuntimeIsland(doc, ctx, schema, accessor) {
14729
+ function emitRuntimeIsland(doc, ctx, schema2, accessor) {
14730
14730
  ctx.definite = false;
14731
- const schemaConst = addConstant(ctx, schema);
14731
+ const schemaConst = addConstant(ctx, schema2);
14732
14732
  const runConst = addConstant(ctx, runtimeRun);
14733
14733
  const outVar = newVar(ctx);
14734
14734
  doc.write(`const ${outVar} = ${runConst}(${schemaConst}, ${accessor});`);
@@ -14743,8 +14743,8 @@ var WHEN_DEFAULTED_CHECKS = /* @__PURE__ */ new Set([
14743
14743
  "min_length",
14744
14744
  "length_equals"
14745
14745
  ]);
14746
- function generateChecks(doc, ctx, schema, accessor) {
14747
- const schemaChecks = schema._zod.def.checks;
14746
+ function generateChecks(doc, ctx, schema2, accessor) {
14747
+ const schemaChecks = schema2._zod.def.checks;
14748
14748
  if (!schemaChecks || schemaChecks.length === 0)
14749
14749
  return accessor;
14750
14750
  let currentAccessor = accessor;
@@ -15119,8 +15119,8 @@ function generateStringFormatCheck(doc, ctx, def, accessor, needsValue = true) {
15119
15119
  }
15120
15120
  return accessor;
15121
15121
  }
15122
- function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
15123
- const def = schema._zod.def;
15122
+ function generateCheck(doc, ctx, schema2, accessor, needsValue = true) {
15123
+ const def = schema2._zod.def;
15124
15124
  const type = def.type;
15125
15125
  if (def.coerce) {
15126
15126
  throw new ZodCompileUnsupportedError(`coercion (z.coerce.${type}())`);
@@ -15129,16 +15129,16 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
15129
15129
  let typeAccessor;
15130
15130
  switch (type) {
15131
15131
  case "string":
15132
- typeAccessor = generateStringCheck(doc, ctx, schema, accessor, buildsValue);
15132
+ typeAccessor = generateStringCheck(doc, ctx, schema2, accessor, buildsValue);
15133
15133
  break;
15134
15134
  case "number":
15135
- typeAccessor = generateNumberCheck(doc, schema, accessor);
15135
+ typeAccessor = generateNumberCheck(doc, schema2, accessor);
15136
15136
  break;
15137
15137
  case "boolean":
15138
15138
  typeAccessor = generateBooleanCheck(doc, accessor);
15139
15139
  break;
15140
15140
  case "bigint":
15141
- typeAccessor = generateBigIntCheck(doc, schema, accessor);
15141
+ typeAccessor = generateBigIntCheck(doc, schema2, accessor);
15142
15142
  break;
15143
15143
  case "symbol":
15144
15144
  typeAccessor = generateSymbolCheck(doc, accessor);
@@ -15167,79 +15167,79 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
15167
15167
  typeAccessor = generateDateCheck(doc, accessor);
15168
15168
  break;
15169
15169
  case "object":
15170
- typeAccessor = generateObjectCheck(doc, ctx, schema, accessor, buildsValue);
15170
+ typeAccessor = generateObjectCheck(doc, ctx, schema2, accessor, buildsValue);
15171
15171
  break;
15172
15172
  case "optional":
15173
- typeAccessor = generateOptionalCheck(doc, ctx, schema, accessor, buildsValue);
15173
+ typeAccessor = generateOptionalCheck(doc, ctx, schema2, accessor, buildsValue);
15174
15174
  break;
15175
15175
  case "nullable":
15176
- typeAccessor = generateNullableCheck(doc, ctx, schema, accessor, buildsValue);
15176
+ typeAccessor = generateNullableCheck(doc, ctx, schema2, accessor, buildsValue);
15177
15177
  break;
15178
15178
  case "array":
15179
- typeAccessor = generateArrayCheck(doc, ctx, schema, accessor, buildsValue);
15179
+ typeAccessor = generateArrayCheck(doc, ctx, schema2, accessor, buildsValue);
15180
15180
  break;
15181
15181
  case "literal":
15182
- typeAccessor = generateLiteralCheck(doc, ctx, schema, accessor);
15182
+ typeAccessor = generateLiteralCheck(doc, ctx, schema2, accessor);
15183
15183
  break;
15184
15184
  case "enum":
15185
- typeAccessor = generateEnumCheck(doc, ctx, schema, accessor);
15185
+ typeAccessor = generateEnumCheck(doc, ctx, schema2, accessor);
15186
15186
  break;
15187
15187
  case "readonly": {
15188
- const innerOut = generateWrapperCheck(doc, ctx, schema, accessor);
15188
+ const innerOut = generateWrapperCheck(doc, ctx, schema2, accessor);
15189
15189
  const frozenVar = newVar(ctx);
15190
15190
  doc.write(`const ${frozenVar} = Object.freeze(${innerOut});`);
15191
15191
  typeAccessor = frozenVar;
15192
15192
  break;
15193
15193
  }
15194
15194
  case "success":
15195
- generateWrapperCheck(doc, ctx, schema, accessor);
15195
+ generateWrapperCheck(doc, ctx, schema2, accessor);
15196
15196
  typeAccessor = "true";
15197
15197
  break;
15198
15198
  case "default":
15199
15199
  case "prefault":
15200
- typeAccessor = generateDefaultCheck(doc, ctx, schema, accessor);
15200
+ typeAccessor = generateDefaultCheck(doc, ctx, schema2, accessor);
15201
15201
  break;
15202
15202
  case "nonoptional":
15203
- typeAccessor = generateNonOptionalCheck(doc, ctx, schema, accessor);
15203
+ typeAccessor = generateNonOptionalCheck(doc, ctx, schema2, accessor);
15204
15204
  break;
15205
15205
  case "tuple":
15206
- typeAccessor = generateTupleCheck(doc, ctx, schema, accessor);
15206
+ typeAccessor = generateTupleCheck(doc, ctx, schema2, accessor);
15207
15207
  break;
15208
15208
  case "union":
15209
- typeAccessor = generateUnionCheck(doc, ctx, schema, accessor);
15209
+ typeAccessor = generateUnionCheck(doc, ctx, schema2, accessor);
15210
15210
  break;
15211
15211
  case "intersection":
15212
- typeAccessor = generateIntersectionCheck(doc, ctx, schema, accessor);
15212
+ typeAccessor = generateIntersectionCheck(doc, ctx, schema2, accessor);
15213
15213
  break;
15214
15214
  case "record":
15215
- typeAccessor = generateRecordCheck(doc, ctx, schema, accessor);
15215
+ typeAccessor = generateRecordCheck(doc, ctx, schema2, accessor);
15216
15216
  break;
15217
15217
  case "map":
15218
- typeAccessor = generateMapCheck(doc, ctx, schema, accessor);
15218
+ typeAccessor = generateMapCheck(doc, ctx, schema2, accessor);
15219
15219
  break;
15220
15220
  case "set":
15221
- typeAccessor = generateSetCheck(doc, ctx, schema, accessor);
15221
+ typeAccessor = generateSetCheck(doc, ctx, schema2, accessor);
15222
15222
  break;
15223
15223
  case "file":
15224
15224
  typeAccessor = generateFileCheck(doc, accessor);
15225
15225
  break;
15226
15226
  case "template_literal":
15227
- typeAccessor = generateTemplateLiteralCheck(doc, ctx, schema, accessor);
15227
+ typeAccessor = generateTemplateLiteralCheck(doc, ctx, schema2, accessor);
15228
15228
  break;
15229
15229
  case "lazy":
15230
- typeAccessor = generateLazyCheck(doc, ctx, schema, accessor);
15230
+ typeAccessor = generateLazyCheck(doc, ctx, schema2, accessor);
15231
15231
  break;
15232
15232
  case "pipe":
15233
- typeAccessor = generatePipeCheck(doc, ctx, schema, accessor);
15233
+ typeAccessor = generatePipeCheck(doc, ctx, schema2, accessor);
15234
15234
  break;
15235
15235
  case "custom":
15236
- typeAccessor = generateCustomCheck(doc, ctx, schema, accessor);
15236
+ typeAccessor = generateCustomCheck(doc, ctx, schema2, accessor);
15237
15237
  break;
15238
15238
  case "transform":
15239
- typeAccessor = generateTransformCheck(doc, ctx, schema, accessor);
15239
+ typeAccessor = generateTransformCheck(doc, ctx, schema2, accessor);
15240
15240
  break;
15241
15241
  case "catch":
15242
- typeAccessor = generateCatchCheck(doc, ctx, schema, accessor);
15242
+ typeAccessor = generateCatchCheck(doc, ctx, schema2, accessor);
15243
15243
  break;
15244
15244
  default: {
15245
15245
  void type;
@@ -15248,18 +15248,18 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
15248
15248
  }
15249
15249
  if (typeAccessor === null)
15250
15250
  return null;
15251
- return generateChecks(doc, ctx, schema, typeAccessor);
15251
+ return generateChecks(doc, ctx, schema2, typeAccessor);
15252
15252
  }
15253
- function generateStringCheck(doc, ctx, schema, accessor, needsValue = true) {
15253
+ function generateStringCheck(doc, ctx, schema2, accessor, needsValue = true) {
15254
15254
  doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
15255
- const def = schema._zod.def;
15255
+ const def = schema2._zod.def;
15256
15256
  if (def.format === void 0)
15257
15257
  return accessor;
15258
15258
  return generateStringFormatCheck(doc, ctx, def, accessor, needsValue);
15259
15259
  }
15260
- function generateNumberCheck(doc, schema, accessor) {
15260
+ function generateNumberCheck(doc, schema2, accessor) {
15261
15261
  doc.write(`if (typeof ${accessor} !== "number" || !Number.isFinite(${accessor})) return INVALID;`);
15262
- const def = schema._zod.def;
15262
+ const def = schema2._zod.def;
15263
15263
  if (def.check === "number_format" && def.format) {
15264
15264
  generateNumberFormatCheck(doc, { format: def.format }, accessor);
15265
15265
  }
@@ -15269,9 +15269,9 @@ function generateBooleanCheck(doc, accessor) {
15269
15269
  doc.write(`if (typeof ${accessor} !== "boolean") return INVALID;`);
15270
15270
  return accessor;
15271
15271
  }
15272
- function generateBigIntCheck(doc, schema, accessor) {
15272
+ function generateBigIntCheck(doc, schema2, accessor) {
15273
15273
  doc.write(`if (typeof ${accessor} !== "bigint") return INVALID;`);
15274
- const def = schema._zod.def;
15274
+ const def = schema2._zod.def;
15275
15275
  if (def.format) {
15276
15276
  switch (def.format) {
15277
15277
  case "int64":
@@ -15308,8 +15308,8 @@ function generateDateCheck(doc, accessor) {
15308
15308
  doc.write(`if (!(${accessor} instanceof Date) || Number.isNaN(${accessor}.getTime())) return INVALID;`);
15309
15309
  return accessor;
15310
15310
  }
15311
- function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
15312
- const def = schema._zod.def;
15311
+ function generateObjectCheck(doc, ctx, schema2, accessor, buildsValue = true) {
15312
+ const def = schema2._zod.def;
15313
15313
  doc.write(`if (typeof ${accessor} !== "object" || ${accessor} === null || Array.isArray(${accessor})) return INVALID;`);
15314
15314
  const shape = def.shape;
15315
15315
  const keys = Object.keys(shape);
@@ -15427,9 +15427,9 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
15427
15427
  }
15428
15428
  return outputVar;
15429
15429
  }
15430
- function generateOptionalCheck(doc, ctx, schema, accessor, buildsValue = true) {
15431
- const def = schema._zod.def;
15432
- if (isExactOptional(schema)) {
15430
+ function generateOptionalCheck(doc, ctx, schema2, accessor, buildsValue = true) {
15431
+ const def = schema2._zod.def;
15432
+ if (isExactOptional(schema2)) {
15433
15433
  return generateCheck(doc, ctx, def.innerType, accessor, buildsValue);
15434
15434
  }
15435
15435
  if (def.innerType._zod.optin === "defaulted") {
@@ -15466,16 +15466,16 @@ function generateOptionalCheck(doc, ctx, schema, accessor, buildsValue = true) {
15466
15466
  doc.write(`}`);
15467
15467
  return outputVar;
15468
15468
  }
15469
- function isExactOptional(schema) {
15470
- return schema._zod.traits?.has("$ZodExactOptional") === true;
15469
+ function isExactOptional(schema2) {
15470
+ return schema2._zod.traits?.has("$ZodExactOptional") === true;
15471
15471
  }
15472
- function requiresPresenceCheck(schema) {
15473
- return schema._zod.optin === void 0 && fastPathAcceptsAbsence(schema);
15472
+ function requiresPresenceCheck(schema2) {
15473
+ return schema2._zod.optin === void 0 && fastPathAcceptsAbsence(schema2);
15474
15474
  }
15475
- function fastPathAcceptsAbsence(schema) {
15476
- if (schema._zod.def.coerce)
15475
+ function fastPathAcceptsAbsence(schema2) {
15476
+ if (schema2._zod.def.coerce)
15477
15477
  return true;
15478
- const def = schema._zod.def;
15478
+ const def = schema2._zod.def;
15479
15479
  switch (def.type) {
15480
15480
  case "any":
15481
15481
  case "unknown":
@@ -15510,7 +15510,7 @@ function fastPathAcceptsAbsence(schema) {
15510
15510
  case "literal":
15511
15511
  return !!def.values?.includes(void 0);
15512
15512
  case "enum":
15513
- return !!schema._zod.values?.has(void 0);
15513
+ return !!schema2._zod.values?.has(void 0);
15514
15514
  case "optional":
15515
15515
  case "nullable":
15516
15516
  case "readonly":
@@ -15530,14 +15530,14 @@ function fastPathAcceptsAbsence(schema) {
15530
15530
  return true;
15531
15531
  }
15532
15532
  }
15533
- function dropsWhenAbsent(schema) {
15534
- return schema._zod.optin === "optional" && schema._zod.optout === "optional";
15533
+ function dropsWhenAbsent(schema2) {
15534
+ return schema2._zod.optin === "optional" && schema2._zod.optout === "optional";
15535
15535
  }
15536
- function mayOmitUndefined(schema) {
15537
- return (schema._zod.optin !== "defaulted" || schema._zod.optout === "optional") && mayOutputUndefined(schema);
15536
+ function mayOmitUndefined(schema2) {
15537
+ return (schema2._zod.optin !== "defaulted" || schema2._zod.optout === "optional") && mayOutputUndefined(schema2);
15538
15538
  }
15539
- function mayOutputUndefined(schema) {
15540
- const def = schema._zod.def;
15539
+ function mayOutputUndefined(schema2) {
15540
+ const def = schema2._zod.def;
15541
15541
  switch (def.type) {
15542
15542
  case "string":
15543
15543
  case "number":
@@ -15561,7 +15561,7 @@ function mayOutputUndefined(schema) {
15561
15561
  case "literal":
15562
15562
  return !!def.values?.includes(void 0);
15563
15563
  case "enum":
15564
- return !!schema._zod.values?.has(void 0);
15564
+ return !!schema2._zod.values?.has(void 0);
15565
15565
  case "optional":
15566
15566
  return true;
15567
15567
  case "nullable":
@@ -15578,8 +15578,8 @@ function mayOutputUndefined(schema) {
15578
15578
  return true;
15579
15579
  }
15580
15580
  }
15581
- function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
15582
- const def = schema._zod.def;
15581
+ function generateNullableCheck(doc, ctx, schema2, accessor, buildsValue = true) {
15582
+ const def = schema2._zod.def;
15583
15583
  const outputVar = buildsValue ? newVar(ctx) : null;
15584
15584
  if (outputVar)
15585
15585
  doc.write(`let ${outputVar} = null;`);
@@ -15592,15 +15592,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
15592
15592
  doc.write(`}`);
15593
15593
  return outputVar;
15594
15594
  }
15595
- function generateSizeGate(doc, schema, size) {
15596
- for (const [max, check2] of sizeCaps(schema._zod.def.checks)) {
15595
+ function generateSizeGate(doc, schema2, size) {
15596
+ for (const [max, check2] of sizeCaps(schema2._zod.def.checks)) {
15597
15597
  doc.write(`if (${size} > ${numericOperand(max, check2._zod.def.check)}) return INVALID;`);
15598
15598
  }
15599
15599
  }
15600
- function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
15601
- const def = schema._zod.def;
15600
+ function generateArrayCheck(doc, ctx, schema2, accessor, buildsValue = true) {
15601
+ const def = schema2._zod.def;
15602
15602
  doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
15603
- generateSizeGate(doc, schema, `${accessor}.length`);
15603
+ generateSizeGate(doc, schema2, `${accessor}.length`);
15604
15604
  const outputVar = buildsValue ? newVar(ctx) : null;
15605
15605
  const iVar = newVar(ctx);
15606
15606
  const elemVar = newVar(ctx);
@@ -15616,8 +15616,8 @@ function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
15616
15616
  doc.write(`}`);
15617
15617
  return outputVar;
15618
15618
  }
15619
- function generateLiteralCheck(doc, ctx, schema, accessor) {
15620
- const def = schema._zod.def;
15619
+ function generateLiteralCheck(doc, ctx, schema2, accessor) {
15620
+ const def = schema2._zod.def;
15621
15621
  const values = def.values;
15622
15622
  if (values.length !== 1) {
15623
15623
  const literalSet = addConstant(ctx, new Set(values));
@@ -15645,8 +15645,8 @@ function generateLiteralCheck(doc, ctx, schema, accessor) {
15645
15645
  }
15646
15646
  return accessor;
15647
15647
  }
15648
- function generateEnumCheck(doc, ctx, schema, accessor) {
15649
- const values = schema._zod.values;
15648
+ function generateEnumCheck(doc, ctx, schema2, accessor) {
15649
+ const values = schema2._zod.values;
15650
15650
  if (!values) {
15651
15651
  throw new ZodCompileUnsupportedError("enum schema without enumerated values");
15652
15652
  }
@@ -15654,15 +15654,15 @@ function generateEnumCheck(doc, ctx, schema, accessor) {
15654
15654
  doc.write(`if (!${enumSet}.has(${accessor})) return INVALID;`);
15655
15655
  return accessor;
15656
15656
  }
15657
- function generateWrapperCheck(doc, ctx, schema, accessor) {
15658
- const def = schema._zod.def;
15657
+ function generateWrapperCheck(doc, ctx, schema2, accessor) {
15658
+ const def = schema2._zod.def;
15659
15659
  return generateCheck(doc, ctx, def.innerType, accessor);
15660
15660
  }
15661
- function generateDefaultCheck(doc, ctx, schema, accessor) {
15662
- const def = schema._zod.def;
15663
- const descriptor = Object.getOwnPropertyDescriptor(schema._zod.def, "defaultValue");
15664
- const defaultGetter = descriptor ? () => schema._zod.def.defaultValue : void 0;
15665
- if (schema._zod.def.type === "prefault") {
15661
+ function generateDefaultCheck(doc, ctx, schema2, accessor) {
15662
+ const def = schema2._zod.def;
15663
+ const descriptor = Object.getOwnPropertyDescriptor(schema2._zod.def, "defaultValue");
15664
+ const defaultGetter = descriptor ? () => schema2._zod.def.defaultValue : void 0;
15665
+ if (schema2._zod.def.type === "prefault") {
15666
15666
  if (!defaultGetter) {
15667
15667
  return generateCheck(doc, ctx, def.innerType, accessor);
15668
15668
  }
@@ -15698,16 +15698,16 @@ function generateDefaultCheck(doc, ctx, schema, accessor) {
15698
15698
  }
15699
15699
  return outputVar;
15700
15700
  }
15701
- function generateNonOptionalCheck(doc, ctx, schema, accessor) {
15702
- const def = schema._zod.def;
15701
+ function generateNonOptionalCheck(doc, ctx, schema2, accessor) {
15702
+ const def = schema2._zod.def;
15703
15703
  const innerOutput = generateCheck(doc, ctx, def.innerType, accessor);
15704
15704
  const outputVar = newVar(ctx);
15705
15705
  doc.write(`const ${outputVar} = ${innerOutput};`);
15706
15706
  doc.write(`if (${outputVar} === undefined) return INVALID;`);
15707
15707
  return outputVar;
15708
15708
  }
15709
- function generateTupleCheck(doc, ctx, schema, accessor) {
15710
- const def = schema._zod.def;
15709
+ function generateTupleCheck(doc, ctx, schema2, accessor) {
15710
+ const def = schema2._zod.def;
15711
15711
  const items = def.items;
15712
15712
  const rest = def.rest;
15713
15713
  doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
@@ -15781,8 +15781,8 @@ function getTupleOptStart2(items, key) {
15781
15781
  }
15782
15782
  return 0;
15783
15783
  }
15784
- function generateUnionCheck(doc, ctx, schema, accessor) {
15785
- const def = schema._zod.def;
15784
+ function generateUnionCheck(doc, ctx, schema2, accessor) {
15785
+ const def = schema2._zod.def;
15786
15786
  const options = def.options;
15787
15787
  if (def.discriminator) {
15788
15788
  return generateDiscriminatedUnionCheck(doc, ctx, def, accessor);
@@ -15882,8 +15882,8 @@ function literalEquality(ctx, accessor, value) {
15882
15882
  }
15883
15883
  throw new ZodCompileUnsupportedError(`literal discriminator value ${String(value)}`);
15884
15884
  }
15885
- function generateIntersectionCheck(doc, ctx, schema, accessor) {
15886
- const def = schema._zod.def;
15885
+ function generateIntersectionCheck(doc, ctx, schema2, accessor) {
15886
+ const def = schema2._zod.def;
15887
15887
  ctx.definite = false;
15888
15888
  const leftOutput = compileChild(doc, ctx, def.left, accessor);
15889
15889
  const rightOutput = compileChild(doc, ctx, def.right, accessor);
@@ -15893,8 +15893,8 @@ function generateIntersectionCheck(doc, ctx, schema, accessor) {
15893
15893
  doc.write(`if (!${mergedVar}.valid) return INVALID;`);
15894
15894
  return `${mergedVar}.data`;
15895
15895
  }
15896
- function generateRecordCheck(doc, ctx, schema, accessor) {
15897
- const def = schema._zod.def;
15896
+ function generateRecordCheck(doc, ctx, schema2, accessor) {
15897
+ const def = schema2._zod.def;
15898
15898
  const isPlainObjectConst = addConstant(ctx, isPlainObject);
15899
15899
  doc.write(`if (!${isPlainObjectConst}(${accessor})) return INVALID;`);
15900
15900
  const outputVar = newVar(ctx);
@@ -15997,10 +15997,10 @@ function literalPropertyKey(ctx, key) {
15997
15997
  return esc(key);
15998
15998
  return addConstant(ctx, key);
15999
15999
  }
16000
- function generateMapCheck(doc, ctx, schema, accessor) {
16001
- const def = schema._zod.def;
16000
+ function generateMapCheck(doc, ctx, schema2, accessor) {
16001
+ const def = schema2._zod.def;
16002
16002
  doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
16003
- generateSizeGate(doc, schema, `${accessor}.size`);
16003
+ generateSizeGate(doc, schema2, `${accessor}.size`);
16004
16004
  const outputVar = newVar(ctx);
16005
16005
  const kVar = newVar(ctx);
16006
16006
  const valVar = newVar(ctx);
@@ -16014,10 +16014,10 @@ function generateMapCheck(doc, ctx, schema, accessor) {
16014
16014
  doc.write(`}`);
16015
16015
  return outputVar;
16016
16016
  }
16017
- function generateSetCheck(doc, ctx, schema, accessor) {
16018
- const def = schema._zod.def;
16017
+ function generateSetCheck(doc, ctx, schema2, accessor) {
16018
+ const def = schema2._zod.def;
16019
16019
  doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
16020
- generateSizeGate(doc, schema, `${accessor}.size`);
16020
+ generateSizeGate(doc, schema2, `${accessor}.size`);
16021
16021
  const outputVar = newVar(ctx);
16022
16022
  const valVar = newVar(ctx);
16023
16023
  doc.write(`const ${outputVar} = new Set();`);
@@ -16033,9 +16033,9 @@ function generateFileCheck(doc, accessor) {
16033
16033
  doc.write(`if (!(${accessor} instanceof File)) return INVALID;`);
16034
16034
  return accessor;
16035
16035
  }
16036
- function generateTemplateLiteralCheck(doc, ctx, schema, accessor) {
16036
+ function generateTemplateLiteralCheck(doc, ctx, schema2, accessor) {
16037
16037
  doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
16038
- const pattern = schema._zod.pattern;
16038
+ const pattern = schema2._zod.pattern;
16039
16039
  if (pattern) {
16040
16040
  const patternConst = addConstant(ctx, pattern);
16041
16041
  doc.write(`${patternConst}.lastIndex = 0;`);
@@ -16043,8 +16043,8 @@ function generateTemplateLiteralCheck(doc, ctx, schema, accessor) {
16043
16043
  }
16044
16044
  return accessor;
16045
16045
  }
16046
- function generateLazyCheck(doc, ctx, schema, accessor) {
16047
- const def = schema._zod.def;
16046
+ function generateLazyCheck(doc, ctx, schema2, accessor) {
16047
+ const def = schema2._zod.def;
16048
16048
  const getterConst = addUserConstant(ctx, def.getter);
16049
16049
  const cacheConst = addConstant(ctx, { parser: null });
16050
16050
  doc.write(`if (!${cacheConst}.parser) {`);
@@ -16063,8 +16063,8 @@ function generateLazyCheck(doc, ctx, schema, accessor) {
16063
16063
  doc.write(`if (${outputVar} === INVALID) return INVALID;`);
16064
16064
  return outputVar;
16065
16065
  }
16066
- function generatePipeCheck(doc, ctx, schema, accessor) {
16067
- const def = schema._zod.def;
16066
+ function generatePipeCheck(doc, ctx, schema2, accessor) {
16067
+ const def = schema2._zod.def;
16068
16068
  const inputOutput = generateCheck(doc, ctx, def.in, accessor);
16069
16069
  if (def.transform) {
16070
16070
  if (isAsyncFunction(def.transform)) {
@@ -16090,8 +16090,8 @@ function generatePipeCheck(doc, ctx, schema, accessor) {
16090
16090
  function isAsyncFunction(fn) {
16091
16091
  return typeof fn === "function" && (fn.constructor.name === "AsyncFunction" || fn[Symbol.toStringTag] === "AsyncFunction");
16092
16092
  }
16093
- function generateCustomCheck(doc, ctx, schema, accessor) {
16094
- const def = schema._zod.def;
16093
+ function generateCustomCheck(doc, ctx, schema2, accessor) {
16094
+ const def = schema2._zod.def;
16095
16095
  if (def.fn) {
16096
16096
  if (isAsyncFunction(def.fn)) {
16097
16097
  throw new ZodCompileAsyncError("z.compile: async custom predicates are not supported");
@@ -16116,8 +16116,8 @@ function runtimeCatch(innerSchema, catchValue, value) {
16116
16116
  return r.value;
16117
16117
  return catchValue();
16118
16118
  }
16119
- function generateCatchCheck(doc, ctx, schema, accessor) {
16120
- const def = schema._zod.def;
16119
+ function generateCatchCheck(doc, ctx, schema2, accessor) {
16120
+ const def = schema2._zod.def;
16121
16121
  if (!def.catchValue[CONSTANT_CATCH]) {
16122
16122
  throw new ZodCompileUnsupportedError("catch with a callback (only a constant catch value compiles)", false);
16123
16123
  }
@@ -16139,8 +16139,8 @@ function generateCatchCheck(doc, ctx, schema, accessor) {
16139
16139
  doc.write(`}`);
16140
16140
  return outputVar;
16141
16141
  }
16142
- function generateTransformCheck(doc, ctx, schema, accessor) {
16143
- const def = schema._zod.def;
16142
+ function generateTransformCheck(doc, ctx, schema2, accessor) {
16143
+ const def = schema2._zod.def;
16144
16144
  if (def.transform) {
16145
16145
  if (isAsyncFunction(def.transform)) {
16146
16146
  throw new ZodCompileAsyncError("z.compile: async transforms are not supported");
@@ -16815,11 +16815,11 @@ function _endsWith(suffix, params) {
16815
16815
  });
16816
16816
  }
16817
16817
  // @__NO_SIDE_EFFECTS__
16818
- function _property(property, schema, params) {
16818
+ function _property(property, schema2, params) {
16819
16819
  return new $ZodCheckProperty({
16820
16820
  check: "property",
16821
16821
  property,
16822
- schema,
16822
+ schema: schema2,
16823
16823
  ...normalizeParams(params)
16824
16824
  });
16825
16825
  }
@@ -17075,23 +17075,23 @@ function _promise(Class2, innerType) {
17075
17075
  function _custom(Class2, fn, _params) {
17076
17076
  const norm = normalizeParams(_params);
17077
17077
  norm.abort ?? (norm.abort = true);
17078
- const schema = new Class2({
17078
+ const schema2 = new Class2({
17079
17079
  type: "custom",
17080
17080
  check: "custom",
17081
17081
  fn,
17082
17082
  ...norm
17083
17083
  });
17084
- return schema;
17084
+ return schema2;
17085
17085
  }
17086
17086
  // @__NO_SIDE_EFFECTS__
17087
17087
  function _refine(Class2, fn, _params) {
17088
- const schema = new Class2({
17088
+ const schema2 = new Class2({
17089
17089
  type: "custom",
17090
17090
  check: "custom",
17091
17091
  fn,
17092
17092
  ...normalizeParams(_params)
17093
17093
  });
17094
- return schema;
17094
+ return schema2;
17095
17095
  }
17096
17096
  // @__NO_SIDE_EFFECTS__
17097
17097
  function _superRefine(fn, params) {
@@ -17257,8 +17257,8 @@ function initializeContext(params) {
17257
17257
  external: params?.external ?? void 0
17258
17258
  };
17259
17259
  }
17260
- function handleUnrepresentable(schema, ctx, json2, params, message2) {
17261
- const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message: message2 }) : ctx.unrepresentable;
17260
+ function handleUnrepresentable(schema2, ctx, json2, params, message2) {
17261
+ const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema2, path: params.path, message: message2 }) : ctx.unrepresentable;
17262
17262
  if (result === "any")
17263
17263
  return false;
17264
17264
  if (result === void 0 || result === "throw")
@@ -17266,42 +17266,42 @@ function handleUnrepresentable(schema, ctx, json2, params, message2) {
17266
17266
  Object.assign(json2, result);
17267
17267
  return true;
17268
17268
  }
17269
- function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
17269
+ function processSchema(schema2, ctx, _params = { path: [], schemaPath: [] }) {
17270
17270
  var _a3;
17271
- const def = schema._zod.def;
17272
- const seen = ctx.seen.get(schema);
17271
+ const def = schema2._zod.def;
17272
+ const seen = ctx.seen.get(schema2);
17273
17273
  if (seen) {
17274
17274
  seen.count++;
17275
- const isCycle = _params.schemaPath.includes(schema);
17275
+ const isCycle = _params.schemaPath.includes(schema2);
17276
17276
  if (isCycle) {
17277
17277
  seen.cycle = _params.path;
17278
17278
  }
17279
17279
  return seen.schema;
17280
17280
  }
17281
17281
  const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
17282
- ctx.seen.set(schema, result);
17282
+ ctx.seen.set(schema2, result);
17283
17283
  ctx.sharedDefsExtractedFor = void 0;
17284
17284
  ctx.sharedEmitDoneFor = void 0;
17285
- const overrideSchema = schema._zod.toJSONSchema?.();
17285
+ const overrideSchema = schema2._zod.toJSONSchema?.();
17286
17286
  if (overrideSchema) {
17287
17287
  result.schema = overrideSchema;
17288
17288
  } else {
17289
17289
  const params = {
17290
17290
  ..._params,
17291
- schemaPath: [..._params.schemaPath, schema],
17291
+ schemaPath: [..._params.schemaPath, schema2],
17292
17292
  path: _params.path
17293
17293
  };
17294
- if (schema._zod.processJSONSchema) {
17295
- schema._zod.processJSONSchema(ctx, result.schema, params);
17294
+ if (schema2._zod.processJSONSchema) {
17295
+ schema2._zod.processJSONSchema(ctx, result.schema, params);
17296
17296
  } else {
17297
17297
  const _json = result.schema;
17298
17298
  const processor = ctx.processors[def.type];
17299
17299
  if (!processor) {
17300
17300
  throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
17301
17301
  }
17302
- processor(schema, ctx, _json, params);
17302
+ processor(schema2, ctx, _json, params);
17303
17303
  }
17304
- const parent = schema._zod.parent;
17304
+ const parent = schema2._zod.parent;
17305
17305
  if (parent) {
17306
17306
  if (!result.ref)
17307
17307
  result.ref = parent;
@@ -17309,24 +17309,24 @@ function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
17309
17309
  ctx.seen.get(parent).isParent = true;
17310
17310
  }
17311
17311
  }
17312
- const meta3 = ctx.metadataRegistry.get(schema);
17312
+ const meta3 = ctx.metadataRegistry.get(schema2);
17313
17313
  if (meta3)
17314
17314
  assignProps(result.schema, meta3);
17315
- if (ctx.io === "input" && isTransforming(schema)) {
17315
+ if (ctx.io === "input" && isTransforming(schema2)) {
17316
17316
  delete result.schema.examples;
17317
17317
  delete result.schema.default;
17318
17318
  }
17319
17319
  if (ctx.io === "input" && "_prefault" in result.schema)
17320
17320
  (_a3 = result.schema).default ?? (_a3.default = result.schema._prefault);
17321
17321
  delete result.schema._prefault;
17322
- const _result = ctx.seen.get(schema);
17322
+ const _result = ctx.seen.get(schema2);
17323
17323
  return _result.schema;
17324
17324
  }
17325
17325
  function encodeJSONPointerSegment(segment) {
17326
17326
  return segment.replace(/~/g, "~0").replace(/\//g, "~1");
17327
17327
  }
17328
- function extractDefs(ctx, schema) {
17329
- const root = ctx.seen.get(schema);
17328
+ function extractDefs(ctx, schema2) {
17329
+ const root = ctx.seen.get(schema2);
17330
17330
  if (!root)
17331
17331
  throw new Error("Unprocessed schema. This is a bug in Zod.");
17332
17332
  if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external)
@@ -17371,11 +17371,11 @@ function extractDefs(ctx, schema) {
17371
17371
  seen.def = { ...seen.schema };
17372
17372
  if (defId)
17373
17373
  seen.defId = defId;
17374
- const schema2 = seen.schema;
17375
- for (const key in schema2) {
17376
- delete schema2[key];
17374
+ const schema3 = seen.schema;
17375
+ for (const key in schema3) {
17376
+ delete schema3[key];
17377
17377
  }
17378
- schema2.$ref = ref;
17378
+ schema3.$ref = ref;
17379
17379
  };
17380
17380
  if (ctx.cycles === "throw") {
17381
17381
  for (const entry of ctx.seen.entries()) {
@@ -17389,13 +17389,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17389
17389
  }
17390
17390
  for (const entry of ctx.seen.entries()) {
17391
17391
  const seen = entry[1];
17392
- if (schema === entry[0]) {
17392
+ if (schema2 === entry[0]) {
17393
17393
  extractToDef(entry);
17394
17394
  continue;
17395
17395
  }
17396
17396
  if (ctx.external) {
17397
17397
  const ext = ctx.external.registry.get(entry[0])?.id;
17398
- if (schema !== entry[0] && ext) {
17398
+ if (schema2 !== entry[0] && ext) {
17399
17399
  extractToDef(entry);
17400
17400
  continue;
17401
17401
  }
@@ -17418,9 +17418,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17418
17418
  if (ctx.external)
17419
17419
  ctx.sharedDefsExtractedFor = ctx.external;
17420
17420
  }
17421
- function compactTypeUnion(schema) {
17422
- const options = schema.anyOf;
17423
- if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0)
17421
+ function compactTypeUnion(schema2) {
17422
+ const options = schema2.anyOf;
17423
+ if (!Array.isArray(options) || options.length === 0 || schema2.type !== void 0)
17424
17424
  return;
17425
17425
  const types = [];
17426
17426
  for (const option of options) {
@@ -17438,8 +17438,8 @@ function compactTypeUnion(schema) {
17438
17438
  types.push(member);
17439
17439
  }
17440
17440
  }
17441
- delete schema.anyOf;
17442
- schema.type = types.length === 1 ? types[0] : types;
17441
+ delete schema2.anyOf;
17442
+ schema2.type = types.length === 1 ? types[0] : types;
17443
17443
  }
17444
17444
  var FOLDABLE_KEYS = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties"]);
17445
17445
  var UNION_KEYS = ["oneOf", "anyOf"];
@@ -17526,16 +17526,16 @@ function foldIntersection(json2) {
17526
17526
  delete json2.allOf;
17527
17527
  assignProps(json2, folded);
17528
17528
  }
17529
- function finalize(ctx, schema) {
17530
- const root = ctx.seen.get(schema);
17529
+ function finalize(ctx, schema2) {
17530
+ const root = ctx.seen.get(schema2);
17531
17531
  if (!root)
17532
17532
  throw new Error("Unprocessed schema. This is a bug in Zod.");
17533
17533
  const flattenRef = (zodSchema) => {
17534
17534
  const seen = ctx.seen.get(zodSchema);
17535
17535
  if (seen.ref === null)
17536
17536
  return;
17537
- const schema2 = seen.def ?? seen.schema;
17538
- const _cached = { ...schema2 };
17537
+ const schema3 = seen.def ?? seen.schema;
17538
+ const _cached = { ...schema3 };
17539
17539
  const ref = seen.ref;
17540
17540
  seen.ref = null;
17541
17541
  if (ref) {
@@ -17543,28 +17543,28 @@ function finalize(ctx, schema) {
17543
17543
  const refSeen = ctx.seen.get(ref);
17544
17544
  const refSchema = refSeen.schema;
17545
17545
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
17546
- schema2.allOf = schema2.allOf ?? [];
17547
- schema2.allOf.push(refSchema);
17546
+ schema3.allOf = schema3.allOf ?? [];
17547
+ schema3.allOf.push(refSchema);
17548
17548
  } else {
17549
- assignProps(schema2, refSchema);
17549
+ assignProps(schema3, refSchema);
17550
17550
  }
17551
- assignProps(schema2, _cached);
17551
+ assignProps(schema3, _cached);
17552
17552
  const isParentRef = zodSchema._zod.parent === ref;
17553
17553
  if (isParentRef) {
17554
- for (const key in schema2) {
17554
+ for (const key in schema3) {
17555
17555
  if (key === "$ref" || key === "allOf")
17556
17556
  continue;
17557
17557
  if (!(key in _cached)) {
17558
- delete schema2[key];
17558
+ delete schema3[key];
17559
17559
  }
17560
17560
  }
17561
17561
  }
17562
17562
  if (refSchema.$ref && refSeen.def) {
17563
- for (const key in schema2) {
17563
+ for (const key in schema3) {
17564
17564
  if (key === "$ref" || key === "allOf")
17565
17565
  continue;
17566
- if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
17567
- delete schema2[key];
17566
+ if (key in refSeen.def && JSON.stringify(schema3[key]) === JSON.stringify(refSeen.def[key])) {
17567
+ delete schema3[key];
17568
17568
  }
17569
17569
  }
17570
17570
  }
@@ -17574,13 +17574,13 @@ function finalize(ctx, schema) {
17574
17574
  flattenRef(parent);
17575
17575
  const parentSeen = ctx.seen.get(parent);
17576
17576
  if (parentSeen?.schema.$ref) {
17577
- schema2.$ref = parentSeen.schema.$ref;
17577
+ schema3.$ref = parentSeen.schema.$ref;
17578
17578
  if (parentSeen.def) {
17579
- for (const key in schema2) {
17579
+ for (const key in schema3) {
17580
17580
  if (key === "$ref" || key === "allOf")
17581
17581
  continue;
17582
- if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
17583
- delete schema2[key];
17582
+ if (key in parentSeen.def && JSON.stringify(schema3[key]) === JSON.stringify(parentSeen.def[key])) {
17583
+ delete schema3[key];
17584
17584
  }
17585
17585
  }
17586
17586
  }
@@ -17588,7 +17588,7 @@ function finalize(ctx, schema) {
17588
17588
  }
17589
17589
  ctx.override({
17590
17590
  zodSchema,
17591
- jsonSchema: schema2,
17591
+ jsonSchema: schema3,
17592
17592
  path: seen.path ?? []
17593
17593
  });
17594
17594
  };
@@ -17634,13 +17634,13 @@ function finalize(ctx, schema) {
17634
17634
  } else {
17635
17635
  }
17636
17636
  if (ctx.external?.uri) {
17637
- const id = ctx.external.registry.get(schema)?.id;
17637
+ const id = ctx.external.registry.get(schema2)?.id;
17638
17638
  if (!id)
17639
17639
  throw new Error("Schema is missing an `id` property");
17640
17640
  result.$id = ctx.external.uri(id);
17641
17641
  }
17642
17642
  assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
17643
- const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
17643
+ const rootMetaId = ctx.metadataRegistry.get(schema2)?.id;
17644
17644
  if (rootMetaId !== void 0 && result.id === rootMetaId)
17645
17645
  delete result.id;
17646
17646
  const defs = ctx.external?.defs ?? {};
@@ -17670,10 +17670,10 @@ function finalize(ctx, schema) {
17670
17670
  const finalized = JSON.parse(JSON.stringify(result));
17671
17671
  Object.defineProperty(finalized, "~standard", {
17672
17672
  value: {
17673
- ...schema["~standard"],
17673
+ ...schema2["~standard"],
17674
17674
  jsonSchema: {
17675
- input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
17676
- output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
17675
+ input: createStandardJSONSchemaMethod(schema2, "input", ctx.processors),
17676
+ output: createStandardJSONSchemaMethod(schema2, "output", ctx.processors)
17677
17677
  }
17678
17678
  },
17679
17679
  enumerable: false,
@@ -17737,18 +17737,18 @@ function isTransforming(_schema, _ctx) {
17737
17737
  }
17738
17738
  return false;
17739
17739
  }
17740
- var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
17740
+ var createToJSONSchemaMethod = (schema2, processors = {}) => (params) => {
17741
17741
  const ctx = initializeContext({ ...params, processors });
17742
- processSchema(schema, ctx);
17743
- extractDefs(ctx, schema);
17744
- return finalize(ctx, schema);
17742
+ processSchema(schema2, ctx);
17743
+ extractDefs(ctx, schema2);
17744
+ return finalize(ctx, schema2);
17745
17745
  };
17746
- var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
17746
+ var createStandardJSONSchemaMethod = (schema2, io, processors = {}) => (params) => {
17747
17747
  const { libraryOptions, target } = params ?? {};
17748
17748
  const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
17749
- processSchema(schema, ctx);
17750
- extractDefs(ctx, schema);
17751
- return finalize(ctx, schema);
17749
+ processSchema(schema2, ctx);
17750
+ extractDefs(ctx, schema2);
17751
+ return finalize(ctx, schema2);
17752
17752
  };
17753
17753
 
17754
17754
  // node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/json-schema-processors.js
@@ -17812,13 +17812,13 @@ var contributors = {
17812
17812
  },
17813
17813
  mime_type: (agg, def) => intersectMime(agg, def.mime)
17814
17814
  };
17815
- function aggregateChecks(schema) {
17815
+ function aggregateChecks(schema2) {
17816
17816
  const agg = {};
17817
- const def = schema._zod.def;
17818
- const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
17817
+ const def = schema2._zod.def;
17818
+ const list = schema2._zod.traits.has("$ZodCheck") ? [schema2, ...def.checks ?? []] : def.checks ?? [];
17819
17819
  for (const ch of list)
17820
17820
  contributors[ch._zod.def.check]?.(agg, ch._zod.def);
17821
- const bag = schema._zod.bag;
17821
+ const bag = schema2._zod.bag;
17822
17822
  if (bag.minimum !== void 0)
17823
17823
  narrowMin(agg, "minimum", bag.minimum);
17824
17824
  if (bag.exclusiveMinimum !== void 0)
@@ -17853,10 +17853,10 @@ var exactPatterns = /* @__PURE__ */ new Map([
17853
17853
  [base64urlCharset, base64url]
17854
17854
  ]);
17855
17855
  var exactPattern = (p) => exactPatterns.get(p) ?? p;
17856
- var stringProcessor = (schema, ctx, _json, _params) => {
17856
+ var stringProcessor = (schema2, ctx, _json, _params) => {
17857
17857
  const json2 = _json;
17858
17858
  json2.type = "string";
17859
- const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
17859
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema2);
17860
17860
  if (typeof minimum === "number")
17861
17861
  json2.minLength = minimum;
17862
17862
  if (typeof maximum === "number")
@@ -17885,9 +17885,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
17885
17885
  }
17886
17886
  }
17887
17887
  };
17888
- var numberProcessor = (schema, ctx, _json, params) => {
17888
+ var numberProcessor = (schema2, ctx, _json, params) => {
17889
17889
  const json2 = _json;
17890
- const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
17890
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema2);
17891
17891
  json2.type = isInt ? "integer" : "number";
17892
17892
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
17893
17893
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
@@ -17918,7 +17918,7 @@ var numberProcessor = (schema, ctx, _json, params) => {
17918
17918
  if (Number.isFinite(divisor) && divisor !== 0)
17919
17919
  divisors.add(Math.abs(divisor));
17920
17920
  else
17921
- handleUnrepresentable(schema, ctx, json2, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
17921
+ handleUnrepresentable(schema2, ctx, json2, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
17922
17922
  }
17923
17923
  const [first, ...rest] = divisors;
17924
17924
  if (first !== void 0)
@@ -17930,11 +17930,11 @@ var numberProcessor = (schema, ctx, _json, params) => {
17930
17930
  var booleanProcessor = (_schema, _ctx, json2, _params) => {
17931
17931
  json2.type = "boolean";
17932
17932
  };
17933
- var bigintProcessor = (schema, ctx, json2, params) => {
17934
- handleUnrepresentable(schema, ctx, json2, params, "BigInt cannot be represented in JSON Schema");
17933
+ var bigintProcessor = (schema2, ctx, json2, params) => {
17934
+ handleUnrepresentable(schema2, ctx, json2, params, "BigInt cannot be represented in JSON Schema");
17935
17935
  };
17936
- var symbolProcessor = (schema, ctx, json2, params) => {
17937
- handleUnrepresentable(schema, ctx, json2, params, "Symbols cannot be represented in JSON Schema");
17936
+ var symbolProcessor = (schema2, ctx, json2, params) => {
17937
+ handleUnrepresentable(schema2, ctx, json2, params, "Symbols cannot be represented in JSON Schema");
17938
17938
  };
17939
17939
  var nullProcessor = (_schema, ctx, json2, _params) => {
17940
17940
  if (ctx.target === "openapi-3.0") {
@@ -17945,11 +17945,11 @@ var nullProcessor = (_schema, ctx, json2, _params) => {
17945
17945
  json2.type = "null";
17946
17946
  }
17947
17947
  };
17948
- var undefinedProcessor = (schema, ctx, json2, params) => {
17949
- handleUnrepresentable(schema, ctx, json2, params, "Undefined cannot be represented in JSON Schema");
17948
+ var undefinedProcessor = (schema2, ctx, json2, params) => {
17949
+ handleUnrepresentable(schema2, ctx, json2, params, "Undefined cannot be represented in JSON Schema");
17950
17950
  };
17951
- var voidProcessor = (schema, ctx, json2, params) => {
17952
- handleUnrepresentable(schema, ctx, json2, params, "Void cannot be represented in JSON Schema");
17951
+ var voidProcessor = (schema2, ctx, json2, params) => {
17952
+ handleUnrepresentable(schema2, ctx, json2, params, "Void cannot be represented in JSON Schema");
17953
17953
  };
17954
17954
  var neverProcessor = (_schema, _ctx, json2, _params) => {
17955
17955
  json2.not = {};
@@ -17958,11 +17958,11 @@ var anyProcessor = (_schema, _ctx, _json, _params) => {
17958
17958
  };
17959
17959
  var unknownProcessor = (_schema, _ctx, _json, _params) => {
17960
17960
  };
17961
- var dateProcessor = (schema, ctx, json2, params) => {
17962
- handleUnrepresentable(schema, ctx, json2, params, "Date cannot be represented in JSON Schema");
17961
+ var dateProcessor = (schema2, ctx, json2, params) => {
17962
+ handleUnrepresentable(schema2, ctx, json2, params, "Date cannot be represented in JSON Schema");
17963
17963
  };
17964
- var enumProcessor = (schema, _ctx, json2, _params) => {
17965
- const def = schema._zod.def;
17964
+ var enumProcessor = (schema2, _ctx, json2, _params) => {
17965
+ const def = schema2._zod.def;
17966
17966
  const values = getEnumValues(def.entries);
17967
17967
  if (values.length === 0) {
17968
17968
  json2.not = {};
@@ -17974,8 +17974,8 @@ var enumProcessor = (schema, _ctx, json2, _params) => {
17974
17974
  json2.type = "string";
17975
17975
  json2.enum = values;
17976
17976
  };
17977
- var literalProcessor = (schema, ctx, json2, params) => {
17978
- const def = schema._zod.def;
17977
+ var literalProcessor = (schema2, ctx, json2, params) => {
17978
+ const def = schema2._zod.def;
17979
17979
  if (def.values.length === 0) {
17980
17980
  json2.not = {};
17981
17981
  return;
@@ -17983,10 +17983,10 @@ var literalProcessor = (schema, ctx, json2, params) => {
17983
17983
  const vals = [];
17984
17984
  for (const val of def.values) {
17985
17985
  if (val === void 0) {
17986
- if (handleUnrepresentable(schema, ctx, json2, params, "Literal `undefined` cannot be represented in JSON Schema"))
17986
+ if (handleUnrepresentable(schema2, ctx, json2, params, "Literal `undefined` cannot be represented in JSON Schema"))
17987
17987
  return;
17988
17988
  } else if (typeof val === "bigint") {
17989
- if (handleUnrepresentable(schema, ctx, json2, params, "BigInt literals cannot be represented in JSON Schema"))
17989
+ if (handleUnrepresentable(schema2, ctx, json2, params, "BigInt literals cannot be represented in JSON Schema"))
17990
17990
  return;
17991
17991
  vals.push(Number(val));
17992
17992
  } else {
@@ -18014,23 +18014,23 @@ var literalProcessor = (schema, ctx, json2, params) => {
18014
18014
  json2.enum = vals;
18015
18015
  }
18016
18016
  };
18017
- var nanProcessor = (schema, ctx, json2, params) => {
18018
- handleUnrepresentable(schema, ctx, json2, params, "NaN cannot be represented in JSON Schema");
18017
+ var nanProcessor = (schema2, ctx, json2, params) => {
18018
+ handleUnrepresentable(schema2, ctx, json2, params, "NaN cannot be represented in JSON Schema");
18019
18019
  };
18020
- var templateLiteralProcessor = (schema, _ctx, json2, _params) => {
18020
+ var templateLiteralProcessor = (schema2, _ctx, json2, _params) => {
18021
18021
  const _json = json2;
18022
- const pattern = schema._zod.pattern;
18022
+ const pattern = schema2._zod.pattern;
18023
18023
  if (!pattern)
18024
18024
  throw new Error("Pattern not found in template literal");
18025
18025
  _json.type = "string";
18026
18026
  _json.pattern = pattern.source;
18027
18027
  };
18028
- var fileProcessor = (schema, _ctx, json2, _params) => {
18028
+ var fileProcessor = (schema2, _ctx, json2, _params) => {
18029
18029
  const _json = json2;
18030
18030
  _json.type = "string";
18031
18031
  _json.format = "binary";
18032
18032
  _json.contentEncoding = "binary";
18033
- const { minimum, maximum, mime } = aggregateChecks(schema);
18033
+ const { minimum, maximum, mime } = aggregateChecks(schema2);
18034
18034
  if (minimum !== void 0)
18035
18035
  _json.minLength = minimum;
18036
18036
  if (maximum !== void 0)
@@ -18047,25 +18047,25 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
18047
18047
  var successProcessor = (_schema, _ctx, json2, _params) => {
18048
18048
  json2.type = "boolean";
18049
18049
  };
18050
- var customProcessor = (schema, ctx, json2, params) => {
18051
- handleUnrepresentable(schema, ctx, json2, params, "Custom types cannot be represented in JSON Schema");
18050
+ var customProcessor = (schema2, ctx, json2, params) => {
18051
+ handleUnrepresentable(schema2, ctx, json2, params, "Custom types cannot be represented in JSON Schema");
18052
18052
  };
18053
- var functionProcessor = (schema, ctx, json2, params) => {
18054
- handleUnrepresentable(schema, ctx, json2, params, "Function types cannot be represented in JSON Schema");
18053
+ var functionProcessor = (schema2, ctx, json2, params) => {
18054
+ handleUnrepresentable(schema2, ctx, json2, params, "Function types cannot be represented in JSON Schema");
18055
18055
  };
18056
- var transformProcessor = (schema, ctx, json2, params) => {
18057
- handleUnrepresentable(schema, ctx, json2, params, "Transforms cannot be represented in JSON Schema");
18056
+ var transformProcessor = (schema2, ctx, json2, params) => {
18057
+ handleUnrepresentable(schema2, ctx, json2, params, "Transforms cannot be represented in JSON Schema");
18058
18058
  };
18059
- var mapProcessor = (schema, ctx, json2, params) => {
18060
- handleUnrepresentable(schema, ctx, json2, params, "Map cannot be represented in JSON Schema");
18059
+ var mapProcessor = (schema2, ctx, json2, params) => {
18060
+ handleUnrepresentable(schema2, ctx, json2, params, "Map cannot be represented in JSON Schema");
18061
18061
  };
18062
- var setProcessor = (schema, ctx, json2, params) => {
18063
- handleUnrepresentable(schema, ctx, json2, params, "Set cannot be represented in JSON Schema");
18062
+ var setProcessor = (schema2, ctx, json2, params) => {
18063
+ handleUnrepresentable(schema2, ctx, json2, params, "Set cannot be represented in JSON Schema");
18064
18064
  };
18065
- var arrayProcessor = (schema, ctx, _json, params) => {
18065
+ var arrayProcessor = (schema2, ctx, _json, params) => {
18066
18066
  const json2 = _json;
18067
- const def = schema._zod.def;
18068
- const { minimum, maximum } = aggregateChecks(schema);
18067
+ const def = schema2._zod.def;
18068
+ const { minimum, maximum } = aggregateChecks(schema2);
18069
18069
  if (typeof minimum === "number")
18070
18070
  json2.minItems = minimum;
18071
18071
  if (typeof maximum === "number")
@@ -18076,22 +18076,22 @@ var arrayProcessor = (schema, ctx, _json, params) => {
18076
18076
  path: [...params.path, "items"]
18077
18077
  });
18078
18078
  };
18079
- function inputOptin(schema) {
18080
- const def = schema._zod.def;
18079
+ function inputOptin(schema2) {
18080
+ const def = schema2._zod.def;
18081
18081
  if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) {
18082
18082
  return inputOptin(def.out);
18083
18083
  }
18084
18084
  if (def.type === "catch") {
18085
18085
  return inputOptin(def.innerType);
18086
18086
  }
18087
- return schema._zod.optin;
18087
+ return schema2._zod.optin;
18088
18088
  }
18089
- var objectProcessor = (schema, ctx, _json, params) => {
18089
+ var objectProcessor = (schema2, ctx, _json, params) => {
18090
18090
  const json2 = _json;
18091
- const def = schema._zod.def;
18091
+ const def = schema2._zod.def;
18092
18092
  const shape = def.shape;
18093
18093
  const symbolKeys = Object.getOwnPropertySymbols(shape);
18094
- if (symbolKeys.length && handleUnrepresentable(schema, ctx, json2, params, "Symbol keys cannot be represented in JSON Schema")) {
18094
+ if (symbolKeys.length && handleUnrepresentable(schema2, ctx, json2, params, "Symbol keys cannot be represented in JSON Schema")) {
18095
18095
  return;
18096
18096
  }
18097
18097
  json2.type = "object";
@@ -18124,8 +18124,8 @@ var objectProcessor = (schema, ctx, _json, params) => {
18124
18124
  });
18125
18125
  }
18126
18126
  };
18127
- var unionProcessor = (schema, ctx, json2, params) => {
18128
- const def = schema._zod.def;
18127
+ var unionProcessor = (schema2, ctx, json2, params) => {
18128
+ const def = schema2._zod.def;
18129
18129
  const isExclusive = def.inclusive === false;
18130
18130
  const options = def.options.map((x, i) => processSchema(x, ctx, {
18131
18131
  ...params,
@@ -18137,8 +18137,8 @@ var unionProcessor = (schema, ctx, json2, params) => {
18137
18137
  json2.anyOf = options;
18138
18138
  }
18139
18139
  };
18140
- var intersectionProcessor = (schema, ctx, json2, params) => {
18141
- const def = schema._zod.def;
18140
+ var intersectionProcessor = (schema2, ctx, json2, params) => {
18141
+ const def = schema2._zod.def;
18142
18142
  const a = processSchema(def.left, ctx, {
18143
18143
  ...params,
18144
18144
  path: [...params.path, "allOf", 0]
@@ -18155,9 +18155,9 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
18155
18155
  json2.allOf = allOf;
18156
18156
  ctx.intersections.push(allOf);
18157
18157
  };
18158
- var tupleProcessor = (schema, ctx, _json, params) => {
18158
+ var tupleProcessor = (schema2, ctx, _json, params) => {
18159
18159
  const json2 = _json;
18160
- const def = schema._zod.def;
18160
+ const def = schema2._zod.def;
18161
18161
  json2.type = "array";
18162
18162
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
18163
18163
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
@@ -18213,7 +18213,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
18213
18213
  if (isClosed)
18214
18214
  json2.maxItems = maxItems;
18215
18215
  }
18216
- const { minimum, maximum } = aggregateChecks(schema);
18216
+ const { minimum, maximum } = aggregateChecks(schema2);
18217
18217
  if (typeof minimum === "number")
18218
18218
  json2.minItems = minimum;
18219
18219
  if (typeof maximum === "number")
@@ -18282,9 +18282,9 @@ function rewriteKeyNames(ctx) {
18282
18282
  }
18283
18283
  }
18284
18284
  }
18285
- var recordProcessor = (schema, ctx, _json, params) => {
18285
+ var recordProcessor = (schema2, ctx, _json, params) => {
18286
18286
  const json2 = _json;
18287
- const def = schema._zod.def;
18287
+ const def = schema2._zod.def;
18288
18288
  json2.type = "object";
18289
18289
  const keyType = def.keyType;
18290
18290
  const patterns = aggregateChecks(keyType).patterns;
@@ -18309,7 +18309,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
18309
18309
  pendingRecords.set(ctx, pending);
18310
18310
  ctx.deferred.push(() => rewriteKeyNames(ctx));
18311
18311
  }
18312
- pending.push(schema);
18312
+ pending.push(schema2);
18313
18313
  }
18314
18314
  json2.additionalProperties = processSchema(def.valueType, ctx, {
18315
18315
  ...params,
@@ -18325,10 +18325,10 @@ var recordProcessor = (schema, ctx, _json, params) => {
18325
18325
  }
18326
18326
  }
18327
18327
  };
18328
- var nullableProcessor = (schema, ctx, json2, params) => {
18329
- const def = schema._zod.def;
18328
+ var nullableProcessor = (schema2, ctx, json2, params) => {
18329
+ const def = schema2._zod.def;
18330
18330
  const inner = processSchema(def.innerType, ctx, params);
18331
- const seen = ctx.seen.get(schema);
18331
+ const seen = ctx.seen.get(schema2);
18332
18332
  if (ctx.target === "openapi-3.0") {
18333
18333
  seen.ref = def.innerType;
18334
18334
  json2.nullable = true;
@@ -18336,14 +18336,14 @@ var nullableProcessor = (schema, ctx, json2, params) => {
18336
18336
  json2.anyOf = [inner, { type: "null" }];
18337
18337
  }
18338
18338
  };
18339
- var nonoptionalProcessor = (schema, ctx, _json, params) => {
18340
- const def = schema._zod.def;
18339
+ var nonoptionalProcessor = (schema2, ctx, _json, params) => {
18340
+ const def = schema2._zod.def;
18341
18341
  processSchema(def.innerType, ctx, params);
18342
- const seen = ctx.seen.get(schema);
18342
+ const seen = ctx.seen.get(schema2);
18343
18343
  seen.ref = def.innerType;
18344
18344
  };
18345
18345
  var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
18346
- function serializeDefaultValue(value, schema, ctx, json2, params) {
18346
+ function serializeDefaultValue(value, schema2, ctx, json2, params) {
18347
18347
  let unrepresentable = false;
18348
18348
  const serialized = JSON.stringify(value, (_, val) => {
18349
18349
  if (typeof val !== "bigint")
@@ -18353,74 +18353,74 @@ function serializeDefaultValue(value, schema, ctx, json2, params) {
18353
18353
  });
18354
18354
  if (!unrepresentable)
18355
18355
  return JSON.parse(serialized);
18356
- handleUnrepresentable(schema, ctx, json2, params, "BigInt defaults cannot be represented in JSON Schema");
18356
+ handleUnrepresentable(schema2, ctx, json2, params, "BigInt defaults cannot be represented in JSON Schema");
18357
18357
  return UNREPRESENTABLE_DEFAULT;
18358
18358
  }
18359
- var defaultProcessor = (schema, ctx, json2, params) => {
18360
- const def = schema._zod.def;
18359
+ var defaultProcessor = (schema2, ctx, json2, params) => {
18360
+ const def = schema2._zod.def;
18361
18361
  processSchema(def.innerType, ctx, params);
18362
- const seen = ctx.seen.get(schema);
18362
+ const seen = ctx.seen.get(schema2);
18363
18363
  seen.ref = def.innerType;
18364
- const value = serializeDefaultValue(def.defaultValue, schema, ctx, json2, params);
18364
+ const value = serializeDefaultValue(def.defaultValue, schema2, ctx, json2, params);
18365
18365
  if (value !== UNREPRESENTABLE_DEFAULT)
18366
18366
  json2.default = value;
18367
18367
  };
18368
- var prefaultProcessor = (schema, ctx, json2, params) => {
18369
- const def = schema._zod.def;
18368
+ var prefaultProcessor = (schema2, ctx, json2, params) => {
18369
+ const def = schema2._zod.def;
18370
18370
  processSchema(def.innerType, ctx, params);
18371
- const seen = ctx.seen.get(schema);
18371
+ const seen = ctx.seen.get(schema2);
18372
18372
  seen.ref = def.innerType;
18373
18373
  if (ctx.io !== "input")
18374
18374
  return;
18375
- const value = serializeDefaultValue(def.defaultValue, schema, ctx, json2, params);
18375
+ const value = serializeDefaultValue(def.defaultValue, schema2, ctx, json2, params);
18376
18376
  if (value !== UNREPRESENTABLE_DEFAULT)
18377
18377
  json2._prefault = value;
18378
18378
  };
18379
- var catchProcessor = (schema, ctx, json2, params) => {
18380
- const def = schema._zod.def;
18379
+ var catchProcessor = (schema2, ctx, json2, params) => {
18380
+ const def = schema2._zod.def;
18381
18381
  processSchema(def.innerType, ctx, params);
18382
- const seen = ctx.seen.get(schema);
18382
+ const seen = ctx.seen.get(schema2);
18383
18383
  seen.ref = def.innerType;
18384
18384
  let catchValue;
18385
18385
  try {
18386
18386
  catchValue = def.catchValue(void 0);
18387
18387
  } catch {
18388
- handleUnrepresentable(schema, ctx, json2, params, "Dynamic catch values are not supported in JSON Schema");
18388
+ handleUnrepresentable(schema2, ctx, json2, params, "Dynamic catch values are not supported in JSON Schema");
18389
18389
  return;
18390
18390
  }
18391
18391
  json2.default = catchValue;
18392
18392
  };
18393
- var pipeProcessor = (schema, ctx, _json, params) => {
18394
- const def = schema._zod.def;
18393
+ var pipeProcessor = (schema2, ctx, _json, params) => {
18394
+ const def = schema2._zod.def;
18395
18395
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
18396
18396
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
18397
18397
  processSchema(innerType, ctx, params);
18398
- const seen = ctx.seen.get(schema);
18398
+ const seen = ctx.seen.get(schema2);
18399
18399
  seen.ref = innerType;
18400
18400
  };
18401
- var readonlyProcessor = (schema, ctx, json2, params) => {
18402
- const def = schema._zod.def;
18401
+ var readonlyProcessor = (schema2, ctx, json2, params) => {
18402
+ const def = schema2._zod.def;
18403
18403
  processSchema(def.innerType, ctx, params);
18404
- const seen = ctx.seen.get(schema);
18404
+ const seen = ctx.seen.get(schema2);
18405
18405
  seen.ref = def.innerType;
18406
18406
  json2.readOnly = true;
18407
18407
  };
18408
- var promiseProcessor = (schema, ctx, _json, params) => {
18409
- const def = schema._zod.def;
18408
+ var promiseProcessor = (schema2, ctx, _json, params) => {
18409
+ const def = schema2._zod.def;
18410
18410
  processSchema(def.innerType, ctx, params);
18411
- const seen = ctx.seen.get(schema);
18411
+ const seen = ctx.seen.get(schema2);
18412
18412
  seen.ref = def.innerType;
18413
18413
  };
18414
- var optionalProcessor = (schema, ctx, _json, params) => {
18415
- const def = schema._zod.def;
18414
+ var optionalProcessor = (schema2, ctx, _json, params) => {
18415
+ const def = schema2._zod.def;
18416
18416
  processSchema(def.innerType, ctx, params);
18417
- const seen = ctx.seen.get(schema);
18417
+ const seen = ctx.seen.get(schema2);
18418
18418
  seen.ref = def.innerType;
18419
18419
  };
18420
- var lazyProcessor = (schema, ctx, _json, params) => {
18421
- const innerType = schema._zod.innerType;
18420
+ var lazyProcessor = (schema2, ctx, _json, params) => {
18421
+ const innerType = schema2._zod.innerType;
18422
18422
  processSchema(innerType, ctx, params);
18423
- const seen = ctx.seen.get(schema);
18423
+ const seen = ctx.seen.get(schema2);
18424
18424
  seen.ref = innerType;
18425
18425
  };
18426
18426
  var allProcessors = {
@@ -18470,8 +18470,8 @@ function toJSONSchema(input2, params) {
18470
18470
  const ctx2 = initializeContext({ ...params, processors: allProcessors });
18471
18471
  const defs = {};
18472
18472
  for (const entry of registry3._idmap.entries()) {
18473
- const [_, schema] = entry;
18474
- processSchema(schema, ctx2);
18473
+ const [_, schema2] = entry;
18474
+ processSchema(schema2, ctx2);
18475
18475
  }
18476
18476
  const schemas = {};
18477
18477
  const external = {
@@ -18481,9 +18481,9 @@ function toJSONSchema(input2, params) {
18481
18481
  };
18482
18482
  ctx2.external = external;
18483
18483
  for (const entry of registry3._idmap.entries()) {
18484
- const [key, schema] = entry;
18485
- extractDefs(ctx2, schema);
18486
- assignProp(schemas, key, finalize(ctx2, schema));
18484
+ const [key, schema2] = entry;
18485
+ extractDefs(ctx2, schema2);
18486
+ assignProp(schemas, key, finalize(ctx2, schema2));
18487
18487
  }
18488
18488
  if (Object.keys(defs).length > 0) {
18489
18489
  const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
@@ -18552,14 +18552,14 @@ var JSONSchemaGenerator = class {
18552
18552
  * Process a schema to prepare it for JSON Schema generation.
18553
18553
  * This must be called before emit().
18554
18554
  */
18555
- process(schema, _params = { path: [], schemaPath: [] }) {
18556
- return processSchema(schema, this.ctx, _params);
18555
+ process(schema2, _params = { path: [], schemaPath: [] }) {
18556
+ return processSchema(schema2, this.ctx, _params);
18557
18557
  }
18558
18558
  /**
18559
18559
  * Emit the final JSON Schema after processing.
18560
18560
  * Must call process() first.
18561
18561
  */
18562
- emit(schema, _params) {
18562
+ emit(schema2, _params) {
18563
18563
  if (_params) {
18564
18564
  if (_params.cycles)
18565
18565
  this.ctx.cycles = _params.cycles;
@@ -18570,8 +18570,8 @@ var JSONSchemaGenerator = class {
18570
18570
  }
18571
18571
  this.ctx.sharedDefsExtractedFor = void 0;
18572
18572
  this.ctx.sharedEmitDoneFor = void 0;
18573
- extractDefs(this.ctx, schema);
18574
- const result = finalize(this.ctx, schema);
18573
+ extractDefs(this.ctx, schema2);
18574
+ const result = finalize(this.ctx, schema2);
18575
18575
  const { "~standard": _, ...plainResult } = result;
18576
18576
  return plainResult;
18577
18577
  }
@@ -19664,8 +19664,8 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
19664
19664
  function array(element, params) {
19665
19665
  return _array(ZodArray, element, params);
19666
19666
  }
19667
- function keyof(schema) {
19668
- const shape = schema._zod.def.shape;
19667
+ function keyof(schema2) {
19668
+ const shape = schema2._zod.def.shape;
19669
19669
  return _enum2(Object.keys(shape));
19670
19670
  }
19671
19671
  var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
@@ -20313,11 +20313,11 @@ function json(params) {
20313
20313
  });
20314
20314
  return jsonSchema;
20315
20315
  }
20316
- function preprocess(fn, schema) {
20316
+ function preprocess(fn, schema2) {
20317
20317
  return new ZodPreprocess({
20318
20318
  type: "pipe",
20319
20319
  in: transform(fn),
20320
- out: schema
20320
+ out: schema2
20321
20321
  });
20322
20322
  }
20323
20323
 
@@ -20449,8 +20449,8 @@ var RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
20449
20449
  "nullable",
20450
20450
  "readOnly"
20451
20451
  ]);
20452
- function detectVersion(schema, defaultTarget) {
20453
- const $schema = schema.$schema;
20452
+ function detectVersion(schema2, defaultTarget) {
20453
+ const $schema = schema2.$schema;
20454
20454
  if ($schema === "https://json-schema.org/draft/2020-12/schema") {
20455
20455
  return "draft-2020-12";
20456
20456
  }
@@ -20678,27 +20678,27 @@ function getTupleRest(restSchema, ctx) {
20678
20678
  return convertSchema(restSchema, ctx);
20679
20679
  }
20680
20680
  var fullTime = /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
20681
- function convertBaseSchema(schema, ctx) {
20682
- if (schema.not !== void 0) {
20683
- if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
20681
+ function convertBaseSchema(schema2, ctx) {
20682
+ if (schema2.not !== void 0) {
20683
+ if (typeof schema2.not === "object" && Object.keys(schema2.not).length === 0) {
20684
20684
  return z.never();
20685
20685
  }
20686
20686
  throw new Error("not is not supported in Zod (except { not: {} } for never)");
20687
20687
  }
20688
- if (schema.unevaluatedItems !== void 0) {
20688
+ if (schema2.unevaluatedItems !== void 0) {
20689
20689
  throw new Error("unevaluatedItems is not supported");
20690
20690
  }
20691
- if (schema.unevaluatedProperties !== void 0) {
20691
+ if (schema2.unevaluatedProperties !== void 0) {
20692
20692
  throw new Error("unevaluatedProperties is not supported");
20693
20693
  }
20694
- if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) {
20694
+ if (schema2.if !== void 0 || schema2.then !== void 0 || schema2.else !== void 0) {
20695
20695
  throw new Error("Conditional schemas (if/then/else) are not supported");
20696
20696
  }
20697
- if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) {
20697
+ if (schema2.dependentSchemas !== void 0 || schema2.dependentRequired !== void 0) {
20698
20698
  throw new Error("dependentSchemas and dependentRequired are not supported");
20699
20699
  }
20700
- if (schema.$ref) {
20701
- const refPath = schema.$ref;
20700
+ if (schema2.$ref) {
20701
+ const refPath = schema2.$ref;
20702
20702
  if (ctx.refs.has(refPath)) {
20703
20703
  return ctx.refs.get(refPath);
20704
20704
  }
@@ -20717,9 +20717,9 @@ function convertBaseSchema(schema, ctx) {
20717
20717
  ctx.processing.delete(refPath);
20718
20718
  return zodSchema2;
20719
20719
  }
20720
- if (schema.enum !== void 0) {
20721
- const enumValues = schema.enum;
20722
- if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
20720
+ if (schema2.enum !== void 0) {
20721
+ const enumValues = schema2.enum;
20722
+ if (ctx.version === "openapi-3.0" && schema2.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
20723
20723
  return z.null();
20724
20724
  }
20725
20725
  if (enumValues.length === 0) {
@@ -20737,13 +20737,13 @@ function convertBaseSchema(schema, ctx) {
20737
20737
  }
20738
20738
  return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
20739
20739
  }
20740
- if (schema.const !== void 0) {
20741
- return z.literal(schema.const);
20740
+ if (schema2.const !== void 0) {
20741
+ return z.literal(schema2.const);
20742
20742
  }
20743
- const type = schema.type;
20743
+ const type = schema2.type;
20744
20744
  if (Array.isArray(type)) {
20745
20745
  const typeSchemas = type.map((t) => {
20746
- const typeSchema = { ...schema, type: t };
20746
+ const typeSchema = { ...schema2, type: t };
20747
20747
  return convertBaseSchema(typeSchema, ctx);
20748
20748
  });
20749
20749
  if (typeSchemas.length === 0) {
@@ -20761,8 +20761,8 @@ function convertBaseSchema(schema, ctx) {
20761
20761
  switch (type) {
20762
20762
  case "string": {
20763
20763
  let stringSchema = z.string();
20764
- if (schema.format) {
20765
- const format = schema.format;
20764
+ if (schema2.format) {
20765
+ const format = schema2.format;
20766
20766
  if (format === "email") {
20767
20767
  stringSchema = stringSchema.check(z.email());
20768
20768
  } else if (format === "uri" || format === "uri-reference") {
@@ -20817,14 +20817,14 @@ function convertBaseSchema(schema, ctx) {
20817
20817
  stringSchema = stringSchema.check(z.ksuid());
20818
20818
  }
20819
20819
  }
20820
- if (typeof schema.minLength === "number") {
20821
- stringSchema = stringSchema.min(schema.minLength);
20820
+ if (typeof schema2.minLength === "number") {
20821
+ stringSchema = stringSchema.min(schema2.minLength);
20822
20822
  }
20823
- if (typeof schema.maxLength === "number") {
20824
- stringSchema = stringSchema.max(schema.maxLength);
20823
+ if (typeof schema2.maxLength === "number") {
20824
+ stringSchema = stringSchema.max(schema2.maxLength);
20825
20825
  }
20826
- if (schema.pattern) {
20827
- stringSchema = stringSchema.regex(new RegExp(schema.pattern));
20826
+ if (schema2.pattern) {
20827
+ stringSchema = stringSchema.regex(new RegExp(schema2.pattern));
20828
20828
  }
20829
20829
  zodSchema = stringSchema;
20830
20830
  break;
@@ -20832,24 +20832,24 @@ function convertBaseSchema(schema, ctx) {
20832
20832
  case "number":
20833
20833
  case "integer": {
20834
20834
  let numberSchema = type === "integer" ? z.number().int() : z.number();
20835
- if (typeof schema.minimum === "number" && schema.exclusiveMinimum !== true) {
20836
- numberSchema = numberSchema.min(schema.minimum);
20835
+ if (typeof schema2.minimum === "number" && schema2.exclusiveMinimum !== true) {
20836
+ numberSchema = numberSchema.min(schema2.minimum);
20837
20837
  }
20838
- if (typeof schema.maximum === "number" && schema.exclusiveMaximum !== true) {
20839
- numberSchema = numberSchema.max(schema.maximum);
20838
+ if (typeof schema2.maximum === "number" && schema2.exclusiveMaximum !== true) {
20839
+ numberSchema = numberSchema.max(schema2.maximum);
20840
20840
  }
20841
- if (typeof schema.exclusiveMinimum === "number") {
20842
- numberSchema = numberSchema.gt(schema.exclusiveMinimum);
20843
- } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
20844
- numberSchema = numberSchema.gt(schema.minimum);
20841
+ if (typeof schema2.exclusiveMinimum === "number") {
20842
+ numberSchema = numberSchema.gt(schema2.exclusiveMinimum);
20843
+ } else if (schema2.exclusiveMinimum === true && typeof schema2.minimum === "number") {
20844
+ numberSchema = numberSchema.gt(schema2.minimum);
20845
20845
  }
20846
- if (typeof schema.exclusiveMaximum === "number") {
20847
- numberSchema = numberSchema.lt(schema.exclusiveMaximum);
20848
- } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
20849
- numberSchema = numberSchema.lt(schema.maximum);
20846
+ if (typeof schema2.exclusiveMaximum === "number") {
20847
+ numberSchema = numberSchema.lt(schema2.exclusiveMaximum);
20848
+ } else if (schema2.exclusiveMaximum === true && typeof schema2.maximum === "number") {
20849
+ numberSchema = numberSchema.lt(schema2.maximum);
20850
20850
  }
20851
- if (typeof schema.multipleOf === "number") {
20852
- numberSchema = numberSchema.multipleOf(schema.multipleOf);
20851
+ if (typeof schema2.multipleOf === "number") {
20852
+ numberSchema = numberSchema.multipleOf(schema2.multipleOf);
20853
20853
  }
20854
20854
  zodSchema = numberSchema;
20855
20855
  break;
@@ -20864,15 +20864,15 @@ function convertBaseSchema(schema, ctx) {
20864
20864
  }
20865
20865
  case "object": {
20866
20866
  const shape = {};
20867
- const properties = schema.properties || {};
20868
- const requiredSet = new Set(schema.required || []);
20869
- const additionalSchema = typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : void 0;
20867
+ const properties = schema2.properties || {};
20868
+ const requiredSet = new Set(schema2.required || []);
20869
+ const additionalSchema = typeof schema2.additionalProperties === "object" ? convertSchema(schema2.additionalProperties, ctx) : void 0;
20870
20870
  for (const [key, propSchema] of Object.entries(properties)) {
20871
20871
  const propZodSchema = convertSchema(propSchema, ctx);
20872
20872
  assignProp(shape, key, requiredSet.has(key) ? propZodSchema : propZodSchema.optional());
20873
20873
  }
20874
- if (schema.patternProperties) {
20875
- const patternProps = schema.patternProperties;
20874
+ if (schema2.patternProperties) {
20875
+ const patternProps = schema2.patternProperties;
20876
20876
  const patternKeys = Object.keys(patternProps);
20877
20877
  const looseRecords = [];
20878
20878
  for (const pattern of patternKeys) {
@@ -20896,7 +20896,7 @@ function convertBaseSchema(schema, ctx) {
20896
20896
  }
20897
20897
  zodSchema = result;
20898
20898
  }
20899
- if (schema.additionalProperties === false) {
20899
+ if (schema2.additionalProperties === false) {
20900
20900
  const propertyKeys = Object.keys(shape);
20901
20901
  const patterns = patternKeys.map((p) => new RegExp(p));
20902
20902
  const basePatternSchema = zodSchema;
@@ -20923,7 +20923,7 @@ function convertBaseSchema(schema, ctx) {
20923
20923
  }
20924
20924
  } else {
20925
20925
  const objectSchema = z.object(shape);
20926
- if (schema.additionalProperties === false) {
20926
+ if (schema2.additionalProperties === false) {
20927
20927
  zodSchema = objectSchema.strict();
20928
20928
  } else if (additionalSchema) {
20929
20929
  zodSchema = objectSchema.catchall(additionalSchema);
@@ -20931,13 +20931,13 @@ function convertBaseSchema(schema, ctx) {
20931
20931
  zodSchema = objectSchema.passthrough();
20932
20932
  }
20933
20933
  }
20934
- const hasKeyGuard = schema.propertyNames !== void 0 && schema.propertyNames !== true;
20935
- const minProperties = typeof schema.minProperties === "number" ? schema.minProperties : void 0;
20936
- const maxProperties = typeof schema.maxProperties === "number" ? schema.maxProperties : void 0;
20934
+ const hasKeyGuard = schema2.propertyNames !== void 0 && schema2.propertyNames !== true;
20935
+ const minProperties = typeof schema2.minProperties === "number" ? schema2.minProperties : void 0;
20936
+ const maxProperties = typeof schema2.maxProperties === "number" ? schema2.maxProperties : void 0;
20937
20937
  if (hasKeyGuard || minProperties !== void 0 || maxProperties !== void 0) {
20938
20938
  let keySchema;
20939
20939
  if (hasKeyGuard) {
20940
- const keyJSONSchema = typeof schema.propertyNames === "object" && schema.propertyNames.type === void 0 ? { type: "string", ...schema.propertyNames } : schema.propertyNames;
20940
+ const keyJSONSchema = typeof schema2.propertyNames === "object" && schema2.propertyNames.type === void 0 ? { type: "string", ...schema2.propertyNames } : schema2.propertyNames;
20941
20941
  keySchema = convertSchema(keyJSONSchema, ctx);
20942
20942
  }
20943
20943
  zodSchema = checkObjectGuards(zodSchema, { keySchema, minProperties, maxProperties });
@@ -20945,53 +20945,53 @@ function convertBaseSchema(schema, ctx) {
20945
20945
  break;
20946
20946
  }
20947
20947
  case "array": {
20948
- const prefixItems = schema.prefixItems;
20949
- const items = schema.items;
20948
+ const prefixItems = schema2.prefixItems;
20949
+ const items = schema2.items;
20950
20950
  if (prefixItems && Array.isArray(prefixItems)) {
20951
- const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
20951
+ const minItems = typeof schema2.minItems === "number" ? schema2.minItems : 0;
20952
20952
  const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
20953
20953
  const positionalItems = applyMinItems(tupleItems, minItems);
20954
20954
  const rest = !Array.isArray(items) ? getTupleRest(items, ctx) : void 0;
20955
20955
  const tupleSchema = z.tuple(positionalItems);
20956
20956
  zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
20957
- if (typeof schema.minItems === "number") {
20958
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
20957
+ if (typeof schema2.minItems === "number") {
20958
+ zodSchema = zodSchema.check(z.minLength(schema2.minItems));
20959
20959
  }
20960
- if (typeof schema.maxItems === "number") {
20961
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
20960
+ if (typeof schema2.maxItems === "number") {
20961
+ zodSchema = zodSchema.check(z.maxLength(schema2.maxItems));
20962
20962
  }
20963
20963
  } else if (Array.isArray(items)) {
20964
- const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
20964
+ const minItems = typeof schema2.minItems === "number" ? schema2.minItems : 0;
20965
20965
  const tupleItems = items.map((item) => convertSchema(item, ctx));
20966
20966
  const positionalItems = applyMinItems(tupleItems, minItems);
20967
- const rest = getTupleRest(schema.additionalItems, ctx);
20967
+ const rest = getTupleRest(schema2.additionalItems, ctx);
20968
20968
  const tupleSchema = z.tuple(positionalItems);
20969
20969
  zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
20970
- if (typeof schema.minItems === "number") {
20971
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
20970
+ if (typeof schema2.minItems === "number") {
20971
+ zodSchema = zodSchema.check(z.minLength(schema2.minItems));
20972
20972
  }
20973
- if (typeof schema.maxItems === "number") {
20974
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
20973
+ if (typeof schema2.maxItems === "number") {
20974
+ zodSchema = zodSchema.check(z.maxLength(schema2.maxItems));
20975
20975
  }
20976
20976
  } else if (items !== void 0) {
20977
20977
  const element = convertSchema(items, ctx);
20978
20978
  let arraySchema = z.array(element);
20979
- if (typeof schema.minItems === "number") {
20980
- arraySchema = arraySchema.min(schema.minItems);
20979
+ if (typeof schema2.minItems === "number") {
20980
+ arraySchema = arraySchema.min(schema2.minItems);
20981
20981
  }
20982
- if (typeof schema.maxItems === "number") {
20983
- arraySchema = arraySchema.max(schema.maxItems);
20982
+ if (typeof schema2.maxItems === "number") {
20983
+ arraySchema = arraySchema.max(schema2.maxItems);
20984
20984
  }
20985
20985
  zodSchema = arraySchema;
20986
20986
  } else {
20987
20987
  zodSchema = z.array(z.any());
20988
20988
  }
20989
- if (schema.uniqueItems === true || schema.contains !== void 0) {
20989
+ if (schema2.uniqueItems === true || schema2.contains !== void 0) {
20990
20990
  zodSchema = checkArrayGuards(zodSchema, {
20991
- uniqueItems: schema.uniqueItems === true,
20992
- containsSchema: schema.contains !== void 0 ? convertSchema(schema.contains, ctx) : void 0,
20993
- minContains: typeof schema.minContains === "number" ? schema.minContains : void 0,
20994
- maxContains: typeof schema.maxContains === "number" ? schema.maxContains : void 0
20991
+ uniqueItems: schema2.uniqueItems === true,
20992
+ containsSchema: schema2.contains !== void 0 ? convertSchema(schema2.contains, ctx) : void 0,
20993
+ minContains: typeof schema2.minContains === "number" ? schema2.minContains : void 0,
20994
+ maxContains: typeof schema2.maxContains === "number" ? schema2.maxContains : void 0
20995
20995
  });
20996
20996
  }
20997
20997
  break;
@@ -21001,94 +21001,94 @@ function convertBaseSchema(schema, ctx) {
21001
21001
  }
21002
21002
  return zodSchema;
21003
21003
  }
21004
- function convertSchema(schema, ctx) {
21005
- if (typeof schema === "boolean") {
21006
- return schema ? z.any() : z.never();
21004
+ function convertSchema(schema2, ctx) {
21005
+ if (typeof schema2 === "boolean") {
21006
+ return schema2 ? z.any() : z.never();
21007
21007
  }
21008
- let baseSchema = convertBaseSchema(schema, ctx);
21009
- const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
21010
- if (schema.anyOf && Array.isArray(schema.anyOf)) {
21011
- const options = schema.anyOf.map((s) => convertSchema(s, ctx));
21008
+ let baseSchema = convertBaseSchema(schema2, ctx);
21009
+ const hasExplicitType = schema2.type || schema2.enum !== void 0 || schema2.const !== void 0;
21010
+ if (schema2.anyOf && Array.isArray(schema2.anyOf)) {
21011
+ const options = schema2.anyOf.map((s) => convertSchema(s, ctx));
21012
21012
  const anyOfUnion = z.union(options);
21013
21013
  baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
21014
21014
  }
21015
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
21016
- const options = schema.oneOf.map((s) => convertSchema(s, ctx));
21015
+ if (schema2.oneOf && Array.isArray(schema2.oneOf)) {
21016
+ const options = schema2.oneOf.map((s) => convertSchema(s, ctx));
21017
21017
  const oneOfUnion = z.xor(options);
21018
21018
  baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
21019
21019
  }
21020
- if (schema.allOf && Array.isArray(schema.allOf)) {
21021
- if (schema.allOf.length === 0) {
21020
+ if (schema2.allOf && Array.isArray(schema2.allOf)) {
21021
+ if (schema2.allOf.length === 0) {
21022
21022
  baseSchema = hasExplicitType ? baseSchema : z.any();
21023
21023
  } else {
21024
- let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
21024
+ let result = hasExplicitType ? baseSchema : convertSchema(schema2.allOf[0], ctx);
21025
21025
  const startIdx = hasExplicitType ? 0 : 1;
21026
- for (let i = startIdx; i < schema.allOf.length; i++) {
21027
- result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
21026
+ for (let i = startIdx; i < schema2.allOf.length; i++) {
21027
+ result = z.intersection(result, convertSchema(schema2.allOf[i], ctx));
21028
21028
  }
21029
21029
  baseSchema = result;
21030
21030
  }
21031
21031
  }
21032
- if (schema.nullable === true && ctx.version === "openapi-3.0") {
21032
+ if (schema2.nullable === true && ctx.version === "openapi-3.0") {
21033
21033
  baseSchema = z.nullable(baseSchema);
21034
21034
  }
21035
- if (schema.readOnly === true) {
21035
+ if (schema2.readOnly === true) {
21036
21036
  baseSchema = z.readonly(baseSchema);
21037
21037
  }
21038
- if (schema.default !== void 0) {
21039
- baseSchema = baseSchema.default(schema.default);
21038
+ if (schema2.default !== void 0) {
21039
+ baseSchema = baseSchema.default(schema2.default);
21040
21040
  }
21041
21041
  const extraMeta = {};
21042
21042
  const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
21043
21043
  for (const key of coreMetadataKeys) {
21044
- if (key in schema) {
21045
- extraMeta[key] = schema[key];
21044
+ if (key in schema2) {
21045
+ extraMeta[key] = schema2[key];
21046
21046
  }
21047
21047
  }
21048
21048
  const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
21049
21049
  for (const key of contentMetadataKeys) {
21050
- if (key in schema) {
21051
- extraMeta[key] = schema[key];
21050
+ if (key in schema2) {
21051
+ extraMeta[key] = schema2[key];
21052
21052
  }
21053
21053
  }
21054
- if (schema.type === "object" && schema.$ref === void 0) {
21055
- if (schema.propertyNames !== void 0 && !containsRef(schema.propertyNames)) {
21056
- extraMeta.propertyNames = schema.propertyNames;
21054
+ if (schema2.type === "object" && schema2.$ref === void 0) {
21055
+ if (schema2.propertyNames !== void 0 && !containsRef(schema2.propertyNames)) {
21056
+ extraMeta.propertyNames = schema2.propertyNames;
21057
21057
  }
21058
21058
  for (const key of ["minProperties", "maxProperties"]) {
21059
- if (schema[key] !== void 0)
21060
- extraMeta[key] = schema[key];
21059
+ if (schema2[key] !== void 0)
21060
+ extraMeta[key] = schema2[key];
21061
21061
  }
21062
21062
  }
21063
- if (schema.type === "array" && schema.$ref === void 0) {
21064
- if (schema.contains !== void 0 && !containsRef(schema.contains)) {
21065
- extraMeta.contains = schema.contains;
21063
+ if (schema2.type === "array" && schema2.$ref === void 0) {
21064
+ if (schema2.contains !== void 0 && !containsRef(schema2.contains)) {
21065
+ extraMeta.contains = schema2.contains;
21066
21066
  }
21067
21067
  for (const key of ["uniqueItems", "minContains", "maxContains"]) {
21068
- if (schema[key] !== void 0)
21069
- extraMeta[key] = schema[key];
21068
+ if (schema2[key] !== void 0)
21069
+ extraMeta[key] = schema2[key];
21070
21070
  }
21071
21071
  }
21072
- for (const key of Object.keys(schema)) {
21072
+ for (const key of Object.keys(schema2)) {
21073
21073
  if (!RECOGNIZED_KEYS.has(key)) {
21074
- assignProp(extraMeta, key, schema[key]);
21074
+ assignProp(extraMeta, key, schema2[key]);
21075
21075
  }
21076
21076
  }
21077
21077
  if (Object.keys(extraMeta).length > 0) {
21078
21078
  ctx.registry.add(baseSchema, extraMeta);
21079
21079
  }
21080
- if (schema.description) {
21081
- baseSchema = baseSchema.describe(schema.description);
21080
+ if (schema2.description) {
21081
+ baseSchema = baseSchema.describe(schema2.description);
21082
21082
  }
21083
21083
  return baseSchema;
21084
21084
  }
21085
- function fromJSONSchema(schema, params) {
21086
- if (typeof schema === "boolean") {
21087
- return schema ? z.any() : z.never();
21085
+ function fromJSONSchema(schema2, params) {
21086
+ if (typeof schema2 === "boolean") {
21087
+ return schema2 ? z.any() : z.never();
21088
21088
  }
21089
21089
  let normalized;
21090
21090
  try {
21091
- normalized = JSON.parse(JSON.stringify(schema));
21091
+ normalized = JSON.parse(JSON.stringify(schema2));
21092
21092
  } catch {
21093
21093
  throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
21094
21094
  }
@@ -21107,13 +21107,13 @@ function fromJSONSchema(schema, params) {
21107
21107
 
21108
21108
  // node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/visit.js
21109
21109
  var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
21110
- function visit(schema, fnOrHandlers) {
21110
+ function visit(schema2, fnOrHandlers) {
21111
21111
  const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
21112
21112
  const h = fnOrHandlers[node2._zod.def.type];
21113
21113
  return h ? h(node2, rewritten) : node2;
21114
21114
  };
21115
21115
  const cache = /* @__PURE__ */ new Map();
21116
- function run2(s) {
21116
+ function run(s) {
21117
21117
  const cached2 = cache.get(s);
21118
21118
  if (cached2 === RESOLVING) {
21119
21119
  return new $ZodLazy({
@@ -21139,21 +21139,21 @@ function visit(schema, fnOrHandlers) {
21139
21139
  let changed = false;
21140
21140
  const newShape = {};
21141
21141
  for (const k of keys) {
21142
- const mapped = run2(oldShape[k]);
21142
+ const mapped = run(oldShape[k]);
21143
21143
  if (mapped !== oldShape[k])
21144
21144
  changed = true;
21145
21145
  newShape[k] = mapped;
21146
21146
  }
21147
21147
  let newCatchall = def.catchall;
21148
21148
  if (def.catchall) {
21149
- newCatchall = run2(def.catchall);
21149
+ newCatchall = run(def.catchall);
21150
21150
  if (newCatchall !== def.catchall)
21151
21151
  changed = true;
21152
21152
  }
21153
21153
  return changed ? clone(s, { ...def, shape: newShape, catchall: newCatchall }) : s;
21154
21154
  }
21155
21155
  case "array": {
21156
- const mapped = run2(def.element);
21156
+ const mapped = run(def.element);
21157
21157
  return mapped === def.element ? s : clone(s, { ...def, element: mapped });
21158
21158
  }
21159
21159
  case "tuple": {
@@ -21161,14 +21161,14 @@ function visit(schema, fnOrHandlers) {
21161
21161
  let changed = false;
21162
21162
  const newItems = [];
21163
21163
  for (const item of oldItems) {
21164
- const mapped = run2(item);
21164
+ const mapped = run(item);
21165
21165
  if (mapped !== item)
21166
21166
  changed = true;
21167
21167
  newItems.push(mapped);
21168
21168
  }
21169
21169
  let newRest = def.rest;
21170
21170
  if (def.rest) {
21171
- newRest = run2(def.rest);
21171
+ newRest = run(def.rest);
21172
21172
  if (newRest !== def.rest)
21173
21173
  changed = true;
21174
21174
  }
@@ -21176,12 +21176,12 @@ function visit(schema, fnOrHandlers) {
21176
21176
  }
21177
21177
  case "record":
21178
21178
  case "map": {
21179
- const newKey = run2(def.keyType);
21180
- const newVal = run2(def.valueType);
21179
+ const newKey = run(def.keyType);
21180
+ const newVal = run(def.valueType);
21181
21181
  return newKey === def.keyType && newVal === def.valueType ? s : clone(s, { ...def, keyType: newKey, valueType: newVal });
21182
21182
  }
21183
21183
  case "set": {
21184
- const newVal = run2(def.valueType);
21184
+ const newVal = run(def.valueType);
21185
21185
  return newVal === def.valueType ? s : clone(s, { ...def, valueType: newVal });
21186
21186
  }
21187
21187
  case "union": {
@@ -21189,7 +21189,7 @@ function visit(schema, fnOrHandlers) {
21189
21189
  let changed = false;
21190
21190
  const newOptions = [];
21191
21191
  for (const opt of oldOptions) {
21192
- const mapped = run2(opt);
21192
+ const mapped = run(opt);
21193
21193
  if (mapped !== opt)
21194
21194
  changed = true;
21195
21195
  newOptions.push(mapped);
@@ -21197,8 +21197,8 @@ function visit(schema, fnOrHandlers) {
21197
21197
  return changed ? clone(s, { ...def, options: newOptions }) : s;
21198
21198
  }
21199
21199
  case "intersection": {
21200
- const newLeft = run2(def.left);
21201
- const newRight = run2(def.right);
21200
+ const newLeft = run(def.left);
21201
+ const newRight = run(def.right);
21202
21202
  return newLeft === def.left && newRight === def.right ? s : clone(s, { ...def, left: newLeft, right: newRight });
21203
21203
  }
21204
21204
  case "optional":
@@ -21210,23 +21210,23 @@ function visit(schema, fnOrHandlers) {
21210
21210
  case "nonoptional":
21211
21211
  case "promise":
21212
21212
  case "success": {
21213
- const newInner = run2(def.innerType);
21213
+ const newInner = run(def.innerType);
21214
21214
  return newInner === def.innerType ? s : clone(s, { ...def, innerType: newInner });
21215
21215
  }
21216
21216
  case "pipe": {
21217
- const newIn = run2(def.in);
21218
- const newOut = run2(def.out);
21217
+ const newIn = run(def.in);
21218
+ const newOut = run(def.out);
21219
21219
  return newIn === def.in && newOut === def.out ? s : clone(s, { ...def, in: newIn, out: newOut });
21220
21220
  }
21221
21221
  case "function": {
21222
- const newInput = run2(def.input);
21223
- const newOutput = run2(def.output);
21222
+ const newInput = run(def.input);
21223
+ const newOutput = run(def.output);
21224
21224
  return newInput === def.input && newOutput === def.output ? s : clone(s, { ...def, input: newInput, output: newOutput });
21225
21225
  }
21226
21226
  case "lazy": {
21227
21227
  const original = def.getter;
21228
21228
  const { _cachedInner, ...rest } = def;
21229
- return clone(s, { ...rest, getter: () => run2(original()) });
21229
+ return clone(s, { ...rest, getter: () => run(original()) });
21230
21230
  }
21231
21231
  // A leaf by choice: `parts` are regex fragments, not data positions.
21232
21232
  case "template_literal":
@@ -21257,12 +21257,12 @@ function visit(schema, fnOrHandlers) {
21257
21257
  }
21258
21258
  }
21259
21259
  }
21260
- return run2(schema);
21260
+ return run(schema2);
21261
21261
  }
21262
21262
 
21263
21263
  // node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/deep-partial.js
21264
- function deepPartial(schema) {
21265
- return visit(schema, {
21264
+ function deepPartial(schema2) {
21265
+ return visit(schema2, {
21266
21266
  object: (s) => s.partial(),
21267
21267
  // Every partialed option now admits `undefined`, which the constructor rejects as a duplicate.
21268
21268
  union: (s) => {
@@ -21285,8 +21285,8 @@ function outSide(def) {
21285
21285
  function inSide(def) {
21286
21286
  return def.in._zod.traits.has("$ZodTransform") ? outSide(def) : def.in;
21287
21287
  }
21288
- function input(schema) {
21289
- return visit(schema, {
21288
+ function input(schema2) {
21289
+ return visit(schema2, {
21290
21290
  pipe: (s) => inSide(s._zod.def),
21291
21291
  // A default value belongs to the output side, so a rewritten inner type leaves it stranded. `.default()` widens the declared input type with `undefined`, and `optional` is what carries that across.
21292
21292
  default: (s, rewritten) => rewritten ? optional(s._zod.def.innerType) : s,
@@ -21294,8 +21294,8 @@ function input(schema) {
21294
21294
  catch: (s, rewritten) => rewritten ? s._zod.def.innerType : s
21295
21295
  });
21296
21296
  }
21297
- function output(schema) {
21298
- return visit(schema, {
21297
+ function output(schema2) {
21298
+ return visit(schema2, {
21299
21299
  pipe: (s) => outSide(s._zod.def),
21300
21300
  // A prefault value is fed through the schema, which makes it input-side, so a rewritten inner type leaves it stranded.
21301
21301
  prefault: (s, rewritten) => rewritten ? s._zod.def.innerType : s
@@ -21913,6 +21913,30 @@ function validVersion(version3) {
21913
21913
  match && (!match[4] || match[4].split(".").every((part) => !/^\d+$/.test(part) || part === "0" || !part.startsWith("0")))
21914
21914
  );
21915
21915
  }
21916
+ function compareVersions(left, right) {
21917
+ if (!validVersion(left) || !validVersion(right)) throw new Error("Invalid release version");
21918
+ const a = versionPattern.exec(left);
21919
+ const b = versionPattern.exec(right);
21920
+ for (let i = 1; i <= 3; i++) {
21921
+ const difference = BigInt(a[i]) - BigInt(b[i]);
21922
+ if (difference) return difference > 0 ? 1 : -1;
21923
+ }
21924
+ if (!a[4] || !b[4]) return a[4] === b[4] ? 0 : a[4] ? -1 : 1;
21925
+ const ap = a[4].split(".");
21926
+ const bp = b[4].split(".");
21927
+ for (let i = 0; i < Math.max(ap.length, bp.length); i++) {
21928
+ const x = ap[i];
21929
+ const y = bp[i];
21930
+ if (x === y) continue;
21931
+ if (x === void 0 || y === void 0) return x === void 0 ? -1 : 1;
21932
+ const xn = /^\d+$/.test(x);
21933
+ const yn = /^\d+$/.test(y);
21934
+ if (xn && yn) return BigInt(x) > BigInt(y) ? 1 : -1;
21935
+ if (xn !== yn) return xn ? -1 : 1;
21936
+ return x > y ? 1 : -1;
21937
+ }
21938
+ return 0;
21939
+ }
21916
21940
 
21917
21941
  // src/shared/codex-compatibility.ts
21918
21942
  var version2 = external_exports.string().max(128).refine(validVersion);
@@ -21965,13 +21989,13 @@ function requireCodexCompatibility(metadata, running, confirmed = false) {
21965
21989
  }
21966
21990
 
21967
21991
  // src/updates/worker.ts
21968
- var import_node_child_process4 = require("node:child_process");
21969
- var import_node_util4 = require("node:util");
21992
+ var import_node_child_process5 = require("node:child_process");
21993
+ var import_node_util5 = require("node:util");
21970
21994
  var import_node_module = require("node:module");
21971
- var import_promises12 = require("node:fs/promises");
21972
- var import_node_fs4 = require("node:fs");
21973
- var import_node_path11 = require("node:path");
21974
- var import_promises13 = require("node:timers/promises");
21995
+ var import_promises14 = require("node:fs/promises");
21996
+ var import_node_fs5 = require("node:fs");
21997
+ var import_node_path13 = require("node:path");
21998
+ var import_promises15 = require("node:timers/promises");
21975
21999
  var import_proper_lockfile7 = __toESM(require_proper_lockfile(), 1);
21976
22000
 
21977
22001
  // src/cli/control.ts
@@ -21979,7 +22003,7 @@ var import_node_http = require("node:http");
21979
22003
  var import_proper_lockfile5 = __toESM(require_proper_lockfile(), 1);
21980
22004
  var import_promises5 = require("node:timers/promises");
21981
22005
  function control(location, action, input2 = {}) {
21982
- return new Promise((resolve3, reject) => {
22006
+ return new Promise((resolve4, reject) => {
21983
22007
  const requestBody = JSON.stringify(input2);
21984
22008
  const outgoing = (0, import_node_http.request)(
21985
22009
  {
@@ -22003,7 +22027,7 @@ function control(location, action, input2 = {}) {
22003
22027
  const result = JSON.parse(body);
22004
22028
  if (incoming.statusCode !== 200)
22005
22029
  reject(new Error(result.error ?? "Control request failed"));
22006
- else resolve3(result);
22030
+ else resolve4(result);
22007
22031
  } catch (error62) {
22008
22032
  reject(error62);
22009
22033
  }
@@ -22037,11 +22061,11 @@ async function stopAndWait(location) {
22037
22061
  }
22038
22062
 
22039
22063
  // src/cli/background.ts
22040
- var import_node_child_process2 = require("node:child_process");
22041
- var import_promises8 = require("node:fs/promises");
22042
- var import_node_path8 = require("node:path");
22043
- var import_node_util2 = require("node:util");
22044
- var import_promises9 = require("node:timers/promises");
22064
+ var import_node_child_process3 = require("node:child_process");
22065
+ var import_promises9 = require("node:fs/promises");
22066
+ var import_node_path9 = require("node:path");
22067
+ var import_node_util3 = require("node:util");
22068
+ var import_promises10 = require("node:timers/promises");
22045
22069
  var import_proper_lockfile6 = __toESM(require_proper_lockfile(), 1);
22046
22070
 
22047
22071
  // src/cli/launchd.ts
@@ -22057,14 +22081,17 @@ var import_node_net = require("node:net");
22057
22081
  var import_promises6 = require("node:fs/promises");
22058
22082
  var import_node_crypto4 = require("node:crypto");
22059
22083
  var import_node_path6 = require("node:path");
22060
- async function environmentBridge(home) {
22084
+ async function environmentBridge(home, runtimePath = process.env.PATH) {
22061
22085
  const path = (0, import_node_path6.join)(home, `e-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}.sock`);
22062
22086
  const clients = /* @__PURE__ */ new Set();
22063
22087
  let accept;
22064
- const consumed = new Promise((resolve3) => {
22065
- accept = resolve3;
22088
+ const consumed = new Promise((resolve4) => {
22089
+ accept = resolve4;
22090
+ });
22091
+ const payload = JSON.stringify({
22092
+ env: { ...process.env, PATH: runtimePath, COVRO_HOME: home },
22093
+ cwd: process.cwd()
22066
22094
  });
22067
- const payload = JSON.stringify({ env: { ...process.env, COVRO_HOME: home }, cwd: process.cwd() });
22068
22095
  const server = (0, import_node_net.createServer)((socket) => {
22069
22096
  clients.add(socket);
22070
22097
  socket.setTimeout(5e3, () => socket.destroy());
@@ -22074,9 +22101,9 @@ async function environmentBridge(home) {
22074
22101
  socket.end(payload, () => accept?.());
22075
22102
  });
22076
22103
  try {
22077
- await new Promise((resolve3, reject) => {
22104
+ await new Promise((resolve4, reject) => {
22078
22105
  server.once("error", reject);
22079
- server.listen(path, resolve3);
22106
+ server.listen(path, resolve4);
22080
22107
  });
22081
22108
  await (0, import_promises6.chmod)(path, 384);
22082
22109
  return {
@@ -22100,7 +22127,7 @@ async function environmentBridge(home) {
22100
22127
  async close() {
22101
22128
  for (const socket of clients) socket.destroy();
22102
22129
  await new Promise(
22103
- (resolve3, reject) => server.close((error62) => error62 ? reject(error62) : resolve3())
22130
+ (resolve4, reject) => server.close((error62) => error62 ? reject(error62) : resolve4())
22104
22131
  );
22105
22132
  await (0, import_promises6.rm)(path, { force: true });
22106
22133
  }
@@ -22181,10 +22208,10 @@ async function loginRegistration(location) {
22181
22208
  throw new Error("\u767B\u5F55\u670D\u52A1\u8EAB\u4EFD\u4E0E\u5F53\u524D\u914D\u7F6E\u4E0D\u5339\u914D");
22182
22209
  return installed;
22183
22210
  }
22184
- function launchdPlist(location, args, login) {
22211
+ function launchdPlist(location, args, login, path = process.env.PATH ?? "/usr/bin:/bin") {
22185
22212
  const { label } = launchdPaths(location, login ? `dev.covro.${location.key}` : void 0);
22186
22213
  const environment = {
22187
- PATH: process.env.PATH ?? "/usr/bin:/bin",
22214
+ PATH: path,
22188
22215
  COVRO_HOME: location.home,
22189
22216
  ...process.env.CODEX_HOME ? { CODEX_HOME: process.env.CODEX_HOME } : {}
22190
22217
  };
@@ -22220,7 +22247,7 @@ async function unloadLaunchd(location) {
22220
22247
  }
22221
22248
  await (0, import_promises7.rm)(temporary, { force: true });
22222
22249
  }
22223
- async function startLaunchd(location, entry) {
22250
+ async function startLaunchd(location, entry, runtime) {
22224
22251
  const installed = await loginRegistration(location);
22225
22252
  const { domain: domain2, target, temporary, login } = launchdPaths(location, installed?.label);
22226
22253
  if (!await guiSessionAvailable(location)) {
@@ -22233,7 +22260,7 @@ async function startLaunchd(location, entry) {
22233
22260
  await launchctl(["bootstrap", domain2, login]);
22234
22261
  return true;
22235
22262
  }
22236
- const bridge = await environmentBridge(location.home);
22263
+ const bridge = await environmentBridge(location.home, runtime?.path);
22237
22264
  try {
22238
22265
  const runner = (0, import_node_path7.join)(location.state, "launch-runner.mjs");
22239
22266
  await (0, import_promises7.writeFile)(runner, launchRunner, { mode: 384 });
@@ -22241,8 +22268,9 @@ async function startLaunchd(location, entry) {
22241
22268
  temporary,
22242
22269
  launchdPlist(
22243
22270
  location,
22244
- [process.execPath, runner, bridge.path, entry, location.config],
22245
- false
22271
+ [runtime?.node ?? process.execPath, runner, bridge.path, entry, location.config],
22272
+ false,
22273
+ runtime?.path
22246
22274
  ),
22247
22275
  { mode: 384 }
22248
22276
  );
@@ -22266,12 +22294,110 @@ async function startLaunchd(location, entry) {
22266
22294
  }
22267
22295
  }
22268
22296
 
22269
- // src/cli/background.ts
22297
+ // src/cli/runtime-launch.ts
22298
+ var import_node_child_process2 = require("node:child_process");
22299
+ var import_node_util2 = require("node:util");
22300
+ var import_promises8 = require("node:fs/promises");
22301
+ var import_node_os2 = require("node:os");
22302
+ var import_node_path8 = require("node:path");
22270
22303
  var exec2 = (0, import_node_util2.promisify)(import_node_child_process2.execFile);
22304
+ var schema = external_exports.object({ node: external_exports.string().startsWith("/"), entry: external_exports.string().startsWith("/"), path: external_exports.string() }).strict();
22305
+ var runtimeFile = (location) => (0, import_node_path8.join)(location.state, "runtime.json");
22306
+ async function launchRuntime(location, entry, override) {
22307
+ const saved = override ?? await readJson(runtimeFile(location));
22308
+ return saved ? schema.parse(saved) : { node: process.execPath, entry, path: process.env.PATH ?? "/usr/bin:/bin" };
22309
+ }
22310
+ var systemdQuote = (value) => `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"').replaceAll("%", "%%").replaceAll("$", () => "$$")}"`;
22311
+ var xml2 = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
22312
+ function serviceContent(location, runtime, service) {
22313
+ const { content, platform } = service;
22314
+ const args = [runtime.node, runtime.entry, "run", "--config", location.config];
22315
+ return platform === "darwin" ? content.replace(
22316
+ /<key>ProgramArguments<\/key><array>.*?<\/array>/s,
22317
+ () => `<key>ProgramArguments</key><array>${args.map((arg) => `<string>${xml2(arg)}</string>`).join("")}</array>`
22318
+ ).replace(
22319
+ /<key>PATH<\/key><string>[^<]*<\/string>/,
22320
+ () => `<key>PATH</key><string>${xml2(runtime.path)}</string>`
22321
+ ) : content.replace(/^ExecStart=.*$/m, () => `ExecStart=${args.map(systemdQuote).join(" ")}`).replace(/"PATH=(?:\\.|[^"\\])*"/, () => systemdQuote(`PATH=${runtime.path}`));
22322
+ }
22323
+ async function snapshotLaunch(location, current) {
22324
+ const runtime = await readJson(runtimeFile(location));
22325
+ const installed = await readJson(
22326
+ (0, import_node_path8.join)(location.state, "service.json")
22327
+ );
22328
+ if (!installed) {
22329
+ if (process.env.INVOCATION_ID || process.env.PM2_HOME || process.env.SUPERVISOR_ENABLED)
22330
+ throw new Error("\u68C0\u6D4B\u5230\u5916\u90E8\u8FDB\u7A0B\u7BA1\u7406\u5668\uFF1B\u8BF7\u4F7F\u7528\u539F\u7BA1\u7406\u5668\u4FEE\u6539 Node \u548C Covro \u542F\u52A8\u8DEF\u5F84\u540E\u91CD\u542F\u3002");
22331
+ return { runtime };
22332
+ }
22333
+ if (installed.platform !== process.platform || installed.label !== `dev.covro.${location.key}`)
22334
+ throw new Error("\u767B\u5F55\u670D\u52A1\u8EAB\u4EFD\u4E0D\u5339\u914D\uFF1B\u8BF7\u7528\u76EE\u6807 Node \u91CD\u65B0\u5B89\u88C5 Covro \u767B\u5F55\u670D\u52A1\u3002");
22335
+ const filename = installed.platform === "darwin" ? launchdPaths(location, installed.label).login : (0, import_node_path8.join)((0, import_node_os2.homedir)(), ".config/systemd/user", `${installed.label}.service`);
22336
+ const content = await (0, import_promises8.readFile)(filename, "utf8");
22337
+ const expected = installed.platform === "darwin" ? `<key>ProgramArguments</key><array>${[current.node, current.entry, "run", "--config", location.config].map((arg) => `<string>${xml2(arg)}</string>`).join("")}</array>` : `ExecStart=${[current.node, current.entry, "run", "--config", location.config].map(systemdQuote).join(" ")}`;
22338
+ if (!content.includes(expected))
22339
+ throw new Error(
22340
+ `\u670D\u52A1\u542F\u52A8\u6765\u6E90\u4E0E\u8FD0\u884C\u5B9E\u4F8B\u4E0D\u5339\u914D\uFF1A${filename}\uFF1B\u8BF7\u6838\u5BF9\u81EA\u5B9A\u4E49\u670D\u52A1\u914D\u7F6E\uFF0C\u5F53\u524D\u670D\u52A1\u4FDD\u6301\u8FD0\u884C\u3002`
22341
+ );
22342
+ if (installed.platform === "linux") {
22343
+ const { stdout } = await exec2(
22344
+ "systemctl",
22345
+ ["--user", "show", `${installed.label}.service`, "--property=FragmentPath,DropInPaths"],
22346
+ { timeout: 5e3 }
22347
+ );
22348
+ const properties = Object.fromEntries(
22349
+ stdout.trim().split("\n").map((line) => {
22350
+ const i = line.indexOf("=");
22351
+ return [line.slice(0, i), line.slice(i + 1)];
22352
+ })
22353
+ );
22354
+ if (properties.FragmentPath !== filename || properties.DropInPaths !== "")
22355
+ throw new Error(
22356
+ "systemd \u5B9E\u9645\u52A0\u8F7D\u6765\u6E90\u4E0E Covro \u670D\u52A1\u6587\u4EF6\u4E0D\u5339\u914D\u6216\u5B58\u5728\u81EA\u5B9A\u4E49 drop-in\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002"
22357
+ );
22358
+ }
22359
+ return { runtime, service: { filename, content, platform: installed.platform } };
22360
+ }
22361
+ async function switchLaunch(location, runtime, snapshot) {
22362
+ schema.parse(runtime);
22363
+ if (/[\r\n]/.test([runtime.node, runtime.entry, runtime.path].join("")))
22364
+ throw new Error("\u8FD0\u884C\u73AF\u5883\u8DEF\u5F84\u4E0D\u80FD\u5305\u542B\u6362\u884C");
22365
+ snapshot.target = runtime;
22366
+ if (snapshot.service) {
22367
+ const { filename, content, platform } = snapshot.service;
22368
+ if (await (0, import_promises8.readFile)(filename, "utf8") !== content)
22369
+ throw new Error("\u670D\u52A1\u6587\u4EF6\u5728\u5347\u7EA7\u671F\u95F4\u88AB\u4FEE\u6539\uFF0C\u62D2\u7EDD\u8986\u76D6\u3002");
22370
+ const updated = serviceContent(location, runtime, snapshot.service);
22371
+ await (0, import_promises8.writeFile)(filename, updated, { mode: 384 });
22372
+ if (platform === "linux")
22373
+ await exec2("systemctl", ["--user", "daemon-reload"], { timeout: 5e3 });
22374
+ }
22375
+ await saveJson(runtimeFile(location), runtime);
22376
+ }
22377
+ async function restoreLaunch(location, snapshot) {
22378
+ if (snapshot.service) {
22379
+ const current2 = await (0, import_promises8.readFile)(snapshot.service.filename, "utf8");
22380
+ if (current2 !== snapshot.service.content && (!snapshot.target || current2 !== serviceContent(location, snapshot.target, snapshot.service)))
22381
+ throw new Error("\u670D\u52A1\u6587\u4EF6\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u62D2\u7EDD\u5728\u6062\u590D\u65F6\u8986\u76D6\uFF1B\u8BF7\u4FDD\u7559\u73B0\u573A\u5E76\u6838\u5BF9\u542F\u52A8\u6765\u6E90\u3002");
22382
+ await (0, import_promises8.writeFile)(snapshot.service.filename, snapshot.service.content, { mode: 384 });
22383
+ if (snapshot.service.platform === "linux")
22384
+ await exec2("systemctl", ["--user", "daemon-reload"], { timeout: 5e3 });
22385
+ }
22386
+ const current = await readJson(runtimeFile(location));
22387
+ if (current && snapshot.target && ![snapshot.runtime, snapshot.target].some(
22388
+ (value) => value && value.node === current.node && value.entry === current.entry && value.path === current.path
22389
+ ))
22390
+ throw new Error("\u5B9E\u4F8B\u542F\u52A8\u6765\u6E90\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u62D2\u7EDD\u8986\u76D6\u3002");
22391
+ if (snapshot.runtime) await saveJson(runtimeFile(location), snapshot.runtime);
22392
+ else await (0, import_promises8.rm)(runtimeFile(location), { force: true });
22393
+ }
22394
+
22395
+ // src/cli/background.ts
22396
+ var exec3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
22271
22397
  async function lifecycle(location, action) {
22272
- await (0, import_promises8.mkdir)(location.state, { recursive: true, mode: 448 });
22398
+ await (0, import_promises9.mkdir)(location.state, { recursive: true, mode: 448 });
22273
22399
  const release = await import_proper_lockfile6.default.lock(location.state, {
22274
- lockfilePath: (0, import_node_path8.join)(location.state, "lifecycle.lock"),
22400
+ lockfilePath: (0, import_node_path9.join)(location.state, "lifecycle.lock"),
22275
22401
  stale: 1e4,
22276
22402
  update: 2e3,
22277
22403
  retries: { retries: 280, minTimeout: 250, maxTimeout: 250 }
@@ -22282,34 +22408,35 @@ async function lifecycle(location, action) {
22282
22408
  await release();
22283
22409
  }
22284
22410
  }
22285
- async function start(location, entry) {
22411
+ async function start(location, entry, override) {
22286
22412
  try {
22287
22413
  return await control(location, "status");
22288
22414
  } catch (error62) {
22289
22415
  if (!isNotRunning(error62)) throw error62;
22290
22416
  }
22291
22417
  let child;
22418
+ const runtime = await launchRuntime(location, entry, override);
22292
22419
  const installed = await readJson(
22293
- (0, import_node_path8.join)(location.state, "service.json")
22420
+ (0, import_node_path9.join)(location.state, "service.json")
22294
22421
  );
22295
- if (process.platform === "darwin" && await startLaunchd(location, entry)) {
22422
+ if (process.platform === "darwin" && await startLaunchd(location, runtime.entry, runtime)) {
22296
22423
  } else if (installed?.platform === "linux") {
22297
- await exec2("systemctl", ["--user", "start", `${installed.label}.service`]);
22424
+ await exec3("systemctl", ["--user", "start", `${installed.label}.service`]);
22298
22425
  } else {
22299
22426
  if (process.platform === "darwin")
22300
22427
  console.warn(
22301
22428
  "\u5F53\u524D\u6CA1\u6709 macOS \u684C\u9762\u767B\u5F55\u4F1A\u8BDD\uFF0C\u4F7F\u7528 headless \u540E\u53F0\u542F\u52A8\uFF1B\u7CFB\u7EDF\u94A5\u5319\u4E32\u51ED\u8BC1\u53EF\u80FD\u4E0D\u53EF\u7528\u3002"
22302
22429
  );
22303
- const log = await (0, import_promises8.open)(location.log, "a", 384);
22430
+ const log = await (0, import_promises9.open)(location.log, "a", 384);
22304
22431
  try {
22305
- child = (0, import_node_child_process2.spawn)(process.execPath, [entry, "run", "--config", location.config], {
22432
+ child = (0, import_node_child_process3.spawn)(runtime.node, [runtime.entry, "run", "--config", location.config], {
22306
22433
  detached: true,
22307
22434
  stdio: ["ignore", log.fd, log.fd],
22308
22435
  windowsHide: true,
22309
- env: { ...process.env, COVRO_HOME: location.home }
22436
+ env: { ...process.env, PATH: runtime.path, COVRO_HOME: location.home }
22310
22437
  });
22311
- await new Promise((resolve3, reject) => {
22312
- child.once("spawn", resolve3);
22438
+ await new Promise((resolve4, reject) => {
22439
+ child.once("spawn", resolve4);
22313
22440
  child.once("error", reject);
22314
22441
  });
22315
22442
  child.unref();
@@ -22324,7 +22451,7 @@ async function start(location, entry) {
22324
22451
  if (!isNotRunning(error62)) throw error62;
22325
22452
  }
22326
22453
  if (child && child.exitCode !== null) throw new Error(`Covro \u542F\u52A8\u5931\u8D25\uFF0C\u8BF7\u67E5\u770B ${location.log}`);
22327
- await (0, import_promises9.setTimeout)(250);
22454
+ await (0, import_promises10.setTimeout)(250);
22328
22455
  }
22329
22456
  throw new Error(`Covro \u5C1A\u672A\u786E\u8BA4\u542F\u52A8\uFF0C\u8BF7\u8FD0\u884C covro status \u5E76\u67E5\u770B ${location.log}`);
22330
22457
  }
@@ -22333,19 +22460,19 @@ async function stop(location) {
22333
22460
  if (process.platform === "darwin") await unloadLaunchd(location);
22334
22461
  else {
22335
22462
  const installed = await readJson(
22336
- (0, import_node_path8.join)(location.state, "service.json")
22463
+ (0, import_node_path9.join)(location.state, "service.json")
22337
22464
  );
22338
22465
  if (installed?.platform === "linux")
22339
- await exec2("systemctl", ["--user", "stop", `${installed.label}.service`]);
22466
+ await exec3("systemctl", ["--user", "stop", `${installed.label}.service`]);
22340
22467
  }
22341
22468
  }
22342
- var startBackground = (location, entry) => lifecycle(location, () => start(location, entry));
22469
+ var startBackground = (location, entry, runtime) => lifecycle(location, () => start(location, entry, runtime));
22343
22470
  var stopBackground = (location) => lifecycle(location, () => stop(location));
22344
22471
 
22345
22472
  // src/updates/transaction.ts
22346
- var import_promises10 = require("node:fs/promises");
22347
- var import_node_path9 = require("node:path");
22348
- async function activateUpdate(paths, effects) {
22473
+ var import_promises11 = require("node:fs/promises");
22474
+ var import_node_path10 = require("node:path");
22475
+ async function activateUpdate(paths, effects, reuseTarget = false) {
22349
22476
  let stopped = false;
22350
22477
  let moved = false;
22351
22478
  let backedUp = false;
@@ -22358,9 +22485,12 @@ async function activateUpdate(paths, effects) {
22358
22485
  await effects.stop();
22359
22486
  await effects.backup();
22360
22487
  backedUp = true;
22361
- await (0, import_promises10.rename)(paths.root, paths.previous);
22362
- moved = true;
22363
- await (0, import_promises10.rename)(paths.candidate, paths.root);
22488
+ if (!reuseTarget) {
22489
+ await (0, import_promises11.rename)(paths.root, paths.previous);
22490
+ moved = true;
22491
+ await (0, import_promises11.rename)(paths.candidate, paths.root);
22492
+ }
22493
+ await effects.switchLaunch?.();
22364
22494
  await effects.phase("verifying", "\u6B63\u5728\u542F\u52A8\u65B0\u7248\u3001\u8FC1\u79FB\u6570\u636E\u5E93\u5E76\u9A8C\u8BC1\uFF1B\u4E1A\u52A1\u5199\u5165\u4FDD\u6301\u6682\u505C");
22365
22495
  await effects.start(true);
22366
22496
  await effects.verify();
@@ -22377,10 +22507,11 @@ async function activateUpdate(paths, effects) {
22377
22507
  try {
22378
22508
  await effects.stop();
22379
22509
  if (moved) {
22380
- await (0, import_promises10.rm)(paths.root, { recursive: true, force: true });
22381
- await (0, import_promises10.rename)(paths.previous, paths.root);
22510
+ await (0, import_promises11.rm)(paths.root, { recursive: true, force: true });
22511
+ await (0, import_promises11.rename)(paths.previous, paths.root);
22382
22512
  }
22383
22513
  if (backedUp) await effects.restore();
22514
+ await effects.restoreLaunch?.();
22384
22515
  await effects.phase(
22385
22516
  "rolledBack",
22386
22517
  `\u65B0\u7248\u542F\u52A8\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u65E7\u7248\uFF1A${error62 instanceof Error ? error62.message : String(error62)}`
@@ -22397,16 +22528,16 @@ async function activateUpdate(paths, effects) {
22397
22528
  }
22398
22529
  }
22399
22530
  function transactionPaths(root, id, dataDir, config2, backup) {
22400
- const prefix = (0, import_node_path9.join)((0, import_node_path9.dirname)(root), `.covro-stage-${id}`);
22531
+ const prefix = (0, import_node_path10.join)((0, import_node_path10.dirname)(root), `.covro-stage-${id}`);
22401
22532
  return {
22402
22533
  root,
22403
22534
  prefix,
22404
- candidate: (0, import_node_path9.join)(
22535
+ candidate: (0, import_node_path10.join)(
22405
22536
  prefix,
22406
22537
  process.platform === "win32" ? "node_modules" : "lib/node_modules",
22407
22538
  npmPackageName
22408
22539
  ),
22409
- previous: (0, import_node_path9.join)((0, import_node_path9.dirname)(root), `.covro-previous-${id}`),
22540
+ previous: (0, import_node_path10.join)((0, import_node_path10.dirname)(root), `.covro-previous-${id}`),
22410
22541
  backup,
22411
22542
  dataDir,
22412
22543
  config: config2
@@ -22414,12 +22545,9 @@ function transactionPaths(root, id, dataDir, config2, backup) {
22414
22545
  }
22415
22546
 
22416
22547
  // src/updates/registry.ts
22417
- var import_node_child_process3 = require("node:child_process");
22418
- var import_node_util3 = require("node:util");
22419
- var import_promises11 = require("node:fs/promises");
22548
+ var import_promises12 = require("node:fs/promises");
22420
22549
  var import_node_fs3 = require("node:fs");
22421
- var import_node_path10 = require("node:path");
22422
- var run = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
22550
+ var import_node_path11 = require("node:path");
22423
22551
  var registry2 = "https://registry.npmjs.org";
22424
22552
  var releaseSchema = external_exports.object({
22425
22553
  name: external_exports.literal(npmPackageName),
@@ -22430,31 +22558,211 @@ var releaseSchema = external_exports.object({
22430
22558
  });
22431
22559
  async function inspectInstallation(root) {
22432
22560
  try {
22433
- const { stdout } = await run("npm", ["root", "--global"], { timeout: 15e3 });
22434
- return await inspectPackageDirectory(root, stdout.trim());
22561
+ const globalRoot = (0, import_node_path11.dirname)((0, import_node_path11.dirname)((0, import_node_path11.resolve)(root)));
22562
+ if (!globalRoot.endsWith("/lib/node_modules"))
22563
+ return "\u5F53\u524D\u4E3A\u975E npm \u5168\u5C40\u5B89\u88C5\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002";
22564
+ if (await (0, import_promises12.realpath)((0, import_node_path11.join)((0, import_node_path11.dirname)((0, import_node_path11.dirname)(globalRoot)), "bin/covro")) !== (0, import_node_path11.join)((0, import_node_path11.resolve)(root), "bin/covro.mjs"))
22565
+ return "\u5F53\u524D Covro \u5165\u53E3\u4E0E npm \u5168\u5C40\u5B89\u88C5\u6765\u6E90\u4E0D\u5339\u914D\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002";
22566
+ return await inspectPackageDirectory(root, globalRoot);
22435
22567
  } catch {
22436
22568
  return "\u65E0\u6CD5\u786E\u8BA4\u53EF\u5199\u7684 npm \u5168\u5C40\u5B89\u88C5\uFF1B\u8BF7\u68C0\u67E5 npm\u3001\u5B89\u88C5\u76EE\u5F55\u6743\u9650\u53CA\u540E\u53F0 PATH\u3002";
22437
22569
  }
22438
22570
  }
22439
22571
  async function inspectPackageDirectory(root, globalRoot) {
22440
- const expected = (0, import_node_path10.join)(await (0, import_promises11.realpath)(globalRoot), npmPackageName);
22441
- if ((await (0, import_promises11.lstat)(expected)).isSymbolicLink() || await (0, import_promises11.realpath)(root) !== expected)
22572
+ const expected = (0, import_node_path11.join)(await (0, import_promises12.realpath)(globalRoot), npmPackageName);
22573
+ if ((await (0, import_promises12.lstat)(expected)).isSymbolicLink() || await (0, import_promises12.realpath)(root) !== expected)
22442
22574
  return "\u5F53\u524D\u4E3A\u6E90\u7801\u3001\u94FE\u63A5\u6216\u975E npm \u5168\u5C40\u5B89\u88C5\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002";
22443
22575
  try {
22444
- await (0, import_promises11.lstat)((0, import_node_path10.join)(expected, ".git"));
22576
+ await (0, import_promises12.lstat)((0, import_node_path11.join)(expected, ".git"));
22445
22577
  return "\u5F53\u524D\u5B89\u88C5\u5305\u542B Git \u5DE5\u4F5C\u533A\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002";
22446
22578
  } catch (error62) {
22447
22579
  if (error62.code !== "ENOENT") throw error62;
22448
22580
  }
22449
- await (0, import_promises11.access)(root, import_node_fs3.constants.W_OK);
22581
+ await (0, import_promises12.access)(root, import_node_fs3.constants.W_OK);
22450
22582
  return void 0;
22451
22583
  }
22452
22584
 
22585
+ // src/updates/runtime.ts
22586
+ var import_node_child_process4 = require("node:child_process");
22587
+ var import_node_util4 = require("node:util");
22588
+ var import_node_os3 = require("node:os");
22589
+ var import_promises13 = require("node:fs/promises");
22590
+ var import_node_fs4 = require("node:fs");
22591
+ var import_node_path12 = require("node:path");
22592
+ var exec4 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
22593
+ function assertRuntime(actual, expected) {
22594
+ if (!actual || actual.node !== expected.node || actual.nodeVersion !== expected.nodeVersion || actual.root !== expected.root || actual.entry !== expected.entry)
22595
+ throw new Error(
22596
+ "\u5B9E\u9645 Node \u6216 Covro \u5B89\u88C5\u6765\u6E90\u4E0E\u76EE\u6807\u4E0D\u5339\u914D\uFF1B\u62D2\u7EDD\u6FC0\u6D3B\uFF0C\u8BF7\u67E5\u770B\u5347\u7EA7\u65E5\u5FD7\u5E76\u8FD0\u884C covro update repair\u3002"
22597
+ );
22598
+ }
22599
+ async function verifyRuntimeExecutable(runtime) {
22600
+ const { stdout } = await exec4(
22601
+ runtime.node,
22602
+ ["-p", "JSON.stringify({node:process.execPath,nodeVersion:process.versions.node})"],
22603
+ { env: targetNpmEnvironment(process.env.PATH ?? "/usr/bin:/bin"), timeout: 15e3 }
22604
+ );
22605
+ const actual = JSON.parse(stdout);
22606
+ if (actual.node !== runtime.node || actual.nodeVersion !== runtime.nodeVersion)
22607
+ throw new Error(
22608
+ "\u65E7 Node \u7684\u78C1\u76D8\u8DEF\u5F84\u5DF2\u88AB\u66FF\u6362\uFF0C\u65E0\u6CD5\u4FDD\u8BC1\u56DE\u6EDA\uFF1B\u8BF7\u4FDD\u7559\u65E7 Node \u5B89\u88C5\u5E76\u6838\u5BF9\u542F\u52A8\u6765\u6E90\u540E\u91CD\u8BD5\u3002"
22609
+ );
22610
+ }
22611
+ var probeSchema = external_exports.object({
22612
+ node: external_exports.string(),
22613
+ nodeVersion: external_exports.string(),
22614
+ path: external_exports.string(),
22615
+ npmConfig: external_exports.record(external_exports.string(), external_exports.string()).optional()
22616
+ });
22617
+ var marker = "COVRO_RUNTIME_281=";
22618
+ var npmConfigKeys = ["prefix", "userconfig", "globalconfig"];
22619
+ var probe = `process.stdout.write('${marker}'+JSON.stringify({node:process.execPath,nodeVersion:process.versions.node,path:process.env.PATH,npmConfig:Object.fromEntries(${JSON.stringify(npmConfigKeys)}.flatMap(k=>{const v=process.env['npm_config_'+k]??process.env['NPM_CONFIG_'+k.toUpperCase()];return v===undefined?[]:[[k,v]]}))})+'\\n')`;
22620
+ function targetNpmEnvironment(path, config2 = {}) {
22621
+ const env = { ...process.env, PATH: path, NODE_OPTIONS: "", NODE_PATH: "" };
22622
+ for (const key of npmConfigKeys) {
22623
+ delete env[`NPM_CONFIG_${key.toUpperCase()}`];
22624
+ delete env[`npm_config_${key}`];
22625
+ if (config2[key]) env[`npm_config_${key}`] = config2[key];
22626
+ }
22627
+ return env;
22628
+ }
22629
+ var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
22630
+ async function defaultNodeEnvironment() {
22631
+ const shell = (0, import_node_os3.userInfo)().shell;
22632
+ if (!shell || !["bash", "zsh", "sh", "dash", "fish"].includes((0, import_node_path12.basename)(shell)))
22633
+ throw new Error(
22634
+ "\u65E0\u6CD5\u8BC6\u522B\u9ED8\u8BA4\u767B\u5F55 shell\uFF1B\u8BF7\u5728\u76EE\u6807 Node \u7684\u7EC8\u7AEF\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u5E76\u91CD\u65B0\u5B89\u88C5\u767B\u5F55\u670D\u52A1\u3002"
22635
+ );
22636
+ const oldBin = (0, import_node_path12.dirname)(process.execPath);
22637
+ const path = (process.env.PATH ?? "").split(import_node_path12.delimiter).filter(
22638
+ (part) => part && part !== oldBin && !/fnm_multishells|\/node-versions\/|\/\.nvm\/versions\/node\//.test(part)
22639
+ );
22640
+ const env = {
22641
+ ...process.env,
22642
+ PATH: [.../* @__PURE__ */ new Set([...path, "/usr/local/bin", "/opt/homebrew/bin", "/usr/bin", "/bin"])].join(
22643
+ import_node_path12.delimiter
22644
+ )
22645
+ };
22646
+ for (const key of ["FNM_MULTISHELL_PATH", "NVM_BIN", "NVM_INC", "NODE_OPTIONS", "NODE_PATH"])
22647
+ delete env[key];
22648
+ for (const key of npmConfigKeys) {
22649
+ delete env[`npm_config_${key}`];
22650
+ delete env[`NPM_CONFIG_${key.toUpperCase()}`];
22651
+ }
22652
+ const { stdout } = await exec4(shell, ["-ilc", `node -e ${quote(probe)}`], {
22653
+ cwd: (0, import_node_os3.homedir)(),
22654
+ env,
22655
+ timeout: 15e3,
22656
+ maxBuffer: 256 * 1024
22657
+ });
22658
+ const lines = stdout.split(/\r?\n/).filter((line) => line.startsWith(marker));
22659
+ if (lines.length !== 1)
22660
+ throw new Error("\u767B\u5F55 shell \u672A\u8FD4\u56DE\u552F\u4E00\u7684\u9ED8\u8BA4 Node\uFF1B\u8BF7\u68C0\u67E5 shell \u542F\u52A8\u914D\u7F6E\u540E\u91CD\u8BD5\u3002");
22661
+ return probeSchema.parse(JSON.parse(lines[0].slice(marker.length)));
22662
+ }
22663
+ async function executable(name, path) {
22664
+ for (const directory of path.split(import_node_path12.delimiter)) {
22665
+ if (!(0, import_node_path12.isAbsolute)(directory)) continue;
22666
+ const filename = (0, import_node_path12.join)(directory, name);
22667
+ try {
22668
+ await (0, import_promises13.access)(filename, import_node_fs4.constants.X_OK);
22669
+ return await (0, import_promises13.realpath)(filename);
22670
+ } catch (error62) {
22671
+ if (!["ENOENT", "EACCES", "ENOTDIR"].includes(error62.code ?? ""))
22672
+ throw error62;
22673
+ }
22674
+ }
22675
+ throw new Error(
22676
+ `\u76EE\u6807 Node \u73AF\u5883\u4E2D\u627E\u4E0D\u5230 ${name}\uFF1B\u8BF7\u5728\u65B0\u7EC8\u7AEF\u68C0\u67E5 node\u3001npm \u548C npm install -g ${npmPackageName}\u3002`
22677
+ );
22678
+ }
22679
+ async function resolveRuntimeTarget(environment = defaultNodeEnvironment) {
22680
+ const found = await environment();
22681
+ const node2 = await (0, import_promises13.realpath)(found.node);
22682
+ await (0, import_promises13.access)(node2, import_node_fs4.constants.X_OK);
22683
+ const { stdout } = await exec4(node2, ["-p", "process.versions.node"], {
22684
+ env: targetNpmEnvironment(found.path, found.npmConfig),
22685
+ timeout: 15e3
22686
+ });
22687
+ const nodeVersion = stdout.trim();
22688
+ if (nodeVersion !== found.nodeVersion || !validVersion(nodeVersion) || compareVersions(nodeVersion, "24.19.0") < 0 || compareVersions(nodeVersion, "25.0.0") >= 0)
22689
+ throw new Error(
22690
+ `\u76EE\u6807 Node ${nodeVersion} \u4E0D\u53D7\u652F\u6301\uFF1B\u9700\u8981 >=24.19.0 <25\uFF0C\u8BF7\u8C03\u6574\u9ED8\u8BA4 Node \u540E\u91CD\u8BD5\u3002`
22691
+ );
22692
+ const npm = await executable("npm", found.path);
22693
+ if (await (0, import_promises13.realpath)((0, import_node_path12.join)((0, import_node_path12.dirname)(node2), "npm")).catch(() => void 0) !== npm)
22694
+ throw new Error("\u9ED8\u8BA4 Node \u548C npm \u6765\u81EA\u4E0D\u540C\u5B89\u88C5\uFF1B\u8BF7\u4FEE\u590D\u767B\u5F55 shell \u7684 PATH \u540E\u91CD\u65B0\u68C0\u67E5\u3002");
22695
+ const npmInfo = JSON.parse(await (0, import_promises13.readFile)((0, import_node_path12.join)((0, import_node_path12.dirname)(npm), "../package.json"), "utf8"));
22696
+ if ((0, import_node_path12.basename)(npm) !== "npm-cli.js" || npmInfo.name !== "npm")
22697
+ throw new Error(
22698
+ "\u76EE\u6807 npm \u662F\u65E0\u6CD5\u786E\u8BA4\u7684 shim\uFF1B\u8BF7\u8BA9\u767B\u5F55 shell \u7684 PATH \u6307\u5411\u76EE\u6807 Node \u81EA\u5E26\u7684 npm \u540E\u91CD\u8BD5\u3002"
22699
+ );
22700
+ const directories = await Promise.all(
22701
+ found.path.split(import_node_path12.delimiter).filter(import_node_path12.isAbsolute).map((part) => (0, import_promises13.realpath)(part).catch(() => void 0))
22702
+ );
22703
+ const path = [
22704
+ .../* @__PURE__ */ new Set([(0, import_node_path12.dirname)(node2), ...directories.filter((part) => Boolean(part))])
22705
+ ].join(import_node_path12.delimiter);
22706
+ const options = {
22707
+ env: targetNpmEnvironment(path, found.npmConfig),
22708
+ cwd: (0, import_node_os3.homedir)(),
22709
+ timeout: 15e3
22710
+ };
22711
+ const [prefixResult, rootResult, npmVersionResult] = await Promise.all([
22712
+ exec4(node2, [npm, "prefix", "--global"], options),
22713
+ exec4(node2, [npm, "root", "--global"], options),
22714
+ exec4(node2, [npm, "--version"], options)
22715
+ ]);
22716
+ const prefix = await (0, import_promises13.realpath)(prefixResult.stdout.trim());
22717
+ const globalRoot = await (0, import_promises13.realpath)(rootResult.stdout.trim());
22718
+ if (globalRoot !== (0, import_node_path12.join)(prefix, "lib/node_modules"))
22719
+ throw new Error("\u76EE\u6807 npm \u5168\u5C40\u76EE\u5F55\u5E03\u5C40\u4E0D\u53D7\u652F\u6301\u3002");
22720
+ const root = (0, import_node_path12.join)(globalRoot, npmPackageName);
22721
+ const npmVersion = npmVersionResult.stdout.trim();
22722
+ if (!validVersion(npmVersion))
22723
+ throw new Error("\u76EE\u6807 npm \u672A\u8FD4\u56DE\u6709\u6548\u7248\u672C\uFF0C\u8BF7\u68C0\u67E5 npm \u5B89\u88C5\u540E\u91CD\u8BD5\u3002");
22724
+ try {
22725
+ const reason = await inspectPackageDirectory(root, globalRoot);
22726
+ if (reason) throw new Error(reason);
22727
+ const entry = (0, import_node_path12.join)(root, "bin/covro.mjs");
22728
+ if ((await (0, import_promises13.lstat)(entry)).isSymbolicLink() || await (0, import_promises13.realpath)((0, import_node_path12.join)(prefix, "bin/covro")) !== entry)
22729
+ throw new Error("\u5168\u5C40 covro \u5165\u53E3\u4E0E npm \u5B89\u88C5\u76EE\u5F55\u4E0D\u5339\u914D");
22730
+ const metadata = JSON.parse(await (0, import_promises13.readFile)((0, import_node_path12.join)(root, "package.json"), "utf8"));
22731
+ if (metadata.name !== npmPackageName || !validVersion(metadata.version))
22732
+ throw new Error("Covro \u5305\u8EAB\u4EFD\u65E0\u6548");
22733
+ return {
22734
+ node: node2,
22735
+ nodeVersion,
22736
+ npm,
22737
+ npmVersion,
22738
+ prefix,
22739
+ globalRoot,
22740
+ root,
22741
+ entry,
22742
+ path,
22743
+ version: metadata.version,
22744
+ covroCodex: metadata.covroCodex,
22745
+ covroCommit: metadata.covroCommit ?? metadata.gitHead,
22746
+ npmConfig: found.npmConfig
22747
+ };
22748
+ } catch (error62) {
22749
+ throw new Error(
22750
+ `\u76EE\u6807 Node ${nodeVersion} \u7684\u5168\u5C40 Covro \u4E0D\u53EF\u7528\uFF1A${error62.message}\u3002\u8BF7\u5728\u65B0\u7EC8\u7AEF\u6267\u884C npm install -g ${npmPackageName} \u540E\u91CD\u8BD5\uFF1B\u5F53\u524D\u670D\u52A1\u4FDD\u6301\u8FD0\u884C\u3002`,
22751
+ { cause: error62 }
22752
+ );
22753
+ }
22754
+ }
22755
+
22453
22756
  // src/updates/worker.ts
22454
- var exec3 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
22757
+ var exec5 = (0, import_node_util5.promisify)(import_node_child_process5.execFile);
22455
22758
  var message = (error62) => error62 instanceof Error ? error62.message : String(error62);
22456
- async function startService(context) {
22457
- await startBackground(context.location, (0, import_node_path11.join)(context.root, "bin/covro.mjs"));
22759
+ async function startService(context, candidate = false) {
22760
+ const target = candidate ? context.target : void 0;
22761
+ await startBackground(
22762
+ context.location,
22763
+ (0, import_node_path13.join)(context.root, "bin/covro.mjs"),
22764
+ target ? { node: target.node, entry: target.entry, path: target.path } : context.source
22765
+ );
22458
22766
  }
22459
22767
  async function stopService(context) {
22460
22768
  await stopBackground(context.location);
@@ -22465,27 +22773,29 @@ async function verifyRestoredService(context, version3) {
22465
22773
  const restored = await control(context.location, "status");
22466
22774
  if (restored.version !== version3 || restored.maintenance)
22467
22775
  throw new Error("\u65E7\u7248\u6062\u590D\u8EAB\u4EFD\u4E0D\u5339\u914D");
22776
+ const record2 = await readJson((0, import_node_path13.join)(context.directory, "run.json"));
22777
+ if (record2?.runtime) assertRuntime(restored.runtime, record2.runtime.from);
22468
22778
  return;
22469
22779
  } catch (error62) {
22470
22780
  if (attempt === 239) throw error62;
22471
22781
  }
22472
- await (0, import_promises13.setTimeout)(250);
22782
+ await (0, import_promises15.setTimeout)(250);
22473
22783
  }
22474
22784
  }
22475
22785
  async function verifyMigrations(context, candidate) {
22476
- const require2 = (0, import_node_module.createRequire)((0, import_node_path11.join)(context.root, "package.json"));
22786
+ const require2 = (0, import_node_module.createRequire)((0, import_node_path13.join)(context.root, "package.json"));
22477
22787
  const Sqlite = require2("better-sqlite3");
22478
- const filename = (0, import_node_path11.join)(context.dataDir, "app.sqlite");
22788
+ const filename = (0, import_node_path13.join)(context.dataDir, "app.sqlite");
22479
22789
  try {
22480
- await (0, import_promises12.access)(filename);
22790
+ await (0, import_promises14.access)(filename);
22481
22791
  } catch (error62) {
22482
22792
  if (error62.code === "ENOENT") return;
22483
22793
  throw error62;
22484
22794
  }
22485
22795
  const db = new Sqlite(filename, { readonly: true, fileMustExist: true });
22486
22796
  try {
22487
- const migrations = readMigrations((0, import_node_path11.join)(candidate, "dist/drizzle"));
22488
- const metadata = await readJson((0, import_node_path11.join)(candidate, "package.json"));
22797
+ const migrations = readMigrations((0, import_node_path13.join)(candidate, "dist/drizzle"));
22798
+ const metadata = await readJson((0, import_node_path13.join)(candidate, "package.json"));
22489
22799
  if (metadata?.covroDatabase) {
22490
22800
  const contract = databaseCompatibilitySchema.parse(metadata.covroDatabase);
22491
22801
  if (contract.schemaVersion !== migrations.length)
@@ -22497,61 +22807,63 @@ async function verifyMigrations(context, candidate) {
22497
22807
  }
22498
22808
  }
22499
22809
  async function worker(directory) {
22500
- await (0, import_promises12.mkdir)(directory, { recursive: true, mode: 448 });
22810
+ await (0, import_promises14.mkdir)(directory, { recursive: true, mode: 448 });
22501
22811
  const release = await import_proper_lockfile7.default.lock(directory, {
22502
22812
  stale: 1e4,
22503
22813
  update: 2e3,
22504
22814
  retries: { retries: 30, minTimeout: 100, maxTimeout: 500 }
22505
22815
  });
22506
- let record2 = await readJson((0, import_node_path11.join)(directory, "run.json"));
22507
- const context = await readJson((0, import_node_path11.join)(directory, "context.json"));
22816
+ let record2 = await readJson((0, import_node_path13.join)(directory, "run.json"));
22817
+ const context = await readJson((0, import_node_path13.join)(directory, "context.json"));
22508
22818
  if (!record2 || !context) {
22509
22819
  await release();
22510
22820
  throw new Error("\u7F3A\u5C11\u5347\u7EA7\u8BB0\u5F55");
22511
22821
  }
22512
22822
  const update = async (phase, detail) => {
22513
22823
  record2 = { ...record2, phase, message: detail, updatedAt: Date.now() };
22514
- await saveJson((0, import_node_path11.join)(directory, "run.json"), record2);
22824
+ await saveJson((0, import_node_path13.join)(directory, "run.json"), record2);
22515
22825
  };
22516
22826
  const paths = transactionPaths(
22517
- context.root,
22827
+ context.target?.root ?? context.root,
22518
22828
  record2.id,
22519
22829
  context.dataDir,
22520
22830
  context.location.config,
22521
- (0, import_node_path11.join)(backupDirectory(context.location.home, context.dataDir), record2.id)
22831
+ (0, import_node_path13.join)(backupDirectory(context.location.home, context.dataDir), record2.id)
22522
22832
  );
22523
22833
  let releaseMaintenance;
22524
22834
  let releaseData;
22525
- const previousMetadata = await readJson(
22526
- (0, import_node_path11.join)(paths.previous, "package.json")
22527
- );
22528
- const originalRoot = previousMetadata?.version === record2.from ? paths.previous : context.root;
22529
- const originalMetadata = await readJson((0, import_node_path11.join)(originalRoot, "package.json"));
22530
- const Sqlite = (0, import_node_module.createRequire)((0, import_node_path11.join)(originalRoot, "package.json"))(
22531
- "better-sqlite3"
22532
- );
22533
- const migrations = readMigrations((0, import_node_path11.join)(originalRoot, "dist/drizzle"));
22534
- const backups = new BackupStore({
22535
- directory: backupDirectory(context.location.home, context.dataDir),
22536
- config: paths.config,
22537
- dataDir: paths.dataDir,
22538
- appVersion: record2.from,
22539
- commit: originalMetadata?.covroCommit,
22540
- contract: databaseCompatibilitySchema.parse(
22541
- originalMetadata?.covroDatabase ?? {
22542
- schemaVersion: migrations.length,
22543
- minRestorableSchemaVersion: 1,
22544
- backupFormatVersion: 1
22545
- }
22546
- ),
22547
- Sqlite,
22548
- migrations
22549
- });
22550
22835
  try {
22836
+ if (record2.runtime) await verifyRuntimeExecutable(record2.runtime.from);
22837
+ const previousMetadata = await readJson(
22838
+ (0, import_node_path13.join)(paths.previous, "package.json")
22839
+ );
22840
+ const sameRoot = paths.root.replace(/\/$/, "") === context.root.replace(/\/$/, "");
22841
+ const originalRoot = sameRoot && previousMetadata?.version === record2.from ? paths.previous : context.root;
22842
+ const originalMetadata = await readJson((0, import_node_path13.join)(originalRoot, "package.json"));
22843
+ const Sqlite = (0, import_node_module.createRequire)((0, import_node_path13.join)(originalRoot, "package.json"))(
22844
+ "better-sqlite3"
22845
+ );
22846
+ const migrations = readMigrations((0, import_node_path13.join)(originalRoot, "dist/drizzle"));
22847
+ const backups = new BackupStore({
22848
+ directory: backupDirectory(context.location.home, context.dataDir),
22849
+ config: paths.config,
22850
+ dataDir: paths.dataDir,
22851
+ appVersion: record2.from,
22852
+ commit: originalMetadata?.covroCommit,
22853
+ contract: databaseCompatibilitySchema.parse(
22854
+ originalMetadata?.covroDatabase ?? {
22855
+ schemaVersion: migrations.length,
22856
+ minRestorableSchemaVersion: 1,
22857
+ backupFormatVersion: 1
22858
+ }
22859
+ ),
22860
+ Sqlite,
22861
+ migrations
22862
+ });
22551
22863
  if (process.argv[3] === "--repair") {
22552
22864
  releaseMaintenance = await acquireMaintenanceLock(context.dataDir);
22553
- if (!await readJson((0, import_node_path11.join)(paths.backup, "snapshot.json")))
22554
- paths.backup = (0, import_node_path11.join)(directory, `backup-${record2.id}`);
22865
+ if (!await readJson((0, import_node_path13.join)(paths.backup, "snapshot.json")))
22866
+ paths.backup = (0, import_node_path13.join)(directory, `backup-${record2.id}`);
22555
22867
  const active = await control(context.location, "status").catch(
22556
22868
  (error62) => {
22557
22869
  if (isNotRunning(error62)) return void 0;
@@ -22562,24 +22874,24 @@ async function worker(directory) {
22562
22874
  if (active && !active.maintenance && active.version !== record2.from)
22563
22875
  throw new Error("\u5F53\u524D\u670D\u52A1\u53EF\u80FD\u5DF2\u63A5\u53D7\u65B0\u7248\u4E1A\u52A1\u6570\u636E\uFF1B\u62D2\u7EDD\u6062\u590D\u65E7\u5FEB\u7167\uFF0C\u8BF7\u4F7F\u7528\u517C\u5BB9\u7248\u672C\u68C0\u67E5\u3002");
22564
22876
  const previous = await readJson(
22565
- (0, import_node_path11.join)(paths.previous, "package.json")
22877
+ (0, import_node_path13.join)(paths.previous, "package.json")
22566
22878
  );
22567
- if (previous) {
22879
+ if (previous || context.reuseTarget) {
22568
22880
  if (active && !active.maintenance)
22569
22881
  throw new Error("\u65E7\u670D\u52A1\u5DF2\u6062\u590D\u4E1A\u52A1\u5199\u5165\uFF1B\u62D2\u7EDD\u7528\u5347\u7EA7\u524D\u5FEB\u7167\u8986\u76D6\u73B0\u6709\u6570\u636E\uFF0C\u8BF7\u4FDD\u7559\u73B0\u573A\u68C0\u67E5\u3002");
22570
- if (previous.name !== npmPackageName || previous.version !== record2.from)
22882
+ if (previous && (previous.name !== npmPackageName || previous.version !== (context.target?.version ?? record2.from)))
22571
22883
  throw new Error("\u65E7\u7248\u5907\u4EFD\u8EAB\u4EFD\u4E0D\u5339\u914D");
22572
22884
  const snapshot = await readJson(
22573
- (0, import_node_path11.join)(paths.backup, "snapshot.json")
22885
+ (0, import_node_path13.join)(paths.backup, "snapshot.json")
22574
22886
  );
22575
22887
  if (snapshot?.formatVersion === 1) {
22576
22888
  const verified = await backups.verify(record2.id);
22577
22889
  if (verified.appVersion !== record2.from || verified.protectedBy !== record2.id || verified.configPath !== paths.config || verified.dataDir !== paths.dataDir)
22578
22890
  throw new Error("\u5907\u4EFD\u8EAB\u4EFD\u4E0D\u5339\u914D");
22579
- } else await verifyLegacySnapshot(paths.backup, Sqlite, (0, import_node_path11.join)(originalRoot, "dist/drizzle"));
22580
- } else {
22891
+ } else await verifyLegacySnapshot(paths.backup, Sqlite, (0, import_node_path13.join)(originalRoot, "dist/drizzle"));
22892
+ } else if (sameRoot) {
22581
22893
  const original = await readJson(
22582
- (0, import_node_path11.join)(paths.root, "package.json")
22894
+ (0, import_node_path13.join)(paths.root, "package.json")
22583
22895
  );
22584
22896
  if (original?.name !== npmPackageName || original.version !== record2.from)
22585
22897
  throw new Error("\u672A\u627E\u5230\u5B8C\u6574\u7684\u4E0A\u4E00\u7248\u672C\u5B89\u88C5");
@@ -22591,20 +22903,24 @@ async function worker(directory) {
22591
22903
  await stopService(context);
22592
22904
  releaseData = await acquireInstanceLock(context.dataDir);
22593
22905
  if (previous) {
22594
- await (0, import_promises12.rm)(paths.root, { recursive: true, force: true });
22595
- await (0, import_promises12.rename)(paths.previous, paths.root);
22906
+ await (0, import_promises14.rm)(paths.root, { recursive: true, force: true });
22907
+ await (0, import_promises14.rename)(paths.previous, paths.root);
22908
+ }
22909
+ if (previous || context.reuseTarget) {
22596
22910
  for (const name of ["app.sqlite", "app.sqlite-wal", "app.sqlite-shm"]) {
22597
- await (0, import_promises12.rm)((0, import_node_path11.join)(paths.dataDir, name), { force: true });
22911
+ await (0, import_promises14.rm)((0, import_node_path13.join)(paths.dataDir, name), { force: true });
22598
22912
  try {
22599
- await copyDurable((0, import_node_path11.join)(paths.backup, name), (0, import_node_path11.join)(paths.dataDir, name));
22913
+ await copyDurable((0, import_node_path13.join)(paths.backup, name), (0, import_node_path13.join)(paths.dataDir, name));
22600
22914
  } catch (error62) {
22601
22915
  if (error62.code !== "ENOENT") throw error62;
22602
22916
  }
22603
22917
  }
22604
- await copyDurable((0, import_node_path11.join)(paths.backup, "config.json"), paths.config);
22918
+ await copyDurable((0, import_node_path13.join)(paths.backup, "config.json"), paths.config);
22605
22919
  }
22920
+ const launch2 = await readJson((0, import_node_path13.join)(directory, `launch-${record2.id}.json`));
22921
+ if (launch2) await restoreLaunch(context.location, launch2);
22606
22922
  const restored = await readJson(
22607
- (0, import_node_path11.join)(paths.root, "package.json")
22923
+ (0, import_node_path13.join)(context.root, "package.json")
22608
22924
  );
22609
22925
  if (restored?.name !== npmPackageName || restored.version !== record2.from)
22610
22926
  throw new Error("\u672A\u627E\u5230\u5B8C\u6574\u7684\u4E0A\u4E00\u7248\u672C\u5B89\u88C5");
@@ -22623,12 +22939,13 @@ async function worker(directory) {
22623
22939
  }
22624
22940
  const reason = await inspectInstallation(context.root);
22625
22941
  if (reason) throw new Error(reason);
22626
- for (const key of await (0, import_promises12.readdir)((0, import_node_path11.join)(context.location.home, "instances"))) {
22942
+ for (const key of await (0, import_promises14.readdir)((0, import_node_path13.join)(context.location.home, "instances"))) {
22627
22943
  if (key === context.location.key) continue;
22628
22944
  const instance = await readJson(
22629
- (0, import_node_path11.join)(context.location.home, "instances", key, "instance.json")
22945
+ (0, import_node_path13.join)(context.location.home, "instances", key, "instance.json")
22630
22946
  );
22631
- if (instance?.root !== context.root) continue;
22947
+ if (!instance || ![context.root.replace(/\/$/, ""), paths.root].includes(instance.root.replace(/\/$/, "")))
22948
+ continue;
22632
22949
  try {
22633
22950
  await control({ ...context.location, socket: instance.socket }, "status");
22634
22951
  throw new Error("\u540C\u4E00 npm \u5B89\u88C5\u8FD8\u6709\u5176\u4ED6 Covro \u5B9E\u4F8B\uFF0C\u8BF7\u5148\u505C\u6B62\u5176\u4ED6\u5B9E\u4F8B\u518D\u5347\u7EA7\u3002");
@@ -22636,24 +22953,39 @@ async function worker(directory) {
22636
22953
  if (!isNotRunning(error62)) throw error62;
22637
22954
  }
22638
22955
  }
22639
- await (0, import_promises12.access)((0, import_node_path11.dirname)(context.root), import_node_fs4.constants.W_OK);
22640
- await exec3(
22641
- "npm",
22642
- [
22643
- "install",
22644
- "--global",
22645
- "--prefix",
22646
- paths.prefix,
22647
- "--omit=dev",
22648
- "--no-audit",
22649
- "--no-fund",
22650
- `--registry=${registry2}`,
22651
- "--allow-scripts=better-sqlite3",
22652
- `${npmPackageName}@${record2.target}`
22653
- ],
22654
- { timeout: 10 * 6e4, maxBuffer: 2 * 1024 * 1024 }
22956
+ await (0, import_promises14.access)((0, import_node_path13.dirname)(context.root), import_node_fs5.constants.W_OK);
22957
+ await (0, import_promises14.access)((0, import_node_path13.dirname)(paths.root), import_node_fs5.constants.W_OK);
22958
+ if (context.target) {
22959
+ const target = await resolveRuntimeTarget();
22960
+ assertRuntime(target, context.target);
22961
+ if (target.npm !== context.target.npm || target.npmVersion !== context.target.npmVersion || target.prefix !== context.target.prefix || target.path !== context.target.path || target.version !== context.target.version)
22962
+ throw new Error("\u76EE\u6807 Node/npm \u73AF\u5883\u5728\u68C0\u67E5\u540E\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u66F4\u65B0\u3002");
22963
+ }
22964
+ const candidateRoot = context.reuseTarget ? paths.root : paths.candidate;
22965
+ const node2 = context.target?.node ?? process.execPath;
22966
+ const env = targetNpmEnvironment(
22967
+ context.target?.path ?? process.env.PATH ?? "/usr/bin:/bin",
22968
+ context.target?.npmConfig
22655
22969
  );
22656
- const candidate = await readJson((0, import_node_path11.join)(paths.candidate, "package.json"));
22970
+ if (!context.reuseTarget)
22971
+ await exec5(
22972
+ context.target?.node ?? "npm",
22973
+ [
22974
+ ...context.target ? [context.target.npm] : [],
22975
+ "install",
22976
+ "--global",
22977
+ "--prefix",
22978
+ paths.prefix,
22979
+ "--omit=dev",
22980
+ "--no-audit",
22981
+ "--no-fund",
22982
+ `--registry=${registry2}`,
22983
+ "--allow-scripts=better-sqlite3",
22984
+ `${npmPackageName}@${record2.target}`
22985
+ ],
22986
+ { env, timeout: 10 * 6e4, maxBuffer: 2 * 1024 * 1024 }
22987
+ );
22988
+ const candidate = await readJson((0, import_node_path13.join)(candidateRoot, "package.json"));
22657
22989
  if (candidate?.name !== npmPackageName || candidate.version !== record2.target)
22658
22990
  throw new Error("\u5019\u9009\u5305\u8EAB\u4EFD\u6216\u7248\u672C\u4E0D\u5339\u914D");
22659
22991
  if (record2.commit && (candidate.covroCommit ?? candidate.gitHead) !== record2.commit)
@@ -22673,81 +23005,106 @@ async function worker(directory) {
22673
23005
  );
22674
23006
  };
22675
23007
  await checkCodex();
22676
- await exec3(process.execPath, [(0, import_node_path11.join)(paths.candidate, "bin/covro.mjs"), "--version"], {
22677
- timeout: 3e4
23008
+ const versionProbe = await exec5(node2, [(0, import_node_path13.join)(candidateRoot, "bin/covro.mjs"), "--version"], {
23009
+ timeout: 3e4,
23010
+ env
22678
23011
  });
23012
+ if (versionProbe.stdout.trim() !== record2.target)
23013
+ throw new Error("\u76EE\u6807 Node \u6267\u884C Covro \u5165\u53E3\u540E\u8FD4\u56DE\u7684\u7248\u672C\u4E0D\u5339\u914D");
22679
23014
  const nativeProbe = 'const {createRequire}=await import("node:module"); const r=createRequire(process.argv[1]); const DB=r("better-sqlite3"); const db=new DB(":memory:"); db.close();';
22680
- await exec3(
22681
- process.execPath,
22682
- ["--input-type=module", "-e", nativeProbe, (0, import_node_path11.join)(paths.candidate, "package.json")],
22683
- { timeout: 3e4 }
23015
+ await exec5(
23016
+ node2,
23017
+ ["--input-type=module", "-e", nativeProbe, (0, import_node_path13.join)(candidateRoot, "package.json")],
23018
+ { env, timeout: 3e4 }
23019
+ );
23020
+ await verifyMigrations(context, candidateRoot);
23021
+ const launch = await snapshotLaunch(
23022
+ context.location,
23023
+ context.source ?? {
23024
+ node: process.execPath,
23025
+ entry: (0, import_node_path13.join)(context.root, "bin/covro.mjs"),
23026
+ path: process.env.PATH ?? "/usr/bin:/bin"
23027
+ }
22684
23028
  );
22685
- await verifyMigrations(context, paths.candidate);
23029
+ if (context.target)
23030
+ launch.target = { node: node2, entry: context.target.entry, path: context.target.path };
23031
+ await saveJson((0, import_node_path13.join)(directory, `launch-${record2.id}.json`), launch);
22686
23032
  releaseMaintenance = await acquireMaintenanceLock(context.dataDir);
22687
- await activateUpdate(paths, {
22688
- backup: async () => {
22689
- releaseData = await acquireInstanceLock(context.dataDir);
22690
- await backups.create({ id: record2.id, trigger: "preUpgrade", protectedBy: record2.id });
22691
- },
22692
- restore: async () => {
22693
- releaseData ??= await acquireInstanceLock(context.dataDir);
22694
- await backups.restoreFiles(record2.id);
22695
- },
22696
- phase: update,
22697
- waitForIdle: async () => {
22698
- for (; ; ) {
22699
- await checkCodex();
22700
- const result = await control(
22701
- context.location,
22702
- "prepare-update"
22703
- );
22704
- if (result.ready) {
23033
+ await activateUpdate(
23034
+ paths,
23035
+ {
23036
+ backup: async () => {
23037
+ releaseData = await acquireInstanceLock(context.dataDir);
23038
+ await backups.create({ id: record2.id, trigger: "preUpgrade", protectedBy: record2.id });
23039
+ },
23040
+ restore: async () => {
23041
+ releaseData ??= await acquireInstanceLock(context.dataDir);
23042
+ await backups.restoreFiles(record2.id);
23043
+ },
23044
+ switchLaunch: context.target ? () => switchLaunch(
23045
+ context.location,
23046
+ { node: node2, entry: context.target.entry, path: context.target.path },
23047
+ launch
23048
+ ) : void 0,
23049
+ restoreLaunch: () => restoreLaunch(context.location, launch),
23050
+ phase: update,
23051
+ waitForIdle: async () => {
23052
+ for (; ; ) {
22705
23053
  await checkCodex();
22706
- return;
23054
+ const result = await control(
23055
+ context.location,
23056
+ "prepare-update"
23057
+ );
23058
+ if (result.ready) {
23059
+ await checkCodex();
23060
+ return;
23061
+ }
23062
+ await update("waiting", result.reason ?? "\u7B49\u5F85\u6240\u6709\u4EFB\u52A1\u7ED3\u675F");
23063
+ await (0, import_promises15.setTimeout)(2e3);
22707
23064
  }
22708
- await update("waiting", result.reason ?? "\u7B49\u5F85\u6240\u6709\u4EFB\u52A1\u7ED3\u675F");
22709
- await (0, import_promises13.setTimeout)(2e3);
22710
- }
22711
- },
22712
- stop: () => stopService(context),
22713
- start: async (candidate2) => {
22714
- await releaseData?.();
22715
- releaseData = void 0;
22716
- await startService(context);
22717
- if (!candidate2) await verifyRestoredService(context, record2.from);
22718
- },
22719
- verify: async () => {
22720
- for (let attempt = 0; attempt < 240; attempt++) {
22721
- const current = await control(context.location, "status").catch(
22722
- () => void 0
22723
- );
22724
- if (current) {
22725
- if (current.version !== record2.target || !current.maintenance)
22726
- throw new Error("\u65B0\u7248\u670D\u52A1\u8EAB\u4EFD\u6216\u7EF4\u62A4\u72B6\u6001\u4E0D\u5339\u914D");
22727
- await checkCodex(current);
22728
- if (current.codexReady) return;
23065
+ },
23066
+ stop: () => stopService(context),
23067
+ start: async (candidate2) => {
23068
+ await releaseData?.();
23069
+ releaseData = void 0;
23070
+ await startService(context, candidate2);
23071
+ if (!candidate2) await verifyRestoredService(context, record2.from);
23072
+ },
23073
+ verify: async () => {
23074
+ for (let attempt = 0; attempt < 240; attempt++) {
23075
+ const current = await control(context.location, "status").catch(
23076
+ () => void 0
23077
+ );
23078
+ if (current) {
23079
+ if (current.version !== record2.target || !current.maintenance)
23080
+ throw new Error("\u65B0\u7248\u670D\u52A1\u8EAB\u4EFD\u6216\u7EF4\u62A4\u72B6\u6001\u4E0D\u5339\u914D");
23081
+ if (record2.runtime) assertRuntime(current.runtime, record2.runtime.target);
23082
+ await checkCodex(current);
23083
+ if (current.codexReady) return;
23084
+ }
23085
+ await (0, import_promises15.setTimeout)(250);
22729
23086
  }
22730
- await (0, import_promises13.setTimeout)(250);
23087
+ throw new Error("\u65B0\u7248\u670D\u52A1\u6216 Codex \u8FDE\u63A5\u672A\u5C31\u7EEA\uFF0C\u62D2\u7EDD\u6FC0\u6D3B");
23088
+ },
23089
+ commit: async () => {
23090
+ await control(context.location, "activate-update", {
23091
+ id: record2.id,
23092
+ channel: record2.channel
23093
+ });
23094
+ const final = await readJson((0, import_node_path13.join)(directory, "run.json"));
23095
+ if (!final?.committed) throw new Error("\u65B0\u7248\u5C1A\u672A\u786E\u8BA4\u5347\u7EA7\u63D0\u4EA4");
23096
+ record2 = final;
23097
+ },
23098
+ hasCommitted: async () => Boolean((await readJson((0, import_node_path13.join)(directory, "run.json")))?.committed),
23099
+ resume: async () => {
23100
+ await control(context.location, "cancel-update").catch(() => {
23101
+ });
22731
23102
  }
22732
- throw new Error("\u65B0\u7248\u670D\u52A1\u6216 Codex \u8FDE\u63A5\u672A\u5C31\u7EEA\uFF0C\u62D2\u7EDD\u6FC0\u6D3B");
22733
- },
22734
- commit: async () => {
22735
- await control(context.location, "activate-update", {
22736
- id: record2.id,
22737
- channel: record2.channel
22738
- });
22739
- const final = await readJson((0, import_node_path11.join)(directory, "run.json"));
22740
- if (!final?.committed) throw new Error("\u65B0\u7248\u5C1A\u672A\u786E\u8BA4\u5347\u7EA7\u63D0\u4EA4");
22741
- record2 = final;
22742
23103
  },
22743
- hasCommitted: async () => Boolean((await readJson((0, import_node_path11.join)(directory, "run.json")))?.committed),
22744
- resume: async () => {
22745
- await control(context.location, "cancel-update").catch(() => {
22746
- });
22747
- }
22748
- });
23104
+ context.reuseTarget
23105
+ );
22749
23106
  } catch (error62) {
22750
- const latest = await readJson((0, import_node_path11.join)(directory, "run.json"));
23107
+ const latest = await readJson((0, import_node_path13.join)(directory, "run.json"));
22751
23108
  if (latest?.committed) {
22752
23109
  record2 = latest;
22753
23110
  } else if (!["rolledBack", "failed"].includes(record2.phase))
@@ -22759,7 +23116,7 @@ async function worker(directory) {
22759
23116
  await releaseMaintenance?.();
22760
23117
  await release();
22761
23118
  if (record2.phase === "succeeded" || record2.phase === "rolledBack") {
22762
- await (0, import_promises12.rm)(paths.prefix, { recursive: true, force: true });
23119
+ await (0, import_promises14.rm)(paths.prefix, { recursive: true, force: true });
22763
23120
  }
22764
23121
  }
22765
23122
  }