@tempad-dev/mcp 0.3.9 → 0.3.11

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.
package/dist/hub.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as SOCK_PATH, c as log, i as RUNTIME_DIR, o as ensureDir, r as PACKAGE_VERSION, s as ensureFile, t as ASSET_DIR } from "./shared-Dx5fhN-T.mjs";
1
+ import { a as SOCK_PATH, c as log, i as RUNTIME_DIR, o as ensureDir, r as PACKAGE_VERSION, s as ensureFile, t as ASSET_DIR } from "./shared-H4sL6Ltt.mjs";
2
2
  import { createServer } from "node:net";
3
3
  import { join } from "node:path";
4
4
  import { URL as URL$1 } from "node:url";
@@ -11,31 +11,37 @@ import { createHash } from "node:crypto";
11
11
  import { createServer as createServer$1 } from "node:http";
12
12
  import { Transform, pipeline } from "node:stream";
13
13
 
14
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js
14
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/core.js
15
15
  /** A special constant with type `never` */
16
16
  const NEVER = Object.freeze({ status: "aborted" });
17
17
  function $constructor(name, initializer$2, params) {
18
18
  function init(inst, def) {
19
- var _a;
20
- Object.defineProperty(inst, "_zod", {
21
- value: inst._zod ?? {},
19
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
20
+ value: {
21
+ def,
22
+ constr: _,
23
+ traits: /* @__PURE__ */ new Set()
24
+ },
22
25
  enumerable: false
23
26
  });
24
- (_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
27
+ if (inst._zod.traits.has(name)) return;
25
28
  inst._zod.traits.add(name);
26
29
  initializer$2(inst, def);
27
- for (const k in _.prototype) if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
28
- inst._zod.constr = _;
29
- inst._zod.def = def;
30
+ const proto = _.prototype;
31
+ const keys = Object.keys(proto);
32
+ for (let i = 0; i < keys.length; i++) {
33
+ const k = keys[i];
34
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
35
+ }
30
36
  }
31
37
  const Parent = params?.Parent ?? Object;
32
38
  class Definition extends Parent {}
33
39
  Object.defineProperty(Definition, "name", { value: name });
34
40
  function _(def) {
35
- var _a;
41
+ var _a$1;
36
42
  const inst = params?.Parent ? new Definition() : this;
37
43
  init(inst, def);
38
- (_a = inst._zod).deferred ?? (_a.deferred = []);
44
+ (_a$1 = inst._zod).deferred ?? (_a$1.deferred = []);
39
45
  for (const fn of inst._zod.deferred) fn();
40
46
  return inst;
41
47
  }
@@ -65,7 +71,7 @@ function config(newConfig) {
65
71
  }
66
72
 
67
73
  //#endregion
68
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js
74
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.js
69
75
  function getEnumValues(entries) {
70
76
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
71
77
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
@@ -140,6 +146,9 @@ function mergeDefs(...defs) {
140
146
  function esc(str) {
141
147
  return JSON.stringify(str);
142
148
  }
149
+ function slugify(input) {
150
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
151
+ }
143
152
  const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
144
153
  function isObject(data) {
145
154
  return typeof data === "object" && data !== null && !Array.isArray(data);
@@ -157,6 +166,7 @@ function isPlainObject(o) {
157
166
  if (isObject(o) === false) return false;
158
167
  const ctor = o.constructor;
159
168
  if (ctor === void 0) return true;
169
+ if (typeof ctor !== "function") return true;
160
170
  const prot = ctor.prototype;
161
171
  if (isObject(prot) === false) return false;
162
172
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
@@ -209,6 +219,8 @@ const NUMBER_FORMAT_RANGES = {
209
219
  };
210
220
  function pick(schema, mask) {
211
221
  const currDef = schema._zod.def;
222
+ const checks = currDef.checks;
223
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
212
224
  return clone(schema, mergeDefs(schema._zod.def, {
213
225
  get shape() {
214
226
  const newShape = {};
@@ -225,6 +237,8 @@ function pick(schema, mask) {
225
237
  }
226
238
  function omit(schema, mask) {
227
239
  const currDef = schema._zod.def;
240
+ const checks = currDef.checks;
241
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
228
242
  return clone(schema, mergeDefs(schema._zod.def, {
229
243
  get shape() {
230
244
  const newShape = { ...schema._zod.def.shape };
@@ -242,33 +256,29 @@ function omit(schema, mask) {
242
256
  function extend(schema, shape) {
243
257
  if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
244
258
  const checks = schema._zod.def.checks;
245
- if (checks && checks.length > 0) throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
246
- return clone(schema, mergeDefs(schema._zod.def, {
247
- get shape() {
248
- const _shape = {
249
- ...schema._zod.def.shape,
250
- ...shape
251
- };
252
- assignProp(this, "shape", _shape);
253
- return _shape;
254
- },
255
- checks: []
256
- }));
259
+ if (checks && checks.length > 0) {
260
+ const existingShape = schema._zod.def.shape;
261
+ for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
262
+ }
263
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
264
+ const _shape = {
265
+ ...schema._zod.def.shape,
266
+ ...shape
267
+ };
268
+ assignProp(this, "shape", _shape);
269
+ return _shape;
270
+ } }));
257
271
  }
258
272
  function safeExtend(schema, shape) {
259
273
  if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
260
- return clone(schema, {
261
- ...schema._zod.def,
262
- get shape() {
263
- const _shape = {
264
- ...schema._zod.def.shape,
265
- ...shape
266
- };
267
- assignProp(this, "shape", _shape);
268
- return _shape;
269
- },
270
- checks: schema._zod.def.checks
271
- });
274
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
275
+ const _shape = {
276
+ ...schema._zod.def.shape,
277
+ ...shape
278
+ };
279
+ assignProp(this, "shape", _shape);
280
+ return _shape;
281
+ } }));
272
282
  }
273
283
  function merge(a, b) {
274
284
  return clone(a, mergeDefs(a._zod.def, {
@@ -287,6 +297,8 @@ function merge(a, b) {
287
297
  }));
288
298
  }
289
299
  function partial(Class, schema, mask) {
300
+ const checks = schema._zod.def.checks;
301
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
290
302
  return clone(schema, mergeDefs(schema._zod.def, {
291
303
  get shape() {
292
304
  const oldShape = schema._zod.def.shape;
@@ -310,27 +322,24 @@ function partial(Class, schema, mask) {
310
322
  }));
311
323
  }
312
324
  function required(Class, schema, mask) {
313
- return clone(schema, mergeDefs(schema._zod.def, {
314
- get shape() {
315
- const oldShape = schema._zod.def.shape;
316
- const shape = { ...oldShape };
317
- if (mask) for (const key in mask) {
318
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
319
- if (!mask[key]) continue;
320
- shape[key] = new Class({
321
- type: "nonoptional",
322
- innerType: oldShape[key]
323
- });
324
- }
325
- else for (const key in oldShape) shape[key] = new Class({
325
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
326
+ const oldShape = schema._zod.def.shape;
327
+ const shape = { ...oldShape };
328
+ if (mask) for (const key in mask) {
329
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
330
+ if (!mask[key]) continue;
331
+ shape[key] = new Class({
326
332
  type: "nonoptional",
327
333
  innerType: oldShape[key]
328
334
  });
329
- assignProp(this, "shape", shape);
330
- return shape;
331
- },
332
- checks: []
333
- }));
335
+ }
336
+ else for (const key in oldShape) shape[key] = new Class({
337
+ type: "nonoptional",
338
+ innerType: oldShape[key]
339
+ });
340
+ assignProp(this, "shape", shape);
341
+ return shape;
342
+ } }));
334
343
  }
335
344
  function aborted(x, startIndex = 0) {
336
345
  if (x.aborted === true) return true;
@@ -339,8 +348,8 @@ function aborted(x, startIndex = 0) {
339
348
  }
340
349
  function prefixIssues(path, issues) {
341
350
  return issues.map((iss) => {
342
- var _a;
343
- (_a = iss).path ?? (_a.path = []);
351
+ var _a$1;
352
+ (_a$1 = iss).path ?? (_a$1.path = []);
344
353
  iss.path.unshift(path);
345
354
  return iss;
346
355
  });
@@ -376,7 +385,7 @@ function issue(...args) {
376
385
  }
377
386
 
378
387
  //#endregion
379
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js
388
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.js
380
389
  const initializer$1 = (inst, def) => {
381
390
  inst.name = "$ZodError";
382
391
  Object.defineProperty(inst, "_zod", {
@@ -434,7 +443,7 @@ function formatError(error, mapper = (issue$1) => issue$1.message) {
434
443
  }
435
444
 
436
445
  //#endregion
437
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js
446
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/parse.js
438
447
  const _parse = (_Err) => (schema, value, _ctx, _params) => {
439
448
  const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
440
449
  const result = schema._zod.run({
@@ -538,7 +547,7 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
538
547
  const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
539
548
 
540
549
  //#endregion
541
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js
550
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/regexes.js
542
551
  const cuid = /^[cC][^\s-]{8,}$/;
543
552
  const cuid2 = /^[0-9a-z]+$/;
544
553
  const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
@@ -568,8 +577,7 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
568
577
  const 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])$/;
569
578
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
570
579
  const base64url = /^[A-Za-z0-9_-]*$/;
571
- const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
572
- const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
580
+ const e164 = /^\+[1-9]\d{6,14}$/;
573
581
  const 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])))`;
574
582
  const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
575
583
  function timeSource(args) {
@@ -592,18 +600,18 @@ const string$1 = (params) => {
592
600
  return /* @__PURE__ */ new RegExp(`^${regex}$`);
593
601
  };
594
602
  const integer = /^-?\d+$/;
595
- const number$1 = /^-?\d+(?:\.\d+)?/;
603
+ const number$1 = /^-?\d+(?:\.\d+)?$/;
596
604
  const boolean$1 = /^(?:true|false)$/i;
597
605
  const lowercase = /^[^A-Z]*$/;
598
606
  const uppercase = /^[^a-z]*$/;
599
607
 
600
608
  //#endregion
601
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js
609
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.js
602
610
  const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
603
- var _a;
611
+ var _a$1;
604
612
  inst._zod ?? (inst._zod = {});
605
613
  inst._zod.def = def;
606
- (_a = inst._zod).onattach ?? (_a.onattach = []);
614
+ (_a$1 = inst._zod).onattach ?? (_a$1.onattach = []);
607
615
  });
608
616
  const numericOriginMap = {
609
617
  number: "number",
@@ -624,7 +632,7 @@ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (ins
624
632
  payload.issues.push({
625
633
  origin,
626
634
  code: "too_big",
627
- maximum: def.value,
635
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
628
636
  input: payload.value,
629
637
  inclusive: def.inclusive,
630
638
  inst,
@@ -646,7 +654,7 @@ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan"
646
654
  payload.issues.push({
647
655
  origin,
648
656
  code: "too_small",
649
- minimum: def.value,
657
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
650
658
  input: payload.value,
651
659
  inclusive: def.inclusive,
652
660
  inst,
@@ -657,8 +665,8 @@ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan"
657
665
  const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
658
666
  $ZodCheck.init(inst, def);
659
667
  inst._zod.onattach.push((inst$1) => {
660
- var _a;
661
- (_a = inst$1._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
668
+ var _a$1;
669
+ (_a$1 = inst$1._zod.bag).multipleOf ?? (_a$1.multipleOf = def.value);
662
670
  });
663
671
  inst._zod.check = (payload) => {
664
672
  if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
@@ -708,6 +716,7 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
708
716
  note: "Integers must be within the safe integer range.",
709
717
  inst,
710
718
  origin,
719
+ inclusive: true,
711
720
  continue: !def.abort
712
721
  });
713
722
  else payload.issues.push({
@@ -717,6 +726,7 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
717
726
  note: "Integers must be within the safe integer range.",
718
727
  inst,
719
728
  origin,
729
+ inclusive: true,
720
730
  continue: !def.abort
721
731
  });
722
732
  return;
@@ -736,14 +746,16 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
736
746
  input,
737
747
  code: "too_big",
738
748
  maximum,
739
- inst
749
+ inclusive: true,
750
+ inst,
751
+ continue: !def.abort
740
752
  });
741
753
  };
742
754
  });
743
755
  const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
744
- var _a;
756
+ var _a$1;
745
757
  $ZodCheck.init(inst, def);
746
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
758
+ (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
747
759
  const val = payload.value;
748
760
  return !nullish(val) && val.length !== void 0;
749
761
  });
@@ -767,9 +779,9 @@ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (i
767
779
  };
768
780
  });
769
781
  const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
770
- var _a;
782
+ var _a$1;
771
783
  $ZodCheck.init(inst, def);
772
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
784
+ (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
773
785
  const val = payload.value;
774
786
  return !nullish(val) && val.length !== void 0;
775
787
  });
@@ -793,9 +805,9 @@ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (i
793
805
  };
794
806
  });
795
807
  const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
796
- var _a;
808
+ var _a$1;
797
809
  $ZodCheck.init(inst, def);
798
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
810
+ (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
799
811
  const val = payload.value;
800
812
  return !nullish(val) && val.length !== void 0;
801
813
  });
@@ -829,7 +841,7 @@ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEqual
829
841
  };
830
842
  });
831
843
  const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
832
- var _a, _b;
844
+ var _a$1, _b;
833
845
  $ZodCheck.init(inst, def);
834
846
  inst._zod.onattach.push((inst$1) => {
835
847
  const bag = inst$1._zod.bag;
@@ -839,7 +851,7 @@ const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringForma
839
851
  bag.patterns.add(def.pattern);
840
852
  }
841
853
  });
842
- if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
854
+ if (def.pattern) (_a$1 = inst._zod).check ?? (_a$1.check = (payload) => {
843
855
  def.pattern.lastIndex = 0;
844
856
  if (def.pattern.test(payload.value)) return;
845
857
  payload.issues.push({
@@ -953,7 +965,7 @@ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (i
953
965
  });
954
966
 
955
967
  //#endregion
956
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js
968
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/doc.js
957
969
  var Doc = class {
958
970
  constructor(args = []) {
959
971
  this.content = [];
@@ -985,17 +997,17 @@ var Doc = class {
985
997
  };
986
998
 
987
999
  //#endregion
988
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js
1000
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/versions.js
989
1001
  const version = {
990
1002
  major: 4,
991
- minor: 1,
992
- patch: 12
1003
+ minor: 3,
1004
+ patch: 5
993
1005
  };
994
1006
 
995
1007
  //#endregion
996
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js
1008
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.js
997
1009
  const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
998
- var _a;
1010
+ var _a$1;
999
1011
  inst ?? (inst = {});
1000
1012
  inst._zod.def = def;
1001
1013
  inst._zod.bag = inst._zod.bag || {};
@@ -1004,7 +1016,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1004
1016
  if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1005
1017
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1006
1018
  if (checks.length === 0) {
1007
- (_a = inst._zod).deferred ?? (_a.deferred = []);
1019
+ (_a$1 = inst._zod).deferred ?? (_a$1.deferred = []);
1008
1020
  inst._zod.deferred?.push(() => {
1009
1021
  inst._zod.run = inst._zod.parse;
1010
1022
  });
@@ -1069,7 +1081,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1069
1081
  return runChecks(result, checks, ctx);
1070
1082
  };
1071
1083
  }
1072
- inst["~standard"] = {
1084
+ defineLazy(inst, "~standard", () => ({
1073
1085
  validate: (value) => {
1074
1086
  try {
1075
1087
  const r = safeParse$1(inst, value);
@@ -1080,7 +1092,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1080
1092
  },
1081
1093
  vendor: "zod",
1082
1094
  version: 1
1083
- };
1095
+ }));
1084
1096
  });
1085
1097
  const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1086
1098
  $ZodType.init(inst, def);
@@ -1140,7 +1152,7 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1140
1152
  code: "invalid_format",
1141
1153
  format: "url",
1142
1154
  note: "Invalid hostname",
1143
- pattern: hostname.source,
1155
+ pattern: def.hostname.source,
1144
1156
  input: payload.value,
1145
1157
  inst,
1146
1158
  continue: !def.abort
@@ -1219,18 +1231,12 @@ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, d
1219
1231
  const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1220
1232
  def.pattern ?? (def.pattern = ipv4);
1221
1233
  $ZodStringFormat.init(inst, def);
1222
- inst._zod.onattach.push((inst$1) => {
1223
- const bag = inst$1._zod.bag;
1224
- bag.format = `ipv4`;
1225
- });
1234
+ inst._zod.bag.format = `ipv4`;
1226
1235
  });
1227
1236
  const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1228
1237
  def.pattern ?? (def.pattern = ipv6);
1229
1238
  $ZodStringFormat.init(inst, def);
1230
- inst._zod.onattach.push((inst$1) => {
1231
- const bag = inst$1._zod.bag;
1232
- bag.format = `ipv6`;
1233
- });
1239
+ inst._zod.bag.format = `ipv6`;
1234
1240
  inst._zod.check = (payload) => {
1235
1241
  try {
1236
1242
  new URL(`http://[${payload.value}]`);
@@ -1286,9 +1292,7 @@ function isValidBase64(data) {
1286
1292
  const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1287
1293
  def.pattern ?? (def.pattern = base64);
1288
1294
  $ZodStringFormat.init(inst, def);
1289
- inst._zod.onattach.push((inst$1) => {
1290
- inst$1._zod.bag.contentEncoding = "base64";
1291
- });
1295
+ inst._zod.bag.contentEncoding = "base64";
1292
1296
  inst._zod.check = (payload) => {
1293
1297
  if (isValidBase64(payload.value)) return;
1294
1298
  payload.issues.push({
@@ -1308,9 +1312,7 @@ function isValidBase64URL(data) {
1308
1312
  const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1309
1313
  def.pattern ?? (def.pattern = base64url);
1310
1314
  $ZodStringFormat.init(inst, def);
1311
- inst._zod.onattach.push((inst$1) => {
1312
- inst$1._zod.bag.contentEncoding = "base64url";
1313
- });
1315
+ inst._zod.bag.contentEncoding = "base64url";
1314
1316
  inst._zod.check = (payload) => {
1315
1317
  if (isValidBase64URL(payload.value)) return;
1316
1318
  payload.issues.push({
@@ -1374,7 +1376,7 @@ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1374
1376
  return payload;
1375
1377
  };
1376
1378
  });
1377
- const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1379
+ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1378
1380
  $ZodCheckNumberFormat.init(inst, def);
1379
1381
  $ZodNumber.init(inst, def);
1380
1382
  });
@@ -1444,8 +1446,11 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1444
1446
  return payload;
1445
1447
  };
1446
1448
  });
1447
- function handlePropertyResult(result, final, key, input) {
1448
- if (result.issues.length) final.issues.push(...prefixIssues(key, result.issues));
1449
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1450
+ if (result.issues.length) {
1451
+ if (isOptionalOut && !(key in input)) return;
1452
+ final.issues.push(...prefixIssues(key, result.issues));
1453
+ }
1449
1454
  if (result.value === void 0) {
1450
1455
  if (key in input) final.value[key] = void 0;
1451
1456
  } else final.value[key] = result.value;
@@ -1467,7 +1472,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1467
1472
  const keySet = def.keySet;
1468
1473
  const _catchall = def.catchall._zod;
1469
1474
  const t = _catchall.def.type;
1470
- for (const key of Object.keys(input)) {
1475
+ const isOptionalOut = _catchall.optout === "optional";
1476
+ for (const key in input) {
1471
1477
  if (keySet.has(key)) continue;
1472
1478
  if (t === "never") {
1473
1479
  unrecognized.push(key);
@@ -1477,8 +1483,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1477
1483
  value: input[key],
1478
1484
  issues: []
1479
1485
  }, ctx);
1480
- if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input)));
1481
- else handlePropertyResult(r, payload, key, input);
1486
+ if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input, isOptionalOut)));
1487
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
1482
1488
  }
1483
1489
  if (unrecognized.length) payload.issues.push({
1484
1490
  code: "unrecognized_keys",
@@ -1533,12 +1539,14 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1533
1539
  const proms = [];
1534
1540
  const shape = value.shape;
1535
1541
  for (const key of value.keys) {
1536
- const r = shape[key]._zod.run({
1542
+ const el = shape[key];
1543
+ const isOptionalOut = el._zod.optout === "optional";
1544
+ const r = el._zod.run({
1537
1545
  value: input[key],
1538
1546
  issues: []
1539
1547
  }, ctx);
1540
- if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input)));
1541
- else handlePropertyResult(r, payload, key, input);
1548
+ if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input, isOptionalOut)));
1549
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
1542
1550
  }
1543
1551
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1544
1552
  return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
@@ -1567,8 +1575,28 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
1567
1575
  for (const key of normalized.keys) {
1568
1576
  const id = ids[key];
1569
1577
  const k = esc(key);
1578
+ const isOptionalOut = shape[key]?._zod?.optout === "optional";
1570
1579
  doc.write(`const ${id} = ${parseStr(key)};`);
1571
- doc.write(`
1580
+ if (isOptionalOut) doc.write(`
1581
+ if (${id}.issues.length) {
1582
+ if (${k} in input) {
1583
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1584
+ ...iss,
1585
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1586
+ })));
1587
+ }
1588
+ }
1589
+
1590
+ if (${id}.value === undefined) {
1591
+ if (${k} in input) {
1592
+ newResult[${k}] = undefined;
1593
+ }
1594
+ } else {
1595
+ newResult[${k}] = ${id}.value;
1596
+ }
1597
+
1598
+ `);
1599
+ else doc.write(`
1572
1600
  if (${id}.issues.length) {
1573
1601
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1574
1602
  ...iss,
@@ -1576,7 +1604,6 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
1576
1604
  })));
1577
1605
  }
1578
1606
 
1579
-
1580
1607
  if (${id}.value === undefined) {
1581
1608
  if (${k} in input) {
1582
1609
  newResult[${k}] = undefined;
@@ -1677,6 +1704,7 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1677
1704
  };
1678
1705
  });
1679
1706
  const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1707
+ def.inclusive = false;
1680
1708
  $ZodUnion.init(inst, def);
1681
1709
  const _super = inst._zod.parse;
1682
1710
  defineLazy(inst._zod, "propValues", () => {
@@ -1804,8 +1832,25 @@ function mergeValues(a, b) {
1804
1832
  };
1805
1833
  }
1806
1834
  function handleIntersectionResults(result, left, right) {
1807
- if (left.issues.length) result.issues.push(...left.issues);
1808
- if (right.issues.length) result.issues.push(...right.issues);
1835
+ const unrecKeys = /* @__PURE__ */ new Map();
1836
+ let unrecIssue;
1837
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1838
+ unrecIssue ?? (unrecIssue = iss);
1839
+ for (const k of iss.keys) {
1840
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1841
+ unrecKeys.get(k).l = true;
1842
+ }
1843
+ } else result.issues.push(iss);
1844
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1845
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1846
+ unrecKeys.get(k).r = true;
1847
+ }
1848
+ else result.issues.push(iss);
1849
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1850
+ if (bothKeys.length && unrecIssue) result.issues.push({
1851
+ ...unrecIssue,
1852
+ keys: bothKeys
1853
+ });
1809
1854
  if (aborted(result)) return result;
1810
1855
  const merged = mergeValues(left.value, right.value);
1811
1856
  if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
@@ -1833,11 +1878,12 @@ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
1833
1878
  const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
1834
1879
  $ZodType.init(inst, def);
1835
1880
  if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
1836
- inst._zod.values = new Set(def.values);
1881
+ const values = new Set(def.values);
1882
+ inst._zod.values = values;
1837
1883
  inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
1838
1884
  inst._zod.parse = (payload, _ctx) => {
1839
1885
  const input = payload.value;
1840
- if (inst._zod.values.has(input)) return payload;
1886
+ if (values.has(input)) return payload;
1841
1887
  payload.issues.push({
1842
1888
  code: "invalid_value",
1843
1889
  values: def.values,
@@ -1889,6 +1935,14 @@ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) =>
1889
1935
  return def.innerType._zod.run(payload, ctx);
1890
1936
  };
1891
1937
  });
1938
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
1939
+ $ZodOptional.init(inst, def);
1940
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1941
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
1942
+ inst._zod.parse = (payload, ctx) => {
1943
+ return def.innerType._zod.run(payload, ctx);
1944
+ };
1945
+ });
1892
1946
  const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
1893
1947
  $ZodType.init(inst, def);
1894
1948
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -2021,8 +2075,8 @@ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) =>
2021
2075
  $ZodType.init(inst, def);
2022
2076
  defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2023
2077
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2024
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2025
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2078
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2079
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2026
2080
  inst._zod.parse = (payload, ctx) => {
2027
2081
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2028
2082
  const result = def.innerType._zod.run(payload, ctx);
@@ -2062,19 +2116,17 @@ function handleRefineResult(result, payload, input, inst) {
2062
2116
  }
2063
2117
 
2064
2118
  //#endregion
2065
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js
2119
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/registries.js
2120
+ var _a;
2066
2121
  var $ZodRegistry = class {
2067
2122
  constructor() {
2068
2123
  this._map = /* @__PURE__ */ new WeakMap();
2069
2124
  this._idmap = /* @__PURE__ */ new Map();
2070
2125
  }
2071
2126
  add(schema, ..._meta) {
2072
- const meta = _meta[0];
2073
- this._map.set(schema, meta);
2074
- if (meta && typeof meta === "object" && "id" in meta) {
2075
- if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
2076
- this._idmap.set(meta.id, schema);
2077
- }
2127
+ const meta$2 = _meta[0];
2128
+ this._map.set(schema, meta$2);
2129
+ if (meta$2 && typeof meta$2 === "object" && "id" in meta$2) this._idmap.set(meta$2.id, schema);
2078
2130
  return this;
2079
2131
  }
2080
2132
  clear() {
@@ -2083,8 +2135,8 @@ var $ZodRegistry = class {
2083
2135
  return this;
2084
2136
  }
2085
2137
  remove(schema) {
2086
- const meta = this._map.get(schema);
2087
- if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
2138
+ const meta$2 = this._map.get(schema);
2139
+ if (meta$2 && typeof meta$2 === "object" && "id" in meta$2) this._idmap.delete(meta$2.id);
2088
2140
  this._map.delete(schema);
2089
2141
  return this;
2090
2142
  }
@@ -2108,16 +2160,19 @@ var $ZodRegistry = class {
2108
2160
  function registry() {
2109
2161
  return new $ZodRegistry();
2110
2162
  }
2111
- const globalRegistry = /* @__PURE__ */ registry();
2163
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2164
+ const globalRegistry = globalThis.__zod_globalRegistry;
2112
2165
 
2113
2166
  //#endregion
2114
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js
2167
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/api.js
2168
+ /* @__NO_SIDE_EFFECTS__ */
2115
2169
  function _string(Class, params) {
2116
2170
  return new Class({
2117
2171
  type: "string",
2118
2172
  ...normalizeParams(params)
2119
2173
  });
2120
2174
  }
2175
+ /* @__NO_SIDE_EFFECTS__ */
2121
2176
  function _email(Class, params) {
2122
2177
  return new Class({
2123
2178
  type: "string",
@@ -2127,6 +2182,7 @@ function _email(Class, params) {
2127
2182
  ...normalizeParams(params)
2128
2183
  });
2129
2184
  }
2185
+ /* @__NO_SIDE_EFFECTS__ */
2130
2186
  function _guid(Class, params) {
2131
2187
  return new Class({
2132
2188
  type: "string",
@@ -2136,6 +2192,7 @@ function _guid(Class, params) {
2136
2192
  ...normalizeParams(params)
2137
2193
  });
2138
2194
  }
2195
+ /* @__NO_SIDE_EFFECTS__ */
2139
2196
  function _uuid(Class, params) {
2140
2197
  return new Class({
2141
2198
  type: "string",
@@ -2145,6 +2202,7 @@ function _uuid(Class, params) {
2145
2202
  ...normalizeParams(params)
2146
2203
  });
2147
2204
  }
2205
+ /* @__NO_SIDE_EFFECTS__ */
2148
2206
  function _uuidv4(Class, params) {
2149
2207
  return new Class({
2150
2208
  type: "string",
@@ -2155,6 +2213,7 @@ function _uuidv4(Class, params) {
2155
2213
  ...normalizeParams(params)
2156
2214
  });
2157
2215
  }
2216
+ /* @__NO_SIDE_EFFECTS__ */
2158
2217
  function _uuidv6(Class, params) {
2159
2218
  return new Class({
2160
2219
  type: "string",
@@ -2165,6 +2224,7 @@ function _uuidv6(Class, params) {
2165
2224
  ...normalizeParams(params)
2166
2225
  });
2167
2226
  }
2227
+ /* @__NO_SIDE_EFFECTS__ */
2168
2228
  function _uuidv7(Class, params) {
2169
2229
  return new Class({
2170
2230
  type: "string",
@@ -2175,6 +2235,7 @@ function _uuidv7(Class, params) {
2175
2235
  ...normalizeParams(params)
2176
2236
  });
2177
2237
  }
2238
+ /* @__NO_SIDE_EFFECTS__ */
2178
2239
  function _url(Class, params) {
2179
2240
  return new Class({
2180
2241
  type: "string",
@@ -2184,6 +2245,7 @@ function _url(Class, params) {
2184
2245
  ...normalizeParams(params)
2185
2246
  });
2186
2247
  }
2248
+ /* @__NO_SIDE_EFFECTS__ */
2187
2249
  function _emoji(Class, params) {
2188
2250
  return new Class({
2189
2251
  type: "string",
@@ -2193,6 +2255,7 @@ function _emoji(Class, params) {
2193
2255
  ...normalizeParams(params)
2194
2256
  });
2195
2257
  }
2258
+ /* @__NO_SIDE_EFFECTS__ */
2196
2259
  function _nanoid(Class, params) {
2197
2260
  return new Class({
2198
2261
  type: "string",
@@ -2202,6 +2265,7 @@ function _nanoid(Class, params) {
2202
2265
  ...normalizeParams(params)
2203
2266
  });
2204
2267
  }
2268
+ /* @__NO_SIDE_EFFECTS__ */
2205
2269
  function _cuid(Class, params) {
2206
2270
  return new Class({
2207
2271
  type: "string",
@@ -2211,6 +2275,7 @@ function _cuid(Class, params) {
2211
2275
  ...normalizeParams(params)
2212
2276
  });
2213
2277
  }
2278
+ /* @__NO_SIDE_EFFECTS__ */
2214
2279
  function _cuid2(Class, params) {
2215
2280
  return new Class({
2216
2281
  type: "string",
@@ -2220,6 +2285,7 @@ function _cuid2(Class, params) {
2220
2285
  ...normalizeParams(params)
2221
2286
  });
2222
2287
  }
2288
+ /* @__NO_SIDE_EFFECTS__ */
2223
2289
  function _ulid(Class, params) {
2224
2290
  return new Class({
2225
2291
  type: "string",
@@ -2229,6 +2295,7 @@ function _ulid(Class, params) {
2229
2295
  ...normalizeParams(params)
2230
2296
  });
2231
2297
  }
2298
+ /* @__NO_SIDE_EFFECTS__ */
2232
2299
  function _xid(Class, params) {
2233
2300
  return new Class({
2234
2301
  type: "string",
@@ -2238,6 +2305,7 @@ function _xid(Class, params) {
2238
2305
  ...normalizeParams(params)
2239
2306
  });
2240
2307
  }
2308
+ /* @__NO_SIDE_EFFECTS__ */
2241
2309
  function _ksuid(Class, params) {
2242
2310
  return new Class({
2243
2311
  type: "string",
@@ -2247,6 +2315,7 @@ function _ksuid(Class, params) {
2247
2315
  ...normalizeParams(params)
2248
2316
  });
2249
2317
  }
2318
+ /* @__NO_SIDE_EFFECTS__ */
2250
2319
  function _ipv4(Class, params) {
2251
2320
  return new Class({
2252
2321
  type: "string",
@@ -2256,6 +2325,7 @@ function _ipv4(Class, params) {
2256
2325
  ...normalizeParams(params)
2257
2326
  });
2258
2327
  }
2328
+ /* @__NO_SIDE_EFFECTS__ */
2259
2329
  function _ipv6(Class, params) {
2260
2330
  return new Class({
2261
2331
  type: "string",
@@ -2265,6 +2335,7 @@ function _ipv6(Class, params) {
2265
2335
  ...normalizeParams(params)
2266
2336
  });
2267
2337
  }
2338
+ /* @__NO_SIDE_EFFECTS__ */
2268
2339
  function _cidrv4(Class, params) {
2269
2340
  return new Class({
2270
2341
  type: "string",
@@ -2274,6 +2345,7 @@ function _cidrv4(Class, params) {
2274
2345
  ...normalizeParams(params)
2275
2346
  });
2276
2347
  }
2348
+ /* @__NO_SIDE_EFFECTS__ */
2277
2349
  function _cidrv6(Class, params) {
2278
2350
  return new Class({
2279
2351
  type: "string",
@@ -2283,6 +2355,7 @@ function _cidrv6(Class, params) {
2283
2355
  ...normalizeParams(params)
2284
2356
  });
2285
2357
  }
2358
+ /* @__NO_SIDE_EFFECTS__ */
2286
2359
  function _base64(Class, params) {
2287
2360
  return new Class({
2288
2361
  type: "string",
@@ -2292,6 +2365,7 @@ function _base64(Class, params) {
2292
2365
  ...normalizeParams(params)
2293
2366
  });
2294
2367
  }
2368
+ /* @__NO_SIDE_EFFECTS__ */
2295
2369
  function _base64url(Class, params) {
2296
2370
  return new Class({
2297
2371
  type: "string",
@@ -2301,6 +2375,7 @@ function _base64url(Class, params) {
2301
2375
  ...normalizeParams(params)
2302
2376
  });
2303
2377
  }
2378
+ /* @__NO_SIDE_EFFECTS__ */
2304
2379
  function _e164(Class, params) {
2305
2380
  return new Class({
2306
2381
  type: "string",
@@ -2310,6 +2385,7 @@ function _e164(Class, params) {
2310
2385
  ...normalizeParams(params)
2311
2386
  });
2312
2387
  }
2388
+ /* @__NO_SIDE_EFFECTS__ */
2313
2389
  function _jwt(Class, params) {
2314
2390
  return new Class({
2315
2391
  type: "string",
@@ -2319,6 +2395,7 @@ function _jwt(Class, params) {
2319
2395
  ...normalizeParams(params)
2320
2396
  });
2321
2397
  }
2398
+ /* @__NO_SIDE_EFFECTS__ */
2322
2399
  function _isoDateTime(Class, params) {
2323
2400
  return new Class({
2324
2401
  type: "string",
@@ -2330,6 +2407,7 @@ function _isoDateTime(Class, params) {
2330
2407
  ...normalizeParams(params)
2331
2408
  });
2332
2409
  }
2410
+ /* @__NO_SIDE_EFFECTS__ */
2333
2411
  function _isoDate(Class, params) {
2334
2412
  return new Class({
2335
2413
  type: "string",
@@ -2338,6 +2416,7 @@ function _isoDate(Class, params) {
2338
2416
  ...normalizeParams(params)
2339
2417
  });
2340
2418
  }
2419
+ /* @__NO_SIDE_EFFECTS__ */
2341
2420
  function _isoTime(Class, params) {
2342
2421
  return new Class({
2343
2422
  type: "string",
@@ -2347,6 +2426,7 @@ function _isoTime(Class, params) {
2347
2426
  ...normalizeParams(params)
2348
2427
  });
2349
2428
  }
2429
+ /* @__NO_SIDE_EFFECTS__ */
2350
2430
  function _isoDuration(Class, params) {
2351
2431
  return new Class({
2352
2432
  type: "string",
@@ -2355,6 +2435,7 @@ function _isoDuration(Class, params) {
2355
2435
  ...normalizeParams(params)
2356
2436
  });
2357
2437
  }
2438
+ /* @__NO_SIDE_EFFECTS__ */
2358
2439
  function _number(Class, params) {
2359
2440
  return new Class({
2360
2441
  type: "number",
@@ -2362,6 +2443,7 @@ function _number(Class, params) {
2362
2443
  ...normalizeParams(params)
2363
2444
  });
2364
2445
  }
2446
+ /* @__NO_SIDE_EFFECTS__ */
2365
2447
  function _int(Class, params) {
2366
2448
  return new Class({
2367
2449
  type: "number",
@@ -2371,21 +2453,25 @@ function _int(Class, params) {
2371
2453
  ...normalizeParams(params)
2372
2454
  });
2373
2455
  }
2456
+ /* @__NO_SIDE_EFFECTS__ */
2374
2457
  function _boolean(Class, params) {
2375
2458
  return new Class({
2376
2459
  type: "boolean",
2377
2460
  ...normalizeParams(params)
2378
2461
  });
2379
2462
  }
2463
+ /* @__NO_SIDE_EFFECTS__ */
2380
2464
  function _unknown(Class) {
2381
2465
  return new Class({ type: "unknown" });
2382
2466
  }
2467
+ /* @__NO_SIDE_EFFECTS__ */
2383
2468
  function _never(Class, params) {
2384
2469
  return new Class({
2385
2470
  type: "never",
2386
2471
  ...normalizeParams(params)
2387
2472
  });
2388
2473
  }
2474
+ /* @__NO_SIDE_EFFECTS__ */
2389
2475
  function _lt(value, params) {
2390
2476
  return new $ZodCheckLessThan({
2391
2477
  check: "less_than",
@@ -2394,6 +2480,7 @@ function _lt(value, params) {
2394
2480
  inclusive: false
2395
2481
  });
2396
2482
  }
2483
+ /* @__NO_SIDE_EFFECTS__ */
2397
2484
  function _lte(value, params) {
2398
2485
  return new $ZodCheckLessThan({
2399
2486
  check: "less_than",
@@ -2402,6 +2489,7 @@ function _lte(value, params) {
2402
2489
  inclusive: true
2403
2490
  });
2404
2491
  }
2492
+ /* @__NO_SIDE_EFFECTS__ */
2405
2493
  function _gt(value, params) {
2406
2494
  return new $ZodCheckGreaterThan({
2407
2495
  check: "greater_than",
@@ -2410,6 +2498,7 @@ function _gt(value, params) {
2410
2498
  inclusive: false
2411
2499
  });
2412
2500
  }
2501
+ /* @__NO_SIDE_EFFECTS__ */
2413
2502
  function _gte(value, params) {
2414
2503
  return new $ZodCheckGreaterThan({
2415
2504
  check: "greater_than",
@@ -2418,6 +2507,7 @@ function _gte(value, params) {
2418
2507
  inclusive: true
2419
2508
  });
2420
2509
  }
2510
+ /* @__NO_SIDE_EFFECTS__ */
2421
2511
  function _multipleOf(value, params) {
2422
2512
  return new $ZodCheckMultipleOf({
2423
2513
  check: "multiple_of",
@@ -2425,6 +2515,7 @@ function _multipleOf(value, params) {
2425
2515
  value
2426
2516
  });
2427
2517
  }
2518
+ /* @__NO_SIDE_EFFECTS__ */
2428
2519
  function _maxLength(maximum, params) {
2429
2520
  return new $ZodCheckMaxLength({
2430
2521
  check: "max_length",
@@ -2432,6 +2523,7 @@ function _maxLength(maximum, params) {
2432
2523
  maximum
2433
2524
  });
2434
2525
  }
2526
+ /* @__NO_SIDE_EFFECTS__ */
2435
2527
  function _minLength(minimum, params) {
2436
2528
  return new $ZodCheckMinLength({
2437
2529
  check: "min_length",
@@ -2439,6 +2531,7 @@ function _minLength(minimum, params) {
2439
2531
  minimum
2440
2532
  });
2441
2533
  }
2534
+ /* @__NO_SIDE_EFFECTS__ */
2442
2535
  function _length(length, params) {
2443
2536
  return new $ZodCheckLengthEquals({
2444
2537
  check: "length_equals",
@@ -2446,6 +2539,7 @@ function _length(length, params) {
2446
2539
  length
2447
2540
  });
2448
2541
  }
2542
+ /* @__NO_SIDE_EFFECTS__ */
2449
2543
  function _regex(pattern, params) {
2450
2544
  return new $ZodCheckRegex({
2451
2545
  check: "string_format",
@@ -2454,6 +2548,7 @@ function _regex(pattern, params) {
2454
2548
  pattern
2455
2549
  });
2456
2550
  }
2551
+ /* @__NO_SIDE_EFFECTS__ */
2457
2552
  function _lowercase(params) {
2458
2553
  return new $ZodCheckLowerCase({
2459
2554
  check: "string_format",
@@ -2461,6 +2556,7 @@ function _lowercase(params) {
2461
2556
  ...normalizeParams(params)
2462
2557
  });
2463
2558
  }
2559
+ /* @__NO_SIDE_EFFECTS__ */
2464
2560
  function _uppercase(params) {
2465
2561
  return new $ZodCheckUpperCase({
2466
2562
  check: "string_format",
@@ -2468,6 +2564,7 @@ function _uppercase(params) {
2468
2564
  ...normalizeParams(params)
2469
2565
  });
2470
2566
  }
2567
+ /* @__NO_SIDE_EFFECTS__ */
2471
2568
  function _includes(includes, params) {
2472
2569
  return new $ZodCheckIncludes({
2473
2570
  check: "string_format",
@@ -2476,6 +2573,7 @@ function _includes(includes, params) {
2476
2573
  includes
2477
2574
  });
2478
2575
  }
2576
+ /* @__NO_SIDE_EFFECTS__ */
2479
2577
  function _startsWith(prefix, params) {
2480
2578
  return new $ZodCheckStartsWith({
2481
2579
  check: "string_format",
@@ -2484,6 +2582,7 @@ function _startsWith(prefix, params) {
2484
2582
  prefix
2485
2583
  });
2486
2584
  }
2585
+ /* @__NO_SIDE_EFFECTS__ */
2487
2586
  function _endsWith(suffix, params) {
2488
2587
  return new $ZodCheckEndsWith({
2489
2588
  check: "string_format",
@@ -2492,24 +2591,34 @@ function _endsWith(suffix, params) {
2492
2591
  suffix
2493
2592
  });
2494
2593
  }
2594
+ /* @__NO_SIDE_EFFECTS__ */
2495
2595
  function _overwrite(tx) {
2496
2596
  return new $ZodCheckOverwrite({
2497
2597
  check: "overwrite",
2498
2598
  tx
2499
2599
  });
2500
2600
  }
2601
+ /* @__NO_SIDE_EFFECTS__ */
2501
2602
  function _normalize(form) {
2502
- return _overwrite((input) => input.normalize(form));
2603
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
2503
2604
  }
2605
+ /* @__NO_SIDE_EFFECTS__ */
2504
2606
  function _trim() {
2505
- return _overwrite((input) => input.trim());
2607
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
2506
2608
  }
2609
+ /* @__NO_SIDE_EFFECTS__ */
2507
2610
  function _toLowerCase() {
2508
- return _overwrite((input) => input.toLowerCase());
2611
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
2509
2612
  }
2613
+ /* @__NO_SIDE_EFFECTS__ */
2510
2614
  function _toUpperCase() {
2511
- return _overwrite((input) => input.toUpperCase());
2615
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
2512
2616
  }
2617
+ /* @__NO_SIDE_EFFECTS__ */
2618
+ function _slugify() {
2619
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
2620
+ }
2621
+ /* @__NO_SIDE_EFFECTS__ */
2513
2622
  function _array(Class, element, params) {
2514
2623
  return new Class({
2515
2624
  type: "array",
@@ -2517,6 +2626,7 @@ function _array(Class, element, params) {
2517
2626
  ...normalizeParams(params)
2518
2627
  });
2519
2628
  }
2629
+ /* @__NO_SIDE_EFFECTS__ */
2520
2630
  function _refine(Class, fn, _params) {
2521
2631
  return new Class({
2522
2632
  type: "custom",
@@ -2525,8 +2635,9 @@ function _refine(Class, fn, _params) {
2525
2635
  ...normalizeParams(_params)
2526
2636
  });
2527
2637
  }
2638
+ /* @__NO_SIDE_EFFECTS__ */
2528
2639
  function _superRefine(fn) {
2529
- const ch = _check((payload) => {
2640
+ const ch = /* @__PURE__ */ _check((payload) => {
2530
2641
  payload.addIssue = (issue$1) => {
2531
2642
  if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
2532
2643
  else {
@@ -2543,6 +2654,7 @@ function _superRefine(fn) {
2543
2654
  });
2544
2655
  return ch;
2545
2656
  }
2657
+ /* @__NO_SIDE_EFFECTS__ */
2546
2658
  function _check(fn, params) {
2547
2659
  const ch = new $ZodCheck({
2548
2660
  check: "custom",
@@ -2551,9 +2663,556 @@ function _check(fn, params) {
2551
2663
  ch._zod.check = fn;
2552
2664
  return ch;
2553
2665
  }
2666
+ /* @__NO_SIDE_EFFECTS__ */
2667
+ function describe$1(description) {
2668
+ const ch = new $ZodCheck({ check: "describe" });
2669
+ ch._zod.onattach = [(inst) => {
2670
+ const existing = globalRegistry.get(inst) ?? {};
2671
+ globalRegistry.add(inst, {
2672
+ ...existing,
2673
+ description
2674
+ });
2675
+ }];
2676
+ ch._zod.check = () => {};
2677
+ return ch;
2678
+ }
2679
+ /* @__NO_SIDE_EFFECTS__ */
2680
+ function meta$1(metadata) {
2681
+ const ch = new $ZodCheck({ check: "meta" });
2682
+ ch._zod.onattach = [(inst) => {
2683
+ const existing = globalRegistry.get(inst) ?? {};
2684
+ globalRegistry.add(inst, {
2685
+ ...existing,
2686
+ ...metadata
2687
+ });
2688
+ }];
2689
+ ch._zod.check = () => {};
2690
+ return ch;
2691
+ }
2554
2692
 
2555
2693
  //#endregion
2556
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js
2694
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/to-json-schema.js
2695
+ function initializeContext(params) {
2696
+ let target = params?.target ?? "draft-2020-12";
2697
+ if (target === "draft-4") target = "draft-04";
2698
+ if (target === "draft-7") target = "draft-07";
2699
+ return {
2700
+ processors: params.processors ?? {},
2701
+ metadataRegistry: params?.metadata ?? globalRegistry,
2702
+ target,
2703
+ unrepresentable: params?.unrepresentable ?? "throw",
2704
+ override: params?.override ?? (() => {}),
2705
+ io: params?.io ?? "output",
2706
+ counter: 0,
2707
+ seen: /* @__PURE__ */ new Map(),
2708
+ cycles: params?.cycles ?? "ref",
2709
+ reused: params?.reused ?? "inline",
2710
+ external: params?.external ?? void 0
2711
+ };
2712
+ }
2713
+ function process$1(schema, ctx, _params = {
2714
+ path: [],
2715
+ schemaPath: []
2716
+ }) {
2717
+ var _a$1;
2718
+ const def = schema._zod.def;
2719
+ const seen = ctx.seen.get(schema);
2720
+ if (seen) {
2721
+ seen.count++;
2722
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
2723
+ return seen.schema;
2724
+ }
2725
+ const result = {
2726
+ schema: {},
2727
+ count: 1,
2728
+ cycle: void 0,
2729
+ path: _params.path
2730
+ };
2731
+ ctx.seen.set(schema, result);
2732
+ const overrideSchema = schema._zod.toJSONSchema?.();
2733
+ if (overrideSchema) result.schema = overrideSchema;
2734
+ else {
2735
+ const params = {
2736
+ ..._params,
2737
+ schemaPath: [..._params.schemaPath, schema],
2738
+ path: _params.path
2739
+ };
2740
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
2741
+ else {
2742
+ const _json = result.schema;
2743
+ const processor = ctx.processors[def.type];
2744
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
2745
+ processor(schema, ctx, _json, params);
2746
+ }
2747
+ const parent = schema._zod.parent;
2748
+ if (parent) {
2749
+ if (!result.ref) result.ref = parent;
2750
+ process$1(parent, ctx, params);
2751
+ ctx.seen.get(parent).isParent = true;
2752
+ }
2753
+ }
2754
+ const meta$2 = ctx.metadataRegistry.get(schema);
2755
+ if (meta$2) Object.assign(result.schema, meta$2);
2756
+ if (ctx.io === "input" && isTransforming(schema)) {
2757
+ delete result.schema.examples;
2758
+ delete result.schema.default;
2759
+ }
2760
+ if (ctx.io === "input" && result.schema._prefault) (_a$1 = result.schema).default ?? (_a$1.default = result.schema._prefault);
2761
+ delete result.schema._prefault;
2762
+ return ctx.seen.get(schema).schema;
2763
+ }
2764
+ function extractDefs(ctx, schema) {
2765
+ const root = ctx.seen.get(schema);
2766
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2767
+ const idToSchema = /* @__PURE__ */ new Map();
2768
+ for (const entry of ctx.seen.entries()) {
2769
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
2770
+ if (id) {
2771
+ const existing = idToSchema.get(id);
2772
+ if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
2773
+ idToSchema.set(id, entry[0]);
2774
+ }
2775
+ }
2776
+ const makeURI = (entry) => {
2777
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
2778
+ if (ctx.external) {
2779
+ const externalId = ctx.external.registry.get(entry[0])?.id;
2780
+ const uriGenerator = ctx.external.uri ?? ((id$1) => id$1);
2781
+ if (externalId) return { ref: uriGenerator(externalId) };
2782
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
2783
+ entry[1].defId = id;
2784
+ return {
2785
+ defId: id,
2786
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
2787
+ };
2788
+ }
2789
+ if (entry[1] === root) return { ref: "#" };
2790
+ const defUriPrefix = `#/${defsSegment}/`;
2791
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2792
+ return {
2793
+ defId,
2794
+ ref: defUriPrefix + defId
2795
+ };
2796
+ };
2797
+ const extractToDef = (entry) => {
2798
+ if (entry[1].schema.$ref) return;
2799
+ const seen = entry[1];
2800
+ const { ref, defId } = makeURI(entry);
2801
+ seen.def = { ...seen.schema };
2802
+ if (defId) seen.defId = defId;
2803
+ const schema$1 = seen.schema;
2804
+ for (const key in schema$1) delete schema$1[key];
2805
+ schema$1.$ref = ref;
2806
+ };
2807
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
2808
+ const seen = entry[1];
2809
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
2810
+
2811
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
2812
+ }
2813
+ for (const entry of ctx.seen.entries()) {
2814
+ const seen = entry[1];
2815
+ if (schema === entry[0]) {
2816
+ extractToDef(entry);
2817
+ continue;
2818
+ }
2819
+ if (ctx.external) {
2820
+ const ext = ctx.external.registry.get(entry[0])?.id;
2821
+ if (schema !== entry[0] && ext) {
2822
+ extractToDef(entry);
2823
+ continue;
2824
+ }
2825
+ }
2826
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
2827
+ extractToDef(entry);
2828
+ continue;
2829
+ }
2830
+ if (seen.cycle) {
2831
+ extractToDef(entry);
2832
+ continue;
2833
+ }
2834
+ if (seen.count > 1) {
2835
+ if (ctx.reused === "ref") {
2836
+ extractToDef(entry);
2837
+ continue;
2838
+ }
2839
+ }
2840
+ }
2841
+ }
2842
+ function finalize(ctx, schema) {
2843
+ const root = ctx.seen.get(schema);
2844
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2845
+ const flattenRef = (zodSchema) => {
2846
+ const seen = ctx.seen.get(zodSchema);
2847
+ if (seen.ref === null) return;
2848
+ const schema$1 = seen.def ?? seen.schema;
2849
+ const _cached = { ...schema$1 };
2850
+ const ref = seen.ref;
2851
+ seen.ref = null;
2852
+ if (ref) {
2853
+ flattenRef(ref);
2854
+ const refSeen = ctx.seen.get(ref);
2855
+ const refSchema = refSeen.schema;
2856
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2857
+ schema$1.allOf = schema$1.allOf ?? [];
2858
+ schema$1.allOf.push(refSchema);
2859
+ } else Object.assign(schema$1, refSchema);
2860
+ Object.assign(schema$1, _cached);
2861
+ if (zodSchema._zod.parent === ref) for (const key in schema$1) {
2862
+ if (key === "$ref" || key === "allOf") continue;
2863
+ if (!(key in _cached)) delete schema$1[key];
2864
+ }
2865
+ if (refSchema.$ref) for (const key in schema$1) {
2866
+ if (key === "$ref" || key === "allOf") continue;
2867
+ if (key in refSeen.def && JSON.stringify(schema$1[key]) === JSON.stringify(refSeen.def[key])) delete schema$1[key];
2868
+ }
2869
+ }
2870
+ const parent = zodSchema._zod.parent;
2871
+ if (parent && parent !== ref) {
2872
+ flattenRef(parent);
2873
+ const parentSeen = ctx.seen.get(parent);
2874
+ if (parentSeen?.schema.$ref) {
2875
+ schema$1.$ref = parentSeen.schema.$ref;
2876
+ if (parentSeen.def) for (const key in schema$1) {
2877
+ if (key === "$ref" || key === "allOf") continue;
2878
+ if (key in parentSeen.def && JSON.stringify(schema$1[key]) === JSON.stringify(parentSeen.def[key])) delete schema$1[key];
2879
+ }
2880
+ }
2881
+ }
2882
+ ctx.override({
2883
+ zodSchema,
2884
+ jsonSchema: schema$1,
2885
+ path: seen.path ?? []
2886
+ });
2887
+ };
2888
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
2889
+ const result = {};
2890
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2891
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
2892
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
2893
+ else if (ctx.target === "openapi-3.0") {}
2894
+ if (ctx.external?.uri) {
2895
+ const id = ctx.external.registry.get(schema)?.id;
2896
+ if (!id) throw new Error("Schema is missing an `id` property");
2897
+ result.$id = ctx.external.uri(id);
2898
+ }
2899
+ Object.assign(result, root.def ?? root.schema);
2900
+ const defs = ctx.external?.defs ?? {};
2901
+ for (const entry of ctx.seen.entries()) {
2902
+ const seen = entry[1];
2903
+ if (seen.def && seen.defId) defs[seen.defId] = seen.def;
2904
+ }
2905
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
2906
+ else result.definitions = defs;
2907
+ try {
2908
+ const finalized = JSON.parse(JSON.stringify(result));
2909
+ Object.defineProperty(finalized, "~standard", {
2910
+ value: {
2911
+ ...schema["~standard"],
2912
+ jsonSchema: {
2913
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
2914
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
2915
+ }
2916
+ },
2917
+ enumerable: false,
2918
+ writable: false
2919
+ });
2920
+ return finalized;
2921
+ } catch (_err) {
2922
+ throw new Error("Error converting schema to JSON.");
2923
+ }
2924
+ }
2925
+ function isTransforming(_schema, _ctx) {
2926
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
2927
+ if (ctx.seen.has(_schema)) return false;
2928
+ ctx.seen.add(_schema);
2929
+ const def = _schema._zod.def;
2930
+ if (def.type === "transform") return true;
2931
+ if (def.type === "array") return isTransforming(def.element, ctx);
2932
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
2933
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
2934
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
2935
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2936
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2937
+ if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
2938
+ if (def.type === "object") {
2939
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
2940
+ return false;
2941
+ }
2942
+ if (def.type === "union") {
2943
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
2944
+ return false;
2945
+ }
2946
+ if (def.type === "tuple") {
2947
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
2948
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
2949
+ return false;
2950
+ }
2951
+ return false;
2952
+ }
2953
+ /**
2954
+ * Creates a toJSONSchema method for a schema instance.
2955
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
2956
+ */
2957
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
2958
+ const ctx = initializeContext({
2959
+ ...params,
2960
+ processors
2961
+ });
2962
+ process$1(schema, ctx);
2963
+ extractDefs(ctx, schema);
2964
+ return finalize(ctx, schema);
2965
+ };
2966
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
2967
+ const { libraryOptions, target } = params ?? {};
2968
+ const ctx = initializeContext({
2969
+ ...libraryOptions ?? {},
2970
+ target,
2971
+ io,
2972
+ processors
2973
+ });
2974
+ process$1(schema, ctx);
2975
+ extractDefs(ctx, schema);
2976
+ return finalize(ctx, schema);
2977
+ };
2978
+
2979
+ //#endregion
2980
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/json-schema-processors.js
2981
+ const formatMap = {
2982
+ guid: "uuid",
2983
+ url: "uri",
2984
+ datetime: "date-time",
2985
+ json_string: "json-string",
2986
+ regex: ""
2987
+ };
2988
+ const stringProcessor = (schema, ctx, _json, _params) => {
2989
+ const json = _json;
2990
+ json.type = "string";
2991
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
2992
+ if (typeof minimum === "number") json.minLength = minimum;
2993
+ if (typeof maximum === "number") json.maxLength = maximum;
2994
+ if (format) {
2995
+ json.format = formatMap[format] ?? format;
2996
+ if (json.format === "") delete json.format;
2997
+ if (format === "time") delete json.format;
2998
+ }
2999
+ if (contentEncoding) json.contentEncoding = contentEncoding;
3000
+ if (patterns && patterns.size > 0) {
3001
+ const regexes = [...patterns];
3002
+ if (regexes.length === 1) json.pattern = regexes[0].source;
3003
+ else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
3004
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3005
+ pattern: regex.source
3006
+ }))];
3007
+ }
3008
+ };
3009
+ const numberProcessor = (schema, ctx, _json, _params) => {
3010
+ const json = _json;
3011
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3012
+ if (typeof format === "string" && format.includes("int")) json.type = "integer";
3013
+ else json.type = "number";
3014
+ if (typeof exclusiveMinimum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3015
+ json.minimum = exclusiveMinimum;
3016
+ json.exclusiveMinimum = true;
3017
+ } else json.exclusiveMinimum = exclusiveMinimum;
3018
+ if (typeof minimum === "number") {
3019
+ json.minimum = minimum;
3020
+ if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
3021
+ else delete json.exclusiveMinimum;
3022
+ }
3023
+ if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3024
+ json.maximum = exclusiveMaximum;
3025
+ json.exclusiveMaximum = true;
3026
+ } else json.exclusiveMaximum = exclusiveMaximum;
3027
+ if (typeof maximum === "number") {
3028
+ json.maximum = maximum;
3029
+ if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
3030
+ else delete json.exclusiveMaximum;
3031
+ }
3032
+ if (typeof multipleOf === "number") json.multipleOf = multipleOf;
3033
+ };
3034
+ const booleanProcessor = (_schema, _ctx, json, _params) => {
3035
+ json.type = "boolean";
3036
+ };
3037
+ const neverProcessor = (_schema, _ctx, json, _params) => {
3038
+ json.not = {};
3039
+ };
3040
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
3041
+ const enumProcessor = (schema, _ctx, json, _params) => {
3042
+ const def = schema._zod.def;
3043
+ const values = getEnumValues(def.entries);
3044
+ if (values.every((v) => typeof v === "number")) json.type = "number";
3045
+ if (values.every((v) => typeof v === "string")) json.type = "string";
3046
+ json.enum = values;
3047
+ };
3048
+ const literalProcessor = (schema, ctx, json, _params) => {
3049
+ const def = schema._zod.def;
3050
+ const vals = [];
3051
+ for (const val of def.values) if (val === void 0) {
3052
+ if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3053
+ } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
3054
+ else vals.push(Number(val));
3055
+ else vals.push(val);
3056
+ if (vals.length === 0) {} else if (vals.length === 1) {
3057
+ const val = vals[0];
3058
+ json.type = val === null ? "null" : typeof val;
3059
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
3060
+ else json.const = val;
3061
+ } else {
3062
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
3063
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
3064
+ if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
3065
+ if (vals.every((v) => v === null)) json.type = "null";
3066
+ json.enum = vals;
3067
+ }
3068
+ };
3069
+ const customProcessor = (_schema, ctx, _json, _params) => {
3070
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
3071
+ };
3072
+ const transformProcessor = (_schema, ctx, _json, _params) => {
3073
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
3074
+ };
3075
+ const arrayProcessor = (schema, ctx, _json, params) => {
3076
+ const json = _json;
3077
+ const def = schema._zod.def;
3078
+ const { minimum, maximum } = schema._zod.bag;
3079
+ if (typeof minimum === "number") json.minItems = minimum;
3080
+ if (typeof maximum === "number") json.maxItems = maximum;
3081
+ json.type = "array";
3082
+ json.items = process$1(def.element, ctx, {
3083
+ ...params,
3084
+ path: [...params.path, "items"]
3085
+ });
3086
+ };
3087
+ const objectProcessor = (schema, ctx, _json, params) => {
3088
+ const json = _json;
3089
+ const def = schema._zod.def;
3090
+ json.type = "object";
3091
+ json.properties = {};
3092
+ const shape = def.shape;
3093
+ for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
3094
+ ...params,
3095
+ path: [
3096
+ ...params.path,
3097
+ "properties",
3098
+ key
3099
+ ]
3100
+ });
3101
+ const allKeys = new Set(Object.keys(shape));
3102
+ const requiredKeys = new Set([...allKeys].filter((key) => {
3103
+ const v = def.shape[key]._zod;
3104
+ if (ctx.io === "input") return v.optin === void 0;
3105
+ else return v.optout === void 0;
3106
+ }));
3107
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
3108
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3109
+ else if (!def.catchall) {
3110
+ if (ctx.io === "output") json.additionalProperties = false;
3111
+ } else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
3112
+ ...params,
3113
+ path: [...params.path, "additionalProperties"]
3114
+ });
3115
+ };
3116
+ const unionProcessor = (schema, ctx, json, params) => {
3117
+ const def = schema._zod.def;
3118
+ const isExclusive = def.inclusive === false;
3119
+ const options = def.options.map((x, i) => process$1(x, ctx, {
3120
+ ...params,
3121
+ path: [
3122
+ ...params.path,
3123
+ isExclusive ? "oneOf" : "anyOf",
3124
+ i
3125
+ ]
3126
+ }));
3127
+ if (isExclusive) json.oneOf = options;
3128
+ else json.anyOf = options;
3129
+ };
3130
+ const intersectionProcessor = (schema, ctx, json, params) => {
3131
+ const def = schema._zod.def;
3132
+ const a = process$1(def.left, ctx, {
3133
+ ...params,
3134
+ path: [
3135
+ ...params.path,
3136
+ "allOf",
3137
+ 0
3138
+ ]
3139
+ });
3140
+ const b = process$1(def.right, ctx, {
3141
+ ...params,
3142
+ path: [
3143
+ ...params.path,
3144
+ "allOf",
3145
+ 1
3146
+ ]
3147
+ });
3148
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3149
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3150
+ };
3151
+ const nullableProcessor = (schema, ctx, json, params) => {
3152
+ const def = schema._zod.def;
3153
+ const inner = process$1(def.innerType, ctx, params);
3154
+ const seen = ctx.seen.get(schema);
3155
+ if (ctx.target === "openapi-3.0") {
3156
+ seen.ref = def.innerType;
3157
+ json.nullable = true;
3158
+ } else json.anyOf = [inner, { type: "null" }];
3159
+ };
3160
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
3161
+ const def = schema._zod.def;
3162
+ process$1(def.innerType, ctx, params);
3163
+ const seen = ctx.seen.get(schema);
3164
+ seen.ref = def.innerType;
3165
+ };
3166
+ const defaultProcessor = (schema, ctx, json, params) => {
3167
+ const def = schema._zod.def;
3168
+ process$1(def.innerType, ctx, params);
3169
+ const seen = ctx.seen.get(schema);
3170
+ seen.ref = def.innerType;
3171
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
3172
+ };
3173
+ const prefaultProcessor = (schema, ctx, json, params) => {
3174
+ const def = schema._zod.def;
3175
+ process$1(def.innerType, ctx, params);
3176
+ const seen = ctx.seen.get(schema);
3177
+ seen.ref = def.innerType;
3178
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3179
+ };
3180
+ const catchProcessor = (schema, ctx, json, params) => {
3181
+ const def = schema._zod.def;
3182
+ process$1(def.innerType, ctx, params);
3183
+ const seen = ctx.seen.get(schema);
3184
+ seen.ref = def.innerType;
3185
+ let catchValue;
3186
+ try {
3187
+ catchValue = def.catchValue(void 0);
3188
+ } catch {
3189
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3190
+ }
3191
+ json.default = catchValue;
3192
+ };
3193
+ const pipeProcessor = (schema, ctx, _json, params) => {
3194
+ const def = schema._zod.def;
3195
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3196
+ process$1(innerType, ctx, params);
3197
+ const seen = ctx.seen.get(schema);
3198
+ seen.ref = innerType;
3199
+ };
3200
+ const readonlyProcessor = (schema, ctx, json, params) => {
3201
+ const def = schema._zod.def;
3202
+ process$1(def.innerType, ctx, params);
3203
+ const seen = ctx.seen.get(schema);
3204
+ seen.ref = def.innerType;
3205
+ json.readOnly = true;
3206
+ };
3207
+ const optionalProcessor = (schema, ctx, _json, params) => {
3208
+ const def = schema._zod.def;
3209
+ process$1(def.innerType, ctx, params);
3210
+ const seen = ctx.seen.get(schema);
3211
+ seen.ref = def.innerType;
3212
+ };
3213
+
3214
+ //#endregion
3215
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/iso.js
2557
3216
  const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
2558
3217
  $ZodISODateTime.init(inst, def);
2559
3218
  ZodStringFormat.init(inst, def);
@@ -2584,7 +3243,7 @@ function duration(params) {
2584
3243
  }
2585
3244
 
2586
3245
  //#endregion
2587
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js
3246
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/errors.js
2588
3247
  const initializer = (inst, issues) => {
2589
3248
  $ZodError.init(inst, issues);
2590
3249
  inst.name = "ZodError";
@@ -2608,7 +3267,7 @@ const ZodError = $constructor("ZodError", initializer);
2608
3267
  const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
2609
3268
 
2610
3269
  //#endregion
2611
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js
3270
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/parse.js
2612
3271
  const parse = /* @__PURE__ */ _parse(ZodRealError);
2613
3272
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
2614
3273
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -2623,9 +3282,14 @@ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
2623
3282
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
2624
3283
 
2625
3284
  //#endregion
2626
- //#region ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js
3285
+ //#region ../../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/schemas.js
2627
3286
  const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2628
3287
  $ZodType.init(inst, def);
3288
+ Object.assign(inst["~standard"], { jsonSchema: {
3289
+ input: createStandardJSONSchemaMethod(inst, "input"),
3290
+ output: createStandardJSONSchemaMethod(inst, "output")
3291
+ } });
3292
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
2629
3293
  inst.def = def;
2630
3294
  inst.type = def.type;
2631
3295
  Object.defineProperty(inst, "_def", { value: def });
@@ -2634,12 +3298,13 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2634
3298
  check: ch,
2635
3299
  def: { check: "custom" },
2636
3300
  onattach: []
2637
- } } : ch)] }));
3301
+ } } : ch)] }), { parent: true });
2638
3302
  };
3303
+ inst.with = inst.check;
2639
3304
  inst.clone = (def$1, params) => clone(inst, def$1, params);
2640
3305
  inst.brand = () => inst;
2641
- inst.register = ((reg, meta) => {
2642
- reg.add(inst, meta);
3306
+ inst.register = ((reg, meta$2) => {
3307
+ reg.add(inst, meta$2);
2643
3308
  return inst;
2644
3309
  });
2645
3310
  inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
@@ -2659,6 +3324,7 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2659
3324
  inst.superRefine = (refinement) => inst.check(superRefine(refinement));
2660
3325
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
2661
3326
  inst.optional = () => optional(inst);
3327
+ inst.exactOptional = () => exactOptional(inst);
2662
3328
  inst.nullable = () => nullable(inst);
2663
3329
  inst.nullish = () => optional(nullable(inst));
2664
3330
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -2690,12 +3356,14 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2690
3356
  };
2691
3357
  inst.isOptional = () => inst.safeParse(void 0).success;
2692
3358
  inst.isNullable = () => inst.safeParse(null).success;
3359
+ inst.apply = (fn) => fn(inst);
2693
3360
  return inst;
2694
3361
  });
2695
3362
  /** @internal */
2696
3363
  const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
2697
3364
  $ZodString.init(inst, def);
2698
3365
  ZodType.init(inst, def);
3366
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
2699
3367
  const bag = inst._zod.bag;
2700
3368
  inst.format = bag.format ?? null;
2701
3369
  inst.minLength = bag.minimum ?? null;
@@ -2714,6 +3382,7 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
2714
3382
  inst.normalize = (...args) => inst.check(_normalize(...args));
2715
3383
  inst.toLowerCase = () => inst.check(_toLowerCase());
2716
3384
  inst.toUpperCase = () => inst.check(_toUpperCase());
3385
+ inst.slugify = () => inst.check(_slugify());
2717
3386
  });
2718
3387
  const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
2719
3388
  $ZodString.init(inst, def);
@@ -2832,6 +3501,7 @@ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
2832
3501
  const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
2833
3502
  $ZodNumber.init(inst, def);
2834
3503
  ZodType.init(inst, def);
3504
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
2835
3505
  inst.gt = (value, params) => inst.check(_gt(value, params));
2836
3506
  inst.gte = (value, params) => inst.check(_gte(value, params));
2837
3507
  inst.min = (value, params) => inst.check(_gte(value, params));
@@ -2867,6 +3537,7 @@ function int(params) {
2867
3537
  const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
2868
3538
  $ZodBoolean.init(inst, def);
2869
3539
  ZodType.init(inst, def);
3540
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
2870
3541
  });
2871
3542
  function boolean(params) {
2872
3543
  return _boolean(ZodBoolean, params);
@@ -2874,6 +3545,7 @@ function boolean(params) {
2874
3545
  const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2875
3546
  $ZodUnknown.init(inst, def);
2876
3547
  ZodType.init(inst, def);
3548
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
2877
3549
  });
2878
3550
  function unknown() {
2879
3551
  return _unknown(ZodUnknown);
@@ -2881,6 +3553,7 @@ function unknown() {
2881
3553
  const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
2882
3554
  $ZodNever.init(inst, def);
2883
3555
  ZodType.init(inst, def);
3556
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
2884
3557
  });
2885
3558
  function never(params) {
2886
3559
  return _never(ZodNever, params);
@@ -2888,6 +3561,7 @@ function never(params) {
2888
3561
  const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2889
3562
  $ZodArray.init(inst, def);
2890
3563
  ZodType.init(inst, def);
3564
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
2891
3565
  inst.element = def.element;
2892
3566
  inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
2893
3567
  inst.nonempty = (params) => inst.check(_minLength(1, params));
@@ -2901,6 +3575,7 @@ function array(element, params) {
2901
3575
  const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
2902
3576
  $ZodObjectJIT.init(inst, def);
2903
3577
  ZodType.init(inst, def);
3578
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
2904
3579
  defineLazy(inst, "shape", () => {
2905
3580
  return def.shape;
2906
3581
  });
@@ -2947,6 +3622,7 @@ function object(shape, params) {
2947
3622
  const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
2948
3623
  $ZodUnion.init(inst, def);
2949
3624
  ZodType.init(inst, def);
3625
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
2950
3626
  inst.options = def.options;
2951
3627
  });
2952
3628
  function union(options, params) {
@@ -2971,6 +3647,7 @@ function discriminatedUnion(discriminator, options, params) {
2971
3647
  const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
2972
3648
  $ZodIntersection.init(inst, def);
2973
3649
  ZodType.init(inst, def);
3650
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
2974
3651
  });
2975
3652
  function intersection(left, right) {
2976
3653
  return new ZodIntersection({
@@ -2982,6 +3659,7 @@ function intersection(left, right) {
2982
3659
  const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
2983
3660
  $ZodEnum.init(inst, def);
2984
3661
  ZodType.init(inst, def);
3662
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
2985
3663
  inst.enum = def.entries;
2986
3664
  inst.options = Object.values(def.entries);
2987
3665
  const keys = new Set(Object.keys(def.entries));
@@ -3018,6 +3696,7 @@ function _enum(values, params) {
3018
3696
  const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
3019
3697
  $ZodLiteral.init(inst, def);
3020
3698
  ZodType.init(inst, def);
3699
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
3021
3700
  inst.values = new Set(def.values);
3022
3701
  Object.defineProperty(inst, "value", { get() {
3023
3702
  if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
@@ -3034,6 +3713,7 @@ function literal(value, params) {
3034
3713
  const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
3035
3714
  $ZodTransform.init(inst, def);
3036
3715
  ZodType.init(inst, def);
3716
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
3037
3717
  inst._zod.parse = (payload, _ctx) => {
3038
3718
  if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
3039
3719
  payload.addIssue = (issue$1) => {
@@ -3065,6 +3745,7 @@ function transform(fn) {
3065
3745
  const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
3066
3746
  $ZodOptional.init(inst, def);
3067
3747
  ZodType.init(inst, def);
3748
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3068
3749
  inst.unwrap = () => inst._zod.def.innerType;
3069
3750
  });
3070
3751
  function optional(innerType) {
@@ -3073,9 +3754,22 @@ function optional(innerType) {
3073
3754
  innerType
3074
3755
  });
3075
3756
  }
3757
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
3758
+ $ZodExactOptional.init(inst, def);
3759
+ ZodType.init(inst, def);
3760
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3761
+ inst.unwrap = () => inst._zod.def.innerType;
3762
+ });
3763
+ function exactOptional(innerType) {
3764
+ return new ZodExactOptional({
3765
+ type: "optional",
3766
+ innerType
3767
+ });
3768
+ }
3076
3769
  const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
3077
3770
  $ZodNullable.init(inst, def);
3078
3771
  ZodType.init(inst, def);
3772
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
3079
3773
  inst.unwrap = () => inst._zod.def.innerType;
3080
3774
  });
3081
3775
  function nullable(innerType) {
@@ -3087,6 +3781,7 @@ function nullable(innerType) {
3087
3781
  const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
3088
3782
  $ZodDefault.init(inst, def);
3089
3783
  ZodType.init(inst, def);
3784
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
3090
3785
  inst.unwrap = () => inst._zod.def.innerType;
3091
3786
  inst.removeDefault = inst.unwrap;
3092
3787
  });
@@ -3102,6 +3797,7 @@ function _default(innerType, defaultValue) {
3102
3797
  const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
3103
3798
  $ZodPrefault.init(inst, def);
3104
3799
  ZodType.init(inst, def);
3800
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
3105
3801
  inst.unwrap = () => inst._zod.def.innerType;
3106
3802
  });
3107
3803
  function prefault(innerType, defaultValue) {
@@ -3116,6 +3812,7 @@ function prefault(innerType, defaultValue) {
3116
3812
  const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
3117
3813
  $ZodNonOptional.init(inst, def);
3118
3814
  ZodType.init(inst, def);
3815
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
3119
3816
  inst.unwrap = () => inst._zod.def.innerType;
3120
3817
  });
3121
3818
  function nonoptional(innerType, params) {
@@ -3128,6 +3825,7 @@ function nonoptional(innerType, params) {
3128
3825
  const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
3129
3826
  $ZodCatch.init(inst, def);
3130
3827
  ZodType.init(inst, def);
3828
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
3131
3829
  inst.unwrap = () => inst._zod.def.innerType;
3132
3830
  inst.removeCatch = inst.unwrap;
3133
3831
  });
@@ -3141,6 +3839,7 @@ function _catch(innerType, catchValue) {
3141
3839
  const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
3142
3840
  $ZodPipe.init(inst, def);
3143
3841
  ZodType.init(inst, def);
3842
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
3144
3843
  inst.in = def.in;
3145
3844
  inst.out = def.out;
3146
3845
  });
@@ -3154,6 +3853,7 @@ function pipe(in_, out) {
3154
3853
  const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
3155
3854
  $ZodReadonly.init(inst, def);
3156
3855
  ZodType.init(inst, def);
3856
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
3157
3857
  inst.unwrap = () => inst._zod.def.innerType;
3158
3858
  });
3159
3859
  function readonly(innerType) {
@@ -3165,6 +3865,7 @@ function readonly(innerType) {
3165
3865
  const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
3166
3866
  $ZodCustom.init(inst, def);
3167
3867
  ZodType.init(inst, def);
3868
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
3168
3869
  });
3169
3870
  function refine(fn, _params = {}) {
3170
3871
  return _refine(ZodCustom, fn, _params);
@@ -3172,6 +3873,8 @@ function refine(fn, _params = {}) {
3172
3873
  function superRefine(fn) {
3173
3874
  return _superRefine(fn);
3174
3875
  }
3876
+ const describe = describe$1;
3877
+ const meta = meta$1;
3175
3878
 
3176
3879
  //#endregion
3177
3880
  //#region ../mcp-shared/dist/index.js
@@ -3184,6 +3887,7 @@ const MCP_MAX_PAYLOAD_BYTES = 4 * 1024 * 1024;
3184
3887
  const MCP_TOOL_TIMEOUT_MS = 15e3;
3185
3888
  const MCP_AUTO_ACTIVATE_GRACE_MS = 1500;
3186
3889
  const MCP_MAX_ASSET_BYTES = 8 * 1024 * 1024;
3890
+ const MCP_ASSET_TTL_MS = 720 * 60 * 60 * 1e3;
3187
3891
  const MCP_ASSET_RESOURCE_NAME = "tempad-assets";
3188
3892
  const MCP_ASSET_URI_PREFIX = "asset://tempad/";
3189
3893
  const MCP_ASSET_URI_TEMPLATE = `${MCP_ASSET_URI_PREFIX}{hash}`;
@@ -3234,10 +3938,10 @@ const AssetDescriptorSchema = object({
3234
3938
  const GetCodeParametersSchema = object({
3235
3939
  nodeId: string().describe("Optional target node id; omit to use the current single selection when pulling the baseline snapshot.").optional(),
3236
3940
  preferredLang: _enum(["jsx", "vue"]).describe("Preferred output language to bias the snapshot; otherwise uses the design’s hint/detected language, then falls back to JSX.").optional(),
3237
- resolveTokens: boolean().describe("Inline token values instead of references for quick renders; default false returns token metadata so you can map into your theming system.").optional()
3941
+ resolveTokens: boolean().describe("Inline token values instead of references for quick renders; default false returns token metadata so you can map into your theming system. When true, values are resolved per-node (mode-aware).").optional()
3238
3942
  });
3239
3943
  const GetTokenDefsParametersSchema = object({
3240
- names: array(string().regex(/^--[a-zA-Z0-9-_]+$/)).min(1).describe("Canonical token names (CSS variable form) from Object.keys(get_code.usedTokens) or your own list to resolve, e.g., --color-primary."),
3944
+ names: array(string().regex(/^--[a-zA-Z0-9-_]+$/)).min(1).describe("Canonical token names (CSS variable form) from Object.keys(get_code.tokens) or your own list to resolve, e.g., --color-primary."),
3241
3945
  includeAllModes: boolean().describe("Include all token modes (light/dark/etc.) instead of just the active one to mirror responsive tokens; default false.").optional()
3242
3946
  });
3243
3947
  const GetScreenshotParametersSchema = object({ nodeId: string().describe("Optional node id to screenshot; defaults to the current single selection. Useful when layout/overlap is uncertain (auto-layout none/inferred).").optional() });
@@ -3251,12 +3955,44 @@ const GetAssetsResultSchema = object({
3251
3955
  missing: array(string().min(1))
3252
3956
  });
3253
3957
 
3958
+ //#endregion
3959
+ //#region src/asset-utils.ts
3960
+ const HASH_FILENAME_PATTERN = new RegExp(`^([a-f0-9]{${MCP_HASH_HEX_LENGTH}})(?:\\.[a-z0-9]+)?$`, "i");
3961
+ const MIME_EXTENSION_OVERRIDES = new Map([["image/jpeg", "jpg"]]);
3962
+ function normalizeMimeType(mimeType) {
3963
+ if (!mimeType) return "application/octet-stream";
3964
+ const [normalized] = mimeType.split(";", 1);
3965
+ return (normalized || "application/octet-stream").trim().toLowerCase();
3966
+ }
3967
+ function getImageExtension(mimeType) {
3968
+ const normalized = normalizeMimeType(mimeType);
3969
+ if (!normalized.startsWith("image/")) return "";
3970
+ const override = MIME_EXTENSION_OVERRIDES.get(normalized);
3971
+ if (override) return `.${override}`;
3972
+ const subtype = normalized.slice(6);
3973
+ if (!subtype) return "";
3974
+ const ext = subtype.split("+", 1)[0] || subtype;
3975
+ return ext ? `.${ext}` : "";
3976
+ }
3977
+ function buildAssetFilename(hash, mimeType) {
3978
+ const ext = getImageExtension(mimeType);
3979
+ return ext ? `${hash}${ext}` : hash;
3980
+ }
3981
+ function getHashFromAssetFilename(filename) {
3982
+ const match = HASH_FILENAME_PATTERN.exec(filename);
3983
+ return match ? match[1] : null;
3984
+ }
3985
+
3254
3986
  //#endregion
3255
3987
  //#region src/config.ts
3256
3988
  function parsePositiveInt(envValue, fallback) {
3257
3989
  const parsed = envValue ? Number.parseInt(envValue, 10) : NaN;
3258
3990
  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
3259
3991
  }
3992
+ function parseNonNegativeInt(envValue, fallback) {
3993
+ const parsed = envValue ? Number.parseInt(envValue, 10) : NaN;
3994
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
3995
+ }
3260
3996
  function resolveToolTimeoutMs() {
3261
3997
  return parsePositiveInt(process.env.TEMPAD_MCP_TOOL_TIMEOUT, MCP_TOOL_TIMEOUT_MS);
3262
3998
  }
@@ -3266,13 +4002,17 @@ function resolveAutoActivateGraceMs() {
3266
4002
  function resolveMaxAssetSizeBytes() {
3267
4003
  return parsePositiveInt(process.env.TEMPAD_MCP_MAX_ASSET_BYTES, MCP_MAX_ASSET_BYTES);
3268
4004
  }
4005
+ function resolveAssetTtlMs() {
4006
+ return parseNonNegativeInt(process.env.TEMPAD_MCP_ASSET_TTL_MS, MCP_ASSET_TTL_MS);
4007
+ }
3269
4008
  function getMcpServerConfig() {
3270
4009
  return {
3271
4010
  wsPortCandidates: [...MCP_PORT_CANDIDATES],
3272
4011
  toolTimeoutMs: resolveToolTimeoutMs(),
3273
4012
  maxPayloadBytes: MCP_MAX_PAYLOAD_BYTES,
3274
4013
  autoActivateGraceMs: resolveAutoActivateGraceMs(),
3275
- maxAssetSizeBytes: resolveMaxAssetSizeBytes()
4014
+ maxAssetSizeBytes: resolveMaxAssetSizeBytes(),
4015
+ assetTtlMs: resolveAssetTtlMs()
3276
4016
  };
3277
4017
  }
3278
4018
 
@@ -3340,7 +4080,12 @@ function createAssetHttpServer(store) {
3340
4080
  sendError(res, 404, "Not Found");
3341
4081
  return;
3342
4082
  }
3343
- const hash = segments[1];
4083
+ const filename = segments[1];
4084
+ const hash = getHashFromAssetFilename(filename);
4085
+ if (!hash) {
4086
+ sendError(res, 404, "Not Found");
4087
+ return;
4088
+ }
3344
4089
  if (req.method === "POST") {
3345
4090
  handleUpload(req, res, hash);
3346
4091
  return;
@@ -3397,30 +4142,41 @@ function createAssetHttpServer(store) {
3397
4142
  sendError(res, 400, "Invalid Hash Format");
3398
4143
  return;
3399
4144
  }
3400
- const mimeType = req.headers["content-type"] || "application/octet-stream";
3401
- const filePath = join(ASSET_DIR, hash);
4145
+ const contentTypeHeader = req.headers["content-type"];
4146
+ const mimeType = normalizeMimeType(Array.isArray(contentTypeHeader) ? contentTypeHeader[0] : contentTypeHeader);
4147
+ const filePath = join(ASSET_DIR, buildAssetFilename(hash, mimeType));
3402
4148
  const width = parseInt(req.headers["x-asset-width"], 10);
3403
4149
  const height = parseInt(req.headers["x-asset-height"], 10);
3404
4150
  const metadata = !isNaN(width) && !isNaN(height) && width > 0 && height > 0 ? {
3405
4151
  width,
3406
4152
  height
3407
4153
  } : void 0;
3408
- if (store.has(hash) && existsSync(filePath)) {
3409
- req.resume();
3410
- const existing = store.get(hash);
3411
- let changed = false;
3412
- if (metadata) {
3413
- existing.metadata = metadata;
3414
- changed = true;
4154
+ const existing = store.get(hash);
4155
+ if (existing) {
4156
+ let existingPath = existing.filePath;
4157
+ if (!existsSync(existingPath) && existsSync(filePath)) {
4158
+ existing.filePath = filePath;
4159
+ existingPath = filePath;
3415
4160
  }
3416
- if (existing.mimeType !== mimeType) {
3417
- existing.mimeType = mimeType;
3418
- changed = true;
4161
+ if (existsSync(existingPath)) {
4162
+ if (existingPath !== filePath) try {
4163
+ renameSync(existingPath, filePath);
4164
+ existing.filePath = filePath;
4165
+ existingPath = filePath;
4166
+ } catch (error) {
4167
+ log.warn({
4168
+ error,
4169
+ hash
4170
+ }, "Failed to rename existing asset to include extension.");
4171
+ }
4172
+ req.resume();
4173
+ if (metadata) existing.metadata = metadata;
4174
+ if (existing.mimeType !== mimeType) existing.mimeType = mimeType;
4175
+ existing.lastAccess = Date.now();
4176
+ store.upsert(existing);
4177
+ sendOk(res, 200, "Asset Already Exists");
4178
+ return;
3419
4179
  }
3420
- if (changed) store.upsert(existing);
3421
- store.touch(hash);
3422
- sendOk(res, 200, "Asset Already Exists");
3423
- return;
3424
4180
  }
3425
4181
  const tmpPath = `${filePath}.tmp.${nanoid()}`;
3426
4182
  const writeStream = createWriteStream(tmpPath);
@@ -3631,13 +4387,14 @@ function createAssetStore(options = {}) {
3631
4387
  }
3632
4388
  continue;
3633
4389
  }
3634
- if (!MCP_HASH_PATTERN.test(file)) continue;
3635
- if (!records.has(file)) {
4390
+ const hash = getHashFromAssetFilename(file);
4391
+ if (!hash) continue;
4392
+ if (!records.has(hash)) {
3636
4393
  const filePath = join(ASSET_DIR, file);
3637
4394
  try {
3638
4395
  const stat = statSync(filePath);
3639
- records.set(file, {
3640
- hash: file,
4396
+ records.set(hash, {
4397
+ hash,
3641
4398
  filePath,
3642
4399
  mimeType: "application/octet-stream",
3643
4400
  size: stat.size,
@@ -3645,7 +4402,7 @@ function createAssetStore(options = {}) {
3645
4402
  lastAccess: stat.atimeMs
3646
4403
  });
3647
4404
  changed = true;
3648
- log.info({ hash: file }, "Recovered orphan asset file.");
4405
+ log.info({ hash }, "Recovered orphan asset file.");
3649
4406
  } catch (e) {
3650
4407
  log.warn({
3651
4408
  error: e,
@@ -3676,7 +4433,7 @@ function createAssetStore(options = {}) {
3676
4433
 
3677
4434
  //#endregion
3678
4435
  //#region src/instructions.md?raw
3679
- var instructions_default = "You are connected to a Figma design file via the MCP server. Convert design elements into production code, preserving design intent while fitting the user’s codebase conventions.\n\n- Start from `get_code` as the baseline, then refactor to match project conventions (components, styling system, file structure, naming).\n- Layout confidence:\n - If `get_code` contains no `data-hint-auto-layout`, it likely indicates the layout is explicit. You can be more confident implementing directly from `get_code`.\n - If any `data-hint-auto-layout` is `none` or `inferred`, the corresponding layout may be uncertain. If you feel ambiguity or uncertainty, consult `get_structure` (hierarchy + geometry) and `get_screenshot` (visual intent such as layering/overlap/masks/shadows/translucency).\n- If `data-hint-component` plus repetition supports it, extract reusable components/variants aligned with project patterns. Do not preserve hint strings in output.\n- Tokens: follow the project’s token/theming framework; if needed, use `get_code.usedToken` metadata (collection, mode) to extend a responsive token system within that framework.\n- Assets: follow the project’s existing conventions/practices (icon system, asset pipeline, import/path rules, optimization) to decide how to represent and reference assets. If `get_code` uses resource URIs, you may replace them with the project’s canonical references when appropriate without changing rendering.\n- Do not output any `data-*` attributes returned by `get_code`.\n- For SVG/vector assets: use the exact provided asset, preserving `path` data, `viewBox`, and full SVG structure. Never redraw or approximate vectors.\n";
4436
+ var instructions_default = "You are connected to a Figma design file via the MCP server. Convert design elements into production code, preserving design intent while fitting the user’s codebase conventions.\n\n- Start from `get_code` as the baseline (omit `nodeId` to use the current single selection), then refactor to match project conventions (components, styling system, file structure, naming). Treat `get_code` as authoritative.\n- If `get_code` returns a `depth-cap` warning, call `get_code` again once per listed `nodeId` to fetch each omitted subtree.\n- Layout confidence:\n - If `data-hint-auto-layout=\"inferred\"` appears, layout may be less certain. You can call `get_structure` or `get_screenshot` with a specific `nodeId` (both accept `nodeId`, otherwise they use the current single selection) to improve layout understanding, but keep `get_code` as the baseline.\n - Otherwise, assume layout is explicit and implement directly from `get_code`.\n- If `data-hint-design-component` plus repetition supports it, extract reusable components/variants aligned with project patterns. Do not preserve hint strings in output.\n- Tokens: `get_code.tokens` is a single map keyed by canonical token name. Multi‑mode values use `${collectionName}:${modeName}` keys. Nodes with explicit overrides include `data-hint-variable-mode=\"Collection=Mode;Collection=Mode\"`; use this to pick the correct mode for a given node. Collection names are assumed unique.\n- Assets: follow the project’s existing conventions/practices (icon system, asset pipeline, import/path rules, optimization) to decide how to represent and reference assets. If `get_code` uses resource URIs, you may replace them with the project’s canonical references when appropriate without changing rendering.\n- Do not output any `data-*` attributes returned by `get_code` (they are hints only).\n- For SVG/vector assets: use the exact provided asset, preserving `path` data, `viewBox`, and full SVG structure. Never redraw or approximate vectors.\n";
3680
4437
 
3681
4438
  //#endregion
3682
4439
  //#region src/request.ts
@@ -3752,7 +4509,7 @@ function hubTool(definition) {
3752
4509
  const TOOL_DEFS = [
3753
4510
  extTool({
3754
4511
  name: "get_code",
3755
- description: "Get a high-fidelity code snapshot for a nodeId/current selection, including assets/usedTokens and codegen preset/config. Start here, then refactor into your component/styling/file/naming conventions; strip any data-* hints. If no data-hint-auto-layout is present, layout is explicit; if any hint is none/inferred, pair with get_structure/get_screenshot to confirm hierarchy/overlap. Use data-hint-component plus repetition to decide on reusable components. Replace resource URIs with your canonical asset system as needed.",
4512
+ description: "Get a high-fidelity code snapshot for a nodeId/current selection (omit nodeId to use the current single selection), including assets/tokens and codegen plugin/config. Start here, then refactor into your component/styling/file/naming conventions; strip any data-* hints. Treat get_code as authoritative. If warnings include depth-cap, call get_code again once per listed nodeId to fetch each omitted subtree. If any data-hint-auto-layout=\"inferred\" appears, you may call get_structure or get_screenshot with a nodeId (both accept nodeId; omit it to use the current single selection) to confirm hierarchy/overlap, but keep get_code as the baseline. Use data-hint-design-component plus repetition to decide on reusable components. Replace resource URIs with your canonical asset system as needed. Tokens: get_code.tokens is a single map keyed by canonical token name; multi-mode values use `${collectionName}:${modeName}` keys. Nodes with explicit mode overrides include data-hint-variable-mode=\"Collection=Mode;Collection=Mode\". Collection names are assumed unique.",
3756
4513
  parameters: GetCodeParametersSchema,
3757
4514
  target: "extension",
3758
4515
  format: createCodeToolResponse
@@ -3802,12 +4559,15 @@ function createCodeToolResponse(payload) {
3802
4559
  const summary = [];
3803
4560
  const codeSize = Buffer.byteLength(payload.code, "utf8");
3804
4561
  summary.push(`Generated \`${payload.lang}\` snippet (${formatBytes$1(codeSize)}).`);
3805
- if (payload.message) summary.push(payload.message);
3806
- summary.push(payload.assets.length ? `Assets attached: ${payload.assets.length}. Fetch bytes via resources/read using resourceUri.` : "No binary assets were attached to this response.");
3807
- const tokenCount = payload.usedTokens ? Object.keys(payload.usedTokens ?? {}).length : 0;
4562
+ if (payload.warnings?.length) {
4563
+ const warningText = payload.warnings.map((warning) => warning.message).join(" ");
4564
+ summary.push(warningText);
4565
+ }
4566
+ summary.push(payload.assets?.length ? `Assets attached: ${payload.assets.length}. Fetch bytes via resources/read using resourceUri.` : "No binary assets were attached to this response.");
4567
+ const tokenCount = payload.tokens ? Object.keys(payload.tokens).length : 0;
3808
4568
  if (tokenCount) summary.push(`Token references included: ${tokenCount}.`);
3809
4569
  summary.push("Read structuredContent for the full code string and asset metadata.");
3810
- const assetLinks = payload.assets.length > 0 ? payload.assets.map((asset) => createAssetResourceLinkBlock$1(asset)) : [];
4570
+ const assetLinks = payload.assets?.length ? payload.assets.map((asset) => createAssetResourceLinkBlock$1(asset)) : [];
3811
4571
  return {
3812
4572
  content: [{
3813
4573
  type: "text",
@@ -3853,7 +4613,7 @@ function isScreenshotResult(payload) {
3853
4613
  function isCodeResult(payload) {
3854
4614
  if (typeof payload !== "object" || !payload) return false;
3855
4615
  const candidate = payload;
3856
- return typeof candidate.code === "string" && typeof candidate.lang === "string" && Array.isArray(candidate.assets);
4616
+ return typeof candidate.code === "string" && typeof candidate.lang === "string" && (candidate.assets === void 0 || Array.isArray(candidate.assets));
3857
4617
  }
3858
4618
  function createAssetResourceLinkBlock$1(asset) {
3859
4619
  return {
@@ -3881,7 +4641,7 @@ function coercePayloadToToolResponse(payload) {
3881
4641
  //#endregion
3882
4642
  //#region src/hub.ts
3883
4643
  const SHUTDOWN_TIMEOUT = 2e3;
3884
- const { wsPortCandidates, toolTimeoutMs, maxPayloadBytes, autoActivateGraceMs } = getMcpServerConfig();
4644
+ const { wsPortCandidates, toolTimeoutMs, maxPayloadBytes, autoActivateGraceMs, assetTtlMs } = getMcpServerConfig();
3885
4645
  log.info({ version: PACKAGE_VERSION }, "TemPad MCP Hub starting...");
3886
4646
  const extensions = [];
3887
4647
  let consumerCount = 0;
@@ -3913,17 +4673,47 @@ const assetStore = createAssetStore();
3913
4673
  const assetHttpServer = createAssetHttpServer(assetStore);
3914
4674
  await assetHttpServer.start();
3915
4675
  registerAssetResources();
4676
+ scheduleAssetCleanup();
3916
4677
  function registerAssetResources() {
3917
- const template = new ResourceTemplate(MCP_ASSET_URI_TEMPLATE, { list: async () => ({ resources: assetStore.list().filter((record) => existsSync(record.filePath)).map((record) => ({
3918
- uri: buildAssetResourceUri(record.hash),
3919
- name: formatAssetResourceName(record.hash),
3920
- description: `${record.mimeType} (${formatBytes(record.size)})`,
3921
- mimeType: record.mimeType
3922
- })) }) });
3923
- mcp.registerResource(MCP_ASSET_RESOURCE_NAME, template, { description: "Binary assets captured by the TemPad Dev hub." }, async (_uri, variables) => {
4678
+ const template = new ResourceTemplate(MCP_ASSET_URI_TEMPLATE, { list: async () => ({ resources: [] }) });
4679
+ mcp.registerResource(MCP_ASSET_RESOURCE_NAME, template, { description: "Exported PNG/SVG assets which can serve as screenshots or be referenced in code output." }, async (_uri, variables) => {
3924
4680
  return readAssetResource(typeof variables.hash === "string" ? variables.hash : "");
3925
4681
  });
3926
4682
  }
4683
+ function scheduleAssetCleanup() {
4684
+ if (assetTtlMs <= 0) {
4685
+ log.info("Asset TTL cleanup disabled (TEMPAD_MCP_ASSET_TTL_MS=0).");
4686
+ return;
4687
+ }
4688
+ pruneExpiredAssets(assetTtlMs);
4689
+ const intervalMs = Math.min(assetTtlMs, 1440 * 60 * 1e3);
4690
+ unrefTimer(setInterval(() => {
4691
+ pruneExpiredAssets(assetTtlMs);
4692
+ }, intervalMs));
4693
+ log.info({
4694
+ ttlMs: assetTtlMs,
4695
+ intervalMs
4696
+ }, "Asset TTL cleanup enabled (list remains empty; assets are tool-linked).");
4697
+ }
4698
+ function pruneExpiredAssets(ttlMs) {
4699
+ const now = Date.now();
4700
+ let removed = 0;
4701
+ let checked = 0;
4702
+ for (const record of assetStore.list()) {
4703
+ checked += 1;
4704
+ const lastAccess = Number.isFinite(record.lastAccess) ? record.lastAccess : record.uploadedAt;
4705
+ if (!lastAccess) continue;
4706
+ if (now - lastAccess > ttlMs) {
4707
+ assetStore.remove(record.hash);
4708
+ removed += 1;
4709
+ }
4710
+ }
4711
+ log.info({
4712
+ checked,
4713
+ removed,
4714
+ ttlMs
4715
+ }, "Asset TTL sweep completed.");
4716
+ }
3927
4717
  async function readAssetResource(hash) {
3928
4718
  if (!hash) throw new Error("Missing asset hash in resource URI.");
3929
4719
  const record = assetStore.get(hash);
@@ -3959,9 +4749,10 @@ function formatAssetResourceName(hash) {
3959
4749
  return `asset:${hash.slice(0, 8)}`;
3960
4750
  }
3961
4751
  function buildAssetDescriptor(record) {
4752
+ const filename = buildAssetFilename(record.hash, record.mimeType);
3962
4753
  return {
3963
4754
  hash: record.hash,
3964
- url: `${assetHttpServer.getBaseUrl()}/assets/${record.hash}`,
4755
+ url: `${assetHttpServer.getBaseUrl()}/assets/${filename}`,
3965
4756
  mimeType: record.mimeType,
3966
4757
  size: record.size,
3967
4758
  resourceUri: buildAssetResourceUri(record.hash),