@sjawhar/opencode-legion-envoy 0.9.0 → 0.11.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.
@@ -1,4889 +0,0 @@
1
- #!/usr/bin/env bun
2
- // @bun
3
-
4
- // ../envoy-client/src/dispatch-mcp-shim.ts
5
- import * as readline from "readline";
6
-
7
- // ../envoy-client/src/dispatch-config.ts
8
- import { readFileSync } from "fs";
9
- import { homedir } from "os";
10
- import * as path from "path";
11
-
12
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
13
- var NEVER = Object.freeze({
14
- status: "aborted"
15
- });
16
- function $constructor(name, initializer, params) {
17
- function init(inst, def) {
18
- if (!inst._zod) {
19
- Object.defineProperty(inst, "_zod", {
20
- value: {
21
- def,
22
- constr: _,
23
- traits: new Set
24
- },
25
- enumerable: false
26
- });
27
- }
28
- if (inst._zod.traits.has(name)) {
29
- return;
30
- }
31
- inst._zod.traits.add(name);
32
- initializer(inst, def);
33
- const proto = _.prototype;
34
- const keys = Object.keys(proto);
35
- for (let i = 0;i < keys.length; i++) {
36
- const k = keys[i];
37
- if (!(k in inst)) {
38
- inst[k] = proto[k].bind(inst);
39
- }
40
- }
41
- }
42
- const Parent = params?.Parent ?? Object;
43
-
44
- class Definition extends Parent {
45
- }
46
- Object.defineProperty(Definition, "name", { value: name });
47
- function _(def) {
48
- var _a;
49
- const inst = params?.Parent ? new Definition : this;
50
- init(inst, def);
51
- (_a = inst._zod).deferred ?? (_a.deferred = []);
52
- for (const fn of inst._zod.deferred) {
53
- fn();
54
- }
55
- return inst;
56
- }
57
- Object.defineProperty(_, "init", { value: init });
58
- Object.defineProperty(_, Symbol.hasInstance, {
59
- value: (inst) => {
60
- if (params?.Parent && inst instanceof params.Parent)
61
- return true;
62
- return inst?._zod?.traits?.has(name);
63
- }
64
- });
65
- Object.defineProperty(_, "name", { value: name });
66
- return _;
67
- }
68
- var $brand = Symbol("zod_brand");
69
-
70
- class $ZodAsyncError extends Error {
71
- constructor() {
72
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
73
- }
74
- }
75
-
76
- class $ZodEncodeError extends Error {
77
- constructor(name) {
78
- super(`Encountered unidirectional transform during encode: ${name}`);
79
- this.name = "ZodEncodeError";
80
- }
81
- }
82
- var globalConfig = {};
83
- function config(newConfig) {
84
- if (newConfig)
85
- Object.assign(globalConfig, newConfig);
86
- return globalConfig;
87
- }
88
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/util.js
89
- function getEnumValues(entries) {
90
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
91
- const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
92
- return values;
93
- }
94
- function jsonStringifyReplacer(_, value) {
95
- if (typeof value === "bigint")
96
- return value.toString();
97
- return value;
98
- }
99
- function cached(getter) {
100
- const set = false;
101
- return {
102
- get value() {
103
- if (!set) {
104
- const value = getter();
105
- Object.defineProperty(this, "value", { value });
106
- return value;
107
- }
108
- throw new Error("cached value already set");
109
- }
110
- };
111
- }
112
- function nullish(input) {
113
- return input === null || input === undefined;
114
- }
115
- function cleanRegex(source) {
116
- const start = source.startsWith("^") ? 1 : 0;
117
- const end = source.endsWith("$") ? source.length - 1 : source.length;
118
- return source.slice(start, end);
119
- }
120
- function floatSafeRemainder(val, step) {
121
- const valDecCount = (val.toString().split(".")[1] || "").length;
122
- const stepString = step.toString();
123
- let stepDecCount = (stepString.split(".")[1] || "").length;
124
- if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
125
- const match = stepString.match(/\d?e-(\d?)/);
126
- if (match?.[1]) {
127
- stepDecCount = Number.parseInt(match[1]);
128
- }
129
- }
130
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
131
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
132
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
133
- return valInt % stepInt / 10 ** decCount;
134
- }
135
- var EVALUATING = Symbol("evaluating");
136
- function defineLazy(object, key, getter) {
137
- let value = undefined;
138
- Object.defineProperty(object, key, {
139
- get() {
140
- if (value === EVALUATING) {
141
- return;
142
- }
143
- if (value === undefined) {
144
- value = EVALUATING;
145
- value = getter();
146
- }
147
- return value;
148
- },
149
- set(v) {
150
- Object.defineProperty(object, key, {
151
- value: v
152
- });
153
- },
154
- configurable: true
155
- });
156
- }
157
- function assignProp(target, prop, value) {
158
- Object.defineProperty(target, prop, {
159
- value,
160
- writable: true,
161
- enumerable: true,
162
- configurable: true
163
- });
164
- }
165
- function mergeDefs(...defs) {
166
- const mergedDescriptors = {};
167
- for (const def of defs) {
168
- const descriptors = Object.getOwnPropertyDescriptors(def);
169
- Object.assign(mergedDescriptors, descriptors);
170
- }
171
- return Object.defineProperties({}, mergedDescriptors);
172
- }
173
- function esc(str) {
174
- return JSON.stringify(str);
175
- }
176
- function slugify(input) {
177
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
178
- }
179
- var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
180
- function isObject(data) {
181
- return typeof data === "object" && data !== null && !Array.isArray(data);
182
- }
183
- var allowsEval = cached(() => {
184
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
185
- return false;
186
- }
187
- try {
188
- const F = Function;
189
- new F("");
190
- return true;
191
- } catch (_) {
192
- return false;
193
- }
194
- });
195
- function isPlainObject(o) {
196
- if (isObject(o) === false)
197
- return false;
198
- const ctor = o.constructor;
199
- if (ctor === undefined)
200
- return true;
201
- if (typeof ctor !== "function")
202
- return true;
203
- const prot = ctor.prototype;
204
- if (isObject(prot) === false)
205
- return false;
206
- if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
207
- return false;
208
- }
209
- return true;
210
- }
211
- function shallowClone(o) {
212
- if (isPlainObject(o))
213
- return { ...o };
214
- if (Array.isArray(o))
215
- return [...o];
216
- return o;
217
- }
218
- var propertyKeyTypes = new Set(["string", "number", "symbol"]);
219
- var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
220
- function escapeRegex(str) {
221
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
222
- }
223
- function clone(inst, def, params) {
224
- const cl = new inst._zod.constr(def ?? inst._zod.def);
225
- if (!def || params?.parent)
226
- cl._zod.parent = inst;
227
- return cl;
228
- }
229
- function normalizeParams(_params) {
230
- const params = _params;
231
- if (!params)
232
- return {};
233
- if (typeof params === "string")
234
- return { error: () => params };
235
- if (params?.message !== undefined) {
236
- if (params?.error !== undefined)
237
- throw new Error("Cannot specify both `message` and `error` params");
238
- params.error = params.message;
239
- }
240
- delete params.message;
241
- if (typeof params.error === "string")
242
- return { ...params, error: () => params.error };
243
- return params;
244
- }
245
- function optionalKeys(shape) {
246
- return Object.keys(shape).filter((k) => {
247
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
248
- });
249
- }
250
- var NUMBER_FORMAT_RANGES = {
251
- safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
252
- int32: [-2147483648, 2147483647],
253
- uint32: [0, 4294967295],
254
- float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
255
- float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
256
- };
257
- function pick(schema, mask) {
258
- const currDef = schema._zod.def;
259
- const checks = currDef.checks;
260
- const hasChecks = checks && checks.length > 0;
261
- if (hasChecks) {
262
- throw new Error(".pick() cannot be used on object schemas containing refinements");
263
- }
264
- const def = mergeDefs(schema._zod.def, {
265
- get shape() {
266
- const newShape = {};
267
- for (const key in mask) {
268
- if (!(key in currDef.shape)) {
269
- throw new Error(`Unrecognized key: "${key}"`);
270
- }
271
- if (!mask[key])
272
- continue;
273
- newShape[key] = currDef.shape[key];
274
- }
275
- assignProp(this, "shape", newShape);
276
- return newShape;
277
- },
278
- checks: []
279
- });
280
- return clone(schema, def);
281
- }
282
- function omit(schema, mask) {
283
- const currDef = schema._zod.def;
284
- const checks = currDef.checks;
285
- const hasChecks = checks && checks.length > 0;
286
- if (hasChecks) {
287
- throw new Error(".omit() cannot be used on object schemas containing refinements");
288
- }
289
- const def = mergeDefs(schema._zod.def, {
290
- get shape() {
291
- const newShape = { ...schema._zod.def.shape };
292
- for (const key in mask) {
293
- if (!(key in currDef.shape)) {
294
- throw new Error(`Unrecognized key: "${key}"`);
295
- }
296
- if (!mask[key])
297
- continue;
298
- delete newShape[key];
299
- }
300
- assignProp(this, "shape", newShape);
301
- return newShape;
302
- },
303
- checks: []
304
- });
305
- return clone(schema, def);
306
- }
307
- function extend(schema, shape) {
308
- if (!isPlainObject(shape)) {
309
- throw new Error("Invalid input to extend: expected a plain object");
310
- }
311
- const checks = schema._zod.def.checks;
312
- const hasChecks = checks && checks.length > 0;
313
- if (hasChecks) {
314
- const existingShape = schema._zod.def.shape;
315
- for (const key in shape) {
316
- if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
317
- throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
318
- }
319
- }
320
- }
321
- const def = mergeDefs(schema._zod.def, {
322
- get shape() {
323
- const _shape = { ...schema._zod.def.shape, ...shape };
324
- assignProp(this, "shape", _shape);
325
- return _shape;
326
- }
327
- });
328
- return clone(schema, def);
329
- }
330
- function safeExtend(schema, shape) {
331
- if (!isPlainObject(shape)) {
332
- throw new Error("Invalid input to safeExtend: expected a plain object");
333
- }
334
- const def = mergeDefs(schema._zod.def, {
335
- get shape() {
336
- const _shape = { ...schema._zod.def.shape, ...shape };
337
- assignProp(this, "shape", _shape);
338
- return _shape;
339
- }
340
- });
341
- return clone(schema, def);
342
- }
343
- function merge(a, b) {
344
- const def = mergeDefs(a._zod.def, {
345
- get shape() {
346
- const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
347
- assignProp(this, "shape", _shape);
348
- return _shape;
349
- },
350
- get catchall() {
351
- return b._zod.def.catchall;
352
- },
353
- checks: []
354
- });
355
- return clone(a, def);
356
- }
357
- function partial(Class, schema, mask) {
358
- const currDef = schema._zod.def;
359
- const checks = currDef.checks;
360
- const hasChecks = checks && checks.length > 0;
361
- if (hasChecks) {
362
- throw new Error(".partial() cannot be used on object schemas containing refinements");
363
- }
364
- const def = mergeDefs(schema._zod.def, {
365
- get shape() {
366
- const oldShape = schema._zod.def.shape;
367
- const shape = { ...oldShape };
368
- if (mask) {
369
- for (const key in mask) {
370
- if (!(key in oldShape)) {
371
- throw new Error(`Unrecognized key: "${key}"`);
372
- }
373
- if (!mask[key])
374
- continue;
375
- shape[key] = Class ? new Class({
376
- type: "optional",
377
- innerType: oldShape[key]
378
- }) : oldShape[key];
379
- }
380
- } else {
381
- for (const key in oldShape) {
382
- shape[key] = Class ? new Class({
383
- type: "optional",
384
- innerType: oldShape[key]
385
- }) : oldShape[key];
386
- }
387
- }
388
- assignProp(this, "shape", shape);
389
- return shape;
390
- },
391
- checks: []
392
- });
393
- return clone(schema, def);
394
- }
395
- function required(Class, schema, mask) {
396
- const def = mergeDefs(schema._zod.def, {
397
- get shape() {
398
- const oldShape = schema._zod.def.shape;
399
- const shape = { ...oldShape };
400
- if (mask) {
401
- for (const key in mask) {
402
- if (!(key in shape)) {
403
- throw new Error(`Unrecognized key: "${key}"`);
404
- }
405
- if (!mask[key])
406
- continue;
407
- shape[key] = new Class({
408
- type: "nonoptional",
409
- innerType: oldShape[key]
410
- });
411
- }
412
- } else {
413
- for (const key in oldShape) {
414
- shape[key] = new Class({
415
- type: "nonoptional",
416
- innerType: oldShape[key]
417
- });
418
- }
419
- }
420
- assignProp(this, "shape", shape);
421
- return shape;
422
- }
423
- });
424
- return clone(schema, def);
425
- }
426
- function aborted(x, startIndex = 0) {
427
- if (x.aborted === true)
428
- return true;
429
- for (let i = startIndex;i < x.issues.length; i++) {
430
- if (x.issues[i]?.continue !== true) {
431
- return true;
432
- }
433
- }
434
- return false;
435
- }
436
- function prefixIssues(path, issues) {
437
- return issues.map((iss) => {
438
- var _a;
439
- (_a = iss).path ?? (_a.path = []);
440
- iss.path.unshift(path);
441
- return iss;
442
- });
443
- }
444
- function unwrapMessage(message) {
445
- return typeof message === "string" ? message : message?.message;
446
- }
447
- function finalizeIssue(iss, ctx, config) {
448
- const full = { ...iss, path: iss.path ?? [] };
449
- if (!iss.message) {
450
- const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
451
- full.message = message;
452
- }
453
- delete full.inst;
454
- delete full.continue;
455
- if (!ctx?.reportInput) {
456
- delete full.input;
457
- }
458
- return full;
459
- }
460
- function getLengthableOrigin(input) {
461
- if (Array.isArray(input))
462
- return "array";
463
- if (typeof input === "string")
464
- return "string";
465
- return "unknown";
466
- }
467
- function issue(...args) {
468
- const [iss, input, inst] = args;
469
- if (typeof iss === "string") {
470
- return {
471
- message: iss,
472
- code: "custom",
473
- input,
474
- inst
475
- };
476
- }
477
- return { ...iss };
478
- }
479
-
480
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/errors.js
481
- var initializer = (inst, def) => {
482
- inst.name = "$ZodError";
483
- Object.defineProperty(inst, "_zod", {
484
- value: inst._zod,
485
- enumerable: false
486
- });
487
- Object.defineProperty(inst, "issues", {
488
- value: def,
489
- enumerable: false
490
- });
491
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
492
- Object.defineProperty(inst, "toString", {
493
- value: () => inst.message,
494
- enumerable: false
495
- });
496
- };
497
- var $ZodError = $constructor("$ZodError", initializer);
498
- var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
499
- function flattenError(error, mapper = (issue) => issue.message) {
500
- const fieldErrors = {};
501
- const formErrors = [];
502
- for (const sub of error.issues) {
503
- if (sub.path.length > 0) {
504
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
505
- fieldErrors[sub.path[0]].push(mapper(sub));
506
- } else {
507
- formErrors.push(mapper(sub));
508
- }
509
- }
510
- return { formErrors, fieldErrors };
511
- }
512
- function formatError(error, mapper = (issue) => issue.message) {
513
- const fieldErrors = { _errors: [] };
514
- const processError = (error) => {
515
- for (const issue of error.issues) {
516
- if (issue.code === "invalid_union" && issue.errors.length) {
517
- issue.errors.map((issues) => processError({ issues }));
518
- } else if (issue.code === "invalid_key") {
519
- processError({ issues: issue.issues });
520
- } else if (issue.code === "invalid_element") {
521
- processError({ issues: issue.issues });
522
- } else if (issue.path.length === 0) {
523
- fieldErrors._errors.push(mapper(issue));
524
- } else {
525
- let curr = fieldErrors;
526
- let i = 0;
527
- while (i < issue.path.length) {
528
- const el = issue.path[i];
529
- const terminal = i === issue.path.length - 1;
530
- if (!terminal) {
531
- curr[el] = curr[el] || { _errors: [] };
532
- } else {
533
- curr[el] = curr[el] || { _errors: [] };
534
- curr[el]._errors.push(mapper(issue));
535
- }
536
- curr = curr[el];
537
- i++;
538
- }
539
- }
540
- }
541
- };
542
- processError(error);
543
- return fieldErrors;
544
- }
545
-
546
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/parse.js
547
- var _parse = (_Err) => (schema, value, _ctx, _params) => {
548
- const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
549
- const result = schema._zod.run({ value, issues: [] }, ctx);
550
- if (result instanceof Promise) {
551
- throw new $ZodAsyncError;
552
- }
553
- if (result.issues.length) {
554
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
555
- captureStackTrace(e, _params?.callee);
556
- throw e;
557
- }
558
- return result.value;
559
- };
560
- var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
561
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
562
- let result = schema._zod.run({ value, issues: [] }, ctx);
563
- if (result instanceof Promise)
564
- result = await result;
565
- if (result.issues.length) {
566
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
567
- captureStackTrace(e, params?.callee);
568
- throw e;
569
- }
570
- return result.value;
571
- };
572
- var _safeParse = (_Err) => (schema, value, _ctx) => {
573
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
574
- const result = schema._zod.run({ value, issues: [] }, ctx);
575
- if (result instanceof Promise) {
576
- throw new $ZodAsyncError;
577
- }
578
- return result.issues.length ? {
579
- success: false,
580
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
581
- } : { success: true, data: result.value };
582
- };
583
- var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
584
- var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
585
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
586
- let result = schema._zod.run({ value, issues: [] }, ctx);
587
- if (result instanceof Promise)
588
- result = await result;
589
- return result.issues.length ? {
590
- success: false,
591
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
592
- } : { success: true, data: result.value };
593
- };
594
- var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
595
- var _encode = (_Err) => (schema, value, _ctx) => {
596
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
597
- return _parse(_Err)(schema, value, ctx);
598
- };
599
- var _decode = (_Err) => (schema, value, _ctx) => {
600
- return _parse(_Err)(schema, value, _ctx);
601
- };
602
- var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
603
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
604
- return _parseAsync(_Err)(schema, value, ctx);
605
- };
606
- var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
607
- return _parseAsync(_Err)(schema, value, _ctx);
608
- };
609
- var _safeEncode = (_Err) => (schema, value, _ctx) => {
610
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
611
- return _safeParse(_Err)(schema, value, ctx);
612
- };
613
- var _safeDecode = (_Err) => (schema, value, _ctx) => {
614
- return _safeParse(_Err)(schema, value, _ctx);
615
- };
616
- var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
617
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
618
- return _safeParseAsync(_Err)(schema, value, ctx);
619
- };
620
- var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
621
- return _safeParseAsync(_Err)(schema, value, _ctx);
622
- };
623
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/regexes.js
624
- var cuid = /^[cC][^\s-]{8,}$/;
625
- var cuid2 = /^[0-9a-z]+$/;
626
- var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
627
- var xid = /^[0-9a-vA-V]{20}$/;
628
- var ksuid = /^[A-Za-z0-9]{27}$/;
629
- var nanoid = /^[a-zA-Z0-9_-]{21}$/;
630
- var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
631
- var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
632
- var uuid = (version) => {
633
- if (!version)
634
- return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
635
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
636
- };
637
- var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
638
- var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
639
- function emoji() {
640
- return new RegExp(_emoji, "u");
641
- }
642
- var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
643
- var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
644
- var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
645
- var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
646
- var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
647
- var base64url = /^[A-Za-z0-9_-]*$/;
648
- var e164 = /^\+[1-9]\d{6,14}$/;
649
- var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
650
- var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
651
- function timeSource(args) {
652
- const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
653
- const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
654
- return regex;
655
- }
656
- function time(args) {
657
- return new RegExp(`^${timeSource(args)}$`);
658
- }
659
- function datetime(args) {
660
- const time = timeSource({ precision: args.precision });
661
- const opts = ["Z"];
662
- if (args.local)
663
- opts.push("");
664
- if (args.offset)
665
- opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
666
- const timeRegex = `${time}(?:${opts.join("|")})`;
667
- return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
668
- }
669
- var string = (params) => {
670
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
671
- return new RegExp(`^${regex}$`);
672
- };
673
- var integer = /^-?\d+$/;
674
- var number = /^-?\d+(?:\.\d+)?$/;
675
- var boolean = /^(?:true|false)$/i;
676
- var lowercase = /^[^A-Z]*$/;
677
- var uppercase = /^[^a-z]*$/;
678
-
679
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/checks.js
680
- var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
681
- var _a;
682
- inst._zod ?? (inst._zod = {});
683
- inst._zod.def = def;
684
- (_a = inst._zod).onattach ?? (_a.onattach = []);
685
- });
686
- var numericOriginMap = {
687
- number: "number",
688
- bigint: "bigint",
689
- object: "date"
690
- };
691
- var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
692
- $ZodCheck.init(inst, def);
693
- const origin = numericOriginMap[typeof def.value];
694
- inst._zod.onattach.push((inst) => {
695
- const bag = inst._zod.bag;
696
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
697
- if (def.value < curr) {
698
- if (def.inclusive)
699
- bag.maximum = def.value;
700
- else
701
- bag.exclusiveMaximum = def.value;
702
- }
703
- });
704
- inst._zod.check = (payload) => {
705
- if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
706
- return;
707
- }
708
- payload.issues.push({
709
- origin,
710
- code: "too_big",
711
- maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
712
- input: payload.value,
713
- inclusive: def.inclusive,
714
- inst,
715
- continue: !def.abort
716
- });
717
- };
718
- });
719
- var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
720
- $ZodCheck.init(inst, def);
721
- const origin = numericOriginMap[typeof def.value];
722
- inst._zod.onattach.push((inst) => {
723
- const bag = inst._zod.bag;
724
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
725
- if (def.value > curr) {
726
- if (def.inclusive)
727
- bag.minimum = def.value;
728
- else
729
- bag.exclusiveMinimum = def.value;
730
- }
731
- });
732
- inst._zod.check = (payload) => {
733
- if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
734
- return;
735
- }
736
- payload.issues.push({
737
- origin,
738
- code: "too_small",
739
- minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
740
- input: payload.value,
741
- inclusive: def.inclusive,
742
- inst,
743
- continue: !def.abort
744
- });
745
- };
746
- });
747
- var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
748
- $ZodCheck.init(inst, def);
749
- inst._zod.onattach.push((inst) => {
750
- var _a;
751
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
752
- });
753
- inst._zod.check = (payload) => {
754
- if (typeof payload.value !== typeof def.value)
755
- throw new Error("Cannot mix number and bigint in multiple_of check.");
756
- const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
757
- if (isMultiple)
758
- return;
759
- payload.issues.push({
760
- origin: typeof payload.value,
761
- code: "not_multiple_of",
762
- divisor: def.value,
763
- input: payload.value,
764
- inst,
765
- continue: !def.abort
766
- });
767
- };
768
- });
769
- var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
770
- $ZodCheck.init(inst, def);
771
- def.format = def.format || "float64";
772
- const isInt = def.format?.includes("int");
773
- const origin = isInt ? "int" : "number";
774
- const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
775
- inst._zod.onattach.push((inst) => {
776
- const bag = inst._zod.bag;
777
- bag.format = def.format;
778
- bag.minimum = minimum;
779
- bag.maximum = maximum;
780
- if (isInt)
781
- bag.pattern = integer;
782
- });
783
- inst._zod.check = (payload) => {
784
- const input = payload.value;
785
- if (isInt) {
786
- if (!Number.isInteger(input)) {
787
- payload.issues.push({
788
- expected: origin,
789
- format: def.format,
790
- code: "invalid_type",
791
- continue: false,
792
- input,
793
- inst
794
- });
795
- return;
796
- }
797
- if (!Number.isSafeInteger(input)) {
798
- if (input > 0) {
799
- payload.issues.push({
800
- input,
801
- code: "too_big",
802
- maximum: Number.MAX_SAFE_INTEGER,
803
- note: "Integers must be within the safe integer range.",
804
- inst,
805
- origin,
806
- inclusive: true,
807
- continue: !def.abort
808
- });
809
- } else {
810
- payload.issues.push({
811
- input,
812
- code: "too_small",
813
- minimum: Number.MIN_SAFE_INTEGER,
814
- note: "Integers must be within the safe integer range.",
815
- inst,
816
- origin,
817
- inclusive: true,
818
- continue: !def.abort
819
- });
820
- }
821
- return;
822
- }
823
- }
824
- if (input < minimum) {
825
- payload.issues.push({
826
- origin: "number",
827
- input,
828
- code: "too_small",
829
- minimum,
830
- inclusive: true,
831
- inst,
832
- continue: !def.abort
833
- });
834
- }
835
- if (input > maximum) {
836
- payload.issues.push({
837
- origin: "number",
838
- input,
839
- code: "too_big",
840
- maximum,
841
- inclusive: true,
842
- inst,
843
- continue: !def.abort
844
- });
845
- }
846
- };
847
- });
848
- var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
849
- var _a;
850
- $ZodCheck.init(inst, def);
851
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
852
- const val = payload.value;
853
- return !nullish(val) && val.length !== undefined;
854
- });
855
- inst._zod.onattach.push((inst) => {
856
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
857
- if (def.maximum < curr)
858
- inst._zod.bag.maximum = def.maximum;
859
- });
860
- inst._zod.check = (payload) => {
861
- const input = payload.value;
862
- const length = input.length;
863
- if (length <= def.maximum)
864
- return;
865
- const origin = getLengthableOrigin(input);
866
- payload.issues.push({
867
- origin,
868
- code: "too_big",
869
- maximum: def.maximum,
870
- inclusive: true,
871
- input,
872
- inst,
873
- continue: !def.abort
874
- });
875
- };
876
- });
877
- var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
878
- var _a;
879
- $ZodCheck.init(inst, def);
880
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
881
- const val = payload.value;
882
- return !nullish(val) && val.length !== undefined;
883
- });
884
- inst._zod.onattach.push((inst) => {
885
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
886
- if (def.minimum > curr)
887
- inst._zod.bag.minimum = def.minimum;
888
- });
889
- inst._zod.check = (payload) => {
890
- const input = payload.value;
891
- const length = input.length;
892
- if (length >= def.minimum)
893
- return;
894
- const origin = getLengthableOrigin(input);
895
- payload.issues.push({
896
- origin,
897
- code: "too_small",
898
- minimum: def.minimum,
899
- inclusive: true,
900
- input,
901
- inst,
902
- continue: !def.abort
903
- });
904
- };
905
- });
906
- var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
907
- var _a;
908
- $ZodCheck.init(inst, def);
909
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
910
- const val = payload.value;
911
- return !nullish(val) && val.length !== undefined;
912
- });
913
- inst._zod.onattach.push((inst) => {
914
- const bag = inst._zod.bag;
915
- bag.minimum = def.length;
916
- bag.maximum = def.length;
917
- bag.length = def.length;
918
- });
919
- inst._zod.check = (payload) => {
920
- const input = payload.value;
921
- const length = input.length;
922
- if (length === def.length)
923
- return;
924
- const origin = getLengthableOrigin(input);
925
- const tooBig = length > def.length;
926
- payload.issues.push({
927
- origin,
928
- ...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
929
- inclusive: true,
930
- exact: true,
931
- input: payload.value,
932
- inst,
933
- continue: !def.abort
934
- });
935
- };
936
- });
937
- var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
938
- var _a, _b;
939
- $ZodCheck.init(inst, def);
940
- inst._zod.onattach.push((inst) => {
941
- const bag = inst._zod.bag;
942
- bag.format = def.format;
943
- if (def.pattern) {
944
- bag.patterns ?? (bag.patterns = new Set);
945
- bag.patterns.add(def.pattern);
946
- }
947
- });
948
- if (def.pattern)
949
- (_a = inst._zod).check ?? (_a.check = (payload) => {
950
- def.pattern.lastIndex = 0;
951
- if (def.pattern.test(payload.value))
952
- return;
953
- payload.issues.push({
954
- origin: "string",
955
- code: "invalid_format",
956
- format: def.format,
957
- input: payload.value,
958
- ...def.pattern ? { pattern: def.pattern.toString() } : {},
959
- inst,
960
- continue: !def.abort
961
- });
962
- });
963
- else
964
- (_b = inst._zod).check ?? (_b.check = () => {});
965
- });
966
- var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
967
- $ZodCheckStringFormat.init(inst, def);
968
- inst._zod.check = (payload) => {
969
- def.pattern.lastIndex = 0;
970
- if (def.pattern.test(payload.value))
971
- return;
972
- payload.issues.push({
973
- origin: "string",
974
- code: "invalid_format",
975
- format: "regex",
976
- input: payload.value,
977
- pattern: def.pattern.toString(),
978
- inst,
979
- continue: !def.abort
980
- });
981
- };
982
- });
983
- var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
984
- def.pattern ?? (def.pattern = lowercase);
985
- $ZodCheckStringFormat.init(inst, def);
986
- });
987
- var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
988
- def.pattern ?? (def.pattern = uppercase);
989
- $ZodCheckStringFormat.init(inst, def);
990
- });
991
- var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
992
- $ZodCheck.init(inst, def);
993
- const escapedRegex = escapeRegex(def.includes);
994
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
995
- def.pattern = pattern;
996
- inst._zod.onattach.push((inst) => {
997
- const bag = inst._zod.bag;
998
- bag.patterns ?? (bag.patterns = new Set);
999
- bag.patterns.add(pattern);
1000
- });
1001
- inst._zod.check = (payload) => {
1002
- if (payload.value.includes(def.includes, def.position))
1003
- return;
1004
- payload.issues.push({
1005
- origin: "string",
1006
- code: "invalid_format",
1007
- format: "includes",
1008
- includes: def.includes,
1009
- input: payload.value,
1010
- inst,
1011
- continue: !def.abort
1012
- });
1013
- };
1014
- });
1015
- var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
1016
- $ZodCheck.init(inst, def);
1017
- const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
1018
- def.pattern ?? (def.pattern = pattern);
1019
- inst._zod.onattach.push((inst) => {
1020
- const bag = inst._zod.bag;
1021
- bag.patterns ?? (bag.patterns = new Set);
1022
- bag.patterns.add(pattern);
1023
- });
1024
- inst._zod.check = (payload) => {
1025
- if (payload.value.startsWith(def.prefix))
1026
- return;
1027
- payload.issues.push({
1028
- origin: "string",
1029
- code: "invalid_format",
1030
- format: "starts_with",
1031
- prefix: def.prefix,
1032
- input: payload.value,
1033
- inst,
1034
- continue: !def.abort
1035
- });
1036
- };
1037
- });
1038
- var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
1039
- $ZodCheck.init(inst, def);
1040
- const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
1041
- def.pattern ?? (def.pattern = pattern);
1042
- inst._zod.onattach.push((inst) => {
1043
- const bag = inst._zod.bag;
1044
- bag.patterns ?? (bag.patterns = new Set);
1045
- bag.patterns.add(pattern);
1046
- });
1047
- inst._zod.check = (payload) => {
1048
- if (payload.value.endsWith(def.suffix))
1049
- return;
1050
- payload.issues.push({
1051
- origin: "string",
1052
- code: "invalid_format",
1053
- format: "ends_with",
1054
- suffix: def.suffix,
1055
- input: payload.value,
1056
- inst,
1057
- continue: !def.abort
1058
- });
1059
- };
1060
- });
1061
- var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
1062
- $ZodCheck.init(inst, def);
1063
- inst._zod.check = (payload) => {
1064
- payload.value = def.tx(payload.value);
1065
- };
1066
- });
1067
-
1068
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/doc.js
1069
- class Doc {
1070
- constructor(args = []) {
1071
- this.content = [];
1072
- this.indent = 0;
1073
- if (this)
1074
- this.args = args;
1075
- }
1076
- indented(fn) {
1077
- this.indent += 1;
1078
- fn(this);
1079
- this.indent -= 1;
1080
- }
1081
- write(arg) {
1082
- if (typeof arg === "function") {
1083
- arg(this, { execution: "sync" });
1084
- arg(this, { execution: "async" });
1085
- return;
1086
- }
1087
- const content = arg;
1088
- const lines = content.split(`
1089
- `).filter((x) => x);
1090
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
1091
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
1092
- for (const line of dedented) {
1093
- this.content.push(line);
1094
- }
1095
- }
1096
- compile() {
1097
- const F = Function;
1098
- const args = this?.args;
1099
- const content = this?.content ?? [``];
1100
- const lines = [...content.map((x) => ` ${x}`)];
1101
- return new F(...args, lines.join(`
1102
- `));
1103
- }
1104
- }
1105
-
1106
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/versions.js
1107
- var version = {
1108
- major: 4,
1109
- minor: 3,
1110
- patch: 6
1111
- };
1112
-
1113
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/schemas.js
1114
- var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1115
- var _a;
1116
- inst ?? (inst = {});
1117
- inst._zod.def = def;
1118
- inst._zod.bag = inst._zod.bag || {};
1119
- inst._zod.version = version;
1120
- const checks = [...inst._zod.def.checks ?? []];
1121
- if (inst._zod.traits.has("$ZodCheck")) {
1122
- checks.unshift(inst);
1123
- }
1124
- for (const ch of checks) {
1125
- for (const fn of ch._zod.onattach) {
1126
- fn(inst);
1127
- }
1128
- }
1129
- if (checks.length === 0) {
1130
- (_a = inst._zod).deferred ?? (_a.deferred = []);
1131
- inst._zod.deferred?.push(() => {
1132
- inst._zod.run = inst._zod.parse;
1133
- });
1134
- } else {
1135
- const runChecks = (payload, checks, ctx) => {
1136
- let isAborted = aborted(payload);
1137
- let asyncResult;
1138
- for (const ch of checks) {
1139
- if (ch._zod.def.when) {
1140
- const shouldRun = ch._zod.def.when(payload);
1141
- if (!shouldRun)
1142
- continue;
1143
- } else if (isAborted) {
1144
- continue;
1145
- }
1146
- const currLen = payload.issues.length;
1147
- const _ = ch._zod.check(payload);
1148
- if (_ instanceof Promise && ctx?.async === false) {
1149
- throw new $ZodAsyncError;
1150
- }
1151
- if (asyncResult || _ instanceof Promise) {
1152
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1153
- await _;
1154
- const nextLen = payload.issues.length;
1155
- if (nextLen === currLen)
1156
- return;
1157
- if (!isAborted)
1158
- isAborted = aborted(payload, currLen);
1159
- });
1160
- } else {
1161
- const nextLen = payload.issues.length;
1162
- if (nextLen === currLen)
1163
- continue;
1164
- if (!isAborted)
1165
- isAborted = aborted(payload, currLen);
1166
- }
1167
- }
1168
- if (asyncResult) {
1169
- return asyncResult.then(() => {
1170
- return payload;
1171
- });
1172
- }
1173
- return payload;
1174
- };
1175
- const handleCanaryResult = (canary, payload, ctx) => {
1176
- if (aborted(canary)) {
1177
- canary.aborted = true;
1178
- return canary;
1179
- }
1180
- const checkResult = runChecks(payload, checks, ctx);
1181
- if (checkResult instanceof Promise) {
1182
- if (ctx.async === false)
1183
- throw new $ZodAsyncError;
1184
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1185
- }
1186
- return inst._zod.parse(checkResult, ctx);
1187
- };
1188
- inst._zod.run = (payload, ctx) => {
1189
- if (ctx.skipChecks) {
1190
- return inst._zod.parse(payload, ctx);
1191
- }
1192
- if (ctx.direction === "backward") {
1193
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
1194
- if (canary instanceof Promise) {
1195
- return canary.then((canary) => {
1196
- return handleCanaryResult(canary, payload, ctx);
1197
- });
1198
- }
1199
- return handleCanaryResult(canary, payload, ctx);
1200
- }
1201
- const result = inst._zod.parse(payload, ctx);
1202
- if (result instanceof Promise) {
1203
- if (ctx.async === false)
1204
- throw new $ZodAsyncError;
1205
- return result.then((result) => runChecks(result, checks, ctx));
1206
- }
1207
- return runChecks(result, checks, ctx);
1208
- };
1209
- }
1210
- defineLazy(inst, "~standard", () => ({
1211
- validate: (value) => {
1212
- try {
1213
- const r = safeParse(inst, value);
1214
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1215
- } catch (_) {
1216
- return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1217
- }
1218
- },
1219
- vendor: "zod",
1220
- version: 1
1221
- }));
1222
- });
1223
- var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1224
- $ZodType.init(inst, def);
1225
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
1226
- inst._zod.parse = (payload, _) => {
1227
- if (def.coerce)
1228
- try {
1229
- payload.value = String(payload.value);
1230
- } catch (_) {}
1231
- if (typeof payload.value === "string")
1232
- return payload;
1233
- payload.issues.push({
1234
- expected: "string",
1235
- code: "invalid_type",
1236
- input: payload.value,
1237
- inst
1238
- });
1239
- return payload;
1240
- };
1241
- });
1242
- var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
1243
- $ZodCheckStringFormat.init(inst, def);
1244
- $ZodString.init(inst, def);
1245
- });
1246
- var $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
1247
- def.pattern ?? (def.pattern = guid);
1248
- $ZodStringFormat.init(inst, def);
1249
- });
1250
- var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
1251
- if (def.version) {
1252
- const versionMap = {
1253
- v1: 1,
1254
- v2: 2,
1255
- v3: 3,
1256
- v4: 4,
1257
- v5: 5,
1258
- v6: 6,
1259
- v7: 7,
1260
- v8: 8
1261
- };
1262
- const v = versionMap[def.version];
1263
- if (v === undefined)
1264
- throw new Error(`Invalid UUID version: "${def.version}"`);
1265
- def.pattern ?? (def.pattern = uuid(v));
1266
- } else
1267
- def.pattern ?? (def.pattern = uuid());
1268
- $ZodStringFormat.init(inst, def);
1269
- });
1270
- var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
1271
- def.pattern ?? (def.pattern = email);
1272
- $ZodStringFormat.init(inst, def);
1273
- });
1274
- var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1275
- $ZodStringFormat.init(inst, def);
1276
- inst._zod.check = (payload) => {
1277
- try {
1278
- const trimmed = payload.value.trim();
1279
- const url = new URL(trimmed);
1280
- if (def.hostname) {
1281
- def.hostname.lastIndex = 0;
1282
- if (!def.hostname.test(url.hostname)) {
1283
- payload.issues.push({
1284
- code: "invalid_format",
1285
- format: "url",
1286
- note: "Invalid hostname",
1287
- pattern: def.hostname.source,
1288
- input: payload.value,
1289
- inst,
1290
- continue: !def.abort
1291
- });
1292
- }
1293
- }
1294
- if (def.protocol) {
1295
- def.protocol.lastIndex = 0;
1296
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
1297
- payload.issues.push({
1298
- code: "invalid_format",
1299
- format: "url",
1300
- note: "Invalid protocol",
1301
- pattern: def.protocol.source,
1302
- input: payload.value,
1303
- inst,
1304
- continue: !def.abort
1305
- });
1306
- }
1307
- }
1308
- if (def.normalize) {
1309
- payload.value = url.href;
1310
- } else {
1311
- payload.value = trimmed;
1312
- }
1313
- return;
1314
- } catch (_) {
1315
- payload.issues.push({
1316
- code: "invalid_format",
1317
- format: "url",
1318
- input: payload.value,
1319
- inst,
1320
- continue: !def.abort
1321
- });
1322
- }
1323
- };
1324
- });
1325
- var $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
1326
- def.pattern ?? (def.pattern = emoji());
1327
- $ZodStringFormat.init(inst, def);
1328
- });
1329
- var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
1330
- def.pattern ?? (def.pattern = nanoid);
1331
- $ZodStringFormat.init(inst, def);
1332
- });
1333
- var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
1334
- def.pattern ?? (def.pattern = cuid);
1335
- $ZodStringFormat.init(inst, def);
1336
- });
1337
- var $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
1338
- def.pattern ?? (def.pattern = cuid2);
1339
- $ZodStringFormat.init(inst, def);
1340
- });
1341
- var $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
1342
- def.pattern ?? (def.pattern = ulid);
1343
- $ZodStringFormat.init(inst, def);
1344
- });
1345
- var $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
1346
- def.pattern ?? (def.pattern = xid);
1347
- $ZodStringFormat.init(inst, def);
1348
- });
1349
- var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
1350
- def.pattern ?? (def.pattern = ksuid);
1351
- $ZodStringFormat.init(inst, def);
1352
- });
1353
- var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1354
- def.pattern ?? (def.pattern = datetime(def));
1355
- $ZodStringFormat.init(inst, def);
1356
- });
1357
- var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1358
- def.pattern ?? (def.pattern = date);
1359
- $ZodStringFormat.init(inst, def);
1360
- });
1361
- var $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
1362
- def.pattern ?? (def.pattern = time(def));
1363
- $ZodStringFormat.init(inst, def);
1364
- });
1365
- var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
1366
- def.pattern ?? (def.pattern = duration);
1367
- $ZodStringFormat.init(inst, def);
1368
- });
1369
- var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1370
- def.pattern ?? (def.pattern = ipv4);
1371
- $ZodStringFormat.init(inst, def);
1372
- inst._zod.bag.format = `ipv4`;
1373
- });
1374
- var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1375
- def.pattern ?? (def.pattern = ipv6);
1376
- $ZodStringFormat.init(inst, def);
1377
- inst._zod.bag.format = `ipv6`;
1378
- inst._zod.check = (payload) => {
1379
- try {
1380
- new URL(`http://[${payload.value}]`);
1381
- } catch {
1382
- payload.issues.push({
1383
- code: "invalid_format",
1384
- format: "ipv6",
1385
- input: payload.value,
1386
- inst,
1387
- continue: !def.abort
1388
- });
1389
- }
1390
- };
1391
- });
1392
- var $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
1393
- def.pattern ?? (def.pattern = cidrv4);
1394
- $ZodStringFormat.init(inst, def);
1395
- });
1396
- var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1397
- def.pattern ?? (def.pattern = cidrv6);
1398
- $ZodStringFormat.init(inst, def);
1399
- inst._zod.check = (payload) => {
1400
- const parts = payload.value.split("/");
1401
- try {
1402
- if (parts.length !== 2)
1403
- throw new Error;
1404
- const [address, prefix] = parts;
1405
- if (!prefix)
1406
- throw new Error;
1407
- const prefixNum = Number(prefix);
1408
- if (`${prefixNum}` !== prefix)
1409
- throw new Error;
1410
- if (prefixNum < 0 || prefixNum > 128)
1411
- throw new Error;
1412
- new URL(`http://[${address}]`);
1413
- } catch {
1414
- payload.issues.push({
1415
- code: "invalid_format",
1416
- format: "cidrv6",
1417
- input: payload.value,
1418
- inst,
1419
- continue: !def.abort
1420
- });
1421
- }
1422
- };
1423
- });
1424
- function isValidBase64(data) {
1425
- if (data === "")
1426
- return true;
1427
- if (data.length % 4 !== 0)
1428
- return false;
1429
- try {
1430
- atob(data);
1431
- return true;
1432
- } catch {
1433
- return false;
1434
- }
1435
- }
1436
- var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1437
- def.pattern ?? (def.pattern = base64);
1438
- $ZodStringFormat.init(inst, def);
1439
- inst._zod.bag.contentEncoding = "base64";
1440
- inst._zod.check = (payload) => {
1441
- if (isValidBase64(payload.value))
1442
- return;
1443
- payload.issues.push({
1444
- code: "invalid_format",
1445
- format: "base64",
1446
- input: payload.value,
1447
- inst,
1448
- continue: !def.abort
1449
- });
1450
- };
1451
- });
1452
- function isValidBase64URL(data) {
1453
- if (!base64url.test(data))
1454
- return false;
1455
- const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1456
- const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
1457
- return isValidBase64(padded);
1458
- }
1459
- var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1460
- def.pattern ?? (def.pattern = base64url);
1461
- $ZodStringFormat.init(inst, def);
1462
- inst._zod.bag.contentEncoding = "base64url";
1463
- inst._zod.check = (payload) => {
1464
- if (isValidBase64URL(payload.value))
1465
- return;
1466
- payload.issues.push({
1467
- code: "invalid_format",
1468
- format: "base64url",
1469
- input: payload.value,
1470
- inst,
1471
- continue: !def.abort
1472
- });
1473
- };
1474
- });
1475
- var $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1476
- def.pattern ?? (def.pattern = e164);
1477
- $ZodStringFormat.init(inst, def);
1478
- });
1479
- function isValidJWT(token, algorithm = null) {
1480
- try {
1481
- const tokensParts = token.split(".");
1482
- if (tokensParts.length !== 3)
1483
- return false;
1484
- const [header] = tokensParts;
1485
- if (!header)
1486
- return false;
1487
- const parsedHeader = JSON.parse(atob(header));
1488
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
1489
- return false;
1490
- if (!parsedHeader.alg)
1491
- return false;
1492
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
1493
- return false;
1494
- return true;
1495
- } catch {
1496
- return false;
1497
- }
1498
- }
1499
- var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1500
- $ZodStringFormat.init(inst, def);
1501
- inst._zod.check = (payload) => {
1502
- if (isValidJWT(payload.value, def.alg))
1503
- return;
1504
- payload.issues.push({
1505
- code: "invalid_format",
1506
- format: "jwt",
1507
- input: payload.value,
1508
- inst,
1509
- continue: !def.abort
1510
- });
1511
- };
1512
- });
1513
- var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1514
- $ZodType.init(inst, def);
1515
- inst._zod.pattern = inst._zod.bag.pattern ?? number;
1516
- inst._zod.parse = (payload, _ctx) => {
1517
- if (def.coerce)
1518
- try {
1519
- payload.value = Number(payload.value);
1520
- } catch (_) {}
1521
- const input = payload.value;
1522
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
1523
- return payload;
1524
- }
1525
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : undefined : undefined;
1526
- payload.issues.push({
1527
- expected: "number",
1528
- code: "invalid_type",
1529
- input,
1530
- inst,
1531
- ...received ? { received } : {}
1532
- });
1533
- return payload;
1534
- };
1535
- });
1536
- var $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1537
- $ZodCheckNumberFormat.init(inst, def);
1538
- $ZodNumber.init(inst, def);
1539
- });
1540
- var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
1541
- $ZodType.init(inst, def);
1542
- inst._zod.pattern = boolean;
1543
- inst._zod.parse = (payload, _ctx) => {
1544
- if (def.coerce)
1545
- try {
1546
- payload.value = Boolean(payload.value);
1547
- } catch (_) {}
1548
- const input = payload.value;
1549
- if (typeof input === "boolean")
1550
- return payload;
1551
- payload.issues.push({
1552
- expected: "boolean",
1553
- code: "invalid_type",
1554
- input,
1555
- inst
1556
- });
1557
- return payload;
1558
- };
1559
- });
1560
- var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1561
- $ZodType.init(inst, def);
1562
- inst._zod.parse = (payload) => payload;
1563
- });
1564
- var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1565
- $ZodType.init(inst, def);
1566
- inst._zod.parse = (payload, _ctx) => {
1567
- payload.issues.push({
1568
- expected: "never",
1569
- code: "invalid_type",
1570
- input: payload.value,
1571
- inst
1572
- });
1573
- return payload;
1574
- };
1575
- });
1576
- function handleArrayResult(result, final, index) {
1577
- if (result.issues.length) {
1578
- final.issues.push(...prefixIssues(index, result.issues));
1579
- }
1580
- final.value[index] = result.value;
1581
- }
1582
- var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1583
- $ZodType.init(inst, def);
1584
- inst._zod.parse = (payload, ctx) => {
1585
- const input = payload.value;
1586
- if (!Array.isArray(input)) {
1587
- payload.issues.push({
1588
- expected: "array",
1589
- code: "invalid_type",
1590
- input,
1591
- inst
1592
- });
1593
- return payload;
1594
- }
1595
- payload.value = Array(input.length);
1596
- const proms = [];
1597
- for (let i = 0;i < input.length; i++) {
1598
- const item = input[i];
1599
- const result = def.element._zod.run({
1600
- value: item,
1601
- issues: []
1602
- }, ctx);
1603
- if (result instanceof Promise) {
1604
- proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1605
- } else {
1606
- handleArrayResult(result, payload, i);
1607
- }
1608
- }
1609
- if (proms.length) {
1610
- return Promise.all(proms).then(() => payload);
1611
- }
1612
- return payload;
1613
- };
1614
- });
1615
- function handlePropertyResult(result, final, key, input, isOptionalOut) {
1616
- if (result.issues.length) {
1617
- if (isOptionalOut && !(key in input)) {
1618
- return;
1619
- }
1620
- final.issues.push(...prefixIssues(key, result.issues));
1621
- }
1622
- if (result.value === undefined) {
1623
- if (key in input) {
1624
- final.value[key] = undefined;
1625
- }
1626
- } else {
1627
- final.value[key] = result.value;
1628
- }
1629
- }
1630
- function normalizeDef(def) {
1631
- const keys = Object.keys(def.shape);
1632
- for (const k of keys) {
1633
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1634
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1635
- }
1636
- }
1637
- const okeys = optionalKeys(def.shape);
1638
- return {
1639
- ...def,
1640
- keys,
1641
- keySet: new Set(keys),
1642
- numKeys: keys.length,
1643
- optionalKeys: new Set(okeys)
1644
- };
1645
- }
1646
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1647
- const unrecognized = [];
1648
- const keySet = def.keySet;
1649
- const _catchall = def.catchall._zod;
1650
- const t = _catchall.def.type;
1651
- const isOptionalOut = _catchall.optout === "optional";
1652
- for (const key in input) {
1653
- if (keySet.has(key))
1654
- continue;
1655
- if (t === "never") {
1656
- unrecognized.push(key);
1657
- continue;
1658
- }
1659
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1660
- if (r instanceof Promise) {
1661
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1662
- } else {
1663
- handlePropertyResult(r, payload, key, input, isOptionalOut);
1664
- }
1665
- }
1666
- if (unrecognized.length) {
1667
- payload.issues.push({
1668
- code: "unrecognized_keys",
1669
- keys: unrecognized,
1670
- input,
1671
- inst
1672
- });
1673
- }
1674
- if (!proms.length)
1675
- return payload;
1676
- return Promise.all(proms).then(() => {
1677
- return payload;
1678
- });
1679
- }
1680
- var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1681
- $ZodType.init(inst, def);
1682
- const desc = Object.getOwnPropertyDescriptor(def, "shape");
1683
- if (!desc?.get) {
1684
- const sh = def.shape;
1685
- Object.defineProperty(def, "shape", {
1686
- get: () => {
1687
- const newSh = { ...sh };
1688
- Object.defineProperty(def, "shape", {
1689
- value: newSh
1690
- });
1691
- return newSh;
1692
- }
1693
- });
1694
- }
1695
- const _normalized = cached(() => normalizeDef(def));
1696
- defineLazy(inst._zod, "propValues", () => {
1697
- const shape = def.shape;
1698
- const propValues = {};
1699
- for (const key in shape) {
1700
- const field = shape[key]._zod;
1701
- if (field.values) {
1702
- propValues[key] ?? (propValues[key] = new Set);
1703
- for (const v of field.values)
1704
- propValues[key].add(v);
1705
- }
1706
- }
1707
- return propValues;
1708
- });
1709
- const isObject2 = isObject;
1710
- const catchall = def.catchall;
1711
- let value;
1712
- inst._zod.parse = (payload, ctx) => {
1713
- value ?? (value = _normalized.value);
1714
- const input = payload.value;
1715
- if (!isObject2(input)) {
1716
- payload.issues.push({
1717
- expected: "object",
1718
- code: "invalid_type",
1719
- input,
1720
- inst
1721
- });
1722
- return payload;
1723
- }
1724
- payload.value = {};
1725
- const proms = [];
1726
- const shape = value.shape;
1727
- for (const key of value.keys) {
1728
- const el = shape[key];
1729
- const isOptionalOut = el._zod.optout === "optional";
1730
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1731
- if (r instanceof Promise) {
1732
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1733
- } else {
1734
- handlePropertyResult(r, payload, key, input, isOptionalOut);
1735
- }
1736
- }
1737
- if (!catchall) {
1738
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
1739
- }
1740
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1741
- };
1742
- });
1743
- var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
1744
- $ZodObject.init(inst, def);
1745
- const superParse = inst._zod.parse;
1746
- const _normalized = cached(() => normalizeDef(def));
1747
- const generateFastpass = (shape) => {
1748
- const doc = new Doc(["shape", "payload", "ctx"]);
1749
- const normalized = _normalized.value;
1750
- const parseStr = (key) => {
1751
- const k = esc(key);
1752
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1753
- };
1754
- doc.write(`const input = payload.value;`);
1755
- const ids = Object.create(null);
1756
- let counter = 0;
1757
- for (const key of normalized.keys) {
1758
- ids[key] = `key_${counter++}`;
1759
- }
1760
- doc.write(`const newResult = {};`);
1761
- for (const key of normalized.keys) {
1762
- const id = ids[key];
1763
- const k = esc(key);
1764
- const schema = shape[key];
1765
- const isOptionalOut = schema?._zod?.optout === "optional";
1766
- doc.write(`const ${id} = ${parseStr(key)};`);
1767
- if (isOptionalOut) {
1768
- doc.write(`
1769
- if (${id}.issues.length) {
1770
- if (${k} in input) {
1771
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1772
- ...iss,
1773
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1774
- })));
1775
- }
1776
- }
1777
-
1778
- if (${id}.value === undefined) {
1779
- if (${k} in input) {
1780
- newResult[${k}] = undefined;
1781
- }
1782
- } else {
1783
- newResult[${k}] = ${id}.value;
1784
- }
1785
-
1786
- `);
1787
- } else {
1788
- doc.write(`
1789
- if (${id}.issues.length) {
1790
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1791
- ...iss,
1792
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1793
- })));
1794
- }
1795
-
1796
- if (${id}.value === undefined) {
1797
- if (${k} in input) {
1798
- newResult[${k}] = undefined;
1799
- }
1800
- } else {
1801
- newResult[${k}] = ${id}.value;
1802
- }
1803
-
1804
- `);
1805
- }
1806
- }
1807
- doc.write(`payload.value = newResult;`);
1808
- doc.write(`return payload;`);
1809
- const fn = doc.compile();
1810
- return (payload, ctx) => fn(shape, payload, ctx);
1811
- };
1812
- let fastpass;
1813
- const isObject2 = isObject;
1814
- const jit = !globalConfig.jitless;
1815
- const allowsEval2 = allowsEval;
1816
- const fastEnabled = jit && allowsEval2.value;
1817
- const catchall = def.catchall;
1818
- let value;
1819
- inst._zod.parse = (payload, ctx) => {
1820
- value ?? (value = _normalized.value);
1821
- const input = payload.value;
1822
- if (!isObject2(input)) {
1823
- payload.issues.push({
1824
- expected: "object",
1825
- code: "invalid_type",
1826
- input,
1827
- inst
1828
- });
1829
- return payload;
1830
- }
1831
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1832
- if (!fastpass)
1833
- fastpass = generateFastpass(def.shape);
1834
- payload = fastpass(payload, ctx);
1835
- if (!catchall)
1836
- return payload;
1837
- return handleCatchall([], input, payload, ctx, value, inst);
1838
- }
1839
- return superParse(payload, ctx);
1840
- };
1841
- });
1842
- function handleUnionResults(results, final, inst, ctx) {
1843
- for (const result of results) {
1844
- if (result.issues.length === 0) {
1845
- final.value = result.value;
1846
- return final;
1847
- }
1848
- }
1849
- const nonaborted = results.filter((r) => !aborted(r));
1850
- if (nonaborted.length === 1) {
1851
- final.value = nonaborted[0].value;
1852
- return nonaborted[0];
1853
- }
1854
- final.issues.push({
1855
- code: "invalid_union",
1856
- input: final.value,
1857
- inst,
1858
- errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1859
- });
1860
- return final;
1861
- }
1862
- var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1863
- $ZodType.init(inst, def);
1864
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
1865
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
1866
- defineLazy(inst._zod, "values", () => {
1867
- if (def.options.every((o) => o._zod.values)) {
1868
- return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1869
- }
1870
- return;
1871
- });
1872
- defineLazy(inst._zod, "pattern", () => {
1873
- if (def.options.every((o) => o._zod.pattern)) {
1874
- const patterns = def.options.map((o) => o._zod.pattern);
1875
- return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1876
- }
1877
- return;
1878
- });
1879
- const single = def.options.length === 1;
1880
- const first = def.options[0]._zod.run;
1881
- inst._zod.parse = (payload, ctx) => {
1882
- if (single) {
1883
- return first(payload, ctx);
1884
- }
1885
- let async = false;
1886
- const results = [];
1887
- for (const option of def.options) {
1888
- const result = option._zod.run({
1889
- value: payload.value,
1890
- issues: []
1891
- }, ctx);
1892
- if (result instanceof Promise) {
1893
- results.push(result);
1894
- async = true;
1895
- } else {
1896
- if (result.issues.length === 0)
1897
- return result;
1898
- results.push(result);
1899
- }
1900
- }
1901
- if (!async)
1902
- return handleUnionResults(results, payload, inst, ctx);
1903
- return Promise.all(results).then((results) => {
1904
- return handleUnionResults(results, payload, inst, ctx);
1905
- });
1906
- };
1907
- });
1908
- var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1909
- def.inclusive = false;
1910
- $ZodUnion.init(inst, def);
1911
- const _super = inst._zod.parse;
1912
- defineLazy(inst._zod, "propValues", () => {
1913
- const propValues = {};
1914
- for (const option of def.options) {
1915
- const pv = option._zod.propValues;
1916
- if (!pv || Object.keys(pv).length === 0)
1917
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1918
- for (const [k, v] of Object.entries(pv)) {
1919
- if (!propValues[k])
1920
- propValues[k] = new Set;
1921
- for (const val of v) {
1922
- propValues[k].add(val);
1923
- }
1924
- }
1925
- }
1926
- return propValues;
1927
- });
1928
- const disc = cached(() => {
1929
- const opts = def.options;
1930
- const map = new Map;
1931
- for (const o of opts) {
1932
- const values = o._zod.propValues?.[def.discriminator];
1933
- if (!values || values.size === 0)
1934
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1935
- for (const v of values) {
1936
- if (map.has(v)) {
1937
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
1938
- }
1939
- map.set(v, o);
1940
- }
1941
- }
1942
- return map;
1943
- });
1944
- inst._zod.parse = (payload, ctx) => {
1945
- const input = payload.value;
1946
- if (!isObject(input)) {
1947
- payload.issues.push({
1948
- code: "invalid_type",
1949
- expected: "object",
1950
- input,
1951
- inst
1952
- });
1953
- return payload;
1954
- }
1955
- const opt = disc.value.get(input?.[def.discriminator]);
1956
- if (opt) {
1957
- return opt._zod.run(payload, ctx);
1958
- }
1959
- if (def.unionFallback) {
1960
- return _super(payload, ctx);
1961
- }
1962
- payload.issues.push({
1963
- code: "invalid_union",
1964
- errors: [],
1965
- note: "No matching discriminator",
1966
- discriminator: def.discriminator,
1967
- input,
1968
- path: [def.discriminator],
1969
- inst
1970
- });
1971
- return payload;
1972
- };
1973
- });
1974
- var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1975
- $ZodType.init(inst, def);
1976
- inst._zod.parse = (payload, ctx) => {
1977
- const input = payload.value;
1978
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1979
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1980
- const async = left instanceof Promise || right instanceof Promise;
1981
- if (async) {
1982
- return Promise.all([left, right]).then(([left, right]) => {
1983
- return handleIntersectionResults(payload, left, right);
1984
- });
1985
- }
1986
- return handleIntersectionResults(payload, left, right);
1987
- };
1988
- });
1989
- function mergeValues(a, b) {
1990
- if (a === b) {
1991
- return { valid: true, data: a };
1992
- }
1993
- if (a instanceof Date && b instanceof Date && +a === +b) {
1994
- return { valid: true, data: a };
1995
- }
1996
- if (isPlainObject(a) && isPlainObject(b)) {
1997
- const bKeys = Object.keys(b);
1998
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1999
- const newObj = { ...a, ...b };
2000
- for (const key of sharedKeys) {
2001
- const sharedValue = mergeValues(a[key], b[key]);
2002
- if (!sharedValue.valid) {
2003
- return {
2004
- valid: false,
2005
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
2006
- };
2007
- }
2008
- newObj[key] = sharedValue.data;
2009
- }
2010
- return { valid: true, data: newObj };
2011
- }
2012
- if (Array.isArray(a) && Array.isArray(b)) {
2013
- if (a.length !== b.length) {
2014
- return { valid: false, mergeErrorPath: [] };
2015
- }
2016
- const newArray = [];
2017
- for (let index = 0;index < a.length; index++) {
2018
- const itemA = a[index];
2019
- const itemB = b[index];
2020
- const sharedValue = mergeValues(itemA, itemB);
2021
- if (!sharedValue.valid) {
2022
- return {
2023
- valid: false,
2024
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
2025
- };
2026
- }
2027
- newArray.push(sharedValue.data);
2028
- }
2029
- return { valid: true, data: newArray };
2030
- }
2031
- return { valid: false, mergeErrorPath: [] };
2032
- }
2033
- function handleIntersectionResults(result, left, right) {
2034
- const unrecKeys = new Map;
2035
- let unrecIssue;
2036
- for (const iss of left.issues) {
2037
- if (iss.code === "unrecognized_keys") {
2038
- unrecIssue ?? (unrecIssue = iss);
2039
- for (const k of iss.keys) {
2040
- if (!unrecKeys.has(k))
2041
- unrecKeys.set(k, {});
2042
- unrecKeys.get(k).l = true;
2043
- }
2044
- } else {
2045
- result.issues.push(iss);
2046
- }
2047
- }
2048
- for (const iss of right.issues) {
2049
- if (iss.code === "unrecognized_keys") {
2050
- for (const k of iss.keys) {
2051
- if (!unrecKeys.has(k))
2052
- unrecKeys.set(k, {});
2053
- unrecKeys.get(k).r = true;
2054
- }
2055
- } else {
2056
- result.issues.push(iss);
2057
- }
2058
- }
2059
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2060
- if (bothKeys.length && unrecIssue) {
2061
- result.issues.push({ ...unrecIssue, keys: bothKeys });
2062
- }
2063
- if (aborted(result))
2064
- return result;
2065
- const merged = mergeValues(left.value, right.value);
2066
- if (!merged.valid) {
2067
- throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
2068
- }
2069
- result.value = merged.data;
2070
- return result;
2071
- }
2072
- var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2073
- $ZodType.init(inst, def);
2074
- inst._zod.parse = (payload, ctx) => {
2075
- const input = payload.value;
2076
- if (!isPlainObject(input)) {
2077
- payload.issues.push({
2078
- expected: "record",
2079
- code: "invalid_type",
2080
- input,
2081
- inst
2082
- });
2083
- return payload;
2084
- }
2085
- const proms = [];
2086
- const values = def.keyType._zod.values;
2087
- if (values) {
2088
- payload.value = {};
2089
- const recordKeys = new Set;
2090
- for (const key of values) {
2091
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2092
- recordKeys.add(typeof key === "number" ? key.toString() : key);
2093
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2094
- if (result instanceof Promise) {
2095
- proms.push(result.then((result) => {
2096
- if (result.issues.length) {
2097
- payload.issues.push(...prefixIssues(key, result.issues));
2098
- }
2099
- payload.value[key] = result.value;
2100
- }));
2101
- } else {
2102
- if (result.issues.length) {
2103
- payload.issues.push(...prefixIssues(key, result.issues));
2104
- }
2105
- payload.value[key] = result.value;
2106
- }
2107
- }
2108
- }
2109
- let unrecognized;
2110
- for (const key in input) {
2111
- if (!recordKeys.has(key)) {
2112
- unrecognized = unrecognized ?? [];
2113
- unrecognized.push(key);
2114
- }
2115
- }
2116
- if (unrecognized && unrecognized.length > 0) {
2117
- payload.issues.push({
2118
- code: "unrecognized_keys",
2119
- input,
2120
- inst,
2121
- keys: unrecognized
2122
- });
2123
- }
2124
- } else {
2125
- payload.value = {};
2126
- for (const key of Reflect.ownKeys(input)) {
2127
- if (key === "__proto__")
2128
- continue;
2129
- let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2130
- if (keyResult instanceof Promise) {
2131
- throw new Error("Async schemas not supported in object keys currently");
2132
- }
2133
- const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
2134
- if (checkNumericKey) {
2135
- const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
2136
- if (retryResult instanceof Promise) {
2137
- throw new Error("Async schemas not supported in object keys currently");
2138
- }
2139
- if (retryResult.issues.length === 0) {
2140
- keyResult = retryResult;
2141
- }
2142
- }
2143
- if (keyResult.issues.length) {
2144
- if (def.mode === "loose") {
2145
- payload.value[key] = input[key];
2146
- } else {
2147
- payload.issues.push({
2148
- code: "invalid_key",
2149
- origin: "record",
2150
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2151
- input: key,
2152
- path: [key],
2153
- inst
2154
- });
2155
- }
2156
- continue;
2157
- }
2158
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2159
- if (result instanceof Promise) {
2160
- proms.push(result.then((result) => {
2161
- if (result.issues.length) {
2162
- payload.issues.push(...prefixIssues(key, result.issues));
2163
- }
2164
- payload.value[keyResult.value] = result.value;
2165
- }));
2166
- } else {
2167
- if (result.issues.length) {
2168
- payload.issues.push(...prefixIssues(key, result.issues));
2169
- }
2170
- payload.value[keyResult.value] = result.value;
2171
- }
2172
- }
2173
- }
2174
- if (proms.length) {
2175
- return Promise.all(proms).then(() => payload);
2176
- }
2177
- return payload;
2178
- };
2179
- });
2180
- var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2181
- $ZodType.init(inst, def);
2182
- const values = getEnumValues(def.entries);
2183
- const valuesSet = new Set(values);
2184
- inst._zod.values = valuesSet;
2185
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2186
- inst._zod.parse = (payload, _ctx) => {
2187
- const input = payload.value;
2188
- if (valuesSet.has(input)) {
2189
- return payload;
2190
- }
2191
- payload.issues.push({
2192
- code: "invalid_value",
2193
- values,
2194
- input,
2195
- inst
2196
- });
2197
- return payload;
2198
- };
2199
- });
2200
- var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
2201
- $ZodType.init(inst, def);
2202
- if (def.values.length === 0) {
2203
- throw new Error("Cannot create literal schema with no valid values");
2204
- }
2205
- const values = new Set(def.values);
2206
- inst._zod.values = values;
2207
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
2208
- inst._zod.parse = (payload, _ctx) => {
2209
- const input = payload.value;
2210
- if (values.has(input)) {
2211
- return payload;
2212
- }
2213
- payload.issues.push({
2214
- code: "invalid_value",
2215
- values: def.values,
2216
- input,
2217
- inst
2218
- });
2219
- return payload;
2220
- };
2221
- });
2222
- var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2223
- $ZodType.init(inst, def);
2224
- inst._zod.parse = (payload, ctx) => {
2225
- if (ctx.direction === "backward") {
2226
- throw new $ZodEncodeError(inst.constructor.name);
2227
- }
2228
- const _out = def.transform(payload.value, payload);
2229
- if (ctx.async) {
2230
- const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2231
- return output.then((output) => {
2232
- payload.value = output;
2233
- return payload;
2234
- });
2235
- }
2236
- if (_out instanceof Promise) {
2237
- throw new $ZodAsyncError;
2238
- }
2239
- payload.value = _out;
2240
- return payload;
2241
- };
2242
- });
2243
- function handleOptionalResult(result, input) {
2244
- if (result.issues.length && input === undefined) {
2245
- return { issues: [], value: undefined };
2246
- }
2247
- return result;
2248
- }
2249
- var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2250
- $ZodType.init(inst, def);
2251
- inst._zod.optin = "optional";
2252
- inst._zod.optout = "optional";
2253
- defineLazy(inst._zod, "values", () => {
2254
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
2255
- });
2256
- defineLazy(inst._zod, "pattern", () => {
2257
- const pattern = def.innerType._zod.pattern;
2258
- return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : undefined;
2259
- });
2260
- inst._zod.parse = (payload, ctx) => {
2261
- if (def.innerType._zod.optin === "optional") {
2262
- const result = def.innerType._zod.run(payload, ctx);
2263
- if (result instanceof Promise)
2264
- return result.then((r) => handleOptionalResult(r, payload.value));
2265
- return handleOptionalResult(result, payload.value);
2266
- }
2267
- if (payload.value === undefined) {
2268
- return payload;
2269
- }
2270
- return def.innerType._zod.run(payload, ctx);
2271
- };
2272
- });
2273
- var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
2274
- $ZodOptional.init(inst, def);
2275
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2276
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2277
- inst._zod.parse = (payload, ctx) => {
2278
- return def.innerType._zod.run(payload, ctx);
2279
- };
2280
- });
2281
- var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
2282
- $ZodType.init(inst, def);
2283
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2284
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2285
- defineLazy(inst._zod, "pattern", () => {
2286
- const pattern = def.innerType._zod.pattern;
2287
- return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : undefined;
2288
- });
2289
- defineLazy(inst._zod, "values", () => {
2290
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
2291
- });
2292
- inst._zod.parse = (payload, ctx) => {
2293
- if (payload.value === null)
2294
- return payload;
2295
- return def.innerType._zod.run(payload, ctx);
2296
- };
2297
- });
2298
- var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
2299
- $ZodType.init(inst, def);
2300
- inst._zod.optin = "optional";
2301
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2302
- inst._zod.parse = (payload, ctx) => {
2303
- if (ctx.direction === "backward") {
2304
- return def.innerType._zod.run(payload, ctx);
2305
- }
2306
- if (payload.value === undefined) {
2307
- payload.value = def.defaultValue;
2308
- return payload;
2309
- }
2310
- const result = def.innerType._zod.run(payload, ctx);
2311
- if (result instanceof Promise) {
2312
- return result.then((result) => handleDefaultResult(result, def));
2313
- }
2314
- return handleDefaultResult(result, def);
2315
- };
2316
- });
2317
- function handleDefaultResult(payload, def) {
2318
- if (payload.value === undefined) {
2319
- payload.value = def.defaultValue;
2320
- }
2321
- return payload;
2322
- }
2323
- var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
2324
- $ZodType.init(inst, def);
2325
- inst._zod.optin = "optional";
2326
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2327
- inst._zod.parse = (payload, ctx) => {
2328
- if (ctx.direction === "backward") {
2329
- return def.innerType._zod.run(payload, ctx);
2330
- }
2331
- if (payload.value === undefined) {
2332
- payload.value = def.defaultValue;
2333
- }
2334
- return def.innerType._zod.run(payload, ctx);
2335
- };
2336
- });
2337
- var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
2338
- $ZodType.init(inst, def);
2339
- defineLazy(inst._zod, "values", () => {
2340
- const v = def.innerType._zod.values;
2341
- return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
2342
- });
2343
- inst._zod.parse = (payload, ctx) => {
2344
- const result = def.innerType._zod.run(payload, ctx);
2345
- if (result instanceof Promise) {
2346
- return result.then((result) => handleNonOptionalResult(result, inst));
2347
- }
2348
- return handleNonOptionalResult(result, inst);
2349
- };
2350
- });
2351
- function handleNonOptionalResult(payload, inst) {
2352
- if (!payload.issues.length && payload.value === undefined) {
2353
- payload.issues.push({
2354
- code: "invalid_type",
2355
- expected: "nonoptional",
2356
- input: payload.value,
2357
- inst
2358
- });
2359
- }
2360
- return payload;
2361
- }
2362
- var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2363
- $ZodType.init(inst, def);
2364
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2365
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2366
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2367
- inst._zod.parse = (payload, ctx) => {
2368
- if (ctx.direction === "backward") {
2369
- return def.innerType._zod.run(payload, ctx);
2370
- }
2371
- const result = def.innerType._zod.run(payload, ctx);
2372
- if (result instanceof Promise) {
2373
- return result.then((result) => {
2374
- payload.value = result.value;
2375
- if (result.issues.length) {
2376
- payload.value = def.catchValue({
2377
- ...payload,
2378
- error: {
2379
- issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
2380
- },
2381
- input: payload.value
2382
- });
2383
- payload.issues = [];
2384
- }
2385
- return payload;
2386
- });
2387
- }
2388
- payload.value = result.value;
2389
- if (result.issues.length) {
2390
- payload.value = def.catchValue({
2391
- ...payload,
2392
- error: {
2393
- issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
2394
- },
2395
- input: payload.value
2396
- });
2397
- payload.issues = [];
2398
- }
2399
- return payload;
2400
- };
2401
- });
2402
- var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
2403
- $ZodType.init(inst, def);
2404
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2405
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2406
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2407
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2408
- inst._zod.parse = (payload, ctx) => {
2409
- if (ctx.direction === "backward") {
2410
- const right = def.out._zod.run(payload, ctx);
2411
- if (right instanceof Promise) {
2412
- return right.then((right) => handlePipeResult(right, def.in, ctx));
2413
- }
2414
- return handlePipeResult(right, def.in, ctx);
2415
- }
2416
- const left = def.in._zod.run(payload, ctx);
2417
- if (left instanceof Promise) {
2418
- return left.then((left) => handlePipeResult(left, def.out, ctx));
2419
- }
2420
- return handlePipeResult(left, def.out, ctx);
2421
- };
2422
- });
2423
- function handlePipeResult(left, next, ctx) {
2424
- if (left.issues.length) {
2425
- left.aborted = true;
2426
- return left;
2427
- }
2428
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2429
- }
2430
- var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2431
- $ZodType.init(inst, def);
2432
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2433
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2434
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2435
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2436
- inst._zod.parse = (payload, ctx) => {
2437
- if (ctx.direction === "backward") {
2438
- return def.innerType._zod.run(payload, ctx);
2439
- }
2440
- const result = def.innerType._zod.run(payload, ctx);
2441
- if (result instanceof Promise) {
2442
- return result.then(handleReadonlyResult);
2443
- }
2444
- return handleReadonlyResult(result);
2445
- };
2446
- });
2447
- function handleReadonlyResult(payload) {
2448
- payload.value = Object.freeze(payload.value);
2449
- return payload;
2450
- }
2451
- var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
2452
- $ZodCheck.init(inst, def);
2453
- $ZodType.init(inst, def);
2454
- inst._zod.parse = (payload, _) => {
2455
- return payload;
2456
- };
2457
- inst._zod.check = (payload) => {
2458
- const input = payload.value;
2459
- const r = def.fn(input);
2460
- if (r instanceof Promise) {
2461
- return r.then((r) => handleRefineResult(r, payload, input, inst));
2462
- }
2463
- handleRefineResult(r, payload, input, inst);
2464
- return;
2465
- };
2466
- });
2467
- function handleRefineResult(result, payload, input, inst) {
2468
- if (!result) {
2469
- const _iss = {
2470
- code: "custom",
2471
- input,
2472
- inst,
2473
- path: [...inst._zod.def.path ?? []],
2474
- continue: !inst._zod.def.abort
2475
- };
2476
- if (inst._zod.def.params)
2477
- _iss.params = inst._zod.def.params;
2478
- payload.issues.push(issue(_iss));
2479
- }
2480
- }
2481
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/registries.js
2482
- var _a;
2483
- var $output = Symbol("ZodOutput");
2484
- var $input = Symbol("ZodInput");
2485
-
2486
- class $ZodRegistry {
2487
- constructor() {
2488
- this._map = new WeakMap;
2489
- this._idmap = new Map;
2490
- }
2491
- add(schema, ..._meta) {
2492
- const meta = _meta[0];
2493
- this._map.set(schema, meta);
2494
- if (meta && typeof meta === "object" && "id" in meta) {
2495
- this._idmap.set(meta.id, schema);
2496
- }
2497
- return this;
2498
- }
2499
- clear() {
2500
- this._map = new WeakMap;
2501
- this._idmap = new Map;
2502
- return this;
2503
- }
2504
- remove(schema) {
2505
- const meta = this._map.get(schema);
2506
- if (meta && typeof meta === "object" && "id" in meta) {
2507
- this._idmap.delete(meta.id);
2508
- }
2509
- this._map.delete(schema);
2510
- return this;
2511
- }
2512
- get(schema) {
2513
- const p = schema._zod.parent;
2514
- if (p) {
2515
- const pm = { ...this.get(p) ?? {} };
2516
- delete pm.id;
2517
- const f = { ...pm, ...this._map.get(schema) };
2518
- return Object.keys(f).length ? f : undefined;
2519
- }
2520
- return this._map.get(schema);
2521
- }
2522
- has(schema) {
2523
- return this._map.has(schema);
2524
- }
2525
- }
2526
- function registry() {
2527
- return new $ZodRegistry;
2528
- }
2529
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2530
- var globalRegistry = globalThis.__zod_globalRegistry;
2531
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/api.js
2532
- function _string(Class, params) {
2533
- return new Class({
2534
- type: "string",
2535
- ...normalizeParams(params)
2536
- });
2537
- }
2538
- function _email(Class, params) {
2539
- return new Class({
2540
- type: "string",
2541
- format: "email",
2542
- check: "string_format",
2543
- abort: false,
2544
- ...normalizeParams(params)
2545
- });
2546
- }
2547
- function _guid(Class, params) {
2548
- return new Class({
2549
- type: "string",
2550
- format: "guid",
2551
- check: "string_format",
2552
- abort: false,
2553
- ...normalizeParams(params)
2554
- });
2555
- }
2556
- function _uuid(Class, params) {
2557
- return new Class({
2558
- type: "string",
2559
- format: "uuid",
2560
- check: "string_format",
2561
- abort: false,
2562
- ...normalizeParams(params)
2563
- });
2564
- }
2565
- function _uuidv4(Class, params) {
2566
- return new Class({
2567
- type: "string",
2568
- format: "uuid",
2569
- check: "string_format",
2570
- abort: false,
2571
- version: "v4",
2572
- ...normalizeParams(params)
2573
- });
2574
- }
2575
- function _uuidv6(Class, params) {
2576
- return new Class({
2577
- type: "string",
2578
- format: "uuid",
2579
- check: "string_format",
2580
- abort: false,
2581
- version: "v6",
2582
- ...normalizeParams(params)
2583
- });
2584
- }
2585
- function _uuidv7(Class, params) {
2586
- return new Class({
2587
- type: "string",
2588
- format: "uuid",
2589
- check: "string_format",
2590
- abort: false,
2591
- version: "v7",
2592
- ...normalizeParams(params)
2593
- });
2594
- }
2595
- function _url(Class, params) {
2596
- return new Class({
2597
- type: "string",
2598
- format: "url",
2599
- check: "string_format",
2600
- abort: false,
2601
- ...normalizeParams(params)
2602
- });
2603
- }
2604
- function _emoji2(Class, params) {
2605
- return new Class({
2606
- type: "string",
2607
- format: "emoji",
2608
- check: "string_format",
2609
- abort: false,
2610
- ...normalizeParams(params)
2611
- });
2612
- }
2613
- function _nanoid(Class, params) {
2614
- return new Class({
2615
- type: "string",
2616
- format: "nanoid",
2617
- check: "string_format",
2618
- abort: false,
2619
- ...normalizeParams(params)
2620
- });
2621
- }
2622
- function _cuid(Class, params) {
2623
- return new Class({
2624
- type: "string",
2625
- format: "cuid",
2626
- check: "string_format",
2627
- abort: false,
2628
- ...normalizeParams(params)
2629
- });
2630
- }
2631
- function _cuid2(Class, params) {
2632
- return new Class({
2633
- type: "string",
2634
- format: "cuid2",
2635
- check: "string_format",
2636
- abort: false,
2637
- ...normalizeParams(params)
2638
- });
2639
- }
2640
- function _ulid(Class, params) {
2641
- return new Class({
2642
- type: "string",
2643
- format: "ulid",
2644
- check: "string_format",
2645
- abort: false,
2646
- ...normalizeParams(params)
2647
- });
2648
- }
2649
- function _xid(Class, params) {
2650
- return new Class({
2651
- type: "string",
2652
- format: "xid",
2653
- check: "string_format",
2654
- abort: false,
2655
- ...normalizeParams(params)
2656
- });
2657
- }
2658
- function _ksuid(Class, params) {
2659
- return new Class({
2660
- type: "string",
2661
- format: "ksuid",
2662
- check: "string_format",
2663
- abort: false,
2664
- ...normalizeParams(params)
2665
- });
2666
- }
2667
- function _ipv4(Class, params) {
2668
- return new Class({
2669
- type: "string",
2670
- format: "ipv4",
2671
- check: "string_format",
2672
- abort: false,
2673
- ...normalizeParams(params)
2674
- });
2675
- }
2676
- function _ipv6(Class, params) {
2677
- return new Class({
2678
- type: "string",
2679
- format: "ipv6",
2680
- check: "string_format",
2681
- abort: false,
2682
- ...normalizeParams(params)
2683
- });
2684
- }
2685
- function _cidrv4(Class, params) {
2686
- return new Class({
2687
- type: "string",
2688
- format: "cidrv4",
2689
- check: "string_format",
2690
- abort: false,
2691
- ...normalizeParams(params)
2692
- });
2693
- }
2694
- function _cidrv6(Class, params) {
2695
- return new Class({
2696
- type: "string",
2697
- format: "cidrv6",
2698
- check: "string_format",
2699
- abort: false,
2700
- ...normalizeParams(params)
2701
- });
2702
- }
2703
- function _base64(Class, params) {
2704
- return new Class({
2705
- type: "string",
2706
- format: "base64",
2707
- check: "string_format",
2708
- abort: false,
2709
- ...normalizeParams(params)
2710
- });
2711
- }
2712
- function _base64url(Class, params) {
2713
- return new Class({
2714
- type: "string",
2715
- format: "base64url",
2716
- check: "string_format",
2717
- abort: false,
2718
- ...normalizeParams(params)
2719
- });
2720
- }
2721
- function _e164(Class, params) {
2722
- return new Class({
2723
- type: "string",
2724
- format: "e164",
2725
- check: "string_format",
2726
- abort: false,
2727
- ...normalizeParams(params)
2728
- });
2729
- }
2730
- function _jwt(Class, params) {
2731
- return new Class({
2732
- type: "string",
2733
- format: "jwt",
2734
- check: "string_format",
2735
- abort: false,
2736
- ...normalizeParams(params)
2737
- });
2738
- }
2739
- function _isoDateTime(Class, params) {
2740
- return new Class({
2741
- type: "string",
2742
- format: "datetime",
2743
- check: "string_format",
2744
- offset: false,
2745
- local: false,
2746
- precision: null,
2747
- ...normalizeParams(params)
2748
- });
2749
- }
2750
- function _isoDate(Class, params) {
2751
- return new Class({
2752
- type: "string",
2753
- format: "date",
2754
- check: "string_format",
2755
- ...normalizeParams(params)
2756
- });
2757
- }
2758
- function _isoTime(Class, params) {
2759
- return new Class({
2760
- type: "string",
2761
- format: "time",
2762
- check: "string_format",
2763
- precision: null,
2764
- ...normalizeParams(params)
2765
- });
2766
- }
2767
- function _isoDuration(Class, params) {
2768
- return new Class({
2769
- type: "string",
2770
- format: "duration",
2771
- check: "string_format",
2772
- ...normalizeParams(params)
2773
- });
2774
- }
2775
- function _number(Class, params) {
2776
- return new Class({
2777
- type: "number",
2778
- checks: [],
2779
- ...normalizeParams(params)
2780
- });
2781
- }
2782
- function _int(Class, params) {
2783
- return new Class({
2784
- type: "number",
2785
- check: "number_format",
2786
- abort: false,
2787
- format: "safeint",
2788
- ...normalizeParams(params)
2789
- });
2790
- }
2791
- function _boolean(Class, params) {
2792
- return new Class({
2793
- type: "boolean",
2794
- ...normalizeParams(params)
2795
- });
2796
- }
2797
- function _unknown(Class) {
2798
- return new Class({
2799
- type: "unknown"
2800
- });
2801
- }
2802
- function _never(Class, params) {
2803
- return new Class({
2804
- type: "never",
2805
- ...normalizeParams(params)
2806
- });
2807
- }
2808
- function _lt(value, params) {
2809
- return new $ZodCheckLessThan({
2810
- check: "less_than",
2811
- ...normalizeParams(params),
2812
- value,
2813
- inclusive: false
2814
- });
2815
- }
2816
- function _lte(value, params) {
2817
- return new $ZodCheckLessThan({
2818
- check: "less_than",
2819
- ...normalizeParams(params),
2820
- value,
2821
- inclusive: true
2822
- });
2823
- }
2824
- function _gt(value, params) {
2825
- return new $ZodCheckGreaterThan({
2826
- check: "greater_than",
2827
- ...normalizeParams(params),
2828
- value,
2829
- inclusive: false
2830
- });
2831
- }
2832
- function _gte(value, params) {
2833
- return new $ZodCheckGreaterThan({
2834
- check: "greater_than",
2835
- ...normalizeParams(params),
2836
- value,
2837
- inclusive: true
2838
- });
2839
- }
2840
- function _multipleOf(value, params) {
2841
- return new $ZodCheckMultipleOf({
2842
- check: "multiple_of",
2843
- ...normalizeParams(params),
2844
- value
2845
- });
2846
- }
2847
- function _maxLength(maximum, params) {
2848
- const ch = new $ZodCheckMaxLength({
2849
- check: "max_length",
2850
- ...normalizeParams(params),
2851
- maximum
2852
- });
2853
- return ch;
2854
- }
2855
- function _minLength(minimum, params) {
2856
- return new $ZodCheckMinLength({
2857
- check: "min_length",
2858
- ...normalizeParams(params),
2859
- minimum
2860
- });
2861
- }
2862
- function _length(length, params) {
2863
- return new $ZodCheckLengthEquals({
2864
- check: "length_equals",
2865
- ...normalizeParams(params),
2866
- length
2867
- });
2868
- }
2869
- function _regex(pattern, params) {
2870
- return new $ZodCheckRegex({
2871
- check: "string_format",
2872
- format: "regex",
2873
- ...normalizeParams(params),
2874
- pattern
2875
- });
2876
- }
2877
- function _lowercase(params) {
2878
- return new $ZodCheckLowerCase({
2879
- check: "string_format",
2880
- format: "lowercase",
2881
- ...normalizeParams(params)
2882
- });
2883
- }
2884
- function _uppercase(params) {
2885
- return new $ZodCheckUpperCase({
2886
- check: "string_format",
2887
- format: "uppercase",
2888
- ...normalizeParams(params)
2889
- });
2890
- }
2891
- function _includes(includes, params) {
2892
- return new $ZodCheckIncludes({
2893
- check: "string_format",
2894
- format: "includes",
2895
- ...normalizeParams(params),
2896
- includes
2897
- });
2898
- }
2899
- function _startsWith(prefix, params) {
2900
- return new $ZodCheckStartsWith({
2901
- check: "string_format",
2902
- format: "starts_with",
2903
- ...normalizeParams(params),
2904
- prefix
2905
- });
2906
- }
2907
- function _endsWith(suffix, params) {
2908
- return new $ZodCheckEndsWith({
2909
- check: "string_format",
2910
- format: "ends_with",
2911
- ...normalizeParams(params),
2912
- suffix
2913
- });
2914
- }
2915
- function _overwrite(tx) {
2916
- return new $ZodCheckOverwrite({
2917
- check: "overwrite",
2918
- tx
2919
- });
2920
- }
2921
- function _normalize(form) {
2922
- return _overwrite((input) => input.normalize(form));
2923
- }
2924
- function _trim() {
2925
- return _overwrite((input) => input.trim());
2926
- }
2927
- function _toLowerCase() {
2928
- return _overwrite((input) => input.toLowerCase());
2929
- }
2930
- function _toUpperCase() {
2931
- return _overwrite((input) => input.toUpperCase());
2932
- }
2933
- function _slugify() {
2934
- return _overwrite((input) => slugify(input));
2935
- }
2936
- function _array(Class, element, params) {
2937
- return new Class({
2938
- type: "array",
2939
- element,
2940
- ...normalizeParams(params)
2941
- });
2942
- }
2943
- function _custom(Class, fn, _params) {
2944
- const norm = normalizeParams(_params);
2945
- norm.abort ?? (norm.abort = true);
2946
- const schema = new Class({
2947
- type: "custom",
2948
- check: "custom",
2949
- fn,
2950
- ...norm
2951
- });
2952
- return schema;
2953
- }
2954
- function _refine(Class, fn, _params) {
2955
- const schema = new Class({
2956
- type: "custom",
2957
- check: "custom",
2958
- fn,
2959
- ...normalizeParams(_params)
2960
- });
2961
- return schema;
2962
- }
2963
- function _superRefine(fn) {
2964
- const ch = _check((payload) => {
2965
- payload.addIssue = (issue2) => {
2966
- if (typeof issue2 === "string") {
2967
- payload.issues.push(issue(issue2, payload.value, ch._zod.def));
2968
- } else {
2969
- const _issue = issue2;
2970
- if (_issue.fatal)
2971
- _issue.continue = false;
2972
- _issue.code ?? (_issue.code = "custom");
2973
- _issue.input ?? (_issue.input = payload.value);
2974
- _issue.inst ?? (_issue.inst = ch);
2975
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2976
- payload.issues.push(issue(_issue));
2977
- }
2978
- };
2979
- return fn(payload.value, payload);
2980
- });
2981
- return ch;
2982
- }
2983
- function _check(fn, params) {
2984
- const ch = new $ZodCheck({
2985
- check: "custom",
2986
- ...normalizeParams(params)
2987
- });
2988
- ch._zod.check = fn;
2989
- return ch;
2990
- }
2991
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
2992
- function initializeContext(params) {
2993
- let target = params?.target ?? "draft-2020-12";
2994
- if (target === "draft-4")
2995
- target = "draft-04";
2996
- if (target === "draft-7")
2997
- target = "draft-07";
2998
- return {
2999
- processors: params.processors ?? {},
3000
- metadataRegistry: params?.metadata ?? globalRegistry,
3001
- target,
3002
- unrepresentable: params?.unrepresentable ?? "throw",
3003
- override: params?.override ?? (() => {}),
3004
- io: params?.io ?? "output",
3005
- counter: 0,
3006
- seen: new Map,
3007
- cycles: params?.cycles ?? "ref",
3008
- reused: params?.reused ?? "inline",
3009
- external: params?.external ?? undefined
3010
- };
3011
- }
3012
- function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
3013
- var _a;
3014
- const def = schema._zod.def;
3015
- const seen = ctx.seen.get(schema);
3016
- if (seen) {
3017
- seen.count++;
3018
- const isCycle = _params.schemaPath.includes(schema);
3019
- if (isCycle) {
3020
- seen.cycle = _params.path;
3021
- }
3022
- return seen.schema;
3023
- }
3024
- const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
3025
- ctx.seen.set(schema, result);
3026
- const overrideSchema = schema._zod.toJSONSchema?.();
3027
- if (overrideSchema) {
3028
- result.schema = overrideSchema;
3029
- } else {
3030
- const params = {
3031
- ..._params,
3032
- schemaPath: [..._params.schemaPath, schema],
3033
- path: _params.path
3034
- };
3035
- if (schema._zod.processJSONSchema) {
3036
- schema._zod.processJSONSchema(ctx, result.schema, params);
3037
- } else {
3038
- const _json = result.schema;
3039
- const processor = ctx.processors[def.type];
3040
- if (!processor) {
3041
- throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
3042
- }
3043
- processor(schema, ctx, _json, params);
3044
- }
3045
- const parent = schema._zod.parent;
3046
- if (parent) {
3047
- if (!result.ref)
3048
- result.ref = parent;
3049
- process2(parent, ctx, params);
3050
- ctx.seen.get(parent).isParent = true;
3051
- }
3052
- }
3053
- const meta = ctx.metadataRegistry.get(schema);
3054
- if (meta)
3055
- Object.assign(result.schema, meta);
3056
- if (ctx.io === "input" && isTransforming(schema)) {
3057
- delete result.schema.examples;
3058
- delete result.schema.default;
3059
- }
3060
- if (ctx.io === "input" && result.schema._prefault)
3061
- (_a = result.schema).default ?? (_a.default = result.schema._prefault);
3062
- delete result.schema._prefault;
3063
- const _result = ctx.seen.get(schema);
3064
- return _result.schema;
3065
- }
3066
- function extractDefs(ctx, schema) {
3067
- const root = ctx.seen.get(schema);
3068
- if (!root)
3069
- throw new Error("Unprocessed schema. This is a bug in Zod.");
3070
- const idToSchema = new Map;
3071
- for (const entry of ctx.seen.entries()) {
3072
- const id = ctx.metadataRegistry.get(entry[0])?.id;
3073
- if (id) {
3074
- const existing = idToSchema.get(id);
3075
- if (existing && existing !== entry[0]) {
3076
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3077
- }
3078
- idToSchema.set(id, entry[0]);
3079
- }
3080
- }
3081
- const makeURI = (entry) => {
3082
- const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3083
- if (ctx.external) {
3084
- const externalId = ctx.external.registry.get(entry[0])?.id;
3085
- const uriGenerator = ctx.external.uri ?? ((id) => id);
3086
- if (externalId) {
3087
- return { ref: uriGenerator(externalId) };
3088
- }
3089
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
3090
- entry[1].defId = id;
3091
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
3092
- }
3093
- if (entry[1] === root) {
3094
- return { ref: "#" };
3095
- }
3096
- const uriPrefix = `#`;
3097
- const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3098
- const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
3099
- return { defId, ref: defUriPrefix + defId };
3100
- };
3101
- const extractToDef = (entry) => {
3102
- if (entry[1].schema.$ref) {
3103
- return;
3104
- }
3105
- const seen = entry[1];
3106
- const { ref, defId } = makeURI(entry);
3107
- seen.def = { ...seen.schema };
3108
- if (defId)
3109
- seen.defId = defId;
3110
- const schema = seen.schema;
3111
- for (const key in schema) {
3112
- delete schema[key];
3113
- }
3114
- schema.$ref = ref;
3115
- };
3116
- if (ctx.cycles === "throw") {
3117
- for (const entry of ctx.seen.entries()) {
3118
- const seen = entry[1];
3119
- if (seen.cycle) {
3120
- throw new Error("Cycle detected: " + `#/${seen.cycle?.join("/")}/<root>` + '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
3121
- }
3122
- }
3123
- }
3124
- for (const entry of ctx.seen.entries()) {
3125
- const seen = entry[1];
3126
- if (schema === entry[0]) {
3127
- extractToDef(entry);
3128
- continue;
3129
- }
3130
- if (ctx.external) {
3131
- const ext = ctx.external.registry.get(entry[0])?.id;
3132
- if (schema !== entry[0] && ext) {
3133
- extractToDef(entry);
3134
- continue;
3135
- }
3136
- }
3137
- const id = ctx.metadataRegistry.get(entry[0])?.id;
3138
- if (id) {
3139
- extractToDef(entry);
3140
- continue;
3141
- }
3142
- if (seen.cycle) {
3143
- extractToDef(entry);
3144
- continue;
3145
- }
3146
- if (seen.count > 1) {
3147
- if (ctx.reused === "ref") {
3148
- extractToDef(entry);
3149
- continue;
3150
- }
3151
- }
3152
- }
3153
- }
3154
- function finalize(ctx, schema) {
3155
- const root = ctx.seen.get(schema);
3156
- if (!root)
3157
- throw new Error("Unprocessed schema. This is a bug in Zod.");
3158
- const flattenRef = (zodSchema) => {
3159
- const seen = ctx.seen.get(zodSchema);
3160
- if (seen.ref === null)
3161
- return;
3162
- const schema = seen.def ?? seen.schema;
3163
- const _cached = { ...schema };
3164
- const ref = seen.ref;
3165
- seen.ref = null;
3166
- if (ref) {
3167
- flattenRef(ref);
3168
- const refSeen = ctx.seen.get(ref);
3169
- const refSchema = refSeen.schema;
3170
- if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3171
- schema.allOf = schema.allOf ?? [];
3172
- schema.allOf.push(refSchema);
3173
- } else {
3174
- Object.assign(schema, refSchema);
3175
- }
3176
- Object.assign(schema, _cached);
3177
- const isParentRef = zodSchema._zod.parent === ref;
3178
- if (isParentRef) {
3179
- for (const key in schema) {
3180
- if (key === "$ref" || key === "allOf")
3181
- continue;
3182
- if (!(key in _cached)) {
3183
- delete schema[key];
3184
- }
3185
- }
3186
- }
3187
- if (refSchema.$ref && refSeen.def) {
3188
- for (const key in schema) {
3189
- if (key === "$ref" || key === "allOf")
3190
- continue;
3191
- if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
3192
- delete schema[key];
3193
- }
3194
- }
3195
- }
3196
- }
3197
- const parent = zodSchema._zod.parent;
3198
- if (parent && parent !== ref) {
3199
- flattenRef(parent);
3200
- const parentSeen = ctx.seen.get(parent);
3201
- if (parentSeen?.schema.$ref) {
3202
- schema.$ref = parentSeen.schema.$ref;
3203
- if (parentSeen.def) {
3204
- for (const key in schema) {
3205
- if (key === "$ref" || key === "allOf")
3206
- continue;
3207
- if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
3208
- delete schema[key];
3209
- }
3210
- }
3211
- }
3212
- }
3213
- }
3214
- ctx.override({
3215
- zodSchema,
3216
- jsonSchema: schema,
3217
- path: seen.path ?? []
3218
- });
3219
- };
3220
- for (const entry of [...ctx.seen.entries()].reverse()) {
3221
- flattenRef(entry[0]);
3222
- }
3223
- const result = {};
3224
- if (ctx.target === "draft-2020-12") {
3225
- result.$schema = "https://json-schema.org/draft/2020-12/schema";
3226
- } else if (ctx.target === "draft-07") {
3227
- result.$schema = "http://json-schema.org/draft-07/schema#";
3228
- } else if (ctx.target === "draft-04") {
3229
- result.$schema = "http://json-schema.org/draft-04/schema#";
3230
- } else if (ctx.target === "openapi-3.0") {}
3231
- if (ctx.external?.uri) {
3232
- const id = ctx.external.registry.get(schema)?.id;
3233
- if (!id)
3234
- throw new Error("Schema is missing an `id` property");
3235
- result.$id = ctx.external.uri(id);
3236
- }
3237
- Object.assign(result, root.def ?? root.schema);
3238
- const defs = ctx.external?.defs ?? {};
3239
- for (const entry of ctx.seen.entries()) {
3240
- const seen = entry[1];
3241
- if (seen.def && seen.defId) {
3242
- defs[seen.defId] = seen.def;
3243
- }
3244
- }
3245
- if (ctx.external) {} else {
3246
- if (Object.keys(defs).length > 0) {
3247
- if (ctx.target === "draft-2020-12") {
3248
- result.$defs = defs;
3249
- } else {
3250
- result.definitions = defs;
3251
- }
3252
- }
3253
- }
3254
- try {
3255
- const finalized = JSON.parse(JSON.stringify(result));
3256
- Object.defineProperty(finalized, "~standard", {
3257
- value: {
3258
- ...schema["~standard"],
3259
- jsonSchema: {
3260
- input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3261
- output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3262
- }
3263
- },
3264
- enumerable: false,
3265
- writable: false
3266
- });
3267
- return finalized;
3268
- } catch (_err) {
3269
- throw new Error("Error converting schema to JSON.");
3270
- }
3271
- }
3272
- function isTransforming(_schema, _ctx) {
3273
- const ctx = _ctx ?? { seen: new Set };
3274
- if (ctx.seen.has(_schema))
3275
- return false;
3276
- ctx.seen.add(_schema);
3277
- const def = _schema._zod.def;
3278
- if (def.type === "transform")
3279
- return true;
3280
- if (def.type === "array")
3281
- return isTransforming(def.element, ctx);
3282
- if (def.type === "set")
3283
- return isTransforming(def.valueType, ctx);
3284
- if (def.type === "lazy")
3285
- return isTransforming(def.getter(), ctx);
3286
- if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
3287
- return isTransforming(def.innerType, ctx);
3288
- }
3289
- if (def.type === "intersection") {
3290
- return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3291
- }
3292
- if (def.type === "record" || def.type === "map") {
3293
- return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3294
- }
3295
- if (def.type === "pipe") {
3296
- return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3297
- }
3298
- if (def.type === "object") {
3299
- for (const key in def.shape) {
3300
- if (isTransforming(def.shape[key], ctx))
3301
- return true;
3302
- }
3303
- return false;
3304
- }
3305
- if (def.type === "union") {
3306
- for (const option of def.options) {
3307
- if (isTransforming(option, ctx))
3308
- return true;
3309
- }
3310
- return false;
3311
- }
3312
- if (def.type === "tuple") {
3313
- for (const item of def.items) {
3314
- if (isTransforming(item, ctx))
3315
- return true;
3316
- }
3317
- if (def.rest && isTransforming(def.rest, ctx))
3318
- return true;
3319
- return false;
3320
- }
3321
- return false;
3322
- }
3323
- var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3324
- const ctx = initializeContext({ ...params, processors });
3325
- process2(schema, ctx);
3326
- extractDefs(ctx, schema);
3327
- return finalize(ctx, schema);
3328
- };
3329
- var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3330
- const { libraryOptions, target } = params ?? {};
3331
- const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
3332
- process2(schema, ctx);
3333
- extractDefs(ctx, schema);
3334
- return finalize(ctx, schema);
3335
- };
3336
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js
3337
- var formatMap = {
3338
- guid: "uuid",
3339
- url: "uri",
3340
- datetime: "date-time",
3341
- json_string: "json-string",
3342
- regex: ""
3343
- };
3344
- var stringProcessor = (schema, ctx, _json, _params) => {
3345
- const json = _json;
3346
- json.type = "string";
3347
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3348
- if (typeof minimum === "number")
3349
- json.minLength = minimum;
3350
- if (typeof maximum === "number")
3351
- json.maxLength = maximum;
3352
- if (format) {
3353
- json.format = formatMap[format] ?? format;
3354
- if (json.format === "")
3355
- delete json.format;
3356
- if (format === "time") {
3357
- delete json.format;
3358
- }
3359
- }
3360
- if (contentEncoding)
3361
- json.contentEncoding = contentEncoding;
3362
- if (patterns && patterns.size > 0) {
3363
- const regexes = [...patterns];
3364
- if (regexes.length === 1)
3365
- json.pattern = regexes[0].source;
3366
- else if (regexes.length > 1) {
3367
- json.allOf = [
3368
- ...regexes.map((regex) => ({
3369
- ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3370
- pattern: regex.source
3371
- }))
3372
- ];
3373
- }
3374
- }
3375
- };
3376
- var numberProcessor = (schema, ctx, _json, _params) => {
3377
- const json = _json;
3378
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3379
- if (typeof format === "string" && format.includes("int"))
3380
- json.type = "integer";
3381
- else
3382
- json.type = "number";
3383
- if (typeof exclusiveMinimum === "number") {
3384
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3385
- json.minimum = exclusiveMinimum;
3386
- json.exclusiveMinimum = true;
3387
- } else {
3388
- json.exclusiveMinimum = exclusiveMinimum;
3389
- }
3390
- }
3391
- if (typeof minimum === "number") {
3392
- json.minimum = minimum;
3393
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
3394
- if (exclusiveMinimum >= minimum)
3395
- delete json.minimum;
3396
- else
3397
- delete json.exclusiveMinimum;
3398
- }
3399
- }
3400
- if (typeof exclusiveMaximum === "number") {
3401
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3402
- json.maximum = exclusiveMaximum;
3403
- json.exclusiveMaximum = true;
3404
- } else {
3405
- json.exclusiveMaximum = exclusiveMaximum;
3406
- }
3407
- }
3408
- if (typeof maximum === "number") {
3409
- json.maximum = maximum;
3410
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
3411
- if (exclusiveMaximum <= maximum)
3412
- delete json.maximum;
3413
- else
3414
- delete json.exclusiveMaximum;
3415
- }
3416
- }
3417
- if (typeof multipleOf === "number")
3418
- json.multipleOf = multipleOf;
3419
- };
3420
- var booleanProcessor = (_schema, _ctx, json, _params) => {
3421
- json.type = "boolean";
3422
- };
3423
- var neverProcessor = (_schema, _ctx, json, _params) => {
3424
- json.not = {};
3425
- };
3426
- var unknownProcessor = (_schema, _ctx, _json, _params) => {};
3427
- var enumProcessor = (schema, _ctx, json, _params) => {
3428
- const def = schema._zod.def;
3429
- const values = getEnumValues(def.entries);
3430
- if (values.every((v) => typeof v === "number"))
3431
- json.type = "number";
3432
- if (values.every((v) => typeof v === "string"))
3433
- json.type = "string";
3434
- json.enum = values;
3435
- };
3436
- var literalProcessor = (schema, ctx, json, _params) => {
3437
- const def = schema._zod.def;
3438
- const vals = [];
3439
- for (const val of def.values) {
3440
- if (val === undefined) {
3441
- if (ctx.unrepresentable === "throw") {
3442
- throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3443
- }
3444
- } else if (typeof val === "bigint") {
3445
- if (ctx.unrepresentable === "throw") {
3446
- throw new Error("BigInt literals cannot be represented in JSON Schema");
3447
- } else {
3448
- vals.push(Number(val));
3449
- }
3450
- } else {
3451
- vals.push(val);
3452
- }
3453
- }
3454
- if (vals.length === 0) {} else if (vals.length === 1) {
3455
- const val = vals[0];
3456
- json.type = val === null ? "null" : typeof val;
3457
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3458
- json.enum = [val];
3459
- } else {
3460
- json.const = val;
3461
- }
3462
- } else {
3463
- if (vals.every((v) => typeof v === "number"))
3464
- json.type = "number";
3465
- if (vals.every((v) => typeof v === "string"))
3466
- json.type = "string";
3467
- if (vals.every((v) => typeof v === "boolean"))
3468
- json.type = "boolean";
3469
- if (vals.every((v) => v === null))
3470
- json.type = "null";
3471
- json.enum = vals;
3472
- }
3473
- };
3474
- var customProcessor = (_schema, ctx, _json, _params) => {
3475
- if (ctx.unrepresentable === "throw") {
3476
- throw new Error("Custom types cannot be represented in JSON Schema");
3477
- }
3478
- };
3479
- var transformProcessor = (_schema, ctx, _json, _params) => {
3480
- if (ctx.unrepresentable === "throw") {
3481
- throw new Error("Transforms cannot be represented in JSON Schema");
3482
- }
3483
- };
3484
- var arrayProcessor = (schema, ctx, _json, params) => {
3485
- const json = _json;
3486
- const def = schema._zod.def;
3487
- const { minimum, maximum } = schema._zod.bag;
3488
- if (typeof minimum === "number")
3489
- json.minItems = minimum;
3490
- if (typeof maximum === "number")
3491
- json.maxItems = maximum;
3492
- json.type = "array";
3493
- json.items = process2(def.element, ctx, { ...params, path: [...params.path, "items"] });
3494
- };
3495
- var objectProcessor = (schema, ctx, _json, params) => {
3496
- const json = _json;
3497
- const def = schema._zod.def;
3498
- json.type = "object";
3499
- json.properties = {};
3500
- const shape = def.shape;
3501
- for (const key in shape) {
3502
- json.properties[key] = process2(shape[key], ctx, {
3503
- ...params,
3504
- path: [...params.path, "properties", key]
3505
- });
3506
- }
3507
- const allKeys = new Set(Object.keys(shape));
3508
- const requiredKeys = new Set([...allKeys].filter((key) => {
3509
- const v = def.shape[key]._zod;
3510
- if (ctx.io === "input") {
3511
- return v.optin === undefined;
3512
- } else {
3513
- return v.optout === undefined;
3514
- }
3515
- }));
3516
- if (requiredKeys.size > 0) {
3517
- json.required = Array.from(requiredKeys);
3518
- }
3519
- if (def.catchall?._zod.def.type === "never") {
3520
- json.additionalProperties = false;
3521
- } else if (!def.catchall) {
3522
- if (ctx.io === "output")
3523
- json.additionalProperties = false;
3524
- } else if (def.catchall) {
3525
- json.additionalProperties = process2(def.catchall, ctx, {
3526
- ...params,
3527
- path: [...params.path, "additionalProperties"]
3528
- });
3529
- }
3530
- };
3531
- var unionProcessor = (schema, ctx, json, params) => {
3532
- const def = schema._zod.def;
3533
- const isExclusive = def.inclusive === false;
3534
- const options = def.options.map((x, i) => process2(x, ctx, {
3535
- ...params,
3536
- path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
3537
- }));
3538
- if (isExclusive) {
3539
- json.oneOf = options;
3540
- } else {
3541
- json.anyOf = options;
3542
- }
3543
- };
3544
- var intersectionProcessor = (schema, ctx, json, params) => {
3545
- const def = schema._zod.def;
3546
- const a = process2(def.left, ctx, {
3547
- ...params,
3548
- path: [...params.path, "allOf", 0]
3549
- });
3550
- const b = process2(def.right, ctx, {
3551
- ...params,
3552
- path: [...params.path, "allOf", 1]
3553
- });
3554
- const isSimpleIntersection = (val) => ("allOf" in val) && Object.keys(val).length === 1;
3555
- const allOf = [
3556
- ...isSimpleIntersection(a) ? a.allOf : [a],
3557
- ...isSimpleIntersection(b) ? b.allOf : [b]
3558
- ];
3559
- json.allOf = allOf;
3560
- };
3561
- var recordProcessor = (schema, ctx, _json, params) => {
3562
- const json = _json;
3563
- const def = schema._zod.def;
3564
- json.type = "object";
3565
- const keyType = def.keyType;
3566
- const keyBag = keyType._zod.bag;
3567
- const patterns = keyBag?.patterns;
3568
- if (def.mode === "loose" && patterns && patterns.size > 0) {
3569
- const valueSchema = process2(def.valueType, ctx, {
3570
- ...params,
3571
- path: [...params.path, "patternProperties", "*"]
3572
- });
3573
- json.patternProperties = {};
3574
- for (const pattern of patterns) {
3575
- json.patternProperties[pattern.source] = valueSchema;
3576
- }
3577
- } else {
3578
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
3579
- json.propertyNames = process2(def.keyType, ctx, {
3580
- ...params,
3581
- path: [...params.path, "propertyNames"]
3582
- });
3583
- }
3584
- json.additionalProperties = process2(def.valueType, ctx, {
3585
- ...params,
3586
- path: [...params.path, "additionalProperties"]
3587
- });
3588
- }
3589
- const keyValues = keyType._zod.values;
3590
- if (keyValues) {
3591
- const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3592
- if (validKeyValues.length > 0) {
3593
- json.required = validKeyValues;
3594
- }
3595
- }
3596
- };
3597
- var nullableProcessor = (schema, ctx, json, params) => {
3598
- const def = schema._zod.def;
3599
- const inner = process2(def.innerType, ctx, params);
3600
- const seen = ctx.seen.get(schema);
3601
- if (ctx.target === "openapi-3.0") {
3602
- seen.ref = def.innerType;
3603
- json.nullable = true;
3604
- } else {
3605
- json.anyOf = [inner, { type: "null" }];
3606
- }
3607
- };
3608
- var nonoptionalProcessor = (schema, ctx, _json, params) => {
3609
- const def = schema._zod.def;
3610
- process2(def.innerType, ctx, params);
3611
- const seen = ctx.seen.get(schema);
3612
- seen.ref = def.innerType;
3613
- };
3614
- var defaultProcessor = (schema, ctx, json, params) => {
3615
- const def = schema._zod.def;
3616
- process2(def.innerType, ctx, params);
3617
- const seen = ctx.seen.get(schema);
3618
- seen.ref = def.innerType;
3619
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
3620
- };
3621
- var prefaultProcessor = (schema, ctx, json, params) => {
3622
- const def = schema._zod.def;
3623
- process2(def.innerType, ctx, params);
3624
- const seen = ctx.seen.get(schema);
3625
- seen.ref = def.innerType;
3626
- if (ctx.io === "input")
3627
- json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3628
- };
3629
- var catchProcessor = (schema, ctx, json, params) => {
3630
- const def = schema._zod.def;
3631
- process2(def.innerType, ctx, params);
3632
- const seen = ctx.seen.get(schema);
3633
- seen.ref = def.innerType;
3634
- let catchValue;
3635
- try {
3636
- catchValue = def.catchValue(undefined);
3637
- } catch {
3638
- throw new Error("Dynamic catch values are not supported in JSON Schema");
3639
- }
3640
- json.default = catchValue;
3641
- };
3642
- var pipeProcessor = (schema, ctx, _json, params) => {
3643
- const def = schema._zod.def;
3644
- const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3645
- process2(innerType, ctx, params);
3646
- const seen = ctx.seen.get(schema);
3647
- seen.ref = innerType;
3648
- };
3649
- var readonlyProcessor = (schema, ctx, json, params) => {
3650
- const def = schema._zod.def;
3651
- process2(def.innerType, ctx, params);
3652
- const seen = ctx.seen.get(schema);
3653
- seen.ref = def.innerType;
3654
- json.readOnly = true;
3655
- };
3656
- var optionalProcessor = (schema, ctx, _json, params) => {
3657
- const def = schema._zod.def;
3658
- process2(def.innerType, ctx, params);
3659
- const seen = ctx.seen.get(schema);
3660
- seen.ref = def.innerType;
3661
- };
3662
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/iso.js
3663
- var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
3664
- $ZodISODateTime.init(inst, def);
3665
- ZodStringFormat.init(inst, def);
3666
- });
3667
- function datetime2(params) {
3668
- return _isoDateTime(ZodISODateTime, params);
3669
- }
3670
- var ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
3671
- $ZodISODate.init(inst, def);
3672
- ZodStringFormat.init(inst, def);
3673
- });
3674
- function date2(params) {
3675
- return _isoDate(ZodISODate, params);
3676
- }
3677
- var ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
3678
- $ZodISOTime.init(inst, def);
3679
- ZodStringFormat.init(inst, def);
3680
- });
3681
- function time2(params) {
3682
- return _isoTime(ZodISOTime, params);
3683
- }
3684
- var ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
3685
- $ZodISODuration.init(inst, def);
3686
- ZodStringFormat.init(inst, def);
3687
- });
3688
- function duration2(params) {
3689
- return _isoDuration(ZodISODuration, params);
3690
- }
3691
-
3692
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/errors.js
3693
- var initializer2 = (inst, issues) => {
3694
- $ZodError.init(inst, issues);
3695
- inst.name = "ZodError";
3696
- Object.defineProperties(inst, {
3697
- format: {
3698
- value: (mapper) => formatError(inst, mapper)
3699
- },
3700
- flatten: {
3701
- value: (mapper) => flattenError(inst, mapper)
3702
- },
3703
- addIssue: {
3704
- value: (issue) => {
3705
- inst.issues.push(issue);
3706
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3707
- }
3708
- },
3709
- addIssues: {
3710
- value: (issues) => {
3711
- inst.issues.push(...issues);
3712
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3713
- }
3714
- },
3715
- isEmpty: {
3716
- get() {
3717
- return inst.issues.length === 0;
3718
- }
3719
- }
3720
- });
3721
- };
3722
- var ZodError = $constructor("ZodError", initializer2);
3723
- var ZodRealError = $constructor("ZodError", initializer2, {
3724
- Parent: Error
3725
- });
3726
-
3727
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/parse.js
3728
- var parse3 = /* @__PURE__ */ _parse(ZodRealError);
3729
- var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
3730
- var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
3731
- var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3732
- var encode = /* @__PURE__ */ _encode(ZodRealError);
3733
- var decode = /* @__PURE__ */ _decode(ZodRealError);
3734
- var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3735
- var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3736
- var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3737
- var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3738
- var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3739
- var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3740
-
3741
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
3742
- var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3743
- $ZodType.init(inst, def);
3744
- Object.assign(inst["~standard"], {
3745
- jsonSchema: {
3746
- input: createStandardJSONSchemaMethod(inst, "input"),
3747
- output: createStandardJSONSchemaMethod(inst, "output")
3748
- }
3749
- });
3750
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3751
- inst.def = def;
3752
- inst.type = def.type;
3753
- Object.defineProperty(inst, "_def", { value: def });
3754
- inst.check = (...checks) => {
3755
- return inst.clone(mergeDefs(def, {
3756
- checks: [
3757
- ...def.checks ?? [],
3758
- ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
3759
- ]
3760
- }), {
3761
- parent: true
3762
- });
3763
- };
3764
- inst.with = inst.check;
3765
- inst.clone = (def, params) => clone(inst, def, params);
3766
- inst.brand = () => inst;
3767
- inst.register = (reg, meta) => {
3768
- reg.add(inst, meta);
3769
- return inst;
3770
- };
3771
- inst.parse = (data, params) => parse3(inst, data, params, { callee: inst.parse });
3772
- inst.safeParse = (data, params) => safeParse2(inst, data, params);
3773
- inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
3774
- inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
3775
- inst.spa = inst.safeParseAsync;
3776
- inst.encode = (data, params) => encode(inst, data, params);
3777
- inst.decode = (data, params) => decode(inst, data, params);
3778
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3779
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3780
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3781
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3782
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3783
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3784
- inst.refine = (check, params) => inst.check(refine(check, params));
3785
- inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3786
- inst.overwrite = (fn) => inst.check(_overwrite(fn));
3787
- inst.optional = () => optional(inst);
3788
- inst.exactOptional = () => exactOptional(inst);
3789
- inst.nullable = () => nullable(inst);
3790
- inst.nullish = () => optional(nullable(inst));
3791
- inst.nonoptional = (params) => nonoptional(inst, params);
3792
- inst.array = () => array(inst);
3793
- inst.or = (arg) => union([inst, arg]);
3794
- inst.and = (arg) => intersection(inst, arg);
3795
- inst.transform = (tx) => pipe(inst, transform(tx));
3796
- inst.default = (def) => _default(inst, def);
3797
- inst.prefault = (def) => prefault(inst, def);
3798
- inst.catch = (params) => _catch(inst, params);
3799
- inst.pipe = (target) => pipe(inst, target);
3800
- inst.readonly = () => readonly(inst);
3801
- inst.describe = (description) => {
3802
- const cl = inst.clone();
3803
- globalRegistry.add(cl, { description });
3804
- return cl;
3805
- };
3806
- Object.defineProperty(inst, "description", {
3807
- get() {
3808
- return globalRegistry.get(inst)?.description;
3809
- },
3810
- configurable: true
3811
- });
3812
- inst.meta = (...args) => {
3813
- if (args.length === 0) {
3814
- return globalRegistry.get(inst);
3815
- }
3816
- const cl = inst.clone();
3817
- globalRegistry.add(cl, args[0]);
3818
- return cl;
3819
- };
3820
- inst.isOptional = () => inst.safeParse(undefined).success;
3821
- inst.isNullable = () => inst.safeParse(null).success;
3822
- inst.apply = (fn) => fn(inst);
3823
- return inst;
3824
- });
3825
- var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
3826
- $ZodString.init(inst, def);
3827
- ZodType.init(inst, def);
3828
- inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3829
- const bag = inst._zod.bag;
3830
- inst.format = bag.format ?? null;
3831
- inst.minLength = bag.minimum ?? null;
3832
- inst.maxLength = bag.maximum ?? null;
3833
- inst.regex = (...args) => inst.check(_regex(...args));
3834
- inst.includes = (...args) => inst.check(_includes(...args));
3835
- inst.startsWith = (...args) => inst.check(_startsWith(...args));
3836
- inst.endsWith = (...args) => inst.check(_endsWith(...args));
3837
- inst.min = (...args) => inst.check(_minLength(...args));
3838
- inst.max = (...args) => inst.check(_maxLength(...args));
3839
- inst.length = (...args) => inst.check(_length(...args));
3840
- inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
3841
- inst.lowercase = (params) => inst.check(_lowercase(params));
3842
- inst.uppercase = (params) => inst.check(_uppercase(params));
3843
- inst.trim = () => inst.check(_trim());
3844
- inst.normalize = (...args) => inst.check(_normalize(...args));
3845
- inst.toLowerCase = () => inst.check(_toLowerCase());
3846
- inst.toUpperCase = () => inst.check(_toUpperCase());
3847
- inst.slugify = () => inst.check(_slugify());
3848
- });
3849
- var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
3850
- $ZodString.init(inst, def);
3851
- _ZodString.init(inst, def);
3852
- inst.email = (params) => inst.check(_email(ZodEmail, params));
3853
- inst.url = (params) => inst.check(_url(ZodURL, params));
3854
- inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
3855
- inst.emoji = (params) => inst.check(_emoji2(ZodEmoji, params));
3856
- inst.guid = (params) => inst.check(_guid(ZodGUID, params));
3857
- inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
3858
- inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
3859
- inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
3860
- inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
3861
- inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
3862
- inst.guid = (params) => inst.check(_guid(ZodGUID, params));
3863
- inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
3864
- inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
3865
- inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
3866
- inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
3867
- inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
3868
- inst.xid = (params) => inst.check(_xid(ZodXID, params));
3869
- inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
3870
- inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
3871
- inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
3872
- inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
3873
- inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
3874
- inst.e164 = (params) => inst.check(_e164(ZodE164, params));
3875
- inst.datetime = (params) => inst.check(datetime2(params));
3876
- inst.date = (params) => inst.check(date2(params));
3877
- inst.time = (params) => inst.check(time2(params));
3878
- inst.duration = (params) => inst.check(duration2(params));
3879
- });
3880
- function string2(params) {
3881
- return _string(ZodString, params);
3882
- }
3883
- var ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
3884
- $ZodStringFormat.init(inst, def);
3885
- _ZodString.init(inst, def);
3886
- });
3887
- var ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
3888
- $ZodEmail.init(inst, def);
3889
- ZodStringFormat.init(inst, def);
3890
- });
3891
- var ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
3892
- $ZodGUID.init(inst, def);
3893
- ZodStringFormat.init(inst, def);
3894
- });
3895
- var ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
3896
- $ZodUUID.init(inst, def);
3897
- ZodStringFormat.init(inst, def);
3898
- });
3899
- var ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
3900
- $ZodURL.init(inst, def);
3901
- ZodStringFormat.init(inst, def);
3902
- });
3903
- function url(params) {
3904
- return _url(ZodURL, params);
3905
- }
3906
- var ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
3907
- $ZodEmoji.init(inst, def);
3908
- ZodStringFormat.init(inst, def);
3909
- });
3910
- var ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
3911
- $ZodNanoID.init(inst, def);
3912
- ZodStringFormat.init(inst, def);
3913
- });
3914
- var ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
3915
- $ZodCUID.init(inst, def);
3916
- ZodStringFormat.init(inst, def);
3917
- });
3918
- var ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
3919
- $ZodCUID2.init(inst, def);
3920
- ZodStringFormat.init(inst, def);
3921
- });
3922
- var ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
3923
- $ZodULID.init(inst, def);
3924
- ZodStringFormat.init(inst, def);
3925
- });
3926
- var ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
3927
- $ZodXID.init(inst, def);
3928
- ZodStringFormat.init(inst, def);
3929
- });
3930
- var ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
3931
- $ZodKSUID.init(inst, def);
3932
- ZodStringFormat.init(inst, def);
3933
- });
3934
- var ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
3935
- $ZodIPv4.init(inst, def);
3936
- ZodStringFormat.init(inst, def);
3937
- });
3938
- var ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
3939
- $ZodIPv6.init(inst, def);
3940
- ZodStringFormat.init(inst, def);
3941
- });
3942
- var ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
3943
- $ZodCIDRv4.init(inst, def);
3944
- ZodStringFormat.init(inst, def);
3945
- });
3946
- var ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
3947
- $ZodCIDRv6.init(inst, def);
3948
- ZodStringFormat.init(inst, def);
3949
- });
3950
- var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
3951
- $ZodBase64.init(inst, def);
3952
- ZodStringFormat.init(inst, def);
3953
- });
3954
- var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
3955
- $ZodBase64URL.init(inst, def);
3956
- ZodStringFormat.init(inst, def);
3957
- });
3958
- var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
3959
- $ZodE164.init(inst, def);
3960
- ZodStringFormat.init(inst, def);
3961
- });
3962
- var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
3963
- $ZodJWT.init(inst, def);
3964
- ZodStringFormat.init(inst, def);
3965
- });
3966
- var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
3967
- $ZodNumber.init(inst, def);
3968
- ZodType.init(inst, def);
3969
- inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3970
- inst.gt = (value, params) => inst.check(_gt(value, params));
3971
- inst.gte = (value, params) => inst.check(_gte(value, params));
3972
- inst.min = (value, params) => inst.check(_gte(value, params));
3973
- inst.lt = (value, params) => inst.check(_lt(value, params));
3974
- inst.lte = (value, params) => inst.check(_lte(value, params));
3975
- inst.max = (value, params) => inst.check(_lte(value, params));
3976
- inst.int = (params) => inst.check(int(params));
3977
- inst.safe = (params) => inst.check(int(params));
3978
- inst.positive = (params) => inst.check(_gt(0, params));
3979
- inst.nonnegative = (params) => inst.check(_gte(0, params));
3980
- inst.negative = (params) => inst.check(_lt(0, params));
3981
- inst.nonpositive = (params) => inst.check(_lte(0, params));
3982
- inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
3983
- inst.step = (value, params) => inst.check(_multipleOf(value, params));
3984
- inst.finite = () => inst;
3985
- const bag = inst._zod.bag;
3986
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3987
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
3988
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
3989
- inst.isFinite = true;
3990
- inst.format = bag.format ?? null;
3991
- });
3992
- function number2(params) {
3993
- return _number(ZodNumber, params);
3994
- }
3995
- var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
3996
- $ZodNumberFormat.init(inst, def);
3997
- ZodNumber.init(inst, def);
3998
- });
3999
- function int(params) {
4000
- return _int(ZodNumberFormat, params);
4001
- }
4002
- var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
4003
- $ZodBoolean.init(inst, def);
4004
- ZodType.init(inst, def);
4005
- inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
4006
- });
4007
- function boolean2(params) {
4008
- return _boolean(ZodBoolean, params);
4009
- }
4010
- var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
4011
- $ZodUnknown.init(inst, def);
4012
- ZodType.init(inst, def);
4013
- inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
4014
- });
4015
- function unknown() {
4016
- return _unknown(ZodUnknown);
4017
- }
4018
- var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
4019
- $ZodNever.init(inst, def);
4020
- ZodType.init(inst, def);
4021
- inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
4022
- });
4023
- function never(params) {
4024
- return _never(ZodNever, params);
4025
- }
4026
- var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
4027
- $ZodArray.init(inst, def);
4028
- ZodType.init(inst, def);
4029
- inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4030
- inst.element = def.element;
4031
- inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
4032
- inst.nonempty = (params) => inst.check(_minLength(1, params));
4033
- inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
4034
- inst.length = (len, params) => inst.check(_length(len, params));
4035
- inst.unwrap = () => inst.element;
4036
- });
4037
- function array(element, params) {
4038
- return _array(ZodArray, element, params);
4039
- }
4040
- var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
4041
- $ZodObjectJIT.init(inst, def);
4042
- ZodType.init(inst, def);
4043
- inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4044
- defineLazy(inst, "shape", () => {
4045
- return def.shape;
4046
- });
4047
- inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
4048
- inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
4049
- inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
4050
- inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
4051
- inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
4052
- inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
4053
- inst.extend = (incoming) => {
4054
- return extend(inst, incoming);
4055
- };
4056
- inst.safeExtend = (incoming) => {
4057
- return safeExtend(inst, incoming);
4058
- };
4059
- inst.merge = (other) => merge(inst, other);
4060
- inst.pick = (mask) => pick(inst, mask);
4061
- inst.omit = (mask) => omit(inst, mask);
4062
- inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
4063
- inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
4064
- });
4065
- function object(shape, params) {
4066
- const def = {
4067
- type: "object",
4068
- shape: shape ?? {},
4069
- ...normalizeParams(params)
4070
- };
4071
- return new ZodObject(def);
4072
- }
4073
- function strictObject(shape, params) {
4074
- return new ZodObject({
4075
- type: "object",
4076
- shape,
4077
- catchall: never(),
4078
- ...normalizeParams(params)
4079
- });
4080
- }
4081
- function looseObject(shape, params) {
4082
- return new ZodObject({
4083
- type: "object",
4084
- shape,
4085
- catchall: unknown(),
4086
- ...normalizeParams(params)
4087
- });
4088
- }
4089
- var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
4090
- $ZodUnion.init(inst, def);
4091
- ZodType.init(inst, def);
4092
- inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
4093
- inst.options = def.options;
4094
- });
4095
- function union(options, params) {
4096
- return new ZodUnion({
4097
- type: "union",
4098
- options,
4099
- ...normalizeParams(params)
4100
- });
4101
- }
4102
- var ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
4103
- ZodUnion.init(inst, def);
4104
- $ZodDiscriminatedUnion.init(inst, def);
4105
- });
4106
- function discriminatedUnion(discriminator, options, params) {
4107
- return new ZodDiscriminatedUnion({
4108
- type: "union",
4109
- options,
4110
- discriminator,
4111
- ...normalizeParams(params)
4112
- });
4113
- }
4114
- var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
4115
- $ZodIntersection.init(inst, def);
4116
- ZodType.init(inst, def);
4117
- inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
4118
- });
4119
- function intersection(left, right) {
4120
- return new ZodIntersection({
4121
- type: "intersection",
4122
- left,
4123
- right
4124
- });
4125
- }
4126
- var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
4127
- $ZodRecord.init(inst, def);
4128
- ZodType.init(inst, def);
4129
- inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
4130
- inst.keyType = def.keyType;
4131
- inst.valueType = def.valueType;
4132
- });
4133
- function record(keyType, valueType, params) {
4134
- return new ZodRecord({
4135
- type: "record",
4136
- keyType,
4137
- valueType,
4138
- ...normalizeParams(params)
4139
- });
4140
- }
4141
- var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
4142
- $ZodEnum.init(inst, def);
4143
- ZodType.init(inst, def);
4144
- inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
4145
- inst.enum = def.entries;
4146
- inst.options = Object.values(def.entries);
4147
- const keys = new Set(Object.keys(def.entries));
4148
- inst.extract = (values, params) => {
4149
- const newEntries = {};
4150
- for (const value of values) {
4151
- if (keys.has(value)) {
4152
- newEntries[value] = def.entries[value];
4153
- } else
4154
- throw new Error(`Key ${value} not found in enum`);
4155
- }
4156
- return new ZodEnum({
4157
- ...def,
4158
- checks: [],
4159
- ...normalizeParams(params),
4160
- entries: newEntries
4161
- });
4162
- };
4163
- inst.exclude = (values, params) => {
4164
- const newEntries = { ...def.entries };
4165
- for (const value of values) {
4166
- if (keys.has(value)) {
4167
- delete newEntries[value];
4168
- } else
4169
- throw new Error(`Key ${value} not found in enum`);
4170
- }
4171
- return new ZodEnum({
4172
- ...def,
4173
- checks: [],
4174
- ...normalizeParams(params),
4175
- entries: newEntries
4176
- });
4177
- };
4178
- });
4179
- function _enum(values, params) {
4180
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
4181
- return new ZodEnum({
4182
- type: "enum",
4183
- entries,
4184
- ...normalizeParams(params)
4185
- });
4186
- }
4187
- var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
4188
- $ZodLiteral.init(inst, def);
4189
- ZodType.init(inst, def);
4190
- inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
4191
- inst.values = new Set(def.values);
4192
- Object.defineProperty(inst, "value", {
4193
- get() {
4194
- if (def.values.length > 1) {
4195
- throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
4196
- }
4197
- return def.values[0];
4198
- }
4199
- });
4200
- });
4201
- function literal(value, params) {
4202
- return new ZodLiteral({
4203
- type: "literal",
4204
- values: Array.isArray(value) ? value : [value],
4205
- ...normalizeParams(params)
4206
- });
4207
- }
4208
- var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
4209
- $ZodTransform.init(inst, def);
4210
- ZodType.init(inst, def);
4211
- inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
4212
- inst._zod.parse = (payload, _ctx) => {
4213
- if (_ctx.direction === "backward") {
4214
- throw new $ZodEncodeError(inst.constructor.name);
4215
- }
4216
- payload.addIssue = (issue2) => {
4217
- if (typeof issue2 === "string") {
4218
- payload.issues.push(issue(issue2, payload.value, def));
4219
- } else {
4220
- const _issue = issue2;
4221
- if (_issue.fatal)
4222
- _issue.continue = false;
4223
- _issue.code ?? (_issue.code = "custom");
4224
- _issue.input ?? (_issue.input = payload.value);
4225
- _issue.inst ?? (_issue.inst = inst);
4226
- payload.issues.push(issue(_issue));
4227
- }
4228
- };
4229
- const output = def.transform(payload.value, payload);
4230
- if (output instanceof Promise) {
4231
- return output.then((output) => {
4232
- payload.value = output;
4233
- return payload;
4234
- });
4235
- }
4236
- payload.value = output;
4237
- return payload;
4238
- };
4239
- });
4240
- function transform(fn) {
4241
- return new ZodTransform({
4242
- type: "transform",
4243
- transform: fn
4244
- });
4245
- }
4246
- var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
4247
- $ZodOptional.init(inst, def);
4248
- ZodType.init(inst, def);
4249
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4250
- inst.unwrap = () => inst._zod.def.innerType;
4251
- });
4252
- function optional(innerType) {
4253
- return new ZodOptional({
4254
- type: "optional",
4255
- innerType
4256
- });
4257
- }
4258
- var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
4259
- $ZodExactOptional.init(inst, def);
4260
- ZodType.init(inst, def);
4261
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4262
- inst.unwrap = () => inst._zod.def.innerType;
4263
- });
4264
- function exactOptional(innerType) {
4265
- return new ZodExactOptional({
4266
- type: "optional",
4267
- innerType
4268
- });
4269
- }
4270
- var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
4271
- $ZodNullable.init(inst, def);
4272
- ZodType.init(inst, def);
4273
- inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4274
- inst.unwrap = () => inst._zod.def.innerType;
4275
- });
4276
- function nullable(innerType) {
4277
- return new ZodNullable({
4278
- type: "nullable",
4279
- innerType
4280
- });
4281
- }
4282
- var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
4283
- $ZodDefault.init(inst, def);
4284
- ZodType.init(inst, def);
4285
- inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4286
- inst.unwrap = () => inst._zod.def.innerType;
4287
- inst.removeDefault = inst.unwrap;
4288
- });
4289
- function _default(innerType, defaultValue) {
4290
- return new ZodDefault({
4291
- type: "default",
4292
- innerType,
4293
- get defaultValue() {
4294
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4295
- }
4296
- });
4297
- }
4298
- var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
4299
- $ZodPrefault.init(inst, def);
4300
- ZodType.init(inst, def);
4301
- inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4302
- inst.unwrap = () => inst._zod.def.innerType;
4303
- });
4304
- function prefault(innerType, defaultValue) {
4305
- return new ZodPrefault({
4306
- type: "prefault",
4307
- innerType,
4308
- get defaultValue() {
4309
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4310
- }
4311
- });
4312
- }
4313
- var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
4314
- $ZodNonOptional.init(inst, def);
4315
- ZodType.init(inst, def);
4316
- inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4317
- inst.unwrap = () => inst._zod.def.innerType;
4318
- });
4319
- function nonoptional(innerType, params) {
4320
- return new ZodNonOptional({
4321
- type: "nonoptional",
4322
- innerType,
4323
- ...normalizeParams(params)
4324
- });
4325
- }
4326
- var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
4327
- $ZodCatch.init(inst, def);
4328
- ZodType.init(inst, def);
4329
- inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4330
- inst.unwrap = () => inst._zod.def.innerType;
4331
- inst.removeCatch = inst.unwrap;
4332
- });
4333
- function _catch(innerType, catchValue) {
4334
- return new ZodCatch({
4335
- type: "catch",
4336
- innerType,
4337
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
4338
- });
4339
- }
4340
- var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
4341
- $ZodPipe.init(inst, def);
4342
- ZodType.init(inst, def);
4343
- inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4344
- inst.in = def.in;
4345
- inst.out = def.out;
4346
- });
4347
- function pipe(in_, out) {
4348
- return new ZodPipe({
4349
- type: "pipe",
4350
- in: in_,
4351
- out
4352
- });
4353
- }
4354
- var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
4355
- $ZodReadonly.init(inst, def);
4356
- ZodType.init(inst, def);
4357
- inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4358
- inst.unwrap = () => inst._zod.def.innerType;
4359
- });
4360
- function readonly(innerType) {
4361
- return new ZodReadonly({
4362
- type: "readonly",
4363
- innerType
4364
- });
4365
- }
4366
- var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4367
- $ZodCustom.init(inst, def);
4368
- ZodType.init(inst, def);
4369
- inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
4370
- });
4371
- function custom(fn, _params) {
4372
- return _custom(ZodCustom, fn ?? (() => true), _params);
4373
- }
4374
- function refine(fn, _params = {}) {
4375
- return _refine(ZodCustom, fn, _params);
4376
- }
4377
- function superRefine(fn) {
4378
- return _superRefine(fn);
4379
- }
4380
- // ../envoy-client/src/errors.ts
4381
- function messageFor(error) {
4382
- return error instanceof Error ? error.message : String(error);
4383
- }
4384
-
4385
- // ../envoy-client/src/dispatch-config.ts
4386
- var DEFAULT_SERVER_URL = "http://localhost:8766";
4387
- var EnvoyFileSchema = looseObject({
4388
- $schema: string2().optional(),
4389
- natsUrls: array(string2()).optional(),
4390
- dispatch: strictObject({
4391
- enabled: boolean2().optional(),
4392
- serverUrl: url().optional()
4393
- }).optional()
4394
- });
4395
- function describeSchemaIssue(filePath, error) {
4396
- const issue = error.issues[0];
4397
- if (!issue)
4398
- return `${filePath}: invalid dispatch config`;
4399
- if (issue.code === "unrecognized_keys") {
4400
- const keys = issue.keys.map((key) => `dispatch.${key}`).join(", ");
4401
- return `${filePath}: unrecognized dispatch key(s): ${keys}`;
4402
- }
4403
- return `${filePath}: ${issue.path.join(".")}: ${issue.message}`;
4404
- }
4405
- function readEnvoyFile(filePath) {
4406
- let raw;
4407
- try {
4408
- raw = readFileSync(filePath, "utf-8");
4409
- } catch {
4410
- return { kind: "absent" };
4411
- }
4412
- let parsedJson;
4413
- try {
4414
- parsedJson = JSON.parse(raw);
4415
- } catch (err) {
4416
- return { kind: "invalid", reason: `${filePath}: invalid JSON (${messageFor(err)})` };
4417
- }
4418
- const parsed = EnvoyFileSchema.safeParse(parsedJson);
4419
- if (!parsed.success) {
4420
- return { kind: "invalid", reason: describeSchemaIssue(filePath, parsed.error) };
4421
- }
4422
- return { kind: "valid", settings: parsed.data.dispatch ?? null };
4423
- }
4424
- function resolveDispatchConfig(env, options = {}) {
4425
- const explicit = env["DISPATCH_MCP_URL"];
4426
- if (explicit)
4427
- return { url: explicit, error: null };
4428
- const home = options.home ?? homedir();
4429
- const cwd = options.cwd ?? process.cwd();
4430
- const userFile = readEnvoyFile(path.join(home, ".config", "opencode", "envoy.json"));
4431
- const repoFile = readEnvoyFile(path.join(cwd, ".opencode", "envoy.json"));
4432
- for (const file of [userFile, repoFile]) {
4433
- if (file.kind === "invalid")
4434
- return { url: null, error: file.reason };
4435
- }
4436
- const merged = {
4437
- ...userFile.kind === "valid" ? userFile.settings : null,
4438
- ...repoFile.kind === "valid" ? repoFile.settings : null
4439
- };
4440
- if (merged.enabled !== true)
4441
- return { url: null, error: null };
4442
- const baseUrl = (merged.serverUrl ?? DEFAULT_SERVER_URL).replace(/\/+$/, "");
4443
- return { url: `${baseUrl}/mcp`, error: null };
4444
- }
4445
-
4446
- // ../envoy-client/src/dispatch-cwd.ts
4447
- import { execFile } from "child_process";
4448
- import { promisify } from "util";
4449
-
4450
- // ../envoy-client/src/machine.ts
4451
- import { hostname } from "os";
4452
- function machineID() {
4453
- return process.env["ENVOY_MACHINE_ID"] || hostname();
4454
- }
4455
-
4456
- // ../envoy-client/src/dispatch-cwd.ts
4457
- var execFileAsync = promisify(execFile);
4458
- var defaultExec = (file, args, options) => execFileAsync(file, args, { cwd: options.cwd, timeout: 5000 });
4459
- async function tryExec(exec, file, args, cwd) {
4460
- try {
4461
- const { stdout } = await exec(file, args, { cwd });
4462
- return stdout;
4463
- } catch {
4464
- return null;
4465
- }
4466
- }
4467
- function parseRemoteList(stdout) {
4468
- const remotes = new Map;
4469
- for (const line of stdout.split(`
4470
- `)) {
4471
- const trimmed = line.trim();
4472
- if (!trimmed)
4473
- continue;
4474
- const match = trimmed.match(/^(\S+)\s+(\S+)/);
4475
- const [, name, url] = match ?? [];
4476
- if (name && url)
4477
- remotes.set(name, url);
4478
- }
4479
- return remotes;
4480
- }
4481
- function selectRemoteUrl(remotes) {
4482
- const origin = remotes.get("origin");
4483
- if (origin)
4484
- return origin;
4485
- const candidates = [...remotes.entries()].filter(([name]) => name !== "upstream");
4486
- return candidates.length === 1 ? candidates[0]?.[1] ?? null : null;
4487
- }
4488
- var GITHUB_REMOTE_PATTERNS = [
4489
- /^https:\/\/(?:[^@/\s]+@)?github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/i,
4490
- /^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?\/?$/i,
4491
- /^ssh:\/\/git@github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/i
4492
- ];
4493
- function parseGitHubRemoteUrl(url) {
4494
- const trimmed = url.trim();
4495
- for (const pattern of GITHUB_REMOTE_PATTERNS) {
4496
- const match = trimmed.match(pattern);
4497
- if (match)
4498
- return `${match[1]}/${match[2]}`;
4499
- }
4500
- return null;
4501
- }
4502
- async function resolveCwdRepo(cwd, exec) {
4503
- const jjOutput = await tryExec(exec, "jj", ["git", "remote", "list"], cwd);
4504
- if (jjOutput !== null) {
4505
- const url = selectRemoteUrl(parseRemoteList(jjOutput));
4506
- return url ? parseGitHubRemoteUrl(url) : null;
4507
- }
4508
- const originUrl = await tryExec(exec, "git", ["remote", "get-url", "origin"], cwd);
4509
- return originUrl ? parseGitHubRemoteUrl(originUrl) : null;
4510
- }
4511
- async function resolveOrigin(env, exec, cwd) {
4512
- const origin = {
4513
- cwd,
4514
- machine: machineID()
4515
- };
4516
- if (env["OMP_SESSION_ID"] || env["OMPCODE"]) {
4517
- origin.host = "omp";
4518
- } else if (env["CLAUDECODE"]) {
4519
- origin.host = "claude";
4520
- }
4521
- const pane = env["TMUX_PANE"];
4522
- if (pane) {
4523
- const output = await tryExec(exec, "tmux", ["display-message", "-p", "-t", pane, "#S:#I.#P #{pane_id}"], cwd);
4524
- const [target, paneId] = output?.trim().split(" ") ?? [];
4525
- if (target)
4526
- origin.tmux = target;
4527
- if (paneId)
4528
- origin.pane = paneId;
4529
- }
4530
- return origin;
4531
- }
4532
-
4533
- // ../envoy-client/src/dispatch-mcp-bridge.ts
4534
- import { execFile as execFile2 } from "child_process";
4535
- import { promisify as promisify2 } from "util";
4536
- var execFileAsync2 = promisify2(execFile2);
4537
- var DEFAULT_TOKEN_CACHE_TTL_MS = 50 * 60 * 1000;
4538
- var defaultGhTokenGetter = async () => {
4539
- try {
4540
- const { stdout } = await execFileAsync2("gh", ["auth", "token"], {
4541
- timeout: 5000
4542
- });
4543
- const value = stdout.trim();
4544
- return value.length > 0 ? value : null;
4545
- } catch {
4546
- return null;
4547
- }
4548
- };
4549
- function parseSseBody(body) {
4550
- for (const line of body.split(`
4551
- `)) {
4552
- const payload = line.match(/^data:\s*(.+)$/)?.[1];
4553
- if (payload !== undefined) {
4554
- return JSON.parse(payload);
4555
- }
4556
- }
4557
- return null;
4558
- }
4559
- function hasUpstreamUnauthorized(parsed) {
4560
- if (!parsed || typeof parsed !== "object")
4561
- return false;
4562
- if ("error" in parsed && parsed.error && typeof parsed.error === "object") {
4563
- const { error } = parsed;
4564
- if ("message" in error && typeof error.message === "string") {
4565
- if (containsUnauthorized(error.message))
4566
- return true;
4567
- }
4568
- }
4569
- if (!("result" in parsed) || !parsed.result || typeof parsed.result !== "object")
4570
- return false;
4571
- const { result } = parsed;
4572
- if (!("isError" in result) || result.isError !== true)
4573
- return false;
4574
- if (!("content" in result) || !isUnknownArray(result.content))
4575
- return false;
4576
- for (const item of result.content) {
4577
- if (item && typeof item === "object" && "text" in item && typeof item.text === "string") {
4578
- if (containsUnauthorized(item.text))
4579
- return true;
4580
- }
4581
- }
4582
- return false;
4583
- }
4584
- function containsUnauthorized(msg) {
4585
- return /\b401\b/.test(msg) && /bad credentials|unauthorized/i.test(msg);
4586
- }
4587
- function isUnknownArray(value) {
4588
- return Array.isArray(value);
4589
- }
4590
- function normalizeSchemaUnionTypes(node) {
4591
- if (isUnknownArray(node))
4592
- return node.map(normalizeSchemaUnionTypes);
4593
- if (!node || typeof node !== "object")
4594
- return node;
4595
- const result = {};
4596
- for (const [key, value] of Object.entries(node)) {
4597
- result[key] = normalizeSchemaUnionTypes(value);
4598
- }
4599
- if (isUnknownArray(result["type"])) {
4600
- const nonNull = result["type"].filter((entry) => entry !== "null");
4601
- if (nonNull.length === 1) {
4602
- result["type"] = nonNull[0];
4603
- } else if (nonNull.length === 0) {
4604
- result["type"] = "null";
4605
- } else {
4606
- const items = result["items"];
4607
- delete result["items"];
4608
- result["anyOf"] = nonNull.map((t) => t === "array" && items != null ? { type: t, items } : { type: t });
4609
- delete result["type"];
4610
- }
4611
- }
4612
- return result;
4613
- }
4614
- function normalizeToolsListResponse(response) {
4615
- if (!response || typeof response.result !== "object" || response.result === null)
4616
- return response;
4617
- const { result } = response;
4618
- if (!("tools" in result) || !isUnknownArray(result.tools))
4619
- return response;
4620
- const tools = result.tools.map((entry) => {
4621
- if (!entry || typeof entry !== "object")
4622
- return entry;
4623
- if (!("inputSchema" in entry) || entry.inputSchema == null)
4624
- return entry;
4625
- if (typeof entry.inputSchema !== "object")
4626
- return entry;
4627
- return { ...entry, inputSchema: normalizeSchemaUnionTypes(entry.inputSchema) };
4628
- });
4629
- return { ...response, result: { ...result, tools } };
4630
- }
4631
- function finalizeResponse(request, response) {
4632
- return request.method === "tools/list" ? normalizeToolsListResponse(response) : response;
4633
- }
4634
- function createBridge(opts) {
4635
- const remoteUrl = opts.remoteUrl;
4636
- const getToken = opts.getToken;
4637
- const fetchImpl = opts.fetchImpl ?? fetch;
4638
- const ttl = opts.tokenCacheTtlMs ?? DEFAULT_TOKEN_CACHE_TTL_MS;
4639
- const now = opts.now ?? Date.now;
4640
- const log = opts.logError ?? ((m) => process.stderr.write(`${m}
4641
- `));
4642
- let cachedToken = null;
4643
- let sessionId = null;
4644
- async function token(force) {
4645
- if (!force && cachedToken && now() - cachedToken.fetchedAt < ttl) {
4646
- return cachedToken.value;
4647
- }
4648
- const value = await getToken();
4649
- if (value) {
4650
- cachedToken = { value, fetchedAt: now() };
4651
- } else {
4652
- cachedToken = null;
4653
- }
4654
- return value;
4655
- }
4656
- function errorResponse(id, code, message) {
4657
- if (id === undefined || id === null)
4658
- return null;
4659
- return { jsonrpc: "2.0", id, error: { code, message } };
4660
- }
4661
- async function attempt(request, forceRefresh) {
4662
- const bearer = await token(forceRefresh);
4663
- if (!bearer) {
4664
- return {
4665
- kind: "err",
4666
- response: errorResponse(request.id, -32000, "envoy-dispatch shim: gh auth token returned empty \u2014 check your gh-app setup")
4667
- };
4668
- }
4669
- const headers = {
4670
- Authorization: `Bearer ${bearer}`,
4671
- "Content-Type": "application/json",
4672
- Accept: "application/json, text/event-stream"
4673
- };
4674
- if (sessionId)
4675
- headers["Mcp-Session-Id"] = sessionId;
4676
- let response;
4677
- try {
4678
- response = await fetchImpl(remoteUrl, {
4679
- method: "POST",
4680
- headers,
4681
- body: JSON.stringify(request)
4682
- });
4683
- } catch (err) {
4684
- const msg = messageFor(err);
4685
- return {
4686
- kind: "err",
4687
- response: errorResponse(request.id, -32603, `envoy-dispatch shim network error: ${msg}`)
4688
- };
4689
- }
4690
- if (response.status === 401 && !forceRefresh) {
4691
- return { kind: "retry" };
4692
- }
4693
- const respSession = response.headers.get("mcp-session-id");
4694
- if (respSession)
4695
- sessionId = respSession;
4696
- if (!response.ok) {
4697
- const body = await response.text().catch(() => "");
4698
- const remoteError = [
4699
- "envoy-dispatch shim: remote",
4700
- response.status,
4701
- response.statusText,
4702
- body.slice(0, 200)
4703
- ].join(" ");
4704
- return {
4705
- kind: "err",
4706
- response: errorResponse(request.id, -32603, remoteError)
4707
- };
4708
- }
4709
- if (request.id === undefined || request.id === null) {
4710
- return { kind: "ok", response: null };
4711
- }
4712
- const body = await response.text();
4713
- const ct = response.headers.get("content-type") ?? "";
4714
- try {
4715
- const parsed = ct.includes("text/event-stream") ? parseSseBody(body) : JSON.parse(body);
4716
- if (parsed && typeof parsed === "object") {
4717
- if (!forceRefresh && hasUpstreamUnauthorized(parsed)) {
4718
- return { kind: "retry" };
4719
- }
4720
- return { kind: "ok", response: parsed };
4721
- }
4722
- return {
4723
- kind: "err",
4724
- response: errorResponse(request.id, -32603, "envoy-dispatch shim: empty/invalid response body")
4725
- };
4726
- } catch (err) {
4727
- const msg = messageFor(err);
4728
- return {
4729
- kind: "err",
4730
- response: errorResponse(request.id, -32603, `envoy-dispatch shim: parse error: ${msg}`)
4731
- };
4732
- }
4733
- }
4734
- return {
4735
- async handle(request) {
4736
- const first = await attempt(request, false);
4737
- if (first.kind === "ok" || first.kind === "err")
4738
- return finalizeResponse(request, first.response);
4739
- log("envoy-dispatch shim: 401 from remote, re-minting token and retrying once");
4740
- const second = await attempt(request, true);
4741
- return finalizeResponse(request, second.kind === "retry" ? null : second.response);
4742
- }
4743
- };
4744
- }
4745
-
4746
- // ../envoy-client/src/dispatch-mcp-shim.ts
4747
- function isJsonRpcRequest(value) {
4748
- if (typeof value !== "object" || value === null)
4749
- return false;
4750
- if (!("jsonrpc" in value) || value.jsonrpc !== "2.0")
4751
- return false;
4752
- if (!("method" in value) || typeof value.method !== "string")
4753
- return false;
4754
- if (!("id" in value))
4755
- return true;
4756
- return value.id === null || typeof value.id === "string" || typeof value.id === "number";
4757
- }
4758
- function dispatchShimGate(env, options = {}) {
4759
- const { url: remoteUrl, error } = resolveDispatchConfig(env, options);
4760
- if (remoteUrl === null) {
4761
- return {
4762
- serve: false,
4763
- reason: error ?? "dispatch is not enabled \u2014 set dispatch.enabled in envoy.json or DISPATCH_MCP_URL"
4764
- };
4765
- }
4766
- return { serve: true, remoteUrl };
4767
- }
4768
- var QUALIFIED_PARENT_RE = /^[^/\s#]+\/[^/\s#]+#\d+/;
4769
- function dispatchCallParams(request) {
4770
- if (request.method !== "tools/call")
4771
- return null;
4772
- return isDispatchToolCallParams(request.params) ? request.params : null;
4773
- }
4774
- function isDispatchToolCallParams(params) {
4775
- if (typeof params !== "object" || params === null)
4776
- return false;
4777
- if (!("name" in params) || params.name !== "dispatch")
4778
- return false;
4779
- const args = "arguments" in params ? params.arguments : undefined;
4780
- return args === undefined || typeof args === "object" && args !== null && !Array.isArray(args);
4781
- }
4782
- function injectDispatchArgs(request, context) {
4783
- const params = dispatchCallParams(request);
4784
- if (params === null)
4785
- return { kind: "forward", request };
4786
- const args = { ...params.arguments };
4787
- const parent = typeof args["parent"] === "string" ? args["parent"] : undefined;
4788
- const hasQualifiedParent = parent !== undefined && QUALIFIED_PARENT_RE.test(parent);
4789
- if (args["repo"] === undefined && !hasQualifiedParent) {
4790
- if (context.repo === null) {
4791
- return {
4792
- kind: "reply",
4793
- response: {
4794
- jsonrpc: "2.0",
4795
- id: request.id ?? null,
4796
- result: {
4797
- isError: true,
4798
- content: [
4799
- {
4800
- type: "text",
4801
- text: `dispatch: ${context.origin.cwd} has no GitHub remote; pass repo=owner/name`
4802
- }
4803
- ]
4804
- }
4805
- }
4806
- };
4807
- }
4808
- args["repo"] = context.repo;
4809
- }
4810
- if (args["origin"] === undefined) {
4811
- args["origin"] = context.origin;
4812
- }
4813
- return {
4814
- kind: "forward",
4815
- request: { ...request, params: { ...params, arguments: args } }
4816
- };
4817
- }
4818
- function runDispatchMcpShim() {
4819
- const gate = dispatchShimGate(process.env);
4820
- if (!gate.serve) {
4821
- process.stderr.write(`envoy-dispatch shim: ${gate.reason}
4822
- `);
4823
- process.exit(0);
4824
- }
4825
- const bridge = createBridge({
4826
- remoteUrl: gate.remoteUrl,
4827
- getToken: defaultGhTokenGetter
4828
- });
4829
- let context = null;
4830
- function dispatchContext() {
4831
- if (context === null) {
4832
- const cwd = process.cwd();
4833
- context = (async () => ({
4834
- repo: await resolveCwdRepo(cwd, defaultExec),
4835
- origin: await resolveOrigin(process.env, defaultExec, cwd)
4836
- }))();
4837
- }
4838
- return context;
4839
- }
4840
- async function handle(request) {
4841
- if (dispatchCallParams(request) === null) {
4842
- return bridge.handle(request);
4843
- }
4844
- const injected = injectDispatchArgs(request, await dispatchContext());
4845
- return injected.kind === "reply" ? injected.response : bridge.handle(injected.request);
4846
- }
4847
- const rl = readline.createInterface({ input: process.stdin });
4848
- let inflight = 0;
4849
- let closed = false;
4850
- let chain = Promise.resolve();
4851
- function maybeExit() {
4852
- if (closed && inflight === 0)
4853
- process.exit(0);
4854
- }
4855
- rl.on("line", (line) => {
4856
- const trimmed = line.trim();
4857
- if (!trimmed)
4858
- return;
4859
- inflight++;
4860
- chain = chain.then(async () => {
4861
- try {
4862
- const parsed = JSON.parse(trimmed);
4863
- if (!isJsonRpcRequest(parsed)) {
4864
- throw new TypeError(`not a JSON-RPC 2.0 request: ${trimmed.slice(0, 120)}`);
4865
- }
4866
- const response = await handle(parsed);
4867
- if (response !== null) {
4868
- process.stdout.write(`${JSON.stringify(response)}
4869
- `);
4870
- }
4871
- } catch (err) {
4872
- process.stderr.write(`envoy-dispatch shim: ${messageFor(err)}
4873
- `);
4874
- } finally {
4875
- inflight--;
4876
- maybeExit();
4877
- }
4878
- });
4879
- });
4880
- rl.on("close", () => {
4881
- closed = true;
4882
- maybeExit();
4883
- });
4884
- process.on("SIGTERM", () => process.exit(0));
4885
- process.on("SIGINT", () => process.exit(0));
4886
- }
4887
-
4888
- // bin/dispatch-mcp-shim.ts
4889
- runDispatchMcpShim();