@hasna/logs 0.3.26 → 0.3.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +33 -10
  2. package/dashboard/dist/assets/index-C0wZYq1m.js +53 -0
  3. package/dashboard/dist/assets/index-DGNrK5qb.css +1 -0
  4. package/dashboard/dist/index.html +14 -0
  5. package/dist/cli/index.js +8511 -177
  6. package/dist/count-bmj4r2zb.js +10 -0
  7. package/dist/{diagnose-e0w5rwbc.js → diagnose-3q5cy9ra.js} +2 -2
  8. package/dist/{export-c3eqjste.js → export-cngdb9fh.js} +1 -1
  9. package/dist/{http-zm3ph78w.js → http-r0xc3d2s.js} +79 -8
  10. package/dist/index-931pbyn5.js +141 -0
  11. package/dist/index-b5c72f1p.js +7 -0
  12. package/dist/{index-7w7v7hnr.js → index-by1pdzbr.js} +14 -5
  13. package/dist/{index-3dr7d80h.js → index-e1930v9b.js} +12 -8
  14. package/dist/{index-eh9bkbpa.js → index-e72k53yq.js} +10 -2
  15. package/dist/{index-edn08m6f.js → index-gcd14q2f.js} +9 -6
  16. package/dist/index-hq6kzaah.js +26 -0
  17. package/dist/index-j34f36wy.js +5672 -0
  18. package/dist/{index-5qznfyah.js → index-q27bgpr1.js} +1086 -1646
  19. package/dist/index-qk8dbvbc.js +1859 -0
  20. package/dist/index-t3x838zw.js +2583 -0
  21. package/dist/{index-gc0zvs88.js → index-y2y0mdtd.js} +596 -37
  22. package/dist/{index-ww5ggfv3.js → index-zkb3z95a.js} +12 -9
  23. package/dist/index.js +2990 -22
  24. package/dist/{jobs-ypmmc2ma.js → jobs-hsgyhfvm.js} +2 -1
  25. package/dist/mcp/index.js +1473 -4286
  26. package/dist/{query-7jwj05er.js → query-c5a43zx3.js} +3 -2
  27. package/dist/server/index.js +2944 -417
  28. package/dist/storage.js +50 -0
  29. package/package.json +27 -8
  30. package/biome.json +0 -13
  31. package/bun.lock +0 -376
  32. package/dashboard/README.md +0 -73
  33. package/dashboard/bun.lock +0 -526
  34. package/dashboard/eslint.config.js +0 -23
  35. package/dashboard/index.html +0 -13
  36. package/dashboard/package.json +0 -32
  37. package/dashboard/src/App.css +0 -184
  38. package/dashboard/src/App.tsx +0 -49
  39. package/dashboard/src/api.ts +0 -33
  40. package/dashboard/src/assets/hero.png +0 -0
  41. package/dashboard/src/assets/react.svg +0 -1
  42. package/dashboard/src/assets/vite.svg +0 -1
  43. package/dashboard/src/index.css +0 -111
  44. package/dashboard/src/main.tsx +0 -10
  45. package/dashboard/src/pages/Alerts.tsx +0 -69
  46. package/dashboard/src/pages/Issues.tsx +0 -50
  47. package/dashboard/src/pages/Perf.tsx +0 -75
  48. package/dashboard/src/pages/Projects.tsx +0 -67
  49. package/dashboard/src/pages/Summary.tsx +0 -67
  50. package/dashboard/src/pages/Tail.tsx +0 -65
  51. package/dashboard/tsconfig.app.json +0 -28
  52. package/dashboard/tsconfig.json +0 -7
  53. package/dashboard/tsconfig.node.json +0 -26
  54. package/dashboard/vite.config.ts +0 -14
  55. package/dist/count-x3n7qg3c.js +0 -9
  56. package/dist/index-997bkzr2.js +0 -15
  57. package/dist/index-pen6t0yc.js +0 -10794
  58. package/sdk/package.json +0 -27
  59. package/sdk/src/index.ts +0 -143
  60. package/sdk/src/types.ts +0 -56
  61. package/src/cli/entrypoints.test.ts +0 -63
  62. package/src/cli/index.ts +0 -471
  63. package/src/db/index.test.ts +0 -33
  64. package/src/db/index.ts +0 -189
  65. package/src/db/migrations/001_alert_rules.ts +0 -21
  66. package/src/db/migrations/002_issues.ts +0 -21
  67. package/src/db/migrations/003_retention.ts +0 -15
  68. package/src/db/migrations/004_page_auth.ts +0 -13
  69. package/src/db/pg-migrations.ts +0 -167
  70. package/src/index.ts +0 -1
  71. package/src/lib/alerts.test.ts +0 -67
  72. package/src/lib/alerts.ts +0 -117
  73. package/src/lib/browser-script.test.ts +0 -35
  74. package/src/lib/browser-script.ts +0 -31
  75. package/src/lib/compare.test.ts +0 -52
  76. package/src/lib/compare.ts +0 -85
  77. package/src/lib/count.test.ts +0 -44
  78. package/src/lib/count.ts +0 -55
  79. package/src/lib/diagnose.test.ts +0 -55
  80. package/src/lib/diagnose.ts +0 -91
  81. package/src/lib/export.test.ts +0 -66
  82. package/src/lib/export.ts +0 -65
  83. package/src/lib/github.ts +0 -38
  84. package/src/lib/health.test.ts +0 -48
  85. package/src/lib/health.ts +0 -51
  86. package/src/lib/ingest.test.ts +0 -57
  87. package/src/lib/ingest.ts +0 -78
  88. package/src/lib/issues.test.ts +0 -79
  89. package/src/lib/issues.ts +0 -70
  90. package/src/lib/jobs.test.ts +0 -69
  91. package/src/lib/jobs.ts +0 -63
  92. package/src/lib/lighthouse.ts +0 -65
  93. package/src/lib/package-meta.test.ts +0 -43
  94. package/src/lib/package-meta.ts +0 -80
  95. package/src/lib/page-auth.test.ts +0 -54
  96. package/src/lib/page-auth.ts +0 -48
  97. package/src/lib/parse-time.test.ts +0 -37
  98. package/src/lib/parse-time.ts +0 -14
  99. package/src/lib/perf.test.ts +0 -45
  100. package/src/lib/perf.ts +0 -46
  101. package/src/lib/projects.test.ts +0 -73
  102. package/src/lib/projects.ts +0 -69
  103. package/src/lib/query.test.ts +0 -104
  104. package/src/lib/query.ts +0 -84
  105. package/src/lib/retention.test.ts +0 -42
  106. package/src/lib/retention.ts +0 -62
  107. package/src/lib/rotate.test.ts +0 -37
  108. package/src/lib/rotate.ts +0 -27
  109. package/src/lib/scanner.ts +0 -131
  110. package/src/lib/scheduler.ts +0 -63
  111. package/src/lib/session-context.ts +0 -28
  112. package/src/lib/summarize.test.ts +0 -38
  113. package/src/lib/summarize.ts +0 -23
  114. package/src/mcp/http.test.ts +0 -92
  115. package/src/mcp/http.ts +0 -135
  116. package/src/mcp/index.test.ts +0 -27
  117. package/src/mcp/index.ts +0 -444
  118. package/src/server/index.ts +0 -61
  119. package/src/server/routes/alerts.ts +0 -32
  120. package/src/server/routes/issues.ts +0 -43
  121. package/src/server/routes/jobs.ts +0 -32
  122. package/src/server/routes/logs.ts +0 -113
  123. package/src/server/routes/perf.ts +0 -23
  124. package/src/server/routes/projects.ts +0 -67
  125. package/src/server/routes/stream.ts +0 -43
  126. package/src/server/server.test.ts +0 -194
  127. package/src/types/index.ts +0 -119
  128. package/tsconfig.json +0 -22
  129. /package/dashboard/{public → dist}/favicon.svg +0 -0
  130. /package/dashboard/{public → dist}/icons.svg +0 -0
@@ -3,35 +3,26 @@ import {
3
3
  __export
4
4
  } from "./index-re3ntm60.js";
5
5
 
6
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js
6
+ // node_modules/zod/v4/core/core.js
7
7
  var NEVER = Object.freeze({
8
8
  status: "aborted"
9
9
  });
10
10
  function $constructor(name, initializer, params) {
11
11
  function init(inst, def) {
12
- if (!inst._zod) {
13
- Object.defineProperty(inst, "_zod", {
14
- value: {
15
- def,
16
- constr: _,
17
- traits: new Set
18
- },
19
- enumerable: false
20
- });
21
- }
22
- if (inst._zod.traits.has(name)) {
23
- return;
24
- }
12
+ var _a;
13
+ Object.defineProperty(inst, "_zod", {
14
+ value: inst._zod ?? {},
15
+ enumerable: false
16
+ });
17
+ (_a = inst._zod).traits ?? (_a.traits = new Set);
25
18
  inst._zod.traits.add(name);
26
19
  initializer(inst, def);
27
- const proto = _.prototype;
28
- const keys = Object.keys(proto);
29
- for (let i = 0;i < keys.length; i++) {
30
- const k = keys[i];
31
- if (!(k in inst)) {
32
- inst[k] = proto[k].bind(inst);
33
- }
20
+ for (const k in _.prototype) {
21
+ if (!(k in inst))
22
+ Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
34
23
  }
24
+ inst._zod.constr = _;
25
+ inst._zod.def = def;
35
26
  }
36
27
  const Parent = params?.Parent ?? Object;
37
28
 
@@ -66,30 +57,17 @@ class $ZodAsyncError extends Error {
66
57
  super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
67
58
  }
68
59
  }
69
-
70
- class $ZodEncodeError extends Error {
71
- constructor(name) {
72
- super(`Encountered unidirectional transform during encode: ${name}`);
73
- this.name = "ZodEncodeError";
74
- }
75
- }
76
60
  var globalConfig = {};
77
61
  function config(newConfig) {
78
62
  if (newConfig)
79
63
  Object.assign(globalConfig, newConfig);
80
64
  return globalConfig;
81
65
  }
82
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js
66
+ // node_modules/zod/v4/core/util.js
83
67
  var exports_util = {};
84
68
  __export(exports_util, {
85
69
  unwrapMessage: () => unwrapMessage,
86
- uint8ArrayToHex: () => uint8ArrayToHex,
87
- uint8ArrayToBase64url: () => uint8ArrayToBase64url,
88
- uint8ArrayToBase64: () => uint8ArrayToBase64,
89
70
  stringifyPrimitive: () => stringifyPrimitive,
90
- slugify: () => slugify,
91
- shallowClone: () => shallowClone,
92
- safeExtend: () => safeExtend,
93
71
  required: () => required,
94
72
  randomString: () => randomString,
95
73
  propertyKeyTypes: () => propertyKeyTypes,
@@ -98,21 +76,17 @@ __export(exports_util, {
98
76
  prefixIssues: () => prefixIssues,
99
77
  pick: () => pick,
100
78
  partial: () => partial,
101
- parsedType: () => parsedType,
102
79
  optionalKeys: () => optionalKeys,
103
80
  omit: () => omit,
104
- objectClone: () => objectClone,
105
81
  numKeys: () => numKeys,
106
82
  nullish: () => nullish,
107
83
  normalizeParams: () => normalizeParams,
108
- mergeDefs: () => mergeDefs,
109
84
  merge: () => merge,
110
85
  jsonStringifyReplacer: () => jsonStringifyReplacer,
111
86
  joinValues: () => joinValues,
112
87
  issue: () => issue,
113
88
  isPlainObject: () => isPlainObject,
114
89
  isObject: () => isObject,
115
- hexToUint8Array: () => hexToUint8Array,
116
90
  getSizableOrigin: () => getSizableOrigin,
117
91
  getParsedType: () => getParsedType,
118
92
  getLengthableOrigin: () => getLengthableOrigin,
@@ -125,14 +99,11 @@ __export(exports_util, {
125
99
  esc: () => esc,
126
100
  defineLazy: () => defineLazy,
127
101
  createTransparentProxy: () => createTransparentProxy,
128
- cloneDef: () => cloneDef,
129
102
  clone: () => clone,
130
103
  cleanRegex: () => cleanRegex,
131
104
  cleanEnum: () => cleanEnum,
132
105
  captureStackTrace: () => captureStackTrace,
133
106
  cached: () => cached,
134
- base64urlToUint8Array: () => base64urlToUint8Array,
135
- base64ToUint8Array: () => base64ToUint8Array,
136
107
  assignProp: () => assignProp,
137
108
  assertNotEqual: () => assertNotEqual,
138
109
  assertNever: () => assertNever,
@@ -153,7 +124,7 @@ function assertNotEqual(val) {
153
124
  }
154
125
  function assertIs(_arg) {}
155
126
  function assertNever(_x) {
156
- throw new Error("Unexpected value in exhaustive check");
127
+ throw new Error;
157
128
  }
158
129
  function assert(_) {}
159
130
  function getEnumValues(entries) {
@@ -192,32 +163,22 @@ function cleanRegex(source) {
192
163
  }
193
164
  function floatSafeRemainder(val, step) {
194
165
  const valDecCount = (val.toString().split(".")[1] || "").length;
195
- const stepString = step.toString();
196
- let stepDecCount = (stepString.split(".")[1] || "").length;
197
- if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
198
- const match = stepString.match(/\d?e-(\d?)/);
199
- if (match?.[1]) {
200
- stepDecCount = Number.parseInt(match[1]);
201
- }
202
- }
166
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
203
167
  const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
204
168
  const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
205
169
  const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
206
170
  return valInt % stepInt / 10 ** decCount;
207
171
  }
208
- var EVALUATING = Symbol("evaluating");
209
172
  function defineLazy(object, key, getter) {
210
- let value = undefined;
173
+ const set = false;
211
174
  Object.defineProperty(object, key, {
212
175
  get() {
213
- if (value === EVALUATING) {
214
- return;
215
- }
216
- if (value === undefined) {
217
- value = EVALUATING;
218
- value = getter();
176
+ if (!set) {
177
+ const value = getter();
178
+ object[key] = value;
179
+ return value;
219
180
  }
220
- return value;
181
+ throw new Error("cached value already set");
221
182
  },
222
183
  set(v) {
223
184
  Object.defineProperty(object, key, {
@@ -227,9 +188,6 @@ function defineLazy(object, key, getter) {
227
188
  configurable: true
228
189
  });
229
190
  }
230
- function objectClone(obj) {
231
- return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
232
- }
233
191
  function assignProp(target, prop, value) {
234
192
  Object.defineProperty(target, prop, {
235
193
  value,
@@ -238,17 +196,6 @@ function assignProp(target, prop, value) {
238
196
  configurable: true
239
197
  });
240
198
  }
241
- function mergeDefs(...defs) {
242
- const mergedDescriptors = {};
243
- for (const def of defs) {
244
- const descriptors = Object.getOwnPropertyDescriptors(def);
245
- Object.assign(mergedDescriptors, descriptors);
246
- }
247
- return Object.defineProperties({}, mergedDescriptors);
248
- }
249
- function cloneDef(schema) {
250
- return mergeDefs(schema._zod.def);
251
- }
252
199
  function getElementAtPath(obj, path) {
253
200
  if (!path)
254
201
  return obj;
@@ -276,10 +223,7 @@ function randomString(length = 10) {
276
223
  function esc(str) {
277
224
  return JSON.stringify(str);
278
225
  }
279
- function slugify(input) {
280
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
281
- }
282
- var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
226
+ var captureStackTrace = Error.captureStackTrace ? Error.captureStackTrace : (..._args) => {};
283
227
  function isObject(data) {
284
228
  return typeof data === "object" && data !== null && !Array.isArray(data);
285
229
  }
@@ -301,8 +245,6 @@ function isPlainObject(o) {
301
245
  const ctor = o.constructor;
302
246
  if (ctor === undefined)
303
247
  return true;
304
- if (typeof ctor !== "function")
305
- return true;
306
248
  const prot = ctor.prototype;
307
249
  if (isObject(prot) === false)
308
250
  return false;
@@ -311,13 +253,6 @@ function isPlainObject(o) {
311
253
  }
312
254
  return true;
313
255
  }
314
- function shallowClone(o) {
315
- if (isPlainObject(o))
316
- return { ...o };
317
- if (Array.isArray(o))
318
- return [...o];
319
- return o;
320
- }
321
256
  function numKeys(data) {
322
257
  let keyCount = 0;
323
258
  for (const key in data) {
@@ -455,181 +390,128 @@ var BIGINT_FORMAT_RANGES = {
455
390
  uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
456
391
  };
457
392
  function pick(schema, mask) {
393
+ const newShape = {};
458
394
  const currDef = schema._zod.def;
459
- const checks = currDef.checks;
460
- const hasChecks = checks && checks.length > 0;
461
- if (hasChecks) {
462
- throw new Error(".pick() cannot be used on object schemas containing refinements");
395
+ for (const key in mask) {
396
+ if (!(key in currDef.shape)) {
397
+ throw new Error(`Unrecognized key: "${key}"`);
398
+ }
399
+ if (!mask[key])
400
+ continue;
401
+ newShape[key] = currDef.shape[key];
463
402
  }
464
- const def = mergeDefs(schema._zod.def, {
465
- get shape() {
466
- const newShape = {};
467
- for (const key in mask) {
468
- if (!(key in currDef.shape)) {
469
- throw new Error(`Unrecognized key: "${key}"`);
470
- }
471
- if (!mask[key])
472
- continue;
473
- newShape[key] = currDef.shape[key];
474
- }
475
- assignProp(this, "shape", newShape);
476
- return newShape;
477
- },
403
+ return clone(schema, {
404
+ ...schema._zod.def,
405
+ shape: newShape,
478
406
  checks: []
479
407
  });
480
- return clone(schema, def);
481
408
  }
482
409
  function omit(schema, mask) {
410
+ const newShape = { ...schema._zod.def.shape };
483
411
  const currDef = schema._zod.def;
484
- const checks = currDef.checks;
485
- const hasChecks = checks && checks.length > 0;
486
- if (hasChecks) {
487
- throw new Error(".omit() cannot be used on object schemas containing refinements");
412
+ for (const key in mask) {
413
+ if (!(key in currDef.shape)) {
414
+ throw new Error(`Unrecognized key: "${key}"`);
415
+ }
416
+ if (!mask[key])
417
+ continue;
418
+ delete newShape[key];
488
419
  }
489
- const def = mergeDefs(schema._zod.def, {
490
- get shape() {
491
- const newShape = { ...schema._zod.def.shape };
492
- for (const key in mask) {
493
- if (!(key in currDef.shape)) {
494
- throw new Error(`Unrecognized key: "${key}"`);
495
- }
496
- if (!mask[key])
497
- continue;
498
- delete newShape[key];
499
- }
500
- assignProp(this, "shape", newShape);
501
- return newShape;
502
- },
420
+ return clone(schema, {
421
+ ...schema._zod.def,
422
+ shape: newShape,
503
423
  checks: []
504
424
  });
505
- return clone(schema, def);
506
425
  }
507
426
  function extend(schema, shape) {
508
427
  if (!isPlainObject(shape)) {
509
428
  throw new Error("Invalid input to extend: expected a plain object");
510
429
  }
511
- const checks = schema._zod.def.checks;
512
- const hasChecks = checks && checks.length > 0;
513
- if (hasChecks) {
514
- const existingShape = schema._zod.def.shape;
515
- for (const key in shape) {
516
- if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
517
- throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
518
- }
519
- }
520
- }
521
- const def = mergeDefs(schema._zod.def, {
522
- get shape() {
523
- const _shape = { ...schema._zod.def.shape, ...shape };
524
- assignProp(this, "shape", _shape);
525
- return _shape;
526
- }
527
- });
528
- return clone(schema, def);
529
- }
530
- function safeExtend(schema, shape) {
531
- if (!isPlainObject(shape)) {
532
- throw new Error("Invalid input to safeExtend: expected a plain object");
533
- }
534
- const def = mergeDefs(schema._zod.def, {
430
+ const def = {
431
+ ...schema._zod.def,
535
432
  get shape() {
536
433
  const _shape = { ...schema._zod.def.shape, ...shape };
537
434
  assignProp(this, "shape", _shape);
538
435
  return _shape;
539
- }
540
- });
436
+ },
437
+ checks: []
438
+ };
541
439
  return clone(schema, def);
542
440
  }
543
441
  function merge(a, b) {
544
- const def = mergeDefs(a._zod.def, {
442
+ return clone(a, {
443
+ ...a._zod.def,
545
444
  get shape() {
546
445
  const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
547
446
  assignProp(this, "shape", _shape);
548
447
  return _shape;
549
448
  },
550
- get catchall() {
551
- return b._zod.def.catchall;
552
- },
449
+ catchall: b._zod.def.catchall,
553
450
  checks: []
554
451
  });
555
- return clone(a, def);
556
452
  }
557
453
  function partial(Class, schema, mask) {
558
- const currDef = schema._zod.def;
559
- const checks = currDef.checks;
560
- const hasChecks = checks && checks.length > 0;
561
- if (hasChecks) {
562
- throw new Error(".partial() cannot be used on object schemas containing refinements");
563
- }
564
- const def = mergeDefs(schema._zod.def, {
565
- get shape() {
566
- const oldShape = schema._zod.def.shape;
567
- const shape = { ...oldShape };
568
- if (mask) {
569
- for (const key in mask) {
570
- if (!(key in oldShape)) {
571
- throw new Error(`Unrecognized key: "${key}"`);
572
- }
573
- if (!mask[key])
574
- continue;
575
- shape[key] = Class ? new Class({
576
- type: "optional",
577
- innerType: oldShape[key]
578
- }) : oldShape[key];
579
- }
580
- } else {
581
- for (const key in oldShape) {
582
- shape[key] = Class ? new Class({
583
- type: "optional",
584
- innerType: oldShape[key]
585
- }) : oldShape[key];
586
- }
454
+ const oldShape = schema._zod.def.shape;
455
+ const shape = { ...oldShape };
456
+ if (mask) {
457
+ for (const key in mask) {
458
+ if (!(key in oldShape)) {
459
+ throw new Error(`Unrecognized key: "${key}"`);
587
460
  }
588
- assignProp(this, "shape", shape);
589
- return shape;
590
- },
461
+ if (!mask[key])
462
+ continue;
463
+ shape[key] = Class ? new Class({
464
+ type: "optional",
465
+ innerType: oldShape[key]
466
+ }) : oldShape[key];
467
+ }
468
+ } else {
469
+ for (const key in oldShape) {
470
+ shape[key] = Class ? new Class({
471
+ type: "optional",
472
+ innerType: oldShape[key]
473
+ }) : oldShape[key];
474
+ }
475
+ }
476
+ return clone(schema, {
477
+ ...schema._zod.def,
478
+ shape,
591
479
  checks: []
592
480
  });
593
- return clone(schema, def);
594
481
  }
595
482
  function required(Class, schema, mask) {
596
- const def = mergeDefs(schema._zod.def, {
597
- get shape() {
598
- const oldShape = schema._zod.def.shape;
599
- const shape = { ...oldShape };
600
- if (mask) {
601
- for (const key in mask) {
602
- if (!(key in shape)) {
603
- throw new Error(`Unrecognized key: "${key}"`);
604
- }
605
- if (!mask[key])
606
- continue;
607
- shape[key] = new Class({
608
- type: "nonoptional",
609
- innerType: oldShape[key]
610
- });
611
- }
612
- } else {
613
- for (const key in oldShape) {
614
- shape[key] = new Class({
615
- type: "nonoptional",
616
- innerType: oldShape[key]
617
- });
618
- }
483
+ const oldShape = schema._zod.def.shape;
484
+ const shape = { ...oldShape };
485
+ if (mask) {
486
+ for (const key in mask) {
487
+ if (!(key in shape)) {
488
+ throw new Error(`Unrecognized key: "${key}"`);
619
489
  }
620
- assignProp(this, "shape", shape);
621
- return shape;
490
+ if (!mask[key])
491
+ continue;
492
+ shape[key] = new Class({
493
+ type: "nonoptional",
494
+ innerType: oldShape[key]
495
+ });
496
+ }
497
+ } else {
498
+ for (const key in oldShape) {
499
+ shape[key] = new Class({
500
+ type: "nonoptional",
501
+ innerType: oldShape[key]
502
+ });
622
503
  }
504
+ }
505
+ return clone(schema, {
506
+ ...schema._zod.def,
507
+ shape,
508
+ checks: []
623
509
  });
624
- return clone(schema, def);
625
510
  }
626
511
  function aborted(x, startIndex = 0) {
627
- if (x.aborted === true)
628
- return true;
629
512
  for (let i = startIndex;i < x.issues.length; i++) {
630
- if (x.issues[i]?.continue !== true) {
513
+ if (x.issues[i]?.continue !== true)
631
514
  return true;
632
- }
633
515
  }
634
516
  return false;
635
517
  }
@@ -673,27 +555,6 @@ function getLengthableOrigin(input) {
673
555
  return "string";
674
556
  return "unknown";
675
557
  }
676
- function parsedType(data) {
677
- const t = typeof data;
678
- switch (t) {
679
- case "number": {
680
- return Number.isNaN(data) ? "nan" : "number";
681
- }
682
- case "object": {
683
- if (data === null) {
684
- return "null";
685
- }
686
- if (Array.isArray(data)) {
687
- return "array";
688
- }
689
- const obj = data;
690
- if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
691
- return obj.constructor.name;
692
- }
693
- }
694
- }
695
- return t;
696
- }
697
558
  function issue(...args) {
698
559
  const [iss, input, inst] = args;
699
560
  if (typeof iss === "string") {
@@ -711,49 +572,12 @@ function cleanEnum(obj) {
711
572
  return Number.isNaN(Number.parseInt(k, 10));
712
573
  }).map((el) => el[1]);
713
574
  }
714
- function base64ToUint8Array(base64) {
715
- const binaryString = atob(base64);
716
- const bytes = new Uint8Array(binaryString.length);
717
- for (let i = 0;i < binaryString.length; i++) {
718
- bytes[i] = binaryString.charCodeAt(i);
719
- }
720
- return bytes;
721
- }
722
- function uint8ArrayToBase64(bytes) {
723
- let binaryString = "";
724
- for (let i = 0;i < bytes.length; i++) {
725
- binaryString += String.fromCharCode(bytes[i]);
726
- }
727
- return btoa(binaryString);
728
- }
729
- function base64urlToUint8Array(base64url) {
730
- const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
731
- const padding = "=".repeat((4 - base64.length % 4) % 4);
732
- return base64ToUint8Array(base64 + padding);
733
- }
734
- function uint8ArrayToBase64url(bytes) {
735
- return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
736
- }
737
- function hexToUint8Array(hex) {
738
- const cleanHex = hex.replace(/^0x/, "");
739
- if (cleanHex.length % 2 !== 0) {
740
- throw new Error("Invalid hex string length");
741
- }
742
- const bytes = new Uint8Array(cleanHex.length / 2);
743
- for (let i = 0;i < cleanHex.length; i += 2) {
744
- bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
745
- }
746
- return bytes;
747
- }
748
- function uint8ArrayToHex(bytes) {
749
- return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
750
- }
751
575
 
752
576
  class Class {
753
577
  constructor(..._args) {}
754
578
  }
755
579
 
756
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js
580
+ // node_modules/zod/v4/core/errors.js
757
581
  var initializer = (inst, def) => {
758
582
  inst.name = "$ZodError";
759
583
  Object.defineProperty(inst, "_zod", {
@@ -764,7 +588,12 @@ var initializer = (inst, def) => {
764
588
  value: def,
765
589
  enumerable: false
766
590
  });
767
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
591
+ Object.defineProperty(inst, "message", {
592
+ get() {
593
+ return JSON.stringify(def, jsonStringifyReplacer, 2);
594
+ },
595
+ enumerable: true
596
+ });
768
597
  Object.defineProperty(inst, "toString", {
769
598
  value: () => inst.message,
770
599
  enumerable: false
@@ -785,7 +614,10 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
785
614
  }
786
615
  return { formErrors, fieldErrors };
787
616
  }
788
- function formatError(error, mapper = (issue2) => issue2.message) {
617
+ function formatError(error, _mapper) {
618
+ const mapper = _mapper || function(issue2) {
619
+ return issue2.message;
620
+ };
789
621
  const fieldErrors = { _errors: [] };
790
622
  const processError = (error2) => {
791
623
  for (const issue2 of error2.issues) {
@@ -819,7 +651,7 @@ function formatError(error, mapper = (issue2) => issue2.message) {
819
651
  return fieldErrors;
820
652
  }
821
653
 
822
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js
654
+ // node_modules/zod/v4/core/parse.js
823
655
  var _parse = (_Err) => (schema, value, _ctx, _params) => {
824
656
  const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
825
657
  const result = schema._zod.run({ value, issues: [] }, ctx);
@@ -870,35 +702,7 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
870
702
  } : { success: true, data: result.value };
871
703
  };
872
704
  var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
873
- var _encode = (_Err) => (schema, value, _ctx) => {
874
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
875
- return _parse(_Err)(schema, value, ctx);
876
- };
877
- var _decode = (_Err) => (schema, value, _ctx) => {
878
- return _parse(_Err)(schema, value, _ctx);
879
- };
880
- var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
881
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
882
- return _parseAsync(_Err)(schema, value, ctx);
883
- };
884
- var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
885
- return _parseAsync(_Err)(schema, value, _ctx);
886
- };
887
- var _safeEncode = (_Err) => (schema, value, _ctx) => {
888
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
889
- return _safeParse(_Err)(schema, value, ctx);
890
- };
891
- var _safeDecode = (_Err) => (schema, value, _ctx) => {
892
- return _safeParse(_Err)(schema, value, _ctx);
893
- };
894
- var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
895
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
896
- return _safeParseAsync(_Err)(schema, value, ctx);
897
- };
898
- var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
899
- return _safeParseAsync(_Err)(schema, value, _ctx);
900
- };
901
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js
705
+ // node_modules/zod/v4/core/regexes.js
902
706
  var cuid = /^[cC][^\s-]{8,}$/;
903
707
  var cuid2 = /^[0-9a-z]+$/;
904
708
  var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
@@ -909,7 +713,7 @@ var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)
909
713
  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})$/;
910
714
  var uuid = (version) => {
911
715
  if (!version)
912
- 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)$/;
716
+ 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)$/;
913
717
  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})$`);
914
718
  };
915
719
  var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
@@ -918,12 +722,13 @@ function emoji() {
918
722
  return new RegExp(_emoji, "u");
919
723
  }
920
724
  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])$/;
921
- 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}|:))$/;
725
+ var ipv6 = /^(([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})$/;
922
726
  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])$/;
923
727
  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])$/;
924
728
  var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
925
729
  var base64url = /^[A-Za-z0-9_-]*$/;
926
- var e164 = /^\+[1-9]\d{6,14}$/;
730
+ var hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
731
+ var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
927
732
  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])))`;
928
733
  var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
929
734
  function timeSource(args) {
@@ -940,7 +745,7 @@ function datetime(args) {
940
745
  if (args.local)
941
746
  opts.push("");
942
747
  if (args.offset)
943
- opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
748
+ opts.push(`([+-]\\d{2}:\\d{2})`);
944
749
  const timeRegex = `${time2}(?:${opts.join("|")})`;
945
750
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
946
751
  }
@@ -948,14 +753,14 @@ var string = (params) => {
948
753
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
949
754
  return new RegExp(`^${regex}$`);
950
755
  };
951
- var integer = /^-?\d+$/;
952
- var number = /^-?\d+(?:\.\d+)?$/;
953
- var boolean = /^(?:true|false)$/i;
954
- var _null = /^null$/i;
756
+ var integer = /^\d+$/;
757
+ var number = /^-?\d+(?:\.\d+)?/i;
758
+ var boolean = /true|false/i;
759
+ var _null = /null/i;
955
760
  var lowercase = /^[^A-Z]*$/;
956
761
  var uppercase = /^[^a-z]*$/;
957
762
 
958
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js
763
+ // node_modules/zod/v4/core/checks.js
959
764
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
960
765
  var _a;
961
766
  inst._zod ?? (inst._zod = {});
@@ -987,7 +792,7 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
987
792
  payload.issues.push({
988
793
  origin,
989
794
  code: "too_big",
990
- maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
795
+ maximum: def.value,
991
796
  input: payload.value,
992
797
  inclusive: def.inclusive,
993
798
  inst,
@@ -1015,7 +820,7 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
1015
820
  payload.issues.push({
1016
821
  origin,
1017
822
  code: "too_small",
1018
- minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
823
+ minimum: def.value,
1019
824
  input: payload.value,
1020
825
  inclusive: def.inclusive,
1021
826
  inst,
@@ -1067,7 +872,6 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1067
872
  expected: origin,
1068
873
  format: def.format,
1069
874
  code: "invalid_type",
1070
- continue: false,
1071
875
  input,
1072
876
  inst
1073
877
  });
@@ -1082,7 +886,6 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1082
886
  note: "Integers must be within the safe integer range.",
1083
887
  inst,
1084
888
  origin,
1085
- inclusive: true,
1086
889
  continue: !def.abort
1087
890
  });
1088
891
  } else {
@@ -1093,7 +896,6 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1093
896
  note: "Integers must be within the safe integer range.",
1094
897
  inst,
1095
898
  origin,
1096
- inclusive: true,
1097
899
  continue: !def.abort
1098
900
  });
1099
901
  }
@@ -1117,9 +919,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1117
919
  input,
1118
920
  code: "too_big",
1119
921
  maximum,
1120
- inclusive: true,
1121
- inst,
1122
- continue: !def.abort
922
+ inst
1123
923
  });
1124
924
  }
1125
925
  };
@@ -1344,7 +1144,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
1344
1144
  };
1345
1145
  });
1346
1146
 
1347
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js
1147
+ // node_modules/zod/v4/core/doc.js
1348
1148
  class Doc {
1349
1149
  constructor(args = []) {
1350
1150
  this.content = [];
@@ -1382,14 +1182,14 @@ class Doc {
1382
1182
  }
1383
1183
  }
1384
1184
 
1385
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js
1185
+ // node_modules/zod/v4/core/versions.js
1386
1186
  var version = {
1387
1187
  major: 4,
1388
- minor: 3,
1389
- patch: 6
1188
+ minor: 0,
1189
+ patch: 0
1390
1190
  };
1391
1191
 
1392
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js
1192
+ // node_modules/zod/v4/core/schemas.js
1393
1193
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1394
1194
  var _a;
1395
1195
  inst ?? (inst = {});
@@ -1451,32 +1251,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1451
1251
  }
1452
1252
  return payload;
1453
1253
  };
1454
- const handleCanaryResult = (canary, payload, ctx) => {
1455
- if (aborted(canary)) {
1456
- canary.aborted = true;
1457
- return canary;
1458
- }
1459
- const checkResult = runChecks(payload, checks, ctx);
1460
- if (checkResult instanceof Promise) {
1461
- if (ctx.async === false)
1462
- throw new $ZodAsyncError;
1463
- return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
1464
- }
1465
- return inst._zod.parse(checkResult, ctx);
1466
- };
1467
1254
  inst._zod.run = (payload, ctx) => {
1468
- if (ctx.skipChecks) {
1469
- return inst._zod.parse(payload, ctx);
1470
- }
1471
- if (ctx.direction === "backward") {
1472
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
1473
- if (canary instanceof Promise) {
1474
- return canary.then((canary2) => {
1475
- return handleCanaryResult(canary2, payload, ctx);
1476
- });
1477
- }
1478
- return handleCanaryResult(canary, payload, ctx);
1479
- }
1480
1255
  const result = inst._zod.parse(payload, ctx);
1481
1256
  if (result instanceof Promise) {
1482
1257
  if (ctx.async === false)
@@ -1486,7 +1261,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1486
1261
  return runChecks(result, checks, ctx);
1487
1262
  };
1488
1263
  }
1489
- defineLazy(inst, "~standard", () => ({
1264
+ inst["~standard"] = {
1490
1265
  validate: (value) => {
1491
1266
  try {
1492
1267
  const r = safeParse(inst, value);
@@ -1497,7 +1272,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1497
1272
  },
1498
1273
  vendor: "zod",
1499
1274
  version: 1
1500
- }));
1275
+ };
1501
1276
  });
1502
1277
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1503
1278
  $ZodType.init(inst, def);
@@ -1554,8 +1329,9 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1554
1329
  $ZodStringFormat.init(inst, def);
1555
1330
  inst._zod.check = (payload) => {
1556
1331
  try {
1557
- const trimmed = payload.value.trim();
1558
- const url = new URL(trimmed);
1332
+ const orig = payload.value;
1333
+ const url = new URL(orig);
1334
+ const href = url.href;
1559
1335
  if (def.hostname) {
1560
1336
  def.hostname.lastIndex = 0;
1561
1337
  if (!def.hostname.test(url.hostname)) {
@@ -1563,7 +1339,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1563
1339
  code: "invalid_format",
1564
1340
  format: "url",
1565
1341
  note: "Invalid hostname",
1566
- pattern: def.hostname.source,
1342
+ pattern: hostname.source,
1567
1343
  input: payload.value,
1568
1344
  inst,
1569
1345
  continue: !def.abort
@@ -1584,10 +1360,10 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1584
1360
  });
1585
1361
  }
1586
1362
  }
1587
- if (def.normalize) {
1588
- payload.value = url.href;
1363
+ if (!orig.endsWith("/") && href.endsWith("/")) {
1364
+ payload.value = href.slice(0, -1);
1589
1365
  } else {
1590
- payload.value = trimmed;
1366
+ payload.value = href;
1591
1367
  }
1592
1368
  return;
1593
1369
  } catch (_) {
@@ -1648,12 +1424,18 @@ var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def
1648
1424
  var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1649
1425
  def.pattern ?? (def.pattern = ipv4);
1650
1426
  $ZodStringFormat.init(inst, def);
1651
- inst._zod.bag.format = `ipv4`;
1427
+ inst._zod.onattach.push((inst2) => {
1428
+ const bag = inst2._zod.bag;
1429
+ bag.format = `ipv4`;
1430
+ });
1652
1431
  });
1653
1432
  var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1654
1433
  def.pattern ?? (def.pattern = ipv6);
1655
1434
  $ZodStringFormat.init(inst, def);
1656
- inst._zod.bag.format = `ipv6`;
1435
+ inst._zod.onattach.push((inst2) => {
1436
+ const bag = inst2._zod.bag;
1437
+ bag.format = `ipv6`;
1438
+ });
1657
1439
  inst._zod.check = (payload) => {
1658
1440
  try {
1659
1441
  new URL(`http://[${payload.value}]`);
@@ -1676,11 +1458,8 @@ var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1676
1458
  def.pattern ?? (def.pattern = cidrv6);
1677
1459
  $ZodStringFormat.init(inst, def);
1678
1460
  inst._zod.check = (payload) => {
1679
- const parts = payload.value.split("/");
1461
+ const [address, prefix] = payload.value.split("/");
1680
1462
  try {
1681
- if (parts.length !== 2)
1682
- throw new Error;
1683
- const [address, prefix] = parts;
1684
1463
  if (!prefix)
1685
1464
  throw new Error;
1686
1465
  const prefixNum = Number(prefix);
@@ -1715,7 +1494,9 @@ function isValidBase64(data) {
1715
1494
  var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1716
1495
  def.pattern ?? (def.pattern = base64);
1717
1496
  $ZodStringFormat.init(inst, def);
1718
- inst._zod.bag.contentEncoding = "base64";
1497
+ inst._zod.onattach.push((inst2) => {
1498
+ inst2._zod.bag.contentEncoding = "base64";
1499
+ });
1719
1500
  inst._zod.check = (payload) => {
1720
1501
  if (isValidBase64(payload.value))
1721
1502
  return;
@@ -1738,7 +1519,9 @@ function isValidBase64URL(data) {
1738
1519
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1739
1520
  def.pattern ?? (def.pattern = base64url);
1740
1521
  $ZodStringFormat.init(inst, def);
1741
- inst._zod.bag.contentEncoding = "base64url";
1522
+ inst._zod.onattach.push((inst2) => {
1523
+ inst2._zod.bag.contentEncoding = "base64url";
1524
+ });
1742
1525
  inst._zod.check = (payload) => {
1743
1526
  if (isValidBase64URL(payload.value))
1744
1527
  return;
@@ -1812,7 +1595,7 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1812
1595
  return payload;
1813
1596
  };
1814
1597
  });
1815
- var $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1598
+ var $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1816
1599
  $ZodCheckNumberFormat.init(inst, def);
1817
1600
  $ZodNumber.init(inst, def);
1818
1601
  });
@@ -1908,87 +1691,48 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1908
1691
  return payload;
1909
1692
  };
1910
1693
  });
1911
- function handlePropertyResult(result, final, key, input, isOptionalOut) {
1694
+ function handleObjectResult(result, final, key) {
1912
1695
  if (result.issues.length) {
1913
- if (isOptionalOut && !(key in input)) {
1914
- return;
1915
- }
1916
1696
  final.issues.push(...prefixIssues(key, result.issues));
1917
1697
  }
1918
- if (result.value === undefined) {
1919
- if (key in input) {
1920
- final.value[key] = undefined;
1921
- }
1922
- } else {
1923
- final.value[key] = result.value;
1924
- }
1925
- }
1926
- function normalizeDef(def) {
1927
- const keys = Object.keys(def.shape);
1928
- for (const k of keys) {
1929
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1930
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1931
- }
1932
- }
1933
- const okeys = optionalKeys(def.shape);
1934
- return {
1935
- ...def,
1936
- keys,
1937
- keySet: new Set(keys),
1938
- numKeys: keys.length,
1939
- optionalKeys: new Set(okeys)
1940
- };
1698
+ final.value[key] = result.value;
1941
1699
  }
1942
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1943
- const unrecognized = [];
1944
- const keySet = def.keySet;
1945
- const _catchall = def.catchall._zod;
1946
- const t = _catchall.def.type;
1947
- const isOptionalOut = _catchall.optout === "optional";
1948
- for (const key in input) {
1949
- if (keySet.has(key))
1950
- continue;
1951
- if (t === "never") {
1952
- unrecognized.push(key);
1953
- continue;
1954
- }
1955
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1956
- if (r instanceof Promise) {
1957
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1700
+ function handleOptionalObjectResult(result, final, key, input) {
1701
+ if (result.issues.length) {
1702
+ if (input[key] === undefined) {
1703
+ if (key in input) {
1704
+ final.value[key] = undefined;
1705
+ } else {
1706
+ final.value[key] = result.value;
1707
+ }
1958
1708
  } else {
1959
- handlePropertyResult(r, payload, key, input, isOptionalOut);
1709
+ final.issues.push(...prefixIssues(key, result.issues));
1960
1710
  }
1711
+ } else if (result.value === undefined) {
1712
+ if (key in input)
1713
+ final.value[key] = undefined;
1714
+ } else {
1715
+ final.value[key] = result.value;
1961
1716
  }
1962
- if (unrecognized.length) {
1963
- payload.issues.push({
1964
- code: "unrecognized_keys",
1965
- keys: unrecognized,
1966
- input,
1967
- inst
1968
- });
1969
- }
1970
- if (!proms.length)
1971
- return payload;
1972
- return Promise.all(proms).then(() => {
1973
- return payload;
1974
- });
1975
1717
  }
1976
1718
  var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1977
1719
  $ZodType.init(inst, def);
1978
- const desc = Object.getOwnPropertyDescriptor(def, "shape");
1979
- if (!desc?.get) {
1980
- const sh = def.shape;
1981
- Object.defineProperty(def, "shape", {
1982
- get: () => {
1983
- const newSh = { ...sh };
1984
- Object.defineProperty(def, "shape", {
1985
- value: newSh
1986
- });
1987
- return newSh;
1720
+ const _normalized = cached(() => {
1721
+ const keys = Object.keys(def.shape);
1722
+ for (const k of keys) {
1723
+ if (!(def.shape[k] instanceof $ZodType)) {
1724
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1988
1725
  }
1989
- });
1990
- }
1991
- const _normalized = cached(() => normalizeDef(def));
1726
+ }
1727
+ const okeys = optionalKeys(def.shape);
1728
+ return {
1729
+ shape: def.shape,
1730
+ keys,
1731
+ keySet: new Set(keys),
1732
+ numKeys: keys.length,
1733
+ optionalKeys: new Set(okeys)
1734
+ };
1735
+ });
1992
1736
  defineLazy(inst._zod, "propValues", () => {
1993
1737
  const shape = def.shape;
1994
1738
  const propValues = {};
@@ -2002,44 +1746,6 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
2002
1746
  }
2003
1747
  return propValues;
2004
1748
  });
2005
- const isObject2 = isObject;
2006
- const catchall = def.catchall;
2007
- let value;
2008
- inst._zod.parse = (payload, ctx) => {
2009
- value ?? (value = _normalized.value);
2010
- const input = payload.value;
2011
- if (!isObject2(input)) {
2012
- payload.issues.push({
2013
- expected: "object",
2014
- code: "invalid_type",
2015
- input,
2016
- inst
2017
- });
2018
- return payload;
2019
- }
2020
- payload.value = {};
2021
- const proms = [];
2022
- const shape = value.shape;
2023
- for (const key of value.keys) {
2024
- const el = shape[key];
2025
- const isOptionalOut = el._zod.optout === "optional";
2026
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
2027
- if (r instanceof Promise) {
2028
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
2029
- } else {
2030
- handlePropertyResult(r, payload, key, input, isOptionalOut);
2031
- }
2032
- }
2033
- if (!catchall) {
2034
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
2035
- }
2036
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2037
- };
2038
- });
2039
- var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
2040
- $ZodObject.init(inst, def);
2041
- const superParse = inst._zod.parse;
2042
- const _normalized = cached(() => normalizeDef(def));
2043
1749
  const generateFastpass = (shape) => {
2044
1750
  const doc = new Doc(["shape", "payload", "ctx"]);
2045
1751
  const normalized = _normalized.value;
@@ -2053,51 +1759,41 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
2053
1759
  for (const key of normalized.keys) {
2054
1760
  ids[key] = `key_${counter++}`;
2055
1761
  }
2056
- doc.write(`const newResult = {};`);
1762
+ doc.write(`const newResult = {}`);
2057
1763
  for (const key of normalized.keys) {
2058
- const id = ids[key];
2059
- const k = esc(key);
2060
- const schema = shape[key];
2061
- const isOptionalOut = schema?._zod?.optout === "optional";
2062
- doc.write(`const ${id} = ${parseStr(key)};`);
2063
- if (isOptionalOut) {
1764
+ if (normalized.optionalKeys.has(key)) {
1765
+ const id = ids[key];
1766
+ doc.write(`const ${id} = ${parseStr(key)};`);
1767
+ const k = esc(key);
2064
1768
  doc.write(`
2065
1769
  if (${id}.issues.length) {
2066
- if (${k} in input) {
2067
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2068
- ...iss,
2069
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2070
- })));
2071
- }
2072
- }
2073
-
2074
- if (${id}.value === undefined) {
2075
- if (${k} in input) {
2076
- newResult[${k}] = undefined;
1770
+ if (input[${k}] === undefined) {
1771
+ if (${k} in input) {
1772
+ newResult[${k}] = undefined;
1773
+ }
1774
+ } else {
1775
+ payload.issues = payload.issues.concat(
1776
+ ${id}.issues.map((iss) => ({
1777
+ ...iss,
1778
+ path: iss.path ? [${k}, ...iss.path] : [${k}],
1779
+ }))
1780
+ );
2077
1781
  }
1782
+ } else if (${id}.value === undefined) {
1783
+ if (${k} in input) newResult[${k}] = undefined;
2078
1784
  } else {
2079
1785
  newResult[${k}] = ${id}.value;
2080
1786
  }
2081
-
2082
- `);
1787
+ `);
2083
1788
  } else {
1789
+ const id = ids[key];
1790
+ doc.write(`const ${id} = ${parseStr(key)};`);
2084
1791
  doc.write(`
2085
- if (${id}.issues.length) {
2086
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1792
+ if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2087
1793
  ...iss,
2088
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2089
- })));
2090
- }
2091
-
2092
- if (${id}.value === undefined) {
2093
- if (${k} in input) {
2094
- newResult[${k}] = undefined;
2095
- }
2096
- } else {
2097
- newResult[${k}] = ${id}.value;
2098
- }
2099
-
2100
- `);
1794
+ path: iss.path ? [${esc(key)}, ...iss.path] : [${esc(key)}]
1795
+ })));`);
1796
+ doc.write(`newResult[${esc(key)}] = ${id}.value`);
2101
1797
  }
2102
1798
  }
2103
1799
  doc.write(`payload.value = newResult;`);
@@ -2124,29 +1820,70 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
2124
1820
  });
2125
1821
  return payload;
2126
1822
  }
1823
+ const proms = [];
2127
1824
  if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
2128
1825
  if (!fastpass)
2129
1826
  fastpass = generateFastpass(def.shape);
2130
1827
  payload = fastpass(payload, ctx);
2131
- if (!catchall)
2132
- return payload;
2133
- return handleCatchall([], input, payload, ctx, value, inst);
1828
+ } else {
1829
+ payload.value = {};
1830
+ const shape = value.shape;
1831
+ for (const key of value.keys) {
1832
+ const el = shape[key];
1833
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1834
+ const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
1835
+ if (r instanceof Promise) {
1836
+ proms.push(r.then((r2) => isOptional ? handleOptionalObjectResult(r2, payload, key, input) : handleObjectResult(r2, payload, key)));
1837
+ } else if (isOptional) {
1838
+ handleOptionalObjectResult(r, payload, key, input);
1839
+ } else {
1840
+ handleObjectResult(r, payload, key);
1841
+ }
1842
+ }
2134
1843
  }
2135
- return superParse(payload, ctx);
2136
- };
2137
- });
2138
- function handleUnionResults(results, final, inst, ctx) {
2139
- for (const result of results) {
2140
- if (result.issues.length === 0) {
2141
- final.value = result.value;
2142
- return final;
1844
+ if (!catchall) {
1845
+ return proms.length ? Promise.all(proms).then(() => payload) : payload;
2143
1846
  }
2144
- }
2145
- const nonaborted = results.filter((r) => !aborted(r));
2146
- if (nonaborted.length === 1) {
2147
- final.value = nonaborted[0].value;
2148
- return nonaborted[0];
2149
- }
1847
+ const unrecognized = [];
1848
+ const keySet = value.keySet;
1849
+ const _catchall = catchall._zod;
1850
+ const t = _catchall.def.type;
1851
+ for (const key of Object.keys(input)) {
1852
+ if (keySet.has(key))
1853
+ continue;
1854
+ if (t === "never") {
1855
+ unrecognized.push(key);
1856
+ continue;
1857
+ }
1858
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1859
+ if (r instanceof Promise) {
1860
+ proms.push(r.then((r2) => handleObjectResult(r2, payload, key)));
1861
+ } else {
1862
+ handleObjectResult(r, payload, key);
1863
+ }
1864
+ }
1865
+ if (unrecognized.length) {
1866
+ payload.issues.push({
1867
+ code: "unrecognized_keys",
1868
+ keys: unrecognized,
1869
+ input,
1870
+ inst
1871
+ });
1872
+ }
1873
+ if (!proms.length)
1874
+ return payload;
1875
+ return Promise.all(proms).then(() => {
1876
+ return payload;
1877
+ });
1878
+ };
1879
+ });
1880
+ function handleUnionResults(results, final, inst, ctx) {
1881
+ for (const result of results) {
1882
+ if (result.issues.length === 0) {
1883
+ final.value = result.value;
1884
+ return final;
1885
+ }
1886
+ }
2150
1887
  final.issues.push({
2151
1888
  code: "invalid_union",
2152
1889
  input: final.value,
@@ -2172,12 +1909,7 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
2172
1909
  }
2173
1910
  return;
2174
1911
  });
2175
- const single = def.options.length === 1;
2176
- const first = def.options[0]._zod.run;
2177
1912
  inst._zod.parse = (payload, ctx) => {
2178
- if (single) {
2179
- return first(payload, ctx);
2180
- }
2181
1913
  let async = false;
2182
1914
  const results = [];
2183
1915
  for (const option of def.options) {
@@ -2202,7 +1934,6 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
2202
1934
  };
2203
1935
  });
2204
1936
  var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
2205
- def.inclusive = false;
2206
1937
  $ZodUnion.init(inst, def);
2207
1938
  const _super = inst._zod.parse;
2208
1939
  defineLazy(inst._zod, "propValues", () => {
@@ -2225,7 +1956,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
2225
1956
  const opts = def.options;
2226
1957
  const map = new Map;
2227
1958
  for (const o of opts) {
2228
- const values = o._zod.propValues?.[def.discriminator];
1959
+ const values = o._zod.propValues[def.discriminator];
2229
1960
  if (!values || values.size === 0)
2230
1961
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
2231
1962
  for (const v of values) {
@@ -2259,7 +1990,6 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
2259
1990
  code: "invalid_union",
2260
1991
  errors: [],
2261
1992
  note: "No matching discriminator",
2262
- discriminator: def.discriminator,
2263
1993
  input,
2264
1994
  path: [def.discriminator],
2265
1995
  inst
@@ -2327,34 +2057,11 @@ function mergeValues(a, b) {
2327
2057
  return { valid: false, mergeErrorPath: [] };
2328
2058
  }
2329
2059
  function handleIntersectionResults(result, left, right) {
2330
- const unrecKeys = new Map;
2331
- let unrecIssue;
2332
- for (const iss of left.issues) {
2333
- if (iss.code === "unrecognized_keys") {
2334
- unrecIssue ?? (unrecIssue = iss);
2335
- for (const k of iss.keys) {
2336
- if (!unrecKeys.has(k))
2337
- unrecKeys.set(k, {});
2338
- unrecKeys.get(k).l = true;
2339
- }
2340
- } else {
2341
- result.issues.push(iss);
2342
- }
2343
- }
2344
- for (const iss of right.issues) {
2345
- if (iss.code === "unrecognized_keys") {
2346
- for (const k of iss.keys) {
2347
- if (!unrecKeys.has(k))
2348
- unrecKeys.set(k, {});
2349
- unrecKeys.get(k).r = true;
2350
- }
2351
- } else {
2352
- result.issues.push(iss);
2353
- }
2060
+ if (left.issues.length) {
2061
+ result.issues.push(...left.issues);
2354
2062
  }
2355
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2356
- if (bothKeys.length && unrecIssue) {
2357
- result.issues.push({ ...unrecIssue, keys: bothKeys });
2063
+ if (right.issues.length) {
2064
+ result.issues.push(...right.issues);
2358
2065
  }
2359
2066
  if (aborted(result))
2360
2067
  return result;
@@ -2379,13 +2086,11 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2379
2086
  return payload;
2380
2087
  }
2381
2088
  const proms = [];
2382
- const values = def.keyType._zod.values;
2383
- if (values) {
2089
+ if (def.keyType._zod.values) {
2090
+ const values = def.keyType._zod.values;
2384
2091
  payload.value = {};
2385
- const recordKeys = new Set;
2386
2092
  for (const key of values) {
2387
2093
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2388
- recordKeys.add(typeof key === "number" ? key.toString() : key);
2389
2094
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2390
2095
  if (result instanceof Promise) {
2391
2096
  proms.push(result.then((result2) => {
@@ -2404,7 +2109,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2404
2109
  }
2405
2110
  let unrecognized;
2406
2111
  for (const key in input) {
2407
- if (!recordKeys.has(key)) {
2112
+ if (!values.has(key)) {
2408
2113
  unrecognized = unrecognized ?? [];
2409
2114
  unrecognized.push(key);
2410
2115
  }
@@ -2422,33 +2127,20 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2422
2127
  for (const key of Reflect.ownKeys(input)) {
2423
2128
  if (key === "__proto__")
2424
2129
  continue;
2425
- let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2130
+ const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2426
2131
  if (keyResult instanceof Promise) {
2427
2132
  throw new Error("Async schemas not supported in object keys currently");
2428
2133
  }
2429
- const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
2430
- if (checkNumericKey) {
2431
- const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
2432
- if (retryResult instanceof Promise) {
2433
- throw new Error("Async schemas not supported in object keys currently");
2434
- }
2435
- if (retryResult.issues.length === 0) {
2436
- keyResult = retryResult;
2437
- }
2438
- }
2439
2134
  if (keyResult.issues.length) {
2440
- if (def.mode === "loose") {
2441
- payload.value[key] = input[key];
2442
- } else {
2443
- payload.issues.push({
2444
- code: "invalid_key",
2445
- origin: "record",
2446
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2447
- input: key,
2448
- path: [key],
2449
- inst
2450
- });
2451
- }
2135
+ payload.issues.push({
2136
+ origin: "record",
2137
+ code: "invalid_key",
2138
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2139
+ input: key,
2140
+ path: [key],
2141
+ inst
2142
+ });
2143
+ payload.value[keyResult.value] = keyResult.value;
2452
2144
  continue;
2453
2145
  }
2454
2146
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
@@ -2476,12 +2168,11 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2476
2168
  var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2477
2169
  $ZodType.init(inst, def);
2478
2170
  const values = getEnumValues(def.entries);
2479
- const valuesSet = new Set(values);
2480
- inst._zod.values = valuesSet;
2171
+ inst._zod.values = new Set(values);
2481
2172
  inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2482
2173
  inst._zod.parse = (payload, _ctx) => {
2483
2174
  const input = payload.value;
2484
- if (valuesSet.has(input)) {
2175
+ if (inst._zod.values.has(input)) {
2485
2176
  return payload;
2486
2177
  }
2487
2178
  payload.issues.push({
@@ -2495,15 +2186,11 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2495
2186
  });
2496
2187
  var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
2497
2188
  $ZodType.init(inst, def);
2498
- if (def.values.length === 0) {
2499
- throw new Error("Cannot create literal schema with no valid values");
2500
- }
2501
- const values = new Set(def.values);
2502
- inst._zod.values = values;
2503
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
2189
+ inst._zod.values = new Set(def.values);
2190
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? o.toString() : String(o)).join("|")})$`);
2504
2191
  inst._zod.parse = (payload, _ctx) => {
2505
2192
  const input = payload.value;
2506
- if (values.has(input)) {
2193
+ if (inst._zod.values.has(input)) {
2507
2194
  return payload;
2508
2195
  }
2509
2196
  payload.issues.push({
@@ -2517,12 +2204,9 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
2517
2204
  });
2518
2205
  var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2519
2206
  $ZodType.init(inst, def);
2520
- inst._zod.parse = (payload, ctx) => {
2521
- if (ctx.direction === "backward") {
2522
- throw new $ZodEncodeError(inst.constructor.name);
2523
- }
2207
+ inst._zod.parse = (payload, _ctx) => {
2524
2208
  const _out = def.transform(payload.value, payload);
2525
- if (ctx.async) {
2209
+ if (_ctx.async) {
2526
2210
  const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2527
2211
  return output.then((output2) => {
2528
2212
  payload.value = output2;
@@ -2536,12 +2220,6 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
2536
2220
  return payload;
2537
2221
  };
2538
2222
  });
2539
- function handleOptionalResult(result, input) {
2540
- if (result.issues.length && input === undefined) {
2541
- return { issues: [], value: undefined };
2542
- }
2543
- return result;
2544
- }
2545
2223
  var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2546
2224
  $ZodType.init(inst, def);
2547
2225
  inst._zod.optin = "optional";
@@ -2555,10 +2233,7 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2555
2233
  });
2556
2234
  inst._zod.parse = (payload, ctx) => {
2557
2235
  if (def.innerType._zod.optin === "optional") {
2558
- const result = def.innerType._zod.run(payload, ctx);
2559
- if (result instanceof Promise)
2560
- return result.then((r) => handleOptionalResult(r, payload.value));
2561
- return handleOptionalResult(result, payload.value);
2236
+ return def.innerType._zod.run(payload, ctx);
2562
2237
  }
2563
2238
  if (payload.value === undefined) {
2564
2239
  return payload;
@@ -2566,14 +2241,6 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2566
2241
  return def.innerType._zod.run(payload, ctx);
2567
2242
  };
2568
2243
  });
2569
- var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
2570
- $ZodOptional.init(inst, def);
2571
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2572
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2573
- inst._zod.parse = (payload, ctx) => {
2574
- return def.innerType._zod.run(payload, ctx);
2575
- };
2576
- });
2577
2244
  var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
2578
2245
  $ZodType.init(inst, def);
2579
2246
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -2596,9 +2263,6 @@ var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
2596
2263
  inst._zod.optin = "optional";
2597
2264
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2598
2265
  inst._zod.parse = (payload, ctx) => {
2599
- if (ctx.direction === "backward") {
2600
- return def.innerType._zod.run(payload, ctx);
2601
- }
2602
2266
  if (payload.value === undefined) {
2603
2267
  payload.value = def.defaultValue;
2604
2268
  return payload;
@@ -2621,9 +2285,6 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
2621
2285
  inst._zod.optin = "optional";
2622
2286
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2623
2287
  inst._zod.parse = (payload, ctx) => {
2624
- if (ctx.direction === "backward") {
2625
- return def.innerType._zod.run(payload, ctx);
2626
- }
2627
2288
  if (payload.value === undefined) {
2628
2289
  payload.value = def.defaultValue;
2629
2290
  }
@@ -2657,13 +2318,10 @@ function handleNonOptionalResult(payload, inst) {
2657
2318
  }
2658
2319
  var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2659
2320
  $ZodType.init(inst, def);
2660
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2321
+ inst._zod.optin = "optional";
2661
2322
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2662
2323
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2663
2324
  inst._zod.parse = (payload, ctx) => {
2664
- if (ctx.direction === "backward") {
2665
- return def.innerType._zod.run(payload, ctx);
2666
- }
2667
2325
  const result = def.innerType._zod.run(payload, ctx);
2668
2326
  if (result instanceof Promise) {
2669
2327
  return result.then((result2) => {
@@ -2700,39 +2358,27 @@ var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
2700
2358
  defineLazy(inst._zod, "values", () => def.in._zod.values);
2701
2359
  defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2702
2360
  defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2703
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2704
2361
  inst._zod.parse = (payload, ctx) => {
2705
- if (ctx.direction === "backward") {
2706
- const right = def.out._zod.run(payload, ctx);
2707
- if (right instanceof Promise) {
2708
- return right.then((right2) => handlePipeResult(right2, def.in, ctx));
2709
- }
2710
- return handlePipeResult(right, def.in, ctx);
2711
- }
2712
2362
  const left = def.in._zod.run(payload, ctx);
2713
2363
  if (left instanceof Promise) {
2714
- return left.then((left2) => handlePipeResult(left2, def.out, ctx));
2364
+ return left.then((left2) => handlePipeResult(left2, def, ctx));
2715
2365
  }
2716
- return handlePipeResult(left, def.out, ctx);
2366
+ return handlePipeResult(left, def, ctx);
2717
2367
  };
2718
2368
  });
2719
- function handlePipeResult(left, next, ctx) {
2720
- if (left.issues.length) {
2721
- left.aborted = true;
2369
+ function handlePipeResult(left, def, ctx) {
2370
+ if (aborted(left)) {
2722
2371
  return left;
2723
2372
  }
2724
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2373
+ return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
2725
2374
  }
2726
2375
  var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2727
2376
  $ZodType.init(inst, def);
2728
2377
  defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2729
2378
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2730
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2731
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2379
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2380
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2732
2381
  inst._zod.parse = (payload, ctx) => {
2733
- if (ctx.direction === "backward") {
2734
- return def.innerType._zod.run(payload, ctx);
2735
- }
2736
2382
  const result = def.innerType._zod.run(payload, ctx);
2737
2383
  if (result instanceof Promise) {
2738
2384
  return result.then(handleReadonlyResult);
@@ -2774,19 +2420,38 @@ function handleRefineResult(result, payload, input, inst) {
2774
2420
  payload.issues.push(issue(_iss));
2775
2421
  }
2776
2422
  }
2777
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/locales/en.js
2423
+ // node_modules/zod/v4/locales/en.js
2424
+ var parsedType = (data) => {
2425
+ const t = typeof data;
2426
+ switch (t) {
2427
+ case "number": {
2428
+ return Number.isNaN(data) ? "NaN" : "number";
2429
+ }
2430
+ case "object": {
2431
+ if (Array.isArray(data)) {
2432
+ return "array";
2433
+ }
2434
+ if (data === null) {
2435
+ return "null";
2436
+ }
2437
+ if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
2438
+ return data.constructor.name;
2439
+ }
2440
+ }
2441
+ }
2442
+ return t;
2443
+ };
2778
2444
  var error = () => {
2779
2445
  const Sizable = {
2780
2446
  string: { unit: "characters", verb: "to have" },
2781
2447
  file: { unit: "bytes", verb: "to have" },
2782
2448
  array: { unit: "items", verb: "to have" },
2783
- set: { unit: "items", verb: "to have" },
2784
- map: { unit: "entries", verb: "to have" }
2449
+ set: { unit: "items", verb: "to have" }
2785
2450
  };
2786
2451
  function getSizing(origin) {
2787
2452
  return Sizable[origin] ?? null;
2788
2453
  }
2789
- const FormatDictionary = {
2454
+ const Nouns = {
2790
2455
  regex: "input",
2791
2456
  email: "email address",
2792
2457
  url: "URL",
@@ -2807,7 +2472,6 @@ var error = () => {
2807
2472
  duration: "ISO duration",
2808
2473
  ipv4: "IPv4 address",
2809
2474
  ipv6: "IPv6 address",
2810
- mac: "MAC address",
2811
2475
  cidrv4: "IPv4 range",
2812
2476
  cidrv6: "IPv6 range",
2813
2477
  base64: "base64-encoded string",
@@ -2817,17 +2481,10 @@ var error = () => {
2817
2481
  jwt: "JWT",
2818
2482
  template_literal: "input"
2819
2483
  };
2820
- const TypeDictionary = {
2821
- nan: "NaN"
2822
- };
2823
2484
  return (issue2) => {
2824
2485
  switch (issue2.code) {
2825
- case "invalid_type": {
2826
- const expected = TypeDictionary[issue2.expected] ?? issue2.expected;
2827
- const receivedType = parsedType(issue2.input);
2828
- const received = TypeDictionary[receivedType] ?? receivedType;
2829
- return `Invalid input: expected ${expected}, received ${received}`;
2830
- }
2486
+ case "invalid_type":
2487
+ return `Invalid input: expected ${issue2.expected}, received ${parsedType(issue2.input)}`;
2831
2488
  case "invalid_value":
2832
2489
  if (issue2.values.length === 1)
2833
2490
  return `Invalid input: expected ${stringifyPrimitive(issue2.values[0])}`;
@@ -2858,7 +2515,7 @@ var error = () => {
2858
2515
  return `Invalid string: must include "${_issue.includes}"`;
2859
2516
  if (_issue.format === "regex")
2860
2517
  return `Invalid string: must match pattern ${_issue.pattern}`;
2861
- return `Invalid ${FormatDictionary[_issue.format] ?? issue2.format}`;
2518
+ return `Invalid ${Nouns[_issue.format] ?? issue2.format}`;
2862
2519
  }
2863
2520
  case "not_multiple_of":
2864
2521
  return `Invalid number: must be a multiple of ${issue2.divisor}`;
@@ -2880,26 +2537,28 @@ function en_default() {
2880
2537
  localeError: error()
2881
2538
  };
2882
2539
  }
2883
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js
2884
- var _a;
2540
+ // node_modules/zod/v4/core/registries.js
2885
2541
  var $output = Symbol("ZodOutput");
2886
2542
  var $input = Symbol("ZodInput");
2887
2543
 
2888
2544
  class $ZodRegistry {
2889
2545
  constructor() {
2890
- this._map = new WeakMap;
2546
+ this._map = new Map;
2891
2547
  this._idmap = new Map;
2892
2548
  }
2893
2549
  add(schema, ..._meta) {
2894
2550
  const meta = _meta[0];
2895
2551
  this._map.set(schema, meta);
2896
2552
  if (meta && typeof meta === "object" && "id" in meta) {
2553
+ if (this._idmap.has(meta.id)) {
2554
+ throw new Error(`ID ${meta.id} already exists in the registry`);
2555
+ }
2897
2556
  this._idmap.set(meta.id, schema);
2898
2557
  }
2899
2558
  return this;
2900
2559
  }
2901
2560
  clear() {
2902
- this._map = new WeakMap;
2561
+ this._map = new Map;
2903
2562
  this._idmap = new Map;
2904
2563
  return this;
2905
2564
  }
@@ -2916,8 +2575,7 @@ class $ZodRegistry {
2916
2575
  if (p) {
2917
2576
  const pm = { ...this.get(p) ?? {} };
2918
2577
  delete pm.id;
2919
- const f = { ...pm, ...this._map.get(schema) };
2920
- return Object.keys(f).length ? f : undefined;
2578
+ return { ...pm, ...this._map.get(schema) };
2921
2579
  }
2922
2580
  return this._map.get(schema);
2923
2581
  }
@@ -2928,9 +2586,8 @@ class $ZodRegistry {
2928
2586
  function registry() {
2929
2587
  return new $ZodRegistry;
2930
2588
  }
2931
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2932
- var globalRegistry = globalThis.__zod_globalRegistry;
2933
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js
2589
+ var globalRegistry = /* @__PURE__ */ registry();
2590
+ // node_modules/zod/v4/core/api.js
2934
2591
  function _string(Class2, params) {
2935
2592
  return new Class2({
2936
2593
  type: "string",
@@ -3338,9 +2995,6 @@ function _toLowerCase() {
3338
2995
  function _toUpperCase() {
3339
2996
  return _overwrite((input) => input.toUpperCase());
3340
2997
  }
3341
- function _slugify() {
3342
- return _overwrite((input) => slugify(input));
3343
- }
3344
2998
  function _array(Class2, element, params) {
3345
2999
  return new Class2({
3346
3000
  type: "array",
@@ -3368,925 +3022,759 @@ function _refine(Class2, fn, _params) {
3368
3022
  });
3369
3023
  return schema;
3370
3024
  }
3371
- function _superRefine(fn) {
3372
- const ch = _check((payload) => {
3373
- payload.addIssue = (issue2) => {
3374
- if (typeof issue2 === "string") {
3375
- payload.issues.push(issue(issue2, payload.value, ch._zod.def));
3376
- } else {
3377
- const _issue = issue2;
3378
- if (_issue.fatal)
3379
- _issue.continue = false;
3380
- _issue.code ?? (_issue.code = "custom");
3381
- _issue.input ?? (_issue.input = payload.value);
3382
- _issue.inst ?? (_issue.inst = ch);
3383
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
3384
- payload.issues.push(issue(_issue));
3385
- }
3025
+ // node_modules/zod/v4/core/to-json-schema.js
3026
+ class JSONSchemaGenerator {
3027
+ constructor(params) {
3028
+ this.counter = 0;
3029
+ this.metadataRegistry = params?.metadata ?? globalRegistry;
3030
+ this.target = params?.target ?? "draft-2020-12";
3031
+ this.unrepresentable = params?.unrepresentable ?? "throw";
3032
+ this.override = params?.override ?? (() => {});
3033
+ this.io = params?.io ?? "output";
3034
+ this.seen = new Map;
3035
+ }
3036
+ process(schema, _params = { path: [], schemaPath: [] }) {
3037
+ var _a;
3038
+ const def = schema._zod.def;
3039
+ const formatMap = {
3040
+ guid: "uuid",
3041
+ url: "uri",
3042
+ datetime: "date-time",
3043
+ json_string: "json-string",
3044
+ regex: ""
3386
3045
  };
3387
- return fn(payload.value, payload);
3388
- });
3389
- return ch;
3390
- }
3391
- function _check(fn, params) {
3392
- const ch = new $ZodCheck({
3393
- check: "custom",
3394
- ...normalizeParams(params)
3395
- });
3396
- ch._zod.check = fn;
3397
- return ch;
3398
- }
3399
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js
3400
- function initializeContext(params) {
3401
- let target = params?.target ?? "draft-2020-12";
3402
- if (target === "draft-4")
3403
- target = "draft-04";
3404
- if (target === "draft-7")
3405
- target = "draft-07";
3406
- return {
3407
- processors: params.processors ?? {},
3408
- metadataRegistry: params?.metadata ?? globalRegistry,
3409
- target,
3410
- unrepresentable: params?.unrepresentable ?? "throw",
3411
- override: params?.override ?? (() => {}),
3412
- io: params?.io ?? "output",
3413
- counter: 0,
3414
- seen: new Map,
3415
- cycles: params?.cycles ?? "ref",
3416
- reused: params?.reused ?? "inline",
3417
- external: params?.external ?? undefined
3418
- };
3419
- }
3420
- function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
3421
- var _a2;
3422
- const def = schema._zod.def;
3423
- const seen = ctx.seen.get(schema);
3424
- if (seen) {
3425
- seen.count++;
3426
- const isCycle = _params.schemaPath.includes(schema);
3427
- if (isCycle) {
3428
- seen.cycle = _params.path;
3046
+ const seen = this.seen.get(schema);
3047
+ if (seen) {
3048
+ seen.count++;
3049
+ const isCycle = _params.schemaPath.includes(schema);
3050
+ if (isCycle) {
3051
+ seen.cycle = _params.path;
3052
+ }
3053
+ return seen.schema;
3429
3054
  }
3430
- return seen.schema;
3431
- }
3432
- const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
3433
- ctx.seen.set(schema, result);
3434
- const overrideSchema = schema._zod.toJSONSchema?.();
3435
- if (overrideSchema) {
3436
- result.schema = overrideSchema;
3437
- } else {
3438
- const params = {
3439
- ..._params,
3440
- schemaPath: [..._params.schemaPath, schema],
3441
- path: _params.path
3442
- };
3443
- if (schema._zod.processJSONSchema) {
3444
- schema._zod.processJSONSchema(ctx, result.schema, params);
3055
+ const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
3056
+ this.seen.set(schema, result);
3057
+ const overrideSchema = schema._zod.toJSONSchema?.();
3058
+ if (overrideSchema) {
3059
+ result.schema = overrideSchema;
3445
3060
  } else {
3446
- const _json = result.schema;
3447
- const processor = ctx.processors[def.type];
3448
- if (!processor) {
3449
- throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
3061
+ const params = {
3062
+ ..._params,
3063
+ schemaPath: [..._params.schemaPath, schema],
3064
+ path: _params.path
3065
+ };
3066
+ const parent = schema._zod.parent;
3067
+ if (parent) {
3068
+ result.ref = parent;
3069
+ this.process(parent, params);
3070
+ this.seen.get(parent).isParent = true;
3071
+ } else {
3072
+ const _json = result.schema;
3073
+ switch (def.type) {
3074
+ case "string": {
3075
+ const json = _json;
3076
+ json.type = "string";
3077
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3078
+ if (typeof minimum === "number")
3079
+ json.minLength = minimum;
3080
+ if (typeof maximum === "number")
3081
+ json.maxLength = maximum;
3082
+ if (format) {
3083
+ json.format = formatMap[format] ?? format;
3084
+ if (json.format === "")
3085
+ delete json.format;
3086
+ }
3087
+ if (contentEncoding)
3088
+ json.contentEncoding = contentEncoding;
3089
+ if (patterns && patterns.size > 0) {
3090
+ const regexes = [...patterns];
3091
+ if (regexes.length === 1)
3092
+ json.pattern = regexes[0].source;
3093
+ else if (regexes.length > 1) {
3094
+ result.schema.allOf = [
3095
+ ...regexes.map((regex) => ({
3096
+ ...this.target === "draft-7" ? { type: "string" } : {},
3097
+ pattern: regex.source
3098
+ }))
3099
+ ];
3100
+ }
3101
+ }
3102
+ break;
3103
+ }
3104
+ case "number": {
3105
+ const json = _json;
3106
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3107
+ if (typeof format === "string" && format.includes("int"))
3108
+ json.type = "integer";
3109
+ else
3110
+ json.type = "number";
3111
+ if (typeof exclusiveMinimum === "number")
3112
+ json.exclusiveMinimum = exclusiveMinimum;
3113
+ if (typeof minimum === "number") {
3114
+ json.minimum = minimum;
3115
+ if (typeof exclusiveMinimum === "number") {
3116
+ if (exclusiveMinimum >= minimum)
3117
+ delete json.minimum;
3118
+ else
3119
+ delete json.exclusiveMinimum;
3120
+ }
3121
+ }
3122
+ if (typeof exclusiveMaximum === "number")
3123
+ json.exclusiveMaximum = exclusiveMaximum;
3124
+ if (typeof maximum === "number") {
3125
+ json.maximum = maximum;
3126
+ if (typeof exclusiveMaximum === "number") {
3127
+ if (exclusiveMaximum <= maximum)
3128
+ delete json.maximum;
3129
+ else
3130
+ delete json.exclusiveMaximum;
3131
+ }
3132
+ }
3133
+ if (typeof multipleOf === "number")
3134
+ json.multipleOf = multipleOf;
3135
+ break;
3136
+ }
3137
+ case "boolean": {
3138
+ const json = _json;
3139
+ json.type = "boolean";
3140
+ break;
3141
+ }
3142
+ case "bigint": {
3143
+ if (this.unrepresentable === "throw") {
3144
+ throw new Error("BigInt cannot be represented in JSON Schema");
3145
+ }
3146
+ break;
3147
+ }
3148
+ case "symbol": {
3149
+ if (this.unrepresentable === "throw") {
3150
+ throw new Error("Symbols cannot be represented in JSON Schema");
3151
+ }
3152
+ break;
3153
+ }
3154
+ case "null": {
3155
+ _json.type = "null";
3156
+ break;
3157
+ }
3158
+ case "any": {
3159
+ break;
3160
+ }
3161
+ case "unknown": {
3162
+ break;
3163
+ }
3164
+ case "undefined": {
3165
+ if (this.unrepresentable === "throw") {
3166
+ throw new Error("Undefined cannot be represented in JSON Schema");
3167
+ }
3168
+ break;
3169
+ }
3170
+ case "void": {
3171
+ if (this.unrepresentable === "throw") {
3172
+ throw new Error("Void cannot be represented in JSON Schema");
3173
+ }
3174
+ break;
3175
+ }
3176
+ case "never": {
3177
+ _json.not = {};
3178
+ break;
3179
+ }
3180
+ case "date": {
3181
+ if (this.unrepresentable === "throw") {
3182
+ throw new Error("Date cannot be represented in JSON Schema");
3183
+ }
3184
+ break;
3185
+ }
3186
+ case "array": {
3187
+ const json = _json;
3188
+ const { minimum, maximum } = schema._zod.bag;
3189
+ if (typeof minimum === "number")
3190
+ json.minItems = minimum;
3191
+ if (typeof maximum === "number")
3192
+ json.maxItems = maximum;
3193
+ json.type = "array";
3194
+ json.items = this.process(def.element, { ...params, path: [...params.path, "items"] });
3195
+ break;
3196
+ }
3197
+ case "object": {
3198
+ const json = _json;
3199
+ json.type = "object";
3200
+ json.properties = {};
3201
+ const shape = def.shape;
3202
+ for (const key in shape) {
3203
+ json.properties[key] = this.process(shape[key], {
3204
+ ...params,
3205
+ path: [...params.path, "properties", key]
3206
+ });
3207
+ }
3208
+ const allKeys = new Set(Object.keys(shape));
3209
+ const requiredKeys = new Set([...allKeys].filter((key) => {
3210
+ const v = def.shape[key]._zod;
3211
+ if (this.io === "input") {
3212
+ return v.optin === undefined;
3213
+ } else {
3214
+ return v.optout === undefined;
3215
+ }
3216
+ }));
3217
+ if (requiredKeys.size > 0) {
3218
+ json.required = Array.from(requiredKeys);
3219
+ }
3220
+ if (def.catchall?._zod.def.type === "never") {
3221
+ json.additionalProperties = false;
3222
+ } else if (!def.catchall) {
3223
+ if (this.io === "output")
3224
+ json.additionalProperties = false;
3225
+ } else if (def.catchall) {
3226
+ json.additionalProperties = this.process(def.catchall, {
3227
+ ...params,
3228
+ path: [...params.path, "additionalProperties"]
3229
+ });
3230
+ }
3231
+ break;
3232
+ }
3233
+ case "union": {
3234
+ const json = _json;
3235
+ json.anyOf = def.options.map((x, i) => this.process(x, {
3236
+ ...params,
3237
+ path: [...params.path, "anyOf", i]
3238
+ }));
3239
+ break;
3240
+ }
3241
+ case "intersection": {
3242
+ const json = _json;
3243
+ const a = this.process(def.left, {
3244
+ ...params,
3245
+ path: [...params.path, "allOf", 0]
3246
+ });
3247
+ const b = this.process(def.right, {
3248
+ ...params,
3249
+ path: [...params.path, "allOf", 1]
3250
+ });
3251
+ const isSimpleIntersection = (val) => ("allOf" in val) && Object.keys(val).length === 1;
3252
+ const allOf = [
3253
+ ...isSimpleIntersection(a) ? a.allOf : [a],
3254
+ ...isSimpleIntersection(b) ? b.allOf : [b]
3255
+ ];
3256
+ json.allOf = allOf;
3257
+ break;
3258
+ }
3259
+ case "tuple": {
3260
+ const json = _json;
3261
+ json.type = "array";
3262
+ const prefixItems = def.items.map((x, i) => this.process(x, { ...params, path: [...params.path, "prefixItems", i] }));
3263
+ if (this.target === "draft-2020-12") {
3264
+ json.prefixItems = prefixItems;
3265
+ } else {
3266
+ json.items = prefixItems;
3267
+ }
3268
+ if (def.rest) {
3269
+ const rest = this.process(def.rest, {
3270
+ ...params,
3271
+ path: [...params.path, "items"]
3272
+ });
3273
+ if (this.target === "draft-2020-12") {
3274
+ json.items = rest;
3275
+ } else {
3276
+ json.additionalItems = rest;
3277
+ }
3278
+ }
3279
+ if (def.rest) {
3280
+ json.items = this.process(def.rest, {
3281
+ ...params,
3282
+ path: [...params.path, "items"]
3283
+ });
3284
+ }
3285
+ const { minimum, maximum } = schema._zod.bag;
3286
+ if (typeof minimum === "number")
3287
+ json.minItems = minimum;
3288
+ if (typeof maximum === "number")
3289
+ json.maxItems = maximum;
3290
+ break;
3291
+ }
3292
+ case "record": {
3293
+ const json = _json;
3294
+ json.type = "object";
3295
+ json.propertyNames = this.process(def.keyType, { ...params, path: [...params.path, "propertyNames"] });
3296
+ json.additionalProperties = this.process(def.valueType, {
3297
+ ...params,
3298
+ path: [...params.path, "additionalProperties"]
3299
+ });
3300
+ break;
3301
+ }
3302
+ case "map": {
3303
+ if (this.unrepresentable === "throw") {
3304
+ throw new Error("Map cannot be represented in JSON Schema");
3305
+ }
3306
+ break;
3307
+ }
3308
+ case "set": {
3309
+ if (this.unrepresentable === "throw") {
3310
+ throw new Error("Set cannot be represented in JSON Schema");
3311
+ }
3312
+ break;
3313
+ }
3314
+ case "enum": {
3315
+ const json = _json;
3316
+ const values = getEnumValues(def.entries);
3317
+ if (values.every((v) => typeof v === "number"))
3318
+ json.type = "number";
3319
+ if (values.every((v) => typeof v === "string"))
3320
+ json.type = "string";
3321
+ json.enum = values;
3322
+ break;
3323
+ }
3324
+ case "literal": {
3325
+ const json = _json;
3326
+ const vals = [];
3327
+ for (const val of def.values) {
3328
+ if (val === undefined) {
3329
+ if (this.unrepresentable === "throw") {
3330
+ throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3331
+ }
3332
+ } else if (typeof val === "bigint") {
3333
+ if (this.unrepresentable === "throw") {
3334
+ throw new Error("BigInt literals cannot be represented in JSON Schema");
3335
+ } else {
3336
+ vals.push(Number(val));
3337
+ }
3338
+ } else {
3339
+ vals.push(val);
3340
+ }
3341
+ }
3342
+ if (vals.length === 0) {} else if (vals.length === 1) {
3343
+ const val = vals[0];
3344
+ json.type = val === null ? "null" : typeof val;
3345
+ json.const = val;
3346
+ } else {
3347
+ if (vals.every((v) => typeof v === "number"))
3348
+ json.type = "number";
3349
+ if (vals.every((v) => typeof v === "string"))
3350
+ json.type = "string";
3351
+ if (vals.every((v) => typeof v === "boolean"))
3352
+ json.type = "string";
3353
+ if (vals.every((v) => v === null))
3354
+ json.type = "null";
3355
+ json.enum = vals;
3356
+ }
3357
+ break;
3358
+ }
3359
+ case "file": {
3360
+ const json = _json;
3361
+ const file = {
3362
+ type: "string",
3363
+ format: "binary",
3364
+ contentEncoding: "binary"
3365
+ };
3366
+ const { minimum, maximum, mime } = schema._zod.bag;
3367
+ if (minimum !== undefined)
3368
+ file.minLength = minimum;
3369
+ if (maximum !== undefined)
3370
+ file.maxLength = maximum;
3371
+ if (mime) {
3372
+ if (mime.length === 1) {
3373
+ file.contentMediaType = mime[0];
3374
+ Object.assign(json, file);
3375
+ } else {
3376
+ json.anyOf = mime.map((m) => {
3377
+ const mFile = { ...file, contentMediaType: m };
3378
+ return mFile;
3379
+ });
3380
+ }
3381
+ } else {
3382
+ Object.assign(json, file);
3383
+ }
3384
+ break;
3385
+ }
3386
+ case "transform": {
3387
+ if (this.unrepresentable === "throw") {
3388
+ throw new Error("Transforms cannot be represented in JSON Schema");
3389
+ }
3390
+ break;
3391
+ }
3392
+ case "nullable": {
3393
+ const inner = this.process(def.innerType, params);
3394
+ _json.anyOf = [inner, { type: "null" }];
3395
+ break;
3396
+ }
3397
+ case "nonoptional": {
3398
+ this.process(def.innerType, params);
3399
+ result.ref = def.innerType;
3400
+ break;
3401
+ }
3402
+ case "success": {
3403
+ const json = _json;
3404
+ json.type = "boolean";
3405
+ break;
3406
+ }
3407
+ case "default": {
3408
+ this.process(def.innerType, params);
3409
+ result.ref = def.innerType;
3410
+ _json.default = JSON.parse(JSON.stringify(def.defaultValue));
3411
+ break;
3412
+ }
3413
+ case "prefault": {
3414
+ this.process(def.innerType, params);
3415
+ result.ref = def.innerType;
3416
+ if (this.io === "input")
3417
+ _json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3418
+ break;
3419
+ }
3420
+ case "catch": {
3421
+ this.process(def.innerType, params);
3422
+ result.ref = def.innerType;
3423
+ let catchValue;
3424
+ try {
3425
+ catchValue = def.catchValue(undefined);
3426
+ } catch {
3427
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3428
+ }
3429
+ _json.default = catchValue;
3430
+ break;
3431
+ }
3432
+ case "nan": {
3433
+ if (this.unrepresentable === "throw") {
3434
+ throw new Error("NaN cannot be represented in JSON Schema");
3435
+ }
3436
+ break;
3437
+ }
3438
+ case "template_literal": {
3439
+ const json = _json;
3440
+ const pattern = schema._zod.pattern;
3441
+ if (!pattern)
3442
+ throw new Error("Pattern not found in template literal");
3443
+ json.type = "string";
3444
+ json.pattern = pattern.source;
3445
+ break;
3446
+ }
3447
+ case "pipe": {
3448
+ const innerType = this.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3449
+ this.process(innerType, params);
3450
+ result.ref = innerType;
3451
+ break;
3452
+ }
3453
+ case "readonly": {
3454
+ this.process(def.innerType, params);
3455
+ result.ref = def.innerType;
3456
+ _json.readOnly = true;
3457
+ break;
3458
+ }
3459
+ case "promise": {
3460
+ this.process(def.innerType, params);
3461
+ result.ref = def.innerType;
3462
+ break;
3463
+ }
3464
+ case "optional": {
3465
+ this.process(def.innerType, params);
3466
+ result.ref = def.innerType;
3467
+ break;
3468
+ }
3469
+ case "lazy": {
3470
+ const innerType = schema._zod.innerType;
3471
+ this.process(innerType, params);
3472
+ result.ref = innerType;
3473
+ break;
3474
+ }
3475
+ case "custom": {
3476
+ if (this.unrepresentable === "throw") {
3477
+ throw new Error("Custom types cannot be represented in JSON Schema");
3478
+ }
3479
+ break;
3480
+ }
3481
+ default: {}
3482
+ }
3450
3483
  }
3451
- processor(schema, ctx, _json, params);
3452
3484
  }
3453
- const parent = schema._zod.parent;
3454
- if (parent) {
3455
- if (!result.ref)
3456
- result.ref = parent;
3457
- process(parent, ctx, params);
3458
- ctx.seen.get(parent).isParent = true;
3485
+ const meta = this.metadataRegistry.get(schema);
3486
+ if (meta)
3487
+ Object.assign(result.schema, meta);
3488
+ if (this.io === "input" && isTransforming(schema)) {
3489
+ delete result.schema.examples;
3490
+ delete result.schema.default;
3459
3491
  }
3492
+ if (this.io === "input" && result.schema._prefault)
3493
+ (_a = result.schema).default ?? (_a.default = result.schema._prefault);
3494
+ delete result.schema._prefault;
3495
+ const _result = this.seen.get(schema);
3496
+ return _result.schema;
3460
3497
  }
3461
- const meta = ctx.metadataRegistry.get(schema);
3462
- if (meta)
3463
- Object.assign(result.schema, meta);
3464
- if (ctx.io === "input" && isTransforming(schema)) {
3465
- delete result.schema.examples;
3466
- delete result.schema.default;
3467
- }
3468
- if (ctx.io === "input" && result.schema._prefault)
3469
- (_a2 = result.schema).default ?? (_a2.default = result.schema._prefault);
3470
- delete result.schema._prefault;
3471
- const _result = ctx.seen.get(schema);
3472
- return _result.schema;
3473
- }
3474
- function extractDefs(ctx, schema) {
3475
- const root = ctx.seen.get(schema);
3476
- if (!root)
3477
- throw new Error("Unprocessed schema. This is a bug in Zod.");
3478
- const idToSchema = new Map;
3479
- for (const entry of ctx.seen.entries()) {
3480
- const id = ctx.metadataRegistry.get(entry[0])?.id;
3481
- if (id) {
3482
- const existing = idToSchema.get(id);
3483
- if (existing && existing !== entry[0]) {
3484
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3498
+ emit(schema, _params) {
3499
+ const params = {
3500
+ cycles: _params?.cycles ?? "ref",
3501
+ reused: _params?.reused ?? "inline",
3502
+ external: _params?.external ?? undefined
3503
+ };
3504
+ const root = this.seen.get(schema);
3505
+ if (!root)
3506
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
3507
+ const makeURI = (entry) => {
3508
+ const defsSegment = this.target === "draft-2020-12" ? "$defs" : "definitions";
3509
+ if (params.external) {
3510
+ const externalId = params.external.registry.get(entry[0])?.id;
3511
+ const uriGenerator = params.external.uri ?? ((id2) => id2);
3512
+ if (externalId) {
3513
+ return { ref: uriGenerator(externalId) };
3514
+ }
3515
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${this.counter++}`;
3516
+ entry[1].defId = id;
3517
+ return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
3485
3518
  }
3486
- idToSchema.set(id, entry[0]);
3487
- }
3488
- }
3489
- const makeURI = (entry) => {
3490
- const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3491
- if (ctx.external) {
3492
- const externalId = ctx.external.registry.get(entry[0])?.id;
3493
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
3494
- if (externalId) {
3495
- return { ref: uriGenerator(externalId) };
3519
+ if (entry[1] === root) {
3520
+ return { ref: "#" };
3521
+ }
3522
+ const uriPrefix = `#`;
3523
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3524
+ const defId = entry[1].schema.id ?? `__schema${this.counter++}`;
3525
+ return { defId, ref: defUriPrefix + defId };
3526
+ };
3527
+ const extractToDef = (entry) => {
3528
+ if (entry[1].schema.$ref) {
3529
+ return;
3496
3530
  }
3497
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
3498
- entry[1].defId = id;
3499
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
3500
- }
3501
- if (entry[1] === root) {
3502
- return { ref: "#" };
3503
- }
3504
- const uriPrefix = `#`;
3505
- const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3506
- const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
3507
- return { defId, ref: defUriPrefix + defId };
3508
- };
3509
- const extractToDef = (entry) => {
3510
- if (entry[1].schema.$ref) {
3511
- return;
3512
- }
3513
- const seen = entry[1];
3514
- const { ref, defId } = makeURI(entry);
3515
- seen.def = { ...seen.schema };
3516
- if (defId)
3517
- seen.defId = defId;
3518
- const schema2 = seen.schema;
3519
- for (const key in schema2) {
3520
- delete schema2[key];
3521
- }
3522
- schema2.$ref = ref;
3523
- };
3524
- if (ctx.cycles === "throw") {
3525
- for (const entry of ctx.seen.entries()) {
3526
3531
  const seen = entry[1];
3527
- if (seen.cycle) {
3528
- throw new Error("Cycle detected: " + `#/${seen.cycle?.join("/")}/<root>` + '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
3532
+ const { ref, defId } = makeURI(entry);
3533
+ seen.def = { ...seen.schema };
3534
+ if (defId)
3535
+ seen.defId = defId;
3536
+ const schema2 = seen.schema;
3537
+ for (const key in schema2) {
3538
+ delete schema2[key];
3539
+ }
3540
+ schema2.$ref = ref;
3541
+ };
3542
+ if (params.cycles === "throw") {
3543
+ for (const entry of this.seen.entries()) {
3544
+ const seen = entry[1];
3545
+ if (seen.cycle) {
3546
+ throw new Error("Cycle detected: " + `#/${seen.cycle?.join("/")}/<root>` + '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
3547
+ }
3529
3548
  }
3530
3549
  }
3531
- }
3532
- for (const entry of ctx.seen.entries()) {
3533
- const seen = entry[1];
3534
- if (schema === entry[0]) {
3535
- extractToDef(entry);
3536
- continue;
3537
- }
3538
- if (ctx.external) {
3539
- const ext = ctx.external.registry.get(entry[0])?.id;
3540
- if (schema !== entry[0] && ext) {
3550
+ for (const entry of this.seen.entries()) {
3551
+ const seen = entry[1];
3552
+ if (schema === entry[0]) {
3541
3553
  extractToDef(entry);
3542
3554
  continue;
3543
3555
  }
3544
- }
3545
- const id = ctx.metadataRegistry.get(entry[0])?.id;
3546
- if (id) {
3547
- extractToDef(entry);
3548
- continue;
3549
- }
3550
- if (seen.cycle) {
3551
- extractToDef(entry);
3552
- continue;
3553
- }
3554
- if (seen.count > 1) {
3555
- if (ctx.reused === "ref") {
3556
+ if (params.external) {
3557
+ const ext = params.external.registry.get(entry[0])?.id;
3558
+ if (schema !== entry[0] && ext) {
3559
+ extractToDef(entry);
3560
+ continue;
3561
+ }
3562
+ }
3563
+ const id = this.metadataRegistry.get(entry[0])?.id;
3564
+ if (id) {
3556
3565
  extractToDef(entry);
3557
3566
  continue;
3558
3567
  }
3559
- }
3560
- }
3561
- }
3562
- function finalize(ctx, schema) {
3563
- const root = ctx.seen.get(schema);
3564
- if (!root)
3565
- throw new Error("Unprocessed schema. This is a bug in Zod.");
3566
- const flattenRef = (zodSchema) => {
3567
- const seen = ctx.seen.get(zodSchema);
3568
- if (seen.ref === null)
3569
- return;
3570
- const schema2 = seen.def ?? seen.schema;
3571
- const _cached = { ...schema2 };
3572
- const ref = seen.ref;
3573
- seen.ref = null;
3574
- if (ref) {
3575
- flattenRef(ref);
3576
- const refSeen = ctx.seen.get(ref);
3577
- const refSchema = refSeen.schema;
3578
- if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3579
- schema2.allOf = schema2.allOf ?? [];
3580
- schema2.allOf.push(refSchema);
3581
- } else {
3582
- Object.assign(schema2, refSchema);
3568
+ if (seen.cycle) {
3569
+ extractToDef(entry);
3570
+ continue;
3583
3571
  }
3584
- Object.assign(schema2, _cached);
3585
- const isParentRef = zodSchema._zod.parent === ref;
3586
- if (isParentRef) {
3587
- for (const key in schema2) {
3588
- if (key === "$ref" || key === "allOf")
3589
- continue;
3590
- if (!(key in _cached)) {
3591
- delete schema2[key];
3592
- }
3572
+ if (seen.count > 1) {
3573
+ if (params.reused === "ref") {
3574
+ extractToDef(entry);
3575
+ continue;
3593
3576
  }
3594
3577
  }
3595
- if (refSchema.$ref && refSeen.def) {
3596
- for (const key in schema2) {
3597
- if (key === "$ref" || key === "allOf")
3598
- continue;
3599
- if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
3600
- delete schema2[key];
3601
- }
3578
+ }
3579
+ const flattenRef = (zodSchema, params2) => {
3580
+ const seen = this.seen.get(zodSchema);
3581
+ const schema2 = seen.def ?? seen.schema;
3582
+ const _cached = { ...schema2 };
3583
+ if (seen.ref === null) {
3584
+ return;
3585
+ }
3586
+ const ref = seen.ref;
3587
+ seen.ref = null;
3588
+ if (ref) {
3589
+ flattenRef(ref, params2);
3590
+ const refSchema = this.seen.get(ref).schema;
3591
+ if (refSchema.$ref && params2.target === "draft-7") {
3592
+ schema2.allOf = schema2.allOf ?? [];
3593
+ schema2.allOf.push(refSchema);
3594
+ } else {
3595
+ Object.assign(schema2, refSchema);
3596
+ Object.assign(schema2, _cached);
3602
3597
  }
3603
3598
  }
3599
+ if (!seen.isParent)
3600
+ this.override({
3601
+ zodSchema,
3602
+ jsonSchema: schema2,
3603
+ path: seen.path ?? []
3604
+ });
3605
+ };
3606
+ for (const entry of [...this.seen.entries()].reverse()) {
3607
+ flattenRef(entry[0], { target: this.target });
3608
+ }
3609
+ const result = {};
3610
+ if (this.target === "draft-2020-12") {
3611
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
3612
+ } else if (this.target === "draft-7") {
3613
+ result.$schema = "http://json-schema.org/draft-07/schema#";
3614
+ } else {
3615
+ console.warn(`Invalid target: ${this.target}`);
3616
+ }
3617
+ if (params.external?.uri) {
3618
+ const id = params.external.registry.get(schema)?.id;
3619
+ if (!id)
3620
+ throw new Error("Schema is missing an `id` property");
3621
+ result.$id = params.external.uri(id);
3622
+ }
3623
+ Object.assign(result, root.def);
3624
+ const defs = params.external?.defs ?? {};
3625
+ for (const entry of this.seen.entries()) {
3626
+ const seen = entry[1];
3627
+ if (seen.def && seen.defId) {
3628
+ defs[seen.defId] = seen.def;
3629
+ }
3604
3630
  }
3605
- const parent = zodSchema._zod.parent;
3606
- if (parent && parent !== ref) {
3607
- flattenRef(parent);
3608
- const parentSeen = ctx.seen.get(parent);
3609
- if (parentSeen?.schema.$ref) {
3610
- schema2.$ref = parentSeen.schema.$ref;
3611
- if (parentSeen.def) {
3612
- for (const key in schema2) {
3613
- if (key === "$ref" || key === "allOf")
3614
- continue;
3615
- if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
3616
- delete schema2[key];
3617
- }
3618
- }
3631
+ if (params.external) {} else {
3632
+ if (Object.keys(defs).length > 0) {
3633
+ if (this.target === "draft-2020-12") {
3634
+ result.$defs = defs;
3635
+ } else {
3636
+ result.definitions = defs;
3619
3637
  }
3620
3638
  }
3621
3639
  }
3622
- ctx.override({
3623
- zodSchema,
3624
- jsonSchema: schema2,
3625
- path: seen.path ?? []
3626
- });
3627
- };
3628
- for (const entry of [...ctx.seen.entries()].reverse()) {
3629
- flattenRef(entry[0]);
3630
- }
3631
- const result = {};
3632
- if (ctx.target === "draft-2020-12") {
3633
- result.$schema = "https://json-schema.org/draft/2020-12/schema";
3634
- } else if (ctx.target === "draft-07") {
3635
- result.$schema = "http://json-schema.org/draft-07/schema#";
3636
- } else if (ctx.target === "draft-04") {
3637
- result.$schema = "http://json-schema.org/draft-04/schema#";
3638
- } else if (ctx.target === "openapi-3.0") {}
3639
- if (ctx.external?.uri) {
3640
- const id = ctx.external.registry.get(schema)?.id;
3641
- if (!id)
3642
- throw new Error("Schema is missing an `id` property");
3643
- result.$id = ctx.external.uri(id);
3644
- }
3645
- Object.assign(result, root.def ?? root.schema);
3646
- const defs = ctx.external?.defs ?? {};
3647
- for (const entry of ctx.seen.entries()) {
3648
- const seen = entry[1];
3649
- if (seen.def && seen.defId) {
3650
- defs[seen.defId] = seen.def;
3640
+ try {
3641
+ return JSON.parse(JSON.stringify(result));
3642
+ } catch (_err) {
3643
+ throw new Error("Error converting schema to JSON.");
3651
3644
  }
3652
3645
  }
3653
- if (ctx.external) {} else {
3646
+ }
3647
+ function toJSONSchema(input, _params) {
3648
+ if (input instanceof $ZodRegistry) {
3649
+ const gen2 = new JSONSchemaGenerator(_params);
3650
+ const defs = {};
3651
+ for (const entry of input._idmap.entries()) {
3652
+ const [_, schema] = entry;
3653
+ gen2.process(schema);
3654
+ }
3655
+ const schemas = {};
3656
+ const external = {
3657
+ registry: input,
3658
+ uri: _params?.uri,
3659
+ defs
3660
+ };
3661
+ for (const entry of input._idmap.entries()) {
3662
+ const [key, schema] = entry;
3663
+ schemas[key] = gen2.emit(schema, {
3664
+ ..._params,
3665
+ external
3666
+ });
3667
+ }
3654
3668
  if (Object.keys(defs).length > 0) {
3655
- if (ctx.target === "draft-2020-12") {
3656
- result.$defs = defs;
3657
- } else {
3658
- result.definitions = defs;
3659
- }
3669
+ const defsSegment = gen2.target === "draft-2020-12" ? "$defs" : "definitions";
3670
+ schemas.__shared = {
3671
+ [defsSegment]: defs
3672
+ };
3660
3673
  }
3674
+ return { schemas };
3661
3675
  }
3662
- try {
3663
- const finalized = JSON.parse(JSON.stringify(result));
3664
- Object.defineProperty(finalized, "~standard", {
3665
- value: {
3666
- ...schema["~standard"],
3667
- jsonSchema: {
3668
- input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3669
- output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3670
- }
3671
- },
3672
- enumerable: false,
3673
- writable: false
3674
- });
3675
- return finalized;
3676
- } catch (_err) {
3677
- throw new Error("Error converting schema to JSON.");
3678
- }
3676
+ const gen = new JSONSchemaGenerator(_params);
3677
+ gen.process(input);
3678
+ return gen.emit(input, _params);
3679
3679
  }
3680
3680
  function isTransforming(_schema, _ctx) {
3681
3681
  const ctx = _ctx ?? { seen: new Set };
3682
3682
  if (ctx.seen.has(_schema))
3683
3683
  return false;
3684
3684
  ctx.seen.add(_schema);
3685
- const def = _schema._zod.def;
3686
- if (def.type === "transform")
3687
- return true;
3688
- if (def.type === "array")
3689
- return isTransforming(def.element, ctx);
3690
- if (def.type === "set")
3691
- return isTransforming(def.valueType, ctx);
3692
- if (def.type === "lazy")
3693
- return isTransforming(def.getter(), ctx);
3694
- if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
3695
- return isTransforming(def.innerType, ctx);
3696
- }
3697
- if (def.type === "intersection") {
3698
- return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3699
- }
3700
- if (def.type === "record" || def.type === "map") {
3701
- return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3702
- }
3703
- if (def.type === "pipe") {
3704
- return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3705
- }
3706
- if (def.type === "object") {
3707
- for (const key in def.shape) {
3708
- if (isTransforming(def.shape[key], ctx))
3709
- return true;
3710
- }
3711
- return false;
3712
- }
3713
- if (def.type === "union") {
3714
- for (const option of def.options) {
3715
- if (isTransforming(option, ctx))
3716
- return true;
3717
- }
3718
- return false;
3719
- }
3720
- if (def.type === "tuple") {
3721
- for (const item of def.items) {
3722
- if (isTransforming(item, ctx))
3723
- return true;
3724
- }
3725
- if (def.rest && isTransforming(def.rest, ctx))
3726
- return true;
3727
- return false;
3728
- }
3729
- return false;
3730
- }
3731
- var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3732
- const ctx = initializeContext({ ...params, processors });
3733
- process(schema, ctx);
3734
- extractDefs(ctx, schema);
3735
- return finalize(ctx, schema);
3736
- };
3737
- var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3738
- const { libraryOptions, target } = params ?? {};
3739
- const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
3740
- process(schema, ctx);
3741
- extractDefs(ctx, schema);
3742
- return finalize(ctx, schema);
3743
- };
3744
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/json-schema-processors.js
3745
- var formatMap = {
3746
- guid: "uuid",
3747
- url: "uri",
3748
- datetime: "date-time",
3749
- json_string: "json-string",
3750
- regex: ""
3751
- };
3752
- var stringProcessor = (schema, ctx, _json, _params) => {
3753
- const json = _json;
3754
- json.type = "string";
3755
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3756
- if (typeof minimum === "number")
3757
- json.minLength = minimum;
3758
- if (typeof maximum === "number")
3759
- json.maxLength = maximum;
3760
- if (format) {
3761
- json.format = formatMap[format] ?? format;
3762
- if (json.format === "")
3763
- delete json.format;
3764
- if (format === "time") {
3765
- delete json.format;
3766
- }
3767
- }
3768
- if (contentEncoding)
3769
- json.contentEncoding = contentEncoding;
3770
- if (patterns && patterns.size > 0) {
3771
- const regexes = [...patterns];
3772
- if (regexes.length === 1)
3773
- json.pattern = regexes[0].source;
3774
- else if (regexes.length > 1) {
3775
- json.allOf = [
3776
- ...regexes.map((regex) => ({
3777
- ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3778
- pattern: regex.source
3779
- }))
3780
- ];
3781
- }
3782
- }
3783
- };
3784
- var numberProcessor = (schema, ctx, _json, _params) => {
3785
- const json = _json;
3786
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3787
- if (typeof format === "string" && format.includes("int"))
3788
- json.type = "integer";
3789
- else
3790
- json.type = "number";
3791
- if (typeof exclusiveMinimum === "number") {
3792
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3793
- json.minimum = exclusiveMinimum;
3794
- json.exclusiveMinimum = true;
3795
- } else {
3796
- json.exclusiveMinimum = exclusiveMinimum;
3797
- }
3798
- }
3799
- if (typeof minimum === "number") {
3800
- json.minimum = minimum;
3801
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
3802
- if (exclusiveMinimum >= minimum)
3803
- delete json.minimum;
3804
- else
3805
- delete json.exclusiveMinimum;
3806
- }
3807
- }
3808
- if (typeof exclusiveMaximum === "number") {
3809
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3810
- json.maximum = exclusiveMaximum;
3811
- json.exclusiveMaximum = true;
3812
- } else {
3813
- json.exclusiveMaximum = exclusiveMaximum;
3814
- }
3815
- }
3816
- if (typeof maximum === "number") {
3817
- json.maximum = maximum;
3818
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
3819
- if (exclusiveMaximum <= maximum)
3820
- delete json.maximum;
3821
- else
3822
- delete json.exclusiveMaximum;
3823
- }
3824
- }
3825
- if (typeof multipleOf === "number")
3826
- json.multipleOf = multipleOf;
3827
- };
3828
- var booleanProcessor = (_schema, _ctx, json, _params) => {
3829
- json.type = "boolean";
3830
- };
3831
- var bigintProcessor = (_schema, ctx, _json, _params) => {
3832
- if (ctx.unrepresentable === "throw") {
3833
- throw new Error("BigInt cannot be represented in JSON Schema");
3834
- }
3835
- };
3836
- var symbolProcessor = (_schema, ctx, _json, _params) => {
3837
- if (ctx.unrepresentable === "throw") {
3838
- throw new Error("Symbols cannot be represented in JSON Schema");
3839
- }
3840
- };
3841
- var nullProcessor = (_schema, ctx, json, _params) => {
3842
- if (ctx.target === "openapi-3.0") {
3843
- json.type = "string";
3844
- json.nullable = true;
3845
- json.enum = [null];
3846
- } else {
3847
- json.type = "null";
3848
- }
3849
- };
3850
- var undefinedProcessor = (_schema, ctx, _json, _params) => {
3851
- if (ctx.unrepresentable === "throw") {
3852
- throw new Error("Undefined cannot be represented in JSON Schema");
3853
- }
3854
- };
3855
- var voidProcessor = (_schema, ctx, _json, _params) => {
3856
- if (ctx.unrepresentable === "throw") {
3857
- throw new Error("Void cannot be represented in JSON Schema");
3858
- }
3859
- };
3860
- var neverProcessor = (_schema, _ctx, json, _params) => {
3861
- json.not = {};
3862
- };
3863
- var anyProcessor = (_schema, _ctx, _json, _params) => {};
3864
- var unknownProcessor = (_schema, _ctx, _json, _params) => {};
3865
- var dateProcessor = (_schema, ctx, _json, _params) => {
3866
- if (ctx.unrepresentable === "throw") {
3867
- throw new Error("Date cannot be represented in JSON Schema");
3868
- }
3869
- };
3870
- var enumProcessor = (schema, _ctx, json, _params) => {
3871
- const def = schema._zod.def;
3872
- const values = getEnumValues(def.entries);
3873
- if (values.every((v) => typeof v === "number"))
3874
- json.type = "number";
3875
- if (values.every((v) => typeof v === "string"))
3876
- json.type = "string";
3877
- json.enum = values;
3878
- };
3879
- var literalProcessor = (schema, ctx, json, _params) => {
3685
+ const schema = _schema;
3880
3686
  const def = schema._zod.def;
3881
- const vals = [];
3882
- for (const val of def.values) {
3883
- if (val === undefined) {
3884
- if (ctx.unrepresentable === "throw") {
3885
- throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3886
- }
3887
- } else if (typeof val === "bigint") {
3888
- if (ctx.unrepresentable === "throw") {
3889
- throw new Error("BigInt literals cannot be represented in JSON Schema");
3890
- } else {
3891
- vals.push(Number(val));
3687
+ switch (def.type) {
3688
+ case "string":
3689
+ case "number":
3690
+ case "bigint":
3691
+ case "boolean":
3692
+ case "date":
3693
+ case "symbol":
3694
+ case "undefined":
3695
+ case "null":
3696
+ case "any":
3697
+ case "unknown":
3698
+ case "never":
3699
+ case "void":
3700
+ case "literal":
3701
+ case "enum":
3702
+ case "nan":
3703
+ case "file":
3704
+ case "template_literal":
3705
+ return false;
3706
+ case "array": {
3707
+ return isTransforming(def.element, ctx);
3708
+ }
3709
+ case "object": {
3710
+ for (const key in def.shape) {
3711
+ if (isTransforming(def.shape[key], ctx))
3712
+ return true;
3892
3713
  }
3893
- } else {
3894
- vals.push(val);
3714
+ return false;
3895
3715
  }
3896
- }
3897
- if (vals.length === 0) {} else if (vals.length === 1) {
3898
- const val = vals[0];
3899
- json.type = val === null ? "null" : typeof val;
3900
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3901
- json.enum = [val];
3902
- } else {
3903
- json.const = val;
3716
+ case "union": {
3717
+ for (const option of def.options) {
3718
+ if (isTransforming(option, ctx))
3719
+ return true;
3720
+ }
3721
+ return false;
3904
3722
  }
3905
- } else {
3906
- if (vals.every((v) => typeof v === "number"))
3907
- json.type = "number";
3908
- if (vals.every((v) => typeof v === "string"))
3909
- json.type = "string";
3910
- if (vals.every((v) => typeof v === "boolean"))
3911
- json.type = "boolean";
3912
- if (vals.every((v) => v === null))
3913
- json.type = "null";
3914
- json.enum = vals;
3915
- }
3916
- };
3917
- var nanProcessor = (_schema, ctx, _json, _params) => {
3918
- if (ctx.unrepresentable === "throw") {
3919
- throw new Error("NaN cannot be represented in JSON Schema");
3920
- }
3921
- };
3922
- var templateLiteralProcessor = (schema, _ctx, json, _params) => {
3923
- const _json = json;
3924
- const pattern = schema._zod.pattern;
3925
- if (!pattern)
3926
- throw new Error("Pattern not found in template literal");
3927
- _json.type = "string";
3928
- _json.pattern = pattern.source;
3929
- };
3930
- var fileProcessor = (schema, _ctx, json, _params) => {
3931
- const _json = json;
3932
- const file = {
3933
- type: "string",
3934
- format: "binary",
3935
- contentEncoding: "binary"
3936
- };
3937
- const { minimum, maximum, mime } = schema._zod.bag;
3938
- if (minimum !== undefined)
3939
- file.minLength = minimum;
3940
- if (maximum !== undefined)
3941
- file.maxLength = maximum;
3942
- if (mime) {
3943
- if (mime.length === 1) {
3944
- file.contentMediaType = mime[0];
3945
- Object.assign(_json, file);
3946
- } else {
3947
- Object.assign(_json, file);
3948
- _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
3723
+ case "intersection": {
3724
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3949
3725
  }
3950
- } else {
3951
- Object.assign(_json, file);
3952
- }
3953
- };
3954
- var successProcessor = (_schema, _ctx, json, _params) => {
3955
- json.type = "boolean";
3956
- };
3957
- var customProcessor = (_schema, ctx, _json, _params) => {
3958
- if (ctx.unrepresentable === "throw") {
3959
- throw new Error("Custom types cannot be represented in JSON Schema");
3960
- }
3961
- };
3962
- var functionProcessor = (_schema, ctx, _json, _params) => {
3963
- if (ctx.unrepresentable === "throw") {
3964
- throw new Error("Function types cannot be represented in JSON Schema");
3965
- }
3966
- };
3967
- var transformProcessor = (_schema, ctx, _json, _params) => {
3968
- if (ctx.unrepresentable === "throw") {
3969
- throw new Error("Transforms cannot be represented in JSON Schema");
3970
- }
3971
- };
3972
- var mapProcessor = (_schema, ctx, _json, _params) => {
3973
- if (ctx.unrepresentable === "throw") {
3974
- throw new Error("Map cannot be represented in JSON Schema");
3975
- }
3976
- };
3977
- var setProcessor = (_schema, ctx, _json, _params) => {
3978
- if (ctx.unrepresentable === "throw") {
3979
- throw new Error("Set cannot be represented in JSON Schema");
3980
- }
3981
- };
3982
- var arrayProcessor = (schema, ctx, _json, params) => {
3983
- const json = _json;
3984
- const def = schema._zod.def;
3985
- const { minimum, maximum } = schema._zod.bag;
3986
- if (typeof minimum === "number")
3987
- json.minItems = minimum;
3988
- if (typeof maximum === "number")
3989
- json.maxItems = maximum;
3990
- json.type = "array";
3991
- json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
3992
- };
3993
- var objectProcessor = (schema, ctx, _json, params) => {
3994
- const json = _json;
3995
- const def = schema._zod.def;
3996
- json.type = "object";
3997
- json.properties = {};
3998
- const shape = def.shape;
3999
- for (const key in shape) {
4000
- json.properties[key] = process(shape[key], ctx, {
4001
- ...params,
4002
- path: [...params.path, "properties", key]
4003
- });
4004
- }
4005
- const allKeys = new Set(Object.keys(shape));
4006
- const requiredKeys = new Set([...allKeys].filter((key) => {
4007
- const v = def.shape[key]._zod;
4008
- if (ctx.io === "input") {
4009
- return v.optin === undefined;
4010
- } else {
4011
- return v.optout === undefined;
3726
+ case "tuple": {
3727
+ for (const item of def.items) {
3728
+ if (isTransforming(item, ctx))
3729
+ return true;
3730
+ }
3731
+ if (def.rest && isTransforming(def.rest, ctx))
3732
+ return true;
3733
+ return false;
4012
3734
  }
4013
- }));
4014
- if (requiredKeys.size > 0) {
4015
- json.required = Array.from(requiredKeys);
4016
- }
4017
- if (def.catchall?._zod.def.type === "never") {
4018
- json.additionalProperties = false;
4019
- } else if (!def.catchall) {
4020
- if (ctx.io === "output")
4021
- json.additionalProperties = false;
4022
- } else if (def.catchall) {
4023
- json.additionalProperties = process(def.catchall, ctx, {
4024
- ...params,
4025
- path: [...params.path, "additionalProperties"]
4026
- });
4027
- }
4028
- };
4029
- var unionProcessor = (schema, ctx, json, params) => {
4030
- const def = schema._zod.def;
4031
- const isExclusive = def.inclusive === false;
4032
- const options = def.options.map((x, i) => process(x, ctx, {
4033
- ...params,
4034
- path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
4035
- }));
4036
- if (isExclusive) {
4037
- json.oneOf = options;
4038
- } else {
4039
- json.anyOf = options;
4040
- }
4041
- };
4042
- var intersectionProcessor = (schema, ctx, json, params) => {
4043
- const def = schema._zod.def;
4044
- const a = process(def.left, ctx, {
4045
- ...params,
4046
- path: [...params.path, "allOf", 0]
4047
- });
4048
- const b = process(def.right, ctx, {
4049
- ...params,
4050
- path: [...params.path, "allOf", 1]
4051
- });
4052
- const isSimpleIntersection = (val) => ("allOf" in val) && Object.keys(val).length === 1;
4053
- const allOf = [
4054
- ...isSimpleIntersection(a) ? a.allOf : [a],
4055
- ...isSimpleIntersection(b) ? b.allOf : [b]
4056
- ];
4057
- json.allOf = allOf;
4058
- };
4059
- var tupleProcessor = (schema, ctx, _json, params) => {
4060
- const json = _json;
4061
- const def = schema._zod.def;
4062
- json.type = "array";
4063
- const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
4064
- const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
4065
- const prefixItems = def.items.map((x, i) => process(x, ctx, {
4066
- ...params,
4067
- path: [...params.path, prefixPath, i]
4068
- }));
4069
- const rest = def.rest ? process(def.rest, ctx, {
4070
- ...params,
4071
- path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
4072
- }) : null;
4073
- if (ctx.target === "draft-2020-12") {
4074
- json.prefixItems = prefixItems;
4075
- if (rest) {
4076
- json.items = rest;
3735
+ case "record": {
3736
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
4077
3737
  }
4078
- } else if (ctx.target === "openapi-3.0") {
4079
- json.items = {
4080
- anyOf: prefixItems
4081
- };
4082
- if (rest) {
4083
- json.items.anyOf.push(rest);
3738
+ case "map": {
3739
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
4084
3740
  }
4085
- json.minItems = prefixItems.length;
4086
- if (!rest) {
4087
- json.maxItems = prefixItems.length;
3741
+ case "set": {
3742
+ return isTransforming(def.valueType, ctx);
4088
3743
  }
4089
- } else {
4090
- json.items = prefixItems;
4091
- if (rest) {
4092
- json.additionalItems = rest;
3744
+ case "promise":
3745
+ case "optional":
3746
+ case "nonoptional":
3747
+ case "nullable":
3748
+ case "readonly":
3749
+ return isTransforming(def.innerType, ctx);
3750
+ case "lazy":
3751
+ return isTransforming(def.getter(), ctx);
3752
+ case "default": {
3753
+ return isTransforming(def.innerType, ctx);
4093
3754
  }
4094
- }
4095
- const { minimum, maximum } = schema._zod.bag;
4096
- if (typeof minimum === "number")
4097
- json.minItems = minimum;
4098
- if (typeof maximum === "number")
4099
- json.maxItems = maximum;
4100
- };
4101
- var recordProcessor = (schema, ctx, _json, params) => {
4102
- const json = _json;
4103
- const def = schema._zod.def;
4104
- json.type = "object";
4105
- const keyType = def.keyType;
4106
- const keyBag = keyType._zod.bag;
4107
- const patterns = keyBag?.patterns;
4108
- if (def.mode === "loose" && patterns && patterns.size > 0) {
4109
- const valueSchema = process(def.valueType, ctx, {
4110
- ...params,
4111
- path: [...params.path, "patternProperties", "*"]
4112
- });
4113
- json.patternProperties = {};
4114
- for (const pattern of patterns) {
4115
- json.patternProperties[pattern.source] = valueSchema;
3755
+ case "prefault": {
3756
+ return isTransforming(def.innerType, ctx);
4116
3757
  }
4117
- } else {
4118
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
4119
- json.propertyNames = process(def.keyType, ctx, {
4120
- ...params,
4121
- path: [...params.path, "propertyNames"]
4122
- });
3758
+ case "custom": {
3759
+ return false;
4123
3760
  }
4124
- json.additionalProperties = process(def.valueType, ctx, {
4125
- ...params,
4126
- path: [...params.path, "additionalProperties"]
4127
- });
4128
- }
4129
- const keyValues = keyType._zod.values;
4130
- if (keyValues) {
4131
- const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
4132
- if (validKeyValues.length > 0) {
4133
- json.required = validKeyValues;
3761
+ case "transform": {
3762
+ return true;
4134
3763
  }
4135
- }
4136
- };
4137
- var nullableProcessor = (schema, ctx, json, params) => {
4138
- const def = schema._zod.def;
4139
- const inner = process(def.innerType, ctx, params);
4140
- const seen = ctx.seen.get(schema);
4141
- if (ctx.target === "openapi-3.0") {
4142
- seen.ref = def.innerType;
4143
- json.nullable = true;
4144
- } else {
4145
- json.anyOf = [inner, { type: "null" }];
4146
- }
4147
- };
4148
- var nonoptionalProcessor = (schema, ctx, _json, params) => {
4149
- const def = schema._zod.def;
4150
- process(def.innerType, ctx, params);
4151
- const seen = ctx.seen.get(schema);
4152
- seen.ref = def.innerType;
4153
- };
4154
- var defaultProcessor = (schema, ctx, json, params) => {
4155
- const def = schema._zod.def;
4156
- process(def.innerType, ctx, params);
4157
- const seen = ctx.seen.get(schema);
4158
- seen.ref = def.innerType;
4159
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
4160
- };
4161
- var prefaultProcessor = (schema, ctx, json, params) => {
4162
- const def = schema._zod.def;
4163
- process(def.innerType, ctx, params);
4164
- const seen = ctx.seen.get(schema);
4165
- seen.ref = def.innerType;
4166
- if (ctx.io === "input")
4167
- json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4168
- };
4169
- var catchProcessor = (schema, ctx, json, params) => {
4170
- const def = schema._zod.def;
4171
- process(def.innerType, ctx, params);
4172
- const seen = ctx.seen.get(schema);
4173
- seen.ref = def.innerType;
4174
- let catchValue;
4175
- try {
4176
- catchValue = def.catchValue(undefined);
4177
- } catch {
4178
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4179
- }
4180
- json.default = catchValue;
4181
- };
4182
- var pipeProcessor = (schema, ctx, _json, params) => {
4183
- const def = schema._zod.def;
4184
- const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
4185
- process(innerType, ctx, params);
4186
- const seen = ctx.seen.get(schema);
4187
- seen.ref = innerType;
4188
- };
4189
- var readonlyProcessor = (schema, ctx, json, params) => {
4190
- const def = schema._zod.def;
4191
- process(def.innerType, ctx, params);
4192
- const seen = ctx.seen.get(schema);
4193
- seen.ref = def.innerType;
4194
- json.readOnly = true;
4195
- };
4196
- var promiseProcessor = (schema, ctx, _json, params) => {
4197
- const def = schema._zod.def;
4198
- process(def.innerType, ctx, params);
4199
- const seen = ctx.seen.get(schema);
4200
- seen.ref = def.innerType;
4201
- };
4202
- var optionalProcessor = (schema, ctx, _json, params) => {
4203
- const def = schema._zod.def;
4204
- process(def.innerType, ctx, params);
4205
- const seen = ctx.seen.get(schema);
4206
- seen.ref = def.innerType;
4207
- };
4208
- var lazyProcessor = (schema, ctx, _json, params) => {
4209
- const innerType = schema._zod.innerType;
4210
- process(innerType, ctx, params);
4211
- const seen = ctx.seen.get(schema);
4212
- seen.ref = innerType;
4213
- };
4214
- var allProcessors = {
4215
- string: stringProcessor,
4216
- number: numberProcessor,
4217
- boolean: booleanProcessor,
4218
- bigint: bigintProcessor,
4219
- symbol: symbolProcessor,
4220
- null: nullProcessor,
4221
- undefined: undefinedProcessor,
4222
- void: voidProcessor,
4223
- never: neverProcessor,
4224
- any: anyProcessor,
4225
- unknown: unknownProcessor,
4226
- date: dateProcessor,
4227
- enum: enumProcessor,
4228
- literal: literalProcessor,
4229
- nan: nanProcessor,
4230
- template_literal: templateLiteralProcessor,
4231
- file: fileProcessor,
4232
- success: successProcessor,
4233
- custom: customProcessor,
4234
- function: functionProcessor,
4235
- transform: transformProcessor,
4236
- map: mapProcessor,
4237
- set: setProcessor,
4238
- array: arrayProcessor,
4239
- object: objectProcessor,
4240
- union: unionProcessor,
4241
- intersection: intersectionProcessor,
4242
- tuple: tupleProcessor,
4243
- record: recordProcessor,
4244
- nullable: nullableProcessor,
4245
- nonoptional: nonoptionalProcessor,
4246
- default: defaultProcessor,
4247
- prefault: prefaultProcessor,
4248
- catch: catchProcessor,
4249
- pipe: pipeProcessor,
4250
- readonly: readonlyProcessor,
4251
- promise: promiseProcessor,
4252
- optional: optionalProcessor,
4253
- lazy: lazyProcessor
4254
- };
4255
- function toJSONSchema(input, params) {
4256
- if ("_idmap" in input) {
4257
- const registry2 = input;
4258
- const ctx2 = initializeContext({ ...params, processors: allProcessors });
4259
- const defs = {};
4260
- for (const entry of registry2._idmap.entries()) {
4261
- const [_, schema] = entry;
4262
- process(schema, ctx2);
3764
+ case "pipe": {
3765
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
4263
3766
  }
4264
- const schemas = {};
4265
- const external = {
4266
- registry: registry2,
4267
- uri: params?.uri,
4268
- defs
4269
- };
4270
- ctx2.external = external;
4271
- for (const entry of registry2._idmap.entries()) {
4272
- const [key, schema] = entry;
4273
- extractDefs(ctx2, schema);
4274
- schemas[key] = finalize(ctx2, schema);
3767
+ case "success": {
3768
+ return false;
4275
3769
  }
4276
- if (Object.keys(defs).length > 0) {
4277
- const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
4278
- schemas.__shared = {
4279
- [defsSegment]: defs
4280
- };
3770
+ case "catch": {
3771
+ return false;
4281
3772
  }
4282
- return { schemas };
3773
+ default:
4283
3774
  }
4284
- const ctx = initializeContext({ ...params, processors: allProcessors });
4285
- process(input, ctx);
4286
- extractDefs(ctx, input);
4287
- return finalize(ctx, input);
3775
+ throw new Error(`Unknown schema type: ${def.type}`);
4288
3776
  }
4289
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js
3777
+ // node_modules/zod/v4/classic/iso.js
4290
3778
  var exports_iso = {};
4291
3779
  __export(exports_iso, {
4292
3780
  time: () => time2,
@@ -4327,7 +3815,7 @@ function duration2(params) {
4327
3815
  return _isoDuration(ZodISODuration, params);
4328
3816
  }
4329
3817
 
4330
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js
3818
+ // node_modules/zod/v4/classic/errors.js
4331
3819
  var initializer2 = (inst, issues) => {
4332
3820
  $ZodError.init(inst, issues);
4333
3821
  inst.name = "ZodError";
@@ -4339,16 +3827,10 @@ var initializer2 = (inst, issues) => {
4339
3827
  value: (mapper) => flattenError(inst, mapper)
4340
3828
  },
4341
3829
  addIssue: {
4342
- value: (issue2) => {
4343
- inst.issues.push(issue2);
4344
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
4345
- }
3830
+ value: (issue2) => inst.issues.push(issue2)
4346
3831
  },
4347
3832
  addIssues: {
4348
- value: (issues2) => {
4349
- inst.issues.push(...issues2);
4350
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
4351
- }
3833
+ value: (issues2) => inst.issues.push(...issues2)
4352
3834
  },
4353
3835
  isEmpty: {
4354
3836
  get() {
@@ -4362,48 +3844,30 @@ var ZodRealError = $constructor("ZodError", initializer2, {
4362
3844
  Parent: Error
4363
3845
  });
4364
3846
 
4365
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js
3847
+ // node_modules/zod/v4/classic/parse.js
4366
3848
  var parse3 = /* @__PURE__ */ _parse(ZodRealError);
4367
3849
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
4368
3850
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
4369
3851
  var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
4370
- var encode = /* @__PURE__ */ _encode(ZodRealError);
4371
- var decode = /* @__PURE__ */ _decode(ZodRealError);
4372
- var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
4373
- var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
4374
- var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
4375
- var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
4376
- var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
4377
- var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
4378
3852
 
4379
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js
3853
+ // node_modules/zod/v4/classic/schemas.js
4380
3854
  var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
4381
3855
  $ZodType.init(inst, def);
4382
- Object.assign(inst["~standard"], {
4383
- jsonSchema: {
4384
- input: createStandardJSONSchemaMethod(inst, "input"),
4385
- output: createStandardJSONSchemaMethod(inst, "output")
4386
- }
4387
- });
4388
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
4389
3856
  inst.def = def;
4390
- inst.type = def.type;
4391
3857
  Object.defineProperty(inst, "_def", { value: def });
4392
3858
  inst.check = (...checks2) => {
4393
- return inst.clone(exports_util.mergeDefs(def, {
3859
+ return inst.clone({
3860
+ ...def,
4394
3861
  checks: [
4395
3862
  ...def.checks ?? [],
4396
3863
  ...checks2.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
4397
3864
  ]
4398
- }), {
4399
- parent: true
4400
3865
  });
4401
3866
  };
4402
- inst.with = inst.check;
4403
3867
  inst.clone = (def2, params) => clone(inst, def2, params);
4404
3868
  inst.brand = () => inst;
4405
- inst.register = (reg, meta2) => {
4406
- reg.add(inst, meta2);
3869
+ inst.register = (reg, meta) => {
3870
+ reg.add(inst, meta);
4407
3871
  return inst;
4408
3872
  };
4409
3873
  inst.parse = (data, params) => parse3(inst, data, params, { callee: inst.parse });
@@ -4411,19 +3875,10 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
4411
3875
  inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
4412
3876
  inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
4413
3877
  inst.spa = inst.safeParseAsync;
4414
- inst.encode = (data, params) => encode(inst, data, params);
4415
- inst.decode = (data, params) => decode(inst, data, params);
4416
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
4417
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
4418
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
4419
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
4420
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
4421
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
4422
3878
  inst.refine = (check, params) => inst.check(refine(check, params));
4423
3879
  inst.superRefine = (refinement) => inst.check(superRefine(refinement));
4424
3880
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
4425
3881
  inst.optional = () => optional(inst);
4426
- inst.exactOptional = () => exactOptional(inst);
4427
3882
  inst.nullable = () => nullable(inst);
4428
3883
  inst.nullish = () => optional(nullable(inst));
4429
3884
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -4457,13 +3912,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
4457
3912
  };
4458
3913
  inst.isOptional = () => inst.safeParse(undefined).success;
4459
3914
  inst.isNullable = () => inst.safeParse(null).success;
4460
- inst.apply = (fn) => fn(inst);
4461
3915
  return inst;
4462
3916
  });
4463
3917
  var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
4464
3918
  $ZodString.init(inst, def);
4465
3919
  ZodType.init(inst, def);
4466
- inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
4467
3920
  const bag = inst._zod.bag;
4468
3921
  inst.format = bag.format ?? null;
4469
3922
  inst.minLength = bag.minimum ?? null;
@@ -4482,7 +3935,6 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
4482
3935
  inst.normalize = (...args) => inst.check(_normalize(...args));
4483
3936
  inst.toLowerCase = () => inst.check(_toLowerCase());
4484
3937
  inst.toUpperCase = () => inst.check(_toUpperCase());
4485
- inst.slugify = () => inst.check(_slugify());
4486
3938
  });
4487
3939
  var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
4488
3940
  $ZodString.init(inst, def);
@@ -4601,7 +4053,6 @@ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
4601
4053
  var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
4602
4054
  $ZodNumber.init(inst, def);
4603
4055
  ZodType.init(inst, def);
4604
- inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
4605
4056
  inst.gt = (value, params) => inst.check(_gt(value, params));
4606
4057
  inst.gte = (value, params) => inst.check(_gte(value, params));
4607
4058
  inst.min = (value, params) => inst.check(_gte(value, params));
@@ -4637,7 +4088,6 @@ function int(params) {
4637
4088
  var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
4638
4089
  $ZodBoolean.init(inst, def);
4639
4090
  ZodType.init(inst, def);
4640
- inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
4641
4091
  });
4642
4092
  function boolean2(params) {
4643
4093
  return _boolean(ZodBoolean, params);
@@ -4645,7 +4095,6 @@ function boolean2(params) {
4645
4095
  var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
4646
4096
  $ZodNull.init(inst, def);
4647
4097
  ZodType.init(inst, def);
4648
- inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
4649
4098
  });
4650
4099
  function _null3(params) {
4651
4100
  return _null2(ZodNull, params);
@@ -4653,7 +4102,6 @@ function _null3(params) {
4653
4102
  var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
4654
4103
  $ZodUnknown.init(inst, def);
4655
4104
  ZodType.init(inst, def);
4656
- inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
4657
4105
  });
4658
4106
  function unknown() {
4659
4107
  return _unknown(ZodUnknown);
@@ -4661,7 +4109,6 @@ function unknown() {
4661
4109
  var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
4662
4110
  $ZodNever.init(inst, def);
4663
4111
  ZodType.init(inst, def);
4664
- inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
4665
4112
  });
4666
4113
  function never(params) {
4667
4114
  return _never(ZodNever, params);
@@ -4669,7 +4116,6 @@ function never(params) {
4669
4116
  var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
4670
4117
  $ZodArray.init(inst, def);
4671
4118
  ZodType.init(inst, def);
4672
- inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4673
4119
  inst.element = def.element;
4674
4120
  inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
4675
4121
  inst.nonempty = (params) => inst.check(_minLength(1, params));
@@ -4681,12 +4127,9 @@ function array(element, params) {
4681
4127
  return _array(ZodArray, element, params);
4682
4128
  }
4683
4129
  var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
4684
- $ZodObjectJIT.init(inst, def);
4130
+ $ZodObject.init(inst, def);
4685
4131
  ZodType.init(inst, def);
4686
- inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4687
- exports_util.defineLazy(inst, "shape", () => {
4688
- return def.shape;
4689
- });
4132
+ exports_util.defineLazy(inst, "shape", () => def.shape);
4690
4133
  inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
4691
4134
  inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
4692
4135
  inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
@@ -4696,9 +4139,6 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
4696
4139
  inst.extend = (incoming) => {
4697
4140
  return exports_util.extend(inst, incoming);
4698
4141
  };
4699
- inst.safeExtend = (incoming) => {
4700
- return exports_util.safeExtend(inst, incoming);
4701
- };
4702
4142
  inst.merge = (other) => exports_util.merge(inst, other);
4703
4143
  inst.pick = (mask) => exports_util.pick(inst, mask);
4704
4144
  inst.omit = (mask) => exports_util.omit(inst, mask);
@@ -4708,7 +4148,10 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
4708
4148
  function object(shape, params) {
4709
4149
  const def = {
4710
4150
  type: "object",
4711
- shape: shape ?? {},
4151
+ get shape() {
4152
+ exports_util.assignProp(this, "shape", { ...shape });
4153
+ return this.shape;
4154
+ },
4712
4155
  ...exports_util.normalizeParams(params)
4713
4156
  };
4714
4157
  return new ZodObject(def);
@@ -4716,7 +4159,10 @@ function object(shape, params) {
4716
4159
  function looseObject(shape, params) {
4717
4160
  return new ZodObject({
4718
4161
  type: "object",
4719
- shape,
4162
+ get shape() {
4163
+ exports_util.assignProp(this, "shape", { ...shape });
4164
+ return this.shape;
4165
+ },
4720
4166
  catchall: unknown(),
4721
4167
  ...exports_util.normalizeParams(params)
4722
4168
  });
@@ -4724,7 +4170,6 @@ function looseObject(shape, params) {
4724
4170
  var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
4725
4171
  $ZodUnion.init(inst, def);
4726
4172
  ZodType.init(inst, def);
4727
- inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
4728
4173
  inst.options = def.options;
4729
4174
  });
4730
4175
  function union(options, params) {
@@ -4749,7 +4194,6 @@ function discriminatedUnion(discriminator, options, params) {
4749
4194
  var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
4750
4195
  $ZodIntersection.init(inst, def);
4751
4196
  ZodType.init(inst, def);
4752
- inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
4753
4197
  });
4754
4198
  function intersection(left, right) {
4755
4199
  return new ZodIntersection({
@@ -4761,7 +4205,6 @@ function intersection(left, right) {
4761
4205
  var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
4762
4206
  $ZodRecord.init(inst, def);
4763
4207
  ZodType.init(inst, def);
4764
- inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
4765
4208
  inst.keyType = def.keyType;
4766
4209
  inst.valueType = def.valueType;
4767
4210
  });
@@ -4776,7 +4219,6 @@ function record(keyType, valueType, params) {
4776
4219
  var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
4777
4220
  $ZodEnum.init(inst, def);
4778
4221
  ZodType.init(inst, def);
4779
- inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
4780
4222
  inst.enum = def.entries;
4781
4223
  inst.options = Object.values(def.entries);
4782
4224
  const keys = new Set(Object.keys(def.entries));
@@ -4822,7 +4264,6 @@ function _enum(values, params) {
4822
4264
  var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
4823
4265
  $ZodLiteral.init(inst, def);
4824
4266
  ZodType.init(inst, def);
4825
- inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
4826
4267
  inst.values = new Set(def.values);
4827
4268
  Object.defineProperty(inst, "value", {
4828
4269
  get() {
@@ -4843,11 +4284,7 @@ function literal(value, params) {
4843
4284
  var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
4844
4285
  $ZodTransform.init(inst, def);
4845
4286
  ZodType.init(inst, def);
4846
- inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
4847
4287
  inst._zod.parse = (payload, _ctx) => {
4848
- if (_ctx.direction === "backward") {
4849
- throw new $ZodEncodeError(inst.constructor.name);
4850
- }
4851
4288
  payload.addIssue = (issue2) => {
4852
4289
  if (typeof issue2 === "string") {
4853
4290
  payload.issues.push(exports_util.issue(issue2, payload.value, def));
@@ -4858,6 +4295,7 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
4858
4295
  _issue.code ?? (_issue.code = "custom");
4859
4296
  _issue.input ?? (_issue.input = payload.value);
4860
4297
  _issue.inst ?? (_issue.inst = inst);
4298
+ _issue.continue ?? (_issue.continue = true);
4861
4299
  payload.issues.push(exports_util.issue(_issue));
4862
4300
  }
4863
4301
  };
@@ -4881,7 +4319,6 @@ function transform(fn) {
4881
4319
  var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
4882
4320
  $ZodOptional.init(inst, def);
4883
4321
  ZodType.init(inst, def);
4884
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4885
4322
  inst.unwrap = () => inst._zod.def.innerType;
4886
4323
  });
4887
4324
  function optional(innerType) {
@@ -4890,22 +4327,9 @@ function optional(innerType) {
4890
4327
  innerType
4891
4328
  });
4892
4329
  }
4893
- var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
4894
- $ZodExactOptional.init(inst, def);
4895
- ZodType.init(inst, def);
4896
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4897
- inst.unwrap = () => inst._zod.def.innerType;
4898
- });
4899
- function exactOptional(innerType) {
4900
- return new ZodExactOptional({
4901
- type: "optional",
4902
- innerType
4903
- });
4904
- }
4905
4330
  var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
4906
4331
  $ZodNullable.init(inst, def);
4907
4332
  ZodType.init(inst, def);
4908
- inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4909
4333
  inst.unwrap = () => inst._zod.def.innerType;
4910
4334
  });
4911
4335
  function nullable(innerType) {
@@ -4917,7 +4341,6 @@ function nullable(innerType) {
4917
4341
  var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
4918
4342
  $ZodDefault.init(inst, def);
4919
4343
  ZodType.init(inst, def);
4920
- inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4921
4344
  inst.unwrap = () => inst._zod.def.innerType;
4922
4345
  inst.removeDefault = inst.unwrap;
4923
4346
  });
@@ -4926,14 +4349,13 @@ function _default(innerType, defaultValue) {
4926
4349
  type: "default",
4927
4350
  innerType,
4928
4351
  get defaultValue() {
4929
- return typeof defaultValue === "function" ? defaultValue() : exports_util.shallowClone(defaultValue);
4352
+ return typeof defaultValue === "function" ? defaultValue() : defaultValue;
4930
4353
  }
4931
4354
  });
4932
4355
  }
4933
4356
  var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
4934
4357
  $ZodPrefault.init(inst, def);
4935
4358
  ZodType.init(inst, def);
4936
- inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4937
4359
  inst.unwrap = () => inst._zod.def.innerType;
4938
4360
  });
4939
4361
  function prefault(innerType, defaultValue) {
@@ -4941,14 +4363,13 @@ function prefault(innerType, defaultValue) {
4941
4363
  type: "prefault",
4942
4364
  innerType,
4943
4365
  get defaultValue() {
4944
- return typeof defaultValue === "function" ? defaultValue() : exports_util.shallowClone(defaultValue);
4366
+ return typeof defaultValue === "function" ? defaultValue() : defaultValue;
4945
4367
  }
4946
4368
  });
4947
4369
  }
4948
4370
  var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
4949
4371
  $ZodNonOptional.init(inst, def);
4950
4372
  ZodType.init(inst, def);
4951
- inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4952
4373
  inst.unwrap = () => inst._zod.def.innerType;
4953
4374
  });
4954
4375
  function nonoptional(innerType, params) {
@@ -4961,7 +4382,6 @@ function nonoptional(innerType, params) {
4961
4382
  var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
4962
4383
  $ZodCatch.init(inst, def);
4963
4384
  ZodType.init(inst, def);
4964
- inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4965
4385
  inst.unwrap = () => inst._zod.def.innerType;
4966
4386
  inst.removeCatch = inst.unwrap;
4967
4387
  });
@@ -4975,7 +4395,6 @@ function _catch(innerType, catchValue) {
4975
4395
  var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
4976
4396
  $ZodPipe.init(inst, def);
4977
4397
  ZodType.init(inst, def);
4978
- inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4979
4398
  inst.in = def.in;
4980
4399
  inst.out = def.out;
4981
4400
  });
@@ -4989,8 +4408,6 @@ function pipe(in_, out) {
4989
4408
  var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
4990
4409
  $ZodReadonly.init(inst, def);
4991
4410
  ZodType.init(inst, def);
4992
- inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4993
- inst.unwrap = () => inst._zod.def.innerType;
4994
4411
  });
4995
4412
  function readonly(innerType) {
4996
4413
  return new ZodReadonly({
@@ -5001,8 +4418,14 @@ function readonly(innerType) {
5001
4418
  var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
5002
4419
  $ZodCustom.init(inst, def);
5003
4420
  ZodType.init(inst, def);
5004
- inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
5005
4421
  });
4422
+ function check(fn) {
4423
+ const ch = new $ZodCheck({
4424
+ check: "custom"
4425
+ });
4426
+ ch._zod.check = fn;
4427
+ return ch;
4428
+ }
5006
4429
  function custom(fn, _params) {
5007
4430
  return _custom(ZodCustom, fn ?? (() => true), _params);
5008
4431
  }
@@ -5010,12 +4433,29 @@ function refine(fn, _params = {}) {
5010
4433
  return _refine(ZodCustom, fn, _params);
5011
4434
  }
5012
4435
  function superRefine(fn) {
5013
- return _superRefine(fn);
4436
+ const ch = check((payload) => {
4437
+ payload.addIssue = (issue2) => {
4438
+ if (typeof issue2 === "string") {
4439
+ payload.issues.push(exports_util.issue(issue2, payload.value, ch._zod.def));
4440
+ } else {
4441
+ const _issue = issue2;
4442
+ if (_issue.fatal)
4443
+ _issue.continue = false;
4444
+ _issue.code ?? (_issue.code = "custom");
4445
+ _issue.input ?? (_issue.input = payload.value);
4446
+ _issue.inst ?? (_issue.inst = ch);
4447
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
4448
+ payload.issues.push(exports_util.issue(_issue));
4449
+ }
4450
+ };
4451
+ return fn(payload.value, payload);
4452
+ });
4453
+ return ch;
5014
4454
  }
5015
4455
  function preprocess(fn, schema) {
5016
4456
  return pipe(transform(fn), schema);
5017
4457
  }
5018
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/external.js
4458
+ // node_modules/zod/v4/classic/external.js
5019
4459
  config(en_default());
5020
4460
 
5021
4461
  // node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
@@ -5865,4 +5305,4 @@ class UrlElicitationRequiredError extends McpError {
5865
5305
  }
5866
5306
  }
5867
5307
 
5868
- export { $constructor, defineLazy, clone, normalizeParams, parse, parseAsync, safeParse, safeParseAsync, $ZodType, $ZodObject, toJSONSchema, ZodOptional, LATEST_PROTOCOL_VERSION, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, RELATED_TASK_META_KEY, isTaskAugmentedRequestParams, isJSONRPCRequest, isJSONRPCNotification, isJSONRPCResultResponse, ErrorCode, isJSONRPCErrorResponse, JSONRPCMessageSchema, EmptyResultSchema, CancelledNotificationSchema, InitializeRequestSchema, isInitializeRequest, InitializedNotificationSchema, PingRequestSchema, ProgressNotificationSchema, CreateTaskResultSchema, TaskStatusNotificationSchema, GetTaskRequestSchema, GetTaskResultSchema, GetTaskPayloadRequestSchema, ListTasksRequestSchema, ListTasksResultSchema, CancelTaskRequestSchema, CancelTaskResultSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListToolsRequestSchema, CallToolResultSchema, CallToolRequestSchema, LoggingLevelSchema, SetLevelRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, ElicitResultSchema, CompleteRequestSchema, assertCompleteRequestPrompt, assertCompleteRequestResourceTemplate, ListRootsResultSchema, McpError };
5308
+ export { $constructor, clone, exports_util, parse, parseAsync, safeParse, safeParseAsync, $ZodType, $ZodObject, toJSONSchema, LATEST_PROTOCOL_VERSION, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, RELATED_TASK_META_KEY, isTaskAugmentedRequestParams, isJSONRPCRequest, isJSONRPCNotification, isJSONRPCResultResponse, ErrorCode, isJSONRPCErrorResponse, JSONRPCMessageSchema, EmptyResultSchema, CancelledNotificationSchema, InitializeRequestSchema, isInitializeRequest, InitializedNotificationSchema, PingRequestSchema, ProgressNotificationSchema, CreateTaskResultSchema, TaskStatusNotificationSchema, GetTaskRequestSchema, GetTaskResultSchema, GetTaskPayloadRequestSchema, ListTasksRequestSchema, ListTasksResultSchema, CancelTaskRequestSchema, CancelTaskResultSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListToolsRequestSchema, CallToolResultSchema, CallToolRequestSchema, LoggingLevelSchema, SetLevelRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, ElicitResultSchema, CompleteRequestSchema, assertCompleteRequestPrompt, assertCompleteRequestResourceTemplate, ListRootsResultSchema, McpError };