@wirecat/zoom-cli 0.64.0 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/answer-entities.d.ts +13 -0
  2. package/dist/answer-entities.d.ts.map +1 -1
  3. package/dist/answer-entities.js +5 -0
  4. package/dist/answer-entities.js.map +1 -1
  5. package/dist/answers.d.ts +8 -0
  6. package/dist/answers.d.ts.map +1 -1
  7. package/dist/archive-import.d.ts +1 -1
  8. package/dist/archive-import.d.ts.map +1 -1
  9. package/dist/archive-import.js +2 -1
  10. package/dist/archive-import.js.map +1 -1
  11. package/dist/bin/zm.js +6 -2
  12. package/dist/bin/zm.js.map +1 -1
  13. package/dist/bundle/{all-profiles-W2OVBZ7S.js → all-profiles-D5CFH2OK.js} +11 -8
  14. package/dist/bundle/answer-policy-YAYMKRRD.js +101 -0
  15. package/dist/bundle/{anthropic-P4BKQNBO.js → anthropic-K2E2JS4S.js} +7 -4
  16. package/dist/bundle/{app-server-AYUW45ND.js → app-server-TVXDG6HZ.js} +68 -61
  17. package/dist/bundle/{bun-MNGPTYDQ.js → bun-O4WHGL2F.js} +2 -2
  18. package/dist/bundle/{bun-sqlite-PTPUSXAO.js → bun-sqlite-HGBEHQI3.js} +6 -3
  19. package/dist/bundle/{chunk-TYKZCJD7.js → chunk-2T5BOLBS.js} +35 -35
  20. package/dist/bundle/{chunk-H3DMYF3W.js → chunk-2VPHQFO5.js} +8 -8
  21. package/dist/bundle/{chunk-JMSKDW5G.js → chunk-2YLNUZ3T.js} +5 -3
  22. package/dist/bundle/{chunk-AAC6VNSL.js → chunk-3B7L2UX4.js} +3 -3
  23. package/dist/bundle/{chunk-6NBQJJT6.js → chunk-3WTKZ2ZS.js} +13 -11
  24. package/dist/bundle/{chunk-H65B6A7Y.js → chunk-3Y2F65AY.js} +8 -8
  25. package/dist/bundle/{chunk-A2FOW3ZC.js → chunk-5A26IBAR.js} +162 -107
  26. package/dist/bundle/{chunk-BO5YVG3X.js → chunk-5GD2XZ6X.js} +132 -40
  27. package/dist/bundle/{chunk-7D56BQZL.js → chunk-5HPALDUO.js} +2 -2
  28. package/dist/bundle/{chunk-5FN4Q5H5.js → chunk-62GOOZO3.js} +8 -13
  29. package/dist/bundle/{chunk-J25UNZIL.js → chunk-67RNZGAG.js} +12 -10
  30. package/dist/bundle/{chunk-3AAO5N4L.js → chunk-6GSJLNP4.js} +2 -2
  31. package/dist/bundle/{chunk-UNO4G5NX.js → chunk-6TIKPRVQ.js} +11 -7
  32. package/dist/bundle/{chunk-HQHUPTZR.js → chunk-756RS4PH.js} +1393 -712
  33. package/dist/bundle/{chunk-R4NTPYXZ.js → chunk-7JMBEPW2.js} +2 -2
  34. package/dist/bundle/{chunk-HIGFBTEI.js → chunk-7KCTPGOF.js} +2 -2
  35. package/dist/bundle/{chunk-TJODNJKE.js → chunk-7PF56S6U.js} +33 -22
  36. package/dist/bundle/{chunk-LEQCRVPD.js → chunk-7SQJCKR6.js} +1 -1
  37. package/dist/bundle/{chunk-BWPKSUXW.js → chunk-A2SCXNA7.js} +4518 -402
  38. package/dist/bundle/{chunk-QK54GOGE.js → chunk-AU4JHT3R.js} +7 -9
  39. package/dist/bundle/{chunk-63MRRNDL.js → chunk-AZ7ICKIA.js} +8 -8
  40. package/dist/bundle/chunk-BLT3LR3U.js +34 -0
  41. package/dist/bundle/{chunk-UABUBDYB.js → chunk-BXSAROQP.js} +2 -2
  42. package/dist/bundle/{chunk-Q3EDUZ5R.js → chunk-CAW6IMFZ.js} +25 -18
  43. package/dist/bundle/{chunk-UCPL55YP.js → chunk-CR4CXOLX.js} +17 -17
  44. package/dist/bundle/{chunk-SMT6SFBK.js → chunk-CZ4KLUJG.js} +2 -2
  45. package/dist/bundle/{chunk-COTC7HF3.js → chunk-D72URWJE.js} +1 -39
  46. package/dist/bundle/{chunk-X6M5DK66.js → chunk-EXXM4RNI.js} +14 -12
  47. package/dist/bundle/{chunk-CZKV4USJ.js → chunk-FWFFQV4D.js} +59 -4
  48. package/dist/bundle/{chunk-JJZAGKUK.js → chunk-GHAPWKG2.js} +5 -3
  49. package/dist/bundle/{chunk-JRPYHDCO.js → chunk-GI6QVSCW.js} +4 -4
  50. package/dist/bundle/{chunk-Y7TWNMTW.js → chunk-GKXFL35E.js} +198 -65
  51. package/dist/bundle/{chunk-K6OSD6DG.js → chunk-GNGBG5BT.js} +81 -35
  52. package/dist/bundle/{chunk-RJLNVHIU.js → chunk-H5ZVZAOD.js} +3 -3
  53. package/dist/bundle/{chunk-XZSQLVED.js → chunk-HKQWV3KT.js} +5 -3
  54. package/dist/bundle/chunk-IDWHJ35K.js +166 -0
  55. package/dist/bundle/{chunk-JM43EKTY.js → chunk-IKQ73INC.js} +1928 -679
  56. package/dist/bundle/chunk-ILHTNOIV.js +23 -0
  57. package/dist/bundle/{chunk-OPP5CWAX.js → chunk-J4EZL6HY.js} +61 -56
  58. package/dist/bundle/{chunk-54UEJGYB.js → chunk-JX3V35A5.js} +3 -3
  59. package/dist/bundle/{chunk-7VJIKJNW.js → chunk-K5CIN4JP.js} +8 -8
  60. package/dist/bundle/{chunk-KJCCT3QY.js → chunk-KDKFGQWG.js} +17 -14
  61. package/dist/bundle/{chunk-RK3JBC4U.js → chunk-L7IK4FOA.js} +2 -2
  62. package/dist/bundle/{chunk-7EOW47PV.js → chunk-LN2S3RA3.js} +4 -4
  63. package/dist/bundle/{chunk-I5QX2HAT.js → chunk-N5JRRBEG.js} +214 -107
  64. package/dist/bundle/chunk-N67BLTBV.js +2443 -0
  65. package/dist/bundle/{chunk-23LOMA2I.js → chunk-N6JMJN5A.js} +48 -26
  66. package/dist/bundle/{chunk-CZFV6XTW.js → chunk-NMQUCHTX.js} +3 -3
  67. package/dist/bundle/{chunk-TJH5IQVZ.js → chunk-NO24PJNW.js} +1 -1
  68. package/dist/bundle/{chunk-UFI5SX3F.js → chunk-O5FKJV3T.js} +14 -12
  69. package/dist/bundle/{chunk-IIP4J3PD.js → chunk-P2G4KGTR.js} +94 -12
  70. package/dist/bundle/{chunk-OWXMQVVN.js → chunk-P2SYZNM4.js} +1 -1
  71. package/dist/bundle/{chunk-EQYPTGCT.js → chunk-P3XVLHIQ.js} +6 -4
  72. package/dist/bundle/chunk-PQLBPYJR.js +46 -0
  73. package/dist/bundle/{chunk-5BCNJB2A.js → chunk-Q47C3QZW.js} +675 -507
  74. package/dist/bundle/{chunk-IIGXCYEL.js → chunk-QAPU2JNO.js} +13 -13
  75. package/dist/bundle/{chunk-WFIJOFS5.js → chunk-QJHRYUMJ.js} +1 -1
  76. package/dist/bundle/{chunk-YNYMWXXH.js → chunk-QV5ZGRK3.js} +40 -11
  77. package/dist/bundle/{chunk-3IMEAZIM.js → chunk-RMKHYUHK.js} +9 -20
  78. package/dist/bundle/{chunk-AF4HONAZ.js → chunk-RO44LANT.js} +6449 -4436
  79. package/dist/bundle/{chunk-3DGQJASQ.js → chunk-S4GDDO5S.js} +1 -1
  80. package/dist/bundle/chunk-S6S3KVJI.js +45 -0
  81. package/dist/bundle/{chunk-SJIBJQJN.js → chunk-SU4WPBQE.js} +44 -14
  82. package/dist/bundle/{chunk-7NDSBTKR.js → chunk-TFDVFD4N.js} +91 -2546
  83. package/dist/bundle/{chunk-HQHYPKSU.js → chunk-TMVKZMDO.js} +54 -37
  84. package/dist/bundle/{chunk-PBJY5VR6.js → chunk-TN7K66PU.js} +1 -1
  85. package/dist/bundle/{chunk-ZW4N73FO.js → chunk-TUEEXECZ.js} +5 -5
  86. package/dist/bundle/{chunk-H5LLZ5XA.js → chunk-U3ZUT557.js} +1 -1
  87. package/dist/bundle/{chunk-4XVRA6P5.js → chunk-U4RVOSX3.js} +1 -1
  88. package/dist/bundle/{chunk-5YLR24D5.js → chunk-UOIXBEFR.js} +13 -6
  89. package/dist/bundle/chunk-UYV2JGLQ.js +34 -0
  90. package/dist/bundle/{chunk-7SWNZ44U.js → chunk-XFUID5NY.js} +4 -4
  91. package/dist/bundle/{chunk-BMYZWBAX.js → chunk-XWDSEJWP.js} +6 -6
  92. package/dist/bundle/{chunk-JZKNHA44.js → chunk-Y3EIK4XW.js} +1 -1
  93. package/dist/bundle/{chunk-24WCZURP.js → chunk-YLEQN6PB.js} +5 -3
  94. package/dist/bundle/{chunk-2UONVSJQ.js → chunk-Z6U3MEGJ.js} +2 -2
  95. package/dist/bundle/{chunk-L4JGVSBN.js → chunk-ZKTXUDSR.js} +33 -28
  96. package/dist/bundle/{chunk-FSYO3PUW.js → chunk-ZNFPDTQM.js} +2 -2
  97. package/dist/bundle/{chunk-C3RRIJ5C.js → chunk-ZTL7ANSG.js} +9 -42
  98. package/dist/bundle/{cli-Y2ZO3D5U.js → cli-HWQIL2AC.js} +124 -73
  99. package/dist/bundle/command-contract-CQFJXWX6.js +40 -0
  100. package/dist/bundle/config-R2Y6ZVQS.js +83 -0
  101. package/dist/bundle/{decode-GO6GAYH2.js → decode-XPAPPUGE.js} +6 -3
  102. package/dist/bundle/dispatch-AKVJGP2S.js +412 -0
  103. package/dist/bundle/{dist-MIJKAGXW.js → dist-LDIUQBM7.js} +23 -16
  104. package/dist/bundle/{echarts-NWK7LALR.js → echarts-FMACRZQC.js} +2 -2
  105. package/dist/bundle/{embed-2DOSN4DV.js → embed-LK45GRQ7.js} +7 -4
  106. package/dist/bundle/{embedder-3Q3C2WKC.js → embedder-QPBC5XBY.js} +12 -9
  107. package/dist/bundle/failure-7OULAOWQ.js +25 -0
  108. package/dist/bundle/first-run-J5FG773Q.js +28 -0
  109. package/dist/bundle/first-screen-MULOBUHN.js +38 -0
  110. package/dist/bundle/{folders-RSWEBHDZ.js → folders-RHPUVMDI.js} +5 -2
  111. package/dist/bundle/{instructions-M3FZPQVI.js → instructions-E5FXYCWF.js} +1 -1
  112. package/dist/bundle/{main-R77BPRRS.js → main-FJHE5YHU.js} +28 -22
  113. package/dist/bundle/{mcp-YJEQYYTR.js → mcp-MNI62HHE.js} +5 -3
  114. package/dist/bundle/{meetings-IV4Y4WRH.js → meetings-MYIDGYGW.js} +19 -6
  115. package/dist/bundle/{node-I3GEHYGL.js → node-4SNKUPXT.js} +2 -2
  116. package/dist/bundle/{node-sqlite-W6MR2TVQ.js → node-sqlite-SYZUTVPC.js} +12 -3
  117. package/dist/bundle/{oauth-M6YL4QXP.js → oauth-QPS5VTN6.js} +8 -5
  118. package/dist/bundle/{open-2VITLJAN.js → open-OVCASRSJ.js} +6 -2
  119. package/dist/bundle/openai-VEVT7D7L.js +25 -0
  120. package/dist/bundle/{output-file-XJJ3XMLQ.js → output-file-K5JEL33Z.js} +7 -4
  121. package/dist/bundle/{process-UBA4L4B2.js → process-HQZOTT6U.js} +1 -1
  122. package/dist/bundle/{program-5R5MRXUM.js → program-A546WC4F.js} +120 -112
  123. package/dist/bundle/{prompt-AVIXIM7Z.js → prompt-CYBKP7S5.js} +6 -3
  124. package/dist/bundle/{recognize-DJKTJOYU.js → recognize-3H3YDCFI.js} +5 -2
  125. package/dist/bundle/{remote-S3DTNYRP.js → remote-VAYVTJBS.js} +8 -5
  126. package/dist/bundle/{rerank-FMCDP6VF.js → rerank-XA4GA5PS.js} +8 -5
  127. package/dist/bundle/{run-log-T4MV2VEH.js → run-log-XAFHMI3F.js} +59 -54
  128. package/dist/bundle/{serve-5SGFJFMC.js → serve-KGHEDUHB.js} +18 -14
  129. package/dist/bundle/server-IDNSJXF3.js +71 -0
  130. package/dist/bundle/{server-PCMCY7WK.js → server-ZYTSMDTP.js} +47 -42
  131. package/dist/bundle/{services-SKRQ2POT.js → services-ZHMZC2OQ.js} +106 -28
  132. package/dist/bundle/{speech-FSDICIKO.js → speech-7CJEFKM3.js} +14 -11
  133. package/dist/bundle/{state-KPUSPWO6.js → state-U6KSYVOH.js} +7 -4
  134. package/dist/bundle/{store-W7LFPKG2.js → store-DJE3LAEG.js} +17 -13
  135. package/dist/bundle/{store-7MP2ZGQ7.js → store-WS4CQGYU.js} +40 -18
  136. package/dist/bundle/store-connection-T5WGOOPH.js +81 -0
  137. package/dist/bundle/store-maintenance-command-5CBQCEQQ.js +61 -0
  138. package/dist/bundle/{streaming-Q44ESD3E.js → streaming-QMHH7L6N.js} +7 -4
  139. package/dist/bundle/{tokens-TAFCHANI.js → tokens-PWQ56OXO.js} +7 -4
  140. package/dist/bundle/zm.js +150 -1
  141. package/dist/local-transcription.d.ts.map +1 -1
  142. package/dist/local-transcription.js +1 -0
  143. package/dist/local-transcription.js.map +1 -1
  144. package/dist/version.d.ts +1 -1
  145. package/dist/version.js +1 -1
  146. package/package.json +5 -4
  147. package/dist/bundle/answer-policy-HOA43GNA.js +0 -96
  148. package/dist/bundle/chunk-JRPAZ2WD.js +0 -3635
  149. package/dist/bundle/command-contract-DGTZIH2F.js +0 -38
  150. package/dist/bundle/config-N2UHDKGG.js +0 -78
  151. package/dist/bundle/first-run-S75VKIT3.js +0 -23
  152. package/dist/bundle/first-screen-DQNRT6GH.js +0 -36
  153. package/dist/bundle/openai-OG6B3JCU.js +0 -22
  154. package/dist/bundle/server-EYGZLKKQ.js +0 -66
  155. package/dist/bundle/store-connection-3HNZFJC4.js +0 -76
  156. package/dist/bundle/store-maintenance-command-6WBLTUZP.js +0 -55
  157. /package/dist/bundle/{chunk-WJWLHLQ7.js → chunk-NUN6OGOV.js} +0 -0
@@ -1,5 +1,31 @@
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-N67BLTBV.js";
22
+ import {
23
+ CliError,
24
+ isCliError
25
+ } from "./chunk-S6S3KVJI.js";
26
+ import {
27
+ visibleControls
28
+ } from "./chunk-UYV2JGLQ.js";
3
29
  import {
4
30
  __commonJS,
5
31
  __name,
@@ -367,26 +393,26 @@ var require_utils = __commonJS({
367
393
  return ret;
368
394
  }
369
395
  __name(mergeOptions, "mergeOptions");
370
- function wordWrap(maxLength2, input) {
396
+ function wordWrap(maxLength, input) {
371
397
  let lines = [];
372
398
  let split = input.split(/(\s+)/g);
373
399
  let line = [];
374
400
  let lineLength = 0;
375
401
  let whitespace;
376
402
  for (let i = 0; i < split.length; i += 2) {
377
- let word2 = split[i];
378
- let newLength = lineLength + strlen(word2);
403
+ let word = split[i];
404
+ let newLength = lineLength + strlen(word);
379
405
  if (lineLength > 0 && whitespace) {
380
406
  newLength += whitespace.length;
381
407
  }
382
- if (newLength > maxLength2) {
408
+ if (newLength > maxLength) {
383
409
  if (lineLength !== 0) {
384
410
  lines.push(line.join(""));
385
411
  }
386
- line = [word2];
387
- lineLength = strlen(word2);
412
+ line = [word];
413
+ lineLength = strlen(word);
388
414
  } else {
389
- line.push(whitespace || "", word2);
415
+ line.push(whitespace || "", word);
390
416
  lineLength = newLength;
391
417
  }
392
418
  whitespace = split[i + 1];
@@ -397,15 +423,15 @@ var require_utils = __commonJS({
397
423
  return lines;
398
424
  }
399
425
  __name(wordWrap, "wordWrap");
400
- function textWrap(maxLength2, input) {
426
+ function textWrap(maxLength, input) {
401
427
  let lines = [];
402
428
  let line = "";
403
429
  function pushLine(str, ws) {
404
430
  if (line.length && ws) line += ws;
405
431
  line += str;
406
- while (line.length > maxLength2) {
407
- lines.push(line.slice(0, maxLength2));
408
- line = line.slice(maxLength2);
432
+ while (line.length > maxLength) {
433
+ lines.push(line.slice(0, maxLength));
434
+ line = line.slice(maxLength);
409
435
  }
410
436
  }
411
437
  __name(pushLine, "pushLine");
@@ -417,12 +443,12 @@ var require_utils = __commonJS({
417
443
  return lines;
418
444
  }
419
445
  __name(textWrap, "textWrap");
420
- function multiLineWordWrap(maxLength2, input, wrapOnWordBoundary = true) {
446
+ function multiLineWordWrap(maxLength, input, wrapOnWordBoundary = true) {
421
447
  let output = [];
422
448
  input = input.split("\n");
423
449
  const handler = wrapOnWordBoundary ? wordWrap : textWrap;
424
450
  for (let i = 0; i < input.length; i++) {
425
- output.push.apply(output, handler(maxLength2, input[i]));
451
+ output.push.apply(output, handler(maxLength, input[i]));
426
452
  }
427
453
  return output;
428
454
  }
@@ -1872,2407 +1898,7 @@ var require_cli_table3 = __commonJS({
1872
1898
  }
1873
1899
  });
1874
1900
 
1875
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/errors.js
1876
- var errorCodes = [
1877
- "validation_error",
1878
- "configuration_error",
1879
- "authentication_error",
1880
- "permission_error",
1881
- "not_found",
1882
- "confirmation_required",
1883
- "rate_limited",
1884
- "timeout",
1885
- "network_error",
1886
- "provider_error",
1887
- "provider_unavailable",
1888
- "invalid_response",
1889
- "outcome_unknown",
1890
- "cancelled"
1891
- ];
1892
- var BRAND = /* @__PURE__ */ Symbol.for("@wirecat/cli-base/CliError");
1893
- var CliError = class extends Error {
1894
- static {
1895
- __name(this, "CliError");
1896
- }
1897
- code;
1898
- details;
1899
- constructor(code, message, details = {}) {
1900
- super(message);
1901
- this.name = "CliError";
1902
- this.code = code;
1903
- this.details = details;
1904
- Object.defineProperty(this, BRAND, { value: true });
1905
- }
1906
- };
1907
- var isCliError = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && value[BRAND] === true, "isCliError");
1908
-
1909
- // node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
1910
- var store$4;
1911
- var DEFAULT_CONFIG = {
1912
- lang: void 0,
1913
- message: void 0,
1914
- abortEarly: void 0,
1915
- abortPipeEarly: void 0
1916
- };
1917
- // @__NO_SIDE_EFFECTS__
1918
- function getGlobalConfig(config$1) {
1919
- if (!config$1 && !store$4) return DEFAULT_CONFIG;
1920
- return {
1921
- lang: config$1?.lang ?? store$4?.lang,
1922
- message: config$1?.message,
1923
- abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
1924
- abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
1925
- };
1926
- }
1927
- __name(getGlobalConfig, "getGlobalConfig");
1928
- var store$3;
1929
- // @__NO_SIDE_EFFECTS__
1930
- function getGlobalMessage(lang) {
1931
- return store$3?.get(lang);
1932
- }
1933
- __name(getGlobalMessage, "getGlobalMessage");
1934
- var store$2;
1935
- // @__NO_SIDE_EFFECTS__
1936
- function getSchemaMessage(lang) {
1937
- return store$2?.get(lang);
1938
- }
1939
- __name(getSchemaMessage, "getSchemaMessage");
1940
- var store$1;
1941
- // @__NO_SIDE_EFFECTS__
1942
- function getSpecificMessage(reference2, lang) {
1943
- return store$1?.get(reference2)?.get(lang);
1944
- }
1945
- __name(getSpecificMessage, "getSpecificMessage");
1946
- // @__NO_SIDE_EFFECTS__
1947
- function _stringify(input) {
1948
- const type = typeof input;
1949
- if (type === "string") return `"${input}"`;
1950
- if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
1951
- if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
1952
- return type;
1953
- }
1954
- __name(_stringify, "_stringify");
1955
- function _addIssue(context, label, dataset, config$1, other) {
1956
- const input = other && "input" in other ? other.input : dataset.value;
1957
- const expected = other?.expected ?? context.expects ?? null;
1958
- const received = other?.received ?? /* @__PURE__ */ _stringify(input);
1959
- const issue = {
1960
- kind: context.kind,
1961
- type: context.type,
1962
- input,
1963
- expected,
1964
- received,
1965
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
1966
- requirement: context.requirement,
1967
- path: other?.path,
1968
- issues: other?.issues,
1969
- lang: config$1.lang,
1970
- abortEarly: config$1.abortEarly,
1971
- abortPipeEarly: config$1.abortPipeEarly
1972
- };
1973
- const isSchema = context.kind === "schema";
1974
- const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
1975
- if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
1976
- if (isSchema) dataset.typed = false;
1977
- if (dataset.issues) dataset.issues.push(issue);
1978
- else dataset.issues = [issue];
1979
- }
1980
- __name(_addIssue, "_addIssue");
1981
- // @__NO_SIDE_EFFECTS__
1982
- function _isSameValueZero(value1, value2) {
1983
- return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
1984
- }
1985
- __name(_isSameValueZero, "_isSameValueZero");
1986
- // @__NO_SIDE_EFFECTS__
1987
- function _isValidObjectKey(object$1, key) {
1988
- return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
1989
- }
1990
- __name(_isValidObjectKey, "_isValidObjectKey");
1991
- // @__NO_SIDE_EFFECTS__
1992
- function _joinExpects(values$1, separator) {
1993
- const list = [...new Set(values$1)];
1994
- if (list.length > 1) return `(${list.join(` ${separator} `)})`;
1995
- return list[0] ?? "never";
1996
- }
1997
- __name(_joinExpects, "_joinExpects");
1998
- function _standardSchema(schema) {
1999
- schema["~standard"] = {
2000
- version: 1,
2001
- vendor: "valibot",
2002
- validate: /* @__PURE__ */ __name((value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig()), "validate")
2003
- };
2004
- return schema;
2005
- }
2006
- __name(_standardSchema, "_standardSchema");
2007
- // @__NO_SIDE_EFFECTS__
2008
- function getDotPath(issue) {
2009
- if (issue.path) {
2010
- let key = "";
2011
- for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
2012
- else key += item.key;
2013
- else return null;
2014
- return key;
2015
- }
2016
- return null;
2017
- }
2018
- __name(getDotPath, "getDotPath");
2019
- var ValiError = class extends Error {
2020
- static {
2021
- __name(this, "ValiError");
2022
- }
2023
- /**
2024
- * Creates a Valibot error with useful information.
2025
- *
2026
- * @param issues The error issues.
2027
- */
2028
- constructor(issues) {
2029
- super(issues[0].message);
2030
- this.name = "ValiError";
2031
- this.issues = issues;
2032
- }
2033
- };
2034
- var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
2035
- var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])$/u;
2036
- var ISO_TIMESTAMP_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])[T ](?:0\d|1\d|2[0-3])(?::[0-5]\d){2}(?:\.\d{1,9})?(?:Z| ?[+-](?:0\d|1\d|2[0-3])(?::?[0-5]\d)?)$/u;
2037
- // @__NO_SIDE_EFFECTS__
2038
- function check(requirement, message$1) {
2039
- return {
2040
- kind: "validation",
2041
- type: "check",
2042
- reference: check,
2043
- async: false,
2044
- expects: null,
2045
- requirement,
2046
- message: message$1,
2047
- "~run"(dataset, config$1) {
2048
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
2049
- return dataset;
2050
- }
2051
- };
2052
- }
2053
- __name(check, "check");
2054
- // @__NO_SIDE_EFFECTS__
2055
- function description(description_) {
2056
- return {
2057
- kind: "metadata",
2058
- type: "description",
2059
- reference: description,
2060
- description: description_
2061
- };
2062
- }
2063
- __name(description, "description");
2064
- // @__NO_SIDE_EFFECTS__
2065
- function endsWith(requirement, message$1) {
2066
- return {
2067
- kind: "validation",
2068
- type: "ends_with",
2069
- reference: endsWith,
2070
- async: false,
2071
- expects: `"${requirement}"`,
2072
- requirement,
2073
- message: message$1,
2074
- "~run"(dataset, config$1) {
2075
- if (dataset.typed && !dataset.value.endsWith(this.requirement)) _addIssue(this, "end", dataset, config$1, { received: `"${dataset.value.slice(-this.requirement.length)}"` });
2076
- return dataset;
2077
- }
2078
- };
2079
- }
2080
- __name(endsWith, "endsWith");
2081
- // @__NO_SIDE_EFFECTS__
2082
- function finite(message$1) {
2083
- return {
2084
- kind: "validation",
2085
- type: "finite",
2086
- reference: finite,
2087
- async: false,
2088
- expects: null,
2089
- requirement: Number.isFinite,
2090
- message: message$1,
2091
- "~run"(dataset, config$1) {
2092
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "finite", dataset, config$1);
2093
- return dataset;
2094
- }
2095
- };
2096
- }
2097
- __name(finite, "finite");
2098
- // @__NO_SIDE_EFFECTS__
2099
- function integer(message$1) {
2100
- return {
2101
- kind: "validation",
2102
- type: "integer",
2103
- reference: integer,
2104
- async: false,
2105
- expects: null,
2106
- requirement: Number.isInteger,
2107
- message: message$1,
2108
- "~run"(dataset, config$1) {
2109
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
2110
- return dataset;
2111
- }
2112
- };
2113
- }
2114
- __name(integer, "integer");
2115
- // @__NO_SIDE_EFFECTS__
2116
- function isoDate(message$1) {
2117
- return {
2118
- kind: "validation",
2119
- type: "iso_date",
2120
- reference: isoDate,
2121
- async: false,
2122
- expects: null,
2123
- requirement: ISO_DATE_REGEX,
2124
- message: message$1,
2125
- "~run"(dataset, config$1) {
2126
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "date", dataset, config$1);
2127
- return dataset;
2128
- }
2129
- };
2130
- }
2131
- __name(isoDate, "isoDate");
2132
- // @__NO_SIDE_EFFECTS__
2133
- function isoTimestamp(message$1) {
2134
- return {
2135
- kind: "validation",
2136
- type: "iso_timestamp",
2137
- reference: isoTimestamp,
2138
- async: false,
2139
- expects: null,
2140
- requirement: ISO_TIMESTAMP_REGEX,
2141
- message: message$1,
2142
- "~run"(dataset, config$1) {
2143
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "timestamp", dataset, config$1);
2144
- return dataset;
2145
- }
2146
- };
2147
- }
2148
- __name(isoTimestamp, "isoTimestamp");
2149
- // @__NO_SIDE_EFFECTS__
2150
- function maxLength(requirement, message$1) {
2151
- return {
2152
- kind: "validation",
2153
- type: "max_length",
2154
- reference: maxLength,
2155
- async: false,
2156
- expects: `<=${requirement}`,
2157
- requirement,
2158
- message: message$1,
2159
- "~run"(dataset, config$1) {
2160
- if (dataset.typed && dataset.value.length > this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
2161
- return dataset;
2162
- }
2163
- };
2164
- }
2165
- __name(maxLength, "maxLength");
2166
- // @__NO_SIDE_EFFECTS__
2167
- function maxValue(requirement, message$1) {
2168
- return {
2169
- kind: "validation",
2170
- type: "max_value",
2171
- reference: maxValue,
2172
- async: false,
2173
- expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
2174
- requirement,
2175
- message: message$1,
2176
- "~run"(dataset, config$1) {
2177
- if (dataset.typed && !(dataset.value <= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
2178
- return dataset;
2179
- }
2180
- };
2181
- }
2182
- __name(maxValue, "maxValue");
2183
- // @__NO_SIDE_EFFECTS__
2184
- function minLength(requirement, message$1) {
2185
- return {
2186
- kind: "validation",
2187
- type: "min_length",
2188
- reference: minLength,
2189
- async: false,
2190
- expects: `>=${requirement}`,
2191
- requirement,
2192
- message: message$1,
2193
- "~run"(dataset, config$1) {
2194
- if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
2195
- return dataset;
2196
- }
2197
- };
2198
- }
2199
- __name(minLength, "minLength");
2200
- // @__NO_SIDE_EFFECTS__
2201
- function minValue(requirement, message$1) {
2202
- return {
2203
- kind: "validation",
2204
- type: "min_value",
2205
- reference: minValue,
2206
- async: false,
2207
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
2208
- requirement,
2209
- message: message$1,
2210
- "~run"(dataset, config$1) {
2211
- if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
2212
- return dataset;
2213
- }
2214
- };
2215
- }
2216
- __name(minValue, "minValue");
2217
- // @__NO_SIDE_EFFECTS__
2218
- function nonEmpty(message$1) {
2219
- return {
2220
- kind: "validation",
2221
- type: "non_empty",
2222
- reference: nonEmpty,
2223
- async: false,
2224
- expects: "!0",
2225
- message: message$1,
2226
- "~run"(dataset, config$1) {
2227
- if (dataset.typed && dataset.value.length === 0) _addIssue(this, "length", dataset, config$1, { received: "0" });
2228
- return dataset;
2229
- }
2230
- };
2231
- }
2232
- __name(nonEmpty, "nonEmpty");
2233
- // @__NO_SIDE_EFFECTS__
2234
- function regex(requirement, message$1) {
2235
- return {
2236
- kind: "validation",
2237
- type: "regex",
2238
- reference: regex,
2239
- async: false,
2240
- expects: `${requirement}`,
2241
- requirement,
2242
- message: message$1,
2243
- "~run"(dataset, config$1) {
2244
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config$1);
2245
- return dataset;
2246
- }
2247
- };
2248
- }
2249
- __name(regex, "regex");
2250
- // @__NO_SIDE_EFFECTS__
2251
- function safeInteger(message$1) {
2252
- return {
2253
- kind: "validation",
2254
- type: "safe_integer",
2255
- reference: safeInteger,
2256
- async: false,
2257
- expects: null,
2258
- requirement: Number.isSafeInteger,
2259
- message: message$1,
2260
- "~run"(dataset, config$1) {
2261
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "safe integer", dataset, config$1);
2262
- return dataset;
2263
- }
2264
- };
2265
- }
2266
- __name(safeInteger, "safeInteger");
2267
- // @__NO_SIDE_EFFECTS__
2268
- function transform(operation) {
2269
- return {
2270
- kind: "transformation",
2271
- type: "transform",
2272
- reference: transform,
2273
- async: false,
2274
- operation,
2275
- "~run"(dataset) {
2276
- dataset.value = this.operation(dataset.value);
2277
- return dataset;
2278
- }
2279
- };
2280
- }
2281
- __name(transform, "transform");
2282
- // @__NO_SIDE_EFFECTS__
2283
- function trim() {
2284
- return {
2285
- kind: "transformation",
2286
- type: "trim",
2287
- reference: trim,
2288
- async: false,
2289
- "~run"(dataset) {
2290
- dataset.value = dataset.value.trim();
2291
- return dataset;
2292
- }
2293
- };
2294
- }
2295
- __name(trim, "trim");
2296
- var ABORT_EARLY_CONFIG = { abortEarly: true };
2297
- // @__NO_SIDE_EFFECTS__
2298
- function getFallback(schema, dataset, config$1) {
2299
- return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
2300
- }
2301
- __name(getFallback, "getFallback");
2302
- // @__NO_SIDE_EFFECTS__
2303
- function forward(action, path) {
2304
- return {
2305
- ...action,
2306
- "~run"(dataset, config$1) {
2307
- const prevIssues = dataset.issues && [...dataset.issues];
2308
- dataset = action["~run"](dataset, config$1);
2309
- if (dataset.issues) {
2310
- for (const issue of dataset.issues) if (!prevIssues?.includes(issue)) {
2311
- let pathInput = dataset.value;
2312
- for (const key of path) {
2313
- const pathValue = pathInput[key];
2314
- const pathItem = {
2315
- type: "unknown",
2316
- origin: "value",
2317
- input: pathInput,
2318
- key,
2319
- value: pathValue
2320
- };
2321
- if (issue.path) issue.path.push(pathItem);
2322
- else issue.path = [pathItem];
2323
- if (!pathValue) break;
2324
- pathInput = pathValue;
2325
- }
2326
- }
2327
- }
2328
- return dataset;
2329
- }
2330
- };
2331
- }
2332
- __name(forward, "forward");
2333
- // @__NO_SIDE_EFFECTS__
2334
- function getDefault(schema, dataset, config$1) {
2335
- return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
2336
- }
2337
- __name(getDefault, "getDefault");
2338
- // @__NO_SIDE_EFFECTS__
2339
- function array(item, message$1) {
2340
- return _standardSchema({
2341
- kind: "schema",
2342
- type: "array",
2343
- reference: array,
2344
- expects: "Array",
2345
- async: false,
2346
- item,
2347
- message: message$1,
2348
- "~run"(dataset, config$1) {
2349
- const input = dataset.value;
2350
- if (Array.isArray(input)) {
2351
- dataset.typed = true;
2352
- dataset.value = [];
2353
- for (let key = 0; key < input.length; key++) {
2354
- const value$1 = input[key];
2355
- const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
2356
- if (itemDataset.issues) {
2357
- const pathItem = {
2358
- type: "array",
2359
- origin: "value",
2360
- input,
2361
- key,
2362
- value: value$1
2363
- };
2364
- for (const issue of itemDataset.issues) {
2365
- if (issue.path) issue.path.unshift(pathItem);
2366
- else issue.path = [pathItem];
2367
- dataset.issues?.push(issue);
2368
- }
2369
- if (!dataset.issues) dataset.issues = itemDataset.issues;
2370
- if (config$1.abortEarly) {
2371
- dataset.typed = false;
2372
- break;
2373
- }
2374
- }
2375
- if (!itemDataset.typed) dataset.typed = false;
2376
- dataset.value.push(itemDataset.value);
2377
- }
2378
- } else _addIssue(this, "type", dataset, config$1);
2379
- return dataset;
2380
- }
2381
- });
2382
- }
2383
- __name(array, "array");
2384
- // @__NO_SIDE_EFFECTS__
2385
- function boolean(message$1) {
2386
- return _standardSchema({
2387
- kind: "schema",
2388
- type: "boolean",
2389
- reference: boolean,
2390
- expects: "boolean",
2391
- async: false,
2392
- message: message$1,
2393
- "~run"(dataset, config$1) {
2394
- if (typeof dataset.value === "boolean") dataset.typed = true;
2395
- else _addIssue(this, "type", dataset, config$1);
2396
- return dataset;
2397
- }
2398
- });
2399
- }
2400
- __name(boolean, "boolean");
2401
- // @__NO_SIDE_EFFECTS__
2402
- function custom(check$1, message$1) {
2403
- return _standardSchema({
2404
- kind: "schema",
2405
- type: "custom",
2406
- reference: custom,
2407
- expects: "unknown",
2408
- async: false,
2409
- check: check$1,
2410
- message: message$1,
2411
- "~run"(dataset, config$1) {
2412
- if (this.check(dataset.value)) dataset.typed = true;
2413
- else _addIssue(this, "type", dataset, config$1);
2414
- return dataset;
2415
- }
2416
- });
2417
- }
2418
- __name(custom, "custom");
2419
- // @__NO_SIDE_EFFECTS__
2420
- function lazy(getter) {
2421
- return _standardSchema({
2422
- kind: "schema",
2423
- type: "lazy",
2424
- reference: lazy,
2425
- expects: "unknown",
2426
- async: false,
2427
- getter,
2428
- "~run"(dataset, config$1) {
2429
- return this.getter(dataset.value)["~run"](dataset, config$1);
2430
- }
2431
- });
2432
- }
2433
- __name(lazy, "lazy");
2434
- // @__NO_SIDE_EFFECTS__
2435
- function literal(literal_, message$1) {
2436
- return _standardSchema({
2437
- kind: "schema",
2438
- type: "literal",
2439
- reference: literal,
2440
- expects: /* @__PURE__ */ _stringify(literal_),
2441
- async: false,
2442
- literal: literal_,
2443
- message: message$1,
2444
- "~run"(dataset, config$1) {
2445
- if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
2446
- else _addIssue(this, "type", dataset, config$1);
2447
- return dataset;
2448
- }
2449
- });
2450
- }
2451
- __name(literal, "literal");
2452
- // @__NO_SIDE_EFFECTS__
2453
- function looseObject(entries$1, message$1) {
2454
- return _standardSchema({
2455
- kind: "schema",
2456
- type: "loose_object",
2457
- reference: looseObject,
2458
- expects: "Object",
2459
- async: false,
2460
- entries: entries$1,
2461
- message: message$1,
2462
- "~run"(dataset, config$1) {
2463
- const input = dataset.value;
2464
- if (input && typeof input === "object") {
2465
- dataset.typed = true;
2466
- dataset.value = {};
2467
- for (const key in this.entries) {
2468
- const valueSchema = this.entries[key];
2469
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2470
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2471
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2472
- if (valueDataset.issues) {
2473
- const pathItem = {
2474
- type: "object",
2475
- origin: "value",
2476
- input,
2477
- key,
2478
- value: value$1
2479
- };
2480
- for (const issue of valueDataset.issues) {
2481
- if (issue.path) issue.path.unshift(pathItem);
2482
- else issue.path = [pathItem];
2483
- dataset.issues?.push(issue);
2484
- }
2485
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2486
- if (config$1.abortEarly) {
2487
- dataset.typed = false;
2488
- break;
2489
- }
2490
- }
2491
- if (!valueDataset.typed) dataset.typed = false;
2492
- dataset.value[key] = valueDataset.value;
2493
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2494
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2495
- _addIssue(this, "key", dataset, config$1, {
2496
- input: void 0,
2497
- expected: `"${key}"`,
2498
- path: [{
2499
- type: "object",
2500
- origin: "key",
2501
- input,
2502
- key,
2503
- value: input[key]
2504
- }]
2505
- });
2506
- if (config$1.abortEarly) break;
2507
- }
2508
- }
2509
- if (!dataset.issues || !config$1.abortEarly) {
2510
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) dataset.value[key] = input[key];
2511
- }
2512
- } else _addIssue(this, "type", dataset, config$1);
2513
- return dataset;
2514
- }
2515
- });
2516
- }
2517
- __name(looseObject, "looseObject");
2518
- // @__NO_SIDE_EFFECTS__
2519
- function null_(message$1) {
2520
- return _standardSchema({
2521
- kind: "schema",
2522
- type: "null",
2523
- reference: null_,
2524
- expects: "null",
2525
- async: false,
2526
- message: message$1,
2527
- "~run"(dataset, config$1) {
2528
- if (dataset.value === null) dataset.typed = true;
2529
- else _addIssue(this, "type", dataset, config$1);
2530
- return dataset;
2531
- }
2532
- });
2533
- }
2534
- __name(null_, "null_");
2535
- // @__NO_SIDE_EFFECTS__
2536
- function nullable(wrapped, default_) {
2537
- return _standardSchema({
2538
- kind: "schema",
2539
- type: "nullable",
2540
- reference: nullable,
2541
- expects: `(${wrapped.expects} | null)`,
2542
- async: false,
2543
- wrapped,
2544
- default: default_,
2545
- "~run"(dataset, config$1) {
2546
- if (dataset.value === null) {
2547
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
2548
- if (dataset.value === null) {
2549
- dataset.typed = true;
2550
- return dataset;
2551
- }
2552
- }
2553
- return this.wrapped["~run"](dataset, config$1);
2554
- }
2555
- });
2556
- }
2557
- __name(nullable, "nullable");
2558
- // @__NO_SIDE_EFFECTS__
2559
- function number(message$1) {
2560
- return _standardSchema({
2561
- kind: "schema",
2562
- type: "number",
2563
- reference: number,
2564
- expects: "number",
2565
- async: false,
2566
- message: message$1,
2567
- "~run"(dataset, config$1) {
2568
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
2569
- else _addIssue(this, "type", dataset, config$1);
2570
- return dataset;
2571
- }
2572
- });
2573
- }
2574
- __name(number, "number");
2575
- // @__NO_SIDE_EFFECTS__
2576
- function object(entries$1, message$1) {
2577
- return _standardSchema({
2578
- kind: "schema",
2579
- type: "object",
2580
- reference: object,
2581
- expects: "Object",
2582
- async: false,
2583
- entries: entries$1,
2584
- message: message$1,
2585
- "~run"(dataset, config$1) {
2586
- const input = dataset.value;
2587
- if (input && typeof input === "object") {
2588
- dataset.typed = true;
2589
- dataset.value = {};
2590
- for (const key in this.entries) {
2591
- const valueSchema = this.entries[key];
2592
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2593
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2594
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2595
- if (valueDataset.issues) {
2596
- const pathItem = {
2597
- type: "object",
2598
- origin: "value",
2599
- input,
2600
- key,
2601
- value: value$1
2602
- };
2603
- for (const issue of valueDataset.issues) {
2604
- if (issue.path) issue.path.unshift(pathItem);
2605
- else issue.path = [pathItem];
2606
- dataset.issues?.push(issue);
2607
- }
2608
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2609
- if (config$1.abortEarly) {
2610
- dataset.typed = false;
2611
- break;
2612
- }
2613
- }
2614
- if (!valueDataset.typed) dataset.typed = false;
2615
- dataset.value[key] = valueDataset.value;
2616
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2617
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2618
- _addIssue(this, "key", dataset, config$1, {
2619
- input: void 0,
2620
- expected: `"${key}"`,
2621
- path: [{
2622
- type: "object",
2623
- origin: "key",
2624
- input,
2625
- key,
2626
- value: input[key]
2627
- }]
2628
- });
2629
- if (config$1.abortEarly) break;
2630
- }
2631
- }
2632
- } else _addIssue(this, "type", dataset, config$1);
2633
- return dataset;
2634
- }
2635
- });
2636
- }
2637
- __name(object, "object");
2638
- // @__NO_SIDE_EFFECTS__
2639
- function objectWithRest(entries$1, rest, message$1) {
2640
- return _standardSchema({
2641
- kind: "schema",
2642
- type: "object_with_rest",
2643
- reference: objectWithRest,
2644
- expects: "Object",
2645
- async: false,
2646
- entries: entries$1,
2647
- rest,
2648
- message: message$1,
2649
- "~run"(dataset, config$1) {
2650
- const input = dataset.value;
2651
- if (input && typeof input === "object") {
2652
- dataset.typed = true;
2653
- dataset.value = {};
2654
- for (const key in this.entries) {
2655
- const valueSchema = this.entries[key];
2656
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2657
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2658
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2659
- if (valueDataset.issues) {
2660
- const pathItem = {
2661
- type: "object",
2662
- origin: "value",
2663
- input,
2664
- key,
2665
- value: value$1
2666
- };
2667
- for (const issue of valueDataset.issues) {
2668
- if (issue.path) issue.path.unshift(pathItem);
2669
- else issue.path = [pathItem];
2670
- dataset.issues?.push(issue);
2671
- }
2672
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2673
- if (config$1.abortEarly) {
2674
- dataset.typed = false;
2675
- break;
2676
- }
2677
- }
2678
- if (!valueDataset.typed) dataset.typed = false;
2679
- dataset.value[key] = valueDataset.value;
2680
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2681
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2682
- _addIssue(this, "key", dataset, config$1, {
2683
- input: void 0,
2684
- expected: `"${key}"`,
2685
- path: [{
2686
- type: "object",
2687
- origin: "key",
2688
- input,
2689
- key,
2690
- value: input[key]
2691
- }]
2692
- });
2693
- if (config$1.abortEarly) break;
2694
- }
2695
- }
2696
- if (!dataset.issues || !config$1.abortEarly) {
2697
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
2698
- const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
2699
- if (valueDataset.issues) {
2700
- const pathItem = {
2701
- type: "object",
2702
- origin: "value",
2703
- input,
2704
- key,
2705
- value: input[key]
2706
- };
2707
- for (const issue of valueDataset.issues) {
2708
- if (issue.path) issue.path.unshift(pathItem);
2709
- else issue.path = [pathItem];
2710
- dataset.issues?.push(issue);
2711
- }
2712
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2713
- if (config$1.abortEarly) {
2714
- dataset.typed = false;
2715
- break;
2716
- }
2717
- }
2718
- if (!valueDataset.typed) dataset.typed = false;
2719
- dataset.value[key] = valueDataset.value;
2720
- }
2721
- }
2722
- } else _addIssue(this, "type", dataset, config$1);
2723
- return dataset;
2724
- }
2725
- });
2726
- }
2727
- __name(objectWithRest, "objectWithRest");
2728
- // @__NO_SIDE_EFFECTS__
2729
- function optional(wrapped, default_) {
2730
- return _standardSchema({
2731
- kind: "schema",
2732
- type: "optional",
2733
- reference: optional,
2734
- expects: `(${wrapped.expects} | undefined)`,
2735
- async: false,
2736
- wrapped,
2737
- default: default_,
2738
- "~run"(dataset, config$1) {
2739
- if (dataset.value === void 0) {
2740
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
2741
- if (dataset.value === void 0) {
2742
- dataset.typed = true;
2743
- return dataset;
2744
- }
2745
- }
2746
- return this.wrapped["~run"](dataset, config$1);
2747
- }
2748
- });
2749
- }
2750
- __name(optional, "optional");
2751
- // @__NO_SIDE_EFFECTS__
2752
- function picklist(options, message$1) {
2753
- return _standardSchema({
2754
- kind: "schema",
2755
- type: "picklist",
2756
- reference: picklist,
2757
- expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
2758
- async: false,
2759
- options,
2760
- message: message$1,
2761
- "~run"(dataset, config$1) {
2762
- if (this.options.includes(dataset.value)) dataset.typed = true;
2763
- else _addIssue(this, "type", dataset, config$1);
2764
- return dataset;
2765
- }
2766
- });
2767
- }
2768
- __name(picklist, "picklist");
2769
- // @__NO_SIDE_EFFECTS__
2770
- function record(key, value$1, message$1) {
2771
- return _standardSchema({
2772
- kind: "schema",
2773
- type: "record",
2774
- reference: record,
2775
- expects: "Object",
2776
- async: false,
2777
- key,
2778
- value: value$1,
2779
- message: message$1,
2780
- "~run"(dataset, config$1) {
2781
- const input = dataset.value;
2782
- if (input && typeof input === "object") {
2783
- dataset.typed = true;
2784
- dataset.value = {};
2785
- for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
2786
- const entryValue = input[entryKey];
2787
- const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
2788
- if (keyDataset.issues) {
2789
- const pathItem = {
2790
- type: "object",
2791
- origin: "key",
2792
- input,
2793
- key: entryKey,
2794
- value: entryValue
2795
- };
2796
- for (const issue of keyDataset.issues) {
2797
- issue.path = [pathItem];
2798
- dataset.issues?.push(issue);
2799
- }
2800
- if (!dataset.issues) dataset.issues = keyDataset.issues;
2801
- if (config$1.abortEarly) {
2802
- dataset.typed = false;
2803
- break;
2804
- }
2805
- }
2806
- const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
2807
- if (valueDataset.issues) {
2808
- const pathItem = {
2809
- type: "object",
2810
- origin: "value",
2811
- input,
2812
- key: entryKey,
2813
- value: entryValue
2814
- };
2815
- for (const issue of valueDataset.issues) {
2816
- if (issue.path) issue.path.unshift(pathItem);
2817
- else issue.path = [pathItem];
2818
- dataset.issues?.push(issue);
2819
- }
2820
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2821
- if (config$1.abortEarly) {
2822
- dataset.typed = false;
2823
- break;
2824
- }
2825
- }
2826
- if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
2827
- if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
2828
- }
2829
- } else _addIssue(this, "type", dataset, config$1);
2830
- return dataset;
2831
- }
2832
- });
2833
- }
2834
- __name(record, "record");
2835
- // @__NO_SIDE_EFFECTS__
2836
- function strictObject(entries$1, message$1) {
2837
- return _standardSchema({
2838
- kind: "schema",
2839
- type: "strict_object",
2840
- reference: strictObject,
2841
- expects: "Object",
2842
- async: false,
2843
- entries: entries$1,
2844
- message: message$1,
2845
- "~run"(dataset, config$1) {
2846
- const input = dataset.value;
2847
- if (input && typeof input === "object") {
2848
- dataset.typed = true;
2849
- dataset.value = {};
2850
- for (const key in this.entries) {
2851
- const valueSchema = this.entries[key];
2852
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2853
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2854
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2855
- if (valueDataset.issues) {
2856
- const pathItem = {
2857
- type: "object",
2858
- origin: "value",
2859
- input,
2860
- key,
2861
- value: value$1
2862
- };
2863
- for (const issue of valueDataset.issues) {
2864
- if (issue.path) issue.path.unshift(pathItem);
2865
- else issue.path = [pathItem];
2866
- dataset.issues?.push(issue);
2867
- }
2868
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2869
- if (config$1.abortEarly) {
2870
- dataset.typed = false;
2871
- break;
2872
- }
2873
- }
2874
- if (!valueDataset.typed) dataset.typed = false;
2875
- dataset.value[key] = valueDataset.value;
2876
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2877
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2878
- _addIssue(this, "key", dataset, config$1, {
2879
- input: void 0,
2880
- expected: `"${key}"`,
2881
- path: [{
2882
- type: "object",
2883
- origin: "key",
2884
- input,
2885
- key,
2886
- value: input[key]
2887
- }]
2888
- });
2889
- if (config$1.abortEarly) break;
2890
- }
2891
- }
2892
- if (!dataset.issues || !config$1.abortEarly) {
2893
- for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
2894
- _addIssue(this, "key", dataset, config$1, {
2895
- input: key,
2896
- expected: "never",
2897
- path: [{
2898
- type: "object",
2899
- origin: "key",
2900
- input,
2901
- key,
2902
- value: input[key]
2903
- }]
2904
- });
2905
- break;
2906
- }
2907
- }
2908
- } else _addIssue(this, "type", dataset, config$1);
2909
- return dataset;
2910
- }
2911
- });
2912
- }
2913
- __name(strictObject, "strictObject");
2914
- // @__NO_SIDE_EFFECTS__
2915
- function string(message$1) {
2916
- return _standardSchema({
2917
- kind: "schema",
2918
- type: "string",
2919
- reference: string,
2920
- expects: "string",
2921
- async: false,
2922
- message: message$1,
2923
- "~run"(dataset, config$1) {
2924
- if (typeof dataset.value === "string") dataset.typed = true;
2925
- else _addIssue(this, "type", dataset, config$1);
2926
- return dataset;
2927
- }
2928
- });
2929
- }
2930
- __name(string, "string");
2931
- // @__NO_SIDE_EFFECTS__
2932
- function _subIssues(datasets) {
2933
- let issues;
2934
- if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
2935
- else issues = dataset.issues;
2936
- return issues;
2937
- }
2938
- __name(_subIssues, "_subIssues");
2939
- // @__NO_SIDE_EFFECTS__
2940
- function union(options, message$1) {
2941
- return _standardSchema({
2942
- kind: "schema",
2943
- type: "union",
2944
- reference: union,
2945
- expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
2946
- async: false,
2947
- options,
2948
- message: message$1,
2949
- "~run"(dataset, config$1) {
2950
- let validDataset;
2951
- let typedDatasets;
2952
- let untypedDatasets;
2953
- for (const schema of this.options) {
2954
- const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
2955
- if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
2956
- else typedDatasets = [optionDataset];
2957
- else {
2958
- validDataset = optionDataset;
2959
- break;
2960
- }
2961
- else if (untypedDatasets) untypedDatasets.push(optionDataset);
2962
- else untypedDatasets = [optionDataset];
2963
- }
2964
- if (validDataset) return validDataset;
2965
- if (typedDatasets) {
2966
- if (typedDatasets.length === 1) return typedDatasets[0];
2967
- _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
2968
- dataset.typed = true;
2969
- } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
2970
- else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
2971
- return dataset;
2972
- }
2973
- });
2974
- }
2975
- __name(union, "union");
2976
- // @__NO_SIDE_EFFECTS__
2977
- function unknown() {
2978
- return _standardSchema({
2979
- kind: "schema",
2980
- type: "unknown",
2981
- reference: unknown,
2982
- expects: "unknown",
2983
- async: false,
2984
- "~run"(dataset) {
2985
- dataset.typed = true;
2986
- return dataset;
2987
- }
2988
- });
2989
- }
2990
- __name(unknown, "unknown");
2991
- // @__NO_SIDE_EFFECTS__
2992
- function variant(key, options, message$1) {
2993
- return _standardSchema({
2994
- kind: "schema",
2995
- type: "variant",
2996
- reference: variant,
2997
- expects: "Object",
2998
- async: false,
2999
- key,
3000
- options,
3001
- message: message$1,
3002
- "~run"(dataset, config$1) {
3003
- const input = dataset.value;
3004
- if (input && typeof input === "object") {
3005
- let outputDataset;
3006
- let maxDiscriminatorPriority = 0;
3007
- let invalidDiscriminatorKey = this.key;
3008
- let expectedDiscriminators = [];
3009
- const parseOptions = /* @__PURE__ */ __name((variant$1, allKeys) => {
3010
- for (const schema of variant$1.options) {
3011
- if (schema.type === "variant") parseOptions(schema, new Set(allKeys).add(schema.key));
3012
- else {
3013
- let keysAreValid = true;
3014
- let currentPriority = 0;
3015
- for (const currentKey of allKeys) {
3016
- const discriminatorSchema = schema.entries[currentKey];
3017
- if (currentKey in input ? discriminatorSchema["~run"]({
3018
- typed: false,
3019
- value: input[currentKey]
3020
- }, ABORT_EARLY_CONFIG).issues : discriminatorSchema.type !== "exact_optional" && discriminatorSchema.type !== "optional" && discriminatorSchema.type !== "nullish") {
3021
- keysAreValid = false;
3022
- if (invalidDiscriminatorKey !== currentKey && (maxDiscriminatorPriority < currentPriority || maxDiscriminatorPriority === currentPriority && currentKey in input && !(invalidDiscriminatorKey in input))) {
3023
- maxDiscriminatorPriority = currentPriority;
3024
- invalidDiscriminatorKey = currentKey;
3025
- expectedDiscriminators = [];
3026
- }
3027
- if (invalidDiscriminatorKey === currentKey) expectedDiscriminators.push(schema.entries[currentKey].expects);
3028
- break;
3029
- }
3030
- currentPriority++;
3031
- }
3032
- if (keysAreValid) {
3033
- const optionDataset = schema["~run"]({ value: input }, config$1);
3034
- if (!outputDataset || !outputDataset.typed && optionDataset.typed) outputDataset = optionDataset;
3035
- }
3036
- }
3037
- if (outputDataset && !outputDataset.issues) break;
3038
- }
3039
- }, "parseOptions");
3040
- parseOptions(this, /* @__PURE__ */ new Set([this.key]));
3041
- if (outputDataset) return outputDataset;
3042
- _addIssue(this, "type", dataset, config$1, {
3043
- input: input[invalidDiscriminatorKey],
3044
- expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
3045
- path: [{
3046
- type: "object",
3047
- origin: "value",
3048
- input,
3049
- key: invalidDiscriminatorKey,
3050
- value: input[invalidDiscriminatorKey]
3051
- }]
3052
- });
3053
- } else _addIssue(this, "type", dataset, config$1);
3054
- return dataset;
3055
- }
3056
- });
3057
- }
3058
- __name(variant, "variant");
3059
- // @__NO_SIDE_EFFECTS__
3060
- function omit(schema, keys) {
3061
- const entries$1 = { ...schema.entries };
3062
- for (const key of keys) delete entries$1[key];
3063
- return _standardSchema({
3064
- ...schema,
3065
- entries: entries$1
3066
- });
3067
- }
3068
- __name(omit, "omit");
3069
- function parse(schema, input, config$1) {
3070
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
3071
- if (dataset.issues) throw new ValiError(dataset.issues);
3072
- return dataset.value;
3073
- }
3074
- __name(parse, "parse");
3075
- // @__NO_SIDE_EFFECTS__
3076
- function partial(schema, keys) {
3077
- const entries$1 = {};
3078
- for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
3079
- return _standardSchema({
3080
- ...schema,
3081
- entries: entries$1
3082
- });
3083
- }
3084
- __name(partial, "partial");
3085
- // @__NO_SIDE_EFFECTS__
3086
- function pick(schema, keys) {
3087
- const entries$1 = {};
3088
- for (const key of keys) entries$1[key] = schema.entries[key];
3089
- return _standardSchema({
3090
- ...schema,
3091
- entries: entries$1
3092
- });
3093
- }
3094
- __name(pick, "pick");
3095
- // @__NO_SIDE_EFFECTS__
3096
- function pipe(...pipe$1) {
3097
- return _standardSchema({
3098
- ...pipe$1[0],
3099
- pipe: pipe$1,
3100
- "~run"(dataset, config$1) {
3101
- for (const item of pipe$1) if (item.kind !== "metadata") {
3102
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
3103
- dataset.typed = false;
3104
- break;
3105
- }
3106
- if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
3107
- }
3108
- return dataset;
3109
- }
3110
- });
3111
- }
3112
- __name(pipe, "pipe");
3113
- // @__NO_SIDE_EFFECTS__
3114
- function safeParse(schema, input, config$1) {
3115
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
3116
- return {
3117
- typed: dataset.typed,
3118
- success: !dataset.issues,
3119
- output: dataset.value,
3120
- issues: dataset.issues
3121
- };
3122
- }
3123
- __name(safeParse, "safeParse");
3124
- // @__NO_SIDE_EFFECTS__
3125
- function summarize(issues) {
3126
- let summary = "";
3127
- for (const issue of issues) {
3128
- if (summary) summary += "\n";
3129
- summary += `\xD7 ${issue.message}`;
3130
- const dotPath = /* @__PURE__ */ getDotPath(issue);
3131
- if (dotPath) summary += `
3132
- \u2192 at ${dotPath}`;
3133
- }
3134
- return summary;
3135
- }
3136
- __name(summarize, "summarize");
3137
- // @__NO_SIDE_EFFECTS__
3138
- function unwrap(schema) {
3139
- return schema.wrapped;
3140
- }
3141
- __name(unwrap, "unwrap");
3142
-
3143
- // node_modules/.pnpm/@valibot+to-json-schema@1.8.0_valibot@1.5.0_typescript@7.0.2_/node_modules/@valibot/to-json-schema/dist/index.mjs
3144
- function addError(errors, message) {
3145
- if (errors) {
3146
- errors.push(message);
3147
- return errors;
3148
- }
3149
- return [message];
3150
- }
3151
- __name(addError, "addError");
3152
- var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
3153
- function escapeRegExp(string2) {
3154
- return string2.replace(ESCAPE_REGEX, "\\$&");
3155
- }
3156
- __name(escapeRegExp, "escapeRegExp");
3157
- function handleError(message, config) {
3158
- switch (config?.errorMode) {
3159
- case "ignore":
3160
- break;
3161
- case "warn":
3162
- console.warn(message);
3163
- break;
3164
- default:
3165
- throw new Error(message);
3166
- }
3167
- }
3168
- __name(handleError, "handleError");
3169
- function isJsonConstValue(value) {
3170
- return typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || typeof value === "string";
3171
- }
3172
- __name(isJsonConstValue, "isJsonConstValue");
3173
- function isJsonEnumValues(values) {
3174
- return values.every(isJsonConstValue);
3175
- }
3176
- __name(isJsonEnumValues, "isJsonEnumValues");
3177
- var ReferenceMap = class extends Map {
3178
- static {
3179
- __name(this, "ReferenceMap");
3180
- }
3181
- /**
3182
- * Creates an empty schema reference map.
3183
- */
3184
- constructor() {
3185
- super();
3186
- this.count = 0;
3187
- this.usedIds = /* @__PURE__ */ new Set();
3188
- }
3189
- /**
3190
- * Adds a schema reference and reserves its ID.
3191
- *
3192
- * @param schema The Valibot schema.
3193
- * @param referenceId The reference ID.
3194
- *
3195
- * @returns The reference map.
3196
- */
3197
- set(schema, referenceId) {
3198
- this.usedIds.add(referenceId);
3199
- return super.set(schema, referenceId);
3200
- }
3201
- /**
3202
- * Creates a reference ID that is not yet used.
3203
- *
3204
- * @param definitions The JSON Schema definitions.
3205
- *
3206
- * @returns The unused reference ID.
3207
- */
3208
- createId(definitions) {
3209
- while (this.usedIds.has(`${this.count}`) || `${this.count}` in definitions) this.count++;
3210
- return `${this.count++}`;
3211
- }
3212
- };
3213
- function getLowerBound(current, value) {
3214
- if (typeof current !== "number" || !Number.isFinite(current) || value > current) return value;
3215
- return current;
3216
- }
3217
- __name(getLowerBound, "getLowerBound");
3218
- function getUpperBound(current, value) {
3219
- if (typeof current !== "number" || !Number.isFinite(current) || value < current) return value;
3220
- return current;
3221
- }
3222
- __name(getUpperBound, "getUpperBound");
3223
- // @__NO_SIDE_EFFECTS__
3224
- function getNotRestriction(current, value) {
3225
- return current !== void 0 ? { anyOf: [current, value] } : value;
3226
- }
3227
- __name(getNotRestriction, "getNotRestriction");
3228
- function intersectEnum(jsonSchema, values) {
3229
- let enumValues = jsonSchema.enum ?? values;
3230
- if (jsonSchema.enum) {
3231
- const valueSet = new Set(values);
3232
- enumValues = enumValues.filter((value) => valueSet.has(value));
3233
- }
3234
- if (enumValues.length) jsonSchema.enum = [...new Set(enumValues)];
3235
- else {
3236
- delete jsonSchema.enum;
3237
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, {});
3238
- }
3239
- }
3240
- __name(intersectEnum, "intersectEnum");
3241
- function convertAction(jsonSchema, valibotAction, config) {
3242
- if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
3243
- let errors;
3244
- switch (valibotAction.type) {
3245
- case "base64":
3246
- jsonSchema.contentEncoding = "base64";
3247
- break;
3248
- case "bic":
3249
- case "cuid2":
3250
- case "decimal":
3251
- case "digits":
3252
- case "domain":
3253
- case "emoji":
3254
- case "hash":
3255
- case "hexadecimal":
3256
- case "hex_color":
3257
- case "isrc":
3258
- case "iso_time_second":
3259
- case "iso_week":
3260
- case "ksuid":
3261
- case "mac":
3262
- case "mac48":
3263
- case "mac64":
3264
- case "nanoid":
3265
- case "octal":
3266
- case "slug":
3267
- case "ulid":
3268
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3269
- else jsonSchema.pattern = valibotAction.requirement.source;
3270
- break;
3271
- case "description":
3272
- jsonSchema.description = valibotAction.description;
3273
- break;
3274
- case "email":
3275
- case "rfc_email":
3276
- jsonSchema.format = "email";
3277
- break;
3278
- case "ends_with":
3279
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3280
- else jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
3281
- break;
3282
- case "empty":
3283
- if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
3284
- else {
3285
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3286
- jsonSchema.maxLength = 0;
3287
- }
3288
- break;
3289
- case "entries":
3290
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3291
- errors = addError(errors, 'The requirement of the "entries" action must be a non-negative integer.');
3292
- break;
3293
- }
3294
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
3295
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
3296
- break;
3297
- case "examples":
3298
- if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples];
3299
- else jsonSchema.examples = valibotAction.examples;
3300
- break;
3301
- case "gt_value":
3302
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3303
- errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
3304
- break;
3305
- }
3306
- if (!Number.isFinite(valibotAction.requirement)) {
3307
- errors = addError(errors, 'The requirement of the "gt_value" action is not JSON compatible.');
3308
- break;
3309
- }
3310
- if (config?.target === "openapi-3.0") {
3311
- errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
3312
- break;
3313
- }
3314
- jsonSchema.exclusiveMinimum = getLowerBound(jsonSchema.exclusiveMinimum, valibotAction.requirement);
3315
- break;
3316
- case "includes":
3317
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3318
- else jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
3319
- break;
3320
- case "integer":
3321
- jsonSchema.type = "integer";
3322
- break;
3323
- case "ipv4":
3324
- jsonSchema.format = "ipv4";
3325
- break;
3326
- case "ipv6":
3327
- jsonSchema.format = "ipv6";
3328
- break;
3329
- case "iso_date":
3330
- jsonSchema.format = "date";
3331
- break;
3332
- case "iso_date_time":
3333
- case "iso_timestamp":
3334
- jsonSchema.format = "date-time";
3335
- break;
3336
- case "iso_time":
3337
- jsonSchema.format = "time";
3338
- break;
3339
- case "jws_compact":
3340
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3341
- else jsonSchema.pattern = valibotAction.requirement.source;
3342
- break;
3343
- case "length":
3344
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3345
- errors = addError(errors, 'The requirement of the "length" action must be a non-negative integer.');
3346
- break;
3347
- }
3348
- if (jsonSchema.type === "array") {
3349
- jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
3350
- jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
3351
- } else {
3352
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3353
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
3354
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
3355
- }
3356
- break;
3357
- case "lt_value":
3358
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3359
- errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
3360
- break;
3361
- }
3362
- if (!Number.isFinite(valibotAction.requirement)) {
3363
- errors = addError(errors, 'The requirement of the "lt_value" action is not JSON compatible.');
3364
- break;
3365
- }
3366
- if (config?.target === "openapi-3.0") {
3367
- errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
3368
- break;
3369
- }
3370
- jsonSchema.exclusiveMaximum = getUpperBound(jsonSchema.exclusiveMaximum, valibotAction.requirement);
3371
- break;
3372
- case "max_entries":
3373
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3374
- errors = addError(errors, 'The requirement of the "max_entries" action must be a non-negative integer.');
3375
- break;
3376
- }
3377
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
3378
- break;
3379
- case "max_length":
3380
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3381
- errors = addError(errors, 'The requirement of the "max_length" action must be a non-negative integer.');
3382
- break;
3383
- }
3384
- if (jsonSchema.type === "array") jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
3385
- else {
3386
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3387
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
3388
- }
3389
- break;
3390
- case "max_value":
3391
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3392
- errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
3393
- break;
3394
- }
3395
- if (!Number.isFinite(valibotAction.requirement)) {
3396
- errors = addError(errors, 'The requirement of the "max_value" action is not JSON compatible.');
3397
- break;
3398
- }
3399
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, valibotAction.requirement);
3400
- break;
3401
- case "metadata":
3402
- if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
3403
- if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
3404
- if (Array.isArray(valibotAction.metadata.examples)) if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples];
3405
- else jsonSchema.examples = valibotAction.metadata.examples;
3406
- for (const key of Object.keys(valibotAction.metadata)) if (key !== "title" && key !== "description" && key !== "examples" && key !== "__proto__") jsonSchema[key] = valibotAction.metadata[key];
3407
- break;
3408
- case "min_entries":
3409
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3410
- errors = addError(errors, 'The requirement of the "min_entries" action must be a non-negative integer.');
3411
- break;
3412
- }
3413
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
3414
- break;
3415
- case "min_length":
3416
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3417
- errors = addError(errors, 'The requirement of the "min_length" action must be a non-negative integer.');
3418
- break;
3419
- }
3420
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
3421
- else {
3422
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3423
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
3424
- }
3425
- break;
3426
- case "min_value":
3427
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3428
- errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
3429
- break;
3430
- }
3431
- if (!Number.isFinite(valibotAction.requirement)) {
3432
- errors = addError(errors, 'The requirement of the "min_value" action is not JSON compatible.');
3433
- break;
3434
- }
3435
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, valibotAction.requirement);
3436
- break;
3437
- case "multiple_of":
3438
- jsonSchema.multipleOf = valibotAction.requirement;
3439
- break;
3440
- case "non_empty":
3441
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, 1);
3442
- else {
3443
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3444
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, 1);
3445
- }
3446
- break;
3447
- case "not_value":
3448
- if (!isJsonConstValue(valibotAction.requirement)) {
3449
- errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
3450
- break;
3451
- }
3452
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, config?.target === "openapi-3.0" ? { enum: [valibotAction.requirement] } : { const: valibotAction.requirement });
3453
- break;
3454
- case "not_values":
3455
- if (!isJsonEnumValues(valibotAction.requirement)) {
3456
- errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
3457
- break;
3458
- }
3459
- if (valibotAction.requirement.length) jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, { enum: [...new Set(valibotAction.requirement)] });
3460
- break;
3461
- case "regex":
3462
- if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
3463
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3464
- else jsonSchema.pattern = valibotAction.requirement.source;
3465
- break;
3466
- case "safe_integer":
3467
- jsonSchema.type = "integer";
3468
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, Number.MIN_SAFE_INTEGER);
3469
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, Number.MAX_SAFE_INTEGER);
3470
- break;
3471
- case "starts_with":
3472
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3473
- else jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
3474
- break;
3475
- case "title":
3476
- jsonSchema.title = valibotAction.title;
3477
- break;
3478
- case "url":
3479
- jsonSchema.format = "uri";
3480
- break;
3481
- case "uuid":
3482
- jsonSchema.format = "uuid";
3483
- break;
3484
- case "value":
3485
- if (!isJsonConstValue(valibotAction.requirement)) {
3486
- errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
3487
- break;
3488
- }
3489
- if (config?.target === "openapi-3.0") intersectEnum(jsonSchema, [valibotAction.requirement]);
3490
- else if ("const" in jsonSchema && jsonSchema.const !== valibotAction.requirement) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with a different "const" restriction.`);
3491
- else jsonSchema.const = valibotAction.requirement;
3492
- break;
3493
- case "values":
3494
- if (!isJsonEnumValues(valibotAction.requirement)) {
3495
- errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
3496
- break;
3497
- }
3498
- intersectEnum(jsonSchema, valibotAction.requirement);
3499
- break;
3500
- default:
3501
- errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
3502
- }
3503
- if (config?.overrideAction) {
3504
- const actionOverride = config.overrideAction({
3505
- valibotAction,
3506
- jsonSchema,
3507
- errors
3508
- });
3509
- if (actionOverride) return { ...actionOverride };
3510
- }
3511
- if (errors) for (const message of errors) handleError(message, config);
3512
- return jsonSchema;
3513
- }
3514
- __name(convertAction, "convertAction");
3515
- function flattenPipe(pipe2) {
3516
- return pipe2.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
3517
- }
3518
- __name(flattenPipe, "flattenPipe");
3519
- function getDefinitionRef(referenceId) {
3520
- return `#/$defs/${referenceId.replaceAll("~", "~0").replaceAll("/", "~1")}`;
3521
- }
3522
- __name(getDefinitionRef, "getDefinitionRef");
3523
- function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
3524
- if (!skipRef) {
3525
- const referenceId = context.referenceMap.get(valibotSchema);
3526
- if (referenceId) {
3527
- jsonSchema.$ref = getDefinitionRef(referenceId);
3528
- if (config?.overrideRef) {
3529
- const refOverride = config.overrideRef({
3530
- ...context,
3531
- referenceId,
3532
- valibotSchema,
3533
- jsonSchema
3534
- });
3535
- if (refOverride) jsonSchema.$ref = refOverride;
3536
- }
3537
- return jsonSchema;
3538
- }
3539
- }
3540
- if ("pipe" in valibotSchema) {
3541
- const flatPipe = flattenPipe(valibotSchema.pipe);
3542
- let startIndex = 0;
3543
- let stopIndex = flatPipe.length - 1;
3544
- if (config?.typeMode === "input") {
3545
- const inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "to_bigint" || item.type === "to_boolean" || item.type === "to_date" || item.type === "to_number" || item.type === "to_string" || item.type === "transform"));
3546
- if (inputStopIndex !== -1) stopIndex = inputStopIndex;
3547
- } else if (config?.typeMode === "output") {
3548
- const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
3549
- if (outputStartIndex !== -1) startIndex = outputStartIndex;
3550
- }
3551
- for (let index = startIndex; index <= stopIndex; index++) {
3552
- const valibotPipeItem = flatPipe[index];
3553
- if (valibotPipeItem.kind === "schema") {
3554
- if (index > startIndex) handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config);
3555
- jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
3556
- } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
3557
- }
3558
- return jsonSchema;
3559
- }
3560
- let errors;
3561
- switch (valibotSchema.type) {
3562
- case "boolean":
3563
- jsonSchema.type = "boolean";
3564
- break;
3565
- case "null":
3566
- if (config?.target === "openapi-3.0") jsonSchema.enum = [null];
3567
- else jsonSchema.type = "null";
3568
- break;
3569
- case "number":
3570
- jsonSchema.type = "number";
3571
- break;
3572
- case "string":
3573
- jsonSchema.type = "string";
3574
- break;
3575
- case "array":
3576
- jsonSchema.type = "array";
3577
- jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
3578
- break;
3579
- case "tuple":
3580
- case "tuple_with_rest":
3581
- case "loose_tuple":
3582
- case "strict_tuple":
3583
- jsonSchema.type = "array";
3584
- if (config?.target === "openapi-3.0") {
3585
- jsonSchema.items = { anyOf: [] };
3586
- jsonSchema.minItems = valibotSchema.items.length;
3587
- for (const item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
3588
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context));
3589
- else if (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") jsonSchema.maxItems = valibotSchema.items.length;
3590
- } else if (config?.target === "draft-2020-12") {
3591
- jsonSchema.prefixItems = [];
3592
- jsonSchema.minItems = valibotSchema.items.length;
3593
- for (const item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
3594
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context);
3595
- else if (valibotSchema.type === "strict_tuple") jsonSchema.items = false;
3596
- } else {
3597
- jsonSchema.items = [];
3598
- jsonSchema.minItems = valibotSchema.items.length;
3599
- for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
3600
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
3601
- else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
3602
- }
3603
- break;
3604
- case "object":
3605
- case "object_with_rest":
3606
- case "loose_object":
3607
- case "strict_object":
3608
- jsonSchema.type = "object";
3609
- jsonSchema.properties = {};
3610
- jsonSchema.required = [];
3611
- for (const key in valibotSchema.entries) {
3612
- const entry2 = valibotSchema.entries[key];
3613
- jsonSchema.properties[key] = convertSchema({}, entry2, config, context);
3614
- if (entry2.type !== "exact_optional" && entry2.type !== "nullish" && entry2.type !== "optional") jsonSchema.required.push(key);
3615
- }
3616
- if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
3617
- else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
3618
- break;
3619
- case "record":
3620
- if (config?.target === "openapi-3.0" && "pipe" in valibotSchema.key) errors = addError(errors, 'The "record" schema with a schema for the key that contains a "pipe" cannot be converted to JSON Schema.');
3621
- if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
3622
- jsonSchema.type = "object";
3623
- if (config?.target !== "openapi-3.0") jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context);
3624
- jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
3625
- break;
3626
- case "any":
3627
- case "unknown":
3628
- break;
3629
- case "never":
3630
- jsonSchema.not = {};
3631
- break;
3632
- case "nullable":
3633
- case "nullish":
3634
- if (config?.target === "openapi-3.0") {
3635
- const innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
3636
- Object.assign(jsonSchema, innerSchema);
3637
- jsonSchema.nullable = true;
3638
- } else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
3639
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
3640
- break;
3641
- case "exact_optional":
3642
- case "optional":
3643
- case "undefinedable":
3644
- jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
3645
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
3646
- break;
3647
- case "literal":
3648
- if (!isJsonConstValue(valibotSchema.literal)) {
3649
- errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
3650
- break;
3651
- }
3652
- if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotSchema.literal];
3653
- else jsonSchema.const = valibotSchema.literal;
3654
- break;
3655
- case "enum":
3656
- case "picklist": {
3657
- const options = valibotSchema.options;
3658
- if (!options.every((option) => typeof option === "string" || typeof option === "number" && Number.isFinite(option))) {
3659
- errors = addError(errors, `An option of the "${valibotSchema.type}" schema is not JSON compatible.`);
3660
- break;
3661
- }
3662
- jsonSchema.enum = options;
3663
- if (options.every((option) => typeof option === "string")) jsonSchema.type = "string";
3664
- else if (options.every((option) => typeof option === "number")) jsonSchema.type = "number";
3665
- else if (config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
3666
- break;
3667
- }
3668
- case "union":
3669
- jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3670
- break;
3671
- case "variant":
3672
- jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3673
- break;
3674
- case "intersect":
3675
- jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3676
- break;
3677
- case "lazy": {
3678
- let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
3679
- if (!wrappedValibotSchema) {
3680
- wrappedValibotSchema = valibotSchema.getter(void 0);
3681
- context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
3682
- }
3683
- let referenceId = context.referenceMap.get(wrappedValibotSchema);
3684
- if (!referenceId) {
3685
- referenceId = context.referenceMap.createId(context.definitions);
3686
- context.referenceMap.set(wrappedValibotSchema, referenceId);
3687
- context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
3688
- }
3689
- jsonSchema.$ref = getDefinitionRef(referenceId);
3690
- if (config?.overrideRef) {
3691
- const refOverride = config.overrideRef({
3692
- ...context,
3693
- referenceId,
3694
- valibotSchema: wrappedValibotSchema,
3695
- jsonSchema
3696
- });
3697
- if (refOverride) jsonSchema.$ref = refOverride;
3698
- }
3699
- break;
3700
- }
3701
- default:
3702
- errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
3703
- }
3704
- if (config?.overrideSchema) {
3705
- const schemaOverride = config.overrideSchema({
3706
- ...context,
3707
- referenceId: context.referenceMap.get(valibotSchema),
3708
- valibotSchema,
3709
- jsonSchema,
3710
- errors
3711
- });
3712
- if (schemaOverride) return { ...schemaOverride };
3713
- }
3714
- if (errors) for (const message of errors) handleError(message, config);
3715
- return jsonSchema;
3716
- }
3717
- __name(convertSchema, "convertSchema");
3718
- var store;
3719
- function getGlobalDefs() {
3720
- return store;
3721
- }
3722
- __name(getGlobalDefs, "getGlobalDefs");
3723
- function toJsonSchema(schema, config) {
3724
- const context = {
3725
- definitions: {},
3726
- referenceMap: new ReferenceMap(),
3727
- getterMap: /* @__PURE__ */ new Map()
3728
- };
3729
- const definitions = config?.definitions ?? getGlobalDefs();
3730
- if (definitions) {
3731
- for (const key in definitions) context.referenceMap.set(definitions[key], key);
3732
- for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
3733
- }
3734
- const jsonSchema = convertSchema({}, schema, config, context);
3735
- const target = config?.target ?? "draft-07";
3736
- if (target === "draft-2020-12") jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema";
3737
- else if (target === "draft-07") jsonSchema.$schema = "http://json-schema.org/draft-07/schema#";
3738
- if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
3739
- return jsonSchema;
3740
- }
3741
- __name(toJsonSchema, "toJsonSchema");
3742
- var SUPPORTED_TARGETS = [
3743
- "draft-07",
3744
- "draft-2020-12",
3745
- "openapi-3.0"
3746
- ];
3747
- function toStandardJsonSchema(schema) {
3748
- return { "~standard": {
3749
- ...schema["~standard"],
3750
- jsonSchema: {
3751
- input(options) {
3752
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
3753
- typeMode: "input",
3754
- target: options.target,
3755
- ...options.libraryOptions
3756
- });
3757
- throw new Error(`Unsupported target: ${options.target}`);
3758
- },
3759
- output(options) {
3760
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
3761
- typeMode: "output",
3762
- target: options.target,
3763
- ...options.libraryOptions
3764
- });
3765
- throw new Error(`Unsupported target: ${options.target}`);
3766
- }
3767
- }
3768
- } };
3769
- }
3770
- __name(toStandardJsonSchema, "toStandardJsonSchema");
3771
-
3772
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/registry.js
3773
- var word = pipe(string(), regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "a lower-case word, words joined by -"));
3774
- var SNAKE_CASE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
3775
- var text = pipe(string(), regex(/\S/, "must not be empty"));
3776
- var dottedId = pipe(string(), regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/, "dotted lower-case words, such as `page.next`"));
3777
- var RegistryError = class extends Error {
3778
- static {
3779
- __name(this, "RegistryError");
3780
- }
3781
- registry;
3782
- problems;
3783
- constructor(registry, problems) {
3784
- super(`${registry} registry: ${problems.join("; ")}`);
3785
- this.registry = registry;
3786
- this.problems = problems;
3787
- this.name = "RegistryError";
3788
- }
3789
- };
3790
- var issuesOf = /* @__PURE__ */ __name((issues) => issues.map((issue) => {
3791
- const path = getDotPath(issue);
3792
- return path ? `${path}: ${issue.message}` : issue.message;
3793
- }), "issuesOf");
3794
- var parseRegistry = /* @__PURE__ */ __name((registry, schema, input, check2 = () => []) => {
3795
- const parsed = safeParse(schema, input);
3796
- if (!parsed.success)
3797
- throw new RegistryError(registry, issuesOf(parsed.issues));
3798
- const problems = check2(parsed.output);
3799
- if (problems.length > 0)
3800
- throw new RegistryError(registry, problems);
3801
- return parsed.output;
3802
- }, "parseRegistry");
3803
- var duplicates = /* @__PURE__ */ __name((values) => [...new Set(values.filter((value, index) => values.indexOf(value) !== index))].sort(), "duplicates");
3804
- var jsonSchemaOf = /* @__PURE__ */ __name((schema, definitions) => toJsonSchema(schema, { target: "draft-2020-12", ...definitions ? { definitions } : {} }), "jsonSchemaOf");
3805
- var PLACEHOLDER = /\{([a-z][a-z0-9]*(?:_[a-z0-9]+)*)\}/g;
3806
- var placeholders = /* @__PURE__ */ __name((template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1] ?? ""), "placeholders");
3807
- var fill = /* @__PURE__ */ __name((template, values) => template.replace(PLACEHOLDER, (_, name) => {
3808
- const value = values[name];
3809
- if (value === void 0)
3810
- throw new Error(`no value for {${name}} in "${template}"`);
3811
- return String(value);
3812
- }), "fill");
3813
-
3814
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/exit-codes.js
3815
- var EXIT_CODES = {
3816
- validation_error: 2,
3817
- configuration_error: 3,
3818
- authentication_error: 4,
3819
- permission_error: 5,
3820
- not_found: 6,
3821
- confirmation_required: 7,
3822
- rate_limited: 8,
3823
- timeout: 9,
3824
- network_error: 10,
3825
- provider_error: 11,
3826
- provider_unavailable: 12,
3827
- invalid_response: 13,
3828
- outcome_unknown: 14,
3829
- cancelled: 130
3830
- };
3831
- var exitCodeFor = /* @__PURE__ */ __name((code) => EXIT_CODES[code], "exitCodeFor");
3832
- var GENERIC_FAILURE = 1;
3833
-
3834
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/sanitize.js
3835
- var CONTROL = (
3836
- // biome-ignore lint/suspicious/noControlCharactersInRegex: matching them is the whole point
3837
- /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u200B\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF\u{E0000}-\u{E007F}]/gu
3838
- );
3839
- var SUBDIVISION_FLAG = /\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}/gu;
3840
- var LINE_BREAKS = /[\t\n\u2028\u2029]/g;
3841
- var escaped = /* @__PURE__ */ __name((c) => {
3842
- const code = c.codePointAt(0) ?? 0;
3843
- if (code > 65535)
3844
- return `\\u{${code.toString(16)}}`;
3845
- return code > 255 ? `\\u${code.toString(16).padStart(4, "0")}` : `\\x${code.toString(16).padStart(2, "0")}`;
3846
- }, "escaped");
3847
- var visibleControls = /* @__PURE__ */ __name((text2) => {
3848
- let at = 0;
3849
- let result = "";
3850
- for (const flag of text2.matchAll(SUBDIVISION_FLAG)) {
3851
- result += text2.slice(at, flag.index).replace(CONTROL, escaped) + flag[0];
3852
- at = flag.index + flag[0].length;
3853
- }
3854
- return result + text2.slice(at).replace(CONTROL, escaped);
3855
- }, "visibleControls");
3856
- var singleLine = /* @__PURE__ */ __name((text2) => visibleControls(text2).replace(LINE_BREAKS, escaped), "singleLine");
3857
-
3858
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/effects.js
3859
- var EFFECT_LEVELS = ["none", "read", "write"];
3860
- var effectsSchema = strictObject({
3861
- remote: picklist(EFFECT_LEVELS),
3862
- local: picklist(EFFECT_LEVELS)
3863
- });
3864
- var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
3865
-
3866
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/output.js
3867
- var MAX_NEXT_STEPS = 2;
3868
- var isoTime = pipe(string(), isoTimestamp("an ISO 8601 time in UTC"), endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"));
3869
- var reference = pipe(string(), regex(/^[a-z]+:\S+$/, "a reference such as `note:42`"));
3870
- var nextStepSchema = variant("kind", [
3871
- strictObject({
3872
- kind: literal("command"),
3873
- step: dottedId,
3874
- /** The command path as one string, `messages list` — what the MCP router tools take as `command`. */
3875
- command: text,
3876
- args: record(string(), unknown()),
3877
- /**
3878
- * The whole line to type, with the tool and the profile it ran with: `tg personal mcp config`. Only the CLI
3879
- * knows the profile, so it fills this; MCP answers leave it out.
3880
- */
3881
- line: optional(text),
3882
- why: text,
3883
- /** True only when the target command is known to write nothing, here or at the provider. */
3884
- safe_to_auto_execute: boolean()
3885
- }),
3886
- /** Something only the person can do — sign in on the phone, approve a device. */
3887
- strictObject({
3888
- kind: literal("user_action"),
3889
- step: dottedId,
3890
- why: text,
3891
- safe_to_auto_execute: literal(false)
3892
- })
3893
- ]);
3894
- var missingSchema = strictObject({
3895
- field: text,
3896
- why: text,
3897
- /** Left out when there is nothing to run that would fill the field. */
3898
- step: optional(dottedId)
3899
- });
3900
- var limit = pipe(number(), integer(), minValue(1));
3901
- var totalSchema = strictObject({
3902
- value: pipe(number(), integer(), minValue(0)),
3903
- relation: picklist(["eq", "gte"])
3904
- });
3905
- var pageSchema = variant("mode", [
3906
- strictObject({
3907
- mode: literal("page"),
3908
- limit,
3909
- has_more: boolean(),
3910
- next_page: optional(pipe(number(), integer(), minValue(2))),
3911
- total: optional(totalSchema)
3912
- }),
3913
- strictObject({
3914
- mode: literal("cursor"),
3915
- limit,
3916
- has_more: boolean(),
3917
- next_cursor: optional(text),
3918
- total: optional(totalSchema)
3919
- })
3920
- ]);
3921
- var issueSchema = strictObject({
3922
- code: picklist(errorCodes),
3923
- reason: optional(dottedId),
3924
- /** The account, provider or source that is missing from the answer. */
3925
- source: text
3926
- });
3927
- var metaSchema = strictObject({
3928
- run_id: text,
3929
- duration_ms: pipe(number(), integer(), minValue(0)),
3930
- accounts: optional(array(text)),
3931
- complete: boolean(),
3932
- issues: optional(array(issueSchema)),
3933
- truncated: optional(boolean()),
3934
- timezone: optional(text),
3935
- window: optional(strictObject({ since: optional(isoTime), until: optional(isoTime) }))
3936
- });
3937
- var nextSteps = optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS)));
3938
- var listEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
3939
- items: array(item),
3940
- page: pageSchema,
3941
- next: nextSteps,
3942
- missing: optional(array(missingSchema)),
3943
- meta: metaSchema
3944
- }), "listEnvelopeSchema");
3945
- var itemEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
3946
- item,
3947
- next: nextSteps,
3948
- missing: optional(array(missingSchema)),
3949
- meta: metaSchema
3950
- }), "itemEnvelopeSchema");
3951
- var jsonlEndSchema = strictObject({
3952
- type: literal("end"),
3953
- complete: boolean(),
3954
- issues: optional(array(issueSchema)),
3955
- page: pageSchema
3956
- });
3957
- var jsonlOf = /* @__PURE__ */ __name(({ items, page, meta }) => [
3958
- ...items.map((data) => JSON.stringify({ type: "item", data })),
3959
- JSON.stringify({ type: "end", complete: meta.complete, ...meta.issues ? { issues: meta.issues } : {}, page })
3960
- ].join("\n"), "jsonlOf");
3961
-
3962
- // node_modules/.pnpm/@wirecat+cli-base@0.71.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
3963
- var CRASH_CODE = "internal_error";
3964
- var CRASH_REASON = "command.crashed";
3965
- var errorObjectSchema = strictObject({
3966
- error: strictObject({
3967
- code: picklist([...errorCodes, CRASH_CODE]),
3968
- reason: dottedId,
3969
- message: text,
3970
- /** The option or argument at fault. */
3971
- param: optional(text),
3972
- details: optional(record(string(), unknown())),
3973
- next: optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS))),
3974
- /** Whether running the same command again may work and cannot do harm; never for a write that may have landed. */
3975
- retry: strictObject({
3976
- safe: boolean(),
3977
- after_ms: optional(pipe(number(), integer(), minValue(0)))
3978
- }),
3979
- /** Optional until every CLI keeps a run for each failure. */
3980
- run_id: optional(text)
3981
- })
3982
- });
3983
- var reasonSchema = strictObject({
3984
- reason: dottedId,
3985
- code: picklist([...errorCodes, CRASH_CODE]),
3986
- /** `{name}` placeholders, each one of `details`. */
3987
- message: pipe(text, maxLength(120)),
3988
- details: array(pipe(string(), regex(SNAKE_CASE, "a snake_case key"))),
3989
- step: optional(dottedId)
3990
- });
3991
- var defineReasons = /* @__PURE__ */ __name((input) => parseRegistry("error reasons", array(reasonSchema), input, (reasons) => [
3992
- ...duplicates(reasons.map((entry2) => entry2.reason)).map((reason) => `"${reason}" is listed twice`),
3993
- ...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`))
3994
- ]), "defineReasons");
3995
- var COMMON_DETAILS = ["attempts", "status", "request_id", "operation", "operation_id"];
3996
- var BASE_REASONS = defineReasons([
3997
- { reason: "input.invalid", code: "validation_error", message: "the input is not valid", details: [] },
3998
- {
3999
- reason: "batch.read-budget",
4000
- code: "validation_error",
4001
- message: "batch stored-text read budget exhausted",
4002
- details: []
4003
- },
4004
- { reason: "batch.output-budget", code: "validation_error", message: "batch output budget exhausted", details: [] },
4005
- { reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
4006
- { reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
4007
- { reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
4008
- { reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
4009
- {
4010
- reason: "tool.not-installed",
4011
- code: "not_found",
4012
- message: "no wcat-<name> program by that name is on PATH",
4013
- details: ["tool", "installed"]
4014
- },
4015
- {
4016
- reason: "confirmation.required",
4017
- code: "confirmation_required",
4018
- message: "this changes something; confirm it",
4019
- details: []
4020
- },
4021
- { reason: "provider.rate-limited", code: "rate_limited", message: "too many requests; wait", details: [] },
4022
- { reason: "command.timed-out", code: "timeout", message: "the command took too long", details: ["timeout_ms"] },
4023
- { reason: "network.failed", code: "network_error", message: "the network did not answer", details: [] },
4024
- { reason: "provider.refused", code: "provider_error", message: "the provider refused", details: [] },
4025
- { reason: "provider.unavailable", code: "provider_unavailable", message: "the provider is down", details: [] },
4026
- {
4027
- reason: "provider.invalid-response",
4028
- code: "invalid_response",
4029
- message: "the answer could not be read",
4030
- details: []
4031
- },
4032
- {
4033
- reason: "output.too-large",
4034
- code: "invalid_response",
4035
- message: "the output is over {max_bytes} bytes",
4036
- details: ["max_bytes", "buffered_bytes", "partial_output"]
4037
- },
4038
- {
4039
- reason: "output.fields-unavailable",
4040
- code: "invalid_response",
4041
- message: "fields can be picked only from whole JSON values",
4042
- details: []
4043
- },
4044
- { reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
4045
- { reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
4046
- { reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] }
4047
- ]);
4048
-
4049
- // node_modules/.pnpm/@wirecat+cli-base@0.71.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
4050
- var SAME_COMMAND = "*";
4051
- var commandPath = pipe(string(), regex(/^[a-z][a-z0-9-]*( [a-z][a-z0-9-]*)*$/, "a command path such as `messages sync`"));
4052
- var stepSchema = union([
4053
- strictObject({
4054
- id: dottedId,
4055
- kind: optional(literal("command"), "command"),
4056
- command: union([literal(SAME_COMMAND), commandPath]),
4057
- args: array(strictObject({
4058
- name: pipe(string(), regex(SNAKE_CASE, "an argument or option name in snake_case")),
4059
- required: boolean()
4060
- })),
4061
- why: pipe(text, maxLength(120))
4062
- }),
4063
- strictObject({ id: dottedId, kind: literal("user_action"), why: pipe(text, maxLength(120)) })
4064
- ]);
4065
- var argsOf = /* @__PURE__ */ __name((step) => step.kind === "command" ? step.args : [], "argsOf");
4066
- var defineSteps = /* @__PURE__ */ __name((input) => parseRegistry("steps", array(stepSchema), input, (steps) => [
4067
- ...duplicates(steps.map((step) => step.id)).map((id) => `"${id}" is listed twice`),
4068
- ...steps.flatMap((step) => duplicates(argsOf(step).map((arg) => arg.name)).map((name) => `${step.id}: argument "${name}" is listed twice`))
4069
- ]), "defineSteps");
4070
- var BINDS = /^[^\p{Cc}\u2028\u2029]*$/u;
4071
- var binds = /* @__PURE__ */ __name((value) => typeof value === "number" || typeof value === "boolean" || typeof value === "string" && BINDS.test(value), "binds");
4072
- var stepOf = /* @__PURE__ */ __name((definition, input = {}) => {
4073
- const args = input.args ?? {};
4074
- if (definition.kind === "user_action")
4075
- return {
4076
- kind: "user_action",
4077
- step: definition.id,
4078
- why: fill(definition.why, { ...input.values }),
4079
- safe_to_auto_execute: false
4080
- };
4081
- const command = definition.command === SAME_COMMAND ? input.command : definition.command;
4082
- if (!command)
4083
- throw new Error(`${definition.id}: the step runs the same command, so pass the command`);
4084
- const known = new Set(definition.args.map((arg) => arg.name));
4085
- if (definition.command !== SAME_COMMAND) {
4086
- for (const name of Object.keys(args))
4087
- if (!known.has(name))
4088
- throw new Error(`${definition.id}: no argument "${name}"`);
4089
- }
4090
- for (const arg of definition.args)
4091
- if (arg.required && args[arg.name] === void 0)
4092
- throw new Error(`${definition.id}: argument "${arg.name}" is required`);
4093
- for (const [name, value] of Object.entries(args))
4094
- if (!(Array.isArray(value) ? value.every(binds) : binds(value)))
4095
- throw new Error(`${definition.id}: "${name}" is not a value an option takes`);
4096
- const target = input.targets?.(command);
4097
- if (input.targets && !target)
4098
- throw new Error(`${definition.id}: no command "${command}"`);
4099
- const names = new Set(target?.names ?? []);
4100
- if (target) {
4101
- for (const name of Object.keys(args))
4102
- if (!names.has(name))
4103
- throw new Error(`${definition.id}: "${command}" takes no "${name}"`);
4104
- }
4105
- const scalars = Object.fromEntries(Object.entries(args).filter((entry2) => ["string", "number"].includes(typeof entry2[1])));
4106
- return {
4107
- kind: "command",
4108
- step: definition.id,
4109
- command,
4110
- args: { ...args },
4111
- why: fill(definition.why, { ...scalars, ...input.values }),
4112
- safe_to_auto_execute: target?.effects !== void 0 && !writes(target.effects)
4113
- };
4114
- }, "stepOf");
4115
- var STEPS = defineSteps([
4116
- {
4117
- id: "page.next",
4118
- command: SAME_COMMAND,
4119
- args: [
4120
- { name: "cursor", required: false },
4121
- { name: "page", required: false },
4122
- { name: "limit", required: false }
4123
- ],
4124
- why: "{shown} shown, more exist"
4125
- }
4126
- ]);
4127
-
4128
- // node_modules/.pnpm/@wirecat+cli-base@0.71.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
4129
- var recognise = /* @__PURE__ */ __name((failure) => {
4130
- if (isCliError(failure))
4131
- return failure;
4132
- if (!(failure instanceof Error) || failure.name !== "CliError")
4133
- return void 0;
4134
- const { code, details } = failure;
4135
- if (!errorCodes.includes(code))
4136
- return void 0;
4137
- return {
4138
- code,
4139
- message: failure.message,
4140
- details: typeof details === "object" && details !== null ? details : {}
4141
- };
4142
- }, "recognise");
4143
- 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.
4144
- BASE_REASONS.find((entry2) => entry2.code === code), "reasonFor");
4145
- var nextFor = /* @__PURE__ */ __name((reason, details, context) => {
4146
- const definition = reason.step ? context.steps?.find((step) => step.id === reason.step) : void 0;
4147
- if (!definition)
4148
- return [];
4149
- const known = new Set(definition.kind === "command" ? definition.args.map((arg) => arg.name) : []);
4150
- const args = Object.fromEntries(Object.entries(details).filter(([key, value]) => known.has(key) && value !== void 0));
4151
- try {
4152
- return [stepOf(definition, { args, ...context.targets ? { targets: context.targets } : {} })];
4153
- } catch {
4154
- return [];
4155
- }
4156
- }, "nextFor");
4157
- var TRANSIENT = [
4158
- "rate_limited",
4159
- "timeout",
4160
- "network_error",
4161
- "provider_unavailable"
4162
- ];
4163
- var retryOf = /* @__PURE__ */ __name((code, details, effects) => {
4164
- const transient = details.retryable !== false && (TRANSIENT.includes(code) || code === "provider_error" && details.retryable === true);
4165
- const safe = code !== "outcome_unknown" && transient && (!writes(effects) || details.sent === false);
4166
- const after = details.retry_after_ms;
4167
- return safe && typeof after === "number" && Number.isInteger(after) && after >= 0 ? { safe, after_ms: after } : { safe };
4168
- }, "retryOf");
4169
- var errorObjectOf = /* @__PURE__ */ __name((failure, context = {}) => {
4170
- const reasons = context.reasons ?? [];
4171
- const recognised = recognise(failure);
4172
- if (!recognised) {
4173
- const reason2 = reasonFor(CRASH_CODE, CRASH_REASON, reasons);
4174
- return {
4175
- error: {
4176
- code: CRASH_CODE,
4177
- reason: reason2.reason,
4178
- message: reason2.message,
4179
- retry: { safe: false },
4180
- ...context.runId ? { run_id: context.runId } : {}
4181
- }
4182
- };
4183
- }
4184
- const { code, message, details } = recognised;
4185
- const reason = reasonFor(code, details.reason, reasons);
4186
- const allowed = /* @__PURE__ */ new Set([...COMMON_DETAILS, ...context.details ?? [], ...reason.details]);
4187
- allowed.delete("cause");
4188
- const kept = Object.fromEntries(Object.entries(details).filter(([key, value]) => allowed.has(key) && value !== void 0));
4189
- const next = nextFor(reason, details, context);
4190
- const runId = context.runId ?? (typeof details.run_id === "string" ? details.run_id : void 0);
4191
- return {
4192
- error: {
4193
- code,
4194
- reason: reason.reason,
4195
- message,
4196
- ...typeof details.param === "string" ? { param: details.param } : {},
4197
- ...Object.keys(kept).length > 0 ? { details: kept } : {},
4198
- ...next.length > 0 ? { next } : {},
4199
- retry: retryOf(code, details, context.effects),
4200
- ...runId ? { run_id: runId } : {}
4201
- }
4202
- };
4203
- }, "errorObjectOf");
4204
- var exitCodeOfError = /* @__PURE__ */ __name(({ error }) => error.code === CRASH_CODE ? GENERIC_FAILURE : EXIT_CODES[error.code], "exitCodeOfError");
4205
- var exitCodeOfAnswer = /* @__PURE__ */ __name((meta, partial2 = false) => {
4206
- if (meta.complete || partial2)
4207
- return 0;
4208
- const code = meta.issues?.[0]?.code;
4209
- return code === void 0 ? GENERIC_FAILURE : EXIT_CODES[code];
4210
- }, "exitCodeOfAnswer");
4211
- var kebab = /* @__PURE__ */ __name((name) => name.replaceAll("_", "-"), "kebab");
4212
- var commandLine = /* @__PURE__ */ __name((cli, step) => [
4213
- cli,
4214
- step.command,
4215
- ...Object.entries(step.args).map(([name, value]) => value === true ? `--${kebab(name)}` : `--${kebab(name)} ${JSON.stringify(value)}`)
4216
- ].join(" "), "commandLine");
4217
- var STACK_FRAMES = 10;
4218
- var errorRecordOf = /* @__PURE__ */ __name((failure, object3, options) => {
4219
- const thrown = failure instanceof Error ? failure : void 0;
4220
- const { cause, ...details } = recognise(failure)?.details ?? {};
4221
- const stack = thrown?.stack?.split("\n").slice(1, STACK_FRAMES + 1).map((line) => visibleControls(line.trim()));
4222
- const reason = thrown?.cause ?? cause;
4223
- return {
4224
- time: (options.time ?? /* @__PURE__ */ new Date()).toISOString(),
4225
- severity: "error",
4226
- body: "command.failed",
4227
- ...object3.error.run_id ? { run_id: object3.error.run_id } : {},
4228
- command: options.command,
4229
- attributes: {
4230
- code: object3.error.code,
4231
- reason: object3.error.reason,
4232
- message: object3.error.message,
4233
- ...Object.keys(details).length > 0 ? { details } : {},
4234
- ...thrown ? { name: thrown.name, thrown_message: visibleControls(thrown.message) } : { thrown: String(failure) },
4235
- ...reason === void 0 ? {} : { cause: visibleControls(reason instanceof Error ? reason.message : String(reason)) },
4236
- ...stack && stack.length > 0 ? { stack } : {}
4237
- },
4238
- resource: { service: options.service, version: options.version }
4239
- };
4240
- }, "errorRecordOf");
4241
- var renderError = /* @__PURE__ */ __name((object3, options) => {
4242
- if (!options.interactive)
4243
- return [JSON.stringify(object3), ...options.record ? [JSON.stringify(options.record)] : []].join("\n");
4244
- const { message, next, run_id: runId } = object3.error;
4245
- const step = next?.[0];
4246
- return [
4247
- `\u2717 ${visibleControls(message)}`,
4248
- ...step?.kind === "command" ? [`\u2192 ${visibleControls(step.why)}: ${visibleControls(step.line ?? commandLine(options.cli, step))}`] : step ? [`\u2192 ${visibleControls(step.why)}`] : [],
4249
- ...options.record ? [JSON.stringify(options.record, null, 2)] : runId ? [`details: ${options.cli} runs show ${runId}`] : []
4250
- ].join("\n");
4251
- }, "renderError");
4252
- var mcpErrorResult = /* @__PURE__ */ __name((object3) => ({
4253
- content: [{ type: "text", text: JSON.stringify(object3) }],
4254
- structuredContent: object3,
4255
- isError: true
4256
- }), "mcpErrorResult");
4257
- var catchCrashes = /* @__PURE__ */ __name((options) => {
4258
- const target = options.target ?? process;
4259
- const write = options.write ?? ((text2) => process.stderr.write(`${text2}
4260
- `));
4261
- const exit = options.exit ?? ((code) => process.exit(code));
4262
- const crashed = /* @__PURE__ */ __name((failure) => {
4263
- const object3 = errorObjectOf(failure, options);
4264
- write(renderError(object3, { cli: options.cli, interactive: options.interactive }));
4265
- exit(exitCodeOfError(object3));
4266
- }, "crashed");
4267
- target.on("uncaughtException", crashed);
4268
- target.on("unhandledRejection", crashed);
4269
- return () => {
4270
- target.off("uncaughtException", crashed);
4271
- target.off("unhandledRejection", crashed);
4272
- };
4273
- }, "catchCrashes");
4274
-
4275
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/result-fields.js
1901
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/result-fields.js
4276
1902
  var forbidden = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
4277
1903
  var validate = /* @__PURE__ */ __name((paths) => {
4278
1904
  if (paths.length === 0 || paths.length > 128 || paths.some((path) => path.length > 256 || !/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/.test(path) || path.split(".").some((part) => forbidden.has(part))))
@@ -4283,14 +1909,14 @@ var fieldsOf = /* @__PURE__ */ __name((value) => {
4283
1909
  validate(paths);
4284
1910
  return [...new Set(paths)];
4285
1911
  }, "fieldsOf");
4286
- var object2 = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "object");
1912
+ var object = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "object");
4287
1913
  var retained = /* @__PURE__ */ new Set(["operation_id", "page", "next", "missing", "meta", "coverage"]);
4288
1914
  var itemPaths = /* @__PURE__ */ __name((paths) => paths.map((path) => path.startsWith("items.") ? path.slice(6) : path), "itemPaths");
4289
1915
  var onePaths = /* @__PURE__ */ __name((paths) => paths.map((path) => path.startsWith("item.") ? path.slice(5) : path), "onePaths");
4290
1916
  var select = /* @__PURE__ */ __name((value, paths) => {
4291
1917
  if (Array.isArray(value))
4292
1918
  return value.map((item) => select(item, paths));
4293
- if (!object2(value))
1919
+ if (!object(value))
4294
1920
  return value;
4295
1921
  const result = {};
4296
1922
  const groups = /* @__PURE__ */ new Map();
@@ -4308,9 +1934,9 @@ var select = /* @__PURE__ */ __name((value, paths) => {
4308
1934
  const found = value[key];
4309
1935
  if (children.includes(""))
4310
1936
  result[key] = found;
4311
- else if (object2(found) || Array.isArray(found)) {
1937
+ else if (object(found) || Array.isArray(found)) {
4312
1938
  const selected = select(found, children);
4313
- if (Array.isArray(selected) || object2(selected) && Object.keys(selected).length > 0)
1939
+ if (Array.isArray(selected) || object(selected) && Object.keys(selected).length > 0)
4314
1940
  result[key] = selected;
4315
1941
  }
4316
1942
  }
@@ -4322,22 +1948,22 @@ var select = /* @__PURE__ */ __name((value, paths) => {
4322
1948
  var project = /* @__PURE__ */ __name((value, fields) => {
4323
1949
  if (Array.isArray(value))
4324
1950
  return value.map((item) => select(item, itemPaths(fields)));
4325
- if (object2(value) && Object.hasOwn(value, "type") && value.type === "item" && Object.hasOwn(value, "data") && Object.keys(value).every((key) => ["type", "data"].includes(key)))
1951
+ if (object(value) && Object.hasOwn(value, "type") && value.type === "item" && Object.hasOwn(value, "data") && Object.keys(value).every((key) => ["type", "data"].includes(key)))
4326
1952
  return { ...value, data: project(value.data, fields) };
4327
- if (object2(value) && Object.hasOwn(value, "type") && value.type === "end" && Object.hasOwn(value, "complete") && typeof value.complete === "boolean")
1953
+ if (object(value) && Object.hasOwn(value, "type") && value.type === "end" && Object.hasOwn(value, "complete") && typeof value.complete === "boolean")
4328
1954
  return value;
4329
- if (object2(value) && Object.hasOwn(value, "item") && (Object.hasOwn(value, "meta") || Object.keys(value).every((key) => ["item", "next", "missing"].includes(key))))
1955
+ if (object(value) && Object.hasOwn(value, "item") && (Object.hasOwn(value, "meta") || Object.keys(value).every((key) => ["item", "next", "missing"].includes(key))))
4330
1956
  return { ...value, item: project(value.item, onePaths(fields)) };
4331
- if (object2(value) && Array.isArray(value.items))
1957
+ if (object(value) && Array.isArray(value.items))
4332
1958
  return { ...value, items: value.items.map((item) => select(item, itemPaths(fields))) };
4333
- return select(value, object2(value) && !Object.hasOwn(value, "items") ? itemPaths(fields) : fields);
1959
+ return select(value, object(value) && !Object.hasOwn(value, "items") ? itemPaths(fields) : fields);
4334
1960
  }, "project");
4335
1961
  var projectFields = /* @__PURE__ */ __name((value, fields) => {
4336
1962
  validate(fields);
4337
1963
  return project(value, fields);
4338
1964
  }, "projectFields");
4339
1965
 
4340
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/batch.js
1966
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/batch.js
4341
1967
  var BATCH_LIMITS = Object.freeze({
4342
1968
  requests: 32,
4343
1969
  input_bytes: 262144,
@@ -4349,7 +1975,7 @@ function invalid(message) {
4349
1975
  throw new CliError("validation_error", message);
4350
1976
  }
4351
1977
  __name(invalid, "invalid");
4352
- var limit2 = /* @__PURE__ */ __name((value, maximum, name) => {
1978
+ var limit = /* @__PURE__ */ __name((value, maximum, name) => {
4353
1979
  if (!Number.isSafeInteger(value) || value < 1 || value > maximum)
4354
1980
  invalid(`invalid batch ${name} limit`);
4355
1981
  return value;
@@ -4373,13 +1999,13 @@ var prepareBatch = /* @__PURE__ */ __name((input, handlers) => {
4373
1999
  invalid("batch takes 1\u201332 requests");
4374
2000
  const ids = /* @__PURE__ */ new Set();
4375
2001
  return requests.map((request) => {
4376
- 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")))
2002
+ 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")))
4377
2003
  invalid("each batch request needs a unique id, registered command path and string args array");
4378
2004
  const id = request.id;
4379
2005
  const command = [...request.command];
4380
2006
  const args = request.args;
4381
2007
  ids.add(id);
4382
- const handler = handlers.find((entry2) => entry2.command.length === command.length && entry2.command.every((word2, i) => word2 === command[i]));
2008
+ const handler = handlers.find((entry2) => entry2.command.length === command.length && entry2.command.every((word, i) => word === command[i]));
4383
2009
  if (!handler)
4384
2010
  invalid(`unsupported batch command: ${command.join(" ")}`);
4385
2011
  return { id, command, operation: handler.prepare(args) };
@@ -4410,15 +2036,15 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4410
2036
  invalid("batch takes 1\u201332 requests");
4411
2037
  if (options.fields)
4412
2038
  projectFields({}, options.fields);
4413
- const maxReadBytes = limit2(options.maxReadBytes ?? BATCH_LIMITS.read_bytes, BATCH_LIMITS.read_bytes, "read");
4414
- const maxOutputBytes = limit2(options.maxOutputBytes ?? BATCH_LIMITS.output_bytes, BATCH_LIMITS.output_bytes, "output");
2039
+ const maxReadBytes = limit(options.maxReadBytes ?? BATCH_LIMITS.read_bytes, BATCH_LIMITS.read_bytes, "read");
2040
+ const maxOutputBytes = limit(options.maxOutputBytes ?? BATCH_LIMITS.output_bytes, BATCH_LIMITS.output_bytes, "output");
4415
2041
  if (maxOutputBytes < 8192 + requests.length * 2048)
4416
2042
  invalid("batch output budget cannot hold its result framing");
4417
2043
  const errorOf = /* @__PURE__ */ __name((error) => {
4418
- const object3 = errorObjectOf(error, options.failureContext).error;
2044
+ const object2 = errorObjectOf(error, options.failureContext).error;
4419
2045
  try {
4420
- if (Buffer.byteLength(JSON.stringify(object3), "utf8") <= 512)
4421
- return object3;
2046
+ if (Buffer.byteLength(JSON.stringify(object2), "utf8") <= 512)
2047
+ return object2;
4422
2048
  } catch {
4423
2049
  }
4424
2050
  const fallback = errorObjectOf(error).error;
@@ -4434,7 +2060,7 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4434
2060
  const context = {
4435
2061
  signal: options.signal,
4436
2062
  reserveReadBytes(bytes) {
4437
- limit2(bytes, BATCH_LIMITS.read_bytes, "operation read");
2063
+ limit(bytes, BATCH_LIMITS.read_bytes, "operation read");
4438
2064
  if (bytes > maxReadBytes - reserved)
4439
2065
  throw budgetError("read");
4440
2066
  reserved += bytes;
@@ -4463,11 +2089,11 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4463
2089
  }
4464
2090
  } catch (error) {
4465
2091
  options.signal?.throwIfAborted();
4466
- const object3 = errorOf(error);
2092
+ const object2 = errorOf(error);
4467
2093
  result = {
4468
2094
  ...framing,
4469
- status: object3.reason === "batch.read-budget" ? "not_run" : "error",
4470
- error: object3,
2095
+ status: object2.reason === "batch.read-budget" ? "not_run" : "error",
2096
+ error: object2,
4471
2097
  complete: false
4472
2098
  };
4473
2099
  }
@@ -4484,7 +2110,7 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4484
2110
  };
4485
2111
  }, "runBatch");
4486
2112
 
4487
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/config.js
2113
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/config.js
4488
2114
  import { randomBytes } from "node:crypto";
4489
2115
  import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
4490
2116
  import { dirname, join } from "node:path";
@@ -4528,7 +2154,7 @@ var saveConfigFile = /* @__PURE__ */ __name((path, config) => {
4528
2154
  `, 384);
4529
2155
  }, "saveConfigFile");
4530
2156
 
4531
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/keyring.js
2157
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/keyring.js
4532
2158
  import { createRequire } from "node:module";
4533
2159
  var ENTRY_OPTIONS = { linux: { store: "secret-service" } };
4534
2160
  var require2 = createRequire(new URL("keyring.js", import.meta.resolve("@wirecat/cli-base")).href);
@@ -4548,7 +2174,7 @@ var systemKeyring = {
4548
2174
  delete: /* @__PURE__ */ __name((service, account) => entry(service, account).deletePassword(), "delete")
4549
2175
  };
4550
2176
 
4551
- // node_modules/.pnpm/@wirecat+cli-base@0.71.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
2177
+ // 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
4552
2178
  import { homedir, userInfo } from "node:os";
4553
2179
  import { join as join2, posix, win32 } from "node:path";
4554
2180
  var PATH_KINDS = ["config", "state", "cache"];
@@ -4597,9 +2223,10 @@ var homeIsMoved = /* @__PURE__ */ __name(({ env = process.env, platform = proces
4597
2223
  const owners = defaultPaths({ appName, env: { HOME: home, USERPROFILE: home }, platform });
4598
2224
  return PATH_KINDS.some((kind) => actual[kind] !== owners[kind]);
4599
2225
  }, "homeIsMoved");
2226
+ var isMovedRun = /* @__PURE__ */ __name((options) => pathsAreOverridden(options) || homeIsMoved(options), "isMovedRun");
4600
2227
  var configFilePath = /* @__PURE__ */ __name((configDir, fileName = "config.json") => join2(configDir, fileName), "configFilePath");
4601
2228
 
4602
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/credentials.js
2229
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/credentials.js
4603
2230
  import { readFileSync as readFileSync2 } from "node:fs";
4604
2231
  import { join as join3, resolve } from "node:path";
4605
2232
  var movedRunService = /* @__PURE__ */ __name((service, configDir) => `${service}:${resolve(configDir)}`, "movedRunService");
@@ -4659,12 +2286,12 @@ var Credentials = class {
4659
2286
  return "keyring";
4660
2287
  }
4661
2288
  }
4662
- const store2 = this.#readFile();
4663
- if (!store2) {
2289
+ const store = this.#readFile();
2290
+ if (!store) {
4664
2291
  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.`);
4665
2292
  }
4666
- store2[account] = { secret };
4667
- this.#writeFile(store2);
2293
+ store[account] = { secret };
2294
+ this.#writeFile(store);
4668
2295
  return "file";
4669
2296
  }
4670
2297
  remove(account) {
@@ -4682,11 +2309,11 @@ var Credentials = class {
4682
2309
  return removed;
4683
2310
  }
4684
2311
  #removeFromFile(account) {
4685
- const store2 = this.#readFile();
4686
- if (store2?.[account] === void 0)
2312
+ const store = this.#readFile();
2313
+ if (store?.[account] === void 0)
4687
2314
  return false;
4688
- delete store2[account];
4689
- this.#writeFile(store2);
2315
+ delete store[account];
2316
+ this.#writeFile(store);
4690
2317
  return true;
4691
2318
  }
4692
2319
  /** Only for the warning: a keyring that fails here must not fail a removal that already happened. */
@@ -4717,8 +2344,8 @@ var Credentials = class {
4717
2344
  return void 0;
4718
2345
  }
4719
2346
  }
4720
- #writeFile(store2) {
4721
- writeSecurely(this.#path(), `${JSON.stringify(store2, null, 2)}
2347
+ #writeFile(store) {
2348
+ writeSecurely(this.#path(), `${JSON.stringify(store, null, 2)}
4722
2349
  `, 384);
4723
2350
  }
4724
2351
  #tryKeyring(operation) {
@@ -4736,10 +2363,10 @@ var Credentials = class {
4736
2363
  }
4737
2364
  };
4738
2365
 
4739
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/logging.js
2366
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/logging.js
4740
2367
  import { appendFileSync } from "node:fs";
4741
2368
 
4742
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/log.js
2369
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/log.js
4743
2370
  var LOG_SEVERITIES = ["trace", "debug", "info", "warn", "error", "fatal"];
4744
2371
  var logRecordSchema = strictObject({
4745
2372
  time: isoTime,
@@ -4797,10 +2424,10 @@ var CONTENT_WORDS = /* @__PURE__ */ new Set([
4797
2424
  "token"
4798
2425
  ]);
4799
2426
  var CONTENT_LAST_WORDS = /* @__PURE__ */ new Set(["message", "name"]);
4800
- var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word2) => word2.toLowerCase()), "wordsOf");
2427
+ var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word) => word.toLowerCase()), "wordsOf");
4801
2428
  var isContentKey = /* @__PURE__ */ __name((key) => {
4802
2429
  const words = wordsOf(key);
4803
- return words.some((word2) => CONTENT_WORDS.has(word2)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
2430
+ return words.some((word) => CONTENT_WORDS.has(word)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
4804
2431
  }, "isContentKey");
4805
2432
  var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
4806
2433
  var traceIdOf = /* @__PURE__ */ __name((traceparent) => {
@@ -4817,7 +2444,7 @@ var traceIdOf = /* @__PURE__ */ __name((traceparent) => {
4817
2444
  return traceId;
4818
2445
  }, "traceIdOf");
4819
2446
 
4820
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/logging.js
2447
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/logging.js
4821
2448
  var REDACTED_FIELDS = [
4822
2449
  "authorization",
4823
2450
  "Authorization",
@@ -4911,7 +2538,7 @@ var silent = {
4911
2538
  }, "error")
4912
2539
  };
4913
2540
 
4914
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/output-buffer.js
2541
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/output-buffer.js
4915
2542
  var createOutputBuffer = /* @__PURE__ */ __name(({ maxOutputBytes = 4 * 1024 * 1024, fields, format } = {}) => {
4916
2543
  if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 0)
4917
2544
  throw new CliError("validation_error", "maxOutputBytes must be a nonnegative whole byte count");
@@ -4972,7 +2599,7 @@ var createOutputBuffer = /* @__PURE__ */ __name(({ maxOutputBytes = 4 * 1024 * 1
4972
2599
  };
4973
2600
  }, "createOutputBuffer");
4974
2601
 
4975
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/retry.js
2602
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/retry.js
4976
2603
  var DEFAULT_RETRY = {
4977
2604
  retries: 1,
4978
2605
  baseDelayMs: 250,
@@ -4984,7 +2611,7 @@ var backoffMs = /* @__PURE__ */ __name((attempt, config, random) => {
4984
2611
  return Math.round(random() * ceiling);
4985
2612
  }, "backoffMs");
4986
2613
 
4987
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/time.js
2614
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/time.js
4988
2615
  var abortError = /* @__PURE__ */ __name(() => new DOMException("The operation was aborted.", "AbortError"), "abortError");
4989
2616
  var realSleep = /* @__PURE__ */ __name((ms, signal) => new Promise((resolve2, reject) => {
4990
2617
  if (signal?.aborted) {
@@ -4998,7 +2625,7 @@ var realSleep = /* @__PURE__ */ __name((ms, signal) => new Promise((resolve2, re
4998
2625
  }, { once: true });
4999
2626
  }), "realSleep");
5000
2627
 
5001
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/deadline.js
2628
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/deadline.js
5002
2629
  var createDeadline = /* @__PURE__ */ __name(({ timeoutMs, signal, sleep = realSleep } = {}) => {
5003
2630
  if (timeoutMs !== void 0 && (!Number.isSafeInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 2147483647))
5004
2631
  throw new CliError("validation_error", "timeoutMs must be an integer from zero through 2147483647");
@@ -5082,7 +2709,7 @@ var createDeadline = /* @__PURE__ */ __name(({ timeoutMs, signal, sleep = realSl
5082
2709
  };
5083
2710
  }, "createDeadline");
5084
2711
 
5085
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/pretty.js
2712
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/pretty.js
5086
2713
  var import_cli_table3 = __toESM(require_cli_table3(), 1);
5087
2714
  import { styleText } from "node:util";
5088
2715
  var renderPretty = /* @__PURE__ */ __name((value, options) => {
@@ -5157,7 +2784,7 @@ var BORDERLESS = {
5157
2784
  middle: ""
5158
2785
  };
5159
2786
 
5160
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/drain.js
2787
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/drain.js
5161
2788
  var waitForDrain = /* @__PURE__ */ __name((stream, signal) => {
5162
2789
  if (signal?.aborted)
5163
2790
  return Promise.reject(signal.reason);
@@ -5185,7 +2812,7 @@ var waitForDrain = /* @__PURE__ */ __name((stream, signal) => {
5185
2812
  });
5186
2813
  }, "waitForDrain");
5187
2814
 
5188
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/streams.js
2815
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/streams.js
5189
2816
  var processStreams = {
5190
2817
  drain: /* @__PURE__ */ __name(async (signal) => {
5191
2818
  await Promise.all([waitForDrain(process.stdout, signal), waitForDrain(process.stderr, signal)]);
@@ -5214,7 +2841,7 @@ var captureStreams = /* @__PURE__ */ __name(() => {
5214
2841
  };
5215
2842
  }, "captureStreams");
5216
2843
 
5217
- // node_modules/.pnpm/@wirecat+cli-base@0.71.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/renderer.js
2844
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/renderer.js
5218
2845
  var createRenderer = /* @__PURE__ */ __name(({ format, color, streams = processStreams, quiet = false }) => {
5219
2846
  const mark = /* @__PURE__ */ __name((symbol, message) => format === "pretty" ? `${symbol} ${visibleControls(message)}` : visibleControls(message), "mark");
5220
2847
  const say = /* @__PURE__ */ __name((symbol) => (message) => {
@@ -5252,89 +2879,6 @@ var createRenderer = /* @__PURE__ */ __name(({ format, color, streams = processS
5252
2879
  }, "createRenderer");
5253
2880
 
5254
2881
  export {
5255
- errorCodes,
5256
- CliError,
5257
- isCliError,
5258
- EXIT_CODES,
5259
- exitCodeFor,
5260
- GENERIC_FAILURE,
5261
- visibleControls,
5262
- singleLine,
5263
- getDotPath,
5264
- check,
5265
- description,
5266
- finite,
5267
- integer,
5268
- isoDate,
5269
- isoTimestamp,
5270
- maxLength,
5271
- maxValue,
5272
- minLength,
5273
- minValue,
5274
- nonEmpty,
5275
- regex,
5276
- safeInteger,
5277
- transform,
5278
- trim,
5279
- forward,
5280
- array,
5281
- boolean,
5282
- custom,
5283
- lazy,
5284
- literal,
5285
- looseObject,
5286
- null_,
5287
- nullable,
5288
- number,
5289
- object,
5290
- objectWithRest,
5291
- optional,
5292
- picklist,
5293
- record,
5294
- strictObject,
5295
- string,
5296
- union,
5297
- unknown,
5298
- variant,
5299
- omit,
5300
- parse,
5301
- partial,
5302
- pick,
5303
- pipe,
5304
- safeParse,
5305
- summarize,
5306
- unwrap,
5307
- effectsSchema,
5308
- writes,
5309
- toJsonSchema,
5310
- toStandardJsonSchema,
5311
- word,
5312
- SNAKE_CASE,
5313
- text,
5314
- RegistryError,
5315
- parseRegistry,
5316
- duplicates,
5317
- jsonSchemaOf,
5318
- MAX_NEXT_STEPS,
5319
- isoTime,
5320
- reference,
5321
- pageSchema,
5322
- listEnvelopeSchema,
5323
- itemEnvelopeSchema,
5324
- jsonlOf,
5325
- CRASH_CODE,
5326
- errorObjectSchema,
5327
- defineReasons,
5328
- defineSteps,
5329
- stepOf,
5330
- STEPS,
5331
- errorObjectOf,
5332
- exitCodeOfError,
5333
- exitCodeOfAnswer,
5334
- errorRecordOf,
5335
- renderError,
5336
- mcpErrorResult,
5337
- catchCrashes,
5338
2882
  fieldsOf,
5339
2883
  projectFields,
5340
2884
  BATCH_LIMITS,
@@ -5347,6 +2891,7 @@ export {
5347
2891
  systemKeyring,
5348
2892
  resolvePaths,
5349
2893
  pathsAreOverridden,
2894
+ isMovedRun,
5350
2895
  configFilePath,
5351
2896
  Credentials,
5352
2897
  realSleep,