@wirecat/cli-memo 0.131.19 → 0.131.21

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 (187) hide show
  1. package/README.md +2 -3
  2. package/dist/actions/command.d.ts +1 -1
  3. package/dist/actions/command.d.ts.map +1 -1
  4. package/dist/actions/command.js +12 -1
  5. package/dist/actions/command.js.map +1 -1
  6. package/dist/bin/memo.js +2 -2
  7. package/dist/bin/memo.js.map +1 -1
  8. package/dist/bundle/{all-profiles-MVF2XGZK.js → all-profiles-EZLU6CY7.js} +9 -7
  9. package/dist/bundle/{anthropic-OPFHMF2S.js → anthropic-XC34PJH5.js} +6 -4
  10. package/dist/bundle/{app-server-VHVC55S3.js → app-server-26YPLJ7M.js} +53 -48
  11. package/dist/bundle/auto-QHTPHGNA.js +86 -0
  12. package/dist/bundle/{bun-P6TMDZGU.js → bun-CKGKUKW5.js} +2 -2
  13. package/dist/bundle/{bun-sqlite-3G3NLK4O.js → bun-sqlite-S6KUSMTC.js} +5 -3
  14. package/dist/bundle/{chunk-XZWUBDBG.js → chunk-2NJUPIAO.js} +1 -1
  15. package/dist/bundle/{chunk-RFB5LOYR.js → chunk-2TBIVKBH.js} +8 -6
  16. package/dist/bundle/{chunk-3DVKC2XM.js → chunk-3V4WIGWC.js} +8 -19
  17. package/dist/bundle/{chunk-BMHSGZNE.js → chunk-5RBLNI6C.js} +4 -4
  18. package/dist/bundle/{chunk-LKYHSVQL.js → chunk-7F6FGMCC.js} +8 -8
  19. package/dist/bundle/{chunk-FMSA2X3E.js → chunk-7MLWSUEK.js} +1 -1
  20. package/dist/bundle/{chunk-DLRLOGVU.js → chunk-7NEWBM2O.js} +13 -9
  21. package/dist/bundle/{chunk-SO6VNTF6.js → chunk-AIIQ7YU4.js} +1 -1
  22. package/dist/bundle/{chunk-4TERVG26.js → chunk-B3YV6Z7Y.js} +8 -2
  23. package/dist/bundle/{chunk-IW3U6XXI.js → chunk-BB2MGFOZ.js} +6 -6
  24. package/dist/bundle/chunk-CCHHEMPM.js +71 -0
  25. package/dist/bundle/{chunk-6DG7VK3H.js → chunk-CCOYC6HL.js} +5 -5
  26. package/dist/bundle/{chunk-MXP4J6BJ.js → chunk-CDZZ2DZO.js} +70 -2517
  27. package/dist/bundle/{chunk-VUWUSGSN.js → chunk-CP5N3KH3.js} +4 -4
  28. package/dist/bundle/{chunk-NKTAEBCU.js → chunk-CRZSJHAK.js} +13 -9
  29. package/dist/bundle/{chunk-LPUFOWL3.js → chunk-D72URWJE.js} +1 -39
  30. package/dist/bundle/{chunk-BINR6MJ5.js → chunk-DNGHE2Q4.js} +1 -1
  31. package/dist/bundle/{chunk-KVVDRD7M.js → chunk-DZSWKA3K.js} +2 -2
  32. package/dist/bundle/{chunk-63XICXGM.js → chunk-E5FQ7U7L.js} +5 -3
  33. package/dist/bundle/{chunk-BPYQYZXA.js → chunk-EAYYWS67.js} +14 -12
  34. package/dist/bundle/chunk-EG2OMKWH.js +2423 -0
  35. package/dist/bundle/chunk-EW3XTUPB.js +166 -0
  36. package/dist/bundle/{chunk-4VKNUBD5.js → chunk-FFWK5NEZ.js} +10 -8
  37. package/dist/bundle/{chunk-3ORDQ62F.js → chunk-GV2FSWFS.js} +10 -8
  38. package/dist/bundle/chunk-ILHTNOIV.js +23 -0
  39. package/dist/bundle/{chunk-VQGVPDMH.js → chunk-INURBEAO.js} +20 -16
  40. package/dist/bundle/{chunk-OVFMY6ZP.js → chunk-IRDGD3QQ.js} +1 -1
  41. package/dist/bundle/{chunk-D6G23NFJ.js → chunk-J4GC33JU.js} +2 -2
  42. package/dist/bundle/{chunk-XWS4PTES.js → chunk-J55Z6EJ3.js} +363 -278
  43. package/dist/bundle/{chunk-TQNQS6TR.js → chunk-JJ3C5AYK.js} +64 -60
  44. package/dist/bundle/{chunk-LQJ4KHXK.js → chunk-JXH22ZGA.js} +15 -15
  45. package/dist/bundle/{chunk-5KUPVC5M.js → chunk-KUNA6MQZ.js} +2 -2
  46. package/dist/bundle/{chunk-LDVU22MF.js → chunk-LGNS4JVK.js} +8 -8
  47. package/dist/bundle/{chunk-57Q6NXQT.js → chunk-LR5EY5JY.js} +4 -4
  48. package/dist/bundle/{chunk-ZYM4M62Q.js → chunk-MCPDL5YU.js} +4 -4
  49. package/dist/bundle/{chunk-V7DZG62U.js → chunk-MHDLZCEO.js} +11 -9
  50. package/dist/bundle/{chunk-SHDZVM3B.js → chunk-NELE7AIX.js} +2 -2
  51. package/dist/bundle/{chunk-WRPRPVZF.js → chunk-NOG5O2NS.js} +44 -42
  52. package/dist/bundle/{chunk-RITXQKYG.js → chunk-NWB5NAGB.js} +6 -6
  53. package/dist/bundle/{chunk-UC4IL2P7.js → chunk-OJRLTJRS.js} +1 -1
  54. package/dist/bundle/{chunk-OTHEM74Z.js → chunk-OUF6RCRZ.js} +6 -6
  55. package/dist/bundle/{chunk-JDJDNMCP.js → chunk-PF3ALSAV.js} +1 -1
  56. package/dist/bundle/{chunk-GJKM32WA.js → chunk-PO5C7VNC.js} +24 -22
  57. package/dist/bundle/chunk-PQLBPYJR.js +46 -0
  58. package/dist/bundle/{chunk-66YZUX2C.js → chunk-QMMUPDRK.js} +10 -10
  59. package/dist/bundle/{chunk-P3TYFDMP.js → chunk-R26CXR5Z.js} +9 -7
  60. package/dist/bundle/{chunk-F5CQ2NVA.js → chunk-RC7TIYUZ.js} +11 -9
  61. package/dist/bundle/{chunk-P22V2OLJ.js → chunk-RG6ITTLQ.js} +22 -16
  62. package/dist/bundle/{chunk-T557KUST.js → chunk-RHJC4PHV.js} +3 -3
  63. package/dist/bundle/{chunk-Z54GPSVH.js → chunk-RNXYDBQO.js} +186 -162
  64. package/dist/bundle/{chunk-YVECM7XA.js → chunk-SMDWUPXE.js} +4 -4
  65. package/dist/bundle/{chunk-KO455254.js → chunk-SXGAIQ5X.js} +13 -13
  66. package/dist/bundle/{chunk-EMKFG5BP.js → chunk-THGFFQCK.js} +3 -3
  67. package/dist/bundle/{chunk-2R25UBIH.js → chunk-TMNHNZVA.js} +26 -24
  68. package/dist/bundle/{chunk-WOIRWVDJ.js → chunk-UXCSNSUU.js} +563 -351
  69. package/dist/bundle/{chunk-EFKEG2BA.js → chunk-VECICKTE.js} +5 -5
  70. package/dist/bundle/{chunk-4MIPN37I.js → chunk-VQM3H422.js} +266 -176
  71. package/dist/bundle/chunk-VXHN3SWW.js +35 -0
  72. package/dist/bundle/{chunk-EL4ZKQUN.js → chunk-WEOFWTWZ.js} +6 -4
  73. package/dist/bundle/{chunk-LEUNYKL6.js → chunk-WUCQ56RP.js} +3 -3
  74. package/dist/bundle/{chunk-SJLVBJ2L.js → chunk-XA6YO24S.js} +2 -2
  75. package/dist/bundle/{chunk-36ULPM2W.js → chunk-XPRYBLTS.js} +6 -6
  76. package/dist/bundle/{chunk-2KOVYXWK.js → chunk-YAUDFROV.js} +1243 -743
  77. package/dist/bundle/{chunk-Y3DGAYTD.js → chunk-YUFUUQUO.js} +7 -5
  78. package/dist/bundle/{chunk-JHKTN6NL.js → chunk-ZCKU6WMX.js} +13 -11
  79. package/dist/bundle/{chunk-5XDYV2YT.js → chunk-ZD3STMY7.js} +1 -1
  80. package/dist/bundle/command-contract-TMVGYSQQ.js +32 -0
  81. package/dist/bundle/{decode-BUTF6VGO.js → decode-6XSZIZAA.js} +5 -3
  82. package/dist/bundle/dispatch-VUMQPYMA.js +411 -0
  83. package/dist/bundle/{echarts-KH3YOWMK.js → echarts-NGS4QG4E.js} +2 -2
  84. package/dist/bundle/{embed-WBVM7KQ2.js → embed-YNH5M6UL.js} +6 -4
  85. package/dist/bundle/{embedder-27HQIFHM.js → embedder-LLNK4JF4.js} +11 -9
  86. package/dist/bundle/{entry-K2WWMF2B.js → entry-DO6ZBFIS.js} +7 -5
  87. package/dist/bundle/failure-LHMJNFY6.js +66 -0
  88. package/dist/bundle/failure-Z2FXWIBY.js +24 -0
  89. package/dist/bundle/first-run-BXFQN6M5.js +27 -0
  90. package/dist/bundle/first-screen-56KZKY77.js +30 -0
  91. package/dist/bundle/{instructions-POJKHKRZ.js → instructions-4EJ4BBWD.js} +1 -1
  92. package/dist/bundle/mcp-A4HPKQK5.js +90 -0
  93. package/dist/bundle/{mcp-FUSDPAOL.js → mcp-MNI62HHE.js} +4 -2
  94. package/dist/bundle/memo.js +182 -39
  95. package/dist/bundle/{node-W245R2OP.js → node-QQXKQWNC.js} +2 -2
  96. package/dist/bundle/{node-sqlite-FUYOXFW5.js → node-sqlite-GJI2GMLW.js} +6 -4
  97. package/dist/bundle/{oauth-ATB3NWQA.js → oauth-Q5VGUPUR.js} +7 -5
  98. package/dist/bundle/{open-HEBEWCYB.js → open-NSXIYF3N.js} +5 -3
  99. package/dist/bundle/{openai-DN7NA2IU.js → openai-LHH7MSGQ.js} +10 -8
  100. package/dist/bundle/{process-QTIDOJMF.js → process-PI6XUJWP.js} +1 -1
  101. package/dist/bundle/{program-WNFCYNGP.js → program-3ZTQ5FEM.js} +8382 -8312
  102. package/dist/bundle/{prompt-RQXVPJ4A.js → prompt-VFXA7IKL.js} +5 -3
  103. package/dist/bundle/{recognize-G7NIZ3IT.js → recognize-UWAARXOH.js} +4 -2
  104. package/dist/bundle/{remote-H452UBSK.js → remote-KGEVCB2Q.js} +7 -5
  105. package/dist/bundle/{rerank-77UYD2UD.js → rerank-SCBTCBPO.js} +7 -5
  106. package/dist/bundle/{serve-L6R4ODZV.js → serve-WPVKVR24.js} +9 -7
  107. package/dist/bundle/{server-ZBX4HFHT.js → server-BMQBWBBN.js} +71 -64
  108. package/dist/bundle/server-NQK5EX7P.js +48 -0
  109. package/dist/bundle/server-UN43Y6BY.js +61 -0
  110. package/dist/bundle/{setup-ZGH5OZ7A.js → setup-FGSVWQ32.js} +47 -43
  111. package/dist/bundle/{state-KHMYDV4I.js → state-KGHS4C6J.js} +6 -4
  112. package/dist/bundle/{store-M7KGTLUG.js → store-VCVOIQES.js} +12 -10
  113. package/dist/bundle/store-maintenance-command-QTEWWDST.js +48 -0
  114. package/dist/bundle/update-XC6KAVCK.js +69 -0
  115. package/dist/config.d.ts +1 -1
  116. package/dist/config.d.ts.map +1 -1
  117. package/dist/config.js +2 -2
  118. package/dist/config.js.map +1 -1
  119. package/dist/contract-overrides/skill.d.ts.map +1 -1
  120. package/dist/contract-overrides/skill.js +14 -0
  121. package/dist/contract-overrides/skill.js.map +1 -1
  122. package/dist/examples.d.ts.map +1 -1
  123. package/dist/examples.js +34 -3
  124. package/dist/examples.js.map +1 -1
  125. package/dist/knowledge/project-actions-command.js +1 -1
  126. package/dist/knowledge/project-actions-command.js.map +1 -1
  127. package/dist/mail/command.d.ts.map +1 -1
  128. package/dist/mail/command.js +11 -1
  129. package/dist/mail/command.js.map +1 -1
  130. package/dist/mail/findings-command.d.ts +8 -0
  131. package/dist/mail/findings-command.d.ts.map +1 -0
  132. package/dist/mail/findings-command.js +80 -0
  133. package/dist/mail/findings-command.js.map +1 -0
  134. package/dist/mail/messages-command.d.ts.map +1 -1
  135. package/dist/mail/messages-command.js +27 -3
  136. package/dist/mail/messages-command.js.map +1 -1
  137. package/dist/mail/review-command.d.ts +12 -0
  138. package/dist/mail/review-command.d.ts.map +1 -0
  139. package/dist/mail/review-command.js +46 -0
  140. package/dist/mail/review-command.js.map +1 -0
  141. package/dist/mcp/catalogue.d.ts +3 -0
  142. package/dist/mcp/catalogue.d.ts.map +1 -1
  143. package/dist/mcp/catalogue.js +2 -1
  144. package/dist/mcp/catalogue.js.map +1 -1
  145. package/dist/mcp/server.js +1 -1
  146. package/dist/mcp/server.js.map +1 -1
  147. package/dist/program.d.ts.map +1 -1
  148. package/dist/program.js +17 -1
  149. package/dist/program.js.map +1 -1
  150. package/dist/read-only.d.ts +1 -1
  151. package/dist/reasons.d.ts.map +1 -1
  152. package/dist/reasons.js +6 -0
  153. package/dist/reasons.js.map +1 -1
  154. package/dist/records/import.d.ts.map +1 -1
  155. package/dist/records/import.js +9 -2
  156. package/dist/records/import.js.map +1 -1
  157. package/dist/records/mapping.d.ts +9 -0
  158. package/dist/records/mapping.d.ts.map +1 -0
  159. package/dist/records/mapping.js +67 -0
  160. package/dist/records/mapping.js.map +1 -0
  161. package/dist/review/kinds.d.ts +0 -6
  162. package/dist/review/kinds.d.ts.map +1 -1
  163. package/dist/review/kinds.js +14 -45
  164. package/dist/review/kinds.js.map +1 -1
  165. package/dist/review/status.d.ts +1 -0
  166. package/dist/review/status.d.ts.map +1 -1
  167. package/dist/schedule/command.d.ts +3 -1
  168. package/dist/schedule/command.d.ts.map +1 -1
  169. package/dist/schedule/command.js +6 -1
  170. package/dist/schedule/command.js.map +1 -1
  171. package/dist/version.d.ts +1 -1
  172. package/dist/version.js +1 -1
  173. package/package.json +4 -3
  174. package/skills/cli-memo/SKILL.md +15 -4
  175. package/skills/mail-triage/SKILL.md +120 -0
  176. package/dist/bundle/auto-F53FUP45.js +0 -82
  177. package/dist/bundle/chunk-7J5HTZCM.js +0 -18
  178. package/dist/bundle/command-contract-NMJKYTS4.js +0 -30
  179. package/dist/bundle/failure-NHDQ5WEW.js +0 -62
  180. package/dist/bundle/first-run-7P5N72VR.js +0 -23
  181. package/dist/bundle/first-screen-3GM5HC4Y.js +0 -28
  182. package/dist/bundle/mcp-YGWNSJUH.js +0 -86
  183. package/dist/bundle/server-SWUSQSRW.js +0 -44
  184. package/dist/bundle/server-W4IKTTUY.js +0 -57
  185. package/dist/bundle/store-maintenance-command-ZPN2ZUL4.js +0 -44
  186. package/dist/bundle/update-RFTADFRO.js +0 -65
  187. /package/dist/bundle/{chunk-7YF2MSEC.js → chunk-YYQN5ES2.js} +0 -0
@@ -1,5 +1,29 @@
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
+ optional,
11
+ parseRegistry,
12
+ picklist,
13
+ pipe,
14
+ record,
15
+ regex,
16
+ safeParse,
17
+ strictObject,
18
+ string,
19
+ text,
20
+ unknown
21
+ } from "./chunk-EG2OMKWH.js";
22
+ import {
23
+ CliError,
24
+ isCliError,
25
+ visibleControls
26
+ } from "./chunk-CCHHEMPM.js";
3
27
  import {
4
28
  __commonJS,
5
29
  __name,
@@ -367,26 +391,26 @@ var require_utils = __commonJS({
367
391
  return ret;
368
392
  }
369
393
  __name(mergeOptions, "mergeOptions");
370
- function wordWrap(maxLength2, input) {
394
+ function wordWrap(maxLength, input) {
371
395
  let lines = [];
372
396
  let split = input.split(/(\s+)/g);
373
397
  let line = [];
374
398
  let lineLength = 0;
375
399
  let whitespace;
376
400
  for (let i = 0; i < split.length; i += 2) {
377
- let word2 = split[i];
378
- let newLength = lineLength + strlen(word2);
401
+ let word = split[i];
402
+ let newLength = lineLength + strlen(word);
379
403
  if (lineLength > 0 && whitespace) {
380
404
  newLength += whitespace.length;
381
405
  }
382
- if (newLength > maxLength2) {
406
+ if (newLength > maxLength) {
383
407
  if (lineLength !== 0) {
384
408
  lines.push(line.join(""));
385
409
  }
386
- line = [word2];
387
- lineLength = strlen(word2);
410
+ line = [word];
411
+ lineLength = strlen(word);
388
412
  } else {
389
- line.push(whitespace || "", word2);
413
+ line.push(whitespace || "", word);
390
414
  lineLength = newLength;
391
415
  }
392
416
  whitespace = split[i + 1];
@@ -397,15 +421,15 @@ var require_utils = __commonJS({
397
421
  return lines;
398
422
  }
399
423
  __name(wordWrap, "wordWrap");
400
- function textWrap(maxLength2, input) {
424
+ function textWrap(maxLength, input) {
401
425
  let lines = [];
402
426
  let line = "";
403
427
  function pushLine(str, ws) {
404
428
  if (line.length && ws) line += ws;
405
429
  line += str;
406
- while (line.length > maxLength2) {
407
- lines.push(line.slice(0, maxLength2));
408
- line = line.slice(maxLength2);
430
+ while (line.length > maxLength) {
431
+ lines.push(line.slice(0, maxLength));
432
+ line = line.slice(maxLength);
409
433
  }
410
434
  }
411
435
  __name(pushLine, "pushLine");
@@ -417,12 +441,12 @@ var require_utils = __commonJS({
417
441
  return lines;
418
442
  }
419
443
  __name(textWrap, "textWrap");
420
- function multiLineWordWrap(maxLength2, input, wrapOnWordBoundary = true) {
444
+ function multiLineWordWrap(maxLength, input, wrapOnWordBoundary = true) {
421
445
  let output = [];
422
446
  input = input.split("\n");
423
447
  const handler = wrapOnWordBoundary ? wordWrap : textWrap;
424
448
  for (let i = 0; i < input.length; i++) {
425
- output.push.apply(output, handler(maxLength2, input[i]));
449
+ output.push.apply(output, handler(maxLength, input[i]));
426
450
  }
427
451
  return output;
428
452
  }
@@ -1872,2393 +1896,6 @@ var require_cli_table3 = __commonJS({
1872
1896
  }
1873
1897
  });
1874
1898
 
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 lazy(getter) {
2403
- return _standardSchema({
2404
- kind: "schema",
2405
- type: "lazy",
2406
- reference: lazy,
2407
- expects: "unknown",
2408
- async: false,
2409
- getter,
2410
- "~run"(dataset, config$1) {
2411
- return this.getter(dataset.value)["~run"](dataset, config$1);
2412
- }
2413
- });
2414
- }
2415
- __name(lazy, "lazy");
2416
- // @__NO_SIDE_EFFECTS__
2417
- function literal(literal_, message$1) {
2418
- return _standardSchema({
2419
- kind: "schema",
2420
- type: "literal",
2421
- reference: literal,
2422
- expects: /* @__PURE__ */ _stringify(literal_),
2423
- async: false,
2424
- literal: literal_,
2425
- message: message$1,
2426
- "~run"(dataset, config$1) {
2427
- if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
2428
- else _addIssue(this, "type", dataset, config$1);
2429
- return dataset;
2430
- }
2431
- });
2432
- }
2433
- __name(literal, "literal");
2434
- // @__NO_SIDE_EFFECTS__
2435
- function looseObject(entries$1, message$1) {
2436
- return _standardSchema({
2437
- kind: "schema",
2438
- type: "loose_object",
2439
- reference: looseObject,
2440
- expects: "Object",
2441
- async: false,
2442
- entries: entries$1,
2443
- message: message$1,
2444
- "~run"(dataset, config$1) {
2445
- const input = dataset.value;
2446
- if (input && typeof input === "object") {
2447
- dataset.typed = true;
2448
- dataset.value = {};
2449
- for (const key in this.entries) {
2450
- const valueSchema = this.entries[key];
2451
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2452
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2453
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2454
- if (valueDataset.issues) {
2455
- const pathItem = {
2456
- type: "object",
2457
- origin: "value",
2458
- input,
2459
- key,
2460
- value: value$1
2461
- };
2462
- for (const issue of valueDataset.issues) {
2463
- if (issue.path) issue.path.unshift(pathItem);
2464
- else issue.path = [pathItem];
2465
- dataset.issues?.push(issue);
2466
- }
2467
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2468
- if (config$1.abortEarly) {
2469
- dataset.typed = false;
2470
- break;
2471
- }
2472
- }
2473
- if (!valueDataset.typed) dataset.typed = false;
2474
- dataset.value[key] = valueDataset.value;
2475
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2476
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2477
- _addIssue(this, "key", dataset, config$1, {
2478
- input: void 0,
2479
- expected: `"${key}"`,
2480
- path: [{
2481
- type: "object",
2482
- origin: "key",
2483
- input,
2484
- key,
2485
- value: input[key]
2486
- }]
2487
- });
2488
- if (config$1.abortEarly) break;
2489
- }
2490
- }
2491
- if (!dataset.issues || !config$1.abortEarly) {
2492
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) dataset.value[key] = input[key];
2493
- }
2494
- } else _addIssue(this, "type", dataset, config$1);
2495
- return dataset;
2496
- }
2497
- });
2498
- }
2499
- __name(looseObject, "looseObject");
2500
- // @__NO_SIDE_EFFECTS__
2501
- function null_(message$1) {
2502
- return _standardSchema({
2503
- kind: "schema",
2504
- type: "null",
2505
- reference: null_,
2506
- expects: "null",
2507
- async: false,
2508
- message: message$1,
2509
- "~run"(dataset, config$1) {
2510
- if (dataset.value === null) dataset.typed = true;
2511
- else _addIssue(this, "type", dataset, config$1);
2512
- return dataset;
2513
- }
2514
- });
2515
- }
2516
- __name(null_, "null_");
2517
- // @__NO_SIDE_EFFECTS__
2518
- function nullable(wrapped, default_) {
2519
- return _standardSchema({
2520
- kind: "schema",
2521
- type: "nullable",
2522
- reference: nullable,
2523
- expects: `(${wrapped.expects} | null)`,
2524
- async: false,
2525
- wrapped,
2526
- default: default_,
2527
- "~run"(dataset, config$1) {
2528
- if (dataset.value === null) {
2529
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
2530
- if (dataset.value === null) {
2531
- dataset.typed = true;
2532
- return dataset;
2533
- }
2534
- }
2535
- return this.wrapped["~run"](dataset, config$1);
2536
- }
2537
- });
2538
- }
2539
- __name(nullable, "nullable");
2540
- // @__NO_SIDE_EFFECTS__
2541
- function number(message$1) {
2542
- return _standardSchema({
2543
- kind: "schema",
2544
- type: "number",
2545
- reference: number,
2546
- expects: "number",
2547
- async: false,
2548
- message: message$1,
2549
- "~run"(dataset, config$1) {
2550
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
2551
- else _addIssue(this, "type", dataset, config$1);
2552
- return dataset;
2553
- }
2554
- });
2555
- }
2556
- __name(number, "number");
2557
- // @__NO_SIDE_EFFECTS__
2558
- function object(entries$1, message$1) {
2559
- return _standardSchema({
2560
- kind: "schema",
2561
- type: "object",
2562
- reference: object,
2563
- expects: "Object",
2564
- async: false,
2565
- entries: entries$1,
2566
- message: message$1,
2567
- "~run"(dataset, config$1) {
2568
- const input = dataset.value;
2569
- if (input && typeof input === "object") {
2570
- dataset.typed = true;
2571
- dataset.value = {};
2572
- for (const key in this.entries) {
2573
- const valueSchema = this.entries[key];
2574
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2575
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2576
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2577
- if (valueDataset.issues) {
2578
- const pathItem = {
2579
- type: "object",
2580
- origin: "value",
2581
- input,
2582
- key,
2583
- value: value$1
2584
- };
2585
- for (const issue of valueDataset.issues) {
2586
- if (issue.path) issue.path.unshift(pathItem);
2587
- else issue.path = [pathItem];
2588
- dataset.issues?.push(issue);
2589
- }
2590
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2591
- if (config$1.abortEarly) {
2592
- dataset.typed = false;
2593
- break;
2594
- }
2595
- }
2596
- if (!valueDataset.typed) dataset.typed = false;
2597
- dataset.value[key] = valueDataset.value;
2598
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2599
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2600
- _addIssue(this, "key", dataset, config$1, {
2601
- input: void 0,
2602
- expected: `"${key}"`,
2603
- path: [{
2604
- type: "object",
2605
- origin: "key",
2606
- input,
2607
- key,
2608
- value: input[key]
2609
- }]
2610
- });
2611
- if (config$1.abortEarly) break;
2612
- }
2613
- }
2614
- } else _addIssue(this, "type", dataset, config$1);
2615
- return dataset;
2616
- }
2617
- });
2618
- }
2619
- __name(object, "object");
2620
- // @__NO_SIDE_EFFECTS__
2621
- function objectWithRest(entries$1, rest, message$1) {
2622
- return _standardSchema({
2623
- kind: "schema",
2624
- type: "object_with_rest",
2625
- reference: objectWithRest,
2626
- expects: "Object",
2627
- async: false,
2628
- entries: entries$1,
2629
- rest,
2630
- message: message$1,
2631
- "~run"(dataset, config$1) {
2632
- const input = dataset.value;
2633
- if (input && typeof input === "object") {
2634
- dataset.typed = true;
2635
- dataset.value = {};
2636
- for (const key in this.entries) {
2637
- const valueSchema = this.entries[key];
2638
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2639
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2640
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2641
- if (valueDataset.issues) {
2642
- const pathItem = {
2643
- type: "object",
2644
- origin: "value",
2645
- input,
2646
- key,
2647
- value: value$1
2648
- };
2649
- for (const issue of valueDataset.issues) {
2650
- if (issue.path) issue.path.unshift(pathItem);
2651
- else issue.path = [pathItem];
2652
- dataset.issues?.push(issue);
2653
- }
2654
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2655
- if (config$1.abortEarly) {
2656
- dataset.typed = false;
2657
- break;
2658
- }
2659
- }
2660
- if (!valueDataset.typed) dataset.typed = false;
2661
- dataset.value[key] = valueDataset.value;
2662
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2663
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2664
- _addIssue(this, "key", dataset, config$1, {
2665
- input: void 0,
2666
- expected: `"${key}"`,
2667
- path: [{
2668
- type: "object",
2669
- origin: "key",
2670
- input,
2671
- key,
2672
- value: input[key]
2673
- }]
2674
- });
2675
- if (config$1.abortEarly) break;
2676
- }
2677
- }
2678
- if (!dataset.issues || !config$1.abortEarly) {
2679
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
2680
- const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
2681
- if (valueDataset.issues) {
2682
- const pathItem = {
2683
- type: "object",
2684
- origin: "value",
2685
- input,
2686
- key,
2687
- value: input[key]
2688
- };
2689
- for (const issue of valueDataset.issues) {
2690
- if (issue.path) issue.path.unshift(pathItem);
2691
- else issue.path = [pathItem];
2692
- dataset.issues?.push(issue);
2693
- }
2694
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2695
- if (config$1.abortEarly) {
2696
- dataset.typed = false;
2697
- break;
2698
- }
2699
- }
2700
- if (!valueDataset.typed) dataset.typed = false;
2701
- dataset.value[key] = valueDataset.value;
2702
- }
2703
- }
2704
- } else _addIssue(this, "type", dataset, config$1);
2705
- return dataset;
2706
- }
2707
- });
2708
- }
2709
- __name(objectWithRest, "objectWithRest");
2710
- // @__NO_SIDE_EFFECTS__
2711
- function optional(wrapped, default_) {
2712
- return _standardSchema({
2713
- kind: "schema",
2714
- type: "optional",
2715
- reference: optional,
2716
- expects: `(${wrapped.expects} | undefined)`,
2717
- async: false,
2718
- wrapped,
2719
- default: default_,
2720
- "~run"(dataset, config$1) {
2721
- if (dataset.value === void 0) {
2722
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
2723
- if (dataset.value === void 0) {
2724
- dataset.typed = true;
2725
- return dataset;
2726
- }
2727
- }
2728
- return this.wrapped["~run"](dataset, config$1);
2729
- }
2730
- });
2731
- }
2732
- __name(optional, "optional");
2733
- // @__NO_SIDE_EFFECTS__
2734
- function picklist(options, message$1) {
2735
- return _standardSchema({
2736
- kind: "schema",
2737
- type: "picklist",
2738
- reference: picklist,
2739
- expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
2740
- async: false,
2741
- options,
2742
- message: message$1,
2743
- "~run"(dataset, config$1) {
2744
- if (this.options.includes(dataset.value)) dataset.typed = true;
2745
- else _addIssue(this, "type", dataset, config$1);
2746
- return dataset;
2747
- }
2748
- });
2749
- }
2750
- __name(picklist, "picklist");
2751
- // @__NO_SIDE_EFFECTS__
2752
- function record(key, value$1, message$1) {
2753
- return _standardSchema({
2754
- kind: "schema",
2755
- type: "record",
2756
- reference: record,
2757
- expects: "Object",
2758
- async: false,
2759
- key,
2760
- value: value$1,
2761
- message: message$1,
2762
- "~run"(dataset, config$1) {
2763
- const input = dataset.value;
2764
- if (input && typeof input === "object") {
2765
- dataset.typed = true;
2766
- dataset.value = {};
2767
- for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
2768
- const entryValue = input[entryKey];
2769
- const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
2770
- if (keyDataset.issues) {
2771
- const pathItem = {
2772
- type: "object",
2773
- origin: "key",
2774
- input,
2775
- key: entryKey,
2776
- value: entryValue
2777
- };
2778
- for (const issue of keyDataset.issues) {
2779
- issue.path = [pathItem];
2780
- dataset.issues?.push(issue);
2781
- }
2782
- if (!dataset.issues) dataset.issues = keyDataset.issues;
2783
- if (config$1.abortEarly) {
2784
- dataset.typed = false;
2785
- break;
2786
- }
2787
- }
2788
- const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
2789
- if (valueDataset.issues) {
2790
- const pathItem = {
2791
- type: "object",
2792
- origin: "value",
2793
- input,
2794
- key: entryKey,
2795
- value: entryValue
2796
- };
2797
- for (const issue of valueDataset.issues) {
2798
- if (issue.path) issue.path.unshift(pathItem);
2799
- else issue.path = [pathItem];
2800
- dataset.issues?.push(issue);
2801
- }
2802
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2803
- if (config$1.abortEarly) {
2804
- dataset.typed = false;
2805
- break;
2806
- }
2807
- }
2808
- if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
2809
- if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
2810
- }
2811
- } else _addIssue(this, "type", dataset, config$1);
2812
- return dataset;
2813
- }
2814
- });
2815
- }
2816
- __name(record, "record");
2817
- // @__NO_SIDE_EFFECTS__
2818
- function strictObject(entries$1, message$1) {
2819
- return _standardSchema({
2820
- kind: "schema",
2821
- type: "strict_object",
2822
- reference: strictObject,
2823
- expects: "Object",
2824
- async: false,
2825
- entries: entries$1,
2826
- message: message$1,
2827
- "~run"(dataset, config$1) {
2828
- const input = dataset.value;
2829
- if (input && typeof input === "object") {
2830
- dataset.typed = true;
2831
- dataset.value = {};
2832
- for (const key in this.entries) {
2833
- const valueSchema = this.entries[key];
2834
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2835
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2836
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2837
- if (valueDataset.issues) {
2838
- const pathItem = {
2839
- type: "object",
2840
- origin: "value",
2841
- input,
2842
- key,
2843
- value: value$1
2844
- };
2845
- for (const issue of valueDataset.issues) {
2846
- if (issue.path) issue.path.unshift(pathItem);
2847
- else issue.path = [pathItem];
2848
- dataset.issues?.push(issue);
2849
- }
2850
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2851
- if (config$1.abortEarly) {
2852
- dataset.typed = false;
2853
- break;
2854
- }
2855
- }
2856
- if (!valueDataset.typed) dataset.typed = false;
2857
- dataset.value[key] = valueDataset.value;
2858
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2859
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2860
- _addIssue(this, "key", dataset, config$1, {
2861
- input: void 0,
2862
- expected: `"${key}"`,
2863
- path: [{
2864
- type: "object",
2865
- origin: "key",
2866
- input,
2867
- key,
2868
- value: input[key]
2869
- }]
2870
- });
2871
- if (config$1.abortEarly) break;
2872
- }
2873
- }
2874
- if (!dataset.issues || !config$1.abortEarly) {
2875
- for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
2876
- _addIssue(this, "key", dataset, config$1, {
2877
- input: key,
2878
- expected: "never",
2879
- path: [{
2880
- type: "object",
2881
- origin: "key",
2882
- input,
2883
- key,
2884
- value: input[key]
2885
- }]
2886
- });
2887
- break;
2888
- }
2889
- }
2890
- } else _addIssue(this, "type", dataset, config$1);
2891
- return dataset;
2892
- }
2893
- });
2894
- }
2895
- __name(strictObject, "strictObject");
2896
- // @__NO_SIDE_EFFECTS__
2897
- function string(message$1) {
2898
- return _standardSchema({
2899
- kind: "schema",
2900
- type: "string",
2901
- reference: string,
2902
- expects: "string",
2903
- async: false,
2904
- message: message$1,
2905
- "~run"(dataset, config$1) {
2906
- if (typeof dataset.value === "string") dataset.typed = true;
2907
- else _addIssue(this, "type", dataset, config$1);
2908
- return dataset;
2909
- }
2910
- });
2911
- }
2912
- __name(string, "string");
2913
- // @__NO_SIDE_EFFECTS__
2914
- function _subIssues(datasets) {
2915
- let issues;
2916
- if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
2917
- else issues = dataset.issues;
2918
- return issues;
2919
- }
2920
- __name(_subIssues, "_subIssues");
2921
- // @__NO_SIDE_EFFECTS__
2922
- function union(options, message$1) {
2923
- return _standardSchema({
2924
- kind: "schema",
2925
- type: "union",
2926
- reference: union,
2927
- expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
2928
- async: false,
2929
- options,
2930
- message: message$1,
2931
- "~run"(dataset, config$1) {
2932
- let validDataset;
2933
- let typedDatasets;
2934
- let untypedDatasets;
2935
- for (const schema of this.options) {
2936
- const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
2937
- if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
2938
- else typedDatasets = [optionDataset];
2939
- else {
2940
- validDataset = optionDataset;
2941
- break;
2942
- }
2943
- else if (untypedDatasets) untypedDatasets.push(optionDataset);
2944
- else untypedDatasets = [optionDataset];
2945
- }
2946
- if (validDataset) return validDataset;
2947
- if (typedDatasets) {
2948
- if (typedDatasets.length === 1) return typedDatasets[0];
2949
- _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
2950
- dataset.typed = true;
2951
- } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
2952
- else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
2953
- return dataset;
2954
- }
2955
- });
2956
- }
2957
- __name(union, "union");
2958
- // @__NO_SIDE_EFFECTS__
2959
- function unknown() {
2960
- return _standardSchema({
2961
- kind: "schema",
2962
- type: "unknown",
2963
- reference: unknown,
2964
- expects: "unknown",
2965
- async: false,
2966
- "~run"(dataset) {
2967
- dataset.typed = true;
2968
- return dataset;
2969
- }
2970
- });
2971
- }
2972
- __name(unknown, "unknown");
2973
- // @__NO_SIDE_EFFECTS__
2974
- function variant(key, options, message$1) {
2975
- return _standardSchema({
2976
- kind: "schema",
2977
- type: "variant",
2978
- reference: variant,
2979
- expects: "Object",
2980
- async: false,
2981
- key,
2982
- options,
2983
- message: message$1,
2984
- "~run"(dataset, config$1) {
2985
- const input = dataset.value;
2986
- if (input && typeof input === "object") {
2987
- let outputDataset;
2988
- let maxDiscriminatorPriority = 0;
2989
- let invalidDiscriminatorKey = this.key;
2990
- let expectedDiscriminators = [];
2991
- const parseOptions = /* @__PURE__ */ __name((variant$1, allKeys) => {
2992
- for (const schema of variant$1.options) {
2993
- if (schema.type === "variant") parseOptions(schema, new Set(allKeys).add(schema.key));
2994
- else {
2995
- let keysAreValid = true;
2996
- let currentPriority = 0;
2997
- for (const currentKey of allKeys) {
2998
- const discriminatorSchema = schema.entries[currentKey];
2999
- if (currentKey in input ? discriminatorSchema["~run"]({
3000
- typed: false,
3001
- value: input[currentKey]
3002
- }, ABORT_EARLY_CONFIG).issues : discriminatorSchema.type !== "exact_optional" && discriminatorSchema.type !== "optional" && discriminatorSchema.type !== "nullish") {
3003
- keysAreValid = false;
3004
- if (invalidDiscriminatorKey !== currentKey && (maxDiscriminatorPriority < currentPriority || maxDiscriminatorPriority === currentPriority && currentKey in input && !(invalidDiscriminatorKey in input))) {
3005
- maxDiscriminatorPriority = currentPriority;
3006
- invalidDiscriminatorKey = currentKey;
3007
- expectedDiscriminators = [];
3008
- }
3009
- if (invalidDiscriminatorKey === currentKey) expectedDiscriminators.push(schema.entries[currentKey].expects);
3010
- break;
3011
- }
3012
- currentPriority++;
3013
- }
3014
- if (keysAreValid) {
3015
- const optionDataset = schema["~run"]({ value: input }, config$1);
3016
- if (!outputDataset || !outputDataset.typed && optionDataset.typed) outputDataset = optionDataset;
3017
- }
3018
- }
3019
- if (outputDataset && !outputDataset.issues) break;
3020
- }
3021
- }, "parseOptions");
3022
- parseOptions(this, /* @__PURE__ */ new Set([this.key]));
3023
- if (outputDataset) return outputDataset;
3024
- _addIssue(this, "type", dataset, config$1, {
3025
- input: input[invalidDiscriminatorKey],
3026
- expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
3027
- path: [{
3028
- type: "object",
3029
- origin: "value",
3030
- input,
3031
- key: invalidDiscriminatorKey,
3032
- value: input[invalidDiscriminatorKey]
3033
- }]
3034
- });
3035
- } else _addIssue(this, "type", dataset, config$1);
3036
- return dataset;
3037
- }
3038
- });
3039
- }
3040
- __name(variant, "variant");
3041
- // @__NO_SIDE_EFFECTS__
3042
- function omit(schema, keys) {
3043
- const entries$1 = { ...schema.entries };
3044
- for (const key of keys) delete entries$1[key];
3045
- return _standardSchema({
3046
- ...schema,
3047
- entries: entries$1
3048
- });
3049
- }
3050
- __name(omit, "omit");
3051
- function parse(schema, input, config$1) {
3052
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
3053
- if (dataset.issues) throw new ValiError(dataset.issues);
3054
- return dataset.value;
3055
- }
3056
- __name(parse, "parse");
3057
- // @__NO_SIDE_EFFECTS__
3058
- function partial(schema, keys) {
3059
- const entries$1 = {};
3060
- for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
3061
- return _standardSchema({
3062
- ...schema,
3063
- entries: entries$1
3064
- });
3065
- }
3066
- __name(partial, "partial");
3067
- // @__NO_SIDE_EFFECTS__
3068
- function pick(schema, keys) {
3069
- const entries$1 = {};
3070
- for (const key of keys) entries$1[key] = schema.entries[key];
3071
- return _standardSchema({
3072
- ...schema,
3073
- entries: entries$1
3074
- });
3075
- }
3076
- __name(pick, "pick");
3077
- // @__NO_SIDE_EFFECTS__
3078
- function pipe(...pipe$1) {
3079
- return _standardSchema({
3080
- ...pipe$1[0],
3081
- pipe: pipe$1,
3082
- "~run"(dataset, config$1) {
3083
- for (const item of pipe$1) if (item.kind !== "metadata") {
3084
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
3085
- dataset.typed = false;
3086
- break;
3087
- }
3088
- if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
3089
- }
3090
- return dataset;
3091
- }
3092
- });
3093
- }
3094
- __name(pipe, "pipe");
3095
- // @__NO_SIDE_EFFECTS__
3096
- function safeParse(schema, input, config$1) {
3097
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
3098
- return {
3099
- typed: dataset.typed,
3100
- success: !dataset.issues,
3101
- output: dataset.value,
3102
- issues: dataset.issues
3103
- };
3104
- }
3105
- __name(safeParse, "safeParse");
3106
- // @__NO_SIDE_EFFECTS__
3107
- function summarize(issues) {
3108
- let summary = "";
3109
- for (const issue of issues) {
3110
- if (summary) summary += "\n";
3111
- summary += `\xD7 ${issue.message}`;
3112
- const dotPath = /* @__PURE__ */ getDotPath(issue);
3113
- if (dotPath) summary += `
3114
- \u2192 at ${dotPath}`;
3115
- }
3116
- return summary;
3117
- }
3118
- __name(summarize, "summarize");
3119
- // @__NO_SIDE_EFFECTS__
3120
- function unwrap(schema) {
3121
- return schema.wrapped;
3122
- }
3123
- __name(unwrap, "unwrap");
3124
-
3125
- // 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
3126
- function addError(errors, message) {
3127
- if (errors) {
3128
- errors.push(message);
3129
- return errors;
3130
- }
3131
- return [message];
3132
- }
3133
- __name(addError, "addError");
3134
- var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
3135
- function escapeRegExp(string2) {
3136
- return string2.replace(ESCAPE_REGEX, "\\$&");
3137
- }
3138
- __name(escapeRegExp, "escapeRegExp");
3139
- function handleError(message, config) {
3140
- switch (config?.errorMode) {
3141
- case "ignore":
3142
- break;
3143
- case "warn":
3144
- console.warn(message);
3145
- break;
3146
- default:
3147
- throw new Error(message);
3148
- }
3149
- }
3150
- __name(handleError, "handleError");
3151
- function isJsonConstValue(value) {
3152
- return typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || typeof value === "string";
3153
- }
3154
- __name(isJsonConstValue, "isJsonConstValue");
3155
- function isJsonEnumValues(values) {
3156
- return values.every(isJsonConstValue);
3157
- }
3158
- __name(isJsonEnumValues, "isJsonEnumValues");
3159
- var ReferenceMap = class extends Map {
3160
- static {
3161
- __name(this, "ReferenceMap");
3162
- }
3163
- /**
3164
- * Creates an empty schema reference map.
3165
- */
3166
- constructor() {
3167
- super();
3168
- this.count = 0;
3169
- this.usedIds = /* @__PURE__ */ new Set();
3170
- }
3171
- /**
3172
- * Adds a schema reference and reserves its ID.
3173
- *
3174
- * @param schema The Valibot schema.
3175
- * @param referenceId The reference ID.
3176
- *
3177
- * @returns The reference map.
3178
- */
3179
- set(schema, referenceId) {
3180
- this.usedIds.add(referenceId);
3181
- return super.set(schema, referenceId);
3182
- }
3183
- /**
3184
- * Creates a reference ID that is not yet used.
3185
- *
3186
- * @param definitions The JSON Schema definitions.
3187
- *
3188
- * @returns The unused reference ID.
3189
- */
3190
- createId(definitions) {
3191
- while (this.usedIds.has(`${this.count}`) || `${this.count}` in definitions) this.count++;
3192
- return `${this.count++}`;
3193
- }
3194
- };
3195
- function getLowerBound(current, value) {
3196
- if (typeof current !== "number" || !Number.isFinite(current) || value > current) return value;
3197
- return current;
3198
- }
3199
- __name(getLowerBound, "getLowerBound");
3200
- function getUpperBound(current, value) {
3201
- if (typeof current !== "number" || !Number.isFinite(current) || value < current) return value;
3202
- return current;
3203
- }
3204
- __name(getUpperBound, "getUpperBound");
3205
- // @__NO_SIDE_EFFECTS__
3206
- function getNotRestriction(current, value) {
3207
- return current !== void 0 ? { anyOf: [current, value] } : value;
3208
- }
3209
- __name(getNotRestriction, "getNotRestriction");
3210
- function intersectEnum(jsonSchema, values) {
3211
- let enumValues = jsonSchema.enum ?? values;
3212
- if (jsonSchema.enum) {
3213
- const valueSet = new Set(values);
3214
- enumValues = enumValues.filter((value) => valueSet.has(value));
3215
- }
3216
- if (enumValues.length) jsonSchema.enum = [...new Set(enumValues)];
3217
- else {
3218
- delete jsonSchema.enum;
3219
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, {});
3220
- }
3221
- }
3222
- __name(intersectEnum, "intersectEnum");
3223
- function convertAction(jsonSchema, valibotAction, config) {
3224
- if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
3225
- let errors;
3226
- switch (valibotAction.type) {
3227
- case "base64":
3228
- jsonSchema.contentEncoding = "base64";
3229
- break;
3230
- case "bic":
3231
- case "cuid2":
3232
- case "decimal":
3233
- case "digits":
3234
- case "domain":
3235
- case "emoji":
3236
- case "hash":
3237
- case "hexadecimal":
3238
- case "hex_color":
3239
- case "isrc":
3240
- case "iso_time_second":
3241
- case "iso_week":
3242
- case "ksuid":
3243
- case "mac":
3244
- case "mac48":
3245
- case "mac64":
3246
- case "nanoid":
3247
- case "octal":
3248
- case "slug":
3249
- case "ulid":
3250
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3251
- else jsonSchema.pattern = valibotAction.requirement.source;
3252
- break;
3253
- case "description":
3254
- jsonSchema.description = valibotAction.description;
3255
- break;
3256
- case "email":
3257
- case "rfc_email":
3258
- jsonSchema.format = "email";
3259
- break;
3260
- case "ends_with":
3261
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3262
- else jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
3263
- break;
3264
- case "empty":
3265
- if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
3266
- else {
3267
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3268
- jsonSchema.maxLength = 0;
3269
- }
3270
- break;
3271
- case "entries":
3272
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3273
- errors = addError(errors, 'The requirement of the "entries" action must be a non-negative integer.');
3274
- break;
3275
- }
3276
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
3277
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
3278
- break;
3279
- case "examples":
3280
- if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples];
3281
- else jsonSchema.examples = valibotAction.examples;
3282
- break;
3283
- case "gt_value":
3284
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3285
- errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
3286
- break;
3287
- }
3288
- if (!Number.isFinite(valibotAction.requirement)) {
3289
- errors = addError(errors, 'The requirement of the "gt_value" action is not JSON compatible.');
3290
- break;
3291
- }
3292
- if (config?.target === "openapi-3.0") {
3293
- errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
3294
- break;
3295
- }
3296
- jsonSchema.exclusiveMinimum = getLowerBound(jsonSchema.exclusiveMinimum, valibotAction.requirement);
3297
- break;
3298
- case "includes":
3299
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3300
- else jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
3301
- break;
3302
- case "integer":
3303
- jsonSchema.type = "integer";
3304
- break;
3305
- case "ipv4":
3306
- jsonSchema.format = "ipv4";
3307
- break;
3308
- case "ipv6":
3309
- jsonSchema.format = "ipv6";
3310
- break;
3311
- case "iso_date":
3312
- jsonSchema.format = "date";
3313
- break;
3314
- case "iso_date_time":
3315
- case "iso_timestamp":
3316
- jsonSchema.format = "date-time";
3317
- break;
3318
- case "iso_time":
3319
- jsonSchema.format = "time";
3320
- break;
3321
- case "jws_compact":
3322
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3323
- else jsonSchema.pattern = valibotAction.requirement.source;
3324
- break;
3325
- case "length":
3326
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3327
- errors = addError(errors, 'The requirement of the "length" action must be a non-negative integer.');
3328
- break;
3329
- }
3330
- if (jsonSchema.type === "array") {
3331
- jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
3332
- jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
3333
- } else {
3334
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3335
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
3336
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
3337
- }
3338
- break;
3339
- case "lt_value":
3340
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3341
- errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
3342
- break;
3343
- }
3344
- if (!Number.isFinite(valibotAction.requirement)) {
3345
- errors = addError(errors, 'The requirement of the "lt_value" action is not JSON compatible.');
3346
- break;
3347
- }
3348
- if (config?.target === "openapi-3.0") {
3349
- errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
3350
- break;
3351
- }
3352
- jsonSchema.exclusiveMaximum = getUpperBound(jsonSchema.exclusiveMaximum, valibotAction.requirement);
3353
- break;
3354
- case "max_entries":
3355
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3356
- errors = addError(errors, 'The requirement of the "max_entries" action must be a non-negative integer.');
3357
- break;
3358
- }
3359
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
3360
- break;
3361
- case "max_length":
3362
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3363
- errors = addError(errors, 'The requirement of the "max_length" action must be a non-negative integer.');
3364
- break;
3365
- }
3366
- if (jsonSchema.type === "array") jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
3367
- else {
3368
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3369
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
3370
- }
3371
- break;
3372
- case "max_value":
3373
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3374
- errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
3375
- break;
3376
- }
3377
- if (!Number.isFinite(valibotAction.requirement)) {
3378
- errors = addError(errors, 'The requirement of the "max_value" action is not JSON compatible.');
3379
- break;
3380
- }
3381
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, valibotAction.requirement);
3382
- break;
3383
- case "metadata":
3384
- if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
3385
- if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
3386
- if (Array.isArray(valibotAction.metadata.examples)) if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples];
3387
- else jsonSchema.examples = valibotAction.metadata.examples;
3388
- for (const key of Object.keys(valibotAction.metadata)) if (key !== "title" && key !== "description" && key !== "examples" && key !== "__proto__") jsonSchema[key] = valibotAction.metadata[key];
3389
- break;
3390
- case "min_entries":
3391
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3392
- errors = addError(errors, 'The requirement of the "min_entries" action must be a non-negative integer.');
3393
- break;
3394
- }
3395
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
3396
- break;
3397
- case "min_length":
3398
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3399
- errors = addError(errors, 'The requirement of the "min_length" action must be a non-negative integer.');
3400
- break;
3401
- }
3402
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
3403
- else {
3404
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3405
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
3406
- }
3407
- break;
3408
- case "min_value":
3409
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3410
- errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
3411
- break;
3412
- }
3413
- if (!Number.isFinite(valibotAction.requirement)) {
3414
- errors = addError(errors, 'The requirement of the "min_value" action is not JSON compatible.');
3415
- break;
3416
- }
3417
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, valibotAction.requirement);
3418
- break;
3419
- case "multiple_of":
3420
- jsonSchema.multipleOf = valibotAction.requirement;
3421
- break;
3422
- case "non_empty":
3423
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, 1);
3424
- else {
3425
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3426
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, 1);
3427
- }
3428
- break;
3429
- case "not_value":
3430
- if (!isJsonConstValue(valibotAction.requirement)) {
3431
- errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
3432
- break;
3433
- }
3434
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, config?.target === "openapi-3.0" ? { enum: [valibotAction.requirement] } : { const: valibotAction.requirement });
3435
- break;
3436
- case "not_values":
3437
- if (!isJsonEnumValues(valibotAction.requirement)) {
3438
- errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
3439
- break;
3440
- }
3441
- if (valibotAction.requirement.length) jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, { enum: [...new Set(valibotAction.requirement)] });
3442
- break;
3443
- case "regex":
3444
- if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
3445
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3446
- else jsonSchema.pattern = valibotAction.requirement.source;
3447
- break;
3448
- case "safe_integer":
3449
- jsonSchema.type = "integer";
3450
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, Number.MIN_SAFE_INTEGER);
3451
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, Number.MAX_SAFE_INTEGER);
3452
- break;
3453
- case "starts_with":
3454
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3455
- else jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
3456
- break;
3457
- case "title":
3458
- jsonSchema.title = valibotAction.title;
3459
- break;
3460
- case "url":
3461
- jsonSchema.format = "uri";
3462
- break;
3463
- case "uuid":
3464
- jsonSchema.format = "uuid";
3465
- break;
3466
- case "value":
3467
- if (!isJsonConstValue(valibotAction.requirement)) {
3468
- errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
3469
- break;
3470
- }
3471
- if (config?.target === "openapi-3.0") intersectEnum(jsonSchema, [valibotAction.requirement]);
3472
- 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.`);
3473
- else jsonSchema.const = valibotAction.requirement;
3474
- break;
3475
- case "values":
3476
- if (!isJsonEnumValues(valibotAction.requirement)) {
3477
- errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
3478
- break;
3479
- }
3480
- intersectEnum(jsonSchema, valibotAction.requirement);
3481
- break;
3482
- default:
3483
- errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
3484
- }
3485
- if (config?.overrideAction) {
3486
- const actionOverride = config.overrideAction({
3487
- valibotAction,
3488
- jsonSchema,
3489
- errors
3490
- });
3491
- if (actionOverride) return { ...actionOverride };
3492
- }
3493
- if (errors) for (const message of errors) handleError(message, config);
3494
- return jsonSchema;
3495
- }
3496
- __name(convertAction, "convertAction");
3497
- function flattenPipe(pipe2) {
3498
- return pipe2.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
3499
- }
3500
- __name(flattenPipe, "flattenPipe");
3501
- function getDefinitionRef(referenceId) {
3502
- return `#/$defs/${referenceId.replaceAll("~", "~0").replaceAll("/", "~1")}`;
3503
- }
3504
- __name(getDefinitionRef, "getDefinitionRef");
3505
- function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
3506
- if (!skipRef) {
3507
- const referenceId = context.referenceMap.get(valibotSchema);
3508
- if (referenceId) {
3509
- jsonSchema.$ref = getDefinitionRef(referenceId);
3510
- if (config?.overrideRef) {
3511
- const refOverride = config.overrideRef({
3512
- ...context,
3513
- referenceId,
3514
- valibotSchema,
3515
- jsonSchema
3516
- });
3517
- if (refOverride) jsonSchema.$ref = refOverride;
3518
- }
3519
- return jsonSchema;
3520
- }
3521
- }
3522
- if ("pipe" in valibotSchema) {
3523
- const flatPipe = flattenPipe(valibotSchema.pipe);
3524
- let startIndex = 0;
3525
- let stopIndex = flatPipe.length - 1;
3526
- if (config?.typeMode === "input") {
3527
- 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"));
3528
- if (inputStopIndex !== -1) stopIndex = inputStopIndex;
3529
- } else if (config?.typeMode === "output") {
3530
- const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
3531
- if (outputStartIndex !== -1) startIndex = outputStartIndex;
3532
- }
3533
- for (let index = startIndex; index <= stopIndex; index++) {
3534
- const valibotPipeItem = flatPipe[index];
3535
- if (valibotPipeItem.kind === "schema") {
3536
- if (index > startIndex) handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config);
3537
- jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
3538
- } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
3539
- }
3540
- return jsonSchema;
3541
- }
3542
- let errors;
3543
- switch (valibotSchema.type) {
3544
- case "boolean":
3545
- jsonSchema.type = "boolean";
3546
- break;
3547
- case "null":
3548
- if (config?.target === "openapi-3.0") jsonSchema.enum = [null];
3549
- else jsonSchema.type = "null";
3550
- break;
3551
- case "number":
3552
- jsonSchema.type = "number";
3553
- break;
3554
- case "string":
3555
- jsonSchema.type = "string";
3556
- break;
3557
- case "array":
3558
- jsonSchema.type = "array";
3559
- jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
3560
- break;
3561
- case "tuple":
3562
- case "tuple_with_rest":
3563
- case "loose_tuple":
3564
- case "strict_tuple":
3565
- jsonSchema.type = "array";
3566
- if (config?.target === "openapi-3.0") {
3567
- jsonSchema.items = { anyOf: [] };
3568
- jsonSchema.minItems = valibotSchema.items.length;
3569
- for (const item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
3570
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context));
3571
- else if (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") jsonSchema.maxItems = valibotSchema.items.length;
3572
- } else if (config?.target === "draft-2020-12") {
3573
- jsonSchema.prefixItems = [];
3574
- jsonSchema.minItems = valibotSchema.items.length;
3575
- for (const item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
3576
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context);
3577
- else if (valibotSchema.type === "strict_tuple") jsonSchema.items = false;
3578
- } else {
3579
- jsonSchema.items = [];
3580
- jsonSchema.minItems = valibotSchema.items.length;
3581
- for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
3582
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
3583
- else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
3584
- }
3585
- break;
3586
- case "object":
3587
- case "object_with_rest":
3588
- case "loose_object":
3589
- case "strict_object":
3590
- jsonSchema.type = "object";
3591
- jsonSchema.properties = {};
3592
- jsonSchema.required = [];
3593
- for (const key in valibotSchema.entries) {
3594
- const entry2 = valibotSchema.entries[key];
3595
- jsonSchema.properties[key] = convertSchema({}, entry2, config, context);
3596
- if (entry2.type !== "exact_optional" && entry2.type !== "nullish" && entry2.type !== "optional") jsonSchema.required.push(key);
3597
- }
3598
- if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
3599
- else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
3600
- break;
3601
- case "record":
3602
- 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.');
3603
- 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.`);
3604
- jsonSchema.type = "object";
3605
- if (config?.target !== "openapi-3.0") jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context);
3606
- jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
3607
- break;
3608
- case "any":
3609
- case "unknown":
3610
- break;
3611
- case "never":
3612
- jsonSchema.not = {};
3613
- break;
3614
- case "nullable":
3615
- case "nullish":
3616
- if (config?.target === "openapi-3.0") {
3617
- const innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
3618
- Object.assign(jsonSchema, innerSchema);
3619
- jsonSchema.nullable = true;
3620
- } else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
3621
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
3622
- break;
3623
- case "exact_optional":
3624
- case "optional":
3625
- case "undefinedable":
3626
- jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
3627
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
3628
- break;
3629
- case "literal":
3630
- if (!isJsonConstValue(valibotSchema.literal)) {
3631
- errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
3632
- break;
3633
- }
3634
- if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotSchema.literal];
3635
- else jsonSchema.const = valibotSchema.literal;
3636
- break;
3637
- case "enum":
3638
- case "picklist": {
3639
- const options = valibotSchema.options;
3640
- if (!options.every((option) => typeof option === "string" || typeof option === "number" && Number.isFinite(option))) {
3641
- errors = addError(errors, `An option of the "${valibotSchema.type}" schema is not JSON compatible.`);
3642
- break;
3643
- }
3644
- jsonSchema.enum = options;
3645
- if (options.every((option) => typeof option === "string")) jsonSchema.type = "string";
3646
- else if (options.every((option) => typeof option === "number")) jsonSchema.type = "number";
3647
- else if (config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
3648
- break;
3649
- }
3650
- case "union":
3651
- jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3652
- break;
3653
- case "variant":
3654
- jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3655
- break;
3656
- case "intersect":
3657
- jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3658
- break;
3659
- case "lazy": {
3660
- let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
3661
- if (!wrappedValibotSchema) {
3662
- wrappedValibotSchema = valibotSchema.getter(void 0);
3663
- context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
3664
- }
3665
- let referenceId = context.referenceMap.get(wrappedValibotSchema);
3666
- if (!referenceId) {
3667
- referenceId = context.referenceMap.createId(context.definitions);
3668
- context.referenceMap.set(wrappedValibotSchema, referenceId);
3669
- context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
3670
- }
3671
- jsonSchema.$ref = getDefinitionRef(referenceId);
3672
- if (config?.overrideRef) {
3673
- const refOverride = config.overrideRef({
3674
- ...context,
3675
- referenceId,
3676
- valibotSchema: wrappedValibotSchema,
3677
- jsonSchema
3678
- });
3679
- if (refOverride) jsonSchema.$ref = refOverride;
3680
- }
3681
- break;
3682
- }
3683
- default:
3684
- errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
3685
- }
3686
- if (config?.overrideSchema) {
3687
- const schemaOverride = config.overrideSchema({
3688
- ...context,
3689
- referenceId: context.referenceMap.get(valibotSchema),
3690
- valibotSchema,
3691
- jsonSchema,
3692
- errors
3693
- });
3694
- if (schemaOverride) return { ...schemaOverride };
3695
- }
3696
- if (errors) for (const message of errors) handleError(message, config);
3697
- return jsonSchema;
3698
- }
3699
- __name(convertSchema, "convertSchema");
3700
- var store;
3701
- function getGlobalDefs() {
3702
- return store;
3703
- }
3704
- __name(getGlobalDefs, "getGlobalDefs");
3705
- function toJsonSchema(schema, config) {
3706
- const context = {
3707
- definitions: {},
3708
- referenceMap: new ReferenceMap(),
3709
- getterMap: /* @__PURE__ */ new Map()
3710
- };
3711
- const definitions = config?.definitions ?? getGlobalDefs();
3712
- if (definitions) {
3713
- for (const key in definitions) context.referenceMap.set(definitions[key], key);
3714
- for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
3715
- }
3716
- const jsonSchema = convertSchema({}, schema, config, context);
3717
- const target = config?.target ?? "draft-07";
3718
- if (target === "draft-2020-12") jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema";
3719
- else if (target === "draft-07") jsonSchema.$schema = "http://json-schema.org/draft-07/schema#";
3720
- if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
3721
- return jsonSchema;
3722
- }
3723
- __name(toJsonSchema, "toJsonSchema");
3724
- var SUPPORTED_TARGETS = [
3725
- "draft-07",
3726
- "draft-2020-12",
3727
- "openapi-3.0"
3728
- ];
3729
- function toStandardJsonSchema(schema) {
3730
- return { "~standard": {
3731
- ...schema["~standard"],
3732
- jsonSchema: {
3733
- input(options) {
3734
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
3735
- typeMode: "input",
3736
- target: options.target,
3737
- ...options.libraryOptions
3738
- });
3739
- throw new Error(`Unsupported target: ${options.target}`);
3740
- },
3741
- output(options) {
3742
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
3743
- typeMode: "output",
3744
- target: options.target,
3745
- ...options.libraryOptions
3746
- });
3747
- throw new Error(`Unsupported target: ${options.target}`);
3748
- }
3749
- }
3750
- } };
3751
- }
3752
- __name(toStandardJsonSchema, "toStandardJsonSchema");
3753
-
3754
- // 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
3755
- var word = pipe(string(), regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "a lower-case word, words joined by -"));
3756
- var SNAKE_CASE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
3757
- var text = pipe(string(), regex(/\S/, "must not be empty"));
3758
- var dottedId = pipe(string(), regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/, "dotted lower-case words, such as `page.next`"));
3759
- var RegistryError = class extends Error {
3760
- static {
3761
- __name(this, "RegistryError");
3762
- }
3763
- registry;
3764
- problems;
3765
- constructor(registry, problems) {
3766
- super(`${registry} registry: ${problems.join("; ")}`);
3767
- this.registry = registry;
3768
- this.problems = problems;
3769
- this.name = "RegistryError";
3770
- }
3771
- };
3772
- var issuesOf = /* @__PURE__ */ __name((issues) => issues.map((issue) => {
3773
- const path = getDotPath(issue);
3774
- return path ? `${path}: ${issue.message}` : issue.message;
3775
- }), "issuesOf");
3776
- var parseRegistry = /* @__PURE__ */ __name((registry, schema, input, check2 = () => []) => {
3777
- const parsed = safeParse(schema, input);
3778
- if (!parsed.success)
3779
- throw new RegistryError(registry, issuesOf(parsed.issues));
3780
- const problems = check2(parsed.output);
3781
- if (problems.length > 0)
3782
- throw new RegistryError(registry, problems);
3783
- return parsed.output;
3784
- }, "parseRegistry");
3785
- var duplicates = /* @__PURE__ */ __name((values) => [...new Set(values.filter((value, index) => values.indexOf(value) !== index))].sort(), "duplicates");
3786
- var jsonSchemaOf = /* @__PURE__ */ __name((schema, definitions) => toJsonSchema(schema, { target: "draft-2020-12", ...definitions ? { definitions } : {} }), "jsonSchemaOf");
3787
- var PLACEHOLDER = /\{([a-z][a-z0-9]*(?:_[a-z0-9]+)*)\}/g;
3788
- var placeholders = /* @__PURE__ */ __name((template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1] ?? ""), "placeholders");
3789
- var fill = /* @__PURE__ */ __name((template, values) => template.replace(PLACEHOLDER, (_, name) => {
3790
- const value = values[name];
3791
- if (value === void 0)
3792
- throw new Error(`no value for {${name}} in "${template}"`);
3793
- return String(value);
3794
- }), "fill");
3795
-
3796
- // 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
3797
- var EXIT_CODES = {
3798
- validation_error: 2,
3799
- configuration_error: 3,
3800
- authentication_error: 4,
3801
- permission_error: 5,
3802
- not_found: 6,
3803
- confirmation_required: 7,
3804
- rate_limited: 8,
3805
- timeout: 9,
3806
- network_error: 10,
3807
- provider_error: 11,
3808
- provider_unavailable: 12,
3809
- invalid_response: 13,
3810
- outcome_unknown: 14,
3811
- cancelled: 130
3812
- };
3813
- var exitCodeFor = /* @__PURE__ */ __name((code) => EXIT_CODES[code], "exitCodeFor");
3814
- var GENERIC_FAILURE = 1;
3815
-
3816
- // 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
3817
- var CONTROL = (
3818
- // biome-ignore lint/suspicious/noControlCharactersInRegex: matching them is the whole point
3819
- /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u200B\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF\u{E0000}-\u{E007F}]/gu
3820
- );
3821
- var SUBDIVISION_FLAG = /\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}/gu;
3822
- var LINE_BREAKS = /[\t\n\u2028\u2029]/g;
3823
- var escaped = /* @__PURE__ */ __name((c) => {
3824
- const code = c.codePointAt(0) ?? 0;
3825
- if (code > 65535)
3826
- return `\\u{${code.toString(16)}}`;
3827
- return code > 255 ? `\\u${code.toString(16).padStart(4, "0")}` : `\\x${code.toString(16).padStart(2, "0")}`;
3828
- }, "escaped");
3829
- var visibleControls = /* @__PURE__ */ __name((text2) => {
3830
- let at = 0;
3831
- let result = "";
3832
- for (const flag of text2.matchAll(SUBDIVISION_FLAG)) {
3833
- result += text2.slice(at, flag.index).replace(CONTROL, escaped) + flag[0];
3834
- at = flag.index + flag[0].length;
3835
- }
3836
- return result + text2.slice(at).replace(CONTROL, escaped);
3837
- }, "visibleControls");
3838
- var singleLine = /* @__PURE__ */ __name((text2) => visibleControls(text2).replace(LINE_BREAKS, escaped), "singleLine");
3839
-
3840
- // 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
3841
- var EFFECT_LEVELS = ["none", "read", "write"];
3842
- var effectsSchema = strictObject({
3843
- remote: picklist(EFFECT_LEVELS),
3844
- local: picklist(EFFECT_LEVELS)
3845
- });
3846
- var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
3847
-
3848
- // 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
3849
- var MAX_NEXT_STEPS = 2;
3850
- var COMPACT_FLAG = "--compact";
3851
- var isoTime = pipe(string(), isoTimestamp("an ISO 8601 time in UTC"), endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"));
3852
- 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"));
3853
- var reference = pipe(string(), regex(/^[a-z]+:\S+$/, "a reference such as `note:42`"));
3854
- var nextStepSchema = variant("kind", [
3855
- strictObject({
3856
- kind: literal("command"),
3857
- step: dottedId,
3858
- /** The command path as one string, `messages list` — what the MCP router tools take as `command`. */
3859
- command: text,
3860
- args: record(string(), unknown()),
3861
- /**
3862
- * The whole line to type, with the tool and the profile it ran with: `tg personal mcp config`. Only the CLI
3863
- * knows the profile, so it fills this; MCP answers leave it out.
3864
- */
3865
- line: optional(text),
3866
- why: text,
3867
- /** True only when the target command is known to write nothing, here or at the provider. */
3868
- safe_to_auto_execute: boolean()
3869
- }),
3870
- /** Something only the person can do — sign in on the phone, approve a device. */
3871
- strictObject({
3872
- kind: literal("user_action"),
3873
- step: dottedId,
3874
- why: text,
3875
- safe_to_auto_execute: literal(false)
3876
- })
3877
- ]);
3878
- var missingSchema = strictObject({
3879
- field: text,
3880
- why: text,
3881
- /** Left out when there is nothing to run that would fill the field. */
3882
- step: optional(dottedId)
3883
- });
3884
- var limit = pipe(number(), integer(), minValue(1));
3885
- var totalSchema = strictObject({
3886
- value: pipe(number(), integer(), minValue(0)),
3887
- relation: picklist(["eq", "gte"])
3888
- });
3889
- var pageSchema = variant("mode", [
3890
- strictObject({
3891
- mode: literal("page"),
3892
- limit,
3893
- has_more: boolean(),
3894
- next_page: optional(pipe(number(), integer(), minValue(2))),
3895
- total: optional(totalSchema)
3896
- }),
3897
- strictObject({
3898
- mode: literal("cursor"),
3899
- limit,
3900
- has_more: boolean(),
3901
- next_cursor: optional(text),
3902
- total: optional(totalSchema)
3903
- })
3904
- ]);
3905
- var issueSchema = strictObject({
3906
- code: picklist(errorCodes),
3907
- reason: optional(dottedId),
3908
- /** The account, provider or source that is missing from the answer. */
3909
- source: text
3910
- });
3911
- var metaSchema = strictObject({
3912
- run_id: text,
3913
- duration_ms: pipe(number(), integer(), minValue(0)),
3914
- accounts: optional(array(text)),
3915
- complete: boolean(),
3916
- issues: optional(array(issueSchema)),
3917
- truncated: optional(boolean()),
3918
- timezone: optional(text),
3919
- /** When the command answered, for an agent that plans from "now" (WC-TIME-7); `timezone` names the zone of `now_local`. */
3920
- now: optional(isoTime),
3921
- now_local: optional(localTime),
3922
- window: optional(strictObject({ since: optional(isoTime), until: optional(isoTime) }))
3923
- });
3924
- var nextSteps = optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS)));
3925
- var listEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
3926
- items: array(item),
3927
- page: pageSchema,
3928
- next: nextSteps,
3929
- missing: optional(array(missingSchema)),
3930
- meta: metaSchema
3931
- }), "listEnvelopeSchema");
3932
- var itemEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
3933
- item,
3934
- next: nextSteps,
3935
- missing: optional(array(missingSchema)),
3936
- meta: metaSchema
3937
- }), "itemEnvelopeSchema");
3938
- var jsonlEndSchema = strictObject({
3939
- type: literal("end"),
3940
- complete: boolean(),
3941
- issues: optional(array(issueSchema)),
3942
- page: pageSchema
3943
- });
3944
- var jsonlOf = /* @__PURE__ */ __name(({ items, page, meta }) => [
3945
- ...items.map((data) => JSON.stringify({ type: "item", data })),
3946
- JSON.stringify({ type: "end", complete: meta.complete, ...meta.issues ? { issues: meta.issues } : {}, page })
3947
- ].join("\n"), "jsonlOf");
3948
-
3949
- // 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
3950
- var CRASH_CODE = "internal_error";
3951
- var CRASH_REASON = "command.crashed";
3952
- var errorObjectSchema = strictObject({
3953
- error: strictObject({
3954
- code: picklist([...errorCodes, CRASH_CODE]),
3955
- reason: dottedId,
3956
- message: text,
3957
- /** The option or argument at fault. */
3958
- param: optional(text),
3959
- details: optional(record(string(), unknown())),
3960
- next: optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS))),
3961
- /** Whether running the same command again may work and cannot do harm; never for a write that may have landed. */
3962
- retry: strictObject({
3963
- safe: boolean(),
3964
- after_ms: optional(pipe(number(), integer(), minValue(0)))
3965
- }),
3966
- /** Optional until every CLI keeps a run for each failure. */
3967
- run_id: optional(text)
3968
- })
3969
- });
3970
- var reasonSchema = strictObject({
3971
- reason: dottedId,
3972
- code: picklist([...errorCodes, CRASH_CODE]),
3973
- /** `{name}` placeholders, each one of `details`. */
3974
- message: pipe(text, maxLength(120)),
3975
- details: array(pipe(string(), regex(SNAKE_CASE, "a snake_case key"))),
3976
- step: optional(dottedId)
3977
- });
3978
- var defineReasons = /* @__PURE__ */ __name((input) => parseRegistry("error reasons", array(reasonSchema), input, (reasons) => [
3979
- ...duplicates(reasons.map((entry2) => entry2.reason)).map((reason) => `"${reason}" is listed twice`),
3980
- ...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`))
3981
- ]), "defineReasons");
3982
- var COMMON_DETAILS = ["attempts", "status", "request_id", "operation", "operation_id"];
3983
- var BASE_REASONS = defineReasons([
3984
- { reason: "input.invalid", code: "validation_error", message: "the input is not valid", details: [] },
3985
- {
3986
- reason: "batch.read-budget",
3987
- code: "validation_error",
3988
- message: "batch stored-text read budget exhausted",
3989
- details: []
3990
- },
3991
- { reason: "batch.output-budget", code: "validation_error", message: "batch output budget exhausted", details: [] },
3992
- { reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
3993
- { reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
3994
- { reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
3995
- { reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
3996
- {
3997
- reason: "tool.not-installed",
3998
- code: "not_found",
3999
- message: "no wcat-<name> program by that name is on PATH",
4000
- details: ["tool", "installed"]
4001
- },
4002
- {
4003
- reason: "confirmation.required",
4004
- code: "confirmation_required",
4005
- message: "this changes something; confirm it",
4006
- details: []
4007
- },
4008
- { reason: "provider.rate-limited", code: "rate_limited", message: "too many requests; wait", details: [] },
4009
- { reason: "command.timed-out", code: "timeout", message: "the command took too long", details: ["timeout_ms"] },
4010
- { reason: "network.failed", code: "network_error", message: "the network did not answer", details: [] },
4011
- { reason: "provider.refused", code: "provider_error", message: "the provider refused", details: [] },
4012
- { reason: "provider.unavailable", code: "provider_unavailable", message: "the provider is down", details: [] },
4013
- {
4014
- reason: "provider.invalid-response",
4015
- code: "invalid_response",
4016
- message: "the answer could not be read",
4017
- details: []
4018
- },
4019
- {
4020
- reason: "output.too-large",
4021
- code: "invalid_response",
4022
- message: "the output is over {max_bytes} bytes",
4023
- details: ["max_bytes", "buffered_bytes", "partial_output"]
4024
- },
4025
- {
4026
- reason: "output.fields-unavailable",
4027
- code: "invalid_response",
4028
- message: "fields can be picked only from whole JSON values",
4029
- details: []
4030
- },
4031
- { reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
4032
- { reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
4033
- { reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] }
4034
- ]);
4035
-
4036
- // 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
4037
- var SAME_COMMAND = "*";
4038
- var commandPath = pipe(string(), regex(/^[a-z][a-z0-9-]*( [a-z][a-z0-9-]*)*$/, "a command path such as `messages sync`"));
4039
- var stepSchema = union([
4040
- strictObject({
4041
- id: dottedId,
4042
- kind: optional(literal("command"), "command"),
4043
- command: union([literal(SAME_COMMAND), commandPath]),
4044
- args: array(strictObject({
4045
- name: pipe(string(), regex(SNAKE_CASE, "an argument or option name in snake_case")),
4046
- required: boolean()
4047
- })),
4048
- why: pipe(text, maxLength(120))
4049
- }),
4050
- strictObject({ id: dottedId, kind: literal("user_action"), why: pipe(text, maxLength(120)) })
4051
- ]);
4052
- var argsOf = /* @__PURE__ */ __name((step) => step.kind === "command" ? step.args : [], "argsOf");
4053
- var defineSteps = /* @__PURE__ */ __name((input) => parseRegistry("steps", array(stepSchema), input, (steps) => [
4054
- ...duplicates(steps.map((step) => step.id)).map((id) => `"${id}" is listed twice`),
4055
- ...steps.flatMap((step) => duplicates(argsOf(step).map((arg) => arg.name)).map((name) => `${step.id}: argument "${name}" is listed twice`))
4056
- ]), "defineSteps");
4057
- var BINDS = /^[^\p{Cc}\u2028\u2029]*$/u;
4058
- var binds = /* @__PURE__ */ __name((value) => typeof value === "number" || typeof value === "boolean" || typeof value === "string" && BINDS.test(value), "binds");
4059
- var stepOf = /* @__PURE__ */ __name((definition, input = {}) => {
4060
- const args = input.args ?? {};
4061
- if (definition.kind === "user_action")
4062
- return {
4063
- kind: "user_action",
4064
- step: definition.id,
4065
- why: fill(definition.why, { ...input.values }),
4066
- safe_to_auto_execute: false
4067
- };
4068
- const command = definition.command === SAME_COMMAND ? input.command : definition.command;
4069
- if (!command)
4070
- throw new Error(`${definition.id}: the step runs the same command, so pass the command`);
4071
- const known = new Set(definition.args.map((arg) => arg.name));
4072
- if (definition.command !== SAME_COMMAND) {
4073
- for (const name of Object.keys(args))
4074
- if (!known.has(name))
4075
- throw new Error(`${definition.id}: no argument "${name}"`);
4076
- }
4077
- for (const arg of definition.args)
4078
- if (arg.required && args[arg.name] === void 0)
4079
- throw new Error(`${definition.id}: argument "${arg.name}" is required`);
4080
- for (const [name, value] of Object.entries(args))
4081
- if (!(Array.isArray(value) ? value.every(binds) : binds(value)))
4082
- throw new Error(`${definition.id}: "${name}" is not a value an option takes`);
4083
- const target = input.targets?.(command);
4084
- if (input.targets && !target)
4085
- throw new Error(`${definition.id}: no command "${command}"`);
4086
- const names = new Set(target?.names ?? []);
4087
- if (target) {
4088
- for (const name of Object.keys(args))
4089
- if (!names.has(name))
4090
- throw new Error(`${definition.id}: "${command}" takes no "${name}"`);
4091
- }
4092
- const scalars = Object.fromEntries(Object.entries(args).filter((entry2) => ["string", "number"].includes(typeof entry2[1])));
4093
- return {
4094
- kind: "command",
4095
- step: definition.id,
4096
- command,
4097
- args: { ...args },
4098
- why: fill(definition.why, { ...scalars, ...input.values }),
4099
- safe_to_auto_execute: target?.effects !== void 0 && !writes(target.effects)
4100
- };
4101
- }, "stepOf");
4102
- var STEPS = defineSteps([
4103
- {
4104
- id: "page.next",
4105
- command: SAME_COMMAND,
4106
- args: [
4107
- { name: "cursor", required: false },
4108
- { name: "page", required: false },
4109
- { name: "limit", required: false }
4110
- ],
4111
- why: "{shown} shown, more exist"
4112
- }
4113
- ]);
4114
-
4115
- // 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
4116
- var recognise = /* @__PURE__ */ __name((failure) => {
4117
- if (isCliError(failure))
4118
- return failure;
4119
- if (!(failure instanceof Error) || failure.name !== "CliError")
4120
- return void 0;
4121
- const { code, details } = failure;
4122
- if (!errorCodes.includes(code))
4123
- return void 0;
4124
- return {
4125
- code,
4126
- message: failure.message,
4127
- details: typeof details === "object" && details !== null ? details : {}
4128
- };
4129
- }, "recognise");
4130
- 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.
4131
- BASE_REASONS.find((entry2) => entry2.code === code), "reasonFor");
4132
- var nextFor = /* @__PURE__ */ __name((reason, details, context) => {
4133
- const definition = reason.step ? context.steps?.find((step) => step.id === reason.step) : void 0;
4134
- if (!definition)
4135
- return [];
4136
- const known = new Set(definition.kind === "command" ? definition.args.map((arg) => arg.name) : []);
4137
- const args = Object.fromEntries(Object.entries(details).filter(([key, value]) => known.has(key) && value !== void 0));
4138
- try {
4139
- return [stepOf(definition, { args, ...context.targets ? { targets: context.targets } : {} })];
4140
- } catch {
4141
- return [];
4142
- }
4143
- }, "nextFor");
4144
- var TRANSIENT = [
4145
- "rate_limited",
4146
- "timeout",
4147
- "network_error",
4148
- "provider_unavailable"
4149
- ];
4150
- var retryOf = /* @__PURE__ */ __name((code, details, effects) => {
4151
- const transient = details.retryable !== false && (TRANSIENT.includes(code) || code === "provider_error" && details.retryable === true);
4152
- const safe = code !== "outcome_unknown" && transient && (!writes(effects) || details.sent === false);
4153
- const after = details.retry_after_ms;
4154
- return safe && typeof after === "number" && Number.isInteger(after) && after >= 0 ? { safe, after_ms: after } : { safe };
4155
- }, "retryOf");
4156
- var errorObjectOf = /* @__PURE__ */ __name((failure, context = {}) => {
4157
- const reasons = context.reasons ?? [];
4158
- const recognised = recognise(failure);
4159
- if (!recognised) {
4160
- const reason2 = reasonFor(CRASH_CODE, CRASH_REASON, reasons);
4161
- return {
4162
- error: {
4163
- code: CRASH_CODE,
4164
- reason: reason2.reason,
4165
- message: reason2.message,
4166
- retry: { safe: false },
4167
- ...context.runId ? { run_id: context.runId } : {}
4168
- }
4169
- };
4170
- }
4171
- const { code, message, details } = recognised;
4172
- const reason = reasonFor(code, details.reason, reasons);
4173
- const allowed = /* @__PURE__ */ new Set([...COMMON_DETAILS, ...context.details ?? [], ...reason.details]);
4174
- allowed.delete("cause");
4175
- const kept = Object.fromEntries(Object.entries(details).filter(([key, value]) => allowed.has(key) && value !== void 0));
4176
- const next = nextFor(reason, details, context);
4177
- const runId = context.runId ?? (typeof details.run_id === "string" ? details.run_id : void 0);
4178
- return {
4179
- error: {
4180
- code,
4181
- reason: reason.reason,
4182
- message,
4183
- ...typeof details.param === "string" ? { param: details.param } : {},
4184
- ...Object.keys(kept).length > 0 ? { details: kept } : {},
4185
- ...next.length > 0 ? { next } : {},
4186
- retry: retryOf(code, details, context.effects),
4187
- ...runId ? { run_id: runId } : {}
4188
- }
4189
- };
4190
- }, "errorObjectOf");
4191
- var exitCodeOfError = /* @__PURE__ */ __name(({ error }) => error.code === CRASH_CODE ? GENERIC_FAILURE : EXIT_CODES[error.code], "exitCodeOfError");
4192
- var exitCodeOfAnswer = /* @__PURE__ */ __name((meta, partial2 = false) => {
4193
- if (meta.complete || partial2)
4194
- return 0;
4195
- const code = meta.issues?.[0]?.code;
4196
- return code === void 0 ? GENERIC_FAILURE : EXIT_CODES[code];
4197
- }, "exitCodeOfAnswer");
4198
- var kebab = /* @__PURE__ */ __name((name) => name.replaceAll("_", "-"), "kebab");
4199
- var commandLine = /* @__PURE__ */ __name((cli, step) => [
4200
- cli,
4201
- step.command,
4202
- ...Object.entries(step.args).map(([name, value]) => value === true ? `--${kebab(name)}` : `--${kebab(name)} ${JSON.stringify(value)}`)
4203
- ].join(" "), "commandLine");
4204
- var STACK_FRAMES = 10;
4205
- var errorRecordOf = /* @__PURE__ */ __name((failure, object3, options) => {
4206
- const thrown = failure instanceof Error ? failure : void 0;
4207
- const { cause, ...details } = recognise(failure)?.details ?? {};
4208
- const stack = thrown?.stack?.split("\n").slice(1, STACK_FRAMES + 1).map((line) => visibleControls(line.trim()));
4209
- const reason = thrown?.cause ?? cause;
4210
- return {
4211
- time: (options.time ?? /* @__PURE__ */ new Date()).toISOString(),
4212
- severity: "error",
4213
- body: "command.failed",
4214
- ...object3.error.run_id ? { run_id: object3.error.run_id } : {},
4215
- command: options.command,
4216
- attributes: {
4217
- code: object3.error.code,
4218
- reason: object3.error.reason,
4219
- message: object3.error.message,
4220
- ...Object.keys(details).length > 0 ? { details } : {},
4221
- ...thrown ? { name: thrown.name, thrown_message: visibleControls(thrown.message) } : { thrown: String(failure) },
4222
- ...reason === void 0 ? {} : { cause: visibleControls(reason instanceof Error ? reason.message : String(reason)) },
4223
- ...stack && stack.length > 0 ? { stack } : {}
4224
- },
4225
- resource: { service: options.service, version: options.version }
4226
- };
4227
- }, "errorRecordOf");
4228
- var renderError = /* @__PURE__ */ __name((object3, options) => {
4229
- if (!options.interactive)
4230
- return [JSON.stringify(object3), ...options.record ? [JSON.stringify(options.record)] : []].join("\n");
4231
- const { message, next, run_id: runId } = object3.error;
4232
- const step = next?.[0];
4233
- return [
4234
- `\u2717 ${visibleControls(message)}`,
4235
- ...step?.kind === "command" ? [`\u2192 ${visibleControls(step.why)}: ${visibleControls(step.line ?? commandLine(options.cli, step))}`] : step ? [`\u2192 ${visibleControls(step.why)}`] : [],
4236
- ...options.record ? [JSON.stringify(options.record, null, 2)] : runId ? [`details: ${options.cli} runs show ${runId}`] : []
4237
- ].join("\n");
4238
- }, "renderError");
4239
- var mcpErrorResult = /* @__PURE__ */ __name((object3) => ({
4240
- content: [{ type: "text", text: JSON.stringify(object3) }],
4241
- structuredContent: object3,
4242
- isError: true
4243
- }), "mcpErrorResult");
4244
- var catchCrashes = /* @__PURE__ */ __name((options) => {
4245
- const target = options.target ?? process;
4246
- const write = options.write ?? ((text2) => process.stderr.write(`${text2}
4247
- `));
4248
- const exit = options.exit ?? ((code) => process.exit(code));
4249
- const crashed = /* @__PURE__ */ __name((failure) => {
4250
- const object3 = errorObjectOf(failure, options);
4251
- write(renderError(object3, { cli: options.cli, interactive: options.interactive }));
4252
- exit(exitCodeOfError(object3));
4253
- }, "crashed");
4254
- target.on("uncaughtException", crashed);
4255
- target.on("unhandledRejection", crashed);
4256
- return () => {
4257
- target.off("uncaughtException", crashed);
4258
- target.off("unhandledRejection", crashed);
4259
- };
4260
- }, "catchCrashes");
4261
-
4262
1899
  // 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
4263
1900
  import { homedir, userInfo } from "node:os";
4264
1901
  import { join, posix, win32 } from "node:path";
@@ -4501,14 +2138,14 @@ var fieldsOf = /* @__PURE__ */ __name((value) => {
4501
2138
  validate(paths);
4502
2139
  return [...new Set(paths)];
4503
2140
  }, "fieldsOf");
4504
- var object2 = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "object");
2141
+ var object = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "object");
4505
2142
  var retained = /* @__PURE__ */ new Set(["operation_id", "page", "next", "missing", "meta", "coverage"]);
4506
2143
  var itemPaths = /* @__PURE__ */ __name((paths) => paths.map((path) => path.startsWith("items.") ? path.slice(6) : path), "itemPaths");
4507
2144
  var onePaths = /* @__PURE__ */ __name((paths) => paths.map((path) => path.startsWith("item.") ? path.slice(5) : path), "onePaths");
4508
2145
  var select = /* @__PURE__ */ __name((value, paths) => {
4509
2146
  if (Array.isArray(value))
4510
2147
  return value.map((item) => select(item, paths));
4511
- if (!object2(value))
2148
+ if (!object(value))
4512
2149
  return value;
4513
2150
  const result = {};
4514
2151
  const groups = /* @__PURE__ */ new Map();
@@ -4526,9 +2163,9 @@ var select = /* @__PURE__ */ __name((value, paths) => {
4526
2163
  const found = value[key];
4527
2164
  if (children.includes(""))
4528
2165
  result[key] = found;
4529
- else if (object2(found) || Array.isArray(found)) {
2166
+ else if (object(found) || Array.isArray(found)) {
4530
2167
  const selected = select(found, children);
4531
- if (Array.isArray(selected) || object2(selected) && Object.keys(selected).length > 0)
2168
+ if (Array.isArray(selected) || object(selected) && Object.keys(selected).length > 0)
4532
2169
  result[key] = selected;
4533
2170
  }
4534
2171
  }
@@ -4540,15 +2177,15 @@ var select = /* @__PURE__ */ __name((value, paths) => {
4540
2177
  var project = /* @__PURE__ */ __name((value, fields) => {
4541
2178
  if (Array.isArray(value))
4542
2179
  return value.map((item) => select(item, itemPaths(fields)));
4543
- if (object2(value) && Object.hasOwn(value, "type") && value.type === "item" && Object.hasOwn(value, "data") && Object.keys(value).every((key) => ["type", "data"].includes(key)))
2180
+ if (object(value) && Object.hasOwn(value, "type") && value.type === "item" && Object.hasOwn(value, "data") && Object.keys(value).every((key) => ["type", "data"].includes(key)))
4544
2181
  return { ...value, data: project(value.data, fields) };
4545
- if (object2(value) && Object.hasOwn(value, "type") && value.type === "end" && Object.hasOwn(value, "complete") && typeof value.complete === "boolean")
2182
+ if (object(value) && Object.hasOwn(value, "type") && value.type === "end" && Object.hasOwn(value, "complete") && typeof value.complete === "boolean")
4546
2183
  return value;
4547
- if (object2(value) && Object.hasOwn(value, "item") && (Object.hasOwn(value, "meta") || Object.keys(value).every((key) => ["item", "next", "missing"].includes(key))))
2184
+ if (object(value) && Object.hasOwn(value, "item") && (Object.hasOwn(value, "meta") || Object.keys(value).every((key) => ["item", "next", "missing"].includes(key))))
4548
2185
  return { ...value, item: project(value.item, onePaths(fields)) };
4549
- if (object2(value) && Array.isArray(value.items))
2186
+ if (object(value) && Array.isArray(value.items))
4550
2187
  return { ...value, items: value.items.map((item) => select(item, itemPaths(fields))) };
4551
- return select(value, object2(value) && !Object.hasOwn(value, "items") ? itemPaths(fields) : fields);
2188
+ return select(value, object(value) && !Object.hasOwn(value, "items") ? itemPaths(fields) : fields);
4552
2189
  }, "project");
4553
2190
  var projectFields = /* @__PURE__ */ __name((value, fields) => {
4554
2191
  validate(fields);
@@ -4567,7 +2204,7 @@ function invalid(message) {
4567
2204
  throw new CliError("validation_error", message);
4568
2205
  }
4569
2206
  __name(invalid, "invalid");
4570
- var limit2 = /* @__PURE__ */ __name((value, maximum, name) => {
2207
+ var limit = /* @__PURE__ */ __name((value, maximum, name) => {
4571
2208
  if (!Number.isSafeInteger(value) || value < 1 || value > maximum)
4572
2209
  invalid(`invalid batch ${name} limit`);
4573
2210
  return value;
@@ -4591,13 +2228,13 @@ var prepareBatch = /* @__PURE__ */ __name((input, handlers) => {
4591
2228
  invalid("batch takes 1\u201332 requests");
4592
2229
  const ids = /* @__PURE__ */ new Set();
4593
2230
  return requests.map((request) => {
4594
- 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")))
2231
+ 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")))
4595
2232
  invalid("each batch request needs a unique id, registered command path and string args array");
4596
2233
  const id = request.id;
4597
2234
  const command = [...request.command];
4598
2235
  const args = request.args;
4599
2236
  ids.add(id);
4600
- const handler = handlers.find((entry2) => entry2.command.length === command.length && entry2.command.every((word2, i) => word2 === command[i]));
2237
+ const handler = handlers.find((entry2) => entry2.command.length === command.length && entry2.command.every((word, i) => word === command[i]));
4601
2238
  if (!handler)
4602
2239
  invalid(`unsupported batch command: ${command.join(" ")}`);
4603
2240
  return { id, command, operation: handler.prepare(args) };
@@ -4628,15 +2265,15 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4628
2265
  invalid("batch takes 1\u201332 requests");
4629
2266
  if (options.fields)
4630
2267
  projectFields({}, options.fields);
4631
- const maxReadBytes = limit2(options.maxReadBytes ?? BATCH_LIMITS.read_bytes, BATCH_LIMITS.read_bytes, "read");
4632
- const maxOutputBytes = limit2(options.maxOutputBytes ?? BATCH_LIMITS.output_bytes, BATCH_LIMITS.output_bytes, "output");
2268
+ const maxReadBytes = limit(options.maxReadBytes ?? BATCH_LIMITS.read_bytes, BATCH_LIMITS.read_bytes, "read");
2269
+ const maxOutputBytes = limit(options.maxOutputBytes ?? BATCH_LIMITS.output_bytes, BATCH_LIMITS.output_bytes, "output");
4633
2270
  if (maxOutputBytes < 8192 + requests.length * 2048)
4634
2271
  invalid("batch output budget cannot hold its result framing");
4635
2272
  const errorOf = /* @__PURE__ */ __name((error) => {
4636
- const object3 = errorObjectOf(error, options.failureContext).error;
2273
+ const object2 = errorObjectOf(error, options.failureContext).error;
4637
2274
  try {
4638
- if (Buffer.byteLength(JSON.stringify(object3), "utf8") <= 512)
4639
- return object3;
2275
+ if (Buffer.byteLength(JSON.stringify(object2), "utf8") <= 512)
2276
+ return object2;
4640
2277
  } catch {
4641
2278
  }
4642
2279
  const fallback = errorObjectOf(error).error;
@@ -4652,7 +2289,7 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4652
2289
  const context = {
4653
2290
  signal: options.signal,
4654
2291
  reserveReadBytes(bytes) {
4655
- limit2(bytes, BATCH_LIMITS.read_bytes, "operation read");
2292
+ limit(bytes, BATCH_LIMITS.read_bytes, "operation read");
4656
2293
  if (bytes > maxReadBytes - reserved)
4657
2294
  throw budgetError("read");
4658
2295
  reserved += bytes;
@@ -4681,11 +2318,11 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4681
2318
  }
4682
2319
  } catch (error) {
4683
2320
  options.signal?.throwIfAborted();
4684
- const object3 = errorOf(error);
2321
+ const object2 = errorOf(error);
4685
2322
  result = {
4686
2323
  ...framing,
4687
- status: object3.reason === "batch.read-budget" ? "not_run" : "error",
4688
- error: object3,
2324
+ status: object2.reason === "batch.read-budget" ? "not_run" : "error",
2325
+ error: object2,
4689
2326
  complete: false
4690
2327
  };
4691
2328
  }
@@ -4828,12 +2465,12 @@ var Credentials = class {
4828
2465
  return "keyring";
4829
2466
  }
4830
2467
  }
4831
- const store2 = this.#readFile();
4832
- if (!store2) {
2468
+ const store = this.#readFile();
2469
+ if (!store) {
4833
2470
  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.`);
4834
2471
  }
4835
- store2[account] = { secret };
4836
- this.#writeFile(store2);
2472
+ store[account] = { secret };
2473
+ this.#writeFile(store);
4837
2474
  return "file";
4838
2475
  }
4839
2476
  remove(account) {
@@ -4851,11 +2488,11 @@ var Credentials = class {
4851
2488
  return removed;
4852
2489
  }
4853
2490
  #removeFromFile(account) {
4854
- const store2 = this.#readFile();
4855
- if (store2?.[account] === void 0)
2491
+ const store = this.#readFile();
2492
+ if (store?.[account] === void 0)
4856
2493
  return false;
4857
- delete store2[account];
4858
- this.#writeFile(store2);
2494
+ delete store[account];
2495
+ this.#writeFile(store);
4859
2496
  return true;
4860
2497
  }
4861
2498
  /** Only for the warning: a keyring that fails here must not fail a removal that already happened. */
@@ -4886,8 +2523,8 @@ var Credentials = class {
4886
2523
  return void 0;
4887
2524
  }
4888
2525
  }
4889
- #writeFile(store2) {
4890
- writeSecurely(this.#path(), `${JSON.stringify(store2, null, 2)}
2526
+ #writeFile(store) {
2527
+ writeSecurely(this.#path(), `${JSON.stringify(store, null, 2)}
4891
2528
  `, 384);
4892
2529
  }
4893
2530
  #tryKeyring(operation) {
@@ -5064,10 +2701,10 @@ var CONTENT_WORDS = /* @__PURE__ */ new Set([
5064
2701
  "token"
5065
2702
  ]);
5066
2703
  var CONTENT_LAST_WORDS = /* @__PURE__ */ new Set(["message", "name"]);
5067
- var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word2) => word2.toLowerCase()), "wordsOf");
2704
+ var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word) => word.toLowerCase()), "wordsOf");
5068
2705
  var isContentKey = /* @__PURE__ */ __name((key) => {
5069
2706
  const words = wordsOf(key);
5070
- return words.some((word2) => CONTENT_WORDS.has(word2)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
2707
+ return words.some((word) => CONTENT_WORDS.has(word)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
5071
2708
  }, "isContentKey");
5072
2709
  var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
5073
2710
  var traceIdOf = /* @__PURE__ */ __name((traceparent) => {
@@ -5179,90 +2816,6 @@ var silent = {
5179
2816
  };
5180
2817
 
5181
2818
  export {
5182
- errorCodes,
5183
- CliError,
5184
- isCliError,
5185
- EXIT_CODES,
5186
- exitCodeFor,
5187
- GENERIC_FAILURE,
5188
- visibleControls,
5189
- singleLine,
5190
- getDotPath,
5191
- ValiError,
5192
- check,
5193
- description,
5194
- finite,
5195
- integer,
5196
- isoDate,
5197
- isoTimestamp,
5198
- maxLength,
5199
- maxValue,
5200
- minLength,
5201
- minValue,
5202
- nonEmpty,
5203
- regex,
5204
- safeInteger,
5205
- transform,
5206
- trim,
5207
- forward,
5208
- array,
5209
- boolean,
5210
- lazy,
5211
- literal,
5212
- looseObject,
5213
- null_,
5214
- nullable,
5215
- number,
5216
- object,
5217
- objectWithRest,
5218
- optional,
5219
- picklist,
5220
- record,
5221
- strictObject,
5222
- string,
5223
- union,
5224
- unknown,
5225
- variant,
5226
- omit,
5227
- parse,
5228
- partial,
5229
- pick,
5230
- pipe,
5231
- safeParse,
5232
- summarize,
5233
- unwrap,
5234
- effectsSchema,
5235
- writes,
5236
- toJsonSchema,
5237
- toStandardJsonSchema,
5238
- word,
5239
- SNAKE_CASE,
5240
- text,
5241
- RegistryError,
5242
- parseRegistry,
5243
- duplicates,
5244
- jsonSchemaOf,
5245
- MAX_NEXT_STEPS,
5246
- COMPACT_FLAG,
5247
- isoTime,
5248
- reference,
5249
- pageSchema,
5250
- listEnvelopeSchema,
5251
- itemEnvelopeSchema,
5252
- jsonlOf,
5253
- CRASH_CODE,
5254
- errorObjectSchema,
5255
- defineReasons,
5256
- defineSteps,
5257
- stepOf,
5258
- STEPS,
5259
- errorObjectOf,
5260
- exitCodeOfError,
5261
- exitCodeOfAnswer,
5262
- errorRecordOf,
5263
- renderError,
5264
- mcpErrorResult,
5265
- catchCrashes,
5266
2819
  fieldsOf,
5267
2820
  projectFields,
5268
2821
  BATCH_LIMITS,