holycodex 0.7.1-dev.29611508860.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +275 -4347
  2. package/package.json +2 -3
package/dist/cli.js CHANGED
@@ -4,3928 +4,10 @@ import { homedir, tmpdir } from "node:os";
4
4
  import { dirname, join } from "node:path";
5
5
  import { execFileSync, spawn, spawnSync } from "node:child_process";
6
6
  import { existsSync } from "node:fs";
7
- import { Buffer } from "node:buffer";
8
- import { pluginRoot } from "@holycodex/plugin";
9
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
10
- var _a$1;
11
- function $constructor(name, initializer, params) {
12
- function init(inst, def) {
13
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
14
- value: {
15
- def,
16
- constr: _,
17
- traits: /* @__PURE__ */ new Set()
18
- },
19
- enumerable: false
20
- });
21
- if (inst._zod.traits.has(name)) return;
22
- inst._zod.traits.add(name);
23
- initializer(inst, def);
24
- const proto = _.prototype;
25
- const keys = Object.keys(proto);
26
- for (let i = 0; i < keys.length; i++) {
27
- const k = keys[i];
28
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
29
- }
30
- }
31
- const Parent = params?.Parent ?? Object;
32
- class Definition extends Parent {}
33
- Object.defineProperty(Definition, "name", { value: name });
34
- function _(def) {
35
- var _a;
36
- const inst = params?.Parent ? new Definition() : this;
37
- init(inst, def);
38
- (_a = inst._zod).deferred ?? (_a.deferred = []);
39
- for (const fn of inst._zod.deferred) fn();
40
- return inst;
41
- }
42
- Object.defineProperty(_, "init", { value: init });
43
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
44
- if (params?.Parent && inst instanceof params.Parent) return true;
45
- return inst?._zod?.traits?.has(name);
46
- } });
47
- Object.defineProperty(_, "name", { value: name });
48
- return _;
49
- }
50
- var $ZodAsyncError = class extends Error {
51
- constructor() {
52
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
53
- }
54
- };
55
- var $ZodEncodeError = class extends Error {
56
- constructor(name) {
57
- super(`Encountered unidirectional transform during encode: ${name}`);
58
- this.name = "ZodEncodeError";
59
- }
60
- };
61
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
62
- var globalConfig = globalThis.__zod_globalConfig;
63
- function config(newConfig) {
64
- if (newConfig) Object.assign(globalConfig, newConfig);
65
- return globalConfig;
66
- }
67
- //#endregion
68
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/util.js
69
- function getEnumValues(entries) {
70
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
71
- return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
72
- }
73
- function jsonStringifyReplacer(_, value) {
74
- if (typeof value === "bigint") return value.toString();
75
- return value;
76
- }
77
- function cached(getter) {
78
- return { get value() {
79
- {
80
- const value = getter();
81
- Object.defineProperty(this, "value", { value });
82
- return value;
83
- }
84
- throw new Error("cached value already set");
85
- } };
86
- }
87
- function nullish(input) {
88
- return input === null || input === void 0;
89
- }
90
- function cleanRegex(source) {
91
- const start = source.startsWith("^") ? 1 : 0;
92
- const end = source.endsWith("$") ? source.length - 1 : source.length;
93
- return source.slice(start, end);
94
- }
95
- var EVALUATING = /* @__PURE__*/ Symbol("evaluating");
96
- function defineLazy(object, key, getter) {
97
- let value = void 0;
98
- Object.defineProperty(object, key, {
99
- get() {
100
- if (value === EVALUATING) return;
101
- if (value === void 0) {
102
- value = EVALUATING;
103
- value = getter();
104
- }
105
- return value;
106
- },
107
- set(v) {
108
- Object.defineProperty(object, key, { value: v });
109
- },
110
- configurable: true
111
- });
112
- }
113
- function assignProp(target, prop, value) {
114
- Object.defineProperty(target, prop, {
115
- value,
116
- writable: true,
117
- enumerable: true,
118
- configurable: true
119
- });
120
- }
121
- function mergeDefs(...defs) {
122
- const mergedDescriptors = {};
123
- for (const def of defs) {
124
- const descriptors = Object.getOwnPropertyDescriptors(def);
125
- Object.assign(mergedDescriptors, descriptors);
126
- }
127
- return Object.defineProperties({}, mergedDescriptors);
128
- }
129
- function esc(str) {
130
- return JSON.stringify(str);
131
- }
132
- function slugify(input) {
133
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
134
- }
135
- var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
136
- function isObject(data) {
137
- return typeof data === "object" && data !== null && !Array.isArray(data);
138
- }
139
- var allowsEval = /* @__PURE__*/ cached(() => {
140
- if (globalConfig.jitless) return false;
141
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
142
- try {
143
- new Function("");
144
- return true;
145
- } catch (_) {
146
- return false;
147
- }
148
- });
149
- function isPlainObject(o) {
150
- if (isObject(o) === false) return false;
151
- const ctor = o.constructor;
152
- if (ctor === void 0) return true;
153
- if (typeof ctor !== "function") return true;
154
- const prot = ctor.prototype;
155
- if (isObject(prot) === false) return false;
156
- if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
157
- return true;
158
- }
159
- function shallowClone(o) {
160
- if (isPlainObject(o)) return { ...o };
161
- if (Array.isArray(o)) return [...o];
162
- if (o instanceof Map) return new Map(o);
163
- if (o instanceof Set) return new Set(o);
164
- return o;
165
- }
166
- var propertyKeyTypes = /* @__PURE__*/ new Set([
167
- "string",
168
- "number",
169
- "symbol"
170
- ]);
171
- function escapeRegex(str) {
172
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
173
- }
174
- function clone(inst, def, params) {
175
- const cl = new inst._zod.constr(def ?? inst._zod.def);
176
- if (!def || params?.parent) cl._zod.parent = inst;
177
- return cl;
178
- }
179
- function normalizeParams(_params) {
180
- const params = _params;
181
- if (!params) return {};
182
- if (typeof params === "string") return { error: () => params };
183
- if (params?.message !== void 0) {
184
- if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
185
- params.error = params.message;
186
- }
187
- delete params.message;
188
- if (typeof params.error === "string") return {
189
- ...params,
190
- error: () => params.error
191
- };
192
- return params;
193
- }
194
- function optionalKeys(shape) {
195
- return Object.keys(shape).filter((k) => {
196
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
197
- });
198
- }
199
- Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, -Number.MAX_VALUE, Number.MAX_VALUE;
200
- function pick(schema, mask) {
201
- const currDef = schema._zod.def;
202
- const checks = currDef.checks;
203
- if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
204
- return clone(schema, mergeDefs(schema._zod.def, {
205
- get shape() {
206
- const newShape = {};
207
- for (const key in mask) {
208
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
209
- if (!mask[key]) continue;
210
- newShape[key] = currDef.shape[key];
211
- }
212
- assignProp(this, "shape", newShape);
213
- return newShape;
214
- },
215
- checks: []
216
- }));
217
- }
218
- function omit(schema, mask) {
219
- const currDef = schema._zod.def;
220
- const checks = currDef.checks;
221
- if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
222
- return clone(schema, mergeDefs(schema._zod.def, {
223
- get shape() {
224
- const newShape = { ...schema._zod.def.shape };
225
- for (const key in mask) {
226
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
227
- if (!mask[key]) continue;
228
- delete newShape[key];
229
- }
230
- assignProp(this, "shape", newShape);
231
- return newShape;
232
- },
233
- checks: []
234
- }));
235
- }
236
- function extend(schema, shape) {
237
- if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
238
- const checks = schema._zod.def.checks;
239
- if (checks && checks.length > 0) {
240
- const existingShape = schema._zod.def.shape;
241
- 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.");
242
- }
243
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
244
- const _shape = {
245
- ...schema._zod.def.shape,
246
- ...shape
247
- };
248
- assignProp(this, "shape", _shape);
249
- return _shape;
250
- } }));
251
- }
252
- function safeExtend(schema, shape) {
253
- if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
254
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
255
- const _shape = {
256
- ...schema._zod.def.shape,
257
- ...shape
258
- };
259
- assignProp(this, "shape", _shape);
260
- return _shape;
261
- } }));
262
- }
263
- function merge(a, b) {
264
- if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
265
- return clone(a, mergeDefs(a._zod.def, {
266
- get shape() {
267
- const _shape = {
268
- ...a._zod.def.shape,
269
- ...b._zod.def.shape
270
- };
271
- assignProp(this, "shape", _shape);
272
- return _shape;
273
- },
274
- get catchall() {
275
- return b._zod.def.catchall;
276
- },
277
- checks: b._zod.def.checks ?? []
278
- }));
279
- }
280
- function partial(Class, schema, mask) {
281
- const checks = schema._zod.def.checks;
282
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
283
- return clone(schema, mergeDefs(schema._zod.def, {
284
- get shape() {
285
- const oldShape = schema._zod.def.shape;
286
- const shape = { ...oldShape };
287
- if (mask) for (const key in mask) {
288
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
289
- if (!mask[key]) continue;
290
- shape[key] = Class ? new Class({
291
- type: "optional",
292
- innerType: oldShape[key]
293
- }) : oldShape[key];
294
- }
295
- else for (const key in oldShape) shape[key] = Class ? new Class({
296
- type: "optional",
297
- innerType: oldShape[key]
298
- }) : oldShape[key];
299
- assignProp(this, "shape", shape);
300
- return shape;
301
- },
302
- checks: []
303
- }));
304
- }
305
- function required(Class, schema, mask) {
306
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
307
- const oldShape = schema._zod.def.shape;
308
- const shape = { ...oldShape };
309
- if (mask) for (const key in mask) {
310
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
311
- if (!mask[key]) continue;
312
- shape[key] = new Class({
313
- type: "nonoptional",
314
- innerType: oldShape[key]
315
- });
316
- }
317
- else for (const key in oldShape) shape[key] = new Class({
318
- type: "nonoptional",
319
- innerType: oldShape[key]
320
- });
321
- assignProp(this, "shape", shape);
322
- return shape;
323
- } }));
324
- }
325
- function aborted(x, startIndex = 0) {
326
- if (x.aborted === true) return true;
327
- for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
328
- return false;
329
- }
330
- function explicitlyAborted(x, startIndex = 0) {
331
- if (x.aborted === true) return true;
332
- for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
333
- return false;
334
- }
335
- function prefixIssues(path, issues) {
336
- return issues.map((iss) => {
337
- var _a;
338
- (_a = iss).path ?? (_a.path = []);
339
- iss.path.unshift(path);
340
- return iss;
341
- });
342
- }
343
- function unwrapMessage(message) {
344
- return typeof message === "string" ? message : message?.message;
345
- }
346
- function finalizeIssue(iss, ctx, config) {
347
- const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
348
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
349
- rest.path ?? (rest.path = []);
350
- rest.message = message;
351
- if (ctx?.reportInput) rest.input = _input;
352
- return rest;
353
- }
354
- function getLengthableOrigin(input) {
355
- if (Array.isArray(input)) return "array";
356
- if (typeof input === "string") return "string";
357
- return "unknown";
358
- }
359
- function issue(...args) {
360
- const [iss, input, inst] = args;
361
- if (typeof iss === "string") return {
362
- message: iss,
363
- code: "custom",
364
- input,
365
- inst
366
- };
367
- return { ...iss };
368
- }
369
- //#endregion
370
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/errors.js
371
- var initializer$1 = (inst, def) => {
372
- inst.name = "$ZodError";
373
- Object.defineProperty(inst, "_zod", {
374
- value: inst._zod,
375
- enumerable: false
376
- });
377
- Object.defineProperty(inst, "issues", {
378
- value: def,
379
- enumerable: false
380
- });
381
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
382
- Object.defineProperty(inst, "toString", {
383
- value: () => inst.message,
384
- enumerable: false
385
- });
386
- };
387
- var $ZodError = $constructor("$ZodError", initializer$1);
388
- var $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
389
- function flattenError(error, mapper = (issue) => issue.message) {
390
- const fieldErrors = {};
391
- const formErrors = [];
392
- for (const sub of error.issues) if (sub.path.length > 0) {
393
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
394
- fieldErrors[sub.path[0]].push(mapper(sub));
395
- } else formErrors.push(mapper(sub));
396
- return {
397
- formErrors,
398
- fieldErrors
399
- };
400
- }
401
- function formatError(error, mapper = (issue) => issue.message) {
402
- const fieldErrors = { _errors: [] };
403
- const processError = (error, path = []) => {
404
- for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
405
- else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
406
- else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
407
- else {
408
- const fullpath = [...path, ...issue.path];
409
- if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
410
- else {
411
- let curr = fieldErrors;
412
- let i = 0;
413
- while (i < fullpath.length) {
414
- const el = fullpath[i];
415
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
416
- else {
417
- curr[el] = curr[el] || { _errors: [] };
418
- curr[el]._errors.push(mapper(issue));
419
- }
420
- curr = curr[el];
421
- i++;
422
- }
423
- }
424
- }
425
- };
426
- processError(error);
427
- return fieldErrors;
428
- }
429
- //#endregion
430
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/parse.js
431
- var _parse = (_Err) => (schema, value, _ctx, _params) => {
432
- const ctx = _ctx ? {
433
- ..._ctx,
434
- async: false
435
- } : { async: false };
436
- const result = schema._zod.run({
437
- value,
438
- issues: []
439
- }, ctx);
440
- if (result instanceof Promise) throw new $ZodAsyncError();
441
- if (result.issues.length) {
442
- const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
443
- captureStackTrace(e, _params?.callee);
444
- throw e;
445
- }
446
- return result.value;
447
- };
448
- var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
449
- const ctx = _ctx ? {
450
- ..._ctx,
451
- async: true
452
- } : { async: true };
453
- let result = schema._zod.run({
454
- value,
455
- issues: []
456
- }, ctx);
457
- if (result instanceof Promise) result = await result;
458
- if (result.issues.length) {
459
- const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
460
- captureStackTrace(e, params?.callee);
461
- throw e;
462
- }
463
- return result.value;
464
- };
465
- var _safeParse = (_Err) => (schema, value, _ctx) => {
466
- const ctx = _ctx ? {
467
- ..._ctx,
468
- async: false
469
- } : { async: false };
470
- const result = schema._zod.run({
471
- value,
472
- issues: []
473
- }, ctx);
474
- if (result instanceof Promise) throw new $ZodAsyncError();
475
- return result.issues.length ? {
476
- success: false,
477
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
478
- } : {
479
- success: true,
480
- data: result.value
481
- };
482
- };
483
- var safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
484
- var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
485
- const ctx = _ctx ? {
486
- ..._ctx,
487
- async: true
488
- } : { async: true };
489
- let result = schema._zod.run({
490
- value,
491
- issues: []
492
- }, ctx);
493
- if (result instanceof Promise) result = await result;
494
- return result.issues.length ? {
495
- success: false,
496
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
497
- } : {
498
- success: true,
499
- data: result.value
500
- };
501
- };
502
- var safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
503
- var _encode = (_Err) => (schema, value, _ctx) => {
504
- const ctx = _ctx ? {
505
- ..._ctx,
506
- direction: "backward"
507
- } : { direction: "backward" };
508
- return _parse(_Err)(schema, value, ctx);
509
- };
510
- var _decode = (_Err) => (schema, value, _ctx) => {
511
- return _parse(_Err)(schema, value, _ctx);
512
- };
513
- var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
514
- const ctx = _ctx ? {
515
- ..._ctx,
516
- direction: "backward"
517
- } : { direction: "backward" };
518
- return _parseAsync(_Err)(schema, value, ctx);
519
- };
520
- var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
521
- return _parseAsync(_Err)(schema, value, _ctx);
522
- };
523
- var _safeEncode = (_Err) => (schema, value, _ctx) => {
524
- const ctx = _ctx ? {
525
- ..._ctx,
526
- direction: "backward"
527
- } : { direction: "backward" };
528
- return _safeParse(_Err)(schema, value, ctx);
529
- };
530
- var _safeDecode = (_Err) => (schema, value, _ctx) => {
531
- return _safeParse(_Err)(schema, value, _ctx);
532
- };
533
- var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
534
- const ctx = _ctx ? {
535
- ..._ctx,
536
- direction: "backward"
537
- } : { direction: "backward" };
538
- return _safeParseAsync(_Err)(schema, value, ctx);
539
- };
540
- var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
541
- return _safeParseAsync(_Err)(schema, value, _ctx);
542
- };
543
- //#endregion
544
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/regexes.js
545
- /**
546
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
547
- * (timestamps embedded in the id). Use {@link cuid2} instead.
548
- * See https://github.com/paralleldrive/cuid.
549
- */
550
- var cuid = /^[cC][0-9a-z]{6,}$/;
551
- var cuid2 = /^[0-9a-z]+$/;
552
- var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
553
- var xid = /^[0-9a-vA-V]{20}$/;
554
- var ksuid = /^[A-Za-z0-9]{27}$/;
555
- var nanoid = /^[a-zA-Z0-9_-]{21}$/;
556
- /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
557
- var duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
558
- /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
559
- var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
560
- /** Returns a regex for validating an RFC 9562/4122 UUID.
561
- *
562
- * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
563
- var uuid = (version) => {
564
- if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
565
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
566
- };
567
- /** Practical email validation */
568
- var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
569
- var _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
570
- function emoji() {
571
- return new RegExp(_emoji$1, "u");
572
- }
573
- var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
574
- var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
575
- var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
576
- var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
577
- var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
578
- var base64url = /^[A-Za-z0-9_-]*$/;
579
- var httpProtocol = /^https?$/;
580
- var e164 = /^\+[1-9]\d{6,14}$/;
581
- var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
582
- var date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
583
- function timeSource(args) {
584
- const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
585
- return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
586
- }
587
- function time$1(args) {
588
- return new RegExp(`^${timeSource(args)}$`);
589
- }
590
- function datetime$1(args) {
591
- const time = timeSource({ precision: args.precision });
592
- const opts = ["Z"];
593
- if (args.local) opts.push("");
594
- if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
595
- const timeRegex = `${time}(?:${opts.join("|")})`;
596
- return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
597
- }
598
- var string$1 = (params) => {
599
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
600
- return new RegExp(`^${regex}$`);
601
- };
602
- var number = /^-?\d+(?:\.\d+)?$/;
603
- var lowercase = /^[^A-Z]*$/;
604
- var uppercase = /^[^a-z]*$/;
605
- //#endregion
606
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/checks.js
607
- var $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
608
- var _a;
609
- inst._zod ?? (inst._zod = {});
610
- inst._zod.def = def;
611
- (_a = inst._zod).onattach ?? (_a.onattach = []);
612
- });
613
- var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
614
- var _a;
615
- $ZodCheck.init(inst, def);
616
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
617
- const val = payload.value;
618
- return !nullish(val) && val.length !== void 0;
619
- });
620
- inst._zod.onattach.push((inst) => {
621
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
622
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
623
- });
624
- inst._zod.check = (payload) => {
625
- const input = payload.value;
626
- if (input.length <= def.maximum) return;
627
- const origin = getLengthableOrigin(input);
628
- payload.issues.push({
629
- origin,
630
- code: "too_big",
631
- maximum: def.maximum,
632
- inclusive: true,
633
- input,
634
- inst,
635
- continue: !def.abort
636
- });
637
- };
638
- });
639
- var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
640
- var _a;
641
- $ZodCheck.init(inst, def);
642
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
643
- const val = payload.value;
644
- return !nullish(val) && val.length !== void 0;
645
- });
646
- inst._zod.onattach.push((inst) => {
647
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
648
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
649
- });
650
- inst._zod.check = (payload) => {
651
- const input = payload.value;
652
- if (input.length >= def.minimum) return;
653
- const origin = getLengthableOrigin(input);
654
- payload.issues.push({
655
- origin,
656
- code: "too_small",
657
- minimum: def.minimum,
658
- inclusive: true,
659
- input,
660
- inst,
661
- continue: !def.abort
662
- });
663
- };
664
- });
665
- var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
666
- var _a;
667
- $ZodCheck.init(inst, def);
668
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
669
- const val = payload.value;
670
- return !nullish(val) && val.length !== void 0;
671
- });
672
- inst._zod.onattach.push((inst) => {
673
- const bag = inst._zod.bag;
674
- bag.minimum = def.length;
675
- bag.maximum = def.length;
676
- bag.length = def.length;
677
- });
678
- inst._zod.check = (payload) => {
679
- const input = payload.value;
680
- const length = input.length;
681
- if (length === def.length) return;
682
- const origin = getLengthableOrigin(input);
683
- const tooBig = length > def.length;
684
- payload.issues.push({
685
- origin,
686
- ...tooBig ? {
687
- code: "too_big",
688
- maximum: def.length
689
- } : {
690
- code: "too_small",
691
- minimum: def.length
692
- },
693
- inclusive: true,
694
- exact: true,
695
- input: payload.value,
696
- inst,
697
- continue: !def.abort
698
- });
699
- };
700
- });
701
- var $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
702
- var _a, _b;
703
- $ZodCheck.init(inst, def);
704
- inst._zod.onattach.push((inst) => {
705
- const bag = inst._zod.bag;
706
- bag.format = def.format;
707
- if (def.pattern) {
708
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
709
- bag.patterns.add(def.pattern);
710
- }
711
- });
712
- if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
713
- def.pattern.lastIndex = 0;
714
- if (def.pattern.test(payload.value)) return;
715
- payload.issues.push({
716
- origin: "string",
717
- code: "invalid_format",
718
- format: def.format,
719
- input: payload.value,
720
- ...def.pattern ? { pattern: def.pattern.toString() } : {},
721
- inst,
722
- continue: !def.abort
723
- });
724
- });
725
- else (_b = inst._zod).check ?? (_b.check = () => {});
726
- });
727
- var $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
728
- $ZodCheckStringFormat.init(inst, def);
729
- inst._zod.check = (payload) => {
730
- def.pattern.lastIndex = 0;
731
- if (def.pattern.test(payload.value)) return;
732
- payload.issues.push({
733
- origin: "string",
734
- code: "invalid_format",
735
- format: "regex",
736
- input: payload.value,
737
- pattern: def.pattern.toString(),
738
- inst,
739
- continue: !def.abort
740
- });
741
- };
742
- });
743
- var $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
744
- def.pattern ?? (def.pattern = lowercase);
745
- $ZodCheckStringFormat.init(inst, def);
746
- });
747
- var $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
748
- def.pattern ?? (def.pattern = uppercase);
749
- $ZodCheckStringFormat.init(inst, def);
750
- });
751
- var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
752
- $ZodCheck.init(inst, def);
753
- const escapedRegex = escapeRegex(def.includes);
754
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
755
- def.pattern = pattern;
756
- inst._zod.onattach.push((inst) => {
757
- const bag = inst._zod.bag;
758
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
759
- bag.patterns.add(pattern);
760
- });
761
- inst._zod.check = (payload) => {
762
- if (payload.value.includes(def.includes, def.position)) return;
763
- payload.issues.push({
764
- origin: "string",
765
- code: "invalid_format",
766
- format: "includes",
767
- includes: def.includes,
768
- input: payload.value,
769
- inst,
770
- continue: !def.abort
771
- });
772
- };
773
- });
774
- var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
775
- $ZodCheck.init(inst, def);
776
- const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
777
- def.pattern ?? (def.pattern = pattern);
778
- inst._zod.onattach.push((inst) => {
779
- const bag = inst._zod.bag;
780
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
781
- bag.patterns.add(pattern);
782
- });
783
- inst._zod.check = (payload) => {
784
- if (payload.value.startsWith(def.prefix)) return;
785
- payload.issues.push({
786
- origin: "string",
787
- code: "invalid_format",
788
- format: "starts_with",
789
- prefix: def.prefix,
790
- input: payload.value,
791
- inst,
792
- continue: !def.abort
793
- });
794
- };
795
- });
796
- var $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
797
- $ZodCheck.init(inst, def);
798
- const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
799
- def.pattern ?? (def.pattern = pattern);
800
- inst._zod.onattach.push((inst) => {
801
- const bag = inst._zod.bag;
802
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
803
- bag.patterns.add(pattern);
804
- });
805
- inst._zod.check = (payload) => {
806
- if (payload.value.endsWith(def.suffix)) return;
807
- payload.issues.push({
808
- origin: "string",
809
- code: "invalid_format",
810
- format: "ends_with",
811
- suffix: def.suffix,
812
- input: payload.value,
813
- inst,
814
- continue: !def.abort
815
- });
816
- };
817
- });
818
- var $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
819
- $ZodCheck.init(inst, def);
820
- inst._zod.check = (payload) => {
821
- payload.value = def.tx(payload.value);
822
- };
823
- });
824
- //#endregion
825
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/doc.js
826
- var Doc = class {
827
- constructor(args = []) {
828
- this.content = [];
829
- this.indent = 0;
830
- if (this) this.args = args;
831
- }
832
- indented(fn) {
833
- this.indent += 1;
834
- fn(this);
835
- this.indent -= 1;
836
- }
837
- write(arg) {
838
- if (typeof arg === "function") {
839
- arg(this, { execution: "sync" });
840
- arg(this, { execution: "async" });
841
- return;
842
- }
843
- const lines = arg.split("\n").filter((x) => x);
844
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
845
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
846
- for (const line of dedented) this.content.push(line);
847
- }
848
- compile() {
849
- const F = Function;
850
- const args = this?.args;
851
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
852
- return new F(...args, lines.join("\n"));
853
- }
854
- };
855
- //#endregion
856
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/versions.js
857
- var version = {
858
- major: 4,
859
- minor: 4,
860
- patch: 3
861
- };
862
- //#endregion
863
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/schemas.js
864
- var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
865
- var _a;
866
- inst ?? (inst = {});
867
- inst._zod.def = def;
868
- inst._zod.bag = inst._zod.bag || {};
869
- inst._zod.version = version;
870
- const checks = [...inst._zod.def.checks ?? []];
871
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
872
- for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
873
- if (checks.length === 0) {
874
- (_a = inst._zod).deferred ?? (_a.deferred = []);
875
- inst._zod.deferred?.push(() => {
876
- inst._zod.run = inst._zod.parse;
877
- });
878
- } else {
879
- const runChecks = (payload, checks, ctx) => {
880
- let isAborted = aborted(payload);
881
- let asyncResult;
882
- for (const ch of checks) {
883
- if (ch._zod.def.when) {
884
- if (explicitlyAborted(payload)) continue;
885
- if (!ch._zod.def.when(payload)) continue;
886
- } else if (isAborted) continue;
887
- const currLen = payload.issues.length;
888
- const _ = ch._zod.check(payload);
889
- if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
890
- if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
891
- await _;
892
- if (payload.issues.length === currLen) return;
893
- if (!isAborted) isAborted = aborted(payload, currLen);
894
- });
895
- else {
896
- if (payload.issues.length === currLen) continue;
897
- if (!isAborted) isAborted = aborted(payload, currLen);
898
- }
899
- }
900
- if (asyncResult) return asyncResult.then(() => {
901
- return payload;
902
- });
903
- return payload;
904
- };
905
- const handleCanaryResult = (canary, payload, ctx) => {
906
- if (aborted(canary)) {
907
- canary.aborted = true;
908
- return canary;
909
- }
910
- const checkResult = runChecks(payload, checks, ctx);
911
- if (checkResult instanceof Promise) {
912
- if (ctx.async === false) throw new $ZodAsyncError();
913
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
914
- }
915
- return inst._zod.parse(checkResult, ctx);
916
- };
917
- inst._zod.run = (payload, ctx) => {
918
- if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
919
- if (ctx.direction === "backward") {
920
- const canary = inst._zod.parse({
921
- value: payload.value,
922
- issues: []
923
- }, {
924
- ...ctx,
925
- skipChecks: true
926
- });
927
- if (canary instanceof Promise) return canary.then((canary) => {
928
- return handleCanaryResult(canary, payload, ctx);
929
- });
930
- return handleCanaryResult(canary, payload, ctx);
931
- }
932
- const result = inst._zod.parse(payload, ctx);
933
- if (result instanceof Promise) {
934
- if (ctx.async === false) throw new $ZodAsyncError();
935
- return result.then((result) => runChecks(result, checks, ctx));
936
- }
937
- return runChecks(result, checks, ctx);
938
- };
939
- }
940
- defineLazy(inst, "~standard", () => ({
941
- validate: (value) => {
942
- try {
943
- const r = safeParse$1(inst, value);
944
- return r.success ? { value: r.data } : { issues: r.error?.issues };
945
- } catch (_) {
946
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
947
- }
948
- },
949
- vendor: "zod",
950
- version: 1
951
- }));
952
- });
953
- var $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
954
- $ZodType.init(inst, def);
955
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
956
- inst._zod.parse = (payload, _) => {
957
- if (def.coerce) try {
958
- payload.value = String(payload.value);
959
- } catch (_) {}
960
- if (typeof payload.value === "string") return payload;
961
- payload.issues.push({
962
- expected: "string",
963
- code: "invalid_type",
964
- input: payload.value,
965
- inst
966
- });
967
- return payload;
968
- };
969
- });
970
- var $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
971
- $ZodCheckStringFormat.init(inst, def);
972
- $ZodString.init(inst, def);
973
- });
974
- var $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
975
- def.pattern ?? (def.pattern = guid);
976
- $ZodStringFormat.init(inst, def);
977
- });
978
- var $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
979
- if (def.version) {
980
- const v = {
981
- v1: 1,
982
- v2: 2,
983
- v3: 3,
984
- v4: 4,
985
- v5: 5,
986
- v6: 6,
987
- v7: 7,
988
- v8: 8
989
- }[def.version];
990
- if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
991
- def.pattern ?? (def.pattern = uuid(v));
992
- } else def.pattern ?? (def.pattern = uuid());
993
- $ZodStringFormat.init(inst, def);
994
- });
995
- var $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
996
- def.pattern ?? (def.pattern = email);
997
- $ZodStringFormat.init(inst, def);
998
- });
999
- var $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1000
- $ZodStringFormat.init(inst, def);
1001
- inst._zod.check = (payload) => {
1002
- try {
1003
- const trimmed = payload.value.trim();
1004
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1005
- if (!/^https?:\/\//i.test(trimmed)) {
1006
- payload.issues.push({
1007
- code: "invalid_format",
1008
- format: "url",
1009
- note: "Invalid URL format",
1010
- input: payload.value,
1011
- inst,
1012
- continue: !def.abort
1013
- });
1014
- return;
1015
- }
1016
- }
1017
- const url = new URL(trimmed);
1018
- if (def.hostname) {
1019
- def.hostname.lastIndex = 0;
1020
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1021
- code: "invalid_format",
1022
- format: "url",
1023
- note: "Invalid hostname",
1024
- pattern: def.hostname.source,
1025
- input: payload.value,
1026
- inst,
1027
- continue: !def.abort
1028
- });
1029
- }
1030
- if (def.protocol) {
1031
- def.protocol.lastIndex = 0;
1032
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1033
- code: "invalid_format",
1034
- format: "url",
1035
- note: "Invalid protocol",
1036
- pattern: def.protocol.source,
1037
- input: payload.value,
1038
- inst,
1039
- continue: !def.abort
1040
- });
1041
- }
1042
- if (def.normalize) payload.value = url.href;
1043
- else payload.value = trimmed;
1044
- return;
1045
- } catch (_) {
1046
- payload.issues.push({
1047
- code: "invalid_format",
1048
- format: "url",
1049
- input: payload.value,
1050
- inst,
1051
- continue: !def.abort
1052
- });
1053
- }
1054
- };
1055
- });
1056
- var $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1057
- def.pattern ?? (def.pattern = emoji());
1058
- $ZodStringFormat.init(inst, def);
1059
- });
1060
- var $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1061
- def.pattern ?? (def.pattern = nanoid);
1062
- $ZodStringFormat.init(inst, def);
1063
- });
1064
- /**
1065
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
1066
- * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
1067
- * See https://github.com/paralleldrive/cuid.
1068
- */
1069
- var $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
1070
- def.pattern ?? (def.pattern = cuid);
1071
- $ZodStringFormat.init(inst, def);
1072
- });
1073
- var $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
1074
- def.pattern ?? (def.pattern = cuid2);
1075
- $ZodStringFormat.init(inst, def);
1076
- });
1077
- var $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
1078
- def.pattern ?? (def.pattern = ulid);
1079
- $ZodStringFormat.init(inst, def);
1080
- });
1081
- var $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
1082
- def.pattern ?? (def.pattern = xid);
1083
- $ZodStringFormat.init(inst, def);
1084
- });
1085
- var $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1086
- def.pattern ?? (def.pattern = ksuid);
1087
- $ZodStringFormat.init(inst, def);
1088
- });
1089
- var $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1090
- def.pattern ?? (def.pattern = datetime$1(def));
1091
- $ZodStringFormat.init(inst, def);
1092
- });
1093
- var $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1094
- def.pattern ?? (def.pattern = date$1);
1095
- $ZodStringFormat.init(inst, def);
1096
- });
1097
- var $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1098
- def.pattern ?? (def.pattern = time$1(def));
1099
- $ZodStringFormat.init(inst, def);
1100
- });
1101
- var $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1102
- def.pattern ?? (def.pattern = duration$1);
1103
- $ZodStringFormat.init(inst, def);
1104
- });
1105
- var $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1106
- def.pattern ?? (def.pattern = ipv4);
1107
- $ZodStringFormat.init(inst, def);
1108
- inst._zod.bag.format = `ipv4`;
1109
- });
1110
- var $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1111
- def.pattern ?? (def.pattern = ipv6);
1112
- $ZodStringFormat.init(inst, def);
1113
- inst._zod.bag.format = `ipv6`;
1114
- inst._zod.check = (payload) => {
1115
- try {
1116
- new URL(`http://[${payload.value}]`);
1117
- } catch {
1118
- payload.issues.push({
1119
- code: "invalid_format",
1120
- format: "ipv6",
1121
- input: payload.value,
1122
- inst,
1123
- continue: !def.abort
1124
- });
1125
- }
1126
- };
1127
- });
1128
- var $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1129
- def.pattern ?? (def.pattern = cidrv4);
1130
- $ZodStringFormat.init(inst, def);
1131
- });
1132
- var $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1133
- def.pattern ?? (def.pattern = cidrv6);
1134
- $ZodStringFormat.init(inst, def);
1135
- inst._zod.check = (payload) => {
1136
- const parts = payload.value.split("/");
1137
- try {
1138
- if (parts.length !== 2) throw new Error();
1139
- const [address, prefix] = parts;
1140
- if (!prefix) throw new Error();
1141
- const prefixNum = Number(prefix);
1142
- if (`${prefixNum}` !== prefix) throw new Error();
1143
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1144
- new URL(`http://[${address}]`);
1145
- } catch {
1146
- payload.issues.push({
1147
- code: "invalid_format",
1148
- format: "cidrv6",
1149
- input: payload.value,
1150
- inst,
1151
- continue: !def.abort
1152
- });
1153
- }
1154
- };
1155
- });
1156
- function isValidBase64(data) {
1157
- if (data === "") return true;
1158
- if (/\s/.test(data)) return false;
1159
- if (data.length % 4 !== 0) return false;
1160
- try {
1161
- atob(data);
1162
- return true;
1163
- } catch {
1164
- return false;
1165
- }
1166
- }
1167
- var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1168
- def.pattern ?? (def.pattern = base64);
1169
- $ZodStringFormat.init(inst, def);
1170
- inst._zod.bag.contentEncoding = "base64";
1171
- inst._zod.check = (payload) => {
1172
- if (isValidBase64(payload.value)) return;
1173
- payload.issues.push({
1174
- code: "invalid_format",
1175
- format: "base64",
1176
- input: payload.value,
1177
- inst,
1178
- continue: !def.abort
1179
- });
1180
- };
1181
- });
1182
- function isValidBase64URL(data) {
1183
- if (!base64url.test(data)) return false;
1184
- const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1185
- return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1186
- }
1187
- var $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1188
- def.pattern ?? (def.pattern = base64url);
1189
- $ZodStringFormat.init(inst, def);
1190
- inst._zod.bag.contentEncoding = "base64url";
1191
- inst._zod.check = (payload) => {
1192
- if (isValidBase64URL(payload.value)) return;
1193
- payload.issues.push({
1194
- code: "invalid_format",
1195
- format: "base64url",
1196
- input: payload.value,
1197
- inst,
1198
- continue: !def.abort
1199
- });
1200
- };
1201
- });
1202
- var $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
1203
- def.pattern ?? (def.pattern = e164);
1204
- $ZodStringFormat.init(inst, def);
1205
- });
1206
- function isValidJWT(token, algorithm = null) {
1207
- try {
1208
- const tokensParts = token.split(".");
1209
- if (tokensParts.length !== 3) return false;
1210
- const [header] = tokensParts;
1211
- if (!header) return false;
1212
- const parsedHeader = JSON.parse(atob(header));
1213
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1214
- if (!parsedHeader.alg) return false;
1215
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
1216
- return true;
1217
- } catch {
1218
- return false;
1219
- }
1220
- }
1221
- var $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
1222
- $ZodStringFormat.init(inst, def);
1223
- inst._zod.check = (payload) => {
1224
- if (isValidJWT(payload.value, def.alg)) return;
1225
- payload.issues.push({
1226
- code: "invalid_format",
1227
- format: "jwt",
1228
- input: payload.value,
1229
- inst,
1230
- continue: !def.abort
1231
- });
1232
- };
1233
- });
1234
- var $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
1235
- $ZodType.init(inst, def);
1236
- inst._zod.parse = (payload) => payload;
1237
- });
1238
- var $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
1239
- $ZodType.init(inst, def);
1240
- inst._zod.parse = (payload, _ctx) => {
1241
- payload.issues.push({
1242
- expected: "never",
1243
- code: "invalid_type",
1244
- input: payload.value,
1245
- inst
1246
- });
1247
- return payload;
1248
- };
1249
- });
1250
- function handleArrayResult(result, final, index) {
1251
- if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1252
- final.value[index] = result.value;
1253
- }
1254
- var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1255
- $ZodType.init(inst, def);
1256
- inst._zod.parse = (payload, ctx) => {
1257
- const input = payload.value;
1258
- if (!Array.isArray(input)) {
1259
- payload.issues.push({
1260
- expected: "array",
1261
- code: "invalid_type",
1262
- input,
1263
- inst
1264
- });
1265
- return payload;
1266
- }
1267
- payload.value = Array(input.length);
1268
- const proms = [];
1269
- for (let i = 0; i < input.length; i++) {
1270
- const item = input[i];
1271
- const result = def.element._zod.run({
1272
- value: item,
1273
- issues: []
1274
- }, ctx);
1275
- if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1276
- else handleArrayResult(result, payload, i);
1277
- }
1278
- if (proms.length) return Promise.all(proms).then(() => payload);
1279
- return payload;
1280
- };
1281
- });
1282
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1283
- const isPresent = key in input;
1284
- if (result.issues.length) {
1285
- if (isOptionalIn && isOptionalOut && !isPresent) return;
1286
- final.issues.push(...prefixIssues(key, result.issues));
1287
- }
1288
- if (!isPresent && !isOptionalIn) {
1289
- if (!result.issues.length) final.issues.push({
1290
- code: "invalid_type",
1291
- expected: "nonoptional",
1292
- input: void 0,
1293
- path: [key]
1294
- });
1295
- return;
1296
- }
1297
- if (result.value === void 0) {
1298
- if (isPresent) final.value[key] = void 0;
1299
- } else final.value[key] = result.value;
1300
- }
1301
- function normalizeDef(def) {
1302
- const keys = Object.keys(def.shape);
1303
- for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1304
- const okeys = optionalKeys(def.shape);
1305
- return {
1306
- ...def,
1307
- keys,
1308
- keySet: new Set(keys),
1309
- numKeys: keys.length,
1310
- optionalKeys: new Set(okeys)
1311
- };
1312
- }
1313
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1314
- const unrecognized = [];
1315
- const keySet = def.keySet;
1316
- const _catchall = def.catchall._zod;
1317
- const t = _catchall.def.type;
1318
- const isOptionalIn = _catchall.optin === "optional";
1319
- const isOptionalOut = _catchall.optout === "optional";
1320
- for (const key in input) {
1321
- if (key === "__proto__") continue;
1322
- if (keySet.has(key)) continue;
1323
- if (t === "never") {
1324
- unrecognized.push(key);
1325
- continue;
1326
- }
1327
- const r = _catchall.run({
1328
- value: input[key],
1329
- issues: []
1330
- }, ctx);
1331
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1332
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1333
- }
1334
- if (unrecognized.length) payload.issues.push({
1335
- code: "unrecognized_keys",
1336
- keys: unrecognized,
1337
- input,
1338
- inst
1339
- });
1340
- if (!proms.length) return payload;
1341
- return Promise.all(proms).then(() => {
1342
- return payload;
1343
- });
1344
- }
1345
- var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1346
- $ZodType.init(inst, def);
1347
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1348
- const sh = def.shape;
1349
- Object.defineProperty(def, "shape", { get: () => {
1350
- const newSh = { ...sh };
1351
- Object.defineProperty(def, "shape", { value: newSh });
1352
- return newSh;
1353
- } });
1354
- }
1355
- const _normalized = cached(() => normalizeDef(def));
1356
- defineLazy(inst._zod, "propValues", () => {
1357
- const shape = def.shape;
1358
- const propValues = {};
1359
- for (const key in shape) {
1360
- const field = shape[key]._zod;
1361
- if (field.values) {
1362
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1363
- for (const v of field.values) propValues[key].add(v);
1364
- }
1365
- }
1366
- return propValues;
1367
- });
1368
- const isObject$2 = isObject;
1369
- const catchall = def.catchall;
1370
- let value;
1371
- inst._zod.parse = (payload, ctx) => {
1372
- value ?? (value = _normalized.value);
1373
- const input = payload.value;
1374
- if (!isObject$2(input)) {
1375
- payload.issues.push({
1376
- expected: "object",
1377
- code: "invalid_type",
1378
- input,
1379
- inst
1380
- });
1381
- return payload;
1382
- }
1383
- payload.value = {};
1384
- const proms = [];
1385
- const shape = value.shape;
1386
- for (const key of value.keys) {
1387
- const el = shape[key];
1388
- const isOptionalIn = el._zod.optin === "optional";
1389
- const isOptionalOut = el._zod.optout === "optional";
1390
- const r = el._zod.run({
1391
- value: input[key],
1392
- issues: []
1393
- }, ctx);
1394
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1395
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1396
- }
1397
- if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1398
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1399
- };
1400
- });
1401
- var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1402
- $ZodObject.init(inst, def);
1403
- const superParse = inst._zod.parse;
1404
- const _normalized = cached(() => normalizeDef(def));
1405
- const generateFastpass = (shape) => {
1406
- const doc = new Doc([
1407
- "shape",
1408
- "payload",
1409
- "ctx"
1410
- ]);
1411
- const normalized = _normalized.value;
1412
- const parseStr = (key) => {
1413
- const k = esc(key);
1414
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1415
- };
1416
- doc.write(`const input = payload.value;`);
1417
- const ids = Object.create(null);
1418
- let counter = 0;
1419
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1420
- doc.write(`const newResult = {};`);
1421
- for (const key of normalized.keys) {
1422
- const id = ids[key];
1423
- const k = esc(key);
1424
- const schema = shape[key];
1425
- const isOptionalIn = schema?._zod?.optin === "optional";
1426
- const isOptionalOut = schema?._zod?.optout === "optional";
1427
- doc.write(`const ${id} = ${parseStr(key)};`);
1428
- if (isOptionalIn && isOptionalOut) doc.write(`
1429
- if (${id}.issues.length) {
1430
- if (${k} in input) {
1431
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1432
- ...iss,
1433
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1434
- })));
1435
- }
1436
- }
1437
-
1438
- if (${id}.value === undefined) {
1439
- if (${k} in input) {
1440
- newResult[${k}] = undefined;
1441
- }
1442
- } else {
1443
- newResult[${k}] = ${id}.value;
1444
- }
1445
-
1446
- `);
1447
- else if (!isOptionalIn) doc.write(`
1448
- const ${id}_present = ${k} in input;
1449
- if (${id}.issues.length) {
1450
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1451
- ...iss,
1452
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1453
- })));
1454
- }
1455
- if (!${id}_present && !${id}.issues.length) {
1456
- payload.issues.push({
1457
- code: "invalid_type",
1458
- expected: "nonoptional",
1459
- input: undefined,
1460
- path: [${k}]
1461
- });
1462
- }
1463
-
1464
- if (${id}_present) {
1465
- if (${id}.value === undefined) {
1466
- newResult[${k}] = undefined;
1467
- } else {
1468
- newResult[${k}] = ${id}.value;
1469
- }
1470
- }
1471
-
1472
- `);
1473
- else doc.write(`
1474
- if (${id}.issues.length) {
1475
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1476
- ...iss,
1477
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1478
- })));
1479
- }
1480
-
1481
- if (${id}.value === undefined) {
1482
- if (${k} in input) {
1483
- newResult[${k}] = undefined;
1484
- }
1485
- } else {
1486
- newResult[${k}] = ${id}.value;
1487
- }
1488
-
1489
- `);
1490
- }
1491
- doc.write(`payload.value = newResult;`);
1492
- doc.write(`return payload;`);
1493
- const fn = doc.compile();
1494
- return (payload, ctx) => fn(shape, payload, ctx);
1495
- };
1496
- let fastpass;
1497
- const isObject$1 = isObject;
1498
- const jit = !globalConfig.jitless;
1499
- const fastEnabled = jit && allowsEval.value;
1500
- const catchall = def.catchall;
1501
- let value;
1502
- inst._zod.parse = (payload, ctx) => {
1503
- value ?? (value = _normalized.value);
1504
- const input = payload.value;
1505
- if (!isObject$1(input)) {
1506
- payload.issues.push({
1507
- expected: "object",
1508
- code: "invalid_type",
1509
- input,
1510
- inst
1511
- });
1512
- return payload;
1513
- }
1514
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1515
- if (!fastpass) fastpass = generateFastpass(def.shape);
1516
- payload = fastpass(payload, ctx);
1517
- if (!catchall) return payload;
1518
- return handleCatchall([], input, payload, ctx, value, inst);
1519
- }
1520
- return superParse(payload, ctx);
1521
- };
1522
- });
1523
- function handleUnionResults(results, final, inst, ctx) {
1524
- for (const result of results) if (result.issues.length === 0) {
1525
- final.value = result.value;
1526
- return final;
1527
- }
1528
- const nonaborted = results.filter((r) => !aborted(r));
1529
- if (nonaborted.length === 1) {
1530
- final.value = nonaborted[0].value;
1531
- return nonaborted[0];
1532
- }
1533
- final.issues.push({
1534
- code: "invalid_union",
1535
- input: final.value,
1536
- inst,
1537
- errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1538
- });
1539
- return final;
1540
- }
1541
- var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1542
- $ZodType.init(inst, def);
1543
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1544
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1545
- defineLazy(inst._zod, "values", () => {
1546
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1547
- });
1548
- defineLazy(inst._zod, "pattern", () => {
1549
- if (def.options.every((o) => o._zod.pattern)) {
1550
- const patterns = def.options.map((o) => o._zod.pattern);
1551
- return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1552
- }
1553
- });
1554
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1555
- inst._zod.parse = (payload, ctx) => {
1556
- if (first) return first(payload, ctx);
1557
- let async = false;
1558
- const results = [];
1559
- for (const option of def.options) {
1560
- const result = option._zod.run({
1561
- value: payload.value,
1562
- issues: []
1563
- }, ctx);
1564
- if (result instanceof Promise) {
1565
- results.push(result);
1566
- async = true;
1567
- } else {
1568
- if (result.issues.length === 0) return result;
1569
- results.push(result);
1570
- }
1571
- }
1572
- if (!async) return handleUnionResults(results, payload, inst, ctx);
1573
- return Promise.all(results).then((results) => {
1574
- return handleUnionResults(results, payload, inst, ctx);
1575
- });
1576
- };
1577
- });
1578
- var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1579
- def.inclusive = false;
1580
- $ZodUnion.init(inst, def);
1581
- const _super = inst._zod.parse;
1582
- defineLazy(inst._zod, "propValues", () => {
1583
- const propValues = {};
1584
- for (const option of def.options) {
1585
- const pv = option._zod.propValues;
1586
- if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1587
- for (const [k, v] of Object.entries(pv)) {
1588
- if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
1589
- for (const val of v) propValues[k].add(val);
1590
- }
1591
- }
1592
- return propValues;
1593
- });
1594
- const disc = cached(() => {
1595
- const opts = def.options;
1596
- const map = /* @__PURE__ */ new Map();
1597
- for (const o of opts) {
1598
- const values = o._zod.propValues?.[def.discriminator];
1599
- if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1600
- for (const v of values) {
1601
- if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
1602
- map.set(v, o);
1603
- }
1604
- }
1605
- return map;
1606
- });
1607
- inst._zod.parse = (payload, ctx) => {
1608
- const input = payload.value;
1609
- if (!isObject(input)) {
1610
- payload.issues.push({
1611
- code: "invalid_type",
1612
- expected: "object",
1613
- input,
1614
- inst
1615
- });
1616
- return payload;
1617
- }
1618
- const opt = disc.value.get(input?.[def.discriminator]);
1619
- if (opt) return opt._zod.run(payload, ctx);
1620
- if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
1621
- payload.issues.push({
1622
- code: "invalid_union",
1623
- errors: [],
1624
- note: "No matching discriminator",
1625
- discriminator: def.discriminator,
1626
- options: Array.from(disc.value.keys()),
1627
- input,
1628
- path: [def.discriminator],
1629
- inst
1630
- });
1631
- return payload;
1632
- };
1633
- });
1634
- var $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
1635
- $ZodType.init(inst, def);
1636
- inst._zod.parse = (payload, ctx) => {
1637
- const input = payload.value;
1638
- const left = def.left._zod.run({
1639
- value: input,
1640
- issues: []
1641
- }, ctx);
1642
- const right = def.right._zod.run({
1643
- value: input,
1644
- issues: []
1645
- }, ctx);
1646
- if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
1647
- return handleIntersectionResults(payload, left, right);
1648
- });
1649
- return handleIntersectionResults(payload, left, right);
1650
- };
1651
- });
1652
- function mergeValues(a, b) {
1653
- if (a === b) return {
1654
- valid: true,
1655
- data: a
1656
- };
1657
- if (a instanceof Date && b instanceof Date && +a === +b) return {
1658
- valid: true,
1659
- data: a
1660
- };
1661
- if (isPlainObject(a) && isPlainObject(b)) {
1662
- const bKeys = Object.keys(b);
1663
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1664
- const newObj = {
1665
- ...a,
1666
- ...b
1667
- };
1668
- for (const key of sharedKeys) {
1669
- const sharedValue = mergeValues(a[key], b[key]);
1670
- if (!sharedValue.valid) return {
1671
- valid: false,
1672
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1673
- };
1674
- newObj[key] = sharedValue.data;
1675
- }
1676
- return {
1677
- valid: true,
1678
- data: newObj
1679
- };
1680
- }
1681
- if (Array.isArray(a) && Array.isArray(b)) {
1682
- if (a.length !== b.length) return {
1683
- valid: false,
1684
- mergeErrorPath: []
1685
- };
1686
- const newArray = [];
1687
- for (let index = 0; index < a.length; index++) {
1688
- const itemA = a[index];
1689
- const itemB = b[index];
1690
- const sharedValue = mergeValues(itemA, itemB);
1691
- if (!sharedValue.valid) return {
1692
- valid: false,
1693
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1694
- };
1695
- newArray.push(sharedValue.data);
1696
- }
1697
- return {
1698
- valid: true,
1699
- data: newArray
1700
- };
1701
- }
1702
- return {
1703
- valid: false,
1704
- mergeErrorPath: []
1705
- };
1706
- }
1707
- function handleIntersectionResults(result, left, right) {
1708
- const unrecKeys = /* @__PURE__ */ new Map();
1709
- let unrecIssue;
1710
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1711
- unrecIssue ?? (unrecIssue = iss);
1712
- for (const k of iss.keys) {
1713
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1714
- unrecKeys.get(k).l = true;
1715
- }
1716
- } else result.issues.push(iss);
1717
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1718
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1719
- unrecKeys.get(k).r = true;
1720
- }
1721
- else result.issues.push(iss);
1722
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1723
- if (bothKeys.length && unrecIssue) result.issues.push({
1724
- ...unrecIssue,
1725
- keys: bothKeys
1726
- });
1727
- if (aborted(result)) return result;
1728
- const merged = mergeValues(left.value, right.value);
1729
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
1730
- result.value = merged.data;
1731
- return result;
1732
- }
1733
- var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
1734
- $ZodType.init(inst, def);
1735
- inst._zod.parse = (payload, ctx) => {
1736
- const input = payload.value;
1737
- if (!isPlainObject(input)) {
1738
- payload.issues.push({
1739
- expected: "record",
1740
- code: "invalid_type",
1741
- input,
1742
- inst
1743
- });
1744
- return payload;
1745
- }
1746
- const proms = [];
1747
- const values = def.keyType._zod.values;
1748
- if (values) {
1749
- payload.value = {};
1750
- const recordKeys = /* @__PURE__ */ new Set();
1751
- for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1752
- recordKeys.add(typeof key === "number" ? key.toString() : key);
1753
- const keyResult = def.keyType._zod.run({
1754
- value: key,
1755
- issues: []
1756
- }, ctx);
1757
- if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
1758
- if (keyResult.issues.length) {
1759
- payload.issues.push({
1760
- code: "invalid_key",
1761
- origin: "record",
1762
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
1763
- input: key,
1764
- path: [key],
1765
- inst
1766
- });
1767
- continue;
1768
- }
1769
- const outKey = keyResult.value;
1770
- const result = def.valueType._zod.run({
1771
- value: input[key],
1772
- issues: []
1773
- }, ctx);
1774
- if (result instanceof Promise) proms.push(result.then((result) => {
1775
- if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1776
- payload.value[outKey] = result.value;
1777
- }));
1778
- else {
1779
- if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1780
- payload.value[outKey] = result.value;
1781
- }
1782
- }
1783
- let unrecognized;
1784
- for (const key in input) if (!recordKeys.has(key)) {
1785
- unrecognized = unrecognized ?? [];
1786
- unrecognized.push(key);
1787
- }
1788
- if (unrecognized && unrecognized.length > 0) payload.issues.push({
1789
- code: "unrecognized_keys",
1790
- input,
1791
- inst,
1792
- keys: unrecognized
1793
- });
1794
- } else {
1795
- payload.value = {};
1796
- for (const key of Reflect.ownKeys(input)) {
1797
- if (key === "__proto__") continue;
1798
- if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
1799
- let keyResult = def.keyType._zod.run({
1800
- value: key,
1801
- issues: []
1802
- }, ctx);
1803
- if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
1804
- if (typeof key === "string" && number.test(key) && keyResult.issues.length) {
1805
- const retryResult = def.keyType._zod.run({
1806
- value: Number(key),
1807
- issues: []
1808
- }, ctx);
1809
- if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
1810
- if (retryResult.issues.length === 0) keyResult = retryResult;
1811
- }
1812
- if (keyResult.issues.length) {
1813
- if (def.mode === "loose") payload.value[key] = input[key];
1814
- else payload.issues.push({
1815
- code: "invalid_key",
1816
- origin: "record",
1817
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
1818
- input: key,
1819
- path: [key],
1820
- inst
1821
- });
1822
- continue;
1823
- }
1824
- const result = def.valueType._zod.run({
1825
- value: input[key],
1826
- issues: []
1827
- }, ctx);
1828
- if (result instanceof Promise) proms.push(result.then((result) => {
1829
- if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1830
- payload.value[keyResult.value] = result.value;
1831
- }));
1832
- else {
1833
- if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1834
- payload.value[keyResult.value] = result.value;
1835
- }
1836
- }
1837
- }
1838
- if (proms.length) return Promise.all(proms).then(() => payload);
1839
- return payload;
1840
- };
1841
- });
1842
- var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1843
- $ZodType.init(inst, def);
1844
- const values = getEnumValues(def.entries);
1845
- const valuesSet = new Set(values);
1846
- inst._zod.values = valuesSet;
1847
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
1848
- inst._zod.parse = (payload, _ctx) => {
1849
- const input = payload.value;
1850
- if (valuesSet.has(input)) return payload;
1851
- payload.issues.push({
1852
- code: "invalid_value",
1853
- values,
1854
- input,
1855
- inst
1856
- });
1857
- return payload;
1858
- };
1859
- });
1860
- var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
1861
- $ZodType.init(inst, def);
1862
- if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
1863
- const values = new Set(def.values);
1864
- inst._zod.values = values;
1865
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
1866
- inst._zod.parse = (payload, _ctx) => {
1867
- const input = payload.value;
1868
- if (values.has(input)) return payload;
1869
- payload.issues.push({
1870
- code: "invalid_value",
1871
- values: def.values,
1872
- input,
1873
- inst
1874
- });
1875
- return payload;
1876
- };
1877
- });
1878
- var $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
1879
- $ZodType.init(inst, def);
1880
- inst._zod.optin = "optional";
1881
- inst._zod.parse = (payload, ctx) => {
1882
- if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1883
- const _out = def.transform(payload.value, payload);
1884
- if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1885
- payload.value = output;
1886
- payload.fallback = true;
1887
- return payload;
1888
- });
1889
- if (_out instanceof Promise) throw new $ZodAsyncError();
1890
- payload.value = _out;
1891
- payload.fallback = true;
1892
- return payload;
1893
- };
1894
- });
1895
- function handleOptionalResult(result, input) {
1896
- if (input === void 0 && (result.issues.length || result.fallback)) return {
1897
- issues: [],
1898
- value: void 0
1899
- };
1900
- return result;
1901
- }
1902
- var $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
1903
- $ZodType.init(inst, def);
1904
- inst._zod.optin = "optional";
1905
- inst._zod.optout = "optional";
1906
- defineLazy(inst._zod, "values", () => {
1907
- return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
1908
- });
1909
- defineLazy(inst._zod, "pattern", () => {
1910
- const pattern = def.innerType._zod.pattern;
1911
- return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
1912
- });
1913
- inst._zod.parse = (payload, ctx) => {
1914
- if (def.innerType._zod.optin === "optional") {
1915
- const input = payload.value;
1916
- const result = def.innerType._zod.run(payload, ctx);
1917
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
1918
- return handleOptionalResult(result, input);
1919
- }
1920
- if (payload.value === void 0) return payload;
1921
- return def.innerType._zod.run(payload, ctx);
1922
- };
1923
- });
1924
- var $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
1925
- $ZodOptional.init(inst, def);
1926
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1927
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
1928
- inst._zod.parse = (payload, ctx) => {
1929
- return def.innerType._zod.run(payload, ctx);
1930
- };
1931
- });
1932
- var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
1933
- $ZodType.init(inst, def);
1934
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1935
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1936
- defineLazy(inst._zod, "pattern", () => {
1937
- const pattern = def.innerType._zod.pattern;
1938
- return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
1939
- });
1940
- defineLazy(inst._zod, "values", () => {
1941
- return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
1942
- });
1943
- inst._zod.parse = (payload, ctx) => {
1944
- if (payload.value === null) return payload;
1945
- return def.innerType._zod.run(payload, ctx);
1946
- };
1947
- });
1948
- var $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
1949
- $ZodType.init(inst, def);
1950
- inst._zod.optin = "optional";
1951
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1952
- inst._zod.parse = (payload, ctx) => {
1953
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1954
- if (payload.value === void 0) {
1955
- payload.value = def.defaultValue;
1956
- /**
1957
- * $ZodDefault returns the default value immediately in forward direction.
1958
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
1959
- return payload;
1960
- }
1961
- const result = def.innerType._zod.run(payload, ctx);
1962
- if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
1963
- return handleDefaultResult(result, def);
1964
- };
1965
- });
1966
- function handleDefaultResult(payload, def) {
1967
- if (payload.value === void 0) payload.value = def.defaultValue;
1968
- return payload;
1969
- }
1970
- var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
1971
- $ZodType.init(inst, def);
1972
- inst._zod.optin = "optional";
1973
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1974
- inst._zod.parse = (payload, ctx) => {
1975
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1976
- if (payload.value === void 0) payload.value = def.defaultValue;
1977
- return def.innerType._zod.run(payload, ctx);
1978
- };
1979
- });
1980
- var $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
1981
- $ZodType.init(inst, def);
1982
- defineLazy(inst._zod, "values", () => {
1983
- const v = def.innerType._zod.values;
1984
- return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
1985
- });
1986
- inst._zod.parse = (payload, ctx) => {
1987
- const result = def.innerType._zod.run(payload, ctx);
1988
- if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
1989
- return handleNonOptionalResult(result, inst);
1990
- };
1991
- });
1992
- function handleNonOptionalResult(payload, inst) {
1993
- if (!payload.issues.length && payload.value === void 0) payload.issues.push({
1994
- code: "invalid_type",
1995
- expected: "nonoptional",
1996
- input: payload.value,
1997
- inst
1998
- });
1999
- return payload;
2000
- }
2001
- var $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2002
- $ZodType.init(inst, def);
2003
- inst._zod.optin = "optional";
2004
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2005
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2006
- inst._zod.parse = (payload, ctx) => {
2007
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2008
- const result = def.innerType._zod.run(payload, ctx);
2009
- if (result instanceof Promise) return result.then((result) => {
2010
- payload.value = result.value;
2011
- if (result.issues.length) {
2012
- payload.value = def.catchValue({
2013
- ...payload,
2014
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2015
- input: payload.value
2016
- });
2017
- payload.issues = [];
2018
- payload.fallback = true;
2019
- }
2020
- return payload;
2021
- });
2022
- payload.value = result.value;
2023
- if (result.issues.length) {
2024
- payload.value = def.catchValue({
2025
- ...payload,
2026
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2027
- input: payload.value
2028
- });
2029
- payload.issues = [];
2030
- payload.fallback = true;
2031
- }
2032
- return payload;
2033
- };
2034
- });
2035
- var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2036
- $ZodType.init(inst, def);
2037
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2038
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2039
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2040
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2041
- inst._zod.parse = (payload, ctx) => {
2042
- if (ctx.direction === "backward") {
2043
- const right = def.out._zod.run(payload, ctx);
2044
- if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
2045
- return handlePipeResult(right, def.in, ctx);
2046
- }
2047
- const left = def.in._zod.run(payload, ctx);
2048
- if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
2049
- return handlePipeResult(left, def.out, ctx);
2050
- };
2051
- });
2052
- function handlePipeResult(left, next, ctx) {
2053
- if (left.issues.length) {
2054
- left.aborted = true;
2055
- return left;
2056
- }
2057
- return next._zod.run({
2058
- value: left.value,
2059
- issues: left.issues,
2060
- fallback: left.fallback
2061
- }, ctx);
2062
- }
2063
- var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2064
- $ZodType.init(inst, def);
2065
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2066
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2067
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2068
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2069
- inst._zod.parse = (payload, ctx) => {
2070
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2071
- const result = def.innerType._zod.run(payload, ctx);
2072
- if (result instanceof Promise) return result.then(handleReadonlyResult);
2073
- return handleReadonlyResult(result);
2074
- };
2075
- });
2076
- function handleReadonlyResult(payload) {
2077
- payload.value = Object.freeze(payload.value);
2078
- return payload;
2079
- }
2080
- var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
2081
- $ZodCheck.init(inst, def);
2082
- $ZodType.init(inst, def);
2083
- inst._zod.parse = (payload, _) => {
2084
- return payload;
2085
- };
2086
- inst._zod.check = (payload) => {
2087
- const input = payload.value;
2088
- const r = def.fn(input);
2089
- if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2090
- handleRefineResult(r, payload, input, inst);
2091
- };
2092
- });
2093
- function handleRefineResult(result, payload, input, inst) {
2094
- if (!result) {
2095
- const _iss = {
2096
- code: "custom",
2097
- input,
2098
- inst,
2099
- path: [...inst._zod.def.path ?? []],
2100
- continue: !inst._zod.def.abort
2101
- };
2102
- if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2103
- payload.issues.push(issue(_iss));
2104
- }
2105
- }
2106
- //#endregion
2107
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/registries.js
2108
- var _a;
2109
- var $ZodRegistry = class {
2110
- constructor() {
2111
- this._map = /* @__PURE__ */ new WeakMap();
2112
- this._idmap = /* @__PURE__ */ new Map();
2113
- }
2114
- add(schema, ..._meta) {
2115
- const meta = _meta[0];
2116
- this._map.set(schema, meta);
2117
- if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
2118
- return this;
2119
- }
2120
- clear() {
2121
- this._map = /* @__PURE__ */ new WeakMap();
2122
- this._idmap = /* @__PURE__ */ new Map();
2123
- return this;
2124
- }
2125
- remove(schema) {
2126
- const meta = this._map.get(schema);
2127
- if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
2128
- this._map.delete(schema);
2129
- return this;
2130
- }
2131
- get(schema) {
2132
- const p = schema._zod.parent;
2133
- if (p) {
2134
- const pm = { ...this.get(p) ?? {} };
2135
- delete pm.id;
2136
- const f = {
2137
- ...pm,
2138
- ...this._map.get(schema)
2139
- };
2140
- return Object.keys(f).length ? f : void 0;
2141
- }
2142
- return this._map.get(schema);
2143
- }
2144
- has(schema) {
2145
- return this._map.has(schema);
2146
- }
2147
- };
2148
- function registry() {
2149
- return new $ZodRegistry();
2150
- }
2151
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2152
- var globalRegistry = globalThis.__zod_globalRegistry;
2153
- //#endregion
2154
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/api.js
2155
- // @__NO_SIDE_EFFECTS__
2156
- function _string(Class, params) {
2157
- return new Class({
2158
- type: "string",
2159
- ...normalizeParams(params)
2160
- });
2161
- }
2162
- // @__NO_SIDE_EFFECTS__
2163
- function _email(Class, params) {
2164
- return new Class({
2165
- type: "string",
2166
- format: "email",
2167
- check: "string_format",
2168
- abort: false,
2169
- ...normalizeParams(params)
2170
- });
2171
- }
2172
- // @__NO_SIDE_EFFECTS__
2173
- function _guid(Class, params) {
2174
- return new Class({
2175
- type: "string",
2176
- format: "guid",
2177
- check: "string_format",
2178
- abort: false,
2179
- ...normalizeParams(params)
2180
- });
2181
- }
2182
- // @__NO_SIDE_EFFECTS__
2183
- function _uuid(Class, params) {
2184
- return new Class({
2185
- type: "string",
2186
- format: "uuid",
2187
- check: "string_format",
2188
- abort: false,
2189
- ...normalizeParams(params)
2190
- });
2191
- }
2192
- // @__NO_SIDE_EFFECTS__
2193
- function _uuidv4(Class, params) {
2194
- return new Class({
2195
- type: "string",
2196
- format: "uuid",
2197
- check: "string_format",
2198
- abort: false,
2199
- version: "v4",
2200
- ...normalizeParams(params)
2201
- });
2202
- }
2203
- // @__NO_SIDE_EFFECTS__
2204
- function _uuidv6(Class, params) {
2205
- return new Class({
2206
- type: "string",
2207
- format: "uuid",
2208
- check: "string_format",
2209
- abort: false,
2210
- version: "v6",
2211
- ...normalizeParams(params)
2212
- });
2213
- }
2214
- // @__NO_SIDE_EFFECTS__
2215
- function _uuidv7(Class, params) {
2216
- return new Class({
2217
- type: "string",
2218
- format: "uuid",
2219
- check: "string_format",
2220
- abort: false,
2221
- version: "v7",
2222
- ...normalizeParams(params)
2223
- });
2224
- }
2225
- // @__NO_SIDE_EFFECTS__
2226
- function _url(Class, params) {
2227
- return new Class({
2228
- type: "string",
2229
- format: "url",
2230
- check: "string_format",
2231
- abort: false,
2232
- ...normalizeParams(params)
2233
- });
2234
- }
2235
- // @__NO_SIDE_EFFECTS__
2236
- function _emoji(Class, params) {
2237
- return new Class({
2238
- type: "string",
2239
- format: "emoji",
2240
- check: "string_format",
2241
- abort: false,
2242
- ...normalizeParams(params)
2243
- });
2244
- }
2245
- // @__NO_SIDE_EFFECTS__
2246
- function _nanoid(Class, params) {
2247
- return new Class({
2248
- type: "string",
2249
- format: "nanoid",
2250
- check: "string_format",
2251
- abort: false,
2252
- ...normalizeParams(params)
2253
- });
2254
- }
2255
- /**
2256
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
2257
- * (timestamps embedded in the id). Use {@link _cuid2} instead.
2258
- * See https://github.com/paralleldrive/cuid.
2259
- */
2260
- // @__NO_SIDE_EFFECTS__
2261
- function _cuid(Class, params) {
2262
- return new Class({
2263
- type: "string",
2264
- format: "cuid",
2265
- check: "string_format",
2266
- abort: false,
2267
- ...normalizeParams(params)
2268
- });
2269
- }
2270
- // @__NO_SIDE_EFFECTS__
2271
- function _cuid2(Class, params) {
2272
- return new Class({
2273
- type: "string",
2274
- format: "cuid2",
2275
- check: "string_format",
2276
- abort: false,
2277
- ...normalizeParams(params)
2278
- });
2279
- }
2280
- // @__NO_SIDE_EFFECTS__
2281
- function _ulid(Class, params) {
2282
- return new Class({
2283
- type: "string",
2284
- format: "ulid",
2285
- check: "string_format",
2286
- abort: false,
2287
- ...normalizeParams(params)
2288
- });
2289
- }
2290
- // @__NO_SIDE_EFFECTS__
2291
- function _xid(Class, params) {
2292
- return new Class({
2293
- type: "string",
2294
- format: "xid",
2295
- check: "string_format",
2296
- abort: false,
2297
- ...normalizeParams(params)
2298
- });
2299
- }
2300
- // @__NO_SIDE_EFFECTS__
2301
- function _ksuid(Class, params) {
2302
- return new Class({
2303
- type: "string",
2304
- format: "ksuid",
2305
- check: "string_format",
2306
- abort: false,
2307
- ...normalizeParams(params)
2308
- });
2309
- }
2310
- // @__NO_SIDE_EFFECTS__
2311
- function _ipv4(Class, params) {
2312
- return new Class({
2313
- type: "string",
2314
- format: "ipv4",
2315
- check: "string_format",
2316
- abort: false,
2317
- ...normalizeParams(params)
2318
- });
2319
- }
2320
- // @__NO_SIDE_EFFECTS__
2321
- function _ipv6(Class, params) {
2322
- return new Class({
2323
- type: "string",
2324
- format: "ipv6",
2325
- check: "string_format",
2326
- abort: false,
2327
- ...normalizeParams(params)
2328
- });
2329
- }
2330
- // @__NO_SIDE_EFFECTS__
2331
- function _cidrv4(Class, params) {
2332
- return new Class({
2333
- type: "string",
2334
- format: "cidrv4",
2335
- check: "string_format",
2336
- abort: false,
2337
- ...normalizeParams(params)
2338
- });
2339
- }
2340
- // @__NO_SIDE_EFFECTS__
2341
- function _cidrv6(Class, params) {
2342
- return new Class({
2343
- type: "string",
2344
- format: "cidrv6",
2345
- check: "string_format",
2346
- abort: false,
2347
- ...normalizeParams(params)
2348
- });
2349
- }
2350
- // @__NO_SIDE_EFFECTS__
2351
- function _base64(Class, params) {
2352
- return new Class({
2353
- type: "string",
2354
- format: "base64",
2355
- check: "string_format",
2356
- abort: false,
2357
- ...normalizeParams(params)
2358
- });
2359
- }
2360
- // @__NO_SIDE_EFFECTS__
2361
- function _base64url(Class, params) {
2362
- return new Class({
2363
- type: "string",
2364
- format: "base64url",
2365
- check: "string_format",
2366
- abort: false,
2367
- ...normalizeParams(params)
2368
- });
2369
- }
2370
- // @__NO_SIDE_EFFECTS__
2371
- function _e164(Class, params) {
2372
- return new Class({
2373
- type: "string",
2374
- format: "e164",
2375
- check: "string_format",
2376
- abort: false,
2377
- ...normalizeParams(params)
2378
- });
2379
- }
2380
- // @__NO_SIDE_EFFECTS__
2381
- function _jwt(Class, params) {
2382
- return new Class({
2383
- type: "string",
2384
- format: "jwt",
2385
- check: "string_format",
2386
- abort: false,
2387
- ...normalizeParams(params)
2388
- });
2389
- }
2390
- // @__NO_SIDE_EFFECTS__
2391
- function _isoDateTime(Class, params) {
2392
- return new Class({
2393
- type: "string",
2394
- format: "datetime",
2395
- check: "string_format",
2396
- offset: false,
2397
- local: false,
2398
- precision: null,
2399
- ...normalizeParams(params)
2400
- });
2401
- }
2402
- // @__NO_SIDE_EFFECTS__
2403
- function _isoDate(Class, params) {
2404
- return new Class({
2405
- type: "string",
2406
- format: "date",
2407
- check: "string_format",
2408
- ...normalizeParams(params)
2409
- });
2410
- }
2411
- // @__NO_SIDE_EFFECTS__
2412
- function _isoTime(Class, params) {
2413
- return new Class({
2414
- type: "string",
2415
- format: "time",
2416
- check: "string_format",
2417
- precision: null,
2418
- ...normalizeParams(params)
2419
- });
2420
- }
2421
- // @__NO_SIDE_EFFECTS__
2422
- function _isoDuration(Class, params) {
2423
- return new Class({
2424
- type: "string",
2425
- format: "duration",
2426
- check: "string_format",
2427
- ...normalizeParams(params)
2428
- });
2429
- }
2430
- // @__NO_SIDE_EFFECTS__
2431
- function _unknown(Class) {
2432
- return new Class({ type: "unknown" });
2433
- }
2434
- // @__NO_SIDE_EFFECTS__
2435
- function _never(Class, params) {
2436
- return new Class({
2437
- type: "never",
2438
- ...normalizeParams(params)
2439
- });
2440
- }
2441
- // @__NO_SIDE_EFFECTS__
2442
- function _maxLength(maximum, params) {
2443
- return new $ZodCheckMaxLength({
2444
- check: "max_length",
2445
- ...normalizeParams(params),
2446
- maximum
2447
- });
2448
- }
2449
- // @__NO_SIDE_EFFECTS__
2450
- function _minLength(minimum, params) {
2451
- return new $ZodCheckMinLength({
2452
- check: "min_length",
2453
- ...normalizeParams(params),
2454
- minimum
2455
- });
2456
- }
2457
- // @__NO_SIDE_EFFECTS__
2458
- function _length(length, params) {
2459
- return new $ZodCheckLengthEquals({
2460
- check: "length_equals",
2461
- ...normalizeParams(params),
2462
- length
2463
- });
2464
- }
2465
- // @__NO_SIDE_EFFECTS__
2466
- function _regex(pattern, params) {
2467
- return new $ZodCheckRegex({
2468
- check: "string_format",
2469
- format: "regex",
2470
- ...normalizeParams(params),
2471
- pattern
2472
- });
2473
- }
2474
- // @__NO_SIDE_EFFECTS__
2475
- function _lowercase(params) {
2476
- return new $ZodCheckLowerCase({
2477
- check: "string_format",
2478
- format: "lowercase",
2479
- ...normalizeParams(params)
2480
- });
2481
- }
2482
- // @__NO_SIDE_EFFECTS__
2483
- function _uppercase(params) {
2484
- return new $ZodCheckUpperCase({
2485
- check: "string_format",
2486
- format: "uppercase",
2487
- ...normalizeParams(params)
2488
- });
2489
- }
2490
- // @__NO_SIDE_EFFECTS__
2491
- function _includes(includes, params) {
2492
- return new $ZodCheckIncludes({
2493
- check: "string_format",
2494
- format: "includes",
2495
- ...normalizeParams(params),
2496
- includes
2497
- });
2498
- }
2499
- // @__NO_SIDE_EFFECTS__
2500
- function _startsWith(prefix, params) {
2501
- return new $ZodCheckStartsWith({
2502
- check: "string_format",
2503
- format: "starts_with",
2504
- ...normalizeParams(params),
2505
- prefix
2506
- });
2507
- }
2508
- // @__NO_SIDE_EFFECTS__
2509
- function _endsWith(suffix, params) {
2510
- return new $ZodCheckEndsWith({
2511
- check: "string_format",
2512
- format: "ends_with",
2513
- ...normalizeParams(params),
2514
- suffix
2515
- });
2516
- }
2517
- // @__NO_SIDE_EFFECTS__
2518
- function _overwrite(tx) {
2519
- return new $ZodCheckOverwrite({
2520
- check: "overwrite",
2521
- tx
2522
- });
2523
- }
2524
- // @__NO_SIDE_EFFECTS__
2525
- function _normalize(form) {
2526
- return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
2527
- }
2528
- // @__NO_SIDE_EFFECTS__
2529
- function _trim() {
2530
- return /* @__PURE__ */ _overwrite((input) => input.trim());
2531
- }
2532
- // @__NO_SIDE_EFFECTS__
2533
- function _toLowerCase() {
2534
- return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
2535
- }
2536
- // @__NO_SIDE_EFFECTS__
2537
- function _toUpperCase() {
2538
- return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
2539
- }
2540
- // @__NO_SIDE_EFFECTS__
2541
- function _slugify() {
2542
- return /* @__PURE__ */ _overwrite((input) => slugify(input));
2543
- }
2544
- // @__NO_SIDE_EFFECTS__
2545
- function _array(Class, element, params) {
2546
- return new Class({
2547
- type: "array",
2548
- element,
2549
- ...normalizeParams(params)
2550
- });
2551
- }
2552
- // @__NO_SIDE_EFFECTS__
2553
- function _refine(Class, fn, _params) {
2554
- return new Class({
2555
- type: "custom",
2556
- check: "custom",
2557
- fn,
2558
- ...normalizeParams(_params)
2559
- });
2560
- }
2561
- // @__NO_SIDE_EFFECTS__
2562
- function _superRefine(fn, params) {
2563
- const ch = /* @__PURE__ */ _check((payload) => {
2564
- payload.addIssue = (issue$2) => {
2565
- if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
2566
- else {
2567
- const _issue = issue$2;
2568
- if (_issue.fatal) _issue.continue = false;
2569
- _issue.code ?? (_issue.code = "custom");
2570
- _issue.input ?? (_issue.input = payload.value);
2571
- _issue.inst ?? (_issue.inst = ch);
2572
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2573
- payload.issues.push(issue(_issue));
2574
- }
2575
- };
2576
- return fn(payload.value, payload);
2577
- }, params);
2578
- return ch;
2579
- }
2580
- // @__NO_SIDE_EFFECTS__
2581
- function _check(fn, params) {
2582
- const ch = new $ZodCheck({
2583
- check: "custom",
2584
- ...normalizeParams(params)
2585
- });
2586
- ch._zod.check = fn;
2587
- return ch;
2588
- }
2589
- //#endregion
2590
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
2591
- function initializeContext(params) {
2592
- let target = params?.target ?? "draft-2020-12";
2593
- if (target === "draft-4") target = "draft-04";
2594
- if (target === "draft-7") target = "draft-07";
2595
- return {
2596
- processors: params.processors ?? {},
2597
- metadataRegistry: params?.metadata ?? globalRegistry,
2598
- target,
2599
- unrepresentable: params?.unrepresentable ?? "throw",
2600
- override: params?.override ?? (() => {}),
2601
- io: params?.io ?? "output",
2602
- counter: 0,
2603
- seen: /* @__PURE__ */ new Map(),
2604
- cycles: params?.cycles ?? "ref",
2605
- reused: params?.reused ?? "inline",
2606
- external: params?.external ?? void 0
2607
- };
2608
- }
2609
- function process$2(schema, ctx, _params = {
2610
- path: [],
2611
- schemaPath: []
2612
- }) {
2613
- var _a;
2614
- const def = schema._zod.def;
2615
- const seen = ctx.seen.get(schema);
2616
- if (seen) {
2617
- seen.count++;
2618
- if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
2619
- return seen.schema;
2620
- }
2621
- const result = {
2622
- schema: {},
2623
- count: 1,
2624
- cycle: void 0,
2625
- path: _params.path
2626
- };
2627
- ctx.seen.set(schema, result);
2628
- const overrideSchema = schema._zod.toJSONSchema?.();
2629
- if (overrideSchema) result.schema = overrideSchema;
2630
- else {
2631
- const params = {
2632
- ..._params,
2633
- schemaPath: [..._params.schemaPath, schema],
2634
- path: _params.path
2635
- };
2636
- if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
2637
- else {
2638
- const _json = result.schema;
2639
- const processor = ctx.processors[def.type];
2640
- if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
2641
- processor(schema, ctx, _json, params);
2642
- }
2643
- const parent = schema._zod.parent;
2644
- if (parent) {
2645
- if (!result.ref) result.ref = parent;
2646
- process$2(parent, ctx, params);
2647
- ctx.seen.get(parent).isParent = true;
2648
- }
2649
- }
2650
- const meta = ctx.metadataRegistry.get(schema);
2651
- if (meta) Object.assign(result.schema, meta);
2652
- if (ctx.io === "input" && isTransforming(schema)) {
2653
- delete result.schema.examples;
2654
- delete result.schema.default;
2655
- }
2656
- if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
2657
- delete result.schema._prefault;
2658
- return ctx.seen.get(schema).schema;
2659
- }
2660
- function extractDefs(ctx, schema) {
2661
- const root = ctx.seen.get(schema);
2662
- if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2663
- const idToSchema = /* @__PURE__ */ new Map();
2664
- for (const entry of ctx.seen.entries()) {
2665
- const id = ctx.metadataRegistry.get(entry[0])?.id;
2666
- if (id) {
2667
- const existing = idToSchema.get(id);
2668
- 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.`);
2669
- idToSchema.set(id, entry[0]);
2670
- }
2671
- }
2672
- const makeURI = (entry) => {
2673
- const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
2674
- if (ctx.external) {
2675
- const externalId = ctx.external.registry.get(entry[0])?.id;
2676
- const uriGenerator = ctx.external.uri ?? ((id) => id);
2677
- if (externalId) return { ref: uriGenerator(externalId) };
2678
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
2679
- entry[1].defId = id;
2680
- return {
2681
- defId: id,
2682
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
2683
- };
2684
- }
2685
- if (entry[1] === root) return { ref: "#" };
2686
- const defUriPrefix = `#/${defsSegment}/`;
2687
- const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2688
- return {
2689
- defId,
2690
- ref: defUriPrefix + defId
2691
- };
2692
- };
2693
- const extractToDef = (entry) => {
2694
- if (entry[1].schema.$ref) return;
2695
- const seen = entry[1];
2696
- const { ref, defId } = makeURI(entry);
2697
- seen.def = { ...seen.schema };
2698
- if (defId) seen.defId = defId;
2699
- const schema = seen.schema;
2700
- for (const key in schema) delete schema[key];
2701
- schema.$ref = ref;
2702
- };
2703
- if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
2704
- const seen = entry[1];
2705
- if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
2706
-
2707
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
2708
- }
2709
- for (const entry of ctx.seen.entries()) {
2710
- const seen = entry[1];
2711
- if (schema === entry[0]) {
2712
- extractToDef(entry);
2713
- continue;
2714
- }
2715
- if (ctx.external) {
2716
- const ext = ctx.external.registry.get(entry[0])?.id;
2717
- if (schema !== entry[0] && ext) {
2718
- extractToDef(entry);
2719
- continue;
2720
- }
2721
- }
2722
- if (ctx.metadataRegistry.get(entry[0])?.id) {
2723
- extractToDef(entry);
2724
- continue;
2725
- }
2726
- if (seen.cycle) {
2727
- extractToDef(entry);
2728
- continue;
2729
- }
2730
- if (seen.count > 1) {
2731
- if (ctx.reused === "ref") {
2732
- extractToDef(entry);
2733
- continue;
2734
- }
2735
- }
2736
- }
2737
- }
2738
- function finalize(ctx, schema) {
2739
- const root = ctx.seen.get(schema);
2740
- if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2741
- const flattenRef = (zodSchema) => {
2742
- const seen = ctx.seen.get(zodSchema);
2743
- if (seen.ref === null) return;
2744
- const schema = seen.def ?? seen.schema;
2745
- const _cached = { ...schema };
2746
- const ref = seen.ref;
2747
- seen.ref = null;
2748
- if (ref) {
2749
- flattenRef(ref);
2750
- const refSeen = ctx.seen.get(ref);
2751
- const refSchema = refSeen.schema;
2752
- if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2753
- schema.allOf = schema.allOf ?? [];
2754
- schema.allOf.push(refSchema);
2755
- } else Object.assign(schema, refSchema);
2756
- Object.assign(schema, _cached);
2757
- if (zodSchema._zod.parent === ref) for (const key in schema) {
2758
- if (key === "$ref" || key === "allOf") continue;
2759
- if (!(key in _cached)) delete schema[key];
2760
- }
2761
- if (refSchema.$ref && refSeen.def) for (const key in schema) {
2762
- if (key === "$ref" || key === "allOf") continue;
2763
- if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
2764
- }
2765
- }
2766
- const parent = zodSchema._zod.parent;
2767
- if (parent && parent !== ref) {
2768
- flattenRef(parent);
2769
- const parentSeen = ctx.seen.get(parent);
2770
- if (parentSeen?.schema.$ref) {
2771
- schema.$ref = parentSeen.schema.$ref;
2772
- if (parentSeen.def) for (const key in schema) {
2773
- if (key === "$ref" || key === "allOf") continue;
2774
- if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
2775
- }
2776
- }
2777
- }
2778
- ctx.override({
2779
- zodSchema,
2780
- jsonSchema: schema,
2781
- path: seen.path ?? []
2782
- });
2783
- };
2784
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
2785
- const result = {};
2786
- if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2787
- else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
2788
- else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
2789
- else if (ctx.target === "openapi-3.0") {}
2790
- if (ctx.external?.uri) {
2791
- const id = ctx.external.registry.get(schema)?.id;
2792
- if (!id) throw new Error("Schema is missing an `id` property");
2793
- result.$id = ctx.external.uri(id);
2794
- }
2795
- Object.assign(result, root.def ?? root.schema);
2796
- const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
2797
- if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
2798
- const defs = ctx.external?.defs ?? {};
2799
- for (const entry of ctx.seen.entries()) {
2800
- const seen = entry[1];
2801
- if (seen.def && seen.defId) {
2802
- if (seen.def.id === seen.defId) delete seen.def.id;
2803
- defs[seen.defId] = seen.def;
2804
- }
2805
- }
2806
- if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
2807
- else result.definitions = defs;
2808
- try {
2809
- const finalized = JSON.parse(JSON.stringify(result));
2810
- Object.defineProperty(finalized, "~standard", {
2811
- value: {
2812
- ...schema["~standard"],
2813
- jsonSchema: {
2814
- input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
2815
- output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
2816
- }
2817
- },
2818
- enumerable: false,
2819
- writable: false
2820
- });
2821
- return finalized;
2822
- } catch (_err) {
2823
- throw new Error("Error converting schema to JSON.");
2824
- }
2825
- }
2826
- function isTransforming(_schema, _ctx) {
2827
- const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
2828
- if (ctx.seen.has(_schema)) return false;
2829
- ctx.seen.add(_schema);
2830
- const def = _schema._zod.def;
2831
- if (def.type === "transform") return true;
2832
- if (def.type === "array") return isTransforming(def.element, ctx);
2833
- if (def.type === "set") return isTransforming(def.valueType, ctx);
2834
- if (def.type === "lazy") return isTransforming(def.getter(), ctx);
2835
- 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);
2836
- if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2837
- if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2838
- if (def.type === "pipe") {
2839
- if (_schema._zod.traits.has("$ZodCodec")) return true;
2840
- return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
2841
- }
2842
- if (def.type === "object") {
2843
- for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
2844
- return false;
2845
- }
2846
- if (def.type === "union") {
2847
- for (const option of def.options) if (isTransforming(option, ctx)) return true;
2848
- return false;
2849
- }
2850
- if (def.type === "tuple") {
2851
- for (const item of def.items) if (isTransforming(item, ctx)) return true;
2852
- if (def.rest && isTransforming(def.rest, ctx)) return true;
2853
- return false;
2854
- }
2855
- return false;
2856
- }
2857
- /**
2858
- * Creates a toJSONSchema method for a schema instance.
2859
- * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
2860
- */
2861
- var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
2862
- const ctx = initializeContext({
2863
- ...params,
2864
- processors
2865
- });
2866
- process$2(schema, ctx);
2867
- extractDefs(ctx, schema);
2868
- return finalize(ctx, schema);
2869
- };
2870
- var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
2871
- const { libraryOptions, target } = params ?? {};
2872
- const ctx = initializeContext({
2873
- ...libraryOptions ?? {},
2874
- target,
2875
- io,
2876
- processors
2877
- });
2878
- process$2(schema, ctx);
2879
- extractDefs(ctx, schema);
2880
- return finalize(ctx, schema);
2881
- };
2882
- //#endregion
2883
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
2884
- var formatMap = {
2885
- guid: "uuid",
2886
- url: "uri",
2887
- datetime: "date-time",
2888
- json_string: "json-string",
2889
- regex: ""
2890
- };
2891
- var stringProcessor = (schema, ctx, _json, _params) => {
2892
- const json = _json;
2893
- json.type = "string";
2894
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
2895
- if (typeof minimum === "number") json.minLength = minimum;
2896
- if (typeof maximum === "number") json.maxLength = maximum;
2897
- if (format) {
2898
- json.format = formatMap[format] ?? format;
2899
- if (json.format === "") delete json.format;
2900
- if (format === "time") delete json.format;
2901
- }
2902
- if (contentEncoding) json.contentEncoding = contentEncoding;
2903
- if (patterns && patterns.size > 0) {
2904
- const regexes = [...patterns];
2905
- if (regexes.length === 1) json.pattern = regexes[0].source;
2906
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
2907
- ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
2908
- pattern: regex.source
2909
- }))];
2910
- }
2911
- };
2912
- var neverProcessor = (_schema, _ctx, json, _params) => {
2913
- json.not = {};
2914
- };
2915
- var enumProcessor = (schema, _ctx, json, _params) => {
2916
- const def = schema._zod.def;
2917
- const values = getEnumValues(def.entries);
2918
- if (values.every((v) => typeof v === "number")) json.type = "number";
2919
- if (values.every((v) => typeof v === "string")) json.type = "string";
2920
- json.enum = values;
2921
- };
2922
- var literalProcessor = (schema, ctx, json, _params) => {
2923
- const def = schema._zod.def;
2924
- const vals = [];
2925
- for (const val of def.values) if (val === void 0) {
2926
- if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
2927
- } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
2928
- else vals.push(Number(val));
2929
- else vals.push(val);
2930
- if (vals.length === 0) {} else if (vals.length === 1) {
2931
- const val = vals[0];
2932
- json.type = val === null ? "null" : typeof val;
2933
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
2934
- else json.const = val;
2935
- } else {
2936
- if (vals.every((v) => typeof v === "number")) json.type = "number";
2937
- if (vals.every((v) => typeof v === "string")) json.type = "string";
2938
- if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
2939
- if (vals.every((v) => v === null)) json.type = "null";
2940
- json.enum = vals;
2941
- }
2942
- };
2943
- var customProcessor = (_schema, ctx, _json, _params) => {
2944
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
2945
- };
2946
- var transformProcessor = (_schema, ctx, _json, _params) => {
2947
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
2948
- };
2949
- var arrayProcessor = (schema, ctx, _json, params) => {
2950
- const json = _json;
2951
- const def = schema._zod.def;
2952
- const { minimum, maximum } = schema._zod.bag;
2953
- if (typeof minimum === "number") json.minItems = minimum;
2954
- if (typeof maximum === "number") json.maxItems = maximum;
2955
- json.type = "array";
2956
- json.items = process$2(def.element, ctx, {
2957
- ...params,
2958
- path: [...params.path, "items"]
2959
- });
2960
- };
2961
- var objectProcessor = (schema, ctx, _json, params) => {
2962
- const json = _json;
2963
- const def = schema._zod.def;
2964
- json.type = "object";
2965
- json.properties = {};
2966
- const shape = def.shape;
2967
- for (const key in shape) json.properties[key] = process$2(shape[key], ctx, {
2968
- ...params,
2969
- path: [
2970
- ...params.path,
2971
- "properties",
2972
- key
2973
- ]
2974
- });
2975
- const allKeys = new Set(Object.keys(shape));
2976
- const requiredKeys = new Set([...allKeys].filter((key) => {
2977
- const v = def.shape[key]._zod;
2978
- if (ctx.io === "input") return v.optin === void 0;
2979
- else return v.optout === void 0;
2980
- }));
2981
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
2982
- if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
2983
- else if (!def.catchall) {
2984
- if (ctx.io === "output") json.additionalProperties = false;
2985
- } else if (def.catchall) json.additionalProperties = process$2(def.catchall, ctx, {
2986
- ...params,
2987
- path: [...params.path, "additionalProperties"]
2988
- });
2989
- };
2990
- var unionProcessor = (schema, ctx, json, params) => {
2991
- const def = schema._zod.def;
2992
- const isExclusive = def.inclusive === false;
2993
- const options = def.options.map((x, i) => process$2(x, ctx, {
2994
- ...params,
2995
- path: [
2996
- ...params.path,
2997
- isExclusive ? "oneOf" : "anyOf",
2998
- i
2999
- ]
3000
- }));
3001
- if (isExclusive) json.oneOf = options;
3002
- else json.anyOf = options;
3003
- };
3004
- var intersectionProcessor = (schema, ctx, json, params) => {
3005
- const def = schema._zod.def;
3006
- const a = process$2(def.left, ctx, {
3007
- ...params,
3008
- path: [
3009
- ...params.path,
3010
- "allOf",
3011
- 0
3012
- ]
3013
- });
3014
- const b = process$2(def.right, ctx, {
3015
- ...params,
3016
- path: [
3017
- ...params.path,
3018
- "allOf",
3019
- 1
3020
- ]
3021
- });
3022
- const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3023
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3024
- };
3025
- var recordProcessor = (schema, ctx, _json, params) => {
3026
- const json = _json;
3027
- const def = schema._zod.def;
3028
- json.type = "object";
3029
- const keyType = def.keyType;
3030
- const patterns = keyType._zod.bag?.patterns;
3031
- if (def.mode === "loose" && patterns && patterns.size > 0) {
3032
- const valueSchema = process$2(def.valueType, ctx, {
3033
- ...params,
3034
- path: [
3035
- ...params.path,
3036
- "patternProperties",
3037
- "*"
3038
- ]
3039
- });
3040
- json.patternProperties = {};
3041
- for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
3042
- } else {
3043
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$2(def.keyType, ctx, {
3044
- ...params,
3045
- path: [...params.path, "propertyNames"]
3046
- });
3047
- json.additionalProperties = process$2(def.valueType, ctx, {
3048
- ...params,
3049
- path: [...params.path, "additionalProperties"]
3050
- });
3051
- }
3052
- const keyValues = keyType._zod.values;
3053
- if (keyValues) {
3054
- const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3055
- if (validKeyValues.length > 0) json.required = validKeyValues;
3056
- }
3057
- };
3058
- var nullableProcessor = (schema, ctx, json, params) => {
3059
- const def = schema._zod.def;
3060
- const inner = process$2(def.innerType, ctx, params);
3061
- const seen = ctx.seen.get(schema);
3062
- if (ctx.target === "openapi-3.0") {
3063
- seen.ref = def.innerType;
3064
- json.nullable = true;
3065
- } else json.anyOf = [inner, { type: "null" }];
3066
- };
3067
- var nonoptionalProcessor = (schema, ctx, _json, params) => {
3068
- const def = schema._zod.def;
3069
- process$2(def.innerType, ctx, params);
3070
- const seen = ctx.seen.get(schema);
3071
- seen.ref = def.innerType;
3072
- };
3073
- var defaultProcessor = (schema, ctx, json, params) => {
3074
- const def = schema._zod.def;
3075
- process$2(def.innerType, ctx, params);
3076
- const seen = ctx.seen.get(schema);
3077
- seen.ref = def.innerType;
3078
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
3079
- };
3080
- var prefaultProcessor = (schema, ctx, json, params) => {
3081
- const def = schema._zod.def;
3082
- process$2(def.innerType, ctx, params);
3083
- const seen = ctx.seen.get(schema);
3084
- seen.ref = def.innerType;
3085
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3086
- };
3087
- var catchProcessor = (schema, ctx, json, params) => {
3088
- const def = schema._zod.def;
3089
- process$2(def.innerType, ctx, params);
3090
- const seen = ctx.seen.get(schema);
3091
- seen.ref = def.innerType;
3092
- let catchValue;
3093
- try {
3094
- catchValue = def.catchValue(void 0);
3095
- } catch {
3096
- throw new Error("Dynamic catch values are not supported in JSON Schema");
3097
- }
3098
- json.default = catchValue;
3099
- };
3100
- var pipeProcessor = (schema, ctx, _json, params) => {
3101
- const def = schema._zod.def;
3102
- const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3103
- const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3104
- process$2(innerType, ctx, params);
3105
- const seen = ctx.seen.get(schema);
3106
- seen.ref = innerType;
3107
- };
3108
- var readonlyProcessor = (schema, ctx, json, params) => {
3109
- const def = schema._zod.def;
3110
- process$2(def.innerType, ctx, params);
3111
- const seen = ctx.seen.get(schema);
3112
- seen.ref = def.innerType;
3113
- json.readOnly = true;
3114
- };
3115
- var optionalProcessor = (schema, ctx, _json, params) => {
3116
- const def = schema._zod.def;
3117
- process$2(def.innerType, ctx, params);
3118
- const seen = ctx.seen.get(schema);
3119
- seen.ref = def.innerType;
3120
- };
3121
- //#endregion
3122
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/iso.js
3123
- var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3124
- $ZodISODateTime.init(inst, def);
3125
- ZodStringFormat.init(inst, def);
3126
- });
3127
- function datetime(params) {
3128
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3129
- }
3130
- var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3131
- $ZodISODate.init(inst, def);
3132
- ZodStringFormat.init(inst, def);
3133
- });
3134
- function date(params) {
3135
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
3136
- }
3137
- var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3138
- $ZodISOTime.init(inst, def);
3139
- ZodStringFormat.init(inst, def);
3140
- });
3141
- function time(params) {
3142
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3143
- }
3144
- var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3145
- $ZodISODuration.init(inst, def);
3146
- ZodStringFormat.init(inst, def);
3147
- });
3148
- function duration(params) {
3149
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
3150
- }
3151
- //#endregion
3152
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/errors.js
3153
- var initializer = (inst, issues) => {
3154
- $ZodError.init(inst, issues);
3155
- inst.name = "ZodError";
3156
- Object.defineProperties(inst, {
3157
- format: { value: (mapper) => formatError(inst, mapper) },
3158
- flatten: { value: (mapper) => flattenError(inst, mapper) },
3159
- addIssue: { value: (issue) => {
3160
- inst.issues.push(issue);
3161
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3162
- } },
3163
- addIssues: { value: (issues) => {
3164
- inst.issues.push(...issues);
3165
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3166
- } },
3167
- isEmpty: { get() {
3168
- return inst.issues.length === 0;
3169
- } }
3170
- });
3171
- };
3172
- var ZodError = /*@__PURE__*/ $constructor("ZodError", initializer);
3173
- var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
3174
- //#endregion
3175
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/parse.js
3176
- var parse = /* @__PURE__ */ _parse(ZodRealError);
3177
- var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3178
- var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3179
- var safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3180
- var encode = /* @__PURE__ */ _encode(ZodRealError);
3181
- var decode = /* @__PURE__ */ _decode(ZodRealError);
3182
- var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3183
- var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3184
- var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3185
- var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3186
- var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3187
- var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3188
- //#endregion
3189
- //#region node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
3190
- var _installedGroups = /* @__PURE__ */ new WeakMap();
3191
- function _installLazyMethods(inst, group, methods) {
3192
- const proto = Object.getPrototypeOf(inst);
3193
- let installed = _installedGroups.get(proto);
3194
- if (!installed) {
3195
- installed = /* @__PURE__ */ new Set();
3196
- _installedGroups.set(proto, installed);
3197
- }
3198
- if (installed.has(group)) return;
3199
- installed.add(group);
3200
- for (const key in methods) {
3201
- const fn = methods[key];
3202
- Object.defineProperty(proto, key, {
3203
- configurable: true,
3204
- enumerable: false,
3205
- get() {
3206
- const bound = fn.bind(this);
3207
- Object.defineProperty(this, key, {
3208
- configurable: true,
3209
- writable: true,
3210
- enumerable: true,
3211
- value: bound
3212
- });
3213
- return bound;
3214
- },
3215
- set(v) {
3216
- Object.defineProperty(this, key, {
3217
- configurable: true,
3218
- writable: true,
3219
- enumerable: true,
3220
- value: v
3221
- });
3222
- }
3223
- });
3224
- }
3225
- }
3226
- var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
3227
- $ZodType.init(inst, def);
3228
- Object.assign(inst["~standard"], { jsonSchema: {
3229
- input: createStandardJSONSchemaMethod(inst, "input"),
3230
- output: createStandardJSONSchemaMethod(inst, "output")
3231
- } });
3232
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3233
- inst.def = def;
3234
- inst.type = def.type;
3235
- Object.defineProperty(inst, "_def", { value: def });
3236
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3237
- inst.safeParse = (data, params) => safeParse(inst, data, params);
3238
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3239
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3240
- inst.spa = inst.safeParseAsync;
3241
- inst.encode = (data, params) => encode(inst, data, params);
3242
- inst.decode = (data, params) => decode(inst, data, params);
3243
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3244
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3245
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3246
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3247
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3248
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3249
- _installLazyMethods(inst, "ZodType", {
3250
- check(...chks) {
3251
- const def = this.def;
3252
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3253
- check: ch,
3254
- def: { check: "custom" },
3255
- onattach: []
3256
- } } : ch)] }), { parent: true });
3257
- },
3258
- with(...chks) {
3259
- return this.check(...chks);
3260
- },
3261
- clone(def, params) {
3262
- return clone(this, def, params);
3263
- },
3264
- brand() {
3265
- return this;
3266
- },
3267
- register(reg, meta) {
3268
- reg.add(this, meta);
3269
- return this;
3270
- },
3271
- refine(check, params) {
3272
- return this.check(refine(check, params));
3273
- },
3274
- superRefine(refinement, params) {
3275
- return this.check(superRefine(refinement, params));
3276
- },
3277
- overwrite(fn) {
3278
- return this.check(/* @__PURE__ */ _overwrite(fn));
3279
- },
3280
- optional() {
3281
- return optional(this);
3282
- },
3283
- exactOptional() {
3284
- return exactOptional(this);
3285
- },
3286
- nullable() {
3287
- return nullable(this);
3288
- },
3289
- nullish() {
3290
- return optional(nullable(this));
3291
- },
3292
- nonoptional(params) {
3293
- return nonoptional(this, params);
3294
- },
3295
- array() {
3296
- return array(this);
3297
- },
3298
- or(arg) {
3299
- return union([this, arg]);
3300
- },
3301
- and(arg) {
3302
- return intersection(this, arg);
3303
- },
3304
- transform(tx) {
3305
- return pipe(this, transform(tx));
3306
- },
3307
- default(d) {
3308
- return _default(this, d);
3309
- },
3310
- prefault(d) {
3311
- return prefault(this, d);
3312
- },
3313
- catch(params) {
3314
- return _catch(this, params);
3315
- },
3316
- pipe(target) {
3317
- return pipe(this, target);
3318
- },
3319
- readonly() {
3320
- return readonly(this);
3321
- },
3322
- describe(description) {
3323
- const cl = this.clone();
3324
- globalRegistry.add(cl, { description });
3325
- return cl;
3326
- },
3327
- meta(...args) {
3328
- if (args.length === 0) return globalRegistry.get(this);
3329
- const cl = this.clone();
3330
- globalRegistry.add(cl, args[0]);
3331
- return cl;
3332
- },
3333
- isOptional() {
3334
- return this.safeParse(void 0).success;
3335
- },
3336
- isNullable() {
3337
- return this.safeParse(null).success;
3338
- },
3339
- apply(fn) {
3340
- return fn(this);
3341
- }
3342
- });
3343
- Object.defineProperty(inst, "description", {
3344
- get() {
3345
- return globalRegistry.get(inst)?.description;
3346
- },
3347
- configurable: true
3348
- });
3349
- return inst;
3350
- });
3351
- /** @internal */
3352
- var _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3353
- $ZodString.init(inst, def);
3354
- ZodType.init(inst, def);
3355
- inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3356
- const bag = inst._zod.bag;
3357
- inst.format = bag.format ?? null;
3358
- inst.minLength = bag.minimum ?? null;
3359
- inst.maxLength = bag.maximum ?? null;
3360
- _installLazyMethods(inst, "_ZodString", {
3361
- regex(...args) {
3362
- return this.check(/* @__PURE__ */ _regex(...args));
3363
- },
3364
- includes(...args) {
3365
- return this.check(/* @__PURE__ */ _includes(...args));
3366
- },
3367
- startsWith(...args) {
3368
- return this.check(/* @__PURE__ */ _startsWith(...args));
3369
- },
3370
- endsWith(...args) {
3371
- return this.check(/* @__PURE__ */ _endsWith(...args));
3372
- },
3373
- min(...args) {
3374
- return this.check(/* @__PURE__ */ _minLength(...args));
3375
- },
3376
- max(...args) {
3377
- return this.check(/* @__PURE__ */ _maxLength(...args));
3378
- },
3379
- length(...args) {
3380
- return this.check(/* @__PURE__ */ _length(...args));
3381
- },
3382
- nonempty(...args) {
3383
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
3384
- },
3385
- lowercase(params) {
3386
- return this.check(/* @__PURE__ */ _lowercase(params));
3387
- },
3388
- uppercase(params) {
3389
- return this.check(/* @__PURE__ */ _uppercase(params));
3390
- },
3391
- trim() {
3392
- return this.check(/* @__PURE__ */ _trim());
3393
- },
3394
- normalize(...args) {
3395
- return this.check(/* @__PURE__ */ _normalize(...args));
3396
- },
3397
- toLowerCase() {
3398
- return this.check(/* @__PURE__ */ _toLowerCase());
3399
- },
3400
- toUpperCase() {
3401
- return this.check(/* @__PURE__ */ _toUpperCase());
3402
- },
3403
- slugify() {
3404
- return this.check(/* @__PURE__ */ _slugify());
3405
- }
3406
- });
3407
- });
3408
- var ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
3409
- $ZodString.init(inst, def);
3410
- _ZodString.init(inst, def);
3411
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3412
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3413
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3414
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3415
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3416
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3417
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3418
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3419
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3420
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3421
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3422
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3423
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3424
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3425
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3426
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3427
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3428
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3429
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3430
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3431
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3432
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3433
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3434
- inst.datetime = (params) => inst.check(datetime(params));
3435
- inst.date = (params) => inst.check(date(params));
3436
- inst.time = (params) => inst.check(time(params));
3437
- inst.duration = (params) => inst.check(duration(params));
3438
- });
3439
- function string(params) {
3440
- return /* @__PURE__ */ _string(ZodString, params);
3441
- }
3442
- var ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
3443
- $ZodStringFormat.init(inst, def);
3444
- _ZodString.init(inst, def);
3445
- });
3446
- var ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
3447
- $ZodEmail.init(inst, def);
3448
- ZodStringFormat.init(inst, def);
3449
- });
3450
- var ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
3451
- $ZodGUID.init(inst, def);
3452
- ZodStringFormat.init(inst, def);
3453
- });
3454
- var ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
3455
- $ZodUUID.init(inst, def);
3456
- ZodStringFormat.init(inst, def);
3457
- });
3458
- var ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
3459
- $ZodURL.init(inst, def);
3460
- ZodStringFormat.init(inst, def);
3461
- });
3462
- var ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
3463
- $ZodEmoji.init(inst, def);
3464
- ZodStringFormat.init(inst, def);
3465
- });
3466
- var ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
3467
- $ZodNanoID.init(inst, def);
3468
- ZodStringFormat.init(inst, def);
3469
- });
3470
- /**
3471
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
3472
- * (timestamps embedded in the id). Use {@link ZodCUID2} instead.
3473
- * See https://github.com/paralleldrive/cuid.
3474
- */
3475
- var ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
3476
- $ZodCUID.init(inst, def);
3477
- ZodStringFormat.init(inst, def);
3478
- });
3479
- var ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
3480
- $ZodCUID2.init(inst, def);
3481
- ZodStringFormat.init(inst, def);
3482
- });
3483
- var ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
3484
- $ZodULID.init(inst, def);
3485
- ZodStringFormat.init(inst, def);
3486
- });
3487
- var ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
3488
- $ZodXID.init(inst, def);
3489
- ZodStringFormat.init(inst, def);
3490
- });
3491
- var ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
3492
- $ZodKSUID.init(inst, def);
3493
- ZodStringFormat.init(inst, def);
3494
- });
3495
- var ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
3496
- $ZodIPv4.init(inst, def);
3497
- ZodStringFormat.init(inst, def);
3498
- });
3499
- var ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
3500
- $ZodIPv6.init(inst, def);
3501
- ZodStringFormat.init(inst, def);
3502
- });
3503
- var ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
3504
- $ZodCIDRv4.init(inst, def);
3505
- ZodStringFormat.init(inst, def);
3506
- });
3507
- var ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
3508
- $ZodCIDRv6.init(inst, def);
3509
- ZodStringFormat.init(inst, def);
3510
- });
3511
- var ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
3512
- $ZodBase64.init(inst, def);
3513
- ZodStringFormat.init(inst, def);
3514
- });
3515
- var ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
3516
- $ZodBase64URL.init(inst, def);
3517
- ZodStringFormat.init(inst, def);
3518
- });
3519
- var ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
3520
- $ZodE164.init(inst, def);
3521
- ZodStringFormat.init(inst, def);
3522
- });
3523
- var ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
3524
- $ZodJWT.init(inst, def);
3525
- ZodStringFormat.init(inst, def);
3526
- });
3527
- var ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
3528
- $ZodUnknown.init(inst, def);
3529
- ZodType.init(inst, def);
3530
- inst._zod.processJSONSchema = (ctx, json, params) => void 0;
3531
- });
3532
- function unknown() {
3533
- return /* @__PURE__ */ _unknown(ZodUnknown);
3534
- }
3535
- var ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
3536
- $ZodNever.init(inst, def);
3537
- ZodType.init(inst, def);
3538
- inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
3539
- });
3540
- function never(params) {
3541
- return /* @__PURE__ */ _never(ZodNever, params);
3542
- }
3543
- var ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
3544
- $ZodArray.init(inst, def);
3545
- ZodType.init(inst, def);
3546
- inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3547
- inst.element = def.element;
3548
- _installLazyMethods(inst, "ZodArray", {
3549
- min(n, params) {
3550
- return this.check(/* @__PURE__ */ _minLength(n, params));
3551
- },
3552
- nonempty(params) {
3553
- return this.check(/* @__PURE__ */ _minLength(1, params));
3554
- },
3555
- max(n, params) {
3556
- return this.check(/* @__PURE__ */ _maxLength(n, params));
3557
- },
3558
- length(n, params) {
3559
- return this.check(/* @__PURE__ */ _length(n, params));
3560
- },
3561
- unwrap() {
3562
- return this.element;
3563
- }
3564
- });
3565
- });
3566
- function array(element, params) {
3567
- return /* @__PURE__ */ _array(ZodArray, element, params);
3568
- }
3569
- var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
3570
- $ZodObjectJIT.init(inst, def);
3571
- ZodType.init(inst, def);
3572
- inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3573
- defineLazy(inst, "shape", () => {
3574
- return def.shape;
3575
- });
3576
- _installLazyMethods(inst, "ZodObject", {
3577
- keyof() {
3578
- return _enum(Object.keys(this._zod.def.shape));
3579
- },
3580
- catchall(catchall) {
3581
- return this.clone({
3582
- ...this._zod.def,
3583
- catchall
3584
- });
3585
- },
3586
- passthrough() {
3587
- return this.clone({
3588
- ...this._zod.def,
3589
- catchall: unknown()
3590
- });
3591
- },
3592
- loose() {
3593
- return this.clone({
3594
- ...this._zod.def,
3595
- catchall: unknown()
3596
- });
3597
- },
3598
- strict() {
3599
- return this.clone({
3600
- ...this._zod.def,
3601
- catchall: never()
3602
- });
3603
- },
3604
- strip() {
3605
- return this.clone({
3606
- ...this._zod.def,
3607
- catchall: void 0
3608
- });
3609
- },
3610
- extend(incoming) {
3611
- return extend(this, incoming);
3612
- },
3613
- safeExtend(incoming) {
3614
- return safeExtend(this, incoming);
3615
- },
3616
- merge(other) {
3617
- return merge(this, other);
3618
- },
3619
- pick(mask) {
3620
- return pick(this, mask);
3621
- },
3622
- omit(mask) {
3623
- return omit(this, mask);
3624
- },
3625
- partial(...args) {
3626
- return partial(ZodOptional, this, args[0]);
3627
- },
3628
- required(...args) {
3629
- return required(ZodNonOptional, this, args[0]);
3630
- }
3631
- });
3632
- });
3633
- function strictObject(shape, params) {
3634
- return new ZodObject({
3635
- type: "object",
3636
- shape,
3637
- catchall: never(),
3638
- ...normalizeParams(params)
3639
- });
3640
- }
3641
- function looseObject(shape, params) {
3642
- return new ZodObject({
3643
- type: "object",
3644
- shape,
3645
- catchall: unknown(),
3646
- ...normalizeParams(params)
3647
- });
3648
- }
3649
- var ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
3650
- $ZodUnion.init(inst, def);
3651
- ZodType.init(inst, def);
3652
- inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
3653
- inst.options = def.options;
3654
- });
3655
- function union(options, params) {
3656
- return new ZodUnion({
3657
- type: "union",
3658
- options,
3659
- ...normalizeParams(params)
3660
- });
3661
- }
3662
- var ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
3663
- ZodUnion.init(inst, def);
3664
- $ZodDiscriminatedUnion.init(inst, def);
3665
- });
3666
- function discriminatedUnion(discriminator, options, params) {
3667
- return new ZodDiscriminatedUnion({
3668
- type: "union",
3669
- options,
3670
- discriminator,
3671
- ...normalizeParams(params)
3672
- });
3673
- }
3674
- var ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
3675
- $ZodIntersection.init(inst, def);
3676
- ZodType.init(inst, def);
3677
- inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
3678
- });
3679
- function intersection(left, right) {
3680
- return new ZodIntersection({
3681
- type: "intersection",
3682
- left,
3683
- right
3684
- });
3685
- }
3686
- var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
3687
- $ZodRecord.init(inst, def);
3688
- ZodType.init(inst, def);
3689
- inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
3690
- inst.keyType = def.keyType;
3691
- inst.valueType = def.valueType;
3692
- });
3693
- function record(keyType, valueType, params) {
3694
- if (!valueType || !valueType._zod) return new ZodRecord({
3695
- type: "record",
3696
- keyType: string(),
3697
- valueType: keyType,
3698
- ...normalizeParams(valueType)
3699
- });
3700
- return new ZodRecord({
3701
- type: "record",
3702
- keyType,
3703
- valueType,
3704
- ...normalizeParams(params)
3705
- });
3706
- }
3707
- var ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
3708
- $ZodEnum.init(inst, def);
3709
- ZodType.init(inst, def);
3710
- inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3711
- inst.enum = def.entries;
3712
- inst.options = Object.values(def.entries);
3713
- const keys = new Set(Object.keys(def.entries));
3714
- inst.extract = (values, params) => {
3715
- const newEntries = {};
3716
- for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
3717
- else throw new Error(`Key ${value} not found in enum`);
3718
- return new ZodEnum({
3719
- ...def,
3720
- checks: [],
3721
- ...normalizeParams(params),
3722
- entries: newEntries
3723
- });
3724
- };
3725
- inst.exclude = (values, params) => {
3726
- const newEntries = { ...def.entries };
3727
- for (const value of values) if (keys.has(value)) delete newEntries[value];
3728
- else throw new Error(`Key ${value} not found in enum`);
3729
- return new ZodEnum({
3730
- ...def,
3731
- checks: [],
3732
- ...normalizeParams(params),
3733
- entries: newEntries
3734
- });
3735
- };
3736
- });
3737
- function _enum(values, params) {
3738
- return new ZodEnum({
3739
- type: "enum",
3740
- entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
3741
- ...normalizeParams(params)
3742
- });
3743
- }
3744
- var ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
3745
- $ZodLiteral.init(inst, def);
3746
- ZodType.init(inst, def);
3747
- inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
3748
- inst.values = new Set(def.values);
3749
- Object.defineProperty(inst, "value", { get() {
3750
- if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
3751
- return def.values[0];
3752
- } });
3753
- });
3754
- function literal(value, params) {
3755
- return new ZodLiteral({
3756
- type: "literal",
3757
- values: Array.isArray(value) ? value : [value],
3758
- ...normalizeParams(params)
3759
- });
3760
- }
3761
- var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3762
- $ZodTransform.init(inst, def);
3763
- ZodType.init(inst, def);
3764
- inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
3765
- inst._zod.parse = (payload, _ctx) => {
3766
- if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
3767
- payload.addIssue = (issue$1) => {
3768
- if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
3769
- else {
3770
- const _issue = issue$1;
3771
- if (_issue.fatal) _issue.continue = false;
3772
- _issue.code ?? (_issue.code = "custom");
3773
- _issue.input ?? (_issue.input = payload.value);
3774
- _issue.inst ?? (_issue.inst = inst);
3775
- payload.issues.push(issue(_issue));
3776
- }
3777
- };
3778
- const output = def.transform(payload.value, payload);
3779
- if (output instanceof Promise) return output.then((output) => {
3780
- payload.value = output;
3781
- payload.fallback = true;
3782
- return payload;
3783
- });
3784
- payload.value = output;
3785
- payload.fallback = true;
3786
- return payload;
3787
- };
3788
- });
3789
- function transform(fn) {
3790
- return new ZodTransform({
3791
- type: "transform",
3792
- transform: fn
3793
- });
3794
- }
3795
- var ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
3796
- $ZodOptional.init(inst, def);
3797
- ZodType.init(inst, def);
3798
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3799
- inst.unwrap = () => inst._zod.def.innerType;
3800
- });
3801
- function optional(innerType) {
3802
- return new ZodOptional({
3803
- type: "optional",
3804
- innerType
3805
- });
3806
- }
3807
- var ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
3808
- $ZodExactOptional.init(inst, def);
3809
- ZodType.init(inst, def);
3810
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3811
- inst.unwrap = () => inst._zod.def.innerType;
3812
- });
3813
- function exactOptional(innerType) {
3814
- return new ZodExactOptional({
3815
- type: "optional",
3816
- innerType
3817
- });
3818
- }
3819
- var ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
3820
- $ZodNullable.init(inst, def);
3821
- ZodType.init(inst, def);
3822
- inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
3823
- inst.unwrap = () => inst._zod.def.innerType;
3824
- });
3825
- function nullable(innerType) {
3826
- return new ZodNullable({
3827
- type: "nullable",
3828
- innerType
3829
- });
3830
- }
3831
- var ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
3832
- $ZodDefault.init(inst, def);
3833
- ZodType.init(inst, def);
3834
- inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
3835
- inst.unwrap = () => inst._zod.def.innerType;
3836
- inst.removeDefault = inst.unwrap;
3837
- });
3838
- function _default(innerType, defaultValue) {
3839
- return new ZodDefault({
3840
- type: "default",
3841
- innerType,
3842
- get defaultValue() {
3843
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3844
- }
3845
- });
3846
- }
3847
- var ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
3848
- $ZodPrefault.init(inst, def);
3849
- ZodType.init(inst, def);
3850
- inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
3851
- inst.unwrap = () => inst._zod.def.innerType;
3852
- });
3853
- function prefault(innerType, defaultValue) {
3854
- return new ZodPrefault({
3855
- type: "prefault",
3856
- innerType,
3857
- get defaultValue() {
3858
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3859
- }
3860
- });
3861
- }
3862
- var ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
3863
- $ZodNonOptional.init(inst, def);
3864
- ZodType.init(inst, def);
3865
- inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
3866
- inst.unwrap = () => inst._zod.def.innerType;
3867
- });
3868
- function nonoptional(innerType, params) {
3869
- return new ZodNonOptional({
3870
- type: "nonoptional",
3871
- innerType,
3872
- ...normalizeParams(params)
3873
- });
3874
- }
3875
- var ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
3876
- $ZodCatch.init(inst, def);
3877
- ZodType.init(inst, def);
3878
- inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
3879
- inst.unwrap = () => inst._zod.def.innerType;
3880
- inst.removeCatch = inst.unwrap;
3881
- });
3882
- function _catch(innerType, catchValue) {
3883
- return new ZodCatch({
3884
- type: "catch",
3885
- innerType,
3886
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
3887
- });
3888
- }
3889
- var ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
3890
- $ZodPipe.init(inst, def);
3891
- ZodType.init(inst, def);
3892
- inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
3893
- inst.in = def.in;
3894
- inst.out = def.out;
3895
- });
3896
- function pipe(in_, out) {
3897
- return new ZodPipe({
3898
- type: "pipe",
3899
- in: in_,
3900
- out
3901
- });
3902
- }
3903
- var ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
3904
- $ZodReadonly.init(inst, def);
3905
- ZodType.init(inst, def);
3906
- inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
3907
- inst.unwrap = () => inst._zod.def.innerType;
3908
- });
3909
- function readonly(innerType) {
3910
- return new ZodReadonly({
3911
- type: "readonly",
3912
- innerType
3913
- });
3914
- }
3915
- var ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
3916
- $ZodCustom.init(inst, def);
3917
- ZodType.init(inst, def);
3918
- inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
3919
- });
3920
- function refine(fn, _params = {}) {
3921
- return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
3922
- }
3923
- function superRefine(fn, params) {
3924
- return /* @__PURE__ */ _superRefine(fn, params);
3925
- }
3926
- //#endregion
7
+ import { pluginRoot } from "@holycodex/plugin";
8
+ import { Buffer } from "node:buffer";
3927
9
  //#region packages/cli/src/catalog.ts
3928
- var VERSION = "0.7.1-dev.29611508860.1";
10
+ var VERSION = "0.7.1";
3929
11
  var SKILLS = [
3930
12
  "ast-grep",
3931
13
  "caveman",
@@ -3944,156 +26,45 @@ var SKILLS = [
3944
26
  "rules",
3945
27
  "security-research"
3946
28
  ];
3947
- var AGENTS = _enum([
29
+ var AGENTS = [
3948
30
  "explorer",
3949
31
  "librarian",
3950
32
  "worker"
3951
- ]).options;
3952
- var PlanNameSchema = _enum([
3953
- "go",
3954
- "plus",
3955
- "pro-5x",
3956
- "pro-20x"
3957
- ]);
3958
- var PLAN_NAMES = PlanNameSchema.options;
3959
- _enum([
3960
- "low",
3961
- "medium",
3962
- "high",
3963
- "xhigh"
3964
- ]);
3965
- var ModelRouteSchema = discriminatedUnion("model", [
3966
- strictObject({
3967
- model: literal("gpt-5.6-luna"),
3968
- reasoningEffort: _enum(["low", "medium"])
3969
- }),
3970
- strictObject({
3971
- model: literal("gpt-5.6-terra"),
3972
- reasoningEffort: _enum([
3973
- "low",
3974
- "medium",
3975
- "high"
3976
- ])
3977
- }),
3978
- strictObject({
3979
- model: literal("gpt-5.6-sol"),
3980
- reasoningEffort: _enum([
3981
- "medium",
3982
- "high",
3983
- "xhigh"
3984
- ])
3985
- })
3986
- ]);
3987
- var RoutingPresetSchema = strictObject({
3988
- root: ModelRouteSchema,
3989
- agents: strictObject({
3990
- explorer: ModelRouteSchema,
3991
- librarian: ModelRouteSchema,
3992
- worker: ModelRouteSchema
3993
- })
3994
- });
3995
- var ModelRoutingPlansSchema = strictObject({
3996
- go: RoutingPresetSchema,
3997
- plus: RoutingPresetSchema,
3998
- "pro-5x": RoutingPresetSchema,
3999
- "pro-20x": RoutingPresetSchema
4000
- });
4001
- var DEFAULT_PLAN = "plus";
4002
- var MODEL_ROUTING_PLANS = ModelRoutingPlansSchema.parse({
4003
- go: {
4004
- root: {
4005
- model: "gpt-5.6-terra",
4006
- reasoningEffort: "medium"
4007
- },
4008
- agents: {
4009
- explorer: {
4010
- model: "gpt-5.6-terra",
4011
- reasoningEffort: "low"
4012
- },
4013
- librarian: {
4014
- model: "gpt-5.6-terra",
4015
- reasoningEffort: "low"
4016
- },
4017
- worker: {
4018
- model: "gpt-5.6-terra",
4019
- reasoningEffort: "medium"
4020
- }
4021
- }
4022
- },
4023
- plus: {
4024
- root: {
4025
- model: "gpt-5.6-sol",
4026
- reasoningEffort: "medium"
4027
- },
4028
- agents: {
4029
- explorer: {
4030
- model: "gpt-5.6-luna",
4031
- reasoningEffort: "low"
4032
- },
4033
- librarian: {
4034
- model: "gpt-5.6-luna",
4035
- reasoningEffort: "low"
4036
- },
4037
- worker: {
4038
- model: "gpt-5.6-terra",
4039
- reasoningEffort: "high"
4040
- }
4041
- }
33
+ ];
34
+ var ROOT_MODEL = {
35
+ model: "gpt-5.6-sol",
36
+ reasoningEffort: "medium"
37
+ };
38
+ var AGENT_MODELS = {
39
+ explorer: {
40
+ model: "gpt-5.6-luna",
41
+ reasoningEffort: "low"
4042
42
  },
4043
- "pro-5x": {
4044
- root: {
4045
- model: "gpt-5.6-sol",
4046
- reasoningEffort: "high"
4047
- },
4048
- agents: {
4049
- explorer: {
4050
- model: "gpt-5.6-terra",
4051
- reasoningEffort: "high"
4052
- },
4053
- librarian: {
4054
- model: "gpt-5.6-terra",
4055
- reasoningEffort: "high"
4056
- },
4057
- worker: {
4058
- model: "gpt-5.6-sol",
4059
- reasoningEffort: "medium"
4060
- }
4061
- }
43
+ librarian: {
44
+ model: "gpt-5.6-luna",
45
+ reasoningEffort: "low"
4062
46
  },
4063
- "pro-20x": {
4064
- root: {
4065
- model: "gpt-5.6-sol",
4066
- reasoningEffort: "xhigh"
4067
- },
4068
- agents: {
4069
- explorer: {
4070
- model: "gpt-5.6-sol",
4071
- reasoningEffort: "medium"
4072
- },
4073
- librarian: {
4074
- model: "gpt-5.6-sol",
4075
- reasoningEffort: "medium"
4076
- },
4077
- worker: {
4078
- model: "gpt-5.6-sol",
4079
- reasoningEffort: "high"
4080
- }
4081
- }
47
+ worker: {
48
+ model: "gpt-5.6-terra",
49
+ reasoningEffort: "high"
4082
50
  }
4083
- });
4084
- MODEL_ROUTING_PLANS[DEFAULT_PLAN].root;
4085
- MODEL_ROUTING_PLANS[DEFAULT_PLAN].agents;
4086
- function managedAgentModels(agent) {
4087
- const routes = PLAN_NAMES.map((plan) => MODEL_ROUTING_PLANS[plan].agents[agent]);
4088
- return agent === "worker" ? [...routes, {
51
+ };
52
+ var MANAGED_AGENT_MODEL_HISTORY = {
53
+ explorer: [{
54
+ model: "gpt-5.6-luna",
55
+ reasoningEffort: "low"
56
+ }],
57
+ librarian: [{
58
+ model: "gpt-5.6-luna",
59
+ reasoningEffort: "low"
60
+ }],
61
+ worker: [{
4089
62
  model: "gpt-5.6-luna",
4090
63
  reasoningEffort: "medium"
4091
- }] : routes;
4092
- }
4093
- var MANAGED_AGENT_MODEL_HISTORY = {
4094
- explorer: managedAgentModels("explorer"),
4095
- librarian: managedAgentModels("librarian"),
4096
- worker: managedAgentModels("worker")
64
+ }, {
65
+ model: "gpt-5.6-terra",
66
+ reasoningEffort: "high"
67
+ }]
4097
68
  };
4098
69
  var GENERATED_RUNTIMES = [
4099
70
  "bootstrap.js",
@@ -4126,7 +97,7 @@ function effectiveMcpServers(platform) {
4126
97
  }
4127
98
  };
4128
99
  }
4129
- /** Returns packaged runtime files required on a platform. */
100
+ /** Reads and validates d package runtimes. */
4130
101
  function requiredPackageRuntimes(platform) {
4131
102
  return platform === "win32" ? GENERATED_RUNTIMES : GENERATED_RUNTIMES.filter((file) => file !== "git-bash.js");
4132
103
  }
@@ -4335,241 +306,93 @@ function appendOutput(state, chunk, limit) {
4335
306
  function outputText(state) {
4336
307
  return state.truncated ? `${state.head}${TRUNCATED_MARKER}${state.tail}` : state.head;
4337
308
  }
4338
- //#endregion
4339
- //#region packages/cli/src/toml.ts
4340
- var TOML_TABLE = /^[ \t]*(?:\[[^\]\r\n]+\]|\[\[[^\]\r\n]+\]\])[ \t]*(?:#.*)?$/m;
4341
- /** Reads a root TOML string value. */
4342
- function rootTomlString(input, key) {
4343
- const table = TOML_TABLE.exec(input);
4344
- const root = table === null ? input : input.slice(0, table.index);
4345
- const match = new RegExp(String.raw`^[ \t]*${escapeRegExp(key)}[ \t]*=[ \t]*(?:"((?:\\.|[^"\\\r\n])*)"|'([^'\r\n]*)')[ \t]*(?:#.*)?$`, "m").exec(root);
4346
- if (match === null) return void 0;
4347
- if (match[2] !== void 0) return match[2];
4348
- try {
4349
- return string().safeParse(JSON.parse(`"${match[1] ?? ""}"`)).data;
4350
- } catch {
4351
- return;
4352
- }
4353
- }
4354
- /** Reads a root TOML string array. */
4355
- function rootTomlStringArray(input, key) {
4356
- return parseRootTomlStringArray(input, key)?.items;
4357
- }
4358
- /** Reads the source text of a root TOML string array. */
4359
- function rootTomlStringArraySource(input, key) {
4360
- return parseRootTomlStringArray(input, key)?.source;
4361
- }
4362
- function parseRootTomlStringArray(input, key) {
4363
- const table = TOML_TABLE.exec(input);
4364
- const root = table === null ? input : input.slice(0, table.index);
4365
- const assignment = new RegExp(String.raw`^[ \t]*${escapeRegExp(key)}[ \t]*=`, "m").exec(root);
4366
- if (assignment === null) return void 0;
4367
- const start = root.indexOf("[", assignment.index + assignment[0].length);
4368
- if (start < 0) return void 0;
4369
- const items = [];
4370
- let quote;
4371
- let raw = "";
4372
- let escaped = false;
4373
- let comment = false;
4374
- for (let index = start + 1; index < root.length; index += 1) {
4375
- const character = root[index];
4376
- if (comment) {
4377
- if (character === "\n") comment = false;
4378
- continue;
4379
- }
4380
- if (quote === "\"") {
4381
- if (escaped) {
4382
- raw += character;
4383
- escaped = false;
4384
- } else if (character === "\\") {
4385
- raw += character;
4386
- escaped = true;
4387
- } else if (character === "\"") {
4388
- try {
4389
- const parsed = string().safeParse(JSON.parse(`"${raw}"`));
4390
- if (!parsed.success) return void 0;
4391
- items.push(parsed.data);
4392
- } catch {
4393
- return;
4394
- }
4395
- quote = void 0;
4396
- raw = "";
4397
- } else raw += character;
4398
- continue;
4399
- }
4400
- if (quote === "'") {
4401
- if (character === "'") {
4402
- items.push(raw);
4403
- quote = void 0;
4404
- raw = "";
4405
- } else raw += character;
4406
- continue;
4407
- }
4408
- if (character === "#") comment = true;
4409
- else if (character === "\"" || character === "'") quote = character;
4410
- else if (character === "]") {
4411
- const suffix = /^[ \t]*(?:#.*)?(?=\r?\n|$)/.exec(root.slice(index + 1))?.[0] ?? "";
4412
- return {
4413
- source: root.slice(assignment.index, index + 1 + suffix.length),
4414
- items
4415
- };
4416
- }
4417
- }
4418
- }
4419
- function escapeRegExp(value) {
4420
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4421
- }
4422
- //#endregion
4423
- //#region packages/cli/src/config.ts
4424
- var START = "# >>> holycodex managed >>>";
4425
- var END = "# <<< holycodex managed <<<";
4426
- var ORIGINAL_ROOT = "# holycodex original root: ";
4427
- var ORIGINAL_TABLE_KEY = "# holycodex original table key: ";
4428
- var PLAN_PREFIX = "# holycodex plan: ";
4429
- var OLD_NAMESPACES = [
4430
- "marketplaces.sisyphuslabs",
4431
- "plugins.\"omo@sisyphuslabs\"",
4432
- "marketplaces.lazycodex",
4433
- "plugins.\"omo@lazycodex\"",
4434
- "marketplaces.code-yeongyu-codex-plugins",
4435
- "plugins.\"omo@code-yeongyu-codex-plugins\"",
4436
- "agents.plan",
4437
- "agents.metis",
4438
- "agents.momus",
4439
- "agents.oracle",
4440
- "agents.sisyphus",
4441
- "agents.prometheus",
4442
- "agents.atlas",
4443
- "agents.hephaestus",
4444
- "hooks.state.\"omo@sisyphuslabs",
4445
- "hooks.state.\"omo@lazycodex",
4446
- "hooks.state.\"omo@code-yeongyu-codex-plugins"
4447
- ];
4448
- /** Removes managed. */
4449
- function removeManaged(input) {
4450
- const escapedStart = START.replaceAll(">", "\\>");
4451
- const escapedEnd = END.replaceAll("<", "\\<");
4452
- return input.replace(new RegExp(`${escapedStart}([\\s\\S]*?)${escapedEnd}(?:\\r?\\n){0,2}`, "g"), (_match, body) => {
4453
- const encoded = body.match(/^# holycodex original root: ([A-Za-z0-9+/=]+)$/m)?.[1];
4454
- if (encoded !== void 0) return `${Buffer.from(encoded, "base64").toString("utf8")}\n`;
4455
- const tableKey = body.match(/^# holycodex original table key: ([A-Za-z0-9+/=]+)$/m)?.[1];
4456
- return tableKey === void 0 ? "" : `${Buffer.from(tableKey, "base64").toString("utf8")}\n`;
4457
- }).trim();
4458
- }
4459
- /** Removes legacy omo. */
4460
- function removeLegacyOmo(input) {
4461
- return input.split(/(?=^\s*\[)/m).filter((section) => {
4462
- const header = /^\s*\[([^\]]+)]/.exec(section)?.[1];
4463
- if (header === void 0) return true;
4464
- if (OLD_NAMESPACES.some((name) => header === name || header.startsWith(`${name}.`) || name.includes("\"omo@") && header.startsWith(name))) return false;
4465
- return ![
4466
- "agents.explorer",
4467
- "agents.librarian",
4468
- "agents.worker"
4469
- ].some((name) => header === name || header.startsWith(`${name}.`)) || !/(?:sisyphuslabs|omo@|oh-my|code-yeongyu)/i.test(section);
4470
- }).join("").trimEnd();
4471
- }
4472
- function injectTableKey(input, table, key, value) {
4473
- const match = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*(?:#.*)?$`, "m").exec(input);
4474
- const tail = match === null ? "" : input.slice(match.index + match[0].length);
4475
- const tableEnd = nextTableBoundary(tail);
4476
- const tableBody = tableEnd < 0 ? tail : tail.slice(0, tableEnd);
4477
- const originalKey = new RegExp(`^[ \\t]*${key}[ \\t]*=.*$`, "m").exec(tableBody)?.[0];
4478
- const managed = `${START}\n${originalKey === void 0 ? "" : `${ORIGINAL_TABLE_KEY}${Buffer.from(originalKey).toString("base64")}\n`}${key} = ${value}\n${END}`;
4479
- if (match === null) return `${input.trimEnd()}\n\n${START}\n[${table}]\n${key} = ${value}\n${END}`.trim();
4480
- const bodyStart = match.index + match[0].length;
4481
- const next = nextTableBoundary(input.slice(bodyStart));
4482
- const bodyEnd = next < 0 ? input.length : bodyStart + next;
4483
- const cleanedBody = input.slice(bodyStart, bodyEnd).replace(new RegExp(`^\\s*${key}\\s*=.*\\r?\\n?`, "gm"), "").trim();
4484
- const suffix = input.slice(bodyEnd).trimStart();
4485
- return `${input.slice(0, bodyStart)}\n${cleanedBody ? `${cleanedBody}\n` : ""}${managed}${suffix ? `\n${suffix}` : ""}`.trim();
4486
- }
4487
- function nextTableBoundary(input) {
4488
- const header = /^\s*\[/m.exec(input)?.index ?? -1;
4489
- const managedHeader = /^# >>> holycodex managed >>>\r?\n\s*\[/m.exec(input)?.index ?? -1;
4490
- if (header < 0) return managedHeader;
4491
- if (managedHeader < 0) return header;
4492
- return Math.min(header, managedHeader);
4493
- }
4494
- function rootValue(input, key) {
4495
- if (key === "status_line") return rootTomlStringArraySource(input, key);
4496
- return new RegExp(`^\\s*${key}\\s*=.*$`, "m").exec(input)?.[0];
4497
- }
4498
- function removeRootValue(input, value) {
4499
- return value === void 0 ? input : input.replace(value, "");
4500
- }
4501
- function rootPreferences(plan) {
4502
- const root = MODEL_ROUTING_PLANS[plan].root;
4503
- return [
4504
- ["model", `model = "${root.model}"`],
4505
- ["model_reasoning_effort", `model_reasoning_effort = "${root.reasoningEffort}"`],
4506
- ["model_verbosity", "model_verbosity = \"low\""]
4507
- ];
309
+ //#endregion
310
+ //#region packages/cli/src/toml.ts
311
+ var TOML_TABLE = /^[ \t]*(?:\[[^\]\r\n]+\]|\[\[[^\]\r\n]+\]\])[ \t]*(?:#.*)?$/m;
312
+ /** Reads a root TOML string value. */
313
+ function rootTomlString(input, key) {
314
+ const table = TOML_TABLE.exec(input);
315
+ const root = table === null ? input : input.slice(0, table.index);
316
+ const match = new RegExp(String.raw`^[ \t]*${escapeRegExp(key)}[ \t]*=[ \t]*(?:"((?:\\.|[^"\\\r\n])*)"|'([^'\r\n]*)')[ \t]*(?:#.*)?$`, "m").exec(root);
317
+ if (match === null) return void 0;
318
+ if (match[2] !== void 0) return match[2];
319
+ try {
320
+ const parsed = JSON.parse(`"${match[1] ?? ""}"`);
321
+ return typeof parsed === "string" ? parsed : void 0;
322
+ } catch {
323
+ return;
324
+ }
4508
325
  }
4509
- /** Reads the explicitly recorded model routing plan from managed configuration. */
4510
- function readManagedPlan(input) {
4511
- const value = new RegExp(`^${PLAN_PREFIX}(.+)$`, "m").exec(input)?.[1]?.trim();
4512
- return PLAN_NAMES.find((plan) => plan === value);
326
+ /** Reads a root TOML string array. */
327
+ function rootTomlStringArray(input, key) {
328
+ return parseRootTomlStringArray(input, key)?.items;
4513
329
  }
4514
- function preserveManagedRootPreferences(input, base) {
4515
- const managedRoot = new RegExp(`^${START}\\r?\\n([\\s\\S]*?)^${END}\\r?$`, "m").exec(input)?.[1];
4516
- if (managedRoot === void 0) return base;
4517
- const previousPlan = readManagedPlan(managedRoot) ?? "plus";
4518
- const firstTable = base.search(/^\s*\[/m);
4519
- const root = firstTable < 0 ? base : base.slice(0, firstTable);
4520
- const tables = firstTable < 0 ? "" : base.slice(firstTable);
4521
- let updatedRoot = root.trim();
4522
- for (const [key, fallback] of rootPreferences(previousPlan)) {
4523
- const live = rootValue(managedRoot, key)?.trim();
4524
- if (live === void 0 || live === (rootValue(root, key)?.trim() ?? fallback)) continue;
4525
- updatedRoot = removeRootValue(updatedRoot, rootValue(updatedRoot, key)).trim();
4526
- updatedRoot = `${updatedRoot}${updatedRoot ? "\n" : ""}${live}`;
4527
- }
4528
- if (updatedRoot === root.trim()) return base;
4529
- return `${updatedRoot}${tables ? `\n${tables.trimStart()}` : ""}`;
330
+ /** Reads the source text of a root TOML string array. */
331
+ function rootTomlStringArraySource(input, key) {
332
+ return parseRootTomlStringArray(input, key)?.source;
4530
333
  }
4531
- function mergedStatusLine(original) {
4532
- if (original === void 0) return "[\"model-with-reasoning\", \"context-remaining\", \"current-dir\"]";
4533
- const items = rootTomlStringArray(original, "status_line") ?? [];
4534
- if (!items.includes("context-remaining")) items.push("context-remaining");
4535
- return `[${items.map((item) => JSON.stringify(item)).join(", ")}]`;
334
+ function parseRootTomlStringArray(input, key) {
335
+ const table = TOML_TABLE.exec(input);
336
+ const root = table === null ? input : input.slice(0, table.index);
337
+ const assignment = new RegExp(String.raw`^[ \t]*${escapeRegExp(key)}[ \t]*=`, "m").exec(root);
338
+ if (assignment === null) return void 0;
339
+ const start = root.indexOf("[", assignment.index + assignment[0].length);
340
+ if (start < 0) return void 0;
341
+ const items = [];
342
+ let quote;
343
+ let raw = "";
344
+ let escaped = false;
345
+ let comment = false;
346
+ for (let index = start + 1; index < root.length; index += 1) {
347
+ const character = root[index];
348
+ if (comment) {
349
+ if (character === "\n") comment = false;
350
+ continue;
351
+ }
352
+ if (quote === "\"") {
353
+ if (escaped) {
354
+ raw += character;
355
+ escaped = false;
356
+ } else if (character === "\\") {
357
+ raw += character;
358
+ escaped = true;
359
+ } else if (character === "\"") {
360
+ try {
361
+ const parsed = JSON.parse(`"${raw}"`);
362
+ if (typeof parsed !== "string") return void 0;
363
+ items.push(parsed);
364
+ } catch {
365
+ return;
366
+ }
367
+ quote = void 0;
368
+ raw = "";
369
+ } else raw += character;
370
+ continue;
371
+ }
372
+ if (quote === "'") {
373
+ if (character === "'") {
374
+ items.push(raw);
375
+ quote = void 0;
376
+ raw = "";
377
+ } else raw += character;
378
+ continue;
379
+ }
380
+ if (character === "#") comment = true;
381
+ else if (character === "\"" || character === "'") quote = character;
382
+ else if (character === "]") {
383
+ const suffix = /^[ \t]*(?:#.*)?(?=\r?\n|$)/.exec(root.slice(index + 1))?.[0] ?? "";
384
+ return {
385
+ source: root.slice(assignment.index, index + 1 + suffix.length),
386
+ items
387
+ };
388
+ }
389
+ }
4536
390
  }
4537
- /** Installs config. */
4538
- function installConfig(input, mode, _platform, plan = DEFAULT_PLAN) {
4539
- const base = preserveManagedRootPreferences(input, removeLegacyOmo(removeManaged(input)));
4540
- const firstTable = base.search(/^\s*\[/m);
4541
- const root = firstTable < 0 ? base : base.slice(0, firstTable);
4542
- const tables = firstTable < 0 ? "" : base.slice(firstTable);
4543
- const controlled = [
4544
- "approval_policy",
4545
- "sandbox_mode",
4546
- "max_concurrent_threads_per_session",
4547
- "status_line"
4548
- ].map((key) => rootValue(root, key));
4549
- const originalRoot = root.trim();
4550
- const preservedRoot = controlled.reduce(removeRootValue, root).trim();
4551
- const hasModel = /^\s*model\s*=/m.test(preservedRoot);
4552
- const hasEffort = /^\s*model_reasoning_effort\s*=/m.test(preservedRoot);
4553
- const hasVerbosity = /^\s*model_verbosity\s*=/m.test(preservedRoot);
4554
- const rootRoute = MODEL_ROUTING_PLANS[plan].root;
4555
- const model = hasModel ? "" : `model = "${rootRoute.model}"\n`;
4556
- const effort = hasEffort ? "" : `model_reasoning_effort = "${rootRoute.reasoningEffort}"\n`;
4557
- const verbosity = hasVerbosity ? "" : "model_verbosity = \"low\"\n";
4558
- const approval = mode === "default" ? "on-request" : "never";
4559
- const sandbox = mode === "dangerous" ? "danger-full-access" : "workspace-write";
4560
- let configured = `${`${START}\n${PLAN_PREFIX}${plan}\n${originalRoot ? `${ORIGINAL_ROOT}${Buffer.from(originalRoot).toString("base64")}\n` : ""}${model}${effort}${verbosity}${preservedRoot ? `${preservedRoot}\n` : ""}approval_policy = "${approval}"\nsandbox_mode = "${sandbox}"\nstatus_line = ${mergedStatusLine(controlled[3])}\n${END}`}${tables ? `\n\n${tables}` : ""}`;
4561
- configured = injectTableKey(configured, "features", "default_mode_request_user_input", "true");
4562
- configured = injectTableKey(configured, "features", "multi_agent", "true");
4563
- configured = injectTableKey(configured, "agents", "max_threads", "2");
4564
- configured = injectTableKey(configured, "agents", "max_depth", "1");
4565
- if (mode !== "dangerous") configured = injectTableKey(configured, "sandbox_workspace_write", "network_access", "true");
4566
- for (const agent of AGENTS) configured = injectTableKey(configured, `agents.${agent}`, "config_file", `"holycodex/agents/${agent}.toml"`);
4567
- const plugin = `${START}\n[marketplaces.holycodex]\nsource = "https://github.com/davidbasilefilho/holycodex.git"\n\n[plugins."holycodex@holycodex"]\nenabled = true\n${END}`;
4568
- return `${configured.trim()}\n\n${plugin}\n`;
391
+ function escapeRegExp(value) {
392
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4569
393
  }
4570
394
  //#endregion
4571
395
  //#region packages/cli/src/doctor.ts
4572
- var McpManifestSchema = looseObject({ mcpServers: record(string(), record(string(), unknown())) });
4573
396
  async function runCommand(name, args, platform) {
4574
397
  const result = await runManagedProcess({
4575
398
  command: name,
@@ -4677,9 +500,9 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
4677
500
  checks.push(missing.length === 0 ? check("package", "ok", "package-ready", `Plugin ${VERSION}, generated runtime, hooks, three agents, and ${SKILLS.length} skills are present.`) : check("package", "error", "package-incomplete", `Missing ${missing.join(", ")}.`, "Reinstall HolyCodex."));
4678
501
  let mcp;
4679
502
  try {
4680
- mcp = McpManifestSchema.parse(JSON.parse(await readFile(join(pluginRoot, ".mcp.json"), "utf8")));
503
+ mcp = JSON.parse(await readFile(join(pluginRoot, ".mcp.json"), "utf8"));
4681
504
  } catch (error) {
4682
- checks.push(check("mcp-config", "error", "malformed-mcp-config", error instanceof ZodError ? "Invalid MCP JSON structure." : error instanceof Error ? error.message : "Invalid MCP JSON.", "Reinstall HolyCodex."));
505
+ checks.push(check("mcp-config", "error", "malformed-mcp-config", error instanceof Error ? error.message : "Invalid MCP JSON.", "Reinstall HolyCodex."));
4683
506
  }
4684
507
  const servers = mcp?.mcpServers;
4685
508
  const requiredMcps = runtime.platform === "win32" ? ["git_bash", "lsp"] : ["lsp"];
@@ -4703,7 +526,7 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
4703
526
  "apiKey"
4704
527
  ].some((key) => key in context7);
4705
528
  if (context7 === void 0) checks.push(check("context7-config", "error", "missing-context7", "Context7 is not configured.", "Reinstall HolyCodex."));
4706
- else if (string().safeParse(context7.url).success) checks.push(check("context7-config", "error", "obsolete-context7-remote", "Context7 still uses a hosted URL.", "Reinstall to use local bunx Context7."));
529
+ else if (typeof context7.url === "string") checks.push(check("context7-config", "error", "obsolete-context7-remote", "Context7 still uses a hosted URL.", "Reinstall to use local bunx Context7."));
4707
530
  else if (obsoleteAuth) checks.push(check("context7-config", "error", "obsolete-context7-auth", "Context7 contains obsolete authentication settings.", "Remove auth settings and reinstall."));
4708
531
  else if (expectedContext7 === void 0 || !mcpConfigMatches(context7, expectedContext7)) checks.push(check("context7-config", "error", "invalid-context7-config", "Context7 launch configuration is stale or contains unsupported settings.", "Repair .mcp.json or reinstall."));
4709
532
  else checks.push(check("context7-config", "ok", "local-context7-config", "Local no-auth Context7 is configured."));
@@ -4726,8 +549,6 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
4726
549
  checks.push(check("codex-config", "error", "missing-codex-config", `Missing ${configPath}.`, "Run holycodex install."));
4727
550
  }
4728
551
  const mode = autonomy(config);
4729
- const plan = readManagedPlan(config);
4730
- checks.push(plan === void 0 ? check("routing-plan", "error", "routing-plan-missing", "No managed model routing plan is recorded.", "Rerun holycodex install.") : check("routing-plan", "ok", "routing-plan-ready", `Model routing plan ${plan} is active.`));
4731
552
  checks.push(mode === "unknown" ? check("autonomy", "error", "invalid-autonomy-config", "Approval, sandbox, and network settings do not match a supported mode.", "Rerun install with the intended autonomy flag.") : mode === "dangerous" ? check("autonomy", "warning", "dangerous-autonomy", "Explicit dangerous autonomy is active; workspace containment is removed.") : check("autonomy", "ok", `${mode}-ready`, mode === "safe-workspace" ? "Safe workspace autonomy is active." : "Approval-free workspace autonomy is active."));
4732
553
  checks.push(tableBoolean(config, "features", "default_mode_request_user_input") === true ? check("user-input", "ok", "user-input-ready", "default_mode_request_user_input is enabled.") : check("user-input", "error", "user-input-disabled", "default_mode_request_user_input is not enabled.", "Rerun holycodex install."));
4733
554
  checks.push(rootTomlStringArray(config, "status_line")?.includes("context-remaining") === true ? check("context-visibility", "warning", "context-visible-support-unverified", "status_line includes context-remaining. Current official Codex config documents this item, but publishes no minimum compatible Codex version.") : check("context-visibility", "error", "context-hidden", "status_line does not include context-remaining.", "Rerun holycodex install."));
@@ -4736,12 +557,12 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
4736
557
  const agentModelFailures = [];
4737
558
  for (const agent of AGENTS) try {
4738
559
  const text = await readFile(join(agentRoot, `${agent}.toml`), "utf8");
4739
- const expected = plan === void 0 ? void 0 : MODEL_ROUTING_PLANS[plan].agents[agent];
4740
- if (expected === void 0 || rootTomlString(text, "model") !== expected.model || rootTomlString(text, "model_reasoning_effort") !== expected.reasoningEffort) agentModelFailures.push(agent);
560
+ const expected = AGENT_MODELS[agent];
561
+ if (rootTomlString(text, "model") !== expected.model || rootTomlString(text, "model_reasoning_effort") !== expected.reasoningEffort) agentModelFailures.push(agent);
4741
562
  } catch {
4742
563
  agentModelFailures.push(agent);
4743
564
  }
4744
- checks.push(agentModelFailures.length === 0 ? check("agent-models", "ok", "agent-models-ready", `Specialist models match the ${plan ?? "unknown"} routing plan.`) : check("agent-models", "error", "agent-models-stale", `Agent model configuration is stale for ${agentModelFailures.join(", ")}.`, "Reinstall HolyCodex."));
565
+ checks.push(agentModelFailures.length === 0 ? check("agent-models", "ok", "agent-models-ready", "Explorer and librarian use Luna low; worker uses Terra high.") : check("agent-models", "error", "agent-models-stale", `Agent model configuration is stale for ${agentModelFailures.join(", ")}.`, "Reinstall HolyCodex."));
4745
566
  return {
4746
567
  healthy: !checks.some((item) => item.status === "error"),
4747
568
  autonomy: mode,
@@ -4749,6 +570,143 @@ async function doctor(home = process.env.CODEX_HOME ?? join(homedir(), ".codex")
4749
570
  };
4750
571
  }
4751
572
  //#endregion
573
+ //#region packages/cli/src/config.ts
574
+ var START = "# >>> holycodex managed >>>";
575
+ var END = "# <<< holycodex managed <<<";
576
+ var ORIGINAL_ROOT = "# holycodex original root: ";
577
+ var ORIGINAL_TABLE_KEY = "# holycodex original table key: ";
578
+ var ROOT_PREFERENCES = [
579
+ ["model", `model = "${ROOT_MODEL.model}"`],
580
+ ["model_reasoning_effort", `model_reasoning_effort = "${ROOT_MODEL.reasoningEffort}"`],
581
+ ["model_verbosity", "model_verbosity = \"low\""]
582
+ ];
583
+ var OLD_NAMESPACES = [
584
+ "marketplaces.sisyphuslabs",
585
+ "plugins.\"omo@sisyphuslabs\"",
586
+ "marketplaces.lazycodex",
587
+ "plugins.\"omo@lazycodex\"",
588
+ "marketplaces.code-yeongyu-codex-plugins",
589
+ "plugins.\"omo@code-yeongyu-codex-plugins\"",
590
+ "agents.plan",
591
+ "agents.metis",
592
+ "agents.momus",
593
+ "agents.oracle",
594
+ "agents.sisyphus",
595
+ "agents.prometheus",
596
+ "agents.atlas",
597
+ "agents.hephaestus",
598
+ "hooks.state.\"omo@sisyphuslabs",
599
+ "hooks.state.\"omo@lazycodex",
600
+ "hooks.state.\"omo@code-yeongyu-codex-plugins"
601
+ ];
602
+ /** Removes managed. */
603
+ function removeManaged(input) {
604
+ const escapedStart = START.replaceAll(">", "\\>");
605
+ const escapedEnd = END.replaceAll("<", "\\<");
606
+ return input.replace(new RegExp(`${escapedStart}([\\s\\S]*?)${escapedEnd}(?:\\r?\\n){0,2}`, "g"), (_match, body) => {
607
+ const encoded = body.match(/^# holycodex original root: ([A-Za-z0-9+/=]+)$/m)?.[1];
608
+ if (encoded !== void 0) return `${Buffer.from(encoded, "base64").toString("utf8")}\n`;
609
+ const tableKey = body.match(/^# holycodex original table key: ([A-Za-z0-9+/=]+)$/m)?.[1];
610
+ return tableKey === void 0 ? "" : `${Buffer.from(tableKey, "base64").toString("utf8")}\n`;
611
+ }).trim();
612
+ }
613
+ /** Removes legacy omo. */
614
+ function removeLegacyOmo(input) {
615
+ return input.split(/(?=^\s*\[)/m).filter((section) => {
616
+ const header = /^\s*\[([^\]]+)]/.exec(section)?.[1];
617
+ if (header === void 0) return true;
618
+ if (OLD_NAMESPACES.some((name) => header === name || header.startsWith(`${name}.`) || name.includes("\"omo@") && header.startsWith(name))) return false;
619
+ return ![
620
+ "agents.explorer",
621
+ "agents.librarian",
622
+ "agents.worker"
623
+ ].some((name) => header === name || header.startsWith(`${name}.`)) || !/(?:sisyphuslabs|omo@|oh-my|code-yeongyu)/i.test(section);
624
+ }).join("").trimEnd();
625
+ }
626
+ function injectTableKey(input, table, key, value) {
627
+ const match = new RegExp(`^\\s*\\[${table.replaceAll(".", "\\.")}]\\s*(?:#.*)?$`, "m").exec(input);
628
+ const tail = match === null ? "" : input.slice(match.index + match[0].length);
629
+ const tableEnd = nextTableBoundary(tail);
630
+ const tableBody = tableEnd < 0 ? tail : tail.slice(0, tableEnd);
631
+ const originalKey = new RegExp(`^[ \\t]*${key}[ \\t]*=.*$`, "m").exec(tableBody)?.[0];
632
+ const managed = `${START}\n${originalKey === void 0 ? "" : `${ORIGINAL_TABLE_KEY}${Buffer.from(originalKey).toString("base64")}\n`}${key} = ${value}\n${END}`;
633
+ if (match === null) return `${input.trimEnd()}\n\n${START}\n[${table}]\n${key} = ${value}\n${END}`.trim();
634
+ const bodyStart = match.index + match[0].length;
635
+ const next = nextTableBoundary(input.slice(bodyStart));
636
+ const bodyEnd = next < 0 ? input.length : bodyStart + next;
637
+ const cleanedBody = input.slice(bodyStart, bodyEnd).replace(new RegExp(`^\\s*${key}\\s*=.*\\r?\\n?`, "gm"), "").trim();
638
+ const suffix = input.slice(bodyEnd).trimStart();
639
+ return `${input.slice(0, bodyStart)}\n${cleanedBody ? `${cleanedBody}\n` : ""}${managed}${suffix ? `\n${suffix}` : ""}`.trim();
640
+ }
641
+ function nextTableBoundary(input) {
642
+ const header = /^\s*\[/m.exec(input)?.index ?? -1;
643
+ const managedHeader = /^# >>> holycodex managed >>>\r?\n\s*\[/m.exec(input)?.index ?? -1;
644
+ if (header < 0) return managedHeader;
645
+ if (managedHeader < 0) return header;
646
+ return Math.min(header, managedHeader);
647
+ }
648
+ function rootValue(input, key) {
649
+ if (key === "status_line") return rootTomlStringArraySource(input, key);
650
+ return new RegExp(`^\\s*${key}\\s*=.*$`, "m").exec(input)?.[0];
651
+ }
652
+ function removeRootValue(input, value) {
653
+ return value === void 0 ? input : input.replace(value, "");
654
+ }
655
+ function preserveManagedRootPreferences(input, base) {
656
+ const managedRoot = new RegExp(`^${START}\\r?\\n([\\s\\S]*?)^${END}\\r?$`, "m").exec(input)?.[1];
657
+ if (managedRoot === void 0) return base;
658
+ const firstTable = base.search(/^\s*\[/m);
659
+ const root = firstTable < 0 ? base : base.slice(0, firstTable);
660
+ const tables = firstTable < 0 ? "" : base.slice(firstTable);
661
+ let updatedRoot = root.trim();
662
+ for (const [key, fallback] of ROOT_PREFERENCES) {
663
+ const live = rootValue(managedRoot, key)?.trim();
664
+ if (live === void 0 || live === (rootValue(root, key)?.trim() ?? fallback)) continue;
665
+ updatedRoot = removeRootValue(updatedRoot, rootValue(updatedRoot, key)).trim();
666
+ updatedRoot = `${updatedRoot}${updatedRoot ? "\n" : ""}${live}`;
667
+ }
668
+ if (updatedRoot === root.trim()) return base;
669
+ return `${updatedRoot}${tables ? `\n${tables.trimStart()}` : ""}`;
670
+ }
671
+ function mergedStatusLine(original) {
672
+ if (original === void 0) return "[\"model-with-reasoning\", \"context-remaining\", \"current-dir\"]";
673
+ const items = rootTomlStringArray(original, "status_line") ?? [];
674
+ if (!items.includes("context-remaining")) items.push("context-remaining");
675
+ return `[${items.map((item) => JSON.stringify(item)).join(", ")}]`;
676
+ }
677
+ /** Installs config. */
678
+ function installConfig(input, mode, _platform) {
679
+ const base = preserveManagedRootPreferences(input, removeLegacyOmo(removeManaged(input)));
680
+ const firstTable = base.search(/^\s*\[/m);
681
+ const root = firstTable < 0 ? base : base.slice(0, firstTable);
682
+ const tables = firstTable < 0 ? "" : base.slice(firstTable);
683
+ const controlled = [
684
+ "approval_policy",
685
+ "sandbox_mode",
686
+ "max_concurrent_threads_per_session",
687
+ "status_line"
688
+ ].map((key) => rootValue(root, key));
689
+ const originalRoot = root.trim();
690
+ const preservedRoot = controlled.reduce(removeRootValue, root).trim();
691
+ const hasModel = /^\s*model\s*=/m.test(preservedRoot);
692
+ const hasEffort = /^\s*model_reasoning_effort\s*=/m.test(preservedRoot);
693
+ const hasVerbosity = /^\s*model_verbosity\s*=/m.test(preservedRoot);
694
+ const model = hasModel ? "" : `model = "${ROOT_MODEL.model}"\n`;
695
+ const effort = hasEffort ? "" : `model_reasoning_effort = "${ROOT_MODEL.reasoningEffort}"\n`;
696
+ const verbosity = hasVerbosity ? "" : "model_verbosity = \"low\"\n";
697
+ const approval = mode === "default" ? "on-request" : "never";
698
+ const sandbox = mode === "dangerous" ? "danger-full-access" : "workspace-write";
699
+ let configured = `${`${START}\n${originalRoot ? `${ORIGINAL_ROOT}${Buffer.from(originalRoot).toString("base64")}\n` : ""}${model}${effort}${verbosity}${preservedRoot ? `${preservedRoot}\n` : ""}approval_policy = "${approval}"\nsandbox_mode = "${sandbox}"\nstatus_line = ${mergedStatusLine(controlled[3])}\n${END}`}${tables ? `\n\n${tables}` : ""}`;
700
+ configured = injectTableKey(configured, "features", "default_mode_request_user_input", "true");
701
+ configured = injectTableKey(configured, "features", "multi_agent", "true");
702
+ configured = injectTableKey(configured, "agents", "max_threads", "2");
703
+ configured = injectTableKey(configured, "agents", "max_depth", "1");
704
+ if (mode !== "dangerous") configured = injectTableKey(configured, "sandbox_workspace_write", "network_access", "true");
705
+ for (const agent of AGENTS) configured = injectTableKey(configured, `agents.${agent}`, "config_file", `"holycodex/agents/${agent}.toml"`);
706
+ const plugin = `${START}\n[marketplaces.holycodex]\nsource = "https://github.com/davidbasilefilho/holycodex.git"\n\n[plugins."holycodex@holycodex"]\nenabled = true\n${END}`;
707
+ return `${configured.trim()}\n\n${plugin}\n`;
708
+ }
709
+ //#endregion
4752
710
  //#region packages/cli/src/files.ts
4753
711
  /** Provides exists. */
4754
712
  async function exists(path) {
@@ -4826,7 +784,6 @@ function assertGitBashReady(platform, resolution) {
4826
784
  /** Provides install. */
4827
785
  async function install(options, runtime = defaultRuntime) {
4828
786
  assertGitBashReady(runtime.platform, runtime.gitBash());
4829
- const plan = options.plan ?? "plus";
4830
787
  const target = paths();
4831
788
  const root = backupRoot();
4832
789
  const backups = [
@@ -4835,9 +792,7 @@ async function install(options, runtime = defaultRuntime) {
4835
792
  await backup(target.agents, root),
4836
793
  ...await Promise.all(target.legacy.map((path) => backup(path, root)))
4837
794
  ].filter((path) => path !== void 0);
4838
- const existingConfig = await readText(target.config);
4839
- const previousPlan = readManagedPlan(existingConfig);
4840
- const config = installConfig(existingConfig, options.autonomy, runtime.platform, plan);
795
+ const config = installConfig(await readText(target.config), options.autonomy, runtime.platform);
4841
796
  await atomicWrite(target.config, config);
4842
797
  await rm(target.marketplaceCache, {
4843
798
  recursive: true,
@@ -4845,14 +800,14 @@ async function install(options, runtime = defaultRuntime) {
4845
800
  });
4846
801
  await mkdir(dirname(target.cache), { recursive: true });
4847
802
  await cp(pluginRoot, target.cache, { recursive: true });
4848
- await writePlatformPlugin(target.cache, runtime.platform, plan);
4849
- const existingAgentPreferences = await readAgentPreferences(target.agents, previousPlan);
803
+ await writePlatformPlugin(target.cache, runtime.platform);
804
+ const existingAgentPreferences = await readAgentPreferences(target.agents);
4850
805
  await rm(target.agents, {
4851
806
  recursive: true,
4852
807
  force: true
4853
808
  });
4854
809
  await cp(join(pluginRoot, "agents"), target.agents, { recursive: true });
4855
- await writeInstalledAgents(target.agents, runtime.platform, plan);
810
+ await writePlatformAgents(target.agents, runtime.platform);
4856
811
  await preserveAgentPreferences(target.agents, existingAgentPreferences);
4857
812
  const removedLegacy = [];
4858
813
  for (const path of target.legacy) {
@@ -4868,18 +823,17 @@ async function install(options, runtime = defaultRuntime) {
4868
823
  target.agents,
4869
824
  ...removedLegacy
4870
825
  ],
4871
- backups,
4872
- plan
826
+ backups
4873
827
  };
4874
828
  }
4875
- async function readAgentPreferences(root, previousPlan) {
829
+ async function readAgentPreferences(root) {
4876
830
  const preferences = {};
4877
831
  await Promise.all(AGENTS.map(async (agent) => {
4878
832
  const source = await readText(join(root, `${agent}.toml`));
4879
833
  const model = rootTomlString(source, "model");
4880
834
  const reasoningEffort = rootTomlString(source, "model_reasoning_effort");
4881
835
  if (model === void 0 && reasoningEffort === void 0) return;
4882
- if (!(previousPlan === void 0 ? MANAGED_AGENT_MODEL_HISTORY[agent] : [MODEL_ROUTING_PLANS[previousPlan].agents[agent]]).some((item) => item.model === model && item.reasoningEffort === reasoningEffort)) preferences[agent] = {
836
+ if (!MANAGED_AGENT_MODEL_HISTORY[agent].some((item) => item.model === model && item.reasoningEffort === reasoningEffort)) preferences[agent] = {
4883
837
  ...model === void 0 ? {} : { model },
4884
838
  ...reasoningEffort === void 0 ? {} : { reasoningEffort }
4885
839
  };
@@ -4900,22 +854,15 @@ async function preserveAgentPreferences(root, preferences) {
4900
854
  function replaceTomlString(input, key, value) {
4901
855
  return input.replace(new RegExp(`^${key}\\s*=.*$`, "m"), `${key} = ${JSON.stringify(value)}`);
4902
856
  }
4903
- async function writePlatformPlugin(root, platform, plan) {
857
+ async function writePlatformPlugin(root, platform) {
4904
858
  await atomicWrite(join(root, ".mcp.json"), `${JSON.stringify({ mcpServers: effectiveMcpServers(platform) }, null, 2)}\n`);
4905
- await writeInstalledAgents(join(root, "agents"), platform, plan);
859
+ await writePlatformAgents(join(root, "agents"), platform);
4906
860
  }
4907
- async function writeInstalledAgents(root, platform, plan) {
861
+ async function writePlatformAgents(root, platform) {
862
+ if (platform === "win32") return;
4908
863
  await Promise.all(AGENTS.map(async (agent) => {
4909
864
  const path = join(root, `${agent}.toml`);
4910
- const route = MODEL_ROUTING_PLANS[plan].agents[agent];
4911
- let source = await readText(path);
4912
- source = replaceTomlString(source, "model", route.model);
4913
- source = replaceTomlString(source, "model_reasoning_effort", route.reasoningEffort);
4914
- if (platform === "win32") {
4915
- await atomicWrite(path, source);
4916
- return;
4917
- }
4918
- await atomicWrite(path, source.replace(`${WINDOWS_SHELL_POLICY}\r\n\r\n`, "").replace(`${WINDOWS_SHELL_POLICY}\n\n`, ""));
865
+ await atomicWrite(path, (await readText(path)).replace(`${WINDOWS_SHELL_POLICY}\r\n\r\n`, "").replace(`${WINDOWS_SHELL_POLICY}\n\n`, ""));
4919
866
  }));
4920
867
  }
4921
868
  /** Provides cleanup. */
@@ -4966,11 +913,6 @@ var DIM = "\x1B[2m";
4966
913
  function paint(enabled, code, text) {
4967
914
  return enabled ? `${code}${text}${RESET}` : text;
4968
915
  }
4969
- /** Formats an unknown CLI failure without exposing validation internals. */
4970
- function formatCliError(error) {
4971
- if (!(error instanceof ZodError)) return error instanceof Error ? error.message : String(error);
4972
- return error.issues.map((issue) => `${issue.path.length === 0 ? "input" : issue.path.join(".")}: ${issue.message}`).join("; ");
4973
- }
4974
916
  /** Checks whether terminal color output is supported. */
4975
917
  function supportsColor(isTTY, noColor) {
4976
918
  return isTTY === true && noColor === void 0;
@@ -4980,13 +922,7 @@ function renderHelp(version, color) {
4980
922
  const title = paint(color, `${BOLD}${CYAN}`, `HOLYCODEX ${version}`);
4981
923
  const section = (text) => paint(color, BOLD, text);
4982
924
  const muted = (text) => paint(color, DIM, text);
4983
- return `${title}\n${muted("Lean Codex toolkit installer and doctor")}\n\n${section("USAGE")}\n holycodex <command> [options]\n\n${section("COMMANDS")}\n install Install or update HolyCodex\n cleanup Remove HolyCodex-owned state\n doctor Diagnose installation and runtime\n\n${section("OPTIONS")}\n --plan <plan> Model routing plan for install: ${PLAN_NAMES.join(", ")}\n Default: ${DEFAULT_PLAN}\n -h, --help Show help\n -v, --version Show version\n --no-tui Accepted; commands remain noninteractive\n --codex-autonomous Never ask; keep workspace sandbox\n --no-codex-autonomous Safe interactive defaults\n --dangerous-codex-autonomous Never ask; disable filesystem sandbox\n --json Print machine-readable output\n`;
4984
- }
4985
- /** Renders install-specific model plan and option help. */
4986
- function renderInstallHelp(version, color) {
4987
- const title = paint(color, `${BOLD}${CYAN}`, `HOLYCODEX ${version}`);
4988
- const section = (text) => paint(color, BOLD, text);
4989
- return `${title}\n\n${section("Usage:")}\n holycodex install [options]\n\n${section("Options:")}\n --plan <plan> Model routing plan: go, plus, pro-5x, or pro-20x\n Default: plus\n --json Print machine-readable output\n --no-tui Accepted; install remains noninteractive\n --codex-autonomous Never ask; keep workspace sandbox\n --no-codex-autonomous Safe interactive defaults\n --dangerous-codex-autonomous Never ask; disable filesystem sandbox\n -h, --help Show help\n\nPlans optimize model routing for the corresponding ChatGPT subscription allowance.\n\n${section("Examples:")}\n bunx holycodex install\n bunx holycodex install --plan go\n bunx holycodex install --plan pro-5x\n bunx holycodex install --plan pro-20x\n`;
925
+ return `${title}\n${muted("Lean Codex toolkit installer and doctor")}\n\n${section("USAGE")}\n holycodex <command> [options]\n\n${section("COMMANDS")}\n install Install or update HolyCodex\n cleanup Remove HolyCodex-owned state\n doctor Diagnose installation and runtime\n\n${section("OPTIONS")}\n -h, --help Show help\n -v, --version Show version\n --no-tui Accepted; commands remain noninteractive\n --codex-autonomous Never ask; keep workspace sandbox\n --no-codex-autonomous Safe interactive defaults\n --dangerous-codex-autonomous Never ask; disable filesystem sandbox\n --json Print machine-readable output\n`;
4990
926
  }
4991
927
  /** Renders error. */
4992
928
  function renderError(message, color) {
@@ -5014,22 +950,15 @@ async function main() {
5014
950
  const args = process$1.argv.slice(2);
5015
951
  const stdoutColor = supportsColor(process$1.stdout.isTTY, process$1.env.NO_COLOR);
5016
952
  const stderrColor = supportsColor(process$1.stderr.isTTY, process$1.env.NO_COLOR);
5017
- const command = args.find((arg, index) => !arg.startsWith("-") && args[index - 1] !== "--plan");
5018
953
  if (args.includes("--help") || args.includes("-h") || args.length === 0) {
5019
- process$1.stdout.write(command === "install" ? renderInstallHelp(VERSION, stdoutColor) : renderHelp(VERSION, stdoutColor));
954
+ process$1.stdout.write(renderHelp(VERSION, stdoutColor));
5020
955
  return;
5021
956
  }
5022
957
  if (args.includes("--version") || args.includes("-v")) {
5023
958
  process$1.stdout.write(`${VERSION}\n`);
5024
959
  return;
5025
960
  }
5026
- if (args.flatMap((arg, index) => arg === "--plan" ? [index] : []).length > 1) throw new Error("--plan may be specified only once.");
5027
- const planFlagIndex = args.indexOf("--plan");
5028
- const planValue = planFlagIndex < 0 ? DEFAULT_PLAN : args[planFlagIndex + 1];
5029
- if (planValue === void 0 || planValue.startsWith("-") || planValue === command) throw new Error(`Missing --plan value. Valid plans: ${PLAN_NAMES.join(", ")}.`);
5030
- const parsedPlan = PlanNameSchema.safeParse(planValue);
5031
- if (!parsedPlan.success) throw new Error(`Unknown plan: ${planValue}. Valid plans: ${PLAN_NAMES.join(", ")}.`);
5032
- const plan = parsedPlan.data;
961
+ const command = args.find((arg) => !arg.startsWith("--"));
5033
962
  const autonomyFlags = args.filter((arg) => [
5034
963
  "--codex-autonomous",
5035
964
  "--no-codex-autonomous",
@@ -5042,8 +971,7 @@ async function main() {
5042
971
  }
5043
972
  const options = {
5044
973
  autonomy: args.includes("--dangerous-codex-autonomous") ? "dangerous" : args.includes("--codex-autonomous") ? "autonomous" : "default",
5045
- json: args.includes("--json"),
5046
- plan
974
+ json: args.includes("--json")
5047
975
  };
5048
976
  if (command === "doctor") {
5049
977
  const result = await doctor();
@@ -5065,7 +993,7 @@ try {
5065
993
  await main();
5066
994
  } catch (error) {
5067
995
  const stderrColor = supportsColor(process$1.stderr.isTTY, process$1.env.NO_COLOR);
5068
- process$1.stderr.write(renderError(formatCliError(error), stderrColor));
996
+ process$1.stderr.write(renderError(error instanceof Error ? error.message : String(error), stderrColor));
5069
997
  process$1.exitCode = 1;
5070
998
  }
5071
999
  //#endregion