@wirecat/zoom-cli 0.65.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 (130) hide show
  1. package/dist/bin/zm.js +2 -2
  2. package/dist/bin/zm.js.map +1 -1
  3. package/dist/bundle/{all-profiles-SKMLZJSY.js → all-profiles-D5CFH2OK.js} +8 -5
  4. package/dist/bundle/answer-policy-YAYMKRRD.js +101 -0
  5. package/dist/bundle/{anthropic-TVHK7CY2.js → anthropic-K2E2JS4S.js} +6 -3
  6. package/dist/bundle/{app-server-44ASFH47.js → app-server-TVXDG6HZ.js} +60 -54
  7. package/dist/bundle/{bun-sqlite-NS32GMM4.js → bun-sqlite-HGBEHQI3.js} +5 -2
  8. package/dist/bundle/{chunk-CVCRQW3A.js → chunk-2T5BOLBS.js} +1 -1
  9. package/dist/bundle/{chunk-XJQB47IL.js → chunk-2VPHQFO5.js} +5 -5
  10. package/dist/bundle/{chunk-MRWIXUYT.js → chunk-2YLNUZ3T.js} +5 -3
  11. package/dist/bundle/{chunk-SQWRZZOQ.js → chunk-3B7L2UX4.js} +2 -2
  12. package/dist/bundle/{chunk-ZREFYKUB.js → chunk-3WTKZ2ZS.js} +9 -7
  13. package/dist/bundle/{chunk-GBZF4IIP.js → chunk-3Y2F65AY.js} +2 -2
  14. package/dist/bundle/{chunk-25IDWPEN.js → chunk-5A26IBAR.js} +19 -15
  15. package/dist/bundle/{chunk-5NGOP4EZ.js → chunk-5GD2XZ6X.js} +21 -19
  16. package/dist/bundle/{chunk-OXUHTKO2.js → chunk-5HPALDUO.js} +1 -1
  17. package/dist/bundle/{chunk-QI7BZS2G.js → chunk-62GOOZO3.js} +3 -3
  18. package/dist/bundle/{chunk-UMHJZWZU.js → chunk-67RNZGAG.js} +6 -4
  19. package/dist/bundle/{chunk-Z5424QL6.js → chunk-6GSJLNP4.js} +1 -1
  20. package/dist/bundle/{chunk-ERPRAYA7.js → chunk-6TIKPRVQ.js} +8 -4
  21. package/dist/bundle/{chunk-UPJXN2CO.js → chunk-756RS4PH.js} +146 -138
  22. package/dist/bundle/{chunk-KYLS5QGC.js → chunk-7JMBEPW2.js} +1 -1
  23. package/dist/bundle/{chunk-MZ6U6HNJ.js → chunk-7KCTPGOF.js} +1 -1
  24. package/dist/bundle/{chunk-VJTGYBJJ.js → chunk-7PF56S6U.js} +21 -15
  25. package/dist/bundle/{chunk-6CS7ETBK.js → chunk-A2SCXNA7.js} +48 -42
  26. package/dist/bundle/{chunk-AMMD6YCJ.js → chunk-AU4JHT3R.js} +1 -1
  27. package/dist/bundle/{chunk-T3KICUOK.js → chunk-AZ7ICKIA.js} +4 -4
  28. package/dist/bundle/{chunk-EA63UGWE.js → chunk-BXSAROQP.js} +2 -2
  29. package/dist/bundle/{chunk-MPKKIL3U.js → chunk-CAW6IMFZ.js} +19 -15
  30. package/dist/bundle/{chunk-DNCKH7CO.js → chunk-CR4CXOLX.js} +6 -6
  31. package/dist/bundle/{chunk-QLCYAQ66.js → chunk-CZ4KLUJG.js} +1 -1
  32. package/dist/bundle/{chunk-LPUFOWL3.js → chunk-D72URWJE.js} +1 -39
  33. package/dist/bundle/{chunk-BNXH73OU.js → chunk-EXXM4RNI.js} +10 -8
  34. package/dist/bundle/{chunk-24F7JBLY.js → chunk-FWFFQV4D.js} +2 -2
  35. package/dist/bundle/{chunk-ZOGYTDHG.js → chunk-GHAPWKG2.js} +4 -2
  36. package/dist/bundle/{chunk-GEX4V5TM.js → chunk-GI6QVSCW.js} +3 -3
  37. package/dist/bundle/{chunk-MH7AWCB4.js → chunk-GKXFL35E.js} +40 -36
  38. package/dist/bundle/{chunk-ZFNM3FNI.js → chunk-GNGBG5BT.js} +17 -13
  39. package/dist/bundle/{chunk-BWRBALXG.js → chunk-H5ZVZAOD.js} +1 -1
  40. package/dist/bundle/{chunk-TUIEDVI6.js → chunk-HKQWV3KT.js} +4 -2
  41. package/dist/bundle/chunk-IDWHJ35K.js +166 -0
  42. package/dist/bundle/{chunk-GXCNCMUY.js → chunk-IKQ73INC.js} +45 -41
  43. package/dist/bundle/chunk-ILHTNOIV.js +23 -0
  44. package/dist/bundle/{chunk-KZE3G4ZT.js → chunk-J4EZL6HY.js} +49 -45
  45. package/dist/bundle/{chunk-VW2SW7ME.js → chunk-JX3V35A5.js} +2 -2
  46. package/dist/bundle/{chunk-RZLNHNSS.js → chunk-K5CIN4JP.js} +1 -1
  47. package/dist/bundle/{chunk-ZXGRK44F.js → chunk-KDKFGQWG.js} +9 -7
  48. package/dist/bundle/{chunk-A6OA2EH2.js → chunk-L7IK4FOA.js} +1 -1
  49. package/dist/bundle/{chunk-TC7PD3LH.js → chunk-LN2S3RA3.js} +1 -1
  50. package/dist/bundle/{chunk-LOL6JYYN.js → chunk-N5JRRBEG.js} +5 -3
  51. package/dist/bundle/chunk-N67BLTBV.js +2443 -0
  52. package/dist/bundle/{chunk-2H5SXK7K.js → chunk-N6JMJN5A.js} +10 -8
  53. package/dist/bundle/{chunk-FYJL276J.js → chunk-NMQUCHTX.js} +2 -2
  54. package/dist/bundle/{chunk-C6BG57FA.js → chunk-O5FKJV3T.js} +13 -11
  55. package/dist/bundle/{chunk-PV3UDPCI.js → chunk-P2G4KGTR.js} +15 -9
  56. package/dist/bundle/{chunk-VH4F2EK4.js → chunk-P2SYZNM4.js} +1 -1
  57. package/dist/bundle/{chunk-U5ASRBBF.js → chunk-P3XVLHIQ.js} +2 -2
  58. package/dist/bundle/chunk-PQLBPYJR.js +46 -0
  59. package/dist/bundle/{chunk-GMTXCFI7.js → chunk-Q47C3QZW.js} +9 -5
  60. package/dist/bundle/{chunk-CNEE6TPE.js → chunk-QAPU2JNO.js} +1 -1
  61. package/dist/bundle/{chunk-3CZIWGZ6.js → chunk-QJHRYUMJ.js} +1 -1
  62. package/dist/bundle/{chunk-FYM27FCG.js → chunk-QV5ZGRK3.js} +10 -4
  63. package/dist/bundle/{chunk-UKU6MYUI.js → chunk-RMKHYUHK.js} +8 -19
  64. package/dist/bundle/{chunk-M6IDHQ7N.js → chunk-RO44LANT.js} +85 -79
  65. package/dist/bundle/chunk-S6S3KVJI.js +45 -0
  66. package/dist/bundle/{chunk-ZH743WNV.js → chunk-SU4WPBQE.js} +5 -3
  67. package/dist/bundle/{chunk-JF7ZEUXU.js → chunk-TFDVFD4N.js} +72 -2535
  68. package/dist/bundle/{chunk-NNNEVWFF.js → chunk-TMVKZMDO.js} +22 -18
  69. package/dist/bundle/{chunk-R5BAF5XE.js → chunk-TN7K66PU.js} +1 -1
  70. package/dist/bundle/{chunk-MIB5X2XW.js → chunk-TUEEXECZ.js} +4 -4
  71. package/dist/bundle/{chunk-K6ATTKQR.js → chunk-UOIXBEFR.js} +4 -4
  72. package/dist/bundle/chunk-UYV2JGLQ.js +34 -0
  73. package/dist/bundle/{chunk-NJSIHMAE.js → chunk-XFUID5NY.js} +3 -3
  74. package/dist/bundle/{chunk-266WOOB3.js → chunk-XWDSEJWP.js} +3 -3
  75. package/dist/bundle/{chunk-37PHGASE.js → chunk-YLEQN6PB.js} +5 -3
  76. package/dist/bundle/{chunk-WLSF3GCC.js → chunk-Z6U3MEGJ.js} +1 -1
  77. package/dist/bundle/{chunk-DYJXAY7Q.js → chunk-ZKTXUDSR.js} +31 -27
  78. package/dist/bundle/{chunk-H7762LDA.js → chunk-ZNFPDTQM.js} +1 -1
  79. package/dist/bundle/{chunk-IPTI3Y2E.js → chunk-ZTL7ANSG.js} +6 -4
  80. package/dist/bundle/{cli-FDO6CP6R.js → cli-HWQIL2AC.js} +71 -66
  81. package/dist/bundle/command-contract-CQFJXWX6.js +40 -0
  82. package/dist/bundle/config-R2Y6ZVQS.js +83 -0
  83. package/dist/bundle/{decode-7SZI3TGZ.js → decode-XPAPPUGE.js} +6 -3
  84. package/dist/bundle/dispatch-AKVJGP2S.js +412 -0
  85. package/dist/bundle/{dist-5GWUXW27.js → dist-LDIUQBM7.js} +18 -15
  86. package/dist/bundle/{embed-24YSXHLP.js → embed-LK45GRQ7.js} +7 -4
  87. package/dist/bundle/{embedder-MEXN2TFB.js → embedder-QPBC5XBY.js} +9 -6
  88. package/dist/bundle/failure-7OULAOWQ.js +25 -0
  89. package/dist/bundle/first-run-J5FG773Q.js +28 -0
  90. package/dist/bundle/first-screen-MULOBUHN.js +38 -0
  91. package/dist/bundle/{folders-DBAAMU26.js → folders-RHPUVMDI.js} +5 -2
  92. package/dist/bundle/{main-EIUCXXDW.js → main-FJHE5YHU.js} +28 -23
  93. package/dist/bundle/{mcp-FUSDPAOL.js → mcp-MNI62HHE.js} +4 -2
  94. package/dist/bundle/{meetings-JDTRGXZJ.js → meetings-MYIDGYGW.js} +6 -3
  95. package/dist/bundle/{node-sqlite-O4BAODFR.js → node-sqlite-SYZUTVPC.js} +5 -2
  96. package/dist/bundle/{oauth-3YLHXGUW.js → oauth-QPS5VTN6.js} +7 -4
  97. package/dist/bundle/{open-QGRMSNM2.js → open-OVCASRSJ.js} +5 -2
  98. package/dist/bundle/openai-VEVT7D7L.js +25 -0
  99. package/dist/bundle/{output-file-J26UQKRA.js → output-file-K5JEL33Z.js} +7 -4
  100. package/dist/bundle/{program-47DT7SHE.js → program-A546WC4F.js} +106 -98
  101. package/dist/bundle/{prompt-IUD7HCDC.js → prompt-CYBKP7S5.js} +6 -3
  102. package/dist/bundle/{recognize-DMJJHHXF.js → recognize-3H3YDCFI.js} +5 -2
  103. package/dist/bundle/{remote-5WFSOVVB.js → remote-VAYVTJBS.js} +8 -5
  104. package/dist/bundle/{rerank-UKQ65ECH.js → rerank-XA4GA5PS.js} +7 -4
  105. package/dist/bundle/{run-log-UGYL6NW2.js → run-log-XAFHMI3F.js} +53 -48
  106. package/dist/bundle/{serve-WAOSED3I.js → serve-KGHEDUHB.js} +13 -10
  107. package/dist/bundle/server-IDNSJXF3.js +71 -0
  108. package/dist/bundle/{server-NWZFNXC5.js → server-ZYTSMDTP.js} +41 -36
  109. package/dist/bundle/{services-VPANRE72.js → services-ZHMZC2OQ.js} +30 -25
  110. package/dist/bundle/{speech-O6UNUDRW.js → speech-7CJEFKM3.js} +14 -11
  111. package/dist/bundle/{state-BNE7I65A.js → state-U6KSYVOH.js} +6 -3
  112. package/dist/bundle/{store-QQH4FJXJ.js → store-DJE3LAEG.js} +14 -11
  113. package/dist/bundle/{store-4IIVSCJ4.js → store-WS4CQGYU.js} +16 -13
  114. package/dist/bundle/store-connection-T5WGOOPH.js +81 -0
  115. package/dist/bundle/store-maintenance-command-5CBQCEQQ.js +61 -0
  116. package/dist/bundle/{streaming-S4EZB6P2.js → streaming-QMHH7L6N.js} +7 -4
  117. package/dist/bundle/{tokens-VCXIH7WZ.js → tokens-PWQ56OXO.js} +7 -4
  118. package/dist/bundle/zm.js +150 -1
  119. package/dist/version.d.ts +1 -1
  120. package/dist/version.js +1 -1
  121. package/package.json +3 -2
  122. package/dist/bundle/answer-policy-BHDNSJWX.js +0 -96
  123. package/dist/bundle/command-contract-O4FDXM4U.js +0 -37
  124. package/dist/bundle/config-UBHKZG3J.js +0 -78
  125. package/dist/bundle/first-run-OCVEJH63.js +0 -23
  126. package/dist/bundle/first-screen-KJIU25MH.js +0 -35
  127. package/dist/bundle/openai-7PSCSTH7.js +0 -22
  128. package/dist/bundle/server-HAXN772R.js +0 -66
  129. package/dist/bundle/store-connection-PPEQK2K3.js +0 -76
  130. package/dist/bundle/store-maintenance-command-JZXCT6NY.js +0 -56
@@ -0,0 +1,2443 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ errorCodes,
5
+ isCliError
6
+ } from "./chunk-S6S3KVJI.js";
7
+ import {
8
+ visibleControls
9
+ } from "./chunk-UYV2JGLQ.js";
10
+ import {
11
+ __name
12
+ } from "./chunk-ZVVMGPBJ.js";
13
+
14
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/exit-codes.js
15
+ var EXIT_CODES = {
16
+ validation_error: 2,
17
+ configuration_error: 3,
18
+ authentication_error: 4,
19
+ permission_error: 5,
20
+ not_found: 6,
21
+ confirmation_required: 7,
22
+ rate_limited: 8,
23
+ timeout: 9,
24
+ network_error: 10,
25
+ provider_error: 11,
26
+ provider_unavailable: 12,
27
+ invalid_response: 13,
28
+ outcome_unknown: 14,
29
+ cancelled: 130
30
+ };
31
+ var exitCodeFor = /* @__PURE__ */ __name((code) => EXIT_CODES[code], "exitCodeFor");
32
+ var GENERIC_FAILURE = 1;
33
+
34
+ // node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
35
+ var store$4;
36
+ var DEFAULT_CONFIG = {
37
+ lang: void 0,
38
+ message: void 0,
39
+ abortEarly: void 0,
40
+ abortPipeEarly: void 0
41
+ };
42
+ // @__NO_SIDE_EFFECTS__
43
+ function getGlobalConfig(config$1) {
44
+ if (!config$1 && !store$4) return DEFAULT_CONFIG;
45
+ return {
46
+ lang: config$1?.lang ?? store$4?.lang,
47
+ message: config$1?.message,
48
+ abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
49
+ abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
50
+ };
51
+ }
52
+ __name(getGlobalConfig, "getGlobalConfig");
53
+ var store$3;
54
+ // @__NO_SIDE_EFFECTS__
55
+ function getGlobalMessage(lang) {
56
+ return store$3?.get(lang);
57
+ }
58
+ __name(getGlobalMessage, "getGlobalMessage");
59
+ var store$2;
60
+ // @__NO_SIDE_EFFECTS__
61
+ function getSchemaMessage(lang) {
62
+ return store$2?.get(lang);
63
+ }
64
+ __name(getSchemaMessage, "getSchemaMessage");
65
+ var store$1;
66
+ // @__NO_SIDE_EFFECTS__
67
+ function getSpecificMessage(reference2, lang) {
68
+ return store$1?.get(reference2)?.get(lang);
69
+ }
70
+ __name(getSpecificMessage, "getSpecificMessage");
71
+ // @__NO_SIDE_EFFECTS__
72
+ function _stringify(input) {
73
+ const type = typeof input;
74
+ if (type === "string") return `"${input}"`;
75
+ if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
76
+ if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
77
+ return type;
78
+ }
79
+ __name(_stringify, "_stringify");
80
+ function _addIssue(context, label, dataset, config$1, other) {
81
+ const input = other && "input" in other ? other.input : dataset.value;
82
+ const expected = other?.expected ?? context.expects ?? null;
83
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
84
+ const issue = {
85
+ kind: context.kind,
86
+ type: context.type,
87
+ input,
88
+ expected,
89
+ received,
90
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
91
+ requirement: context.requirement,
92
+ path: other?.path,
93
+ issues: other?.issues,
94
+ lang: config$1.lang,
95
+ abortEarly: config$1.abortEarly,
96
+ abortPipeEarly: config$1.abortPipeEarly
97
+ };
98
+ const isSchema = context.kind === "schema";
99
+ 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);
100
+ if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
101
+ if (isSchema) dataset.typed = false;
102
+ if (dataset.issues) dataset.issues.push(issue);
103
+ else dataset.issues = [issue];
104
+ }
105
+ __name(_addIssue, "_addIssue");
106
+ // @__NO_SIDE_EFFECTS__
107
+ function _isSameValueZero(value1, value2) {
108
+ return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
109
+ }
110
+ __name(_isSameValueZero, "_isSameValueZero");
111
+ // @__NO_SIDE_EFFECTS__
112
+ function _isValidObjectKey(object$1, key) {
113
+ return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
114
+ }
115
+ __name(_isValidObjectKey, "_isValidObjectKey");
116
+ // @__NO_SIDE_EFFECTS__
117
+ function _joinExpects(values$1, separator) {
118
+ const list = [...new Set(values$1)];
119
+ if (list.length > 1) return `(${list.join(` ${separator} `)})`;
120
+ return list[0] ?? "never";
121
+ }
122
+ __name(_joinExpects, "_joinExpects");
123
+ function _standardSchema(schema) {
124
+ schema["~standard"] = {
125
+ version: 1,
126
+ vendor: "valibot",
127
+ validate: /* @__PURE__ */ __name((value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig()), "validate")
128
+ };
129
+ return schema;
130
+ }
131
+ __name(_standardSchema, "_standardSchema");
132
+ // @__NO_SIDE_EFFECTS__
133
+ function getDotPath(issue) {
134
+ if (issue.path) {
135
+ let key = "";
136
+ for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
137
+ else key += item.key;
138
+ else return null;
139
+ return key;
140
+ }
141
+ return null;
142
+ }
143
+ __name(getDotPath, "getDotPath");
144
+ var ValiError = class extends Error {
145
+ static {
146
+ __name(this, "ValiError");
147
+ }
148
+ /**
149
+ * Creates a Valibot error with useful information.
150
+ *
151
+ * @param issues The error issues.
152
+ */
153
+ constructor(issues) {
154
+ super(issues[0].message);
155
+ this.name = "ValiError";
156
+ this.issues = issues;
157
+ }
158
+ };
159
+ 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");
160
+ var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])$/u;
161
+ 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;
162
+ // @__NO_SIDE_EFFECTS__
163
+ function check(requirement, message$1) {
164
+ return {
165
+ kind: "validation",
166
+ type: "check",
167
+ reference: check,
168
+ async: false,
169
+ expects: null,
170
+ requirement,
171
+ message: message$1,
172
+ "~run"(dataset, config$1) {
173
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
174
+ return dataset;
175
+ }
176
+ };
177
+ }
178
+ __name(check, "check");
179
+ // @__NO_SIDE_EFFECTS__
180
+ function description(description_) {
181
+ return {
182
+ kind: "metadata",
183
+ type: "description",
184
+ reference: description,
185
+ description: description_
186
+ };
187
+ }
188
+ __name(description, "description");
189
+ // @__NO_SIDE_EFFECTS__
190
+ function endsWith(requirement, message$1) {
191
+ return {
192
+ kind: "validation",
193
+ type: "ends_with",
194
+ reference: endsWith,
195
+ async: false,
196
+ expects: `"${requirement}"`,
197
+ requirement,
198
+ message: message$1,
199
+ "~run"(dataset, config$1) {
200
+ if (dataset.typed && !dataset.value.endsWith(this.requirement)) _addIssue(this, "end", dataset, config$1, { received: `"${dataset.value.slice(-this.requirement.length)}"` });
201
+ return dataset;
202
+ }
203
+ };
204
+ }
205
+ __name(endsWith, "endsWith");
206
+ // @__NO_SIDE_EFFECTS__
207
+ function finite(message$1) {
208
+ return {
209
+ kind: "validation",
210
+ type: "finite",
211
+ reference: finite,
212
+ async: false,
213
+ expects: null,
214
+ requirement: Number.isFinite,
215
+ message: message$1,
216
+ "~run"(dataset, config$1) {
217
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "finite", dataset, config$1);
218
+ return dataset;
219
+ }
220
+ };
221
+ }
222
+ __name(finite, "finite");
223
+ // @__NO_SIDE_EFFECTS__
224
+ function integer(message$1) {
225
+ return {
226
+ kind: "validation",
227
+ type: "integer",
228
+ reference: integer,
229
+ async: false,
230
+ expects: null,
231
+ requirement: Number.isInteger,
232
+ message: message$1,
233
+ "~run"(dataset, config$1) {
234
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
235
+ return dataset;
236
+ }
237
+ };
238
+ }
239
+ __name(integer, "integer");
240
+ // @__NO_SIDE_EFFECTS__
241
+ function isoDate(message$1) {
242
+ return {
243
+ kind: "validation",
244
+ type: "iso_date",
245
+ reference: isoDate,
246
+ async: false,
247
+ expects: null,
248
+ requirement: ISO_DATE_REGEX,
249
+ message: message$1,
250
+ "~run"(dataset, config$1) {
251
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "date", dataset, config$1);
252
+ return dataset;
253
+ }
254
+ };
255
+ }
256
+ __name(isoDate, "isoDate");
257
+ // @__NO_SIDE_EFFECTS__
258
+ function isoTimestamp(message$1) {
259
+ return {
260
+ kind: "validation",
261
+ type: "iso_timestamp",
262
+ reference: isoTimestamp,
263
+ async: false,
264
+ expects: null,
265
+ requirement: ISO_TIMESTAMP_REGEX,
266
+ message: message$1,
267
+ "~run"(dataset, config$1) {
268
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "timestamp", dataset, config$1);
269
+ return dataset;
270
+ }
271
+ };
272
+ }
273
+ __name(isoTimestamp, "isoTimestamp");
274
+ // @__NO_SIDE_EFFECTS__
275
+ function maxLength(requirement, message$1) {
276
+ return {
277
+ kind: "validation",
278
+ type: "max_length",
279
+ reference: maxLength,
280
+ async: false,
281
+ expects: `<=${requirement}`,
282
+ requirement,
283
+ message: message$1,
284
+ "~run"(dataset, config$1) {
285
+ if (dataset.typed && dataset.value.length > this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
286
+ return dataset;
287
+ }
288
+ };
289
+ }
290
+ __name(maxLength, "maxLength");
291
+ // @__NO_SIDE_EFFECTS__
292
+ function maxValue(requirement, message$1) {
293
+ return {
294
+ kind: "validation",
295
+ type: "max_value",
296
+ reference: maxValue,
297
+ async: false,
298
+ expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
299
+ requirement,
300
+ message: message$1,
301
+ "~run"(dataset, config$1) {
302
+ 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) });
303
+ return dataset;
304
+ }
305
+ };
306
+ }
307
+ __name(maxValue, "maxValue");
308
+ // @__NO_SIDE_EFFECTS__
309
+ function minLength(requirement, message$1) {
310
+ return {
311
+ kind: "validation",
312
+ type: "min_length",
313
+ reference: minLength,
314
+ async: false,
315
+ expects: `>=${requirement}`,
316
+ requirement,
317
+ message: message$1,
318
+ "~run"(dataset, config$1) {
319
+ if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
320
+ return dataset;
321
+ }
322
+ };
323
+ }
324
+ __name(minLength, "minLength");
325
+ // @__NO_SIDE_EFFECTS__
326
+ function minValue(requirement, message$1) {
327
+ return {
328
+ kind: "validation",
329
+ type: "min_value",
330
+ reference: minValue,
331
+ async: false,
332
+ expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
333
+ requirement,
334
+ message: message$1,
335
+ "~run"(dataset, config$1) {
336
+ 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) });
337
+ return dataset;
338
+ }
339
+ };
340
+ }
341
+ __name(minValue, "minValue");
342
+ // @__NO_SIDE_EFFECTS__
343
+ function nonEmpty(message$1) {
344
+ return {
345
+ kind: "validation",
346
+ type: "non_empty",
347
+ reference: nonEmpty,
348
+ async: false,
349
+ expects: "!0",
350
+ message: message$1,
351
+ "~run"(dataset, config$1) {
352
+ if (dataset.typed && dataset.value.length === 0) _addIssue(this, "length", dataset, config$1, { received: "0" });
353
+ return dataset;
354
+ }
355
+ };
356
+ }
357
+ __name(nonEmpty, "nonEmpty");
358
+ // @__NO_SIDE_EFFECTS__
359
+ function regex(requirement, message$1) {
360
+ return {
361
+ kind: "validation",
362
+ type: "regex",
363
+ reference: regex,
364
+ async: false,
365
+ expects: `${requirement}`,
366
+ requirement,
367
+ message: message$1,
368
+ "~run"(dataset, config$1) {
369
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config$1);
370
+ return dataset;
371
+ }
372
+ };
373
+ }
374
+ __name(regex, "regex");
375
+ // @__NO_SIDE_EFFECTS__
376
+ function safeInteger(message$1) {
377
+ return {
378
+ kind: "validation",
379
+ type: "safe_integer",
380
+ reference: safeInteger,
381
+ async: false,
382
+ expects: null,
383
+ requirement: Number.isSafeInteger,
384
+ message: message$1,
385
+ "~run"(dataset, config$1) {
386
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "safe integer", dataset, config$1);
387
+ return dataset;
388
+ }
389
+ };
390
+ }
391
+ __name(safeInteger, "safeInteger");
392
+ // @__NO_SIDE_EFFECTS__
393
+ function transform(operation) {
394
+ return {
395
+ kind: "transformation",
396
+ type: "transform",
397
+ reference: transform,
398
+ async: false,
399
+ operation,
400
+ "~run"(dataset) {
401
+ dataset.value = this.operation(dataset.value);
402
+ return dataset;
403
+ }
404
+ };
405
+ }
406
+ __name(transform, "transform");
407
+ // @__NO_SIDE_EFFECTS__
408
+ function trim() {
409
+ return {
410
+ kind: "transformation",
411
+ type: "trim",
412
+ reference: trim,
413
+ async: false,
414
+ "~run"(dataset) {
415
+ dataset.value = dataset.value.trim();
416
+ return dataset;
417
+ }
418
+ };
419
+ }
420
+ __name(trim, "trim");
421
+ var ABORT_EARLY_CONFIG = { abortEarly: true };
422
+ // @__NO_SIDE_EFFECTS__
423
+ function getFallback(schema, dataset, config$1) {
424
+ return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
425
+ }
426
+ __name(getFallback, "getFallback");
427
+ // @__NO_SIDE_EFFECTS__
428
+ function forward(action, path) {
429
+ return {
430
+ ...action,
431
+ "~run"(dataset, config$1) {
432
+ const prevIssues = dataset.issues && [...dataset.issues];
433
+ dataset = action["~run"](dataset, config$1);
434
+ if (dataset.issues) {
435
+ for (const issue of dataset.issues) if (!prevIssues?.includes(issue)) {
436
+ let pathInput = dataset.value;
437
+ for (const key of path) {
438
+ const pathValue = pathInput[key];
439
+ const pathItem = {
440
+ type: "unknown",
441
+ origin: "value",
442
+ input: pathInput,
443
+ key,
444
+ value: pathValue
445
+ };
446
+ if (issue.path) issue.path.push(pathItem);
447
+ else issue.path = [pathItem];
448
+ if (!pathValue) break;
449
+ pathInput = pathValue;
450
+ }
451
+ }
452
+ }
453
+ return dataset;
454
+ }
455
+ };
456
+ }
457
+ __name(forward, "forward");
458
+ // @__NO_SIDE_EFFECTS__
459
+ function getDefault(schema, dataset, config$1) {
460
+ return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
461
+ }
462
+ __name(getDefault, "getDefault");
463
+ // @__NO_SIDE_EFFECTS__
464
+ function array(item, message$1) {
465
+ return _standardSchema({
466
+ kind: "schema",
467
+ type: "array",
468
+ reference: array,
469
+ expects: "Array",
470
+ async: false,
471
+ item,
472
+ message: message$1,
473
+ "~run"(dataset, config$1) {
474
+ const input = dataset.value;
475
+ if (Array.isArray(input)) {
476
+ dataset.typed = true;
477
+ dataset.value = [];
478
+ for (let key = 0; key < input.length; key++) {
479
+ const value$1 = input[key];
480
+ const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
481
+ if (itemDataset.issues) {
482
+ const pathItem = {
483
+ type: "array",
484
+ origin: "value",
485
+ input,
486
+ key,
487
+ value: value$1
488
+ };
489
+ for (const issue of itemDataset.issues) {
490
+ if (issue.path) issue.path.unshift(pathItem);
491
+ else issue.path = [pathItem];
492
+ dataset.issues?.push(issue);
493
+ }
494
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
495
+ if (config$1.abortEarly) {
496
+ dataset.typed = false;
497
+ break;
498
+ }
499
+ }
500
+ if (!itemDataset.typed) dataset.typed = false;
501
+ dataset.value.push(itemDataset.value);
502
+ }
503
+ } else _addIssue(this, "type", dataset, config$1);
504
+ return dataset;
505
+ }
506
+ });
507
+ }
508
+ __name(array, "array");
509
+ // @__NO_SIDE_EFFECTS__
510
+ function boolean(message$1) {
511
+ return _standardSchema({
512
+ kind: "schema",
513
+ type: "boolean",
514
+ reference: boolean,
515
+ expects: "boolean",
516
+ async: false,
517
+ message: message$1,
518
+ "~run"(dataset, config$1) {
519
+ if (typeof dataset.value === "boolean") dataset.typed = true;
520
+ else _addIssue(this, "type", dataset, config$1);
521
+ return dataset;
522
+ }
523
+ });
524
+ }
525
+ __name(boolean, "boolean");
526
+ // @__NO_SIDE_EFFECTS__
527
+ function custom(check$1, message$1) {
528
+ return _standardSchema({
529
+ kind: "schema",
530
+ type: "custom",
531
+ reference: custom,
532
+ expects: "unknown",
533
+ async: false,
534
+ check: check$1,
535
+ message: message$1,
536
+ "~run"(dataset, config$1) {
537
+ if (this.check(dataset.value)) dataset.typed = true;
538
+ else _addIssue(this, "type", dataset, config$1);
539
+ return dataset;
540
+ }
541
+ });
542
+ }
543
+ __name(custom, "custom");
544
+ // @__NO_SIDE_EFFECTS__
545
+ function lazy(getter) {
546
+ return _standardSchema({
547
+ kind: "schema",
548
+ type: "lazy",
549
+ reference: lazy,
550
+ expects: "unknown",
551
+ async: false,
552
+ getter,
553
+ "~run"(dataset, config$1) {
554
+ return this.getter(dataset.value)["~run"](dataset, config$1);
555
+ }
556
+ });
557
+ }
558
+ __name(lazy, "lazy");
559
+ // @__NO_SIDE_EFFECTS__
560
+ function literal(literal_, message$1) {
561
+ return _standardSchema({
562
+ kind: "schema",
563
+ type: "literal",
564
+ reference: literal,
565
+ expects: /* @__PURE__ */ _stringify(literal_),
566
+ async: false,
567
+ literal: literal_,
568
+ message: message$1,
569
+ "~run"(dataset, config$1) {
570
+ if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
571
+ else _addIssue(this, "type", dataset, config$1);
572
+ return dataset;
573
+ }
574
+ });
575
+ }
576
+ __name(literal, "literal");
577
+ // @__NO_SIDE_EFFECTS__
578
+ function looseObject(entries$1, message$1) {
579
+ return _standardSchema({
580
+ kind: "schema",
581
+ type: "loose_object",
582
+ reference: looseObject,
583
+ expects: "Object",
584
+ async: false,
585
+ entries: entries$1,
586
+ message: message$1,
587
+ "~run"(dataset, config$1) {
588
+ const input = dataset.value;
589
+ if (input && typeof input === "object") {
590
+ dataset.typed = true;
591
+ dataset.value = {};
592
+ for (const key in this.entries) {
593
+ const valueSchema = this.entries[key];
594
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
595
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
596
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
597
+ if (valueDataset.issues) {
598
+ const pathItem = {
599
+ type: "object",
600
+ origin: "value",
601
+ input,
602
+ key,
603
+ value: value$1
604
+ };
605
+ for (const issue of valueDataset.issues) {
606
+ if (issue.path) issue.path.unshift(pathItem);
607
+ else issue.path = [pathItem];
608
+ dataset.issues?.push(issue);
609
+ }
610
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
611
+ if (config$1.abortEarly) {
612
+ dataset.typed = false;
613
+ break;
614
+ }
615
+ }
616
+ if (!valueDataset.typed) dataset.typed = false;
617
+ dataset.value[key] = valueDataset.value;
618
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
619
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
620
+ _addIssue(this, "key", dataset, config$1, {
621
+ input: void 0,
622
+ expected: `"${key}"`,
623
+ path: [{
624
+ type: "object",
625
+ origin: "key",
626
+ input,
627
+ key,
628
+ value: input[key]
629
+ }]
630
+ });
631
+ if (config$1.abortEarly) break;
632
+ }
633
+ }
634
+ if (!dataset.issues || !config$1.abortEarly) {
635
+ for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) dataset.value[key] = input[key];
636
+ }
637
+ } else _addIssue(this, "type", dataset, config$1);
638
+ return dataset;
639
+ }
640
+ });
641
+ }
642
+ __name(looseObject, "looseObject");
643
+ // @__NO_SIDE_EFFECTS__
644
+ function null_(message$1) {
645
+ return _standardSchema({
646
+ kind: "schema",
647
+ type: "null",
648
+ reference: null_,
649
+ expects: "null",
650
+ async: false,
651
+ message: message$1,
652
+ "~run"(dataset, config$1) {
653
+ if (dataset.value === null) dataset.typed = true;
654
+ else _addIssue(this, "type", dataset, config$1);
655
+ return dataset;
656
+ }
657
+ });
658
+ }
659
+ __name(null_, "null_");
660
+ // @__NO_SIDE_EFFECTS__
661
+ function nullable(wrapped, default_) {
662
+ return _standardSchema({
663
+ kind: "schema",
664
+ type: "nullable",
665
+ reference: nullable,
666
+ expects: `(${wrapped.expects} | null)`,
667
+ async: false,
668
+ wrapped,
669
+ default: default_,
670
+ "~run"(dataset, config$1) {
671
+ if (dataset.value === null) {
672
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
673
+ if (dataset.value === null) {
674
+ dataset.typed = true;
675
+ return dataset;
676
+ }
677
+ }
678
+ return this.wrapped["~run"](dataset, config$1);
679
+ }
680
+ });
681
+ }
682
+ __name(nullable, "nullable");
683
+ // @__NO_SIDE_EFFECTS__
684
+ function number(message$1) {
685
+ return _standardSchema({
686
+ kind: "schema",
687
+ type: "number",
688
+ reference: number,
689
+ expects: "number",
690
+ async: false,
691
+ message: message$1,
692
+ "~run"(dataset, config$1) {
693
+ if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
694
+ else _addIssue(this, "type", dataset, config$1);
695
+ return dataset;
696
+ }
697
+ });
698
+ }
699
+ __name(number, "number");
700
+ // @__NO_SIDE_EFFECTS__
701
+ function object(entries$1, message$1) {
702
+ return _standardSchema({
703
+ kind: "schema",
704
+ type: "object",
705
+ reference: object,
706
+ expects: "Object",
707
+ async: false,
708
+ entries: entries$1,
709
+ message: message$1,
710
+ "~run"(dataset, config$1) {
711
+ const input = dataset.value;
712
+ if (input && typeof input === "object") {
713
+ dataset.typed = true;
714
+ dataset.value = {};
715
+ for (const key in this.entries) {
716
+ const valueSchema = this.entries[key];
717
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
718
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
719
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
720
+ if (valueDataset.issues) {
721
+ const pathItem = {
722
+ type: "object",
723
+ origin: "value",
724
+ input,
725
+ key,
726
+ value: value$1
727
+ };
728
+ for (const issue of valueDataset.issues) {
729
+ if (issue.path) issue.path.unshift(pathItem);
730
+ else issue.path = [pathItem];
731
+ dataset.issues?.push(issue);
732
+ }
733
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
734
+ if (config$1.abortEarly) {
735
+ dataset.typed = false;
736
+ break;
737
+ }
738
+ }
739
+ if (!valueDataset.typed) dataset.typed = false;
740
+ dataset.value[key] = valueDataset.value;
741
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
742
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
743
+ _addIssue(this, "key", dataset, config$1, {
744
+ input: void 0,
745
+ expected: `"${key}"`,
746
+ path: [{
747
+ type: "object",
748
+ origin: "key",
749
+ input,
750
+ key,
751
+ value: input[key]
752
+ }]
753
+ });
754
+ if (config$1.abortEarly) break;
755
+ }
756
+ }
757
+ } else _addIssue(this, "type", dataset, config$1);
758
+ return dataset;
759
+ }
760
+ });
761
+ }
762
+ __name(object, "object");
763
+ // @__NO_SIDE_EFFECTS__
764
+ function objectWithRest(entries$1, rest, message$1) {
765
+ return _standardSchema({
766
+ kind: "schema",
767
+ type: "object_with_rest",
768
+ reference: objectWithRest,
769
+ expects: "Object",
770
+ async: false,
771
+ entries: entries$1,
772
+ rest,
773
+ message: message$1,
774
+ "~run"(dataset, config$1) {
775
+ const input = dataset.value;
776
+ if (input && typeof input === "object") {
777
+ dataset.typed = true;
778
+ dataset.value = {};
779
+ for (const key in this.entries) {
780
+ const valueSchema = this.entries[key];
781
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
782
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
783
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
784
+ if (valueDataset.issues) {
785
+ const pathItem = {
786
+ type: "object",
787
+ origin: "value",
788
+ input,
789
+ key,
790
+ value: value$1
791
+ };
792
+ for (const issue of valueDataset.issues) {
793
+ if (issue.path) issue.path.unshift(pathItem);
794
+ else issue.path = [pathItem];
795
+ dataset.issues?.push(issue);
796
+ }
797
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
798
+ if (config$1.abortEarly) {
799
+ dataset.typed = false;
800
+ break;
801
+ }
802
+ }
803
+ if (!valueDataset.typed) dataset.typed = false;
804
+ dataset.value[key] = valueDataset.value;
805
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
806
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
807
+ _addIssue(this, "key", dataset, config$1, {
808
+ input: void 0,
809
+ expected: `"${key}"`,
810
+ path: [{
811
+ type: "object",
812
+ origin: "key",
813
+ input,
814
+ key,
815
+ value: input[key]
816
+ }]
817
+ });
818
+ if (config$1.abortEarly) break;
819
+ }
820
+ }
821
+ if (!dataset.issues || !config$1.abortEarly) {
822
+ for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
823
+ const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
824
+ if (valueDataset.issues) {
825
+ const pathItem = {
826
+ type: "object",
827
+ origin: "value",
828
+ input,
829
+ key,
830
+ value: input[key]
831
+ };
832
+ for (const issue of valueDataset.issues) {
833
+ if (issue.path) issue.path.unshift(pathItem);
834
+ else issue.path = [pathItem];
835
+ dataset.issues?.push(issue);
836
+ }
837
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
838
+ if (config$1.abortEarly) {
839
+ dataset.typed = false;
840
+ break;
841
+ }
842
+ }
843
+ if (!valueDataset.typed) dataset.typed = false;
844
+ dataset.value[key] = valueDataset.value;
845
+ }
846
+ }
847
+ } else _addIssue(this, "type", dataset, config$1);
848
+ return dataset;
849
+ }
850
+ });
851
+ }
852
+ __name(objectWithRest, "objectWithRest");
853
+ // @__NO_SIDE_EFFECTS__
854
+ function optional(wrapped, default_) {
855
+ return _standardSchema({
856
+ kind: "schema",
857
+ type: "optional",
858
+ reference: optional,
859
+ expects: `(${wrapped.expects} | undefined)`,
860
+ async: false,
861
+ wrapped,
862
+ default: default_,
863
+ "~run"(dataset, config$1) {
864
+ if (dataset.value === void 0) {
865
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
866
+ if (dataset.value === void 0) {
867
+ dataset.typed = true;
868
+ return dataset;
869
+ }
870
+ }
871
+ return this.wrapped["~run"](dataset, config$1);
872
+ }
873
+ });
874
+ }
875
+ __name(optional, "optional");
876
+ // @__NO_SIDE_EFFECTS__
877
+ function picklist(options, message$1) {
878
+ return _standardSchema({
879
+ kind: "schema",
880
+ type: "picklist",
881
+ reference: picklist,
882
+ expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
883
+ async: false,
884
+ options,
885
+ message: message$1,
886
+ "~run"(dataset, config$1) {
887
+ if (this.options.includes(dataset.value)) dataset.typed = true;
888
+ else _addIssue(this, "type", dataset, config$1);
889
+ return dataset;
890
+ }
891
+ });
892
+ }
893
+ __name(picklist, "picklist");
894
+ // @__NO_SIDE_EFFECTS__
895
+ function record(key, value$1, message$1) {
896
+ return _standardSchema({
897
+ kind: "schema",
898
+ type: "record",
899
+ reference: record,
900
+ expects: "Object",
901
+ async: false,
902
+ key,
903
+ value: value$1,
904
+ message: message$1,
905
+ "~run"(dataset, config$1) {
906
+ const input = dataset.value;
907
+ if (input && typeof input === "object") {
908
+ dataset.typed = true;
909
+ dataset.value = {};
910
+ for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
911
+ const entryValue = input[entryKey];
912
+ const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
913
+ if (keyDataset.issues) {
914
+ const pathItem = {
915
+ type: "object",
916
+ origin: "key",
917
+ input,
918
+ key: entryKey,
919
+ value: entryValue
920
+ };
921
+ for (const issue of keyDataset.issues) {
922
+ issue.path = [pathItem];
923
+ dataset.issues?.push(issue);
924
+ }
925
+ if (!dataset.issues) dataset.issues = keyDataset.issues;
926
+ if (config$1.abortEarly) {
927
+ dataset.typed = false;
928
+ break;
929
+ }
930
+ }
931
+ const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
932
+ if (valueDataset.issues) {
933
+ const pathItem = {
934
+ type: "object",
935
+ origin: "value",
936
+ input,
937
+ key: entryKey,
938
+ value: entryValue
939
+ };
940
+ for (const issue of valueDataset.issues) {
941
+ if (issue.path) issue.path.unshift(pathItem);
942
+ else issue.path = [pathItem];
943
+ dataset.issues?.push(issue);
944
+ }
945
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
946
+ if (config$1.abortEarly) {
947
+ dataset.typed = false;
948
+ break;
949
+ }
950
+ }
951
+ if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
952
+ if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
953
+ }
954
+ } else _addIssue(this, "type", dataset, config$1);
955
+ return dataset;
956
+ }
957
+ });
958
+ }
959
+ __name(record, "record");
960
+ // @__NO_SIDE_EFFECTS__
961
+ function strictObject(entries$1, message$1) {
962
+ return _standardSchema({
963
+ kind: "schema",
964
+ type: "strict_object",
965
+ reference: strictObject,
966
+ expects: "Object",
967
+ async: false,
968
+ entries: entries$1,
969
+ message: message$1,
970
+ "~run"(dataset, config$1) {
971
+ const input = dataset.value;
972
+ if (input && typeof input === "object") {
973
+ dataset.typed = true;
974
+ dataset.value = {};
975
+ for (const key in this.entries) {
976
+ const valueSchema = this.entries[key];
977
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
978
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
979
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
980
+ if (valueDataset.issues) {
981
+ const pathItem = {
982
+ type: "object",
983
+ origin: "value",
984
+ input,
985
+ key,
986
+ value: value$1
987
+ };
988
+ for (const issue of valueDataset.issues) {
989
+ if (issue.path) issue.path.unshift(pathItem);
990
+ else issue.path = [pathItem];
991
+ dataset.issues?.push(issue);
992
+ }
993
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
994
+ if (config$1.abortEarly) {
995
+ dataset.typed = false;
996
+ break;
997
+ }
998
+ }
999
+ if (!valueDataset.typed) dataset.typed = false;
1000
+ dataset.value[key] = valueDataset.value;
1001
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
1002
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
1003
+ _addIssue(this, "key", dataset, config$1, {
1004
+ input: void 0,
1005
+ expected: `"${key}"`,
1006
+ path: [{
1007
+ type: "object",
1008
+ origin: "key",
1009
+ input,
1010
+ key,
1011
+ value: input[key]
1012
+ }]
1013
+ });
1014
+ if (config$1.abortEarly) break;
1015
+ }
1016
+ }
1017
+ if (!dataset.issues || !config$1.abortEarly) {
1018
+ for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
1019
+ _addIssue(this, "key", dataset, config$1, {
1020
+ input: key,
1021
+ expected: "never",
1022
+ path: [{
1023
+ type: "object",
1024
+ origin: "key",
1025
+ input,
1026
+ key,
1027
+ value: input[key]
1028
+ }]
1029
+ });
1030
+ break;
1031
+ }
1032
+ }
1033
+ } else _addIssue(this, "type", dataset, config$1);
1034
+ return dataset;
1035
+ }
1036
+ });
1037
+ }
1038
+ __name(strictObject, "strictObject");
1039
+ // @__NO_SIDE_EFFECTS__
1040
+ function string(message$1) {
1041
+ return _standardSchema({
1042
+ kind: "schema",
1043
+ type: "string",
1044
+ reference: string,
1045
+ expects: "string",
1046
+ async: false,
1047
+ message: message$1,
1048
+ "~run"(dataset, config$1) {
1049
+ if (typeof dataset.value === "string") dataset.typed = true;
1050
+ else _addIssue(this, "type", dataset, config$1);
1051
+ return dataset;
1052
+ }
1053
+ });
1054
+ }
1055
+ __name(string, "string");
1056
+ // @__NO_SIDE_EFFECTS__
1057
+ function _subIssues(datasets) {
1058
+ let issues;
1059
+ if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
1060
+ else issues = dataset.issues;
1061
+ return issues;
1062
+ }
1063
+ __name(_subIssues, "_subIssues");
1064
+ // @__NO_SIDE_EFFECTS__
1065
+ function union(options, message$1) {
1066
+ return _standardSchema({
1067
+ kind: "schema",
1068
+ type: "union",
1069
+ reference: union,
1070
+ expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1071
+ async: false,
1072
+ options,
1073
+ message: message$1,
1074
+ "~run"(dataset, config$1) {
1075
+ let validDataset;
1076
+ let typedDatasets;
1077
+ let untypedDatasets;
1078
+ for (const schema of this.options) {
1079
+ const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
1080
+ if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
1081
+ else typedDatasets = [optionDataset];
1082
+ else {
1083
+ validDataset = optionDataset;
1084
+ break;
1085
+ }
1086
+ else if (untypedDatasets) untypedDatasets.push(optionDataset);
1087
+ else untypedDatasets = [optionDataset];
1088
+ }
1089
+ if (validDataset) return validDataset;
1090
+ if (typedDatasets) {
1091
+ if (typedDatasets.length === 1) return typedDatasets[0];
1092
+ _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
1093
+ dataset.typed = true;
1094
+ } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
1095
+ else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
1096
+ return dataset;
1097
+ }
1098
+ });
1099
+ }
1100
+ __name(union, "union");
1101
+ // @__NO_SIDE_EFFECTS__
1102
+ function unknown() {
1103
+ return _standardSchema({
1104
+ kind: "schema",
1105
+ type: "unknown",
1106
+ reference: unknown,
1107
+ expects: "unknown",
1108
+ async: false,
1109
+ "~run"(dataset) {
1110
+ dataset.typed = true;
1111
+ return dataset;
1112
+ }
1113
+ });
1114
+ }
1115
+ __name(unknown, "unknown");
1116
+ // @__NO_SIDE_EFFECTS__
1117
+ function variant(key, options, message$1) {
1118
+ return _standardSchema({
1119
+ kind: "schema",
1120
+ type: "variant",
1121
+ reference: variant,
1122
+ expects: "Object",
1123
+ async: false,
1124
+ key,
1125
+ options,
1126
+ message: message$1,
1127
+ "~run"(dataset, config$1) {
1128
+ const input = dataset.value;
1129
+ if (input && typeof input === "object") {
1130
+ let outputDataset;
1131
+ let maxDiscriminatorPriority = 0;
1132
+ let invalidDiscriminatorKey = this.key;
1133
+ let expectedDiscriminators = [];
1134
+ const parseOptions = /* @__PURE__ */ __name((variant$1, allKeys) => {
1135
+ for (const schema of variant$1.options) {
1136
+ if (schema.type === "variant") parseOptions(schema, new Set(allKeys).add(schema.key));
1137
+ else {
1138
+ let keysAreValid = true;
1139
+ let currentPriority = 0;
1140
+ for (const currentKey of allKeys) {
1141
+ const discriminatorSchema = schema.entries[currentKey];
1142
+ if (currentKey in input ? discriminatorSchema["~run"]({
1143
+ typed: false,
1144
+ value: input[currentKey]
1145
+ }, ABORT_EARLY_CONFIG).issues : discriminatorSchema.type !== "exact_optional" && discriminatorSchema.type !== "optional" && discriminatorSchema.type !== "nullish") {
1146
+ keysAreValid = false;
1147
+ if (invalidDiscriminatorKey !== currentKey && (maxDiscriminatorPriority < currentPriority || maxDiscriminatorPriority === currentPriority && currentKey in input && !(invalidDiscriminatorKey in input))) {
1148
+ maxDiscriminatorPriority = currentPriority;
1149
+ invalidDiscriminatorKey = currentKey;
1150
+ expectedDiscriminators = [];
1151
+ }
1152
+ if (invalidDiscriminatorKey === currentKey) expectedDiscriminators.push(schema.entries[currentKey].expects);
1153
+ break;
1154
+ }
1155
+ currentPriority++;
1156
+ }
1157
+ if (keysAreValid) {
1158
+ const optionDataset = schema["~run"]({ value: input }, config$1);
1159
+ if (!outputDataset || !outputDataset.typed && optionDataset.typed) outputDataset = optionDataset;
1160
+ }
1161
+ }
1162
+ if (outputDataset && !outputDataset.issues) break;
1163
+ }
1164
+ }, "parseOptions");
1165
+ parseOptions(this, /* @__PURE__ */ new Set([this.key]));
1166
+ if (outputDataset) return outputDataset;
1167
+ _addIssue(this, "type", dataset, config$1, {
1168
+ input: input[invalidDiscriminatorKey],
1169
+ expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
1170
+ path: [{
1171
+ type: "object",
1172
+ origin: "value",
1173
+ input,
1174
+ key: invalidDiscriminatorKey,
1175
+ value: input[invalidDiscriminatorKey]
1176
+ }]
1177
+ });
1178
+ } else _addIssue(this, "type", dataset, config$1);
1179
+ return dataset;
1180
+ }
1181
+ });
1182
+ }
1183
+ __name(variant, "variant");
1184
+ // @__NO_SIDE_EFFECTS__
1185
+ function omit(schema, keys) {
1186
+ const entries$1 = { ...schema.entries };
1187
+ for (const key of keys) delete entries$1[key];
1188
+ return _standardSchema({
1189
+ ...schema,
1190
+ entries: entries$1
1191
+ });
1192
+ }
1193
+ __name(omit, "omit");
1194
+ function parse(schema, input, config$1) {
1195
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1196
+ if (dataset.issues) throw new ValiError(dataset.issues);
1197
+ return dataset.value;
1198
+ }
1199
+ __name(parse, "parse");
1200
+ // @__NO_SIDE_EFFECTS__
1201
+ function partial(schema, keys) {
1202
+ const entries$1 = {};
1203
+ for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
1204
+ return _standardSchema({
1205
+ ...schema,
1206
+ entries: entries$1
1207
+ });
1208
+ }
1209
+ __name(partial, "partial");
1210
+ // @__NO_SIDE_EFFECTS__
1211
+ function pick(schema, keys) {
1212
+ const entries$1 = {};
1213
+ for (const key of keys) entries$1[key] = schema.entries[key];
1214
+ return _standardSchema({
1215
+ ...schema,
1216
+ entries: entries$1
1217
+ });
1218
+ }
1219
+ __name(pick, "pick");
1220
+ // @__NO_SIDE_EFFECTS__
1221
+ function pipe(...pipe$1) {
1222
+ return _standardSchema({
1223
+ ...pipe$1[0],
1224
+ pipe: pipe$1,
1225
+ "~run"(dataset, config$1) {
1226
+ for (const item of pipe$1) if (item.kind !== "metadata") {
1227
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
1228
+ dataset.typed = false;
1229
+ break;
1230
+ }
1231
+ if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
1232
+ }
1233
+ return dataset;
1234
+ }
1235
+ });
1236
+ }
1237
+ __name(pipe, "pipe");
1238
+ // @__NO_SIDE_EFFECTS__
1239
+ function safeParse(schema, input, config$1) {
1240
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1241
+ return {
1242
+ typed: dataset.typed,
1243
+ success: !dataset.issues,
1244
+ output: dataset.value,
1245
+ issues: dataset.issues
1246
+ };
1247
+ }
1248
+ __name(safeParse, "safeParse");
1249
+ // @__NO_SIDE_EFFECTS__
1250
+ function summarize(issues) {
1251
+ let summary = "";
1252
+ for (const issue of issues) {
1253
+ if (summary) summary += "\n";
1254
+ summary += `\xD7 ${issue.message}`;
1255
+ const dotPath = /* @__PURE__ */ getDotPath(issue);
1256
+ if (dotPath) summary += `
1257
+ \u2192 at ${dotPath}`;
1258
+ }
1259
+ return summary;
1260
+ }
1261
+ __name(summarize, "summarize");
1262
+ // @__NO_SIDE_EFFECTS__
1263
+ function unwrap(schema) {
1264
+ return schema.wrapped;
1265
+ }
1266
+ __name(unwrap, "unwrap");
1267
+
1268
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/effects.js
1269
+ var EFFECT_LEVELS = ["none", "read", "write"];
1270
+ var effectsSchema = strictObject({
1271
+ remote: picklist(EFFECT_LEVELS),
1272
+ local: picklist(EFFECT_LEVELS)
1273
+ });
1274
+ var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
1275
+
1276
+ // 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
1277
+ function addError(errors, message) {
1278
+ if (errors) {
1279
+ errors.push(message);
1280
+ return errors;
1281
+ }
1282
+ return [message];
1283
+ }
1284
+ __name(addError, "addError");
1285
+ var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
1286
+ function escapeRegExp(string2) {
1287
+ return string2.replace(ESCAPE_REGEX, "\\$&");
1288
+ }
1289
+ __name(escapeRegExp, "escapeRegExp");
1290
+ function handleError(message, config) {
1291
+ switch (config?.errorMode) {
1292
+ case "ignore":
1293
+ break;
1294
+ case "warn":
1295
+ console.warn(message);
1296
+ break;
1297
+ default:
1298
+ throw new Error(message);
1299
+ }
1300
+ }
1301
+ __name(handleError, "handleError");
1302
+ function isJsonConstValue(value) {
1303
+ return typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || typeof value === "string";
1304
+ }
1305
+ __name(isJsonConstValue, "isJsonConstValue");
1306
+ function isJsonEnumValues(values) {
1307
+ return values.every(isJsonConstValue);
1308
+ }
1309
+ __name(isJsonEnumValues, "isJsonEnumValues");
1310
+ var ReferenceMap = class extends Map {
1311
+ static {
1312
+ __name(this, "ReferenceMap");
1313
+ }
1314
+ /**
1315
+ * Creates an empty schema reference map.
1316
+ */
1317
+ constructor() {
1318
+ super();
1319
+ this.count = 0;
1320
+ this.usedIds = /* @__PURE__ */ new Set();
1321
+ }
1322
+ /**
1323
+ * Adds a schema reference and reserves its ID.
1324
+ *
1325
+ * @param schema The Valibot schema.
1326
+ * @param referenceId The reference ID.
1327
+ *
1328
+ * @returns The reference map.
1329
+ */
1330
+ set(schema, referenceId) {
1331
+ this.usedIds.add(referenceId);
1332
+ return super.set(schema, referenceId);
1333
+ }
1334
+ /**
1335
+ * Creates a reference ID that is not yet used.
1336
+ *
1337
+ * @param definitions The JSON Schema definitions.
1338
+ *
1339
+ * @returns The unused reference ID.
1340
+ */
1341
+ createId(definitions) {
1342
+ while (this.usedIds.has(`${this.count}`) || `${this.count}` in definitions) this.count++;
1343
+ return `${this.count++}`;
1344
+ }
1345
+ };
1346
+ function getLowerBound(current, value) {
1347
+ if (typeof current !== "number" || !Number.isFinite(current) || value > current) return value;
1348
+ return current;
1349
+ }
1350
+ __name(getLowerBound, "getLowerBound");
1351
+ function getUpperBound(current, value) {
1352
+ if (typeof current !== "number" || !Number.isFinite(current) || value < current) return value;
1353
+ return current;
1354
+ }
1355
+ __name(getUpperBound, "getUpperBound");
1356
+ // @__NO_SIDE_EFFECTS__
1357
+ function getNotRestriction(current, value) {
1358
+ return current !== void 0 ? { anyOf: [current, value] } : value;
1359
+ }
1360
+ __name(getNotRestriction, "getNotRestriction");
1361
+ function intersectEnum(jsonSchema, values) {
1362
+ let enumValues = jsonSchema.enum ?? values;
1363
+ if (jsonSchema.enum) {
1364
+ const valueSet = new Set(values);
1365
+ enumValues = enumValues.filter((value) => valueSet.has(value));
1366
+ }
1367
+ if (enumValues.length) jsonSchema.enum = [...new Set(enumValues)];
1368
+ else {
1369
+ delete jsonSchema.enum;
1370
+ jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, {});
1371
+ }
1372
+ }
1373
+ __name(intersectEnum, "intersectEnum");
1374
+ function convertAction(jsonSchema, valibotAction, config) {
1375
+ if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
1376
+ let errors;
1377
+ switch (valibotAction.type) {
1378
+ case "base64":
1379
+ jsonSchema.contentEncoding = "base64";
1380
+ break;
1381
+ case "bic":
1382
+ case "cuid2":
1383
+ case "decimal":
1384
+ case "digits":
1385
+ case "domain":
1386
+ case "emoji":
1387
+ case "hash":
1388
+ case "hexadecimal":
1389
+ case "hex_color":
1390
+ case "isrc":
1391
+ case "iso_time_second":
1392
+ case "iso_week":
1393
+ case "ksuid":
1394
+ case "mac":
1395
+ case "mac48":
1396
+ case "mac64":
1397
+ case "nanoid":
1398
+ case "octal":
1399
+ case "slug":
1400
+ case "ulid":
1401
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1402
+ else jsonSchema.pattern = valibotAction.requirement.source;
1403
+ break;
1404
+ case "description":
1405
+ jsonSchema.description = valibotAction.description;
1406
+ break;
1407
+ case "email":
1408
+ case "rfc_email":
1409
+ jsonSchema.format = "email";
1410
+ break;
1411
+ case "ends_with":
1412
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1413
+ else jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
1414
+ break;
1415
+ case "empty":
1416
+ if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
1417
+ else {
1418
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1419
+ jsonSchema.maxLength = 0;
1420
+ }
1421
+ break;
1422
+ case "entries":
1423
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1424
+ errors = addError(errors, 'The requirement of the "entries" action must be a non-negative integer.');
1425
+ break;
1426
+ }
1427
+ jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
1428
+ jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
1429
+ break;
1430
+ case "examples":
1431
+ if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples];
1432
+ else jsonSchema.examples = valibotAction.examples;
1433
+ break;
1434
+ case "gt_value":
1435
+ if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1436
+ errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
1437
+ break;
1438
+ }
1439
+ if (!Number.isFinite(valibotAction.requirement)) {
1440
+ errors = addError(errors, 'The requirement of the "gt_value" action is not JSON compatible.');
1441
+ break;
1442
+ }
1443
+ if (config?.target === "openapi-3.0") {
1444
+ errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
1445
+ break;
1446
+ }
1447
+ jsonSchema.exclusiveMinimum = getLowerBound(jsonSchema.exclusiveMinimum, valibotAction.requirement);
1448
+ break;
1449
+ case "includes":
1450
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1451
+ else jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
1452
+ break;
1453
+ case "integer":
1454
+ jsonSchema.type = "integer";
1455
+ break;
1456
+ case "ipv4":
1457
+ jsonSchema.format = "ipv4";
1458
+ break;
1459
+ case "ipv6":
1460
+ jsonSchema.format = "ipv6";
1461
+ break;
1462
+ case "iso_date":
1463
+ jsonSchema.format = "date";
1464
+ break;
1465
+ case "iso_date_time":
1466
+ case "iso_timestamp":
1467
+ jsonSchema.format = "date-time";
1468
+ break;
1469
+ case "iso_time":
1470
+ jsonSchema.format = "time";
1471
+ break;
1472
+ case "jws_compact":
1473
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1474
+ else jsonSchema.pattern = valibotAction.requirement.source;
1475
+ break;
1476
+ case "length":
1477
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1478
+ errors = addError(errors, 'The requirement of the "length" action must be a non-negative integer.');
1479
+ break;
1480
+ }
1481
+ if (jsonSchema.type === "array") {
1482
+ jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
1483
+ jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
1484
+ } else {
1485
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1486
+ jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
1487
+ jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
1488
+ }
1489
+ break;
1490
+ case "lt_value":
1491
+ if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1492
+ errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
1493
+ break;
1494
+ }
1495
+ if (!Number.isFinite(valibotAction.requirement)) {
1496
+ errors = addError(errors, 'The requirement of the "lt_value" action is not JSON compatible.');
1497
+ break;
1498
+ }
1499
+ if (config?.target === "openapi-3.0") {
1500
+ errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
1501
+ break;
1502
+ }
1503
+ jsonSchema.exclusiveMaximum = getUpperBound(jsonSchema.exclusiveMaximum, valibotAction.requirement);
1504
+ break;
1505
+ case "max_entries":
1506
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1507
+ errors = addError(errors, 'The requirement of the "max_entries" action must be a non-negative integer.');
1508
+ break;
1509
+ }
1510
+ jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
1511
+ break;
1512
+ case "max_length":
1513
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1514
+ errors = addError(errors, 'The requirement of the "max_length" action must be a non-negative integer.');
1515
+ break;
1516
+ }
1517
+ if (jsonSchema.type === "array") jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
1518
+ else {
1519
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1520
+ jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
1521
+ }
1522
+ break;
1523
+ case "max_value":
1524
+ if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1525
+ errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
1526
+ break;
1527
+ }
1528
+ if (!Number.isFinite(valibotAction.requirement)) {
1529
+ errors = addError(errors, 'The requirement of the "max_value" action is not JSON compatible.');
1530
+ break;
1531
+ }
1532
+ jsonSchema.maximum = getUpperBound(jsonSchema.maximum, valibotAction.requirement);
1533
+ break;
1534
+ case "metadata":
1535
+ if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
1536
+ if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
1537
+ if (Array.isArray(valibotAction.metadata.examples)) if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples];
1538
+ else jsonSchema.examples = valibotAction.metadata.examples;
1539
+ for (const key of Object.keys(valibotAction.metadata)) if (key !== "title" && key !== "description" && key !== "examples" && key !== "__proto__") jsonSchema[key] = valibotAction.metadata[key];
1540
+ break;
1541
+ case "min_entries":
1542
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1543
+ errors = addError(errors, 'The requirement of the "min_entries" action must be a non-negative integer.');
1544
+ break;
1545
+ }
1546
+ jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
1547
+ break;
1548
+ case "min_length":
1549
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1550
+ errors = addError(errors, 'The requirement of the "min_length" action must be a non-negative integer.');
1551
+ break;
1552
+ }
1553
+ if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
1554
+ else {
1555
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1556
+ jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
1557
+ }
1558
+ break;
1559
+ case "min_value":
1560
+ if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1561
+ errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
1562
+ break;
1563
+ }
1564
+ if (!Number.isFinite(valibotAction.requirement)) {
1565
+ errors = addError(errors, 'The requirement of the "min_value" action is not JSON compatible.');
1566
+ break;
1567
+ }
1568
+ jsonSchema.minimum = getLowerBound(jsonSchema.minimum, valibotAction.requirement);
1569
+ break;
1570
+ case "multiple_of":
1571
+ jsonSchema.multipleOf = valibotAction.requirement;
1572
+ break;
1573
+ case "non_empty":
1574
+ if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, 1);
1575
+ else {
1576
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1577
+ jsonSchema.minLength = getLowerBound(jsonSchema.minLength, 1);
1578
+ }
1579
+ break;
1580
+ case "not_value":
1581
+ if (!isJsonConstValue(valibotAction.requirement)) {
1582
+ errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
1583
+ break;
1584
+ }
1585
+ jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, config?.target === "openapi-3.0" ? { enum: [valibotAction.requirement] } : { const: valibotAction.requirement });
1586
+ break;
1587
+ case "not_values":
1588
+ if (!isJsonEnumValues(valibotAction.requirement)) {
1589
+ errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
1590
+ break;
1591
+ }
1592
+ if (valibotAction.requirement.length) jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, { enum: [...new Set(valibotAction.requirement)] });
1593
+ break;
1594
+ case "regex":
1595
+ if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
1596
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1597
+ else jsonSchema.pattern = valibotAction.requirement.source;
1598
+ break;
1599
+ case "safe_integer":
1600
+ jsonSchema.type = "integer";
1601
+ jsonSchema.minimum = getLowerBound(jsonSchema.minimum, Number.MIN_SAFE_INTEGER);
1602
+ jsonSchema.maximum = getUpperBound(jsonSchema.maximum, Number.MAX_SAFE_INTEGER);
1603
+ break;
1604
+ case "starts_with":
1605
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1606
+ else jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
1607
+ break;
1608
+ case "title":
1609
+ jsonSchema.title = valibotAction.title;
1610
+ break;
1611
+ case "url":
1612
+ jsonSchema.format = "uri";
1613
+ break;
1614
+ case "uuid":
1615
+ jsonSchema.format = "uuid";
1616
+ break;
1617
+ case "value":
1618
+ if (!isJsonConstValue(valibotAction.requirement)) {
1619
+ errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
1620
+ break;
1621
+ }
1622
+ if (config?.target === "openapi-3.0") intersectEnum(jsonSchema, [valibotAction.requirement]);
1623
+ 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.`);
1624
+ else jsonSchema.const = valibotAction.requirement;
1625
+ break;
1626
+ case "values":
1627
+ if (!isJsonEnumValues(valibotAction.requirement)) {
1628
+ errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
1629
+ break;
1630
+ }
1631
+ intersectEnum(jsonSchema, valibotAction.requirement);
1632
+ break;
1633
+ default:
1634
+ errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
1635
+ }
1636
+ if (config?.overrideAction) {
1637
+ const actionOverride = config.overrideAction({
1638
+ valibotAction,
1639
+ jsonSchema,
1640
+ errors
1641
+ });
1642
+ if (actionOverride) return { ...actionOverride };
1643
+ }
1644
+ if (errors) for (const message of errors) handleError(message, config);
1645
+ return jsonSchema;
1646
+ }
1647
+ __name(convertAction, "convertAction");
1648
+ function flattenPipe(pipe2) {
1649
+ return pipe2.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
1650
+ }
1651
+ __name(flattenPipe, "flattenPipe");
1652
+ function getDefinitionRef(referenceId) {
1653
+ return `#/$defs/${referenceId.replaceAll("~", "~0").replaceAll("/", "~1")}`;
1654
+ }
1655
+ __name(getDefinitionRef, "getDefinitionRef");
1656
+ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
1657
+ if (!skipRef) {
1658
+ const referenceId = context.referenceMap.get(valibotSchema);
1659
+ if (referenceId) {
1660
+ jsonSchema.$ref = getDefinitionRef(referenceId);
1661
+ if (config?.overrideRef) {
1662
+ const refOverride = config.overrideRef({
1663
+ ...context,
1664
+ referenceId,
1665
+ valibotSchema,
1666
+ jsonSchema
1667
+ });
1668
+ if (refOverride) jsonSchema.$ref = refOverride;
1669
+ }
1670
+ return jsonSchema;
1671
+ }
1672
+ }
1673
+ if ("pipe" in valibotSchema) {
1674
+ const flatPipe = flattenPipe(valibotSchema.pipe);
1675
+ let startIndex = 0;
1676
+ let stopIndex = flatPipe.length - 1;
1677
+ if (config?.typeMode === "input") {
1678
+ 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"));
1679
+ if (inputStopIndex !== -1) stopIndex = inputStopIndex;
1680
+ } else if (config?.typeMode === "output") {
1681
+ const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
1682
+ if (outputStartIndex !== -1) startIndex = outputStartIndex;
1683
+ }
1684
+ for (let index = startIndex; index <= stopIndex; index++) {
1685
+ const valibotPipeItem = flatPipe[index];
1686
+ if (valibotPipeItem.kind === "schema") {
1687
+ if (index > startIndex) handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config);
1688
+ jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
1689
+ } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
1690
+ }
1691
+ return jsonSchema;
1692
+ }
1693
+ let errors;
1694
+ switch (valibotSchema.type) {
1695
+ case "boolean":
1696
+ jsonSchema.type = "boolean";
1697
+ break;
1698
+ case "null":
1699
+ if (config?.target === "openapi-3.0") jsonSchema.enum = [null];
1700
+ else jsonSchema.type = "null";
1701
+ break;
1702
+ case "number":
1703
+ jsonSchema.type = "number";
1704
+ break;
1705
+ case "string":
1706
+ jsonSchema.type = "string";
1707
+ break;
1708
+ case "array":
1709
+ jsonSchema.type = "array";
1710
+ jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
1711
+ break;
1712
+ case "tuple":
1713
+ case "tuple_with_rest":
1714
+ case "loose_tuple":
1715
+ case "strict_tuple":
1716
+ jsonSchema.type = "array";
1717
+ if (config?.target === "openapi-3.0") {
1718
+ jsonSchema.items = { anyOf: [] };
1719
+ jsonSchema.minItems = valibotSchema.items.length;
1720
+ for (const item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
1721
+ if (valibotSchema.type === "tuple_with_rest") jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context));
1722
+ else if (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") jsonSchema.maxItems = valibotSchema.items.length;
1723
+ } else if (config?.target === "draft-2020-12") {
1724
+ jsonSchema.prefixItems = [];
1725
+ jsonSchema.minItems = valibotSchema.items.length;
1726
+ for (const item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
1727
+ if (valibotSchema.type === "tuple_with_rest") jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context);
1728
+ else if (valibotSchema.type === "strict_tuple") jsonSchema.items = false;
1729
+ } else {
1730
+ jsonSchema.items = [];
1731
+ jsonSchema.minItems = valibotSchema.items.length;
1732
+ for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
1733
+ if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
1734
+ else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
1735
+ }
1736
+ break;
1737
+ case "object":
1738
+ case "object_with_rest":
1739
+ case "loose_object":
1740
+ case "strict_object":
1741
+ jsonSchema.type = "object";
1742
+ jsonSchema.properties = {};
1743
+ jsonSchema.required = [];
1744
+ for (const key in valibotSchema.entries) {
1745
+ const entry = valibotSchema.entries[key];
1746
+ jsonSchema.properties[key] = convertSchema({}, entry, config, context);
1747
+ if (entry.type !== "exact_optional" && entry.type !== "nullish" && entry.type !== "optional") jsonSchema.required.push(key);
1748
+ }
1749
+ if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
1750
+ else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
1751
+ break;
1752
+ case "record":
1753
+ 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.');
1754
+ 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.`);
1755
+ jsonSchema.type = "object";
1756
+ if (config?.target !== "openapi-3.0") jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context);
1757
+ jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
1758
+ break;
1759
+ case "any":
1760
+ case "unknown":
1761
+ break;
1762
+ case "never":
1763
+ jsonSchema.not = {};
1764
+ break;
1765
+ case "nullable":
1766
+ case "nullish":
1767
+ if (config?.target === "openapi-3.0") {
1768
+ const innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
1769
+ Object.assign(jsonSchema, innerSchema);
1770
+ jsonSchema.nullable = true;
1771
+ } else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
1772
+ if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
1773
+ break;
1774
+ case "exact_optional":
1775
+ case "optional":
1776
+ case "undefinedable":
1777
+ jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
1778
+ if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
1779
+ break;
1780
+ case "literal":
1781
+ if (!isJsonConstValue(valibotSchema.literal)) {
1782
+ errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
1783
+ break;
1784
+ }
1785
+ if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotSchema.literal];
1786
+ else jsonSchema.const = valibotSchema.literal;
1787
+ break;
1788
+ case "enum":
1789
+ case "picklist": {
1790
+ const options = valibotSchema.options;
1791
+ if (!options.every((option) => typeof option === "string" || typeof option === "number" && Number.isFinite(option))) {
1792
+ errors = addError(errors, `An option of the "${valibotSchema.type}" schema is not JSON compatible.`);
1793
+ break;
1794
+ }
1795
+ jsonSchema.enum = options;
1796
+ if (options.every((option) => typeof option === "string")) jsonSchema.type = "string";
1797
+ else if (options.every((option) => typeof option === "number")) jsonSchema.type = "number";
1798
+ else if (config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
1799
+ break;
1800
+ }
1801
+ case "union":
1802
+ jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1803
+ break;
1804
+ case "variant":
1805
+ jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1806
+ break;
1807
+ case "intersect":
1808
+ jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1809
+ break;
1810
+ case "lazy": {
1811
+ let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
1812
+ if (!wrappedValibotSchema) {
1813
+ wrappedValibotSchema = valibotSchema.getter(void 0);
1814
+ context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
1815
+ }
1816
+ let referenceId = context.referenceMap.get(wrappedValibotSchema);
1817
+ if (!referenceId) {
1818
+ referenceId = context.referenceMap.createId(context.definitions);
1819
+ context.referenceMap.set(wrappedValibotSchema, referenceId);
1820
+ context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
1821
+ }
1822
+ jsonSchema.$ref = getDefinitionRef(referenceId);
1823
+ if (config?.overrideRef) {
1824
+ const refOverride = config.overrideRef({
1825
+ ...context,
1826
+ referenceId,
1827
+ valibotSchema: wrappedValibotSchema,
1828
+ jsonSchema
1829
+ });
1830
+ if (refOverride) jsonSchema.$ref = refOverride;
1831
+ }
1832
+ break;
1833
+ }
1834
+ default:
1835
+ errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
1836
+ }
1837
+ if (config?.overrideSchema) {
1838
+ const schemaOverride = config.overrideSchema({
1839
+ ...context,
1840
+ referenceId: context.referenceMap.get(valibotSchema),
1841
+ valibotSchema,
1842
+ jsonSchema,
1843
+ errors
1844
+ });
1845
+ if (schemaOverride) return { ...schemaOverride };
1846
+ }
1847
+ if (errors) for (const message of errors) handleError(message, config);
1848
+ return jsonSchema;
1849
+ }
1850
+ __name(convertSchema, "convertSchema");
1851
+ var store;
1852
+ function getGlobalDefs() {
1853
+ return store;
1854
+ }
1855
+ __name(getGlobalDefs, "getGlobalDefs");
1856
+ function toJsonSchema(schema, config) {
1857
+ const context = {
1858
+ definitions: {},
1859
+ referenceMap: new ReferenceMap(),
1860
+ getterMap: /* @__PURE__ */ new Map()
1861
+ };
1862
+ const definitions = config?.definitions ?? getGlobalDefs();
1863
+ if (definitions) {
1864
+ for (const key in definitions) context.referenceMap.set(definitions[key], key);
1865
+ for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
1866
+ }
1867
+ const jsonSchema = convertSchema({}, schema, config, context);
1868
+ const target = config?.target ?? "draft-07";
1869
+ if (target === "draft-2020-12") jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema";
1870
+ else if (target === "draft-07") jsonSchema.$schema = "http://json-schema.org/draft-07/schema#";
1871
+ if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
1872
+ return jsonSchema;
1873
+ }
1874
+ __name(toJsonSchema, "toJsonSchema");
1875
+ var SUPPORTED_TARGETS = [
1876
+ "draft-07",
1877
+ "draft-2020-12",
1878
+ "openapi-3.0"
1879
+ ];
1880
+ function toStandardJsonSchema(schema) {
1881
+ return { "~standard": {
1882
+ ...schema["~standard"],
1883
+ jsonSchema: {
1884
+ input(options) {
1885
+ if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
1886
+ typeMode: "input",
1887
+ target: options.target,
1888
+ ...options.libraryOptions
1889
+ });
1890
+ throw new Error(`Unsupported target: ${options.target}`);
1891
+ },
1892
+ output(options) {
1893
+ if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
1894
+ typeMode: "output",
1895
+ target: options.target,
1896
+ ...options.libraryOptions
1897
+ });
1898
+ throw new Error(`Unsupported target: ${options.target}`);
1899
+ }
1900
+ }
1901
+ } };
1902
+ }
1903
+ __name(toStandardJsonSchema, "toStandardJsonSchema");
1904
+
1905
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/registry.js
1906
+ var word = pipe(string(), regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "a lower-case word, words joined by -"));
1907
+ var SNAKE_CASE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
1908
+ var text = pipe(string(), regex(/\S/, "must not be empty"));
1909
+ var dottedId = pipe(string(), regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/, "dotted lower-case words, such as `page.next`"));
1910
+ var RegistryError = class extends Error {
1911
+ static {
1912
+ __name(this, "RegistryError");
1913
+ }
1914
+ registry;
1915
+ problems;
1916
+ constructor(registry, problems) {
1917
+ super(`${registry} registry: ${problems.join("; ")}`);
1918
+ this.registry = registry;
1919
+ this.problems = problems;
1920
+ this.name = "RegistryError";
1921
+ }
1922
+ };
1923
+ var issuesOf = /* @__PURE__ */ __name((issues) => issues.map((issue) => {
1924
+ const path = getDotPath(issue);
1925
+ return path ? `${path}: ${issue.message}` : issue.message;
1926
+ }), "issuesOf");
1927
+ var parseRegistry = /* @__PURE__ */ __name((registry, schema, input, check2 = () => []) => {
1928
+ const parsed = safeParse(schema, input);
1929
+ if (!parsed.success)
1930
+ throw new RegistryError(registry, issuesOf(parsed.issues));
1931
+ const problems = check2(parsed.output);
1932
+ if (problems.length > 0)
1933
+ throw new RegistryError(registry, problems);
1934
+ return parsed.output;
1935
+ }, "parseRegistry");
1936
+ var duplicates = /* @__PURE__ */ __name((values) => [...new Set(values.filter((value, index) => values.indexOf(value) !== index))].sort(), "duplicates");
1937
+ var jsonSchemaOf = /* @__PURE__ */ __name((schema, definitions) => toJsonSchema(schema, { target: "draft-2020-12", ...definitions ? { definitions } : {} }), "jsonSchemaOf");
1938
+ var PLACEHOLDER = /\{([a-z][a-z0-9]*(?:_[a-z0-9]+)*)\}/g;
1939
+ var placeholders = /* @__PURE__ */ __name((template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1] ?? ""), "placeholders");
1940
+ var fill = /* @__PURE__ */ __name((template, values) => template.replace(PLACEHOLDER, (_, name) => {
1941
+ const value = values[name];
1942
+ if (value === void 0)
1943
+ throw new Error(`no value for {${name}} in "${template}"`);
1944
+ return String(value);
1945
+ }), "fill");
1946
+
1947
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/output.js
1948
+ var MAX_NEXT_STEPS = 2;
1949
+ var COMPACT_FLAG = "--compact";
1950
+ var isoTime = pipe(string(), isoTimestamp("an ISO 8601 time in UTC"), endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"));
1951
+ var localTime = pipe(string(), regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2}$/, "an ISO 8601 time with its offset"));
1952
+ var reference = pipe(string(), regex(/^[a-z]+:\S+$/, "a reference such as `note:42`"));
1953
+ var nextStepSchema = variant("kind", [
1954
+ strictObject({
1955
+ kind: literal("command"),
1956
+ step: dottedId,
1957
+ /** The command path as one string, `messages list` — what the MCP router tools take as `command`. */
1958
+ command: text,
1959
+ args: record(string(), unknown()),
1960
+ /**
1961
+ * The whole line to type, with the tool and the profile it ran with: `tg personal mcp config`. Only the CLI
1962
+ * knows the profile, so it fills this; MCP answers leave it out.
1963
+ */
1964
+ line: optional(text),
1965
+ why: text,
1966
+ /** True only when the target command is known to write nothing, here or at the provider. */
1967
+ safe_to_auto_execute: boolean()
1968
+ }),
1969
+ /** Something only the person can do — sign in on the phone, approve a device. */
1970
+ strictObject({
1971
+ kind: literal("user_action"),
1972
+ step: dottedId,
1973
+ why: text,
1974
+ safe_to_auto_execute: literal(false)
1975
+ })
1976
+ ]);
1977
+ var missingSchema = strictObject({
1978
+ field: text,
1979
+ why: text,
1980
+ /** Left out when there is nothing to run that would fill the field. */
1981
+ step: optional(dottedId)
1982
+ });
1983
+ var limit = pipe(number(), integer(), minValue(1));
1984
+ var totalSchema = strictObject({
1985
+ value: pipe(number(), integer(), minValue(0)),
1986
+ relation: picklist(["eq", "gte"])
1987
+ });
1988
+ var pageSchema = variant("mode", [
1989
+ strictObject({
1990
+ mode: literal("page"),
1991
+ limit,
1992
+ has_more: boolean(),
1993
+ next_page: optional(pipe(number(), integer(), minValue(2))),
1994
+ total: optional(totalSchema)
1995
+ }),
1996
+ strictObject({
1997
+ mode: literal("cursor"),
1998
+ limit,
1999
+ has_more: boolean(),
2000
+ next_cursor: optional(text),
2001
+ total: optional(totalSchema)
2002
+ })
2003
+ ]);
2004
+ var issueSchema = strictObject({
2005
+ code: picklist(errorCodes),
2006
+ reason: optional(dottedId),
2007
+ /** The account, provider or source that is missing from the answer. */
2008
+ source: text
2009
+ });
2010
+ var metaSchema = strictObject({
2011
+ run_id: text,
2012
+ duration_ms: pipe(number(), integer(), minValue(0)),
2013
+ accounts: optional(array(text)),
2014
+ complete: boolean(),
2015
+ issues: optional(array(issueSchema)),
2016
+ truncated: optional(boolean()),
2017
+ timezone: optional(text),
2018
+ /** When the command answered, for an agent that plans from "now" (WC-TIME-7); `timezone` names the zone of `now_local`. */
2019
+ now: optional(isoTime),
2020
+ now_local: optional(localTime),
2021
+ window: optional(strictObject({ since: optional(isoTime), until: optional(isoTime) }))
2022
+ });
2023
+ var nextSteps = optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS)));
2024
+ var listEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
2025
+ items: array(item),
2026
+ page: pageSchema,
2027
+ next: nextSteps,
2028
+ missing: optional(array(missingSchema)),
2029
+ meta: metaSchema
2030
+ }), "listEnvelopeSchema");
2031
+ var itemEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
2032
+ item,
2033
+ next: nextSteps,
2034
+ missing: optional(array(missingSchema)),
2035
+ meta: metaSchema
2036
+ }), "itemEnvelopeSchema");
2037
+ var jsonlEndSchema = strictObject({
2038
+ type: literal("end"),
2039
+ complete: boolean(),
2040
+ issues: optional(array(issueSchema)),
2041
+ page: pageSchema
2042
+ });
2043
+ var jsonlOf = /* @__PURE__ */ __name(({ items, page, meta }) => [
2044
+ ...items.map((data) => JSON.stringify({ type: "item", data })),
2045
+ JSON.stringify({ type: "end", complete: meta.complete, ...meta.issues ? { issues: meta.issues } : {}, page })
2046
+ ].join("\n"), "jsonlOf");
2047
+
2048
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/errors.js
2049
+ var CRASH_CODE = "internal_error";
2050
+ var CRASH_REASON = "command.crashed";
2051
+ var errorObjectSchema = strictObject({
2052
+ error: strictObject({
2053
+ code: picklist([...errorCodes, CRASH_CODE]),
2054
+ reason: dottedId,
2055
+ message: text,
2056
+ /** The option or argument at fault. */
2057
+ param: optional(text),
2058
+ details: optional(record(string(), unknown())),
2059
+ next: optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS))),
2060
+ /** Whether running the same command again may work and cannot do harm; never for a write that may have landed. */
2061
+ retry: strictObject({
2062
+ safe: boolean(),
2063
+ after_ms: optional(pipe(number(), integer(), minValue(0)))
2064
+ }),
2065
+ /** Optional until every CLI keeps a run for each failure. */
2066
+ run_id: optional(text)
2067
+ })
2068
+ });
2069
+ var reasonSchema = strictObject({
2070
+ reason: dottedId,
2071
+ code: picklist([...errorCodes, CRASH_CODE]),
2072
+ /** `{name}` placeholders, each one of `details`. */
2073
+ message: pipe(text, maxLength(120)),
2074
+ details: array(pipe(string(), regex(SNAKE_CASE, "a snake_case key"))),
2075
+ step: optional(dottedId)
2076
+ });
2077
+ var defineReasons = /* @__PURE__ */ __name((input) => parseRegistry("error reasons", array(reasonSchema), input, (reasons) => [
2078
+ ...duplicates(reasons.map((entry) => entry.reason)).map((reason) => `"${reason}" is listed twice`),
2079
+ ...reasons.flatMap((entry) => placeholders(entry.message).filter((name) => !entry.details.includes(name)).map((name) => `${entry.reason}: the message names {${name}}, which is not one of its details`))
2080
+ ]), "defineReasons");
2081
+ var COMMON_DETAILS = ["attempts", "status", "request_id", "operation", "operation_id"];
2082
+ var BASE_REASONS = defineReasons([
2083
+ { reason: "input.invalid", code: "validation_error", message: "the input is not valid", details: [] },
2084
+ {
2085
+ reason: "batch.read-budget",
2086
+ code: "validation_error",
2087
+ message: "batch stored-text read budget exhausted",
2088
+ details: []
2089
+ },
2090
+ { reason: "batch.output-budget", code: "validation_error", message: "batch output budget exhausted", details: [] },
2091
+ { reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
2092
+ { reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
2093
+ { reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
2094
+ { reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
2095
+ {
2096
+ reason: "tool.not-installed",
2097
+ code: "not_found",
2098
+ message: "no wcat-<name> program by that name is on PATH",
2099
+ details: ["tool", "installed"]
2100
+ },
2101
+ {
2102
+ reason: "confirmation.required",
2103
+ code: "confirmation_required",
2104
+ message: "this changes something; confirm it",
2105
+ details: []
2106
+ },
2107
+ { reason: "provider.rate-limited", code: "rate_limited", message: "too many requests; wait", details: [] },
2108
+ { reason: "command.timed-out", code: "timeout", message: "the command took too long", details: ["timeout_ms"] },
2109
+ { reason: "network.failed", code: "network_error", message: "the network did not answer", details: [] },
2110
+ { reason: "provider.refused", code: "provider_error", message: "the provider refused", details: [] },
2111
+ { reason: "provider.unavailable", code: "provider_unavailable", message: "the provider is down", details: [] },
2112
+ {
2113
+ reason: "provider.invalid-response",
2114
+ code: "invalid_response",
2115
+ message: "the answer could not be read",
2116
+ details: []
2117
+ },
2118
+ {
2119
+ reason: "output.too-large",
2120
+ code: "invalid_response",
2121
+ message: "the output is over {max_bytes} bytes",
2122
+ details: ["max_bytes", "buffered_bytes", "partial_output"]
2123
+ },
2124
+ {
2125
+ reason: "output.fields-unavailable",
2126
+ code: "invalid_response",
2127
+ message: "fields can be picked only from whole JSON values",
2128
+ details: []
2129
+ },
2130
+ { reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
2131
+ { reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
2132
+ { reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] }
2133
+ ]);
2134
+
2135
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/steps.js
2136
+ var SAME_COMMAND = "*";
2137
+ var commandPath = pipe(string(), regex(/^[a-z][a-z0-9-]*( [a-z][a-z0-9-]*)*$/, "a command path such as `messages sync`"));
2138
+ var stepSchema = union([
2139
+ strictObject({
2140
+ id: dottedId,
2141
+ kind: optional(literal("command"), "command"),
2142
+ command: union([literal(SAME_COMMAND), commandPath]),
2143
+ args: array(strictObject({
2144
+ name: pipe(string(), regex(SNAKE_CASE, "an argument or option name in snake_case")),
2145
+ required: boolean()
2146
+ })),
2147
+ why: pipe(text, maxLength(120))
2148
+ }),
2149
+ strictObject({ id: dottedId, kind: literal("user_action"), why: pipe(text, maxLength(120)) })
2150
+ ]);
2151
+ var argsOf = /* @__PURE__ */ __name((step) => step.kind === "command" ? step.args : [], "argsOf");
2152
+ var defineSteps = /* @__PURE__ */ __name((input) => parseRegistry("steps", array(stepSchema), input, (steps) => [
2153
+ ...duplicates(steps.map((step) => step.id)).map((id) => `"${id}" is listed twice`),
2154
+ ...steps.flatMap((step) => duplicates(argsOf(step).map((arg) => arg.name)).map((name) => `${step.id}: argument "${name}" is listed twice`))
2155
+ ]), "defineSteps");
2156
+ var BINDS = /^[^\p{Cc}\u2028\u2029]*$/u;
2157
+ var binds = /* @__PURE__ */ __name((value) => typeof value === "number" || typeof value === "boolean" || typeof value === "string" && BINDS.test(value), "binds");
2158
+ var stepOf = /* @__PURE__ */ __name((definition, input = {}) => {
2159
+ const args = input.args ?? {};
2160
+ if (definition.kind === "user_action")
2161
+ return {
2162
+ kind: "user_action",
2163
+ step: definition.id,
2164
+ why: fill(definition.why, { ...input.values }),
2165
+ safe_to_auto_execute: false
2166
+ };
2167
+ const command = definition.command === SAME_COMMAND ? input.command : definition.command;
2168
+ if (!command)
2169
+ throw new Error(`${definition.id}: the step runs the same command, so pass the command`);
2170
+ const known = new Set(definition.args.map((arg) => arg.name));
2171
+ if (definition.command !== SAME_COMMAND) {
2172
+ for (const name of Object.keys(args))
2173
+ if (!known.has(name))
2174
+ throw new Error(`${definition.id}: no argument "${name}"`);
2175
+ }
2176
+ for (const arg of definition.args)
2177
+ if (arg.required && args[arg.name] === void 0)
2178
+ throw new Error(`${definition.id}: argument "${arg.name}" is required`);
2179
+ for (const [name, value] of Object.entries(args))
2180
+ if (!(Array.isArray(value) ? value.every(binds) : binds(value)))
2181
+ throw new Error(`${definition.id}: "${name}" is not a value an option takes`);
2182
+ const target = input.targets?.(command);
2183
+ if (input.targets && !target)
2184
+ throw new Error(`${definition.id}: no command "${command}"`);
2185
+ const names = new Set(target?.names ?? []);
2186
+ if (target) {
2187
+ for (const name of Object.keys(args))
2188
+ if (!names.has(name))
2189
+ throw new Error(`${definition.id}: "${command}" takes no "${name}"`);
2190
+ }
2191
+ const scalars = Object.fromEntries(Object.entries(args).filter((entry) => ["string", "number"].includes(typeof entry[1])));
2192
+ return {
2193
+ kind: "command",
2194
+ step: definition.id,
2195
+ command,
2196
+ args: { ...args },
2197
+ why: fill(definition.why, { ...scalars, ...input.values }),
2198
+ safe_to_auto_execute: target?.effects !== void 0 && !writes(target.effects)
2199
+ };
2200
+ }, "stepOf");
2201
+ var STEPS = defineSteps([
2202
+ {
2203
+ id: "page.next",
2204
+ command: SAME_COMMAND,
2205
+ args: [
2206
+ { name: "cursor", required: false },
2207
+ { name: "page", required: false },
2208
+ { name: "limit", required: false }
2209
+ ],
2210
+ why: "{shown} shown, more exist"
2211
+ }
2212
+ ]);
2213
+
2214
+ // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/failure.js
2215
+ var recognise = /* @__PURE__ */ __name((failure) => {
2216
+ if (isCliError(failure))
2217
+ return failure;
2218
+ if (!(failure instanceof Error) || failure.name !== "CliError")
2219
+ return void 0;
2220
+ const { code, details } = failure;
2221
+ if (!errorCodes.includes(code))
2222
+ return void 0;
2223
+ return {
2224
+ code,
2225
+ message: failure.message,
2226
+ details: typeof details === "object" && details !== null ? details : {}
2227
+ };
2228
+ }, "recognise");
2229
+ var reasonFor = /* @__PURE__ */ __name((code, named, reasons) => reasons.find((entry) => entry.reason === named && entry.code === code) ?? BASE_REASONS.find((entry) => entry.reason === named && entry.code === code) ?? // The first base reason for each code is its fallback.
2230
+ BASE_REASONS.find((entry) => entry.code === code), "reasonFor");
2231
+ var nextFor = /* @__PURE__ */ __name((reason, details, context) => {
2232
+ const definition = reason.step ? context.steps?.find((step) => step.id === reason.step) : void 0;
2233
+ if (!definition)
2234
+ return [];
2235
+ const known = new Set(definition.kind === "command" ? definition.args.map((arg) => arg.name) : []);
2236
+ const args = Object.fromEntries(Object.entries(details).filter(([key, value]) => known.has(key) && value !== void 0));
2237
+ try {
2238
+ return [stepOf(definition, { args, ...context.targets ? { targets: context.targets } : {} })];
2239
+ } catch {
2240
+ return [];
2241
+ }
2242
+ }, "nextFor");
2243
+ var TRANSIENT = [
2244
+ "rate_limited",
2245
+ "timeout",
2246
+ "network_error",
2247
+ "provider_unavailable"
2248
+ ];
2249
+ var retryOf = /* @__PURE__ */ __name((code, details, effects) => {
2250
+ const transient = details.retryable !== false && (TRANSIENT.includes(code) || code === "provider_error" && details.retryable === true);
2251
+ const safe = code !== "outcome_unknown" && transient && (!writes(effects) || details.sent === false);
2252
+ const after = details.retry_after_ms;
2253
+ return safe && typeof after === "number" && Number.isInteger(after) && after >= 0 ? { safe, after_ms: after } : { safe };
2254
+ }, "retryOf");
2255
+ var errorObjectOf = /* @__PURE__ */ __name((failure, context = {}) => {
2256
+ const reasons = context.reasons ?? [];
2257
+ const recognised = recognise(failure);
2258
+ if (!recognised) {
2259
+ const reason2 = reasonFor(CRASH_CODE, CRASH_REASON, reasons);
2260
+ return {
2261
+ error: {
2262
+ code: CRASH_CODE,
2263
+ reason: reason2.reason,
2264
+ message: reason2.message,
2265
+ retry: { safe: false },
2266
+ ...context.runId ? { run_id: context.runId } : {}
2267
+ }
2268
+ };
2269
+ }
2270
+ const { code, message, details } = recognised;
2271
+ const reason = reasonFor(code, details.reason, reasons);
2272
+ const allowed = /* @__PURE__ */ new Set([...COMMON_DETAILS, ...context.details ?? [], ...reason.details]);
2273
+ allowed.delete("cause");
2274
+ const kept = Object.fromEntries(Object.entries(details).filter(([key, value]) => allowed.has(key) && value !== void 0));
2275
+ const next = nextFor(reason, details, context);
2276
+ const runId = context.runId ?? (typeof details.run_id === "string" ? details.run_id : void 0);
2277
+ return {
2278
+ error: {
2279
+ code,
2280
+ reason: reason.reason,
2281
+ message,
2282
+ ...typeof details.param === "string" ? { param: details.param } : {},
2283
+ ...Object.keys(kept).length > 0 ? { details: kept } : {},
2284
+ ...next.length > 0 ? { next } : {},
2285
+ retry: retryOf(code, details, context.effects),
2286
+ ...runId ? { run_id: runId } : {}
2287
+ }
2288
+ };
2289
+ }, "errorObjectOf");
2290
+ var exitCodeOfError = /* @__PURE__ */ __name(({ error }) => error.code === CRASH_CODE ? GENERIC_FAILURE : EXIT_CODES[error.code], "exitCodeOfError");
2291
+ var exitCodeOfAnswer = /* @__PURE__ */ __name((meta, partial2 = false) => {
2292
+ if (meta.complete || partial2)
2293
+ return 0;
2294
+ const code = meta.issues?.[0]?.code;
2295
+ return code === void 0 ? GENERIC_FAILURE : EXIT_CODES[code];
2296
+ }, "exitCodeOfAnswer");
2297
+ var kebab = /* @__PURE__ */ __name((name) => name.replaceAll("_", "-"), "kebab");
2298
+ var commandLine = /* @__PURE__ */ __name((cli, step) => [
2299
+ cli,
2300
+ step.command,
2301
+ ...Object.entries(step.args).map(([name, value]) => value === true ? `--${kebab(name)}` : `--${kebab(name)} ${JSON.stringify(value)}`)
2302
+ ].join(" "), "commandLine");
2303
+ var STACK_FRAMES = 10;
2304
+ var errorRecordOf = /* @__PURE__ */ __name((failure, object2, options) => {
2305
+ const thrown = failure instanceof Error ? failure : void 0;
2306
+ const { cause, ...details } = recognise(failure)?.details ?? {};
2307
+ const stack = thrown?.stack?.split("\n").slice(1, STACK_FRAMES + 1).map((line) => visibleControls(line.trim()));
2308
+ const reason = thrown?.cause ?? cause;
2309
+ return {
2310
+ time: (options.time ?? /* @__PURE__ */ new Date()).toISOString(),
2311
+ severity: "error",
2312
+ body: "command.failed",
2313
+ ...object2.error.run_id ? { run_id: object2.error.run_id } : {},
2314
+ command: options.command,
2315
+ attributes: {
2316
+ code: object2.error.code,
2317
+ reason: object2.error.reason,
2318
+ message: object2.error.message,
2319
+ ...Object.keys(details).length > 0 ? { details } : {},
2320
+ ...thrown ? { name: thrown.name, thrown_message: visibleControls(thrown.message) } : { thrown: String(failure) },
2321
+ ...reason === void 0 ? {} : { cause: visibleControls(reason instanceof Error ? reason.message : String(reason)) },
2322
+ ...stack && stack.length > 0 ? { stack } : {}
2323
+ },
2324
+ resource: { service: options.service, version: options.version }
2325
+ };
2326
+ }, "errorRecordOf");
2327
+ var renderError = /* @__PURE__ */ __name((object2, options) => {
2328
+ if (!options.interactive)
2329
+ return [JSON.stringify(object2), ...options.record ? [JSON.stringify(options.record)] : []].join("\n");
2330
+ const { message, next, run_id: runId } = object2.error;
2331
+ const step = next?.[0];
2332
+ return [
2333
+ `\u2717 ${visibleControls(message)}`,
2334
+ ...step?.kind === "command" ? [`\u2192 ${visibleControls(step.why)}: ${visibleControls(step.line ?? commandLine(options.cli, step))}`] : step ? [`\u2192 ${visibleControls(step.why)}`] : [],
2335
+ ...options.record ? [JSON.stringify(options.record, null, 2)] : runId ? [`details: ${options.cli} runs show ${runId}`] : []
2336
+ ].join("\n");
2337
+ }, "renderError");
2338
+ var mcpErrorResult = /* @__PURE__ */ __name((object2) => ({
2339
+ content: [{ type: "text", text: JSON.stringify(object2) }],
2340
+ structuredContent: object2,
2341
+ isError: true
2342
+ }), "mcpErrorResult");
2343
+ var catchCrashes = /* @__PURE__ */ __name((options) => {
2344
+ const target = options.target ?? process;
2345
+ const write = options.write ?? ((text2) => process.stderr.write(`${text2}
2346
+ `));
2347
+ const exit = options.exit ?? ((code) => process.exit(code));
2348
+ const crashed = /* @__PURE__ */ __name((failure) => {
2349
+ const object2 = errorObjectOf(failure, options);
2350
+ write(renderError(object2, { cli: options.cli, interactive: options.interactive }));
2351
+ exit(exitCodeOfError(object2));
2352
+ }, "crashed");
2353
+ target.on("uncaughtException", crashed);
2354
+ target.on("unhandledRejection", crashed);
2355
+ return () => {
2356
+ target.off("uncaughtException", crashed);
2357
+ target.off("unhandledRejection", crashed);
2358
+ };
2359
+ }, "catchCrashes");
2360
+
2361
+ export {
2362
+ EXIT_CODES,
2363
+ exitCodeFor,
2364
+ GENERIC_FAILURE,
2365
+ getDotPath,
2366
+ check,
2367
+ description,
2368
+ finite,
2369
+ integer,
2370
+ isoDate,
2371
+ isoTimestamp,
2372
+ maxLength,
2373
+ maxValue,
2374
+ minLength,
2375
+ minValue,
2376
+ nonEmpty,
2377
+ regex,
2378
+ safeInteger,
2379
+ transform,
2380
+ trim,
2381
+ forward,
2382
+ array,
2383
+ boolean,
2384
+ custom,
2385
+ lazy,
2386
+ literal,
2387
+ looseObject,
2388
+ null_,
2389
+ nullable,
2390
+ number,
2391
+ object,
2392
+ objectWithRest,
2393
+ optional,
2394
+ picklist,
2395
+ record,
2396
+ strictObject,
2397
+ string,
2398
+ union,
2399
+ unknown,
2400
+ variant,
2401
+ omit,
2402
+ parse,
2403
+ partial,
2404
+ pick,
2405
+ pipe,
2406
+ safeParse,
2407
+ summarize,
2408
+ unwrap,
2409
+ effectsSchema,
2410
+ writes,
2411
+ toJsonSchema,
2412
+ toStandardJsonSchema,
2413
+ word,
2414
+ SNAKE_CASE,
2415
+ text,
2416
+ dottedId,
2417
+ RegistryError,
2418
+ parseRegistry,
2419
+ duplicates,
2420
+ jsonSchemaOf,
2421
+ MAX_NEXT_STEPS,
2422
+ COMPACT_FLAG,
2423
+ isoTime,
2424
+ reference,
2425
+ pageSchema,
2426
+ listEnvelopeSchema,
2427
+ itemEnvelopeSchema,
2428
+ jsonlOf,
2429
+ CRASH_CODE,
2430
+ errorObjectSchema,
2431
+ defineReasons,
2432
+ defineSteps,
2433
+ stepOf,
2434
+ STEPS,
2435
+ retryOf,
2436
+ errorObjectOf,
2437
+ exitCodeOfError,
2438
+ exitCodeOfAnswer,
2439
+ errorRecordOf,
2440
+ renderError,
2441
+ mcpErrorResult,
2442
+ catchCrashes
2443
+ };