@wirecat/zoom-cli 0.65.0 → 0.67.0

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 (194) hide show
  1. package/README.md +2 -1
  2. package/constants.json +7 -0
  3. package/dist/answers.d.ts +4 -4
  4. package/dist/bin/main.js +3 -2
  5. package/dist/bin/main.js.map +1 -1
  6. package/dist/bin/zm.js +2 -2
  7. package/dist/bin/zm.js.map +1 -1
  8. package/dist/bundle/{all-profiles-SKMLZJSY.js → all-profiles-SEW2VL76.js} +12 -8
  9. package/dist/bundle/answer-policy-5OYUL6UF.js +103 -0
  10. package/dist/bundle/{anthropic-TVHK7CY2.js → anthropic-FSNASJML.js} +7 -4
  11. package/dist/bundle/{app-server-44ASFH47.js → app-server-EVSRYJ3H.js} +66 -59
  12. package/dist/bundle/{bun-O4WHGL2F.js → bun-DACL5SVO.js} +2 -2
  13. package/dist/bundle/{bun-sqlite-NS32GMM4.js → bun-sqlite-HQ2KOXSI.js} +6 -3
  14. package/dist/bundle/chunk-2UW533HQ.js +166 -0
  15. package/dist/bundle/{chunk-FYJL276J.js → chunk-3GO3KME7.js} +3 -3
  16. package/dist/bundle/{chunk-Z5424QL6.js → chunk-3ZIHUSMM.js} +2 -2
  17. package/dist/bundle/{chunk-MRWIXUYT.js → chunk-4GCKDO2H.js} +5 -3
  18. package/dist/bundle/{chunk-7SQJCKR6.js → chunk-4KDZ22RA.js} +1 -1
  19. package/dist/bundle/{chunk-25IDWPEN.js → chunk-4U2555EQ.js} +35 -31
  20. package/dist/bundle/{chunk-UKU6MYUI.js → chunk-4UVT2QCO.js} +9 -20
  21. package/dist/bundle/{chunk-ZOGYTDHG.js → chunk-4ZR5DJ26.js} +5 -3
  22. package/dist/bundle/{chunk-CVCRQW3A.js → chunk-54RTMQL6.js} +4 -4
  23. package/dist/bundle/chunk-6AJDVJVZ.js +35 -0
  24. package/dist/bundle/chunk-6IBM4Z3V.js +34 -0
  25. package/dist/bundle/{chunk-CNEE6TPE.js → chunk-6TZF2JP7.js} +13 -13
  26. package/dist/bundle/{chunk-QLCYAQ66.js → chunk-6UFWFKFH.js} +2 -2
  27. package/dist/bundle/chunk-6VFORXL3.js +101 -0
  28. package/dist/bundle/{chunk-M6IDHQ7N.js → chunk-7HAIM7GV.js} +1633 -683
  29. package/dist/bundle/{chunk-FYM27FCG.js → chunk-7K5TDTZY.js} +13 -7
  30. package/dist/bundle/{chunk-NO24PJNW.js → chunk-7LLUUXJB.js} +1 -1
  31. package/dist/bundle/{chunk-VJTGYBJJ.js → chunk-7VU5UGRR.js} +37 -29
  32. package/dist/bundle/{chunk-ZH743WNV.js → chunk-AAZFLJSH.js} +25 -24
  33. package/dist/bundle/{chunk-DYJXAY7Q.js → chunk-ASCHAVNW.js} +35 -27
  34. package/dist/bundle/{chunk-EA63UGWE.js → chunk-B3KWAULD.js} +2 -2
  35. package/dist/bundle/{chunk-H7762LDA.js → chunk-B5Z4XPVS.js} +2 -2
  36. package/dist/bundle/{chunk-UPJXN2CO.js → chunk-BKY4XVB4.js} +1787 -1224
  37. package/dist/bundle/{chunk-QI7BZS2G.js → chunk-C6UKW7JO.js} +6 -6
  38. package/dist/bundle/{chunk-U3ZUT557.js → chunk-CLEZE65P.js} +1 -1
  39. package/dist/bundle/{chunk-37PHGASE.js → chunk-CRLBTNC4.js} +5 -3
  40. package/dist/bundle/{chunk-VH4F2EK4.js → chunk-D4KBD63W.js} +1 -1
  41. package/dist/bundle/{chunk-DNCKH7CO.js → chunk-D6OXI2NV.js} +17 -17
  42. package/dist/bundle/{chunk-LPUFOWL3.js → chunk-D72URWJE.js} +1 -39
  43. package/dist/bundle/{chunk-GMTXCFI7.js → chunk-DFUPETW7.js} +449 -308
  44. package/dist/bundle/{chunk-VW2SW7ME.js → chunk-DG4DWAU7.js} +3 -3
  45. package/dist/bundle/{chunk-U5ASRBBF.js → chunk-EPDRF66S.js} +4 -4
  46. package/dist/bundle/{chunk-BNXH73OU.js → chunk-EQ7XRRKV.js} +14 -12
  47. package/dist/bundle/{chunk-5NGOP4EZ.js → chunk-ESFMHBHH.js} +38 -35
  48. package/dist/bundle/{chunk-GEX4V5TM.js → chunk-EUPZSR2G.js} +4 -4
  49. package/dist/bundle/{chunk-KZE3G4ZT.js → chunk-FGTPREAZ.js} +58 -54
  50. package/dist/bundle/{chunk-MH7AWCB4.js → chunk-FWU3ZYHE.js} +68 -64
  51. package/dist/bundle/{chunk-MPKKIL3U.js → chunk-FXQPK742.js} +63 -21
  52. package/dist/bundle/{chunk-PV3UDPCI.js → chunk-GP4NSYDU.js} +20 -14
  53. package/dist/bundle/{chunk-ZFNM3FNI.js → chunk-I7SOXH64.js} +75 -38
  54. package/dist/bundle/{chunk-S4GDDO5S.js → chunk-IFDO3YPJ.js} +1 -1
  55. package/dist/bundle/{chunk-LOL6JYYN.js → chunk-J3ZBEWQY.js} +375 -9
  56. package/dist/bundle/chunk-JVCHGI7W.js +37 -0
  57. package/dist/bundle/{chunk-MZ6U6HNJ.js → chunk-KANH7GBB.js} +2 -2
  58. package/dist/bundle/{chunk-3CZIWGZ6.js → chunk-KIJLM5UL.js} +1 -1
  59. package/dist/bundle/chunk-KV4267S4.js +23 -0
  60. package/dist/bundle/{chunk-266WOOB3.js → chunk-KWRSC6O6.js} +6 -6
  61. package/dist/bundle/{chunk-C6BG57FA.js → chunk-L643D4RJ.js} +14 -12
  62. package/dist/bundle/{chunk-IPTI3Y2E.js → chunk-L6CAUVMU.js} +7 -5
  63. package/dist/bundle/{chunk-MIB5X2XW.js → chunk-L6WUAGPN.js} +5 -5
  64. package/dist/bundle/{chunk-BWRBALXG.js → chunk-LFQ73UFK.js} +3 -3
  65. package/dist/bundle/{chunk-GBZF4IIP.js → chunk-LKJXTACE.js} +10 -89
  66. package/dist/bundle/{chunk-T3KICUOK.js → chunk-LM26DJOK.js} +8 -8
  67. package/dist/bundle/{chunk-GXCNCMUY.js → chunk-M43MBWJX.js} +3260 -1263
  68. package/dist/bundle/{chunk-TC7PD3LH.js → chunk-MWEOVTIF.js} +4 -4
  69. package/dist/bundle/chunk-NTZDM5SJ.js +2462 -0
  70. package/dist/bundle/{chunk-ERPRAYA7.js → chunk-OTMGAKUM.js} +11 -7
  71. package/dist/bundle/chunk-OZEYFJX2.js +93 -0
  72. package/dist/bundle/{chunk-NJSIHMAE.js → chunk-Q65SDEFN.js} +4 -4
  73. package/dist/bundle/{chunk-UMHJZWZU.js → chunk-QEI55M2F.js} +12 -10
  74. package/dist/bundle/{chunk-SQWRZZOQ.js → chunk-QX2MAT6I.js} +3 -3
  75. package/dist/bundle/{chunk-ZXGRK44F.js → chunk-RAMPYIO2.js} +17 -12
  76. package/dist/bundle/{chunk-BLT3LR3U.js → chunk-RYKG6AEH.js} +1 -1
  77. package/dist/bundle/{chunk-WLSF3GCC.js → chunk-SCFFCIIP.js} +4 -2
  78. package/dist/bundle/{chunk-2H5SXK7K.js → chunk-SMVO5R3T.js} +21 -19
  79. package/dist/bundle/{chunk-Y3EIK4XW.js → chunk-SOZVC3SV.js} +1 -1
  80. package/dist/bundle/{chunk-6CS7ETBK.js → chunk-SSXCOUP3.js} +1114 -282
  81. package/dist/bundle/{chunk-R5BAF5XE.js → chunk-SXFODCYK.js} +1 -1
  82. package/dist/bundle/{chunk-JF7ZEUXU.js → chunk-T6CZWSHF.js} +136 -2540
  83. package/dist/bundle/{chunk-KYLS5QGC.js → chunk-TBRG2DPE.js} +2 -2
  84. package/dist/bundle/{chunk-K6ATTKQR.js → chunk-V33VGWT3.js} +5 -5
  85. package/dist/bundle/{chunk-RZLNHNSS.js → chunk-VFIEYRYD.js} +8 -8
  86. package/dist/bundle/{chunk-OXUHTKO2.js → chunk-VNIBTNV4.js} +3 -2
  87. package/dist/bundle/{chunk-ZREFYKUB.js → chunk-VQTAU4DV.js} +13 -11
  88. package/dist/bundle/{chunk-NNNEVWFF.js → chunk-WHQ4ZCJI.js} +57 -34
  89. package/dist/bundle/chunk-WZ5XK74U.js +46 -0
  90. package/dist/bundle/{chunk-XJQB47IL.js → chunk-X67YD3QI.js} +6 -6
  91. package/dist/bundle/chunk-YPF6OS37.js +46 -0
  92. package/dist/bundle/{chunk-AMMD6YCJ.js → chunk-YRNZT4GQ.js} +7 -7
  93. package/dist/bundle/{chunk-TUIEDVI6.js → chunk-Z3WXI4DK.js} +5 -3
  94. package/dist/bundle/{chunk-U4RVOSX3.js → chunk-ZMPTO2WB.js} +1 -1
  95. package/dist/bundle/{chunk-24F7JBLY.js → chunk-ZRMZBMOF.js} +69 -9
  96. package/dist/bundle/{cli-FDO6CP6R.js → cli-YUATSOLA.js} +113 -81
  97. package/dist/bundle/command-contract-UWHY55UE.js +41 -0
  98. package/dist/bundle/config-TGF6E6ZD.js +89 -0
  99. package/dist/bundle/{decode-7SZI3TGZ.js → decode-IL44LNC3.js} +6 -3
  100. package/dist/bundle/dispatch-3BGIXSJR.js +412 -0
  101. package/dist/bundle/{dist-5GWUXW27.js → dist-3W27UQ2S.js} +48 -16
  102. package/dist/bundle/{echarts-FMACRZQC.js → echarts-CO4D26JF.js} +2 -2
  103. package/dist/bundle/{embed-24YSXHLP.js → embed-XH2X4DFM.js} +7 -4
  104. package/dist/bundle/{embedder-MEXN2TFB.js → embedder-WTFWDXBJ.js} +12 -9
  105. package/dist/bundle/failure-HTIS3NLS.js +25 -0
  106. package/dist/bundle/first-run-5RBH7FDO.js +28 -0
  107. package/dist/bundle/first-screen-PGFIXJAX.js +39 -0
  108. package/dist/bundle/{folders-DBAAMU26.js → folders-F4DNQPIY.js} +5 -2
  109. package/dist/bundle/{instructions-E5FXYCWF.js → instructions-EPPBL6TT.js} +1 -1
  110. package/dist/bundle/{main-EIUCXXDW.js → main-LVQTCDZS.js} +31 -25
  111. package/dist/bundle/{mcp-FUSDPAOL.js → mcp-PPVOM4SE.js} +5 -3
  112. package/dist/bundle/{meetings-JDTRGXZJ.js → meetings-BMELXRTR.js} +31 -4
  113. package/dist/bundle/{node-4SNKUPXT.js → node-CQVMWVIG.js} +2 -2
  114. package/dist/bundle/{node-sqlite-O4BAODFR.js → node-sqlite-QQEX7LZT.js} +7 -4
  115. package/dist/bundle/{oauth-3YLHXGUW.js → oauth-AYGX7CQS.js} +8 -5
  116. package/dist/bundle/{open-QGRMSNM2.js → open-MIL2TOT6.js} +6 -3
  117. package/dist/bundle/openai-7QZZXQW5.js +25 -0
  118. package/dist/bundle/{output-file-J26UQKRA.js → output-file-4XADZPYH.js} +7 -4
  119. package/dist/bundle/{process-HQZOTT6U.js → process-NJVQK6GB.js} +1 -1
  120. package/dist/bundle/{program-47DT7SHE.js → program-WUYRS6H7.js} +191 -135
  121. package/dist/bundle/{prompt-IUD7HCDC.js → prompt-J4QPFLEA.js} +6 -3
  122. package/dist/bundle/{recognize-DMJJHHXF.js → recognize-OLJZVNWW.js} +5 -2
  123. package/dist/bundle/{remote-5WFSOVVB.js → remote-JPUXNYLV.js} +8 -5
  124. package/dist/bundle/{rerank-UKQ65ECH.js → rerank-XVV3X5TT.js} +8 -5
  125. package/dist/bundle/run-log-DJXBEVS5.js +118 -0
  126. package/dist/bundle/{serve-WAOSED3I.js → serve-NYYUO3MR.js} +16 -13
  127. package/dist/bundle/{server-NWZFNXC5.js → server-4Z5E4YTT.js} +48 -42
  128. package/dist/bundle/server-VW5UVCH7.js +72 -0
  129. package/dist/bundle/{services-VPANRE72.js → services-EKWM76HP.js} +50 -28
  130. package/dist/bundle/{speech-O6UNUDRW.js → speech-WFJ44ACJ.js} +14 -11
  131. package/dist/bundle/{state-BNE7I65A.js → state-VIRCT4VW.js} +7 -4
  132. package/dist/bundle/{store-4IIVSCJ4.js → store-2Q4GEZJS.js} +30 -18
  133. package/dist/bundle/{store-QQH4FJXJ.js → store-ZTDZ6UY5.js} +20 -14
  134. package/dist/bundle/store-connection-FKVVQLEF.js +83 -0
  135. package/dist/bundle/store-maintenance-command-AU73UVUQ.js +62 -0
  136. package/dist/bundle/{streaming-S4EZB6P2.js → streaming-7BPKIGAS.js} +7 -4
  137. package/dist/bundle/{tokens-VCXIH7WZ.js → tokens-CQHMMKNX.js} +7 -4
  138. package/dist/bundle/zm.js +150 -1
  139. package/dist/bundle/zoom-app-OEKFMJS6.js +25 -0
  140. package/dist/config.d.ts +9 -0
  141. package/dist/config.d.ts.map +1 -1
  142. package/dist/config.js +46 -7
  143. package/dist/config.js.map +1 -1
  144. package/dist/meeting-source.d.ts.map +1 -1
  145. package/dist/meeting-source.js +2 -1
  146. package/dist/meeting-source.js.map +1 -1
  147. package/dist/meeting-stats-commands.d.ts +4 -2
  148. package/dist/meeting-stats-commands.d.ts.map +1 -1
  149. package/dist/meeting-stats-commands.js +27 -2
  150. package/dist/meeting-stats-commands.js.map +1 -1
  151. package/dist/program-bindings.d.ts.map +1 -1
  152. package/dist/program-bindings.js +3 -2
  153. package/dist/program-bindings.js.map +1 -1
  154. package/dist/recording-schedule-setup.d.ts.map +1 -1
  155. package/dist/recording-schedule-setup.js +5 -5
  156. package/dist/recording-schedule-setup.js.map +1 -1
  157. package/dist/run.d.ts.map +1 -1
  158. package/dist/run.js +2 -6
  159. package/dist/run.js.map +1 -1
  160. package/dist/setup-commands.d.ts +1 -1
  161. package/dist/setup-commands.d.ts.map +1 -1
  162. package/dist/setup-commands.js +30 -8
  163. package/dist/setup-commands.js.map +1 -1
  164. package/dist/store-commands.d.ts.map +1 -1
  165. package/dist/store-commands.js +6 -0
  166. package/dist/store-commands.js.map +1 -1
  167. package/dist/store-connection.d.ts +2 -1
  168. package/dist/store-connection.d.ts.map +1 -1
  169. package/dist/store-connection.js +4 -0
  170. package/dist/store-connection.js.map +1 -1
  171. package/dist/version.d.ts +1 -1
  172. package/dist/version.js +1 -1
  173. package/dist/watch-service.d.ts +1 -1
  174. package/dist/watch-service.d.ts.map +1 -1
  175. package/dist/watch-service.js +5 -3
  176. package/dist/watch-service.js.map +1 -1
  177. package/dist/zoom-app.d.ts +17 -0
  178. package/dist/zoom-app.d.ts.map +1 -0
  179. package/dist/zoom-app.js +22 -0
  180. package/dist/zoom-app.js.map +1 -0
  181. package/package.json +6 -4
  182. package/skills/zoom-cli/SKILL.md +4 -1
  183. package/dist/bundle/answer-policy-BHDNSJWX.js +0 -96
  184. package/dist/bundle/chunk-A6OA2EH2.js +0 -18
  185. package/dist/bundle/command-contract-O4FDXM4U.js +0 -37
  186. package/dist/bundle/config-UBHKZG3J.js +0 -78
  187. package/dist/bundle/first-run-OCVEJH63.js +0 -23
  188. package/dist/bundle/first-screen-KJIU25MH.js +0 -35
  189. package/dist/bundle/openai-7PSCSTH7.js +0 -22
  190. package/dist/bundle/run-log-UGYL6NW2.js +0 -111
  191. package/dist/bundle/server-HAXN772R.js +0 -66
  192. package/dist/bundle/store-connection-PPEQK2K3.js +0 -76
  193. package/dist/bundle/store-maintenance-command-JZXCT6NY.js +0 -56
  194. /package/dist/bundle/{chunk-NUN6OGOV.js → chunk-LU3WKZBA.js} +0 -0
@@ -1,5 +1,32 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ array,
5
+ dottedId,
6
+ duplicates,
7
+ errorObjectOf,
8
+ getDotPath,
9
+ isoTime,
10
+ object,
11
+ optional,
12
+ parseRegistry,
13
+ picklist,
14
+ pipe,
15
+ record,
16
+ regex,
17
+ safeParse,
18
+ strictObject,
19
+ string,
20
+ text,
21
+ unknown
22
+ } from "./chunk-NTZDM5SJ.js";
23
+ import {
24
+ CliError,
25
+ isCliError
26
+ } from "./chunk-WZ5XK74U.js";
27
+ import {
28
+ visibleControls
29
+ } from "./chunk-6IBM4Z3V.js";
3
30
  import {
4
31
  __commonJS,
5
32
  __name,
@@ -367,26 +394,26 @@ var require_utils = __commonJS({
367
394
  return ret;
368
395
  }
369
396
  __name(mergeOptions, "mergeOptions");
370
- function wordWrap(maxLength2, input) {
397
+ function wordWrap(maxLength, input) {
371
398
  let lines = [];
372
399
  let split = input.split(/(\s+)/g);
373
400
  let line = [];
374
401
  let lineLength = 0;
375
402
  let whitespace;
376
403
  for (let i = 0; i < split.length; i += 2) {
377
- let word2 = split[i];
378
- let newLength = lineLength + strlen(word2);
404
+ let word = split[i];
405
+ let newLength = lineLength + strlen(word);
379
406
  if (lineLength > 0 && whitespace) {
380
407
  newLength += whitespace.length;
381
408
  }
382
- if (newLength > maxLength2) {
409
+ if (newLength > maxLength) {
383
410
  if (lineLength !== 0) {
384
411
  lines.push(line.join(""));
385
412
  }
386
- line = [word2];
387
- lineLength = strlen(word2);
413
+ line = [word];
414
+ lineLength = strlen(word);
388
415
  } else {
389
- line.push(whitespace || "", word2);
416
+ line.push(whitespace || "", word);
390
417
  lineLength = newLength;
391
418
  }
392
419
  whitespace = split[i + 1];
@@ -397,15 +424,15 @@ var require_utils = __commonJS({
397
424
  return lines;
398
425
  }
399
426
  __name(wordWrap, "wordWrap");
400
- function textWrap(maxLength2, input) {
427
+ function textWrap(maxLength, input) {
401
428
  let lines = [];
402
429
  let line = "";
403
430
  function pushLine(str, ws) {
404
431
  if (line.length && ws) line += ws;
405
432
  line += str;
406
- while (line.length > maxLength2) {
407
- lines.push(line.slice(0, maxLength2));
408
- line = line.slice(maxLength2);
433
+ while (line.length > maxLength) {
434
+ lines.push(line.slice(0, maxLength));
435
+ line = line.slice(maxLength);
409
436
  }
410
437
  }
411
438
  __name(pushLine, "pushLine");
@@ -417,12 +444,12 @@ var require_utils = __commonJS({
417
444
  return lines;
418
445
  }
419
446
  __name(textWrap, "textWrap");
420
- function multiLineWordWrap(maxLength2, input, wrapOnWordBoundary = true) {
447
+ function multiLineWordWrap(maxLength, input, wrapOnWordBoundary = true) {
421
448
  let output = [];
422
449
  input = input.split("\n");
423
450
  const handler = wrapOnWordBoundary ? wordWrap : textWrap;
424
451
  for (let i = 0; i < input.length; i++) {
425
- output.push.apply(output, handler(maxLength2, input[i]));
452
+ output.push.apply(output, handler(maxLength, input[i]));
426
453
  }
427
454
  return output;
428
455
  }
@@ -1872,2412 +1899,7 @@ var require_cli_table3 = __commonJS({
1872
1899
  }
1873
1900
  });
1874
1901
 
1875
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/errors.js
1876
- var errorCodes = [
1877
- "validation_error",
1878
- "configuration_error",
1879
- "authentication_error",
1880
- "permission_error",
1881
- "not_found",
1882
- "confirmation_required",
1883
- "rate_limited",
1884
- "timeout",
1885
- "network_error",
1886
- "provider_error",
1887
- "provider_unavailable",
1888
- "invalid_response",
1889
- "outcome_unknown",
1890
- "cancelled"
1891
- ];
1892
- var BRAND = /* @__PURE__ */ Symbol.for("@wirecat/cli-base/CliError");
1893
- var CliError = class extends Error {
1894
- static {
1895
- __name(this, "CliError");
1896
- }
1897
- code;
1898
- details;
1899
- constructor(code, message, details = {}) {
1900
- super(message);
1901
- this.name = "CliError";
1902
- this.code = code;
1903
- this.details = details;
1904
- Object.defineProperty(this, BRAND, { value: true });
1905
- }
1906
- };
1907
- var isCliError = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && value[BRAND] === true, "isCliError");
1908
-
1909
- // node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
1910
- var store$4;
1911
- var DEFAULT_CONFIG = {
1912
- lang: void 0,
1913
- message: void 0,
1914
- abortEarly: void 0,
1915
- abortPipeEarly: void 0
1916
- };
1917
- // @__NO_SIDE_EFFECTS__
1918
- function getGlobalConfig(config$1) {
1919
- if (!config$1 && !store$4) return DEFAULT_CONFIG;
1920
- return {
1921
- lang: config$1?.lang ?? store$4?.lang,
1922
- message: config$1?.message,
1923
- abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
1924
- abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
1925
- };
1926
- }
1927
- __name(getGlobalConfig, "getGlobalConfig");
1928
- var store$3;
1929
- // @__NO_SIDE_EFFECTS__
1930
- function getGlobalMessage(lang) {
1931
- return store$3?.get(lang);
1932
- }
1933
- __name(getGlobalMessage, "getGlobalMessage");
1934
- var store$2;
1935
- // @__NO_SIDE_EFFECTS__
1936
- function getSchemaMessage(lang) {
1937
- return store$2?.get(lang);
1938
- }
1939
- __name(getSchemaMessage, "getSchemaMessage");
1940
- var store$1;
1941
- // @__NO_SIDE_EFFECTS__
1942
- function getSpecificMessage(reference2, lang) {
1943
- return store$1?.get(reference2)?.get(lang);
1944
- }
1945
- __name(getSpecificMessage, "getSpecificMessage");
1946
- // @__NO_SIDE_EFFECTS__
1947
- function _stringify(input) {
1948
- const type = typeof input;
1949
- if (type === "string") return `"${input}"`;
1950
- if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
1951
- if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
1952
- return type;
1953
- }
1954
- __name(_stringify, "_stringify");
1955
- function _addIssue(context, label, dataset, config$1, other) {
1956
- const input = other && "input" in other ? other.input : dataset.value;
1957
- const expected = other?.expected ?? context.expects ?? null;
1958
- const received = other?.received ?? /* @__PURE__ */ _stringify(input);
1959
- const issue = {
1960
- kind: context.kind,
1961
- type: context.type,
1962
- input,
1963
- expected,
1964
- received,
1965
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
1966
- requirement: context.requirement,
1967
- path: other?.path,
1968
- issues: other?.issues,
1969
- lang: config$1.lang,
1970
- abortEarly: config$1.abortEarly,
1971
- abortPipeEarly: config$1.abortPipeEarly
1972
- };
1973
- const isSchema = context.kind === "schema";
1974
- const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
1975
- if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
1976
- if (isSchema) dataset.typed = false;
1977
- if (dataset.issues) dataset.issues.push(issue);
1978
- else dataset.issues = [issue];
1979
- }
1980
- __name(_addIssue, "_addIssue");
1981
- // @__NO_SIDE_EFFECTS__
1982
- function _isSameValueZero(value1, value2) {
1983
- return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
1984
- }
1985
- __name(_isSameValueZero, "_isSameValueZero");
1986
- // @__NO_SIDE_EFFECTS__
1987
- function _isValidObjectKey(object$1, key) {
1988
- return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
1989
- }
1990
- __name(_isValidObjectKey, "_isValidObjectKey");
1991
- // @__NO_SIDE_EFFECTS__
1992
- function _joinExpects(values$1, separator) {
1993
- const list = [...new Set(values$1)];
1994
- if (list.length > 1) return `(${list.join(` ${separator} `)})`;
1995
- return list[0] ?? "never";
1996
- }
1997
- __name(_joinExpects, "_joinExpects");
1998
- function _standardSchema(schema) {
1999
- schema["~standard"] = {
2000
- version: 1,
2001
- vendor: "valibot",
2002
- validate: /* @__PURE__ */ __name((value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig()), "validate")
2003
- };
2004
- return schema;
2005
- }
2006
- __name(_standardSchema, "_standardSchema");
2007
- // @__NO_SIDE_EFFECTS__
2008
- function getDotPath(issue) {
2009
- if (issue.path) {
2010
- let key = "";
2011
- for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
2012
- else key += item.key;
2013
- else return null;
2014
- return key;
2015
- }
2016
- return null;
2017
- }
2018
- __name(getDotPath, "getDotPath");
2019
- var ValiError = class extends Error {
2020
- static {
2021
- __name(this, "ValiError");
2022
- }
2023
- /**
2024
- * Creates a Valibot error with useful information.
2025
- *
2026
- * @param issues The error issues.
2027
- */
2028
- constructor(issues) {
2029
- super(issues[0].message);
2030
- this.name = "ValiError";
2031
- this.issues = issues;
2032
- }
2033
- };
2034
- var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
2035
- var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])$/u;
2036
- var ISO_TIMESTAMP_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])[T ](?:0\d|1\d|2[0-3])(?::[0-5]\d){2}(?:\.\d{1,9})?(?:Z| ?[+-](?:0\d|1\d|2[0-3])(?::?[0-5]\d)?)$/u;
2037
- // @__NO_SIDE_EFFECTS__
2038
- function check(requirement, message$1) {
2039
- return {
2040
- kind: "validation",
2041
- type: "check",
2042
- reference: check,
2043
- async: false,
2044
- expects: null,
2045
- requirement,
2046
- message: message$1,
2047
- "~run"(dataset, config$1) {
2048
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
2049
- return dataset;
2050
- }
2051
- };
2052
- }
2053
- __name(check, "check");
2054
- // @__NO_SIDE_EFFECTS__
2055
- function description(description_) {
2056
- return {
2057
- kind: "metadata",
2058
- type: "description",
2059
- reference: description,
2060
- description: description_
2061
- };
2062
- }
2063
- __name(description, "description");
2064
- // @__NO_SIDE_EFFECTS__
2065
- function endsWith(requirement, message$1) {
2066
- return {
2067
- kind: "validation",
2068
- type: "ends_with",
2069
- reference: endsWith,
2070
- async: false,
2071
- expects: `"${requirement}"`,
2072
- requirement,
2073
- message: message$1,
2074
- "~run"(dataset, config$1) {
2075
- if (dataset.typed && !dataset.value.endsWith(this.requirement)) _addIssue(this, "end", dataset, config$1, { received: `"${dataset.value.slice(-this.requirement.length)}"` });
2076
- return dataset;
2077
- }
2078
- };
2079
- }
2080
- __name(endsWith, "endsWith");
2081
- // @__NO_SIDE_EFFECTS__
2082
- function finite(message$1) {
2083
- return {
2084
- kind: "validation",
2085
- type: "finite",
2086
- reference: finite,
2087
- async: false,
2088
- expects: null,
2089
- requirement: Number.isFinite,
2090
- message: message$1,
2091
- "~run"(dataset, config$1) {
2092
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "finite", dataset, config$1);
2093
- return dataset;
2094
- }
2095
- };
2096
- }
2097
- __name(finite, "finite");
2098
- // @__NO_SIDE_EFFECTS__
2099
- function integer(message$1) {
2100
- return {
2101
- kind: "validation",
2102
- type: "integer",
2103
- reference: integer,
2104
- async: false,
2105
- expects: null,
2106
- requirement: Number.isInteger,
2107
- message: message$1,
2108
- "~run"(dataset, config$1) {
2109
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
2110
- return dataset;
2111
- }
2112
- };
2113
- }
2114
- __name(integer, "integer");
2115
- // @__NO_SIDE_EFFECTS__
2116
- function isoDate(message$1) {
2117
- return {
2118
- kind: "validation",
2119
- type: "iso_date",
2120
- reference: isoDate,
2121
- async: false,
2122
- expects: null,
2123
- requirement: ISO_DATE_REGEX,
2124
- message: message$1,
2125
- "~run"(dataset, config$1) {
2126
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "date", dataset, config$1);
2127
- return dataset;
2128
- }
2129
- };
2130
- }
2131
- __name(isoDate, "isoDate");
2132
- // @__NO_SIDE_EFFECTS__
2133
- function isoTimestamp(message$1) {
2134
- return {
2135
- kind: "validation",
2136
- type: "iso_timestamp",
2137
- reference: isoTimestamp,
2138
- async: false,
2139
- expects: null,
2140
- requirement: ISO_TIMESTAMP_REGEX,
2141
- message: message$1,
2142
- "~run"(dataset, config$1) {
2143
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "timestamp", dataset, config$1);
2144
- return dataset;
2145
- }
2146
- };
2147
- }
2148
- __name(isoTimestamp, "isoTimestamp");
2149
- // @__NO_SIDE_EFFECTS__
2150
- function maxLength(requirement, message$1) {
2151
- return {
2152
- kind: "validation",
2153
- type: "max_length",
2154
- reference: maxLength,
2155
- async: false,
2156
- expects: `<=${requirement}`,
2157
- requirement,
2158
- message: message$1,
2159
- "~run"(dataset, config$1) {
2160
- if (dataset.typed && dataset.value.length > this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
2161
- return dataset;
2162
- }
2163
- };
2164
- }
2165
- __name(maxLength, "maxLength");
2166
- // @__NO_SIDE_EFFECTS__
2167
- function maxValue(requirement, message$1) {
2168
- return {
2169
- kind: "validation",
2170
- type: "max_value",
2171
- reference: maxValue,
2172
- async: false,
2173
- expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
2174
- requirement,
2175
- message: message$1,
2176
- "~run"(dataset, config$1) {
2177
- if (dataset.typed && !(dataset.value <= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
2178
- return dataset;
2179
- }
2180
- };
2181
- }
2182
- __name(maxValue, "maxValue");
2183
- // @__NO_SIDE_EFFECTS__
2184
- function minLength(requirement, message$1) {
2185
- return {
2186
- kind: "validation",
2187
- type: "min_length",
2188
- reference: minLength,
2189
- async: false,
2190
- expects: `>=${requirement}`,
2191
- requirement,
2192
- message: message$1,
2193
- "~run"(dataset, config$1) {
2194
- if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
2195
- return dataset;
2196
- }
2197
- };
2198
- }
2199
- __name(minLength, "minLength");
2200
- // @__NO_SIDE_EFFECTS__
2201
- function minValue(requirement, message$1) {
2202
- return {
2203
- kind: "validation",
2204
- type: "min_value",
2205
- reference: minValue,
2206
- async: false,
2207
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
2208
- requirement,
2209
- message: message$1,
2210
- "~run"(dataset, config$1) {
2211
- if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
2212
- return dataset;
2213
- }
2214
- };
2215
- }
2216
- __name(minValue, "minValue");
2217
- // @__NO_SIDE_EFFECTS__
2218
- function nonEmpty(message$1) {
2219
- return {
2220
- kind: "validation",
2221
- type: "non_empty",
2222
- reference: nonEmpty,
2223
- async: false,
2224
- expects: "!0",
2225
- message: message$1,
2226
- "~run"(dataset, config$1) {
2227
- if (dataset.typed && dataset.value.length === 0) _addIssue(this, "length", dataset, config$1, { received: "0" });
2228
- return dataset;
2229
- }
2230
- };
2231
- }
2232
- __name(nonEmpty, "nonEmpty");
2233
- // @__NO_SIDE_EFFECTS__
2234
- function regex(requirement, message$1) {
2235
- return {
2236
- kind: "validation",
2237
- type: "regex",
2238
- reference: regex,
2239
- async: false,
2240
- expects: `${requirement}`,
2241
- requirement,
2242
- message: message$1,
2243
- "~run"(dataset, config$1) {
2244
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config$1);
2245
- return dataset;
2246
- }
2247
- };
2248
- }
2249
- __name(regex, "regex");
2250
- // @__NO_SIDE_EFFECTS__
2251
- function safeInteger(message$1) {
2252
- return {
2253
- kind: "validation",
2254
- type: "safe_integer",
2255
- reference: safeInteger,
2256
- async: false,
2257
- expects: null,
2258
- requirement: Number.isSafeInteger,
2259
- message: message$1,
2260
- "~run"(dataset, config$1) {
2261
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "safe integer", dataset, config$1);
2262
- return dataset;
2263
- }
2264
- };
2265
- }
2266
- __name(safeInteger, "safeInteger");
2267
- // @__NO_SIDE_EFFECTS__
2268
- function transform(operation) {
2269
- return {
2270
- kind: "transformation",
2271
- type: "transform",
2272
- reference: transform,
2273
- async: false,
2274
- operation,
2275
- "~run"(dataset) {
2276
- dataset.value = this.operation(dataset.value);
2277
- return dataset;
2278
- }
2279
- };
2280
- }
2281
- __name(transform, "transform");
2282
- // @__NO_SIDE_EFFECTS__
2283
- function trim() {
2284
- return {
2285
- kind: "transformation",
2286
- type: "trim",
2287
- reference: trim,
2288
- async: false,
2289
- "~run"(dataset) {
2290
- dataset.value = dataset.value.trim();
2291
- return dataset;
2292
- }
2293
- };
2294
- }
2295
- __name(trim, "trim");
2296
- var ABORT_EARLY_CONFIG = { abortEarly: true };
2297
- // @__NO_SIDE_EFFECTS__
2298
- function getFallback(schema, dataset, config$1) {
2299
- return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
2300
- }
2301
- __name(getFallback, "getFallback");
2302
- // @__NO_SIDE_EFFECTS__
2303
- function forward(action, path) {
2304
- return {
2305
- ...action,
2306
- "~run"(dataset, config$1) {
2307
- const prevIssues = dataset.issues && [...dataset.issues];
2308
- dataset = action["~run"](dataset, config$1);
2309
- if (dataset.issues) {
2310
- for (const issue of dataset.issues) if (!prevIssues?.includes(issue)) {
2311
- let pathInput = dataset.value;
2312
- for (const key of path) {
2313
- const pathValue = pathInput[key];
2314
- const pathItem = {
2315
- type: "unknown",
2316
- origin: "value",
2317
- input: pathInput,
2318
- key,
2319
- value: pathValue
2320
- };
2321
- if (issue.path) issue.path.push(pathItem);
2322
- else issue.path = [pathItem];
2323
- if (!pathValue) break;
2324
- pathInput = pathValue;
2325
- }
2326
- }
2327
- }
2328
- return dataset;
2329
- }
2330
- };
2331
- }
2332
- __name(forward, "forward");
2333
- // @__NO_SIDE_EFFECTS__
2334
- function getDefault(schema, dataset, config$1) {
2335
- return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
2336
- }
2337
- __name(getDefault, "getDefault");
2338
- // @__NO_SIDE_EFFECTS__
2339
- function array(item, message$1) {
2340
- return _standardSchema({
2341
- kind: "schema",
2342
- type: "array",
2343
- reference: array,
2344
- expects: "Array",
2345
- async: false,
2346
- item,
2347
- message: message$1,
2348
- "~run"(dataset, config$1) {
2349
- const input = dataset.value;
2350
- if (Array.isArray(input)) {
2351
- dataset.typed = true;
2352
- dataset.value = [];
2353
- for (let key = 0; key < input.length; key++) {
2354
- const value$1 = input[key];
2355
- const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
2356
- if (itemDataset.issues) {
2357
- const pathItem = {
2358
- type: "array",
2359
- origin: "value",
2360
- input,
2361
- key,
2362
- value: value$1
2363
- };
2364
- for (const issue of itemDataset.issues) {
2365
- if (issue.path) issue.path.unshift(pathItem);
2366
- else issue.path = [pathItem];
2367
- dataset.issues?.push(issue);
2368
- }
2369
- if (!dataset.issues) dataset.issues = itemDataset.issues;
2370
- if (config$1.abortEarly) {
2371
- dataset.typed = false;
2372
- break;
2373
- }
2374
- }
2375
- if (!itemDataset.typed) dataset.typed = false;
2376
- dataset.value.push(itemDataset.value);
2377
- }
2378
- } else _addIssue(this, "type", dataset, config$1);
2379
- return dataset;
2380
- }
2381
- });
2382
- }
2383
- __name(array, "array");
2384
- // @__NO_SIDE_EFFECTS__
2385
- function boolean(message$1) {
2386
- return _standardSchema({
2387
- kind: "schema",
2388
- type: "boolean",
2389
- reference: boolean,
2390
- expects: "boolean",
2391
- async: false,
2392
- message: message$1,
2393
- "~run"(dataset, config$1) {
2394
- if (typeof dataset.value === "boolean") dataset.typed = true;
2395
- else _addIssue(this, "type", dataset, config$1);
2396
- return dataset;
2397
- }
2398
- });
2399
- }
2400
- __name(boolean, "boolean");
2401
- // @__NO_SIDE_EFFECTS__
2402
- function custom(check$1, message$1) {
2403
- return _standardSchema({
2404
- kind: "schema",
2405
- type: "custom",
2406
- reference: custom,
2407
- expects: "unknown",
2408
- async: false,
2409
- check: check$1,
2410
- message: message$1,
2411
- "~run"(dataset, config$1) {
2412
- if (this.check(dataset.value)) dataset.typed = true;
2413
- else _addIssue(this, "type", dataset, config$1);
2414
- return dataset;
2415
- }
2416
- });
2417
- }
2418
- __name(custom, "custom");
2419
- // @__NO_SIDE_EFFECTS__
2420
- function lazy(getter) {
2421
- return _standardSchema({
2422
- kind: "schema",
2423
- type: "lazy",
2424
- reference: lazy,
2425
- expects: "unknown",
2426
- async: false,
2427
- getter,
2428
- "~run"(dataset, config$1) {
2429
- return this.getter(dataset.value)["~run"](dataset, config$1);
2430
- }
2431
- });
2432
- }
2433
- __name(lazy, "lazy");
2434
- // @__NO_SIDE_EFFECTS__
2435
- function literal(literal_, message$1) {
2436
- return _standardSchema({
2437
- kind: "schema",
2438
- type: "literal",
2439
- reference: literal,
2440
- expects: /* @__PURE__ */ _stringify(literal_),
2441
- async: false,
2442
- literal: literal_,
2443
- message: message$1,
2444
- "~run"(dataset, config$1) {
2445
- if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
2446
- else _addIssue(this, "type", dataset, config$1);
2447
- return dataset;
2448
- }
2449
- });
2450
- }
2451
- __name(literal, "literal");
2452
- // @__NO_SIDE_EFFECTS__
2453
- function looseObject(entries$1, message$1) {
2454
- return _standardSchema({
2455
- kind: "schema",
2456
- type: "loose_object",
2457
- reference: looseObject,
2458
- expects: "Object",
2459
- async: false,
2460
- entries: entries$1,
2461
- message: message$1,
2462
- "~run"(dataset, config$1) {
2463
- const input = dataset.value;
2464
- if (input && typeof input === "object") {
2465
- dataset.typed = true;
2466
- dataset.value = {};
2467
- for (const key in this.entries) {
2468
- const valueSchema = this.entries[key];
2469
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2470
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2471
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2472
- if (valueDataset.issues) {
2473
- const pathItem = {
2474
- type: "object",
2475
- origin: "value",
2476
- input,
2477
- key,
2478
- value: value$1
2479
- };
2480
- for (const issue of valueDataset.issues) {
2481
- if (issue.path) issue.path.unshift(pathItem);
2482
- else issue.path = [pathItem];
2483
- dataset.issues?.push(issue);
2484
- }
2485
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2486
- if (config$1.abortEarly) {
2487
- dataset.typed = false;
2488
- break;
2489
- }
2490
- }
2491
- if (!valueDataset.typed) dataset.typed = false;
2492
- dataset.value[key] = valueDataset.value;
2493
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2494
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2495
- _addIssue(this, "key", dataset, config$1, {
2496
- input: void 0,
2497
- expected: `"${key}"`,
2498
- path: [{
2499
- type: "object",
2500
- origin: "key",
2501
- input,
2502
- key,
2503
- value: input[key]
2504
- }]
2505
- });
2506
- if (config$1.abortEarly) break;
2507
- }
2508
- }
2509
- if (!dataset.issues || !config$1.abortEarly) {
2510
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) dataset.value[key] = input[key];
2511
- }
2512
- } else _addIssue(this, "type", dataset, config$1);
2513
- return dataset;
2514
- }
2515
- });
2516
- }
2517
- __name(looseObject, "looseObject");
2518
- // @__NO_SIDE_EFFECTS__
2519
- function null_(message$1) {
2520
- return _standardSchema({
2521
- kind: "schema",
2522
- type: "null",
2523
- reference: null_,
2524
- expects: "null",
2525
- async: false,
2526
- message: message$1,
2527
- "~run"(dataset, config$1) {
2528
- if (dataset.value === null) dataset.typed = true;
2529
- else _addIssue(this, "type", dataset, config$1);
2530
- return dataset;
2531
- }
2532
- });
2533
- }
2534
- __name(null_, "null_");
2535
- // @__NO_SIDE_EFFECTS__
2536
- function nullable(wrapped, default_) {
2537
- return _standardSchema({
2538
- kind: "schema",
2539
- type: "nullable",
2540
- reference: nullable,
2541
- expects: `(${wrapped.expects} | null)`,
2542
- async: false,
2543
- wrapped,
2544
- default: default_,
2545
- "~run"(dataset, config$1) {
2546
- if (dataset.value === null) {
2547
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
2548
- if (dataset.value === null) {
2549
- dataset.typed = true;
2550
- return dataset;
2551
- }
2552
- }
2553
- return this.wrapped["~run"](dataset, config$1);
2554
- }
2555
- });
2556
- }
2557
- __name(nullable, "nullable");
2558
- // @__NO_SIDE_EFFECTS__
2559
- function number(message$1) {
2560
- return _standardSchema({
2561
- kind: "schema",
2562
- type: "number",
2563
- reference: number,
2564
- expects: "number",
2565
- async: false,
2566
- message: message$1,
2567
- "~run"(dataset, config$1) {
2568
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
2569
- else _addIssue(this, "type", dataset, config$1);
2570
- return dataset;
2571
- }
2572
- });
2573
- }
2574
- __name(number, "number");
2575
- // @__NO_SIDE_EFFECTS__
2576
- function object(entries$1, message$1) {
2577
- return _standardSchema({
2578
- kind: "schema",
2579
- type: "object",
2580
- reference: object,
2581
- expects: "Object",
2582
- async: false,
2583
- entries: entries$1,
2584
- message: message$1,
2585
- "~run"(dataset, config$1) {
2586
- const input = dataset.value;
2587
- if (input && typeof input === "object") {
2588
- dataset.typed = true;
2589
- dataset.value = {};
2590
- for (const key in this.entries) {
2591
- const valueSchema = this.entries[key];
2592
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2593
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2594
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2595
- if (valueDataset.issues) {
2596
- const pathItem = {
2597
- type: "object",
2598
- origin: "value",
2599
- input,
2600
- key,
2601
- value: value$1
2602
- };
2603
- for (const issue of valueDataset.issues) {
2604
- if (issue.path) issue.path.unshift(pathItem);
2605
- else issue.path = [pathItem];
2606
- dataset.issues?.push(issue);
2607
- }
2608
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2609
- if (config$1.abortEarly) {
2610
- dataset.typed = false;
2611
- break;
2612
- }
2613
- }
2614
- if (!valueDataset.typed) dataset.typed = false;
2615
- dataset.value[key] = valueDataset.value;
2616
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2617
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2618
- _addIssue(this, "key", dataset, config$1, {
2619
- input: void 0,
2620
- expected: `"${key}"`,
2621
- path: [{
2622
- type: "object",
2623
- origin: "key",
2624
- input,
2625
- key,
2626
- value: input[key]
2627
- }]
2628
- });
2629
- if (config$1.abortEarly) break;
2630
- }
2631
- }
2632
- } else _addIssue(this, "type", dataset, config$1);
2633
- return dataset;
2634
- }
2635
- });
2636
- }
2637
- __name(object, "object");
2638
- // @__NO_SIDE_EFFECTS__
2639
- function objectWithRest(entries$1, rest, message$1) {
2640
- return _standardSchema({
2641
- kind: "schema",
2642
- type: "object_with_rest",
2643
- reference: objectWithRest,
2644
- expects: "Object",
2645
- async: false,
2646
- entries: entries$1,
2647
- rest,
2648
- message: message$1,
2649
- "~run"(dataset, config$1) {
2650
- const input = dataset.value;
2651
- if (input && typeof input === "object") {
2652
- dataset.typed = true;
2653
- dataset.value = {};
2654
- for (const key in this.entries) {
2655
- const valueSchema = this.entries[key];
2656
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2657
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2658
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2659
- if (valueDataset.issues) {
2660
- const pathItem = {
2661
- type: "object",
2662
- origin: "value",
2663
- input,
2664
- key,
2665
- value: value$1
2666
- };
2667
- for (const issue of valueDataset.issues) {
2668
- if (issue.path) issue.path.unshift(pathItem);
2669
- else issue.path = [pathItem];
2670
- dataset.issues?.push(issue);
2671
- }
2672
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2673
- if (config$1.abortEarly) {
2674
- dataset.typed = false;
2675
- break;
2676
- }
2677
- }
2678
- if (!valueDataset.typed) dataset.typed = false;
2679
- dataset.value[key] = valueDataset.value;
2680
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2681
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2682
- _addIssue(this, "key", dataset, config$1, {
2683
- input: void 0,
2684
- expected: `"${key}"`,
2685
- path: [{
2686
- type: "object",
2687
- origin: "key",
2688
- input,
2689
- key,
2690
- value: input[key]
2691
- }]
2692
- });
2693
- if (config$1.abortEarly) break;
2694
- }
2695
- }
2696
- if (!dataset.issues || !config$1.abortEarly) {
2697
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
2698
- const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
2699
- if (valueDataset.issues) {
2700
- const pathItem = {
2701
- type: "object",
2702
- origin: "value",
2703
- input,
2704
- key,
2705
- value: input[key]
2706
- };
2707
- for (const issue of valueDataset.issues) {
2708
- if (issue.path) issue.path.unshift(pathItem);
2709
- else issue.path = [pathItem];
2710
- dataset.issues?.push(issue);
2711
- }
2712
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2713
- if (config$1.abortEarly) {
2714
- dataset.typed = false;
2715
- break;
2716
- }
2717
- }
2718
- if (!valueDataset.typed) dataset.typed = false;
2719
- dataset.value[key] = valueDataset.value;
2720
- }
2721
- }
2722
- } else _addIssue(this, "type", dataset, config$1);
2723
- return dataset;
2724
- }
2725
- });
2726
- }
2727
- __name(objectWithRest, "objectWithRest");
2728
- // @__NO_SIDE_EFFECTS__
2729
- function optional(wrapped, default_) {
2730
- return _standardSchema({
2731
- kind: "schema",
2732
- type: "optional",
2733
- reference: optional,
2734
- expects: `(${wrapped.expects} | undefined)`,
2735
- async: false,
2736
- wrapped,
2737
- default: default_,
2738
- "~run"(dataset, config$1) {
2739
- if (dataset.value === void 0) {
2740
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
2741
- if (dataset.value === void 0) {
2742
- dataset.typed = true;
2743
- return dataset;
2744
- }
2745
- }
2746
- return this.wrapped["~run"](dataset, config$1);
2747
- }
2748
- });
2749
- }
2750
- __name(optional, "optional");
2751
- // @__NO_SIDE_EFFECTS__
2752
- function picklist(options, message$1) {
2753
- return _standardSchema({
2754
- kind: "schema",
2755
- type: "picklist",
2756
- reference: picklist,
2757
- expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
2758
- async: false,
2759
- options,
2760
- message: message$1,
2761
- "~run"(dataset, config$1) {
2762
- if (this.options.includes(dataset.value)) dataset.typed = true;
2763
- else _addIssue(this, "type", dataset, config$1);
2764
- return dataset;
2765
- }
2766
- });
2767
- }
2768
- __name(picklist, "picklist");
2769
- // @__NO_SIDE_EFFECTS__
2770
- function record(key, value$1, message$1) {
2771
- return _standardSchema({
2772
- kind: "schema",
2773
- type: "record",
2774
- reference: record,
2775
- expects: "Object",
2776
- async: false,
2777
- key,
2778
- value: value$1,
2779
- message: message$1,
2780
- "~run"(dataset, config$1) {
2781
- const input = dataset.value;
2782
- if (input && typeof input === "object") {
2783
- dataset.typed = true;
2784
- dataset.value = {};
2785
- for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
2786
- const entryValue = input[entryKey];
2787
- const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
2788
- if (keyDataset.issues) {
2789
- const pathItem = {
2790
- type: "object",
2791
- origin: "key",
2792
- input,
2793
- key: entryKey,
2794
- value: entryValue
2795
- };
2796
- for (const issue of keyDataset.issues) {
2797
- issue.path = [pathItem];
2798
- dataset.issues?.push(issue);
2799
- }
2800
- if (!dataset.issues) dataset.issues = keyDataset.issues;
2801
- if (config$1.abortEarly) {
2802
- dataset.typed = false;
2803
- break;
2804
- }
2805
- }
2806
- const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
2807
- if (valueDataset.issues) {
2808
- const pathItem = {
2809
- type: "object",
2810
- origin: "value",
2811
- input,
2812
- key: entryKey,
2813
- value: entryValue
2814
- };
2815
- for (const issue of valueDataset.issues) {
2816
- if (issue.path) issue.path.unshift(pathItem);
2817
- else issue.path = [pathItem];
2818
- dataset.issues?.push(issue);
2819
- }
2820
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2821
- if (config$1.abortEarly) {
2822
- dataset.typed = false;
2823
- break;
2824
- }
2825
- }
2826
- if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
2827
- if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
2828
- }
2829
- } else _addIssue(this, "type", dataset, config$1);
2830
- return dataset;
2831
- }
2832
- });
2833
- }
2834
- __name(record, "record");
2835
- // @__NO_SIDE_EFFECTS__
2836
- function strictObject(entries$1, message$1) {
2837
- return _standardSchema({
2838
- kind: "schema",
2839
- type: "strict_object",
2840
- reference: strictObject,
2841
- expects: "Object",
2842
- async: false,
2843
- entries: entries$1,
2844
- message: message$1,
2845
- "~run"(dataset, config$1) {
2846
- const input = dataset.value;
2847
- if (input && typeof input === "object") {
2848
- dataset.typed = true;
2849
- dataset.value = {};
2850
- for (const key in this.entries) {
2851
- const valueSchema = this.entries[key];
2852
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2853
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2854
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2855
- if (valueDataset.issues) {
2856
- const pathItem = {
2857
- type: "object",
2858
- origin: "value",
2859
- input,
2860
- key,
2861
- value: value$1
2862
- };
2863
- for (const issue of valueDataset.issues) {
2864
- if (issue.path) issue.path.unshift(pathItem);
2865
- else issue.path = [pathItem];
2866
- dataset.issues?.push(issue);
2867
- }
2868
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2869
- if (config$1.abortEarly) {
2870
- dataset.typed = false;
2871
- break;
2872
- }
2873
- }
2874
- if (!valueDataset.typed) dataset.typed = false;
2875
- dataset.value[key] = valueDataset.value;
2876
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2877
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2878
- _addIssue(this, "key", dataset, config$1, {
2879
- input: void 0,
2880
- expected: `"${key}"`,
2881
- path: [{
2882
- type: "object",
2883
- origin: "key",
2884
- input,
2885
- key,
2886
- value: input[key]
2887
- }]
2888
- });
2889
- if (config$1.abortEarly) break;
2890
- }
2891
- }
2892
- if (!dataset.issues || !config$1.abortEarly) {
2893
- for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
2894
- _addIssue(this, "key", dataset, config$1, {
2895
- input: key,
2896
- expected: "never",
2897
- path: [{
2898
- type: "object",
2899
- origin: "key",
2900
- input,
2901
- key,
2902
- value: input[key]
2903
- }]
2904
- });
2905
- break;
2906
- }
2907
- }
2908
- } else _addIssue(this, "type", dataset, config$1);
2909
- return dataset;
2910
- }
2911
- });
2912
- }
2913
- __name(strictObject, "strictObject");
2914
- // @__NO_SIDE_EFFECTS__
2915
- function string(message$1) {
2916
- return _standardSchema({
2917
- kind: "schema",
2918
- type: "string",
2919
- reference: string,
2920
- expects: "string",
2921
- async: false,
2922
- message: message$1,
2923
- "~run"(dataset, config$1) {
2924
- if (typeof dataset.value === "string") dataset.typed = true;
2925
- else _addIssue(this, "type", dataset, config$1);
2926
- return dataset;
2927
- }
2928
- });
2929
- }
2930
- __name(string, "string");
2931
- // @__NO_SIDE_EFFECTS__
2932
- function _subIssues(datasets) {
2933
- let issues;
2934
- if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
2935
- else issues = dataset.issues;
2936
- return issues;
2937
- }
2938
- __name(_subIssues, "_subIssues");
2939
- // @__NO_SIDE_EFFECTS__
2940
- function union(options, message$1) {
2941
- return _standardSchema({
2942
- kind: "schema",
2943
- type: "union",
2944
- reference: union,
2945
- expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
2946
- async: false,
2947
- options,
2948
- message: message$1,
2949
- "~run"(dataset, config$1) {
2950
- let validDataset;
2951
- let typedDatasets;
2952
- let untypedDatasets;
2953
- for (const schema of this.options) {
2954
- const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
2955
- if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
2956
- else typedDatasets = [optionDataset];
2957
- else {
2958
- validDataset = optionDataset;
2959
- break;
2960
- }
2961
- else if (untypedDatasets) untypedDatasets.push(optionDataset);
2962
- else untypedDatasets = [optionDataset];
2963
- }
2964
- if (validDataset) return validDataset;
2965
- if (typedDatasets) {
2966
- if (typedDatasets.length === 1) return typedDatasets[0];
2967
- _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
2968
- dataset.typed = true;
2969
- } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
2970
- else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
2971
- return dataset;
2972
- }
2973
- });
2974
- }
2975
- __name(union, "union");
2976
- // @__NO_SIDE_EFFECTS__
2977
- function unknown() {
2978
- return _standardSchema({
2979
- kind: "schema",
2980
- type: "unknown",
2981
- reference: unknown,
2982
- expects: "unknown",
2983
- async: false,
2984
- "~run"(dataset) {
2985
- dataset.typed = true;
2986
- return dataset;
2987
- }
2988
- });
2989
- }
2990
- __name(unknown, "unknown");
2991
- // @__NO_SIDE_EFFECTS__
2992
- function variant(key, options, message$1) {
2993
- return _standardSchema({
2994
- kind: "schema",
2995
- type: "variant",
2996
- reference: variant,
2997
- expects: "Object",
2998
- async: false,
2999
- key,
3000
- options,
3001
- message: message$1,
3002
- "~run"(dataset, config$1) {
3003
- const input = dataset.value;
3004
- if (input && typeof input === "object") {
3005
- let outputDataset;
3006
- let maxDiscriminatorPriority = 0;
3007
- let invalidDiscriminatorKey = this.key;
3008
- let expectedDiscriminators = [];
3009
- const parseOptions = /* @__PURE__ */ __name((variant$1, allKeys) => {
3010
- for (const schema of variant$1.options) {
3011
- if (schema.type === "variant") parseOptions(schema, new Set(allKeys).add(schema.key));
3012
- else {
3013
- let keysAreValid = true;
3014
- let currentPriority = 0;
3015
- for (const currentKey of allKeys) {
3016
- const discriminatorSchema = schema.entries[currentKey];
3017
- if (currentKey in input ? discriminatorSchema["~run"]({
3018
- typed: false,
3019
- value: input[currentKey]
3020
- }, ABORT_EARLY_CONFIG).issues : discriminatorSchema.type !== "exact_optional" && discriminatorSchema.type !== "optional" && discriminatorSchema.type !== "nullish") {
3021
- keysAreValid = false;
3022
- if (invalidDiscriminatorKey !== currentKey && (maxDiscriminatorPriority < currentPriority || maxDiscriminatorPriority === currentPriority && currentKey in input && !(invalidDiscriminatorKey in input))) {
3023
- maxDiscriminatorPriority = currentPriority;
3024
- invalidDiscriminatorKey = currentKey;
3025
- expectedDiscriminators = [];
3026
- }
3027
- if (invalidDiscriminatorKey === currentKey) expectedDiscriminators.push(schema.entries[currentKey].expects);
3028
- break;
3029
- }
3030
- currentPriority++;
3031
- }
3032
- if (keysAreValid) {
3033
- const optionDataset = schema["~run"]({ value: input }, config$1);
3034
- if (!outputDataset || !outputDataset.typed && optionDataset.typed) outputDataset = optionDataset;
3035
- }
3036
- }
3037
- if (outputDataset && !outputDataset.issues) break;
3038
- }
3039
- }, "parseOptions");
3040
- parseOptions(this, /* @__PURE__ */ new Set([this.key]));
3041
- if (outputDataset) return outputDataset;
3042
- _addIssue(this, "type", dataset, config$1, {
3043
- input: input[invalidDiscriminatorKey],
3044
- expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
3045
- path: [{
3046
- type: "object",
3047
- origin: "value",
3048
- input,
3049
- key: invalidDiscriminatorKey,
3050
- value: input[invalidDiscriminatorKey]
3051
- }]
3052
- });
3053
- } else _addIssue(this, "type", dataset, config$1);
3054
- return dataset;
3055
- }
3056
- });
3057
- }
3058
- __name(variant, "variant");
3059
- // @__NO_SIDE_EFFECTS__
3060
- function omit(schema, keys) {
3061
- const entries$1 = { ...schema.entries };
3062
- for (const key of keys) delete entries$1[key];
3063
- return _standardSchema({
3064
- ...schema,
3065
- entries: entries$1
3066
- });
3067
- }
3068
- __name(omit, "omit");
3069
- function parse(schema, input, config$1) {
3070
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
3071
- if (dataset.issues) throw new ValiError(dataset.issues);
3072
- return dataset.value;
3073
- }
3074
- __name(parse, "parse");
3075
- // @__NO_SIDE_EFFECTS__
3076
- function partial(schema, keys) {
3077
- const entries$1 = {};
3078
- for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
3079
- return _standardSchema({
3080
- ...schema,
3081
- entries: entries$1
3082
- });
3083
- }
3084
- __name(partial, "partial");
3085
- // @__NO_SIDE_EFFECTS__
3086
- function pick(schema, keys) {
3087
- const entries$1 = {};
3088
- for (const key of keys) entries$1[key] = schema.entries[key];
3089
- return _standardSchema({
3090
- ...schema,
3091
- entries: entries$1
3092
- });
3093
- }
3094
- __name(pick, "pick");
3095
- // @__NO_SIDE_EFFECTS__
3096
- function pipe(...pipe$1) {
3097
- return _standardSchema({
3098
- ...pipe$1[0],
3099
- pipe: pipe$1,
3100
- "~run"(dataset, config$1) {
3101
- for (const item of pipe$1) if (item.kind !== "metadata") {
3102
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
3103
- dataset.typed = false;
3104
- break;
3105
- }
3106
- if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
3107
- }
3108
- return dataset;
3109
- }
3110
- });
3111
- }
3112
- __name(pipe, "pipe");
3113
- // @__NO_SIDE_EFFECTS__
3114
- function safeParse(schema, input, config$1) {
3115
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
3116
- return {
3117
- typed: dataset.typed,
3118
- success: !dataset.issues,
3119
- output: dataset.value,
3120
- issues: dataset.issues
3121
- };
3122
- }
3123
- __name(safeParse, "safeParse");
3124
- // @__NO_SIDE_EFFECTS__
3125
- function summarize(issues) {
3126
- let summary = "";
3127
- for (const issue of issues) {
3128
- if (summary) summary += "\n";
3129
- summary += `\xD7 ${issue.message}`;
3130
- const dotPath = /* @__PURE__ */ getDotPath(issue);
3131
- if (dotPath) summary += `
3132
- \u2192 at ${dotPath}`;
3133
- }
3134
- return summary;
3135
- }
3136
- __name(summarize, "summarize");
3137
- // @__NO_SIDE_EFFECTS__
3138
- function unwrap(schema) {
3139
- return schema.wrapped;
3140
- }
3141
- __name(unwrap, "unwrap");
3142
-
3143
- // node_modules/.pnpm/@valibot+to-json-schema@1.8.0_valibot@1.5.0_typescript@7.0.2_/node_modules/@valibot/to-json-schema/dist/index.mjs
3144
- function addError(errors, message) {
3145
- if (errors) {
3146
- errors.push(message);
3147
- return errors;
3148
- }
3149
- return [message];
3150
- }
3151
- __name(addError, "addError");
3152
- var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
3153
- function escapeRegExp(string2) {
3154
- return string2.replace(ESCAPE_REGEX, "\\$&");
3155
- }
3156
- __name(escapeRegExp, "escapeRegExp");
3157
- function handleError(message, config) {
3158
- switch (config?.errorMode) {
3159
- case "ignore":
3160
- break;
3161
- case "warn":
3162
- console.warn(message);
3163
- break;
3164
- default:
3165
- throw new Error(message);
3166
- }
3167
- }
3168
- __name(handleError, "handleError");
3169
- function isJsonConstValue(value) {
3170
- return typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || typeof value === "string";
3171
- }
3172
- __name(isJsonConstValue, "isJsonConstValue");
3173
- function isJsonEnumValues(values) {
3174
- return values.every(isJsonConstValue);
3175
- }
3176
- __name(isJsonEnumValues, "isJsonEnumValues");
3177
- var ReferenceMap = class extends Map {
3178
- static {
3179
- __name(this, "ReferenceMap");
3180
- }
3181
- /**
3182
- * Creates an empty schema reference map.
3183
- */
3184
- constructor() {
3185
- super();
3186
- this.count = 0;
3187
- this.usedIds = /* @__PURE__ */ new Set();
3188
- }
3189
- /**
3190
- * Adds a schema reference and reserves its ID.
3191
- *
3192
- * @param schema The Valibot schema.
3193
- * @param referenceId The reference ID.
3194
- *
3195
- * @returns The reference map.
3196
- */
3197
- set(schema, referenceId) {
3198
- this.usedIds.add(referenceId);
3199
- return super.set(schema, referenceId);
3200
- }
3201
- /**
3202
- * Creates a reference ID that is not yet used.
3203
- *
3204
- * @param definitions The JSON Schema definitions.
3205
- *
3206
- * @returns The unused reference ID.
3207
- */
3208
- createId(definitions) {
3209
- while (this.usedIds.has(`${this.count}`) || `${this.count}` in definitions) this.count++;
3210
- return `${this.count++}`;
3211
- }
3212
- };
3213
- function getLowerBound(current, value) {
3214
- if (typeof current !== "number" || !Number.isFinite(current) || value > current) return value;
3215
- return current;
3216
- }
3217
- __name(getLowerBound, "getLowerBound");
3218
- function getUpperBound(current, value) {
3219
- if (typeof current !== "number" || !Number.isFinite(current) || value < current) return value;
3220
- return current;
3221
- }
3222
- __name(getUpperBound, "getUpperBound");
3223
- // @__NO_SIDE_EFFECTS__
3224
- function getNotRestriction(current, value) {
3225
- return current !== void 0 ? { anyOf: [current, value] } : value;
3226
- }
3227
- __name(getNotRestriction, "getNotRestriction");
3228
- function intersectEnum(jsonSchema, values) {
3229
- let enumValues = jsonSchema.enum ?? values;
3230
- if (jsonSchema.enum) {
3231
- const valueSet = new Set(values);
3232
- enumValues = enumValues.filter((value) => valueSet.has(value));
3233
- }
3234
- if (enumValues.length) jsonSchema.enum = [...new Set(enumValues)];
3235
- else {
3236
- delete jsonSchema.enum;
3237
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, {});
3238
- }
3239
- }
3240
- __name(intersectEnum, "intersectEnum");
3241
- function convertAction(jsonSchema, valibotAction, config) {
3242
- if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
3243
- let errors;
3244
- switch (valibotAction.type) {
3245
- case "base64":
3246
- jsonSchema.contentEncoding = "base64";
3247
- break;
3248
- case "bic":
3249
- case "cuid2":
3250
- case "decimal":
3251
- case "digits":
3252
- case "domain":
3253
- case "emoji":
3254
- case "hash":
3255
- case "hexadecimal":
3256
- case "hex_color":
3257
- case "isrc":
3258
- case "iso_time_second":
3259
- case "iso_week":
3260
- case "ksuid":
3261
- case "mac":
3262
- case "mac48":
3263
- case "mac64":
3264
- case "nanoid":
3265
- case "octal":
3266
- case "slug":
3267
- case "ulid":
3268
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3269
- else jsonSchema.pattern = valibotAction.requirement.source;
3270
- break;
3271
- case "description":
3272
- jsonSchema.description = valibotAction.description;
3273
- break;
3274
- case "email":
3275
- case "rfc_email":
3276
- jsonSchema.format = "email";
3277
- break;
3278
- case "ends_with":
3279
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3280
- else jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
3281
- break;
3282
- case "empty":
3283
- if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
3284
- else {
3285
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3286
- jsonSchema.maxLength = 0;
3287
- }
3288
- break;
3289
- case "entries":
3290
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3291
- errors = addError(errors, 'The requirement of the "entries" action must be a non-negative integer.');
3292
- break;
3293
- }
3294
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
3295
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
3296
- break;
3297
- case "examples":
3298
- if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples];
3299
- else jsonSchema.examples = valibotAction.examples;
3300
- break;
3301
- case "gt_value":
3302
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3303
- errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
3304
- break;
3305
- }
3306
- if (!Number.isFinite(valibotAction.requirement)) {
3307
- errors = addError(errors, 'The requirement of the "gt_value" action is not JSON compatible.');
3308
- break;
3309
- }
3310
- if (config?.target === "openapi-3.0") {
3311
- errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
3312
- break;
3313
- }
3314
- jsonSchema.exclusiveMinimum = getLowerBound(jsonSchema.exclusiveMinimum, valibotAction.requirement);
3315
- break;
3316
- case "includes":
3317
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3318
- else jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
3319
- break;
3320
- case "integer":
3321
- jsonSchema.type = "integer";
3322
- break;
3323
- case "ipv4":
3324
- jsonSchema.format = "ipv4";
3325
- break;
3326
- case "ipv6":
3327
- jsonSchema.format = "ipv6";
3328
- break;
3329
- case "iso_date":
3330
- jsonSchema.format = "date";
3331
- break;
3332
- case "iso_date_time":
3333
- case "iso_timestamp":
3334
- jsonSchema.format = "date-time";
3335
- break;
3336
- case "iso_time":
3337
- jsonSchema.format = "time";
3338
- break;
3339
- case "jws_compact":
3340
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3341
- else jsonSchema.pattern = valibotAction.requirement.source;
3342
- break;
3343
- case "length":
3344
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3345
- errors = addError(errors, 'The requirement of the "length" action must be a non-negative integer.');
3346
- break;
3347
- }
3348
- if (jsonSchema.type === "array") {
3349
- jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
3350
- jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
3351
- } else {
3352
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3353
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
3354
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
3355
- }
3356
- break;
3357
- case "lt_value":
3358
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3359
- errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
3360
- break;
3361
- }
3362
- if (!Number.isFinite(valibotAction.requirement)) {
3363
- errors = addError(errors, 'The requirement of the "lt_value" action is not JSON compatible.');
3364
- break;
3365
- }
3366
- if (config?.target === "openapi-3.0") {
3367
- errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
3368
- break;
3369
- }
3370
- jsonSchema.exclusiveMaximum = getUpperBound(jsonSchema.exclusiveMaximum, valibotAction.requirement);
3371
- break;
3372
- case "max_entries":
3373
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3374
- errors = addError(errors, 'The requirement of the "max_entries" action must be a non-negative integer.');
3375
- break;
3376
- }
3377
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
3378
- break;
3379
- case "max_length":
3380
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3381
- errors = addError(errors, 'The requirement of the "max_length" action must be a non-negative integer.');
3382
- break;
3383
- }
3384
- if (jsonSchema.type === "array") jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
3385
- else {
3386
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3387
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
3388
- }
3389
- break;
3390
- case "max_value":
3391
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3392
- errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
3393
- break;
3394
- }
3395
- if (!Number.isFinite(valibotAction.requirement)) {
3396
- errors = addError(errors, 'The requirement of the "max_value" action is not JSON compatible.');
3397
- break;
3398
- }
3399
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, valibotAction.requirement);
3400
- break;
3401
- case "metadata":
3402
- if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
3403
- if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
3404
- if (Array.isArray(valibotAction.metadata.examples)) if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples];
3405
- else jsonSchema.examples = valibotAction.metadata.examples;
3406
- for (const key of Object.keys(valibotAction.metadata)) if (key !== "title" && key !== "description" && key !== "examples" && key !== "__proto__") jsonSchema[key] = valibotAction.metadata[key];
3407
- break;
3408
- case "min_entries":
3409
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3410
- errors = addError(errors, 'The requirement of the "min_entries" action must be a non-negative integer.');
3411
- break;
3412
- }
3413
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
3414
- break;
3415
- case "min_length":
3416
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3417
- errors = addError(errors, 'The requirement of the "min_length" action must be a non-negative integer.');
3418
- break;
3419
- }
3420
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
3421
- else {
3422
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3423
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
3424
- }
3425
- break;
3426
- case "min_value":
3427
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3428
- errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
3429
- break;
3430
- }
3431
- if (!Number.isFinite(valibotAction.requirement)) {
3432
- errors = addError(errors, 'The requirement of the "min_value" action is not JSON compatible.');
3433
- break;
3434
- }
3435
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, valibotAction.requirement);
3436
- break;
3437
- case "multiple_of":
3438
- jsonSchema.multipleOf = valibotAction.requirement;
3439
- break;
3440
- case "non_empty":
3441
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, 1);
3442
- else {
3443
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3444
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, 1);
3445
- }
3446
- break;
3447
- case "not_value":
3448
- if (!isJsonConstValue(valibotAction.requirement)) {
3449
- errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
3450
- break;
3451
- }
3452
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, config?.target === "openapi-3.0" ? { enum: [valibotAction.requirement] } : { const: valibotAction.requirement });
3453
- break;
3454
- case "not_values":
3455
- if (!isJsonEnumValues(valibotAction.requirement)) {
3456
- errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
3457
- break;
3458
- }
3459
- if (valibotAction.requirement.length) jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, { enum: [...new Set(valibotAction.requirement)] });
3460
- break;
3461
- case "regex":
3462
- if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
3463
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3464
- else jsonSchema.pattern = valibotAction.requirement.source;
3465
- break;
3466
- case "safe_integer":
3467
- jsonSchema.type = "integer";
3468
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, Number.MIN_SAFE_INTEGER);
3469
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, Number.MAX_SAFE_INTEGER);
3470
- break;
3471
- case "starts_with":
3472
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3473
- else jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
3474
- break;
3475
- case "title":
3476
- jsonSchema.title = valibotAction.title;
3477
- break;
3478
- case "url":
3479
- jsonSchema.format = "uri";
3480
- break;
3481
- case "uuid":
3482
- jsonSchema.format = "uuid";
3483
- break;
3484
- case "value":
3485
- if (!isJsonConstValue(valibotAction.requirement)) {
3486
- errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
3487
- break;
3488
- }
3489
- if (config?.target === "openapi-3.0") intersectEnum(jsonSchema, [valibotAction.requirement]);
3490
- else if ("const" in jsonSchema && jsonSchema.const !== valibotAction.requirement) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with a different "const" restriction.`);
3491
- else jsonSchema.const = valibotAction.requirement;
3492
- break;
3493
- case "values":
3494
- if (!isJsonEnumValues(valibotAction.requirement)) {
3495
- errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
3496
- break;
3497
- }
3498
- intersectEnum(jsonSchema, valibotAction.requirement);
3499
- break;
3500
- default:
3501
- errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
3502
- }
3503
- if (config?.overrideAction) {
3504
- const actionOverride = config.overrideAction({
3505
- valibotAction,
3506
- jsonSchema,
3507
- errors
3508
- });
3509
- if (actionOverride) return { ...actionOverride };
3510
- }
3511
- if (errors) for (const message of errors) handleError(message, config);
3512
- return jsonSchema;
3513
- }
3514
- __name(convertAction, "convertAction");
3515
- function flattenPipe(pipe2) {
3516
- return pipe2.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
3517
- }
3518
- __name(flattenPipe, "flattenPipe");
3519
- function getDefinitionRef(referenceId) {
3520
- return `#/$defs/${referenceId.replaceAll("~", "~0").replaceAll("/", "~1")}`;
3521
- }
3522
- __name(getDefinitionRef, "getDefinitionRef");
3523
- function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
3524
- if (!skipRef) {
3525
- const referenceId = context.referenceMap.get(valibotSchema);
3526
- if (referenceId) {
3527
- jsonSchema.$ref = getDefinitionRef(referenceId);
3528
- if (config?.overrideRef) {
3529
- const refOverride = config.overrideRef({
3530
- ...context,
3531
- referenceId,
3532
- valibotSchema,
3533
- jsonSchema
3534
- });
3535
- if (refOverride) jsonSchema.$ref = refOverride;
3536
- }
3537
- return jsonSchema;
3538
- }
3539
- }
3540
- if ("pipe" in valibotSchema) {
3541
- const flatPipe = flattenPipe(valibotSchema.pipe);
3542
- let startIndex = 0;
3543
- let stopIndex = flatPipe.length - 1;
3544
- if (config?.typeMode === "input") {
3545
- const inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "to_bigint" || item.type === "to_boolean" || item.type === "to_date" || item.type === "to_number" || item.type === "to_string" || item.type === "transform"));
3546
- if (inputStopIndex !== -1) stopIndex = inputStopIndex;
3547
- } else if (config?.typeMode === "output") {
3548
- const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
3549
- if (outputStartIndex !== -1) startIndex = outputStartIndex;
3550
- }
3551
- for (let index = startIndex; index <= stopIndex; index++) {
3552
- const valibotPipeItem = flatPipe[index];
3553
- if (valibotPipeItem.kind === "schema") {
3554
- if (index > startIndex) handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config);
3555
- jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
3556
- } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
3557
- }
3558
- return jsonSchema;
3559
- }
3560
- let errors;
3561
- switch (valibotSchema.type) {
3562
- case "boolean":
3563
- jsonSchema.type = "boolean";
3564
- break;
3565
- case "null":
3566
- if (config?.target === "openapi-3.0") jsonSchema.enum = [null];
3567
- else jsonSchema.type = "null";
3568
- break;
3569
- case "number":
3570
- jsonSchema.type = "number";
3571
- break;
3572
- case "string":
3573
- jsonSchema.type = "string";
3574
- break;
3575
- case "array":
3576
- jsonSchema.type = "array";
3577
- jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
3578
- break;
3579
- case "tuple":
3580
- case "tuple_with_rest":
3581
- case "loose_tuple":
3582
- case "strict_tuple":
3583
- jsonSchema.type = "array";
3584
- if (config?.target === "openapi-3.0") {
3585
- jsonSchema.items = { anyOf: [] };
3586
- jsonSchema.minItems = valibotSchema.items.length;
3587
- for (const item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
3588
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context));
3589
- else if (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") jsonSchema.maxItems = valibotSchema.items.length;
3590
- } else if (config?.target === "draft-2020-12") {
3591
- jsonSchema.prefixItems = [];
3592
- jsonSchema.minItems = valibotSchema.items.length;
3593
- for (const item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
3594
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context);
3595
- else if (valibotSchema.type === "strict_tuple") jsonSchema.items = false;
3596
- } else {
3597
- jsonSchema.items = [];
3598
- jsonSchema.minItems = valibotSchema.items.length;
3599
- for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
3600
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
3601
- else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
3602
- }
3603
- break;
3604
- case "object":
3605
- case "object_with_rest":
3606
- case "loose_object":
3607
- case "strict_object":
3608
- jsonSchema.type = "object";
3609
- jsonSchema.properties = {};
3610
- jsonSchema.required = [];
3611
- for (const key in valibotSchema.entries) {
3612
- const entry2 = valibotSchema.entries[key];
3613
- jsonSchema.properties[key] = convertSchema({}, entry2, config, context);
3614
- if (entry2.type !== "exact_optional" && entry2.type !== "nullish" && entry2.type !== "optional") jsonSchema.required.push(key);
3615
- }
3616
- if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
3617
- else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
3618
- break;
3619
- case "record":
3620
- if (config?.target === "openapi-3.0" && "pipe" in valibotSchema.key) errors = addError(errors, 'The "record" schema with a schema for the key that contains a "pipe" cannot be converted to JSON Schema.');
3621
- if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
3622
- jsonSchema.type = "object";
3623
- if (config?.target !== "openapi-3.0") jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context);
3624
- jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
3625
- break;
3626
- case "any":
3627
- case "unknown":
3628
- break;
3629
- case "never":
3630
- jsonSchema.not = {};
3631
- break;
3632
- case "nullable":
3633
- case "nullish":
3634
- if (config?.target === "openapi-3.0") {
3635
- const innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
3636
- Object.assign(jsonSchema, innerSchema);
3637
- jsonSchema.nullable = true;
3638
- } else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
3639
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
3640
- break;
3641
- case "exact_optional":
3642
- case "optional":
3643
- case "undefinedable":
3644
- jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
3645
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
3646
- break;
3647
- case "literal":
3648
- if (!isJsonConstValue(valibotSchema.literal)) {
3649
- errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
3650
- break;
3651
- }
3652
- if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotSchema.literal];
3653
- else jsonSchema.const = valibotSchema.literal;
3654
- break;
3655
- case "enum":
3656
- case "picklist": {
3657
- const options = valibotSchema.options;
3658
- if (!options.every((option) => typeof option === "string" || typeof option === "number" && Number.isFinite(option))) {
3659
- errors = addError(errors, `An option of the "${valibotSchema.type}" schema is not JSON compatible.`);
3660
- break;
3661
- }
3662
- jsonSchema.enum = options;
3663
- if (options.every((option) => typeof option === "string")) jsonSchema.type = "string";
3664
- else if (options.every((option) => typeof option === "number")) jsonSchema.type = "number";
3665
- else if (config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
3666
- break;
3667
- }
3668
- case "union":
3669
- jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3670
- break;
3671
- case "variant":
3672
- jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3673
- break;
3674
- case "intersect":
3675
- jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3676
- break;
3677
- case "lazy": {
3678
- let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
3679
- if (!wrappedValibotSchema) {
3680
- wrappedValibotSchema = valibotSchema.getter(void 0);
3681
- context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
3682
- }
3683
- let referenceId = context.referenceMap.get(wrappedValibotSchema);
3684
- if (!referenceId) {
3685
- referenceId = context.referenceMap.createId(context.definitions);
3686
- context.referenceMap.set(wrappedValibotSchema, referenceId);
3687
- context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
3688
- }
3689
- jsonSchema.$ref = getDefinitionRef(referenceId);
3690
- if (config?.overrideRef) {
3691
- const refOverride = config.overrideRef({
3692
- ...context,
3693
- referenceId,
3694
- valibotSchema: wrappedValibotSchema,
3695
- jsonSchema
3696
- });
3697
- if (refOverride) jsonSchema.$ref = refOverride;
3698
- }
3699
- break;
3700
- }
3701
- default:
3702
- errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
3703
- }
3704
- if (config?.overrideSchema) {
3705
- const schemaOverride = config.overrideSchema({
3706
- ...context,
3707
- referenceId: context.referenceMap.get(valibotSchema),
3708
- valibotSchema,
3709
- jsonSchema,
3710
- errors
3711
- });
3712
- if (schemaOverride) return { ...schemaOverride };
3713
- }
3714
- if (errors) for (const message of errors) handleError(message, config);
3715
- return jsonSchema;
3716
- }
3717
- __name(convertSchema, "convertSchema");
3718
- var store;
3719
- function getGlobalDefs() {
3720
- return store;
3721
- }
3722
- __name(getGlobalDefs, "getGlobalDefs");
3723
- function toJsonSchema(schema, config) {
3724
- const context = {
3725
- definitions: {},
3726
- referenceMap: new ReferenceMap(),
3727
- getterMap: /* @__PURE__ */ new Map()
3728
- };
3729
- const definitions = config?.definitions ?? getGlobalDefs();
3730
- if (definitions) {
3731
- for (const key in definitions) context.referenceMap.set(definitions[key], key);
3732
- for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
3733
- }
3734
- const jsonSchema = convertSchema({}, schema, config, context);
3735
- const target = config?.target ?? "draft-07";
3736
- if (target === "draft-2020-12") jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema";
3737
- else if (target === "draft-07") jsonSchema.$schema = "http://json-schema.org/draft-07/schema#";
3738
- if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
3739
- return jsonSchema;
3740
- }
3741
- __name(toJsonSchema, "toJsonSchema");
3742
- var SUPPORTED_TARGETS = [
3743
- "draft-07",
3744
- "draft-2020-12",
3745
- "openapi-3.0"
3746
- ];
3747
- function toStandardJsonSchema(schema) {
3748
- return { "~standard": {
3749
- ...schema["~standard"],
3750
- jsonSchema: {
3751
- input(options) {
3752
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
3753
- typeMode: "input",
3754
- target: options.target,
3755
- ...options.libraryOptions
3756
- });
3757
- throw new Error(`Unsupported target: ${options.target}`);
3758
- },
3759
- output(options) {
3760
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
3761
- typeMode: "output",
3762
- target: options.target,
3763
- ...options.libraryOptions
3764
- });
3765
- throw new Error(`Unsupported target: ${options.target}`);
3766
- }
3767
- }
3768
- } };
3769
- }
3770
- __name(toStandardJsonSchema, "toStandardJsonSchema");
3771
-
3772
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/registry.js
3773
- var word = pipe(string(), regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "a lower-case word, words joined by -"));
3774
- var SNAKE_CASE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
3775
- var text = pipe(string(), regex(/\S/, "must not be empty"));
3776
- var dottedId = pipe(string(), regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/, "dotted lower-case words, such as `page.next`"));
3777
- var RegistryError = class extends Error {
3778
- static {
3779
- __name(this, "RegistryError");
3780
- }
3781
- registry;
3782
- problems;
3783
- constructor(registry, problems) {
3784
- super(`${registry} registry: ${problems.join("; ")}`);
3785
- this.registry = registry;
3786
- this.problems = problems;
3787
- this.name = "RegistryError";
3788
- }
3789
- };
3790
- var issuesOf = /* @__PURE__ */ __name((issues) => issues.map((issue) => {
3791
- const path = getDotPath(issue);
3792
- return path ? `${path}: ${issue.message}` : issue.message;
3793
- }), "issuesOf");
3794
- var parseRegistry = /* @__PURE__ */ __name((registry, schema, input, check2 = () => []) => {
3795
- const parsed = safeParse(schema, input);
3796
- if (!parsed.success)
3797
- throw new RegistryError(registry, issuesOf(parsed.issues));
3798
- const problems = check2(parsed.output);
3799
- if (problems.length > 0)
3800
- throw new RegistryError(registry, problems);
3801
- return parsed.output;
3802
- }, "parseRegistry");
3803
- var duplicates = /* @__PURE__ */ __name((values) => [...new Set(values.filter((value, index) => values.indexOf(value) !== index))].sort(), "duplicates");
3804
- var jsonSchemaOf = /* @__PURE__ */ __name((schema, definitions) => toJsonSchema(schema, { target: "draft-2020-12", ...definitions ? { definitions } : {} }), "jsonSchemaOf");
3805
- var PLACEHOLDER = /\{([a-z][a-z0-9]*(?:_[a-z0-9]+)*)\}/g;
3806
- var placeholders = /* @__PURE__ */ __name((template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1] ?? ""), "placeholders");
3807
- var fill = /* @__PURE__ */ __name((template, values) => template.replace(PLACEHOLDER, (_, name) => {
3808
- const value = values[name];
3809
- if (value === void 0)
3810
- throw new Error(`no value for {${name}} in "${template}"`);
3811
- return String(value);
3812
- }), "fill");
3813
-
3814
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/exit-codes.js
3815
- var EXIT_CODES = {
3816
- validation_error: 2,
3817
- configuration_error: 3,
3818
- authentication_error: 4,
3819
- permission_error: 5,
3820
- not_found: 6,
3821
- confirmation_required: 7,
3822
- rate_limited: 8,
3823
- timeout: 9,
3824
- network_error: 10,
3825
- provider_error: 11,
3826
- provider_unavailable: 12,
3827
- invalid_response: 13,
3828
- outcome_unknown: 14,
3829
- cancelled: 130
3830
- };
3831
- var exitCodeFor = /* @__PURE__ */ __name((code) => EXIT_CODES[code], "exitCodeFor");
3832
- var GENERIC_FAILURE = 1;
3833
-
3834
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/sanitize.js
3835
- var CONTROL = (
3836
- // biome-ignore lint/suspicious/noControlCharactersInRegex: matching them is the whole point
3837
- /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u200B\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF\u{E0000}-\u{E007F}]/gu
3838
- );
3839
- var SUBDIVISION_FLAG = /\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}/gu;
3840
- var LINE_BREAKS = /[\t\n\u2028\u2029]/g;
3841
- var escaped = /* @__PURE__ */ __name((c) => {
3842
- const code = c.codePointAt(0) ?? 0;
3843
- if (code > 65535)
3844
- return `\\u{${code.toString(16)}}`;
3845
- return code > 255 ? `\\u${code.toString(16).padStart(4, "0")}` : `\\x${code.toString(16).padStart(2, "0")}`;
3846
- }, "escaped");
3847
- var visibleControls = /* @__PURE__ */ __name((text2) => {
3848
- let at = 0;
3849
- let result = "";
3850
- for (const flag of text2.matchAll(SUBDIVISION_FLAG)) {
3851
- result += text2.slice(at, flag.index).replace(CONTROL, escaped) + flag[0];
3852
- at = flag.index + flag[0].length;
3853
- }
3854
- return result + text2.slice(at).replace(CONTROL, escaped);
3855
- }, "visibleControls");
3856
- var singleLine = /* @__PURE__ */ __name((text2) => visibleControls(text2).replace(LINE_BREAKS, escaped), "singleLine");
3857
-
3858
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/effects.js
3859
- var EFFECT_LEVELS = ["none", "read", "write"];
3860
- var effectsSchema = strictObject({
3861
- remote: picklist(EFFECT_LEVELS),
3862
- local: picklist(EFFECT_LEVELS)
3863
- });
3864
- var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
3865
-
3866
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/output.js
3867
- var MAX_NEXT_STEPS = 2;
3868
- var COMPACT_FLAG = "--compact";
3869
- var isoTime = pipe(string(), isoTimestamp("an ISO 8601 time in UTC"), endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"));
3870
- var localTime = pipe(string(), regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2}$/, "an ISO 8601 time with its offset"));
3871
- var reference = pipe(string(), regex(/^[a-z]+:\S+$/, "a reference such as `note:42`"));
3872
- var nextStepSchema = variant("kind", [
3873
- strictObject({
3874
- kind: literal("command"),
3875
- step: dottedId,
3876
- /** The command path as one string, `messages list` — what the MCP router tools take as `command`. */
3877
- command: text,
3878
- args: record(string(), unknown()),
3879
- /**
3880
- * The whole line to type, with the tool and the profile it ran with: `tg personal mcp config`. Only the CLI
3881
- * knows the profile, so it fills this; MCP answers leave it out.
3882
- */
3883
- line: optional(text),
3884
- why: text,
3885
- /** True only when the target command is known to write nothing, here or at the provider. */
3886
- safe_to_auto_execute: boolean()
3887
- }),
3888
- /** Something only the person can do — sign in on the phone, approve a device. */
3889
- strictObject({
3890
- kind: literal("user_action"),
3891
- step: dottedId,
3892
- why: text,
3893
- safe_to_auto_execute: literal(false)
3894
- })
3895
- ]);
3896
- var missingSchema = strictObject({
3897
- field: text,
3898
- why: text,
3899
- /** Left out when there is nothing to run that would fill the field. */
3900
- step: optional(dottedId)
3901
- });
3902
- var limit = pipe(number(), integer(), minValue(1));
3903
- var totalSchema = strictObject({
3904
- value: pipe(number(), integer(), minValue(0)),
3905
- relation: picklist(["eq", "gte"])
3906
- });
3907
- var pageSchema = variant("mode", [
3908
- strictObject({
3909
- mode: literal("page"),
3910
- limit,
3911
- has_more: boolean(),
3912
- next_page: optional(pipe(number(), integer(), minValue(2))),
3913
- total: optional(totalSchema)
3914
- }),
3915
- strictObject({
3916
- mode: literal("cursor"),
3917
- limit,
3918
- has_more: boolean(),
3919
- next_cursor: optional(text),
3920
- total: optional(totalSchema)
3921
- })
3922
- ]);
3923
- var issueSchema = strictObject({
3924
- code: picklist(errorCodes),
3925
- reason: optional(dottedId),
3926
- /** The account, provider or source that is missing from the answer. */
3927
- source: text
3928
- });
3929
- var metaSchema = strictObject({
3930
- run_id: text,
3931
- duration_ms: pipe(number(), integer(), minValue(0)),
3932
- accounts: optional(array(text)),
3933
- complete: boolean(),
3934
- issues: optional(array(issueSchema)),
3935
- truncated: optional(boolean()),
3936
- timezone: optional(text),
3937
- /** When the command answered, for an agent that plans from "now" (WC-TIME-7); `timezone` names the zone of `now_local`. */
3938
- now: optional(isoTime),
3939
- now_local: optional(localTime),
3940
- window: optional(strictObject({ since: optional(isoTime), until: optional(isoTime) }))
3941
- });
3942
- var nextSteps = optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS)));
3943
- var listEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
3944
- items: array(item),
3945
- page: pageSchema,
3946
- next: nextSteps,
3947
- missing: optional(array(missingSchema)),
3948
- meta: metaSchema
3949
- }), "listEnvelopeSchema");
3950
- var itemEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
3951
- item,
3952
- next: nextSteps,
3953
- missing: optional(array(missingSchema)),
3954
- meta: metaSchema
3955
- }), "itemEnvelopeSchema");
3956
- var jsonlEndSchema = strictObject({
3957
- type: literal("end"),
3958
- complete: boolean(),
3959
- issues: optional(array(issueSchema)),
3960
- page: pageSchema
3961
- });
3962
- var jsonlOf = /* @__PURE__ */ __name(({ items, page, meta }) => [
3963
- ...items.map((data) => JSON.stringify({ type: "item", data })),
3964
- JSON.stringify({ type: "end", complete: meta.complete, ...meta.issues ? { issues: meta.issues } : {}, page })
3965
- ].join("\n"), "jsonlOf");
3966
-
3967
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/errors.js
3968
- var CRASH_CODE = "internal_error";
3969
- var CRASH_REASON = "command.crashed";
3970
- var errorObjectSchema = strictObject({
3971
- error: strictObject({
3972
- code: picklist([...errorCodes, CRASH_CODE]),
3973
- reason: dottedId,
3974
- message: text,
3975
- /** The option or argument at fault. */
3976
- param: optional(text),
3977
- details: optional(record(string(), unknown())),
3978
- next: optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS))),
3979
- /** Whether running the same command again may work and cannot do harm; never for a write that may have landed. */
3980
- retry: strictObject({
3981
- safe: boolean(),
3982
- after_ms: optional(pipe(number(), integer(), minValue(0)))
3983
- }),
3984
- /** Optional until every CLI keeps a run for each failure. */
3985
- run_id: optional(text)
3986
- })
3987
- });
3988
- var reasonSchema = strictObject({
3989
- reason: dottedId,
3990
- code: picklist([...errorCodes, CRASH_CODE]),
3991
- /** `{name}` placeholders, each one of `details`. */
3992
- message: pipe(text, maxLength(120)),
3993
- details: array(pipe(string(), regex(SNAKE_CASE, "a snake_case key"))),
3994
- step: optional(dottedId)
3995
- });
3996
- var defineReasons = /* @__PURE__ */ __name((input) => parseRegistry("error reasons", array(reasonSchema), input, (reasons) => [
3997
- ...duplicates(reasons.map((entry2) => entry2.reason)).map((reason) => `"${reason}" is listed twice`),
3998
- ...reasons.flatMap((entry2) => placeholders(entry2.message).filter((name) => !entry2.details.includes(name)).map((name) => `${entry2.reason}: the message names {${name}}, which is not one of its details`))
3999
- ]), "defineReasons");
4000
- var COMMON_DETAILS = ["attempts", "status", "request_id", "operation", "operation_id"];
4001
- var BASE_REASONS = defineReasons([
4002
- { reason: "input.invalid", code: "validation_error", message: "the input is not valid", details: [] },
4003
- {
4004
- reason: "batch.read-budget",
4005
- code: "validation_error",
4006
- message: "batch stored-text read budget exhausted",
4007
- details: []
4008
- },
4009
- { reason: "batch.output-budget", code: "validation_error", message: "batch output budget exhausted", details: [] },
4010
- { reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
4011
- { reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
4012
- { reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
4013
- { reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
4014
- {
4015
- reason: "tool.not-installed",
4016
- code: "not_found",
4017
- message: "no wcat-<name> program by that name is on PATH",
4018
- details: ["tool", "installed"]
4019
- },
4020
- {
4021
- reason: "confirmation.required",
4022
- code: "confirmation_required",
4023
- message: "this changes something; confirm it",
4024
- details: []
4025
- },
4026
- { reason: "provider.rate-limited", code: "rate_limited", message: "too many requests; wait", details: [] },
4027
- { reason: "command.timed-out", code: "timeout", message: "the command took too long", details: ["timeout_ms"] },
4028
- { reason: "network.failed", code: "network_error", message: "the network did not answer", details: [] },
4029
- { reason: "provider.refused", code: "provider_error", message: "the provider refused", details: [] },
4030
- { reason: "provider.unavailable", code: "provider_unavailable", message: "the provider is down", details: [] },
4031
- {
4032
- reason: "provider.invalid-response",
4033
- code: "invalid_response",
4034
- message: "the answer could not be read",
4035
- details: []
4036
- },
4037
- {
4038
- reason: "output.too-large",
4039
- code: "invalid_response",
4040
- message: "the output is over {max_bytes} bytes",
4041
- details: ["max_bytes", "buffered_bytes", "partial_output"]
4042
- },
4043
- {
4044
- reason: "output.fields-unavailable",
4045
- code: "invalid_response",
4046
- message: "fields can be picked only from whole JSON values",
4047
- details: []
4048
- },
4049
- { reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
4050
- { reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
4051
- { reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] }
4052
- ]);
4053
-
4054
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/steps.js
4055
- var SAME_COMMAND = "*";
4056
- var commandPath = pipe(string(), regex(/^[a-z][a-z0-9-]*( [a-z][a-z0-9-]*)*$/, "a command path such as `messages sync`"));
4057
- var stepSchema = union([
4058
- strictObject({
4059
- id: dottedId,
4060
- kind: optional(literal("command"), "command"),
4061
- command: union([literal(SAME_COMMAND), commandPath]),
4062
- args: array(strictObject({
4063
- name: pipe(string(), regex(SNAKE_CASE, "an argument or option name in snake_case")),
4064
- required: boolean()
4065
- })),
4066
- why: pipe(text, maxLength(120))
4067
- }),
4068
- strictObject({ id: dottedId, kind: literal("user_action"), why: pipe(text, maxLength(120)) })
4069
- ]);
4070
- var argsOf = /* @__PURE__ */ __name((step) => step.kind === "command" ? step.args : [], "argsOf");
4071
- var defineSteps = /* @__PURE__ */ __name((input) => parseRegistry("steps", array(stepSchema), input, (steps) => [
4072
- ...duplicates(steps.map((step) => step.id)).map((id) => `"${id}" is listed twice`),
4073
- ...steps.flatMap((step) => duplicates(argsOf(step).map((arg) => arg.name)).map((name) => `${step.id}: argument "${name}" is listed twice`))
4074
- ]), "defineSteps");
4075
- var BINDS = /^[^\p{Cc}\u2028\u2029]*$/u;
4076
- var binds = /* @__PURE__ */ __name((value) => typeof value === "number" || typeof value === "boolean" || typeof value === "string" && BINDS.test(value), "binds");
4077
- var stepOf = /* @__PURE__ */ __name((definition, input = {}) => {
4078
- const args = input.args ?? {};
4079
- if (definition.kind === "user_action")
4080
- return {
4081
- kind: "user_action",
4082
- step: definition.id,
4083
- why: fill(definition.why, { ...input.values }),
4084
- safe_to_auto_execute: false
4085
- };
4086
- const command = definition.command === SAME_COMMAND ? input.command : definition.command;
4087
- if (!command)
4088
- throw new Error(`${definition.id}: the step runs the same command, so pass the command`);
4089
- const known = new Set(definition.args.map((arg) => arg.name));
4090
- if (definition.command !== SAME_COMMAND) {
4091
- for (const name of Object.keys(args))
4092
- if (!known.has(name))
4093
- throw new Error(`${definition.id}: no argument "${name}"`);
4094
- }
4095
- for (const arg of definition.args)
4096
- if (arg.required && args[arg.name] === void 0)
4097
- throw new Error(`${definition.id}: argument "${arg.name}" is required`);
4098
- for (const [name, value] of Object.entries(args))
4099
- if (!(Array.isArray(value) ? value.every(binds) : binds(value)))
4100
- throw new Error(`${definition.id}: "${name}" is not a value an option takes`);
4101
- const target = input.targets?.(command);
4102
- if (input.targets && !target)
4103
- throw new Error(`${definition.id}: no command "${command}"`);
4104
- const names = new Set(target?.names ?? []);
4105
- if (target) {
4106
- for (const name of Object.keys(args))
4107
- if (!names.has(name))
4108
- throw new Error(`${definition.id}: "${command}" takes no "${name}"`);
4109
- }
4110
- const scalars = Object.fromEntries(Object.entries(args).filter((entry2) => ["string", "number"].includes(typeof entry2[1])));
4111
- return {
4112
- kind: "command",
4113
- step: definition.id,
4114
- command,
4115
- args: { ...args },
4116
- why: fill(definition.why, { ...scalars, ...input.values }),
4117
- safe_to_auto_execute: target?.effects !== void 0 && !writes(target.effects)
4118
- };
4119
- }, "stepOf");
4120
- var STEPS = defineSteps([
4121
- {
4122
- id: "page.next",
4123
- command: SAME_COMMAND,
4124
- args: [
4125
- { name: "cursor", required: false },
4126
- { name: "page", required: false },
4127
- { name: "limit", required: false }
4128
- ],
4129
- why: "{shown} shown, more exist"
4130
- }
4131
- ]);
4132
-
4133
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/failure.js
4134
- var recognise = /* @__PURE__ */ __name((failure) => {
4135
- if (isCliError(failure))
4136
- return failure;
4137
- if (!(failure instanceof Error) || failure.name !== "CliError")
4138
- return void 0;
4139
- const { code, details } = failure;
4140
- if (!errorCodes.includes(code))
4141
- return void 0;
4142
- return {
4143
- code,
4144
- message: failure.message,
4145
- details: typeof details === "object" && details !== null ? details : {}
4146
- };
4147
- }, "recognise");
4148
- var reasonFor = /* @__PURE__ */ __name((code, named, reasons) => reasons.find((entry2) => entry2.reason === named && entry2.code === code) ?? BASE_REASONS.find((entry2) => entry2.reason === named && entry2.code === code) ?? // The first base reason for each code is its fallback.
4149
- BASE_REASONS.find((entry2) => entry2.code === code), "reasonFor");
4150
- var nextFor = /* @__PURE__ */ __name((reason, details, context) => {
4151
- const definition = reason.step ? context.steps?.find((step) => step.id === reason.step) : void 0;
4152
- if (!definition)
4153
- return [];
4154
- const known = new Set(definition.kind === "command" ? definition.args.map((arg) => arg.name) : []);
4155
- const args = Object.fromEntries(Object.entries(details).filter(([key, value]) => known.has(key) && value !== void 0));
4156
- try {
4157
- return [stepOf(definition, { args, ...context.targets ? { targets: context.targets } : {} })];
4158
- } catch {
4159
- return [];
4160
- }
4161
- }, "nextFor");
4162
- var TRANSIENT = [
4163
- "rate_limited",
4164
- "timeout",
4165
- "network_error",
4166
- "provider_unavailable"
4167
- ];
4168
- var retryOf = /* @__PURE__ */ __name((code, details, effects) => {
4169
- const transient = details.retryable !== false && (TRANSIENT.includes(code) || code === "provider_error" && details.retryable === true);
4170
- const safe = code !== "outcome_unknown" && transient && (!writes(effects) || details.sent === false);
4171
- const after = details.retry_after_ms;
4172
- return safe && typeof after === "number" && Number.isInteger(after) && after >= 0 ? { safe, after_ms: after } : { safe };
4173
- }, "retryOf");
4174
- var errorObjectOf = /* @__PURE__ */ __name((failure, context = {}) => {
4175
- const reasons = context.reasons ?? [];
4176
- const recognised = recognise(failure);
4177
- if (!recognised) {
4178
- const reason2 = reasonFor(CRASH_CODE, CRASH_REASON, reasons);
4179
- return {
4180
- error: {
4181
- code: CRASH_CODE,
4182
- reason: reason2.reason,
4183
- message: reason2.message,
4184
- retry: { safe: false },
4185
- ...context.runId ? { run_id: context.runId } : {}
4186
- }
4187
- };
4188
- }
4189
- const { code, message, details } = recognised;
4190
- const reason = reasonFor(code, details.reason, reasons);
4191
- const allowed = /* @__PURE__ */ new Set([...COMMON_DETAILS, ...context.details ?? [], ...reason.details]);
4192
- allowed.delete("cause");
4193
- const kept = Object.fromEntries(Object.entries(details).filter(([key, value]) => allowed.has(key) && value !== void 0));
4194
- const next = nextFor(reason, details, context);
4195
- const runId = context.runId ?? (typeof details.run_id === "string" ? details.run_id : void 0);
4196
- return {
4197
- error: {
4198
- code,
4199
- reason: reason.reason,
4200
- message,
4201
- ...typeof details.param === "string" ? { param: details.param } : {},
4202
- ...Object.keys(kept).length > 0 ? { details: kept } : {},
4203
- ...next.length > 0 ? { next } : {},
4204
- retry: retryOf(code, details, context.effects),
4205
- ...runId ? { run_id: runId } : {}
4206
- }
4207
- };
4208
- }, "errorObjectOf");
4209
- var exitCodeOfError = /* @__PURE__ */ __name(({ error }) => error.code === CRASH_CODE ? GENERIC_FAILURE : EXIT_CODES[error.code], "exitCodeOfError");
4210
- var exitCodeOfAnswer = /* @__PURE__ */ __name((meta, partial2 = false) => {
4211
- if (meta.complete || partial2)
4212
- return 0;
4213
- const code = meta.issues?.[0]?.code;
4214
- return code === void 0 ? GENERIC_FAILURE : EXIT_CODES[code];
4215
- }, "exitCodeOfAnswer");
4216
- var kebab = /* @__PURE__ */ __name((name) => name.replaceAll("_", "-"), "kebab");
4217
- var commandLine = /* @__PURE__ */ __name((cli, step) => [
4218
- cli,
4219
- step.command,
4220
- ...Object.entries(step.args).map(([name, value]) => value === true ? `--${kebab(name)}` : `--${kebab(name)} ${JSON.stringify(value)}`)
4221
- ].join(" "), "commandLine");
4222
- var STACK_FRAMES = 10;
4223
- var errorRecordOf = /* @__PURE__ */ __name((failure, object3, options) => {
4224
- const thrown = failure instanceof Error ? failure : void 0;
4225
- const { cause, ...details } = recognise(failure)?.details ?? {};
4226
- const stack = thrown?.stack?.split("\n").slice(1, STACK_FRAMES + 1).map((line) => visibleControls(line.trim()));
4227
- const reason = thrown?.cause ?? cause;
4228
- return {
4229
- time: (options.time ?? /* @__PURE__ */ new Date()).toISOString(),
4230
- severity: "error",
4231
- body: "command.failed",
4232
- ...object3.error.run_id ? { run_id: object3.error.run_id } : {},
4233
- command: options.command,
4234
- attributes: {
4235
- code: object3.error.code,
4236
- reason: object3.error.reason,
4237
- message: object3.error.message,
4238
- ...Object.keys(details).length > 0 ? { details } : {},
4239
- ...thrown ? { name: thrown.name, thrown_message: visibleControls(thrown.message) } : { thrown: String(failure) },
4240
- ...reason === void 0 ? {} : { cause: visibleControls(reason instanceof Error ? reason.message : String(reason)) },
4241
- ...stack && stack.length > 0 ? { stack } : {}
4242
- },
4243
- resource: { service: options.service, version: options.version }
4244
- };
4245
- }, "errorRecordOf");
4246
- var renderError = /* @__PURE__ */ __name((object3, options) => {
4247
- if (!options.interactive)
4248
- return [JSON.stringify(object3), ...options.record ? [JSON.stringify(options.record)] : []].join("\n");
4249
- const { message, next, run_id: runId } = object3.error;
4250
- const step = next?.[0];
4251
- return [
4252
- `\u2717 ${visibleControls(message)}`,
4253
- ...step?.kind === "command" ? [`\u2192 ${visibleControls(step.why)}: ${visibleControls(step.line ?? commandLine(options.cli, step))}`] : step ? [`\u2192 ${visibleControls(step.why)}`] : [],
4254
- ...options.record ? [JSON.stringify(options.record, null, 2)] : runId ? [`details: ${options.cli} runs show ${runId}`] : []
4255
- ].join("\n");
4256
- }, "renderError");
4257
- var mcpErrorResult = /* @__PURE__ */ __name((object3) => ({
4258
- content: [{ type: "text", text: JSON.stringify(object3) }],
4259
- structuredContent: object3,
4260
- isError: true
4261
- }), "mcpErrorResult");
4262
- var catchCrashes = /* @__PURE__ */ __name((options) => {
4263
- const target = options.target ?? process;
4264
- const write = options.write ?? ((text2) => process.stderr.write(`${text2}
4265
- `));
4266
- const exit = options.exit ?? ((code) => process.exit(code));
4267
- const crashed = /* @__PURE__ */ __name((failure) => {
4268
- const object3 = errorObjectOf(failure, options);
4269
- write(renderError(object3, { cli: options.cli, interactive: options.interactive }));
4270
- exit(exitCodeOfError(object3));
4271
- }, "crashed");
4272
- target.on("uncaughtException", crashed);
4273
- target.on("unhandledRejection", crashed);
4274
- return () => {
4275
- target.off("uncaughtException", crashed);
4276
- target.off("unhandledRejection", crashed);
4277
- };
4278
- }, "catchCrashes");
4279
-
4280
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/result-fields.js
1902
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/result-fields.js
4281
1903
  var forbidden = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
4282
1904
  var validate = /* @__PURE__ */ __name((paths) => {
4283
1905
  if (paths.length === 0 || paths.length > 128 || paths.some((path) => path.length > 256 || !/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/.test(path) || path.split(".").some((part) => forbidden.has(part))))
@@ -4342,7 +1964,7 @@ var projectFields = /* @__PURE__ */ __name((value, fields) => {
4342
1964
  return project(value, fields);
4343
1965
  }, "projectFields");
4344
1966
 
4345
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/batch.js
1967
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/batch.js
4346
1968
  var BATCH_LIMITS = Object.freeze({
4347
1969
  requests: 32,
4348
1970
  input_bytes: 262144,
@@ -4354,7 +1976,7 @@ function invalid(message) {
4354
1976
  throw new CliError("validation_error", message);
4355
1977
  }
4356
1978
  __name(invalid, "invalid");
4357
- var limit2 = /* @__PURE__ */ __name((value, maximum, name) => {
1979
+ var limit = /* @__PURE__ */ __name((value, maximum, name) => {
4358
1980
  if (!Number.isSafeInteger(value) || value < 1 || value > maximum)
4359
1981
  invalid(`invalid batch ${name} limit`);
4360
1982
  return value;
@@ -4378,13 +2000,13 @@ var prepareBatch = /* @__PURE__ */ __name((input, handlers) => {
4378
2000
  invalid("batch takes 1\u201332 requests");
4379
2001
  const ids = /* @__PURE__ */ new Set();
4380
2002
  return requests.map((request) => {
4381
- if (!record2(request) || Object.keys(request).some((key) => !["id", "command", "args"].includes(key)) || typeof request.id !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/.test(request.id) || ids.has(request.id) || !Array.isArray(request.command) || request.command.length < 1 || request.command.length > 8 || request.command.some((word2) => typeof word2 !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(word2)) || !Array.isArray(request.args) || request.args.length > 128 || request.args.some((arg) => typeof arg !== "string" || arg.includes("\0")))
2003
+ if (!record2(request) || Object.keys(request).some((key) => !["id", "command", "args"].includes(key)) || typeof request.id !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/.test(request.id) || ids.has(request.id) || !Array.isArray(request.command) || request.command.length < 1 || request.command.length > 8 || request.command.some((word) => typeof word !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(word)) || !Array.isArray(request.args) || request.args.length > 128 || request.args.some((arg) => typeof arg !== "string" || arg.includes("\0")))
4382
2004
  invalid("each batch request needs a unique id, registered command path and string args array");
4383
2005
  const id = request.id;
4384
2006
  const command = [...request.command];
4385
2007
  const args = request.args;
4386
2008
  ids.add(id);
4387
- const handler = handlers.find((entry2) => entry2.command.length === command.length && entry2.command.every((word2, i) => word2 === command[i]));
2009
+ const handler = handlers.find((entry2) => entry2.command.length === command.length && entry2.command.every((word, i) => word === command[i]));
4388
2010
  if (!handler)
4389
2011
  invalid(`unsupported batch command: ${command.join(" ")}`);
4390
2012
  return { id, command, operation: handler.prepare(args) };
@@ -4415,8 +2037,8 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4415
2037
  invalid("batch takes 1\u201332 requests");
4416
2038
  if (options.fields)
4417
2039
  projectFields({}, options.fields);
4418
- const maxReadBytes = limit2(options.maxReadBytes ?? BATCH_LIMITS.read_bytes, BATCH_LIMITS.read_bytes, "read");
4419
- const maxOutputBytes = limit2(options.maxOutputBytes ?? BATCH_LIMITS.output_bytes, BATCH_LIMITS.output_bytes, "output");
2040
+ const maxReadBytes = limit(options.maxReadBytes ?? BATCH_LIMITS.read_bytes, BATCH_LIMITS.read_bytes, "read");
2041
+ const maxOutputBytes = limit(options.maxOutputBytes ?? BATCH_LIMITS.output_bytes, BATCH_LIMITS.output_bytes, "output");
4420
2042
  if (maxOutputBytes < 8192 + requests.length * 2048)
4421
2043
  invalid("batch output budget cannot hold its result framing");
4422
2044
  const errorOf = /* @__PURE__ */ __name((error) => {
@@ -4439,7 +2061,7 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4439
2061
  const context = {
4440
2062
  signal: options.signal,
4441
2063
  reserveReadBytes(bytes) {
4442
- limit2(bytes, BATCH_LIMITS.read_bytes, "operation read");
2064
+ limit(bytes, BATCH_LIMITS.read_bytes, "operation read");
4443
2065
  if (bytes > maxReadBytes - reserved)
4444
2066
  throw budgetError("read");
4445
2067
  reserved += bytes;
@@ -4489,7 +2111,7 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4489
2111
  };
4490
2112
  }, "runBatch");
4491
2113
 
4492
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/config.js
2114
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/config.js
4493
2115
  import { randomBytes } from "node:crypto";
4494
2116
  import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
4495
2117
  import { dirname, join } from "node:path";
@@ -4533,7 +2155,7 @@ var saveConfigFile = /* @__PURE__ */ __name((path, config) => {
4533
2155
  `, 384);
4534
2156
  }, "saveConfigFile");
4535
2157
 
4536
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/keyring.js
2158
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/keyring.js
4537
2159
  import { createRequire } from "node:module";
4538
2160
  var ENTRY_OPTIONS = { linux: { store: "secret-service" } };
4539
2161
  var require2 = createRequire(new URL("keyring.js", import.meta.resolve("@wirecat/cli-base")).href);
@@ -4553,7 +2175,7 @@ var systemKeyring = {
4553
2175
  delete: /* @__PURE__ */ __name((service, account) => entry(service, account).deletePassword(), "delete")
4554
2176
  };
4555
2177
 
4556
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/paths.js
2178
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/paths.js
4557
2179
  import { homedir, userInfo } from "node:os";
4558
2180
  import { join as join2, posix, win32 } from "node:path";
4559
2181
  var PATH_KINDS = ["config", "state", "cache"];
@@ -4605,7 +2227,7 @@ var homeIsMoved = /* @__PURE__ */ __name(({ env = process.env, platform = proces
4605
2227
  var isMovedRun = /* @__PURE__ */ __name((options) => pathsAreOverridden(options) || homeIsMoved(options), "isMovedRun");
4606
2228
  var configFilePath = /* @__PURE__ */ __name((configDir, fileName = "config.json") => join2(configDir, fileName), "configFilePath");
4607
2229
 
4608
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/credentials.js
2230
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/credentials.js
4609
2231
  import { readFileSync as readFileSync2 } from "node:fs";
4610
2232
  import { join as join3, resolve } from "node:path";
4611
2233
  var movedRunService = /* @__PURE__ */ __name((service, configDir) => `${service}:${resolve(configDir)}`, "movedRunService");
@@ -4665,12 +2287,12 @@ var Credentials = class {
4665
2287
  return "keyring";
4666
2288
  }
4667
2289
  }
4668
- const store2 = this.#readFile();
4669
- if (!store2) {
2290
+ const store = this.#readFile();
2291
+ if (!store) {
4670
2292
  throw new CliError("configuration_error", `${this.#path()} cannot be read as a credentials file; storing now would replace every secret in it. Fix the file or move it aside, then try again.`);
4671
2293
  }
4672
- store2[account] = { secret };
4673
- this.#writeFile(store2);
2294
+ store[account] = { secret };
2295
+ this.#writeFile(store);
4674
2296
  return "file";
4675
2297
  }
4676
2298
  remove(account) {
@@ -4688,11 +2310,11 @@ var Credentials = class {
4688
2310
  return removed;
4689
2311
  }
4690
2312
  #removeFromFile(account) {
4691
- const store2 = this.#readFile();
4692
- if (store2?.[account] === void 0)
2313
+ const store = this.#readFile();
2314
+ if (store?.[account] === void 0)
4693
2315
  return false;
4694
- delete store2[account];
4695
- this.#writeFile(store2);
2316
+ delete store[account];
2317
+ this.#writeFile(store);
4696
2318
  return true;
4697
2319
  }
4698
2320
  /** Only for the warning: a keyring that fails here must not fail a removal that already happened. */
@@ -4723,8 +2345,8 @@ var Credentials = class {
4723
2345
  return void 0;
4724
2346
  }
4725
2347
  }
4726
- #writeFile(store2) {
4727
- writeSecurely(this.#path(), `${JSON.stringify(store2, null, 2)}
2348
+ #writeFile(store) {
2349
+ writeSecurely(this.#path(), `${JSON.stringify(store, null, 2)}
4728
2350
  `, 384);
4729
2351
  }
4730
2352
  #tryKeyring(operation) {
@@ -4742,10 +2364,10 @@ var Credentials = class {
4742
2364
  }
4743
2365
  };
4744
2366
 
4745
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/logging.js
2367
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/logging.js
4746
2368
  import { appendFileSync } from "node:fs";
4747
2369
 
4748
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/log.js
2370
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/log.js
4749
2371
  var LOG_SEVERITIES = ["trace", "debug", "info", "warn", "error", "fatal"];
4750
2372
  var logRecordSchema = strictObject({
4751
2373
  time: isoTime,
@@ -4803,10 +2425,10 @@ var CONTENT_WORDS = /* @__PURE__ */ new Set([
4803
2425
  "token"
4804
2426
  ]);
4805
2427
  var CONTENT_LAST_WORDS = /* @__PURE__ */ new Set(["message", "name"]);
4806
- var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word2) => word2.toLowerCase()), "wordsOf");
2428
+ var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word) => word.toLowerCase()), "wordsOf");
4807
2429
  var isContentKey = /* @__PURE__ */ __name((key) => {
4808
2430
  const words = wordsOf(key);
4809
- return words.some((word2) => CONTENT_WORDS.has(word2)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
2431
+ return words.some((word) => CONTENT_WORDS.has(word)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
4810
2432
  }, "isContentKey");
4811
2433
  var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
4812
2434
  var traceIdOf = /* @__PURE__ */ __name((traceparent) => {
@@ -4823,7 +2445,7 @@ var traceIdOf = /* @__PURE__ */ __name((traceparent) => {
4823
2445
  return traceId;
4824
2446
  }, "traceIdOf");
4825
2447
 
4826
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/logging.js
2448
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/logging.js
4827
2449
  var REDACTED_FIELDS = [
4828
2450
  "authorization",
4829
2451
  "Authorization",
@@ -4917,7 +2539,7 @@ var silent = {
4917
2539
  }, "error")
4918
2540
  };
4919
2541
 
4920
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/output-buffer.js
2542
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/output-buffer.js
4921
2543
  var createOutputBuffer = /* @__PURE__ */ __name(({ maxOutputBytes = 4 * 1024 * 1024, fields, format } = {}) => {
4922
2544
  if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 0)
4923
2545
  throw new CliError("validation_error", "maxOutputBytes must be a nonnegative whole byte count");
@@ -4978,7 +2600,7 @@ var createOutputBuffer = /* @__PURE__ */ __name(({ maxOutputBytes = 4 * 1024 * 1
4978
2600
  };
4979
2601
  }, "createOutputBuffer");
4980
2602
 
4981
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/retry.js
2603
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/retry.js
4982
2604
  var DEFAULT_RETRY = {
4983
2605
  retries: 1,
4984
2606
  baseDelayMs: 250,
@@ -4990,7 +2612,62 @@ var backoffMs = /* @__PURE__ */ __name((attempt, config, random) => {
4990
2612
  return Math.round(random() * ceiling);
4991
2613
  }, "backoffMs");
4992
2614
 
4993
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/time.js
2615
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/constants.js
2616
+ import { fileURLToPath } from "node:url";
2617
+ var BASE_CONSTANTS = new URL("../constants.json", new URL("constants.js", import.meta.resolve("@wirecat/cli-base")).href);
2618
+ var baseConstantsSchema = object({});
2619
+ var LayerSchema = record(string(), unknown());
2620
+ var isPlainObject = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isPlainObject");
2621
+ var merge = /* @__PURE__ */ __name((into, from, file, setBy, prefix = "") => {
2622
+ const out = { ...into };
2623
+ for (const [key, value] of Object.entries(from)) {
2624
+ const path = prefix ? `${prefix}.${key}` : key;
2625
+ const current = out[key];
2626
+ if (isPlainObject(current) && isPlainObject(value)) {
2627
+ out[key] = merge(current, value, file, setBy, path);
2628
+ } else {
2629
+ out[key] = value;
2630
+ setBy.set(path, file);
2631
+ }
2632
+ }
2633
+ return out;
2634
+ }, "merge");
2635
+ var deepFreeze = /* @__PURE__ */ __name((value) => {
2636
+ if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
2637
+ for (const child of Object.values(value))
2638
+ deepFreeze(child);
2639
+ Object.freeze(value);
2640
+ }
2641
+ return value;
2642
+ }, "deepFreeze");
2643
+ var fileOf = /* @__PURE__ */ __name((path, setBy, files) => {
2644
+ for (let at = path.split("."); at.length > 0; at = at.slice(0, -1)) {
2645
+ const file = setBy.get(at.join("."));
2646
+ if (file)
2647
+ return `set in ${file}`;
2648
+ }
2649
+ return `not set in ${files.join(", ")}`;
2650
+ }, "fileOf");
2651
+ var loadConstants = /* @__PURE__ */ __name((layers, schema) => {
2652
+ const files = layers.map((layer) => fileURLToPath(layer));
2653
+ const setBy = /* @__PURE__ */ new Map();
2654
+ let merged = {};
2655
+ for (const file of files) {
2656
+ merged = merge(merged, loadConfigFile(file, LayerSchema, () => ({})), file, setBy);
2657
+ }
2658
+ const result = safeParse(schema, merged);
2659
+ if (!result.success) {
2660
+ const problems = result.issues.map((issue) => {
2661
+ const path = getDotPath(issue) ?? "(root)";
2662
+ return `${path}: ${issue.message} (${fileOf(path, setBy, files)})`;
2663
+ });
2664
+ throw new Error(`the packaged constants are not valid:
2665
+ ${problems.join("\n ")}`);
2666
+ }
2667
+ return deepFreeze(result.output);
2668
+ }, "loadConstants");
2669
+
2670
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/time.js
4994
2671
  var abortError = /* @__PURE__ */ __name(() => new DOMException("The operation was aborted.", "AbortError"), "abortError");
4995
2672
  var realSleep = /* @__PURE__ */ __name((ms, signal) => new Promise((resolve2, reject) => {
4996
2673
  if (signal?.aborted) {
@@ -5004,7 +2681,7 @@ var realSleep = /* @__PURE__ */ __name((ms, signal) => new Promise((resolve2, re
5004
2681
  }, { once: true });
5005
2682
  }), "realSleep");
5006
2683
 
5007
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/deadline.js
2684
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/deadline.js
5008
2685
  var createDeadline = /* @__PURE__ */ __name(({ timeoutMs, signal, sleep = realSleep } = {}) => {
5009
2686
  if (timeoutMs !== void 0 && (!Number.isSafeInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 2147483647))
5010
2687
  throw new CliError("validation_error", "timeoutMs must be an integer from zero through 2147483647");
@@ -5088,7 +2765,7 @@ var createDeadline = /* @__PURE__ */ __name(({ timeoutMs, signal, sleep = realSl
5088
2765
  };
5089
2766
  }, "createDeadline");
5090
2767
 
5091
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/pretty.js
2768
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/pretty.js
5092
2769
  var import_cli_table3 = __toESM(require_cli_table3(), 1);
5093
2770
  import { styleText } from "node:util";
5094
2771
  var renderPretty = /* @__PURE__ */ __name((value, options) => {
@@ -5098,7 +2775,7 @@ var renderPretty = /* @__PURE__ */ __name((value, options) => {
5098
2775
  return paint2.dim("(nothing)");
5099
2776
  return isRowLike(value) ? renderTable(value, paint2) : renderJson(value);
5100
2777
  }
5101
- if (isPlainObject(value)) {
2778
+ if (isPlainObject2(value)) {
5102
2779
  const listKey = Object.keys(value).find((key) => Array.isArray(value[key]) && isRowLike(value[key]));
5103
2780
  if (listKey) {
5104
2781
  const rest = Object.fromEntries(Object.entries(value).filter(([key]) => key !== listKey));
@@ -5118,8 +2795,8 @@ var palette = /* @__PURE__ */ __name((color) => ({
5118
2795
  bold: paint("bold", color),
5119
2796
  label: paint("cyan", color)
5120
2797
  }), "palette");
5121
- var isPlainObject = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isPlainObject");
5122
- var isRowLike = /* @__PURE__ */ __name((value) => value.length > 0 && value.every((item) => isPlainObject(item)) && value.length <= 500, "isRowLike");
2798
+ var isPlainObject2 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isPlainObject");
2799
+ var isRowLike = /* @__PURE__ */ __name((value) => value.length > 0 && value.every((item) => isPlainObject2(item)) && value.length <= 500, "isRowLike");
5123
2800
  var renderTable = /* @__PURE__ */ __name((rows, paint2) => {
5124
2801
  const columns = [...new Set(rows.flatMap((row) => Object.keys(row)))];
5125
2802
  const table = new import_cli_table3.default({
@@ -5163,7 +2840,7 @@ var BORDERLESS = {
5163
2840
  middle: ""
5164
2841
  };
5165
2842
 
5166
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/drain.js
2843
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/drain.js
5167
2844
  var waitForDrain = /* @__PURE__ */ __name((stream, signal) => {
5168
2845
  if (signal?.aborted)
5169
2846
  return Promise.reject(signal.reason);
@@ -5191,7 +2868,7 @@ var waitForDrain = /* @__PURE__ */ __name((stream, signal) => {
5191
2868
  });
5192
2869
  }, "waitForDrain");
5193
2870
 
5194
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/streams.js
2871
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/streams.js
5195
2872
  var processStreams = {
5196
2873
  drain: /* @__PURE__ */ __name(async (signal) => {
5197
2874
  await Promise.all([waitForDrain(process.stdout, signal), waitForDrain(process.stderr, signal)]);
@@ -5220,7 +2897,7 @@ var captureStreams = /* @__PURE__ */ __name(() => {
5220
2897
  };
5221
2898
  }, "captureStreams");
5222
2899
 
5223
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/renderer.js
2900
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/renderer.js
5224
2901
  var createRenderer = /* @__PURE__ */ __name(({ format, color, streams = processStreams, quiet = false }) => {
5225
2902
  const mark = /* @__PURE__ */ __name((symbol, message) => format === "pretty" ? `${symbol} ${visibleControls(message)}` : visibleControls(message), "mark");
5226
2903
  const say = /* @__PURE__ */ __name((symbol) => (message) => {
@@ -5258,90 +2935,6 @@ var createRenderer = /* @__PURE__ */ __name(({ format, color, streams = processS
5258
2935
  }, "createRenderer");
5259
2936
 
5260
2937
  export {
5261
- errorCodes,
5262
- CliError,
5263
- isCliError,
5264
- EXIT_CODES,
5265
- exitCodeFor,
5266
- GENERIC_FAILURE,
5267
- visibleControls,
5268
- singleLine,
5269
- getDotPath,
5270
- check,
5271
- description,
5272
- finite,
5273
- integer,
5274
- isoDate,
5275
- isoTimestamp,
5276
- maxLength,
5277
- maxValue,
5278
- minLength,
5279
- minValue,
5280
- nonEmpty,
5281
- regex,
5282
- safeInteger,
5283
- transform,
5284
- trim,
5285
- forward,
5286
- array,
5287
- boolean,
5288
- custom,
5289
- lazy,
5290
- literal,
5291
- looseObject,
5292
- null_,
5293
- nullable,
5294
- number,
5295
- object,
5296
- objectWithRest,
5297
- optional,
5298
- picklist,
5299
- record,
5300
- strictObject,
5301
- string,
5302
- union,
5303
- unknown,
5304
- variant,
5305
- omit,
5306
- parse,
5307
- partial,
5308
- pick,
5309
- pipe,
5310
- safeParse,
5311
- summarize,
5312
- unwrap,
5313
- effectsSchema,
5314
- writes,
5315
- toJsonSchema,
5316
- toStandardJsonSchema,
5317
- word,
5318
- SNAKE_CASE,
5319
- text,
5320
- RegistryError,
5321
- parseRegistry,
5322
- duplicates,
5323
- jsonSchemaOf,
5324
- MAX_NEXT_STEPS,
5325
- COMPACT_FLAG,
5326
- isoTime,
5327
- reference,
5328
- pageSchema,
5329
- listEnvelopeSchema,
5330
- itemEnvelopeSchema,
5331
- jsonlOf,
5332
- CRASH_CODE,
5333
- errorObjectSchema,
5334
- defineReasons,
5335
- defineSteps,
5336
- stepOf,
5337
- STEPS,
5338
- errorObjectOf,
5339
- exitCodeOfError,
5340
- exitCodeOfAnswer,
5341
- errorRecordOf,
5342
- renderError,
5343
- mcpErrorResult,
5344
- catchCrashes,
5345
2938
  fieldsOf,
5346
2939
  projectFields,
5347
2940
  BATCH_LIMITS,
@@ -5351,6 +2944,9 @@ export {
5351
2944
  writeSecurely,
5352
2945
  loadConfigFile,
5353
2946
  saveConfigFile,
2947
+ BASE_CONSTANTS,
2948
+ baseConstantsSchema,
2949
+ loadConstants,
5354
2950
  systemKeyring,
5355
2951
  resolvePaths,
5356
2952
  pathsAreOverridden,