@jeffreyjyz/opencode-command-code 0.2.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,2416 @@
1
1
  // @bun
2
- // src/index.ts
3
- import { tool } from "@opencode-ai/plugin";
2
+ // node_modules/zod/v4/core/core.js
3
+ var NEVER = Object.freeze({
4
+ status: "aborted"
5
+ });
6
+ function $constructor(name, initializer, params) {
7
+ function init(inst, def) {
8
+ var _a;
9
+ Object.defineProperty(inst, "_zod", {
10
+ value: inst._zod ?? {},
11
+ enumerable: false
12
+ });
13
+ (_a = inst._zod).traits ?? (_a.traits = new Set);
14
+ inst._zod.traits.add(name);
15
+ initializer(inst, def);
16
+ for (const k in _.prototype) {
17
+ if (!(k in inst))
18
+ Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
19
+ }
20
+ inst._zod.constr = _;
21
+ inst._zod.def = def;
22
+ }
23
+ const Parent = params?.Parent ?? Object;
24
+
25
+ class Definition extends Parent {
26
+ }
27
+ Object.defineProperty(Definition, "name", { value: name });
28
+ function _(def) {
29
+ var _a;
30
+ const inst = params?.Parent ? new Definition : this;
31
+ init(inst, def);
32
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
33
+ for (const fn of inst._zod.deferred) {
34
+ fn();
35
+ }
36
+ return inst;
37
+ }
38
+ Object.defineProperty(_, "init", { value: init });
39
+ Object.defineProperty(_, Symbol.hasInstance, {
40
+ value: (inst) => {
41
+ if (params?.Parent && inst instanceof params.Parent)
42
+ return true;
43
+ return inst?._zod?.traits?.has(name);
44
+ }
45
+ });
46
+ Object.defineProperty(_, "name", { value: name });
47
+ return _;
48
+ }
49
+ var $brand = Symbol("zod_brand");
50
+
51
+ class $ZodAsyncError extends Error {
52
+ constructor() {
53
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
54
+ }
55
+ }
56
+
57
+ class $ZodEncodeError extends Error {
58
+ constructor(name) {
59
+ super(`Encountered unidirectional transform during encode: ${name}`);
60
+ this.name = "ZodEncodeError";
61
+ }
62
+ }
63
+ var globalConfig = {};
64
+ function config(newConfig) {
65
+ if (newConfig)
66
+ Object.assign(globalConfig, newConfig);
67
+ return globalConfig;
68
+ }
69
+ // node_modules/zod/v4/core/util.js
70
+ function jsonStringifyReplacer(_, value) {
71
+ if (typeof value === "bigint")
72
+ return value.toString();
73
+ return value;
74
+ }
75
+ function cached(getter) {
76
+ const set = false;
77
+ return {
78
+ get value() {
79
+ if (!set) {
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
+ }
88
+ function nullish(input) {
89
+ return input === null || input === undefined;
90
+ }
91
+ function cleanRegex(source) {
92
+ const start = source.startsWith("^") ? 1 : 0;
93
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
94
+ return source.slice(start, end);
95
+ }
96
+ var EVALUATING = Symbol("evaluating");
97
+ function defineLazy(object, key, getter) {
98
+ let value = undefined;
99
+ Object.defineProperty(object, key, {
100
+ get() {
101
+ if (value === EVALUATING) {
102
+ return;
103
+ }
104
+ if (value === undefined) {
105
+ value = EVALUATING;
106
+ value = getter();
107
+ }
108
+ return value;
109
+ },
110
+ set(v) {
111
+ Object.defineProperty(object, key, {
112
+ value: v
113
+ });
114
+ },
115
+ configurable: true
116
+ });
117
+ }
118
+ var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
119
+ function isObject(data) {
120
+ return typeof data === "object" && data !== null && !Array.isArray(data);
121
+ }
122
+ var allowsEval = cached(() => {
123
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
124
+ return false;
125
+ }
126
+ try {
127
+ const F = Function;
128
+ new F("");
129
+ return true;
130
+ } catch (_) {
131
+ return false;
132
+ }
133
+ });
134
+ function isPlainObject(o) {
135
+ if (isObject(o) === false)
136
+ return false;
137
+ const ctor = o.constructor;
138
+ if (ctor === undefined)
139
+ return true;
140
+ const prot = ctor.prototype;
141
+ if (isObject(prot) === false)
142
+ return false;
143
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
144
+ return false;
145
+ }
146
+ return true;
147
+ }
148
+ function shallowClone(o) {
149
+ if (isPlainObject(o))
150
+ return { ...o };
151
+ if (Array.isArray(o))
152
+ return [...o];
153
+ return o;
154
+ }
155
+ var propertyKeyTypes = new Set(["string", "number", "symbol"]);
156
+ var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
157
+ function escapeRegex(str) {
158
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
159
+ }
160
+ function clone(inst, def, params) {
161
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
162
+ if (!def || params?.parent)
163
+ cl._zod.parent = inst;
164
+ return cl;
165
+ }
166
+ function normalizeParams(_params) {
167
+ const params = _params;
168
+ if (!params)
169
+ return {};
170
+ if (typeof params === "string")
171
+ return { error: () => params };
172
+ if (params?.message !== undefined) {
173
+ if (params?.error !== undefined)
174
+ throw new Error("Cannot specify both `message` and `error` params");
175
+ params.error = params.message;
176
+ }
177
+ delete params.message;
178
+ if (typeof params.error === "string")
179
+ return { ...params, error: () => params.error };
180
+ return params;
181
+ }
182
+ var NUMBER_FORMAT_RANGES = {
183
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
184
+ int32: [-2147483648, 2147483647],
185
+ uint32: [0, 4294967295],
186
+ float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
187
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
188
+ };
189
+ function aborted(x, startIndex = 0) {
190
+ if (x.aborted === true)
191
+ return true;
192
+ for (let i = startIndex;i < x.issues.length; i++) {
193
+ if (x.issues[i]?.continue !== true) {
194
+ return true;
195
+ }
196
+ }
197
+ return false;
198
+ }
199
+ function prefixIssues(path, issues) {
200
+ return issues.map((iss) => {
201
+ var _a;
202
+ (_a = iss).path ?? (_a.path = []);
203
+ iss.path.unshift(path);
204
+ return iss;
205
+ });
206
+ }
207
+ function unwrapMessage(message) {
208
+ return typeof message === "string" ? message : message?.message;
209
+ }
210
+ function finalizeIssue(iss, ctx, config) {
211
+ const full = { ...iss, path: iss.path ?? [] };
212
+ if (!iss.message) {
213
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
214
+ full.message = message;
215
+ }
216
+ delete full.inst;
217
+ delete full.continue;
218
+ if (!ctx?.reportInput) {
219
+ delete full.input;
220
+ }
221
+ return full;
222
+ }
223
+ function getLengthableOrigin(input) {
224
+ if (Array.isArray(input))
225
+ return "array";
226
+ if (typeof input === "string")
227
+ return "string";
228
+ return "unknown";
229
+ }
230
+ function issue(...args) {
231
+ const [iss, input, inst] = args;
232
+ if (typeof iss === "string") {
233
+ return {
234
+ message: iss,
235
+ code: "custom",
236
+ input,
237
+ inst
238
+ };
239
+ }
240
+ return { ...iss };
241
+ }
242
+
243
+ // node_modules/zod/v4/core/errors.js
244
+ var initializer = (inst, def) => {
245
+ inst.name = "$ZodError";
246
+ Object.defineProperty(inst, "_zod", {
247
+ value: inst._zod,
248
+ enumerable: false
249
+ });
250
+ Object.defineProperty(inst, "issues", {
251
+ value: def,
252
+ enumerable: false
253
+ });
254
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
255
+ Object.defineProperty(inst, "toString", {
256
+ value: () => inst.message,
257
+ enumerable: false
258
+ });
259
+ };
260
+ var $ZodError = $constructor("$ZodError", initializer);
261
+ var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
262
+ function flattenError(error, mapper = (issue) => issue.message) {
263
+ const fieldErrors = {};
264
+ const formErrors = [];
265
+ for (const sub of error.issues) {
266
+ if (sub.path.length > 0) {
267
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
268
+ fieldErrors[sub.path[0]].push(mapper(sub));
269
+ } else {
270
+ formErrors.push(mapper(sub));
271
+ }
272
+ }
273
+ return { formErrors, fieldErrors };
274
+ }
275
+ function formatError(error, _mapper) {
276
+ const mapper = _mapper || function(issue) {
277
+ return issue.message;
278
+ };
279
+ const fieldErrors = { _errors: [] };
280
+ const processError = (error) => {
281
+ for (const issue of error.issues) {
282
+ if (issue.code === "invalid_union" && issue.errors.length) {
283
+ issue.errors.map((issues) => processError({ issues }));
284
+ } else if (issue.code === "invalid_key") {
285
+ processError({ issues: issue.issues });
286
+ } else if (issue.code === "invalid_element") {
287
+ processError({ issues: issue.issues });
288
+ } else if (issue.path.length === 0) {
289
+ fieldErrors._errors.push(mapper(issue));
290
+ } else {
291
+ let curr = fieldErrors;
292
+ let i = 0;
293
+ while (i < issue.path.length) {
294
+ const el = issue.path[i];
295
+ const terminal = i === issue.path.length - 1;
296
+ if (!terminal) {
297
+ curr[el] = curr[el] || { _errors: [] };
298
+ } else {
299
+ curr[el] = curr[el] || { _errors: [] };
300
+ curr[el]._errors.push(mapper(issue));
301
+ }
302
+ curr = curr[el];
303
+ i++;
304
+ }
305
+ }
306
+ }
307
+ };
308
+ processError(error);
309
+ return fieldErrors;
310
+ }
311
+
312
+ // node_modules/zod/v4/core/parse.js
313
+ var _parse = (_Err) => (schema, value, _ctx, _params) => {
314
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
315
+ const result = schema._zod.run({ value, issues: [] }, ctx);
316
+ if (result instanceof Promise) {
317
+ throw new $ZodAsyncError;
318
+ }
319
+ if (result.issues.length) {
320
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
321
+ captureStackTrace(e, _params?.callee);
322
+ throw e;
323
+ }
324
+ return result.value;
325
+ };
326
+ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
327
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
328
+ let result = schema._zod.run({ value, issues: [] }, ctx);
329
+ if (result instanceof Promise)
330
+ result = await result;
331
+ if (result.issues.length) {
332
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
333
+ captureStackTrace(e, params?.callee);
334
+ throw e;
335
+ }
336
+ return result.value;
337
+ };
338
+ var _safeParse = (_Err) => (schema, value, _ctx) => {
339
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
340
+ const result = schema._zod.run({ value, issues: [] }, ctx);
341
+ if (result instanceof Promise) {
342
+ throw new $ZodAsyncError;
343
+ }
344
+ return result.issues.length ? {
345
+ success: false,
346
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
347
+ } : { success: true, data: result.value };
348
+ };
349
+ var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
350
+ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
351
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
352
+ let result = schema._zod.run({ value, issues: [] }, ctx);
353
+ if (result instanceof Promise)
354
+ result = await result;
355
+ return result.issues.length ? {
356
+ success: false,
357
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
358
+ } : { success: true, data: result.value };
359
+ };
360
+ var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
361
+ var _encode = (_Err) => (schema, value, _ctx) => {
362
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
363
+ return _parse(_Err)(schema, value, ctx);
364
+ };
365
+ var _decode = (_Err) => (schema, value, _ctx) => {
366
+ return _parse(_Err)(schema, value, _ctx);
367
+ };
368
+ var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
369
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
370
+ return _parseAsync(_Err)(schema, value, ctx);
371
+ };
372
+ var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
373
+ return _parseAsync(_Err)(schema, value, _ctx);
374
+ };
375
+ var _safeEncode = (_Err) => (schema, value, _ctx) => {
376
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
377
+ return _safeParse(_Err)(schema, value, ctx);
378
+ };
379
+ var _safeDecode = (_Err) => (schema, value, _ctx) => {
380
+ return _safeParse(_Err)(schema, value, _ctx);
381
+ };
382
+ var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
383
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
384
+ return _safeParseAsync(_Err)(schema, value, ctx);
385
+ };
386
+ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
387
+ return _safeParseAsync(_Err)(schema, value, _ctx);
388
+ };
389
+ // node_modules/zod/v4/core/regexes.js
390
+ var cuid = /^[cC][^\s-]{8,}$/;
391
+ var cuid2 = /^[0-9a-z]+$/;
392
+ var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
393
+ var xid = /^[0-9a-vA-V]{20}$/;
394
+ var ksuid = /^[A-Za-z0-9]{27}$/;
395
+ var nanoid = /^[a-zA-Z0-9_-]{21}$/;
396
+ var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
397
+ 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})$/;
398
+ var uuid = (version) => {
399
+ if (!version)
400
+ 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)$/;
401
+ 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})$`);
402
+ };
403
+ var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
404
+ var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
405
+ function emoji() {
406
+ return new RegExp(_emoji, "u");
407
+ }
408
+ 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])$/;
409
+ 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}|:))$/;
410
+ 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])$/;
411
+ 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])$/;
412
+ var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
413
+ var base64url = /^[A-Za-z0-9_-]*$/;
414
+ var hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
415
+ var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
416
+ 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])))`;
417
+ var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
418
+ function timeSource(args) {
419
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
420
+ const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
421
+ return regex;
422
+ }
423
+ function time(args) {
424
+ return new RegExp(`^${timeSource(args)}$`);
425
+ }
426
+ function datetime(args) {
427
+ const time = timeSource({ precision: args.precision });
428
+ const opts = ["Z"];
429
+ if (args.local)
430
+ opts.push("");
431
+ if (args.offset)
432
+ opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
433
+ const timeRegex = `${time}(?:${opts.join("|")})`;
434
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
435
+ }
436
+ var string = (params) => {
437
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
438
+ return new RegExp(`^${regex}$`);
439
+ };
440
+ var lowercase = /^[^A-Z]*$/;
441
+ var uppercase = /^[^a-z]*$/;
442
+
443
+ // node_modules/zod/v4/core/checks.js
444
+ var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
445
+ var _a;
446
+ inst._zod ?? (inst._zod = {});
447
+ inst._zod.def = def;
448
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
449
+ });
450
+ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
451
+ var _a;
452
+ $ZodCheck.init(inst, def);
453
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
454
+ const val = payload.value;
455
+ return !nullish(val) && val.length !== undefined;
456
+ });
457
+ inst._zod.onattach.push((inst) => {
458
+ const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
459
+ if (def.maximum < curr)
460
+ inst._zod.bag.maximum = def.maximum;
461
+ });
462
+ inst._zod.check = (payload) => {
463
+ const input = payload.value;
464
+ const length = input.length;
465
+ if (length <= def.maximum)
466
+ return;
467
+ const origin = getLengthableOrigin(input);
468
+ payload.issues.push({
469
+ origin,
470
+ code: "too_big",
471
+ maximum: def.maximum,
472
+ inclusive: true,
473
+ input,
474
+ inst,
475
+ continue: !def.abort
476
+ });
477
+ };
478
+ });
479
+ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
480
+ var _a;
481
+ $ZodCheck.init(inst, def);
482
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
483
+ const val = payload.value;
484
+ return !nullish(val) && val.length !== undefined;
485
+ });
486
+ inst._zod.onattach.push((inst) => {
487
+ const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
488
+ if (def.minimum > curr)
489
+ inst._zod.bag.minimum = def.minimum;
490
+ });
491
+ inst._zod.check = (payload) => {
492
+ const input = payload.value;
493
+ const length = input.length;
494
+ if (length >= def.minimum)
495
+ return;
496
+ const origin = getLengthableOrigin(input);
497
+ payload.issues.push({
498
+ origin,
499
+ code: "too_small",
500
+ minimum: def.minimum,
501
+ inclusive: true,
502
+ input,
503
+ inst,
504
+ continue: !def.abort
505
+ });
506
+ };
507
+ });
508
+ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
509
+ var _a;
510
+ $ZodCheck.init(inst, def);
511
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
512
+ const val = payload.value;
513
+ return !nullish(val) && val.length !== undefined;
514
+ });
515
+ inst._zod.onattach.push((inst) => {
516
+ const bag = inst._zod.bag;
517
+ bag.minimum = def.length;
518
+ bag.maximum = def.length;
519
+ bag.length = def.length;
520
+ });
521
+ inst._zod.check = (payload) => {
522
+ const input = payload.value;
523
+ const length = input.length;
524
+ if (length === def.length)
525
+ return;
526
+ const origin = getLengthableOrigin(input);
527
+ const tooBig = length > def.length;
528
+ payload.issues.push({
529
+ origin,
530
+ ...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
531
+ inclusive: true,
532
+ exact: true,
533
+ input: payload.value,
534
+ inst,
535
+ continue: !def.abort
536
+ });
537
+ };
538
+ });
539
+ var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
540
+ var _a, _b;
541
+ $ZodCheck.init(inst, def);
542
+ inst._zod.onattach.push((inst) => {
543
+ const bag = inst._zod.bag;
544
+ bag.format = def.format;
545
+ if (def.pattern) {
546
+ bag.patterns ?? (bag.patterns = new Set);
547
+ bag.patterns.add(def.pattern);
548
+ }
549
+ });
550
+ if (def.pattern)
551
+ (_a = inst._zod).check ?? (_a.check = (payload) => {
552
+ def.pattern.lastIndex = 0;
553
+ if (def.pattern.test(payload.value))
554
+ return;
555
+ payload.issues.push({
556
+ origin: "string",
557
+ code: "invalid_format",
558
+ format: def.format,
559
+ input: payload.value,
560
+ ...def.pattern ? { pattern: def.pattern.toString() } : {},
561
+ inst,
562
+ continue: !def.abort
563
+ });
564
+ });
565
+ else
566
+ (_b = inst._zod).check ?? (_b.check = () => {});
567
+ });
568
+ var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
569
+ $ZodCheckStringFormat.init(inst, def);
570
+ inst._zod.check = (payload) => {
571
+ def.pattern.lastIndex = 0;
572
+ if (def.pattern.test(payload.value))
573
+ return;
574
+ payload.issues.push({
575
+ origin: "string",
576
+ code: "invalid_format",
577
+ format: "regex",
578
+ input: payload.value,
579
+ pattern: def.pattern.toString(),
580
+ inst,
581
+ continue: !def.abort
582
+ });
583
+ };
584
+ });
585
+ var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
586
+ def.pattern ?? (def.pattern = lowercase);
587
+ $ZodCheckStringFormat.init(inst, def);
588
+ });
589
+ var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
590
+ def.pattern ?? (def.pattern = uppercase);
591
+ $ZodCheckStringFormat.init(inst, def);
592
+ });
593
+ var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
594
+ $ZodCheck.init(inst, def);
595
+ const escapedRegex = escapeRegex(def.includes);
596
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
597
+ def.pattern = pattern;
598
+ inst._zod.onattach.push((inst) => {
599
+ const bag = inst._zod.bag;
600
+ bag.patterns ?? (bag.patterns = new Set);
601
+ bag.patterns.add(pattern);
602
+ });
603
+ inst._zod.check = (payload) => {
604
+ if (payload.value.includes(def.includes, def.position))
605
+ return;
606
+ payload.issues.push({
607
+ origin: "string",
608
+ code: "invalid_format",
609
+ format: "includes",
610
+ includes: def.includes,
611
+ input: payload.value,
612
+ inst,
613
+ continue: !def.abort
614
+ });
615
+ };
616
+ });
617
+ var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
618
+ $ZodCheck.init(inst, def);
619
+ const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
620
+ def.pattern ?? (def.pattern = pattern);
621
+ inst._zod.onattach.push((inst) => {
622
+ const bag = inst._zod.bag;
623
+ bag.patterns ?? (bag.patterns = new Set);
624
+ bag.patterns.add(pattern);
625
+ });
626
+ inst._zod.check = (payload) => {
627
+ if (payload.value.startsWith(def.prefix))
628
+ return;
629
+ payload.issues.push({
630
+ origin: "string",
631
+ code: "invalid_format",
632
+ format: "starts_with",
633
+ prefix: def.prefix,
634
+ input: payload.value,
635
+ inst,
636
+ continue: !def.abort
637
+ });
638
+ };
639
+ });
640
+ var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
641
+ $ZodCheck.init(inst, def);
642
+ const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
643
+ def.pattern ?? (def.pattern = pattern);
644
+ inst._zod.onattach.push((inst) => {
645
+ const bag = inst._zod.bag;
646
+ bag.patterns ?? (bag.patterns = new Set);
647
+ bag.patterns.add(pattern);
648
+ });
649
+ inst._zod.check = (payload) => {
650
+ if (payload.value.endsWith(def.suffix))
651
+ return;
652
+ payload.issues.push({
653
+ origin: "string",
654
+ code: "invalid_format",
655
+ format: "ends_with",
656
+ suffix: def.suffix,
657
+ input: payload.value,
658
+ inst,
659
+ continue: !def.abort
660
+ });
661
+ };
662
+ });
663
+ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
664
+ $ZodCheck.init(inst, def);
665
+ inst._zod.check = (payload) => {
666
+ payload.value = def.tx(payload.value);
667
+ };
668
+ });
669
+
670
+ // node_modules/zod/v4/core/versions.js
671
+ var version = {
672
+ major: 4,
673
+ minor: 1,
674
+ patch: 8
675
+ };
676
+
677
+ // node_modules/zod/v4/core/schemas.js
678
+ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
679
+ var _a;
680
+ inst ?? (inst = {});
681
+ inst._zod.def = def;
682
+ inst._zod.bag = inst._zod.bag || {};
683
+ inst._zod.version = version;
684
+ const checks = [...inst._zod.def.checks ?? []];
685
+ if (inst._zod.traits.has("$ZodCheck")) {
686
+ checks.unshift(inst);
687
+ }
688
+ for (const ch of checks) {
689
+ for (const fn of ch._zod.onattach) {
690
+ fn(inst);
691
+ }
692
+ }
693
+ if (checks.length === 0) {
694
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
695
+ inst._zod.deferred?.push(() => {
696
+ inst._zod.run = inst._zod.parse;
697
+ });
698
+ } else {
699
+ const runChecks = (payload, checks, ctx) => {
700
+ let isAborted = aborted(payload);
701
+ let asyncResult;
702
+ for (const ch of checks) {
703
+ if (ch._zod.def.when) {
704
+ const shouldRun = ch._zod.def.when(payload);
705
+ if (!shouldRun)
706
+ continue;
707
+ } else if (isAborted) {
708
+ continue;
709
+ }
710
+ const currLen = payload.issues.length;
711
+ const _ = ch._zod.check(payload);
712
+ if (_ instanceof Promise && ctx?.async === false) {
713
+ throw new $ZodAsyncError;
714
+ }
715
+ if (asyncResult || _ instanceof Promise) {
716
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
717
+ await _;
718
+ const nextLen = payload.issues.length;
719
+ if (nextLen === currLen)
720
+ return;
721
+ if (!isAborted)
722
+ isAborted = aborted(payload, currLen);
723
+ });
724
+ } else {
725
+ const nextLen = payload.issues.length;
726
+ if (nextLen === currLen)
727
+ continue;
728
+ if (!isAborted)
729
+ isAborted = aborted(payload, currLen);
730
+ }
731
+ }
732
+ if (asyncResult) {
733
+ return asyncResult.then(() => {
734
+ return payload;
735
+ });
736
+ }
737
+ return payload;
738
+ };
739
+ const handleCanaryResult = (canary, payload, ctx) => {
740
+ if (aborted(canary)) {
741
+ canary.aborted = true;
742
+ return canary;
743
+ }
744
+ const checkResult = runChecks(payload, checks, ctx);
745
+ if (checkResult instanceof Promise) {
746
+ if (ctx.async === false)
747
+ throw new $ZodAsyncError;
748
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
749
+ }
750
+ return inst._zod.parse(checkResult, ctx);
751
+ };
752
+ inst._zod.run = (payload, ctx) => {
753
+ if (ctx.skipChecks) {
754
+ return inst._zod.parse(payload, ctx);
755
+ }
756
+ if (ctx.direction === "backward") {
757
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
758
+ if (canary instanceof Promise) {
759
+ return canary.then((canary) => {
760
+ return handleCanaryResult(canary, payload, ctx);
761
+ });
762
+ }
763
+ return handleCanaryResult(canary, payload, ctx);
764
+ }
765
+ const result = inst._zod.parse(payload, ctx);
766
+ if (result instanceof Promise) {
767
+ if (ctx.async === false)
768
+ throw new $ZodAsyncError;
769
+ return result.then((result) => runChecks(result, checks, ctx));
770
+ }
771
+ return runChecks(result, checks, ctx);
772
+ };
773
+ }
774
+ inst["~standard"] = {
775
+ validate: (value) => {
776
+ try {
777
+ const r = safeParse(inst, value);
778
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
779
+ } catch (_) {
780
+ return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
781
+ }
782
+ },
783
+ vendor: "zod",
784
+ version: 1
785
+ };
786
+ });
787
+ var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
788
+ $ZodType.init(inst, def);
789
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
790
+ inst._zod.parse = (payload, _) => {
791
+ if (def.coerce)
792
+ try {
793
+ payload.value = String(payload.value);
794
+ } catch (_) {}
795
+ if (typeof payload.value === "string")
796
+ return payload;
797
+ payload.issues.push({
798
+ expected: "string",
799
+ code: "invalid_type",
800
+ input: payload.value,
801
+ inst
802
+ });
803
+ return payload;
804
+ };
805
+ });
806
+ var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
807
+ $ZodCheckStringFormat.init(inst, def);
808
+ $ZodString.init(inst, def);
809
+ });
810
+ var $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
811
+ def.pattern ?? (def.pattern = guid);
812
+ $ZodStringFormat.init(inst, def);
813
+ });
814
+ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
815
+ if (def.version) {
816
+ const versionMap = {
817
+ v1: 1,
818
+ v2: 2,
819
+ v3: 3,
820
+ v4: 4,
821
+ v5: 5,
822
+ v6: 6,
823
+ v7: 7,
824
+ v8: 8
825
+ };
826
+ const v = versionMap[def.version];
827
+ if (v === undefined)
828
+ throw new Error(`Invalid UUID version: "${def.version}"`);
829
+ def.pattern ?? (def.pattern = uuid(v));
830
+ } else
831
+ def.pattern ?? (def.pattern = uuid());
832
+ $ZodStringFormat.init(inst, def);
833
+ });
834
+ var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
835
+ def.pattern ?? (def.pattern = email);
836
+ $ZodStringFormat.init(inst, def);
837
+ });
838
+ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
839
+ $ZodStringFormat.init(inst, def);
840
+ inst._zod.check = (payload) => {
841
+ try {
842
+ const trimmed = payload.value.trim();
843
+ const url = new URL(trimmed);
844
+ if (def.hostname) {
845
+ def.hostname.lastIndex = 0;
846
+ if (!def.hostname.test(url.hostname)) {
847
+ payload.issues.push({
848
+ code: "invalid_format",
849
+ format: "url",
850
+ note: "Invalid hostname",
851
+ pattern: hostname.source,
852
+ input: payload.value,
853
+ inst,
854
+ continue: !def.abort
855
+ });
856
+ }
857
+ }
858
+ if (def.protocol) {
859
+ def.protocol.lastIndex = 0;
860
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
861
+ payload.issues.push({
862
+ code: "invalid_format",
863
+ format: "url",
864
+ note: "Invalid protocol",
865
+ pattern: def.protocol.source,
866
+ input: payload.value,
867
+ inst,
868
+ continue: !def.abort
869
+ });
870
+ }
871
+ }
872
+ if (def.normalize) {
873
+ payload.value = url.href;
874
+ } else {
875
+ payload.value = trimmed;
876
+ }
877
+ return;
878
+ } catch (_) {
879
+ payload.issues.push({
880
+ code: "invalid_format",
881
+ format: "url",
882
+ input: payload.value,
883
+ inst,
884
+ continue: !def.abort
885
+ });
886
+ }
887
+ };
888
+ });
889
+ var $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
890
+ def.pattern ?? (def.pattern = emoji());
891
+ $ZodStringFormat.init(inst, def);
892
+ });
893
+ var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
894
+ def.pattern ?? (def.pattern = nanoid);
895
+ $ZodStringFormat.init(inst, def);
896
+ });
897
+ var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
898
+ def.pattern ?? (def.pattern = cuid);
899
+ $ZodStringFormat.init(inst, def);
900
+ });
901
+ var $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
902
+ def.pattern ?? (def.pattern = cuid2);
903
+ $ZodStringFormat.init(inst, def);
904
+ });
905
+ var $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
906
+ def.pattern ?? (def.pattern = ulid);
907
+ $ZodStringFormat.init(inst, def);
908
+ });
909
+ var $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
910
+ def.pattern ?? (def.pattern = xid);
911
+ $ZodStringFormat.init(inst, def);
912
+ });
913
+ var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
914
+ def.pattern ?? (def.pattern = ksuid);
915
+ $ZodStringFormat.init(inst, def);
916
+ });
917
+ var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
918
+ def.pattern ?? (def.pattern = datetime(def));
919
+ $ZodStringFormat.init(inst, def);
920
+ });
921
+ var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
922
+ def.pattern ?? (def.pattern = date);
923
+ $ZodStringFormat.init(inst, def);
924
+ });
925
+ var $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
926
+ def.pattern ?? (def.pattern = time(def));
927
+ $ZodStringFormat.init(inst, def);
928
+ });
929
+ var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
930
+ def.pattern ?? (def.pattern = duration);
931
+ $ZodStringFormat.init(inst, def);
932
+ });
933
+ var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
934
+ def.pattern ?? (def.pattern = ipv4);
935
+ $ZodStringFormat.init(inst, def);
936
+ inst._zod.onattach.push((inst) => {
937
+ const bag = inst._zod.bag;
938
+ bag.format = `ipv4`;
939
+ });
940
+ });
941
+ var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
942
+ def.pattern ?? (def.pattern = ipv6);
943
+ $ZodStringFormat.init(inst, def);
944
+ inst._zod.onattach.push((inst) => {
945
+ const bag = inst._zod.bag;
946
+ bag.format = `ipv6`;
947
+ });
948
+ inst._zod.check = (payload) => {
949
+ try {
950
+ new URL(`http://[${payload.value}]`);
951
+ } catch {
952
+ payload.issues.push({
953
+ code: "invalid_format",
954
+ format: "ipv6",
955
+ input: payload.value,
956
+ inst,
957
+ continue: !def.abort
958
+ });
959
+ }
960
+ };
961
+ });
962
+ var $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
963
+ def.pattern ?? (def.pattern = cidrv4);
964
+ $ZodStringFormat.init(inst, def);
965
+ });
966
+ var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
967
+ def.pattern ?? (def.pattern = cidrv6);
968
+ $ZodStringFormat.init(inst, def);
969
+ inst._zod.check = (payload) => {
970
+ const parts = payload.value.split("/");
971
+ try {
972
+ if (parts.length !== 2)
973
+ throw new Error;
974
+ const [address, prefix] = parts;
975
+ if (!prefix)
976
+ throw new Error;
977
+ const prefixNum = Number(prefix);
978
+ if (`${prefixNum}` !== prefix)
979
+ throw new Error;
980
+ if (prefixNum < 0 || prefixNum > 128)
981
+ throw new Error;
982
+ new URL(`http://[${address}]`);
983
+ } catch {
984
+ payload.issues.push({
985
+ code: "invalid_format",
986
+ format: "cidrv6",
987
+ input: payload.value,
988
+ inst,
989
+ continue: !def.abort
990
+ });
991
+ }
992
+ };
993
+ });
994
+ function isValidBase64(data) {
995
+ if (data === "")
996
+ return true;
997
+ if (data.length % 4 !== 0)
998
+ return false;
999
+ try {
1000
+ atob(data);
1001
+ return true;
1002
+ } catch {
1003
+ return false;
1004
+ }
1005
+ }
1006
+ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1007
+ def.pattern ?? (def.pattern = base64);
1008
+ $ZodStringFormat.init(inst, def);
1009
+ inst._zod.onattach.push((inst) => {
1010
+ inst._zod.bag.contentEncoding = "base64";
1011
+ });
1012
+ inst._zod.check = (payload) => {
1013
+ if (isValidBase64(payload.value))
1014
+ return;
1015
+ payload.issues.push({
1016
+ code: "invalid_format",
1017
+ format: "base64",
1018
+ input: payload.value,
1019
+ inst,
1020
+ continue: !def.abort
1021
+ });
1022
+ };
1023
+ });
1024
+ function isValidBase64URL(data) {
1025
+ if (!base64url.test(data))
1026
+ return false;
1027
+ const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1028
+ const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
1029
+ return isValidBase64(padded);
1030
+ }
1031
+ var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1032
+ def.pattern ?? (def.pattern = base64url);
1033
+ $ZodStringFormat.init(inst, def);
1034
+ inst._zod.onattach.push((inst) => {
1035
+ inst._zod.bag.contentEncoding = "base64url";
1036
+ });
1037
+ inst._zod.check = (payload) => {
1038
+ if (isValidBase64URL(payload.value))
1039
+ return;
1040
+ payload.issues.push({
1041
+ code: "invalid_format",
1042
+ format: "base64url",
1043
+ input: payload.value,
1044
+ inst,
1045
+ continue: !def.abort
1046
+ });
1047
+ };
1048
+ });
1049
+ var $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1050
+ def.pattern ?? (def.pattern = e164);
1051
+ $ZodStringFormat.init(inst, def);
1052
+ });
1053
+ function isValidJWT(token, algorithm = null) {
1054
+ try {
1055
+ const tokensParts = token.split(".");
1056
+ if (tokensParts.length !== 3)
1057
+ return false;
1058
+ const [header] = tokensParts;
1059
+ if (!header)
1060
+ return false;
1061
+ const parsedHeader = JSON.parse(atob(header));
1062
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
1063
+ return false;
1064
+ if (!parsedHeader.alg)
1065
+ return false;
1066
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
1067
+ return false;
1068
+ return true;
1069
+ } catch {
1070
+ return false;
1071
+ }
1072
+ }
1073
+ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1074
+ $ZodStringFormat.init(inst, def);
1075
+ inst._zod.check = (payload) => {
1076
+ if (isValidJWT(payload.value, def.alg))
1077
+ return;
1078
+ payload.issues.push({
1079
+ code: "invalid_format",
1080
+ format: "jwt",
1081
+ input: payload.value,
1082
+ inst,
1083
+ continue: !def.abort
1084
+ });
1085
+ };
1086
+ });
1087
+ function handleArrayResult(result, final, index) {
1088
+ if (result.issues.length) {
1089
+ final.issues.push(...prefixIssues(index, result.issues));
1090
+ }
1091
+ final.value[index] = result.value;
1092
+ }
1093
+ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1094
+ $ZodType.init(inst, def);
1095
+ inst._zod.parse = (payload, ctx) => {
1096
+ const input = payload.value;
1097
+ if (!Array.isArray(input)) {
1098
+ payload.issues.push({
1099
+ expected: "array",
1100
+ code: "invalid_type",
1101
+ input,
1102
+ inst
1103
+ });
1104
+ return payload;
1105
+ }
1106
+ payload.value = Array(input.length);
1107
+ const proms = [];
1108
+ for (let i = 0;i < input.length; i++) {
1109
+ const item = input[i];
1110
+ const result = def.element._zod.run({
1111
+ value: item,
1112
+ issues: []
1113
+ }, ctx);
1114
+ if (result instanceof Promise) {
1115
+ proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1116
+ } else {
1117
+ handleArrayResult(result, payload, i);
1118
+ }
1119
+ }
1120
+ if (proms.length) {
1121
+ return Promise.all(proms).then(() => payload);
1122
+ }
1123
+ return payload;
1124
+ };
1125
+ });
1126
+ function handleUnionResults(results, final, inst, ctx) {
1127
+ for (const result of results) {
1128
+ if (result.issues.length === 0) {
1129
+ final.value = result.value;
1130
+ return final;
1131
+ }
1132
+ }
1133
+ const nonaborted = results.filter((r) => !aborted(r));
1134
+ if (nonaborted.length === 1) {
1135
+ final.value = nonaborted[0].value;
1136
+ return nonaborted[0];
1137
+ }
1138
+ final.issues.push({
1139
+ code: "invalid_union",
1140
+ input: final.value,
1141
+ inst,
1142
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1143
+ });
1144
+ return final;
1145
+ }
1146
+ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1147
+ $ZodType.init(inst, def);
1148
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
1149
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
1150
+ defineLazy(inst._zod, "values", () => {
1151
+ if (def.options.every((o) => o._zod.values)) {
1152
+ return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1153
+ }
1154
+ return;
1155
+ });
1156
+ defineLazy(inst._zod, "pattern", () => {
1157
+ if (def.options.every((o) => o._zod.pattern)) {
1158
+ const patterns = def.options.map((o) => o._zod.pattern);
1159
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1160
+ }
1161
+ return;
1162
+ });
1163
+ const single = def.options.length === 1;
1164
+ const first = def.options[0]._zod.run;
1165
+ inst._zod.parse = (payload, ctx) => {
1166
+ if (single) {
1167
+ return first(payload, ctx);
1168
+ }
1169
+ let async = false;
1170
+ const results = [];
1171
+ for (const option of def.options) {
1172
+ const result = option._zod.run({
1173
+ value: payload.value,
1174
+ issues: []
1175
+ }, ctx);
1176
+ if (result instanceof Promise) {
1177
+ results.push(result);
1178
+ async = true;
1179
+ } else {
1180
+ if (result.issues.length === 0)
1181
+ return result;
1182
+ results.push(result);
1183
+ }
1184
+ }
1185
+ if (!async)
1186
+ return handleUnionResults(results, payload, inst, ctx);
1187
+ return Promise.all(results).then((results) => {
1188
+ return handleUnionResults(results, payload, inst, ctx);
1189
+ });
1190
+ };
1191
+ });
1192
+ var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1193
+ $ZodType.init(inst, def);
1194
+ inst._zod.parse = (payload, ctx) => {
1195
+ const input = payload.value;
1196
+ const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1197
+ const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1198
+ const async = left instanceof Promise || right instanceof Promise;
1199
+ if (async) {
1200
+ return Promise.all([left, right]).then(([left, right]) => {
1201
+ return handleIntersectionResults(payload, left, right);
1202
+ });
1203
+ }
1204
+ return handleIntersectionResults(payload, left, right);
1205
+ };
1206
+ });
1207
+ function mergeValues(a, b) {
1208
+ if (a === b) {
1209
+ return { valid: true, data: a };
1210
+ }
1211
+ if (a instanceof Date && b instanceof Date && +a === +b) {
1212
+ return { valid: true, data: a };
1213
+ }
1214
+ if (isPlainObject(a) && isPlainObject(b)) {
1215
+ const bKeys = Object.keys(b);
1216
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1217
+ const newObj = { ...a, ...b };
1218
+ for (const key of sharedKeys) {
1219
+ const sharedValue = mergeValues(a[key], b[key]);
1220
+ if (!sharedValue.valid) {
1221
+ return {
1222
+ valid: false,
1223
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1224
+ };
1225
+ }
1226
+ newObj[key] = sharedValue.data;
1227
+ }
1228
+ return { valid: true, data: newObj };
1229
+ }
1230
+ if (Array.isArray(a) && Array.isArray(b)) {
1231
+ if (a.length !== b.length) {
1232
+ return { valid: false, mergeErrorPath: [] };
1233
+ }
1234
+ const newArray = [];
1235
+ for (let index = 0;index < a.length; index++) {
1236
+ const itemA = a[index];
1237
+ const itemB = b[index];
1238
+ const sharedValue = mergeValues(itemA, itemB);
1239
+ if (!sharedValue.valid) {
1240
+ return {
1241
+ valid: false,
1242
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1243
+ };
1244
+ }
1245
+ newArray.push(sharedValue.data);
1246
+ }
1247
+ return { valid: true, data: newArray };
1248
+ }
1249
+ return { valid: false, mergeErrorPath: [] };
1250
+ }
1251
+ function handleIntersectionResults(result, left, right) {
1252
+ if (left.issues.length) {
1253
+ result.issues.push(...left.issues);
1254
+ }
1255
+ if (right.issues.length) {
1256
+ result.issues.push(...right.issues);
1257
+ }
1258
+ if (aborted(result))
1259
+ return result;
1260
+ const merged = mergeValues(left.value, right.value);
1261
+ if (!merged.valid) {
1262
+ throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1263
+ }
1264
+ result.value = merged.data;
1265
+ return result;
1266
+ }
1267
+ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
1268
+ $ZodType.init(inst, def);
1269
+ inst._zod.parse = (payload, ctx) => {
1270
+ if (ctx.direction === "backward") {
1271
+ throw new $ZodEncodeError(inst.constructor.name);
1272
+ }
1273
+ const _out = def.transform(payload.value, payload);
1274
+ if (ctx.async) {
1275
+ const output = _out instanceof Promise ? _out : Promise.resolve(_out);
1276
+ return output.then((output) => {
1277
+ payload.value = output;
1278
+ return payload;
1279
+ });
1280
+ }
1281
+ if (_out instanceof Promise) {
1282
+ throw new $ZodAsyncError;
1283
+ }
1284
+ payload.value = _out;
1285
+ return payload;
1286
+ };
1287
+ });
1288
+ function handleOptionalResult(result, input) {
1289
+ if (result.issues.length && input === undefined) {
1290
+ return { issues: [], value: undefined };
1291
+ }
1292
+ return result;
1293
+ }
1294
+ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
1295
+ $ZodType.init(inst, def);
1296
+ inst._zod.optin = "optional";
1297
+ inst._zod.optout = "optional";
1298
+ defineLazy(inst._zod, "values", () => {
1299
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
1300
+ });
1301
+ defineLazy(inst._zod, "pattern", () => {
1302
+ const pattern = def.innerType._zod.pattern;
1303
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : undefined;
1304
+ });
1305
+ inst._zod.parse = (payload, ctx) => {
1306
+ if (def.innerType._zod.optin === "optional") {
1307
+ const result = def.innerType._zod.run(payload, ctx);
1308
+ if (result instanceof Promise)
1309
+ return result.then((r) => handleOptionalResult(r, payload.value));
1310
+ return handleOptionalResult(result, payload.value);
1311
+ }
1312
+ if (payload.value === undefined) {
1313
+ return payload;
1314
+ }
1315
+ return def.innerType._zod.run(payload, ctx);
1316
+ };
1317
+ });
1318
+ var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
1319
+ $ZodType.init(inst, def);
1320
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1321
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1322
+ defineLazy(inst._zod, "pattern", () => {
1323
+ const pattern = def.innerType._zod.pattern;
1324
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : undefined;
1325
+ });
1326
+ defineLazy(inst._zod, "values", () => {
1327
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
1328
+ });
1329
+ inst._zod.parse = (payload, ctx) => {
1330
+ if (payload.value === null)
1331
+ return payload;
1332
+ return def.innerType._zod.run(payload, ctx);
1333
+ };
1334
+ });
1335
+ var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
1336
+ $ZodType.init(inst, def);
1337
+ inst._zod.optin = "optional";
1338
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1339
+ inst._zod.parse = (payload, ctx) => {
1340
+ if (ctx.direction === "backward") {
1341
+ return def.innerType._zod.run(payload, ctx);
1342
+ }
1343
+ if (payload.value === undefined) {
1344
+ payload.value = def.defaultValue;
1345
+ return payload;
1346
+ }
1347
+ const result = def.innerType._zod.run(payload, ctx);
1348
+ if (result instanceof Promise) {
1349
+ return result.then((result) => handleDefaultResult(result, def));
1350
+ }
1351
+ return handleDefaultResult(result, def);
1352
+ };
1353
+ });
1354
+ function handleDefaultResult(payload, def) {
1355
+ if (payload.value === undefined) {
1356
+ payload.value = def.defaultValue;
1357
+ }
1358
+ return payload;
1359
+ }
1360
+ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
1361
+ $ZodType.init(inst, def);
1362
+ inst._zod.optin = "optional";
1363
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1364
+ inst._zod.parse = (payload, ctx) => {
1365
+ if (ctx.direction === "backward") {
1366
+ return def.innerType._zod.run(payload, ctx);
1367
+ }
1368
+ if (payload.value === undefined) {
1369
+ payload.value = def.defaultValue;
1370
+ }
1371
+ return def.innerType._zod.run(payload, ctx);
1372
+ };
1373
+ });
1374
+ var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
1375
+ $ZodType.init(inst, def);
1376
+ defineLazy(inst._zod, "values", () => {
1377
+ const v = def.innerType._zod.values;
1378
+ return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
1379
+ });
1380
+ inst._zod.parse = (payload, ctx) => {
1381
+ const result = def.innerType._zod.run(payload, ctx);
1382
+ if (result instanceof Promise) {
1383
+ return result.then((result) => handleNonOptionalResult(result, inst));
1384
+ }
1385
+ return handleNonOptionalResult(result, inst);
1386
+ };
1387
+ });
1388
+ function handleNonOptionalResult(payload, inst) {
1389
+ if (!payload.issues.length && payload.value === undefined) {
1390
+ payload.issues.push({
1391
+ code: "invalid_type",
1392
+ expected: "nonoptional",
1393
+ input: payload.value,
1394
+ inst
1395
+ });
1396
+ }
1397
+ return payload;
1398
+ }
1399
+ var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
1400
+ $ZodType.init(inst, def);
1401
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1402
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1403
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1404
+ inst._zod.parse = (payload, ctx) => {
1405
+ if (ctx.direction === "backward") {
1406
+ return def.innerType._zod.run(payload, ctx);
1407
+ }
1408
+ const result = def.innerType._zod.run(payload, ctx);
1409
+ if (result instanceof Promise) {
1410
+ return result.then((result) => {
1411
+ payload.value = result.value;
1412
+ if (result.issues.length) {
1413
+ payload.value = def.catchValue({
1414
+ ...payload,
1415
+ error: {
1416
+ issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
1417
+ },
1418
+ input: payload.value
1419
+ });
1420
+ payload.issues = [];
1421
+ }
1422
+ return payload;
1423
+ });
1424
+ }
1425
+ payload.value = result.value;
1426
+ if (result.issues.length) {
1427
+ payload.value = def.catchValue({
1428
+ ...payload,
1429
+ error: {
1430
+ issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
1431
+ },
1432
+ input: payload.value
1433
+ });
1434
+ payload.issues = [];
1435
+ }
1436
+ return payload;
1437
+ };
1438
+ });
1439
+ var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
1440
+ $ZodType.init(inst, def);
1441
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
1442
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1443
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1444
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
1445
+ inst._zod.parse = (payload, ctx) => {
1446
+ if (ctx.direction === "backward") {
1447
+ const right = def.out._zod.run(payload, ctx);
1448
+ if (right instanceof Promise) {
1449
+ return right.then((right) => handlePipeResult(right, def.in, ctx));
1450
+ }
1451
+ return handlePipeResult(right, def.in, ctx);
1452
+ }
1453
+ const left = def.in._zod.run(payload, ctx);
1454
+ if (left instanceof Promise) {
1455
+ return left.then((left) => handlePipeResult(left, def.out, ctx));
1456
+ }
1457
+ return handlePipeResult(left, def.out, ctx);
1458
+ };
1459
+ });
1460
+ function handlePipeResult(left, next, ctx) {
1461
+ if (left.issues.length) {
1462
+ left.aborted = true;
1463
+ return left;
1464
+ }
1465
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
1466
+ }
1467
+ var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
1468
+ $ZodType.init(inst, def);
1469
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1470
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1471
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1472
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1473
+ inst._zod.parse = (payload, ctx) => {
1474
+ if (ctx.direction === "backward") {
1475
+ return def.innerType._zod.run(payload, ctx);
1476
+ }
1477
+ const result = def.innerType._zod.run(payload, ctx);
1478
+ if (result instanceof Promise) {
1479
+ return result.then(handleReadonlyResult);
1480
+ }
1481
+ return handleReadonlyResult(result);
1482
+ };
1483
+ });
1484
+ function handleReadonlyResult(payload) {
1485
+ payload.value = Object.freeze(payload.value);
1486
+ return payload;
1487
+ }
1488
+ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
1489
+ $ZodCheck.init(inst, def);
1490
+ $ZodType.init(inst, def);
1491
+ inst._zod.parse = (payload, _) => {
1492
+ return payload;
1493
+ };
1494
+ inst._zod.check = (payload) => {
1495
+ const input = payload.value;
1496
+ const r = def.fn(input);
1497
+ if (r instanceof Promise) {
1498
+ return r.then((r) => handleRefineResult(r, payload, input, inst));
1499
+ }
1500
+ handleRefineResult(r, payload, input, inst);
1501
+ return;
1502
+ };
1503
+ });
1504
+ function handleRefineResult(result, payload, input, inst) {
1505
+ if (!result) {
1506
+ const _iss = {
1507
+ code: "custom",
1508
+ input,
1509
+ inst,
1510
+ path: [...inst._zod.def.path ?? []],
1511
+ continue: !inst._zod.def.abort
1512
+ };
1513
+ if (inst._zod.def.params)
1514
+ _iss.params = inst._zod.def.params;
1515
+ payload.issues.push(issue(_iss));
1516
+ }
1517
+ }
1518
+ // node_modules/zod/v4/core/registries.js
1519
+ var $output = Symbol("ZodOutput");
1520
+ var $input = Symbol("ZodInput");
1521
+
1522
+ class $ZodRegistry {
1523
+ constructor() {
1524
+ this._map = new WeakMap;
1525
+ this._idmap = new Map;
1526
+ }
1527
+ add(schema, ..._meta) {
1528
+ const meta = _meta[0];
1529
+ this._map.set(schema, meta);
1530
+ if (meta && typeof meta === "object" && "id" in meta) {
1531
+ if (this._idmap.has(meta.id)) {
1532
+ throw new Error(`ID ${meta.id} already exists in the registry`);
1533
+ }
1534
+ this._idmap.set(meta.id, schema);
1535
+ }
1536
+ return this;
1537
+ }
1538
+ clear() {
1539
+ this._map = new WeakMap;
1540
+ this._idmap = new Map;
1541
+ return this;
1542
+ }
1543
+ remove(schema) {
1544
+ const meta = this._map.get(schema);
1545
+ if (meta && typeof meta === "object" && "id" in meta) {
1546
+ this._idmap.delete(meta.id);
1547
+ }
1548
+ this._map.delete(schema);
1549
+ return this;
1550
+ }
1551
+ get(schema) {
1552
+ const p = schema._zod.parent;
1553
+ if (p) {
1554
+ const pm = { ...this.get(p) ?? {} };
1555
+ delete pm.id;
1556
+ const f = { ...pm, ...this._map.get(schema) };
1557
+ return Object.keys(f).length ? f : undefined;
1558
+ }
1559
+ return this._map.get(schema);
1560
+ }
1561
+ has(schema) {
1562
+ return this._map.has(schema);
1563
+ }
1564
+ }
1565
+ function registry() {
1566
+ return new $ZodRegistry;
1567
+ }
1568
+ var globalRegistry = /* @__PURE__ */ registry();
1569
+ // node_modules/zod/v4/core/api.js
1570
+ function _string(Class, params) {
1571
+ return new Class({
1572
+ type: "string",
1573
+ ...normalizeParams(params)
1574
+ });
1575
+ }
1576
+ function _email(Class, params) {
1577
+ return new Class({
1578
+ type: "string",
1579
+ format: "email",
1580
+ check: "string_format",
1581
+ abort: false,
1582
+ ...normalizeParams(params)
1583
+ });
1584
+ }
1585
+ function _guid(Class, params) {
1586
+ return new Class({
1587
+ type: "string",
1588
+ format: "guid",
1589
+ check: "string_format",
1590
+ abort: false,
1591
+ ...normalizeParams(params)
1592
+ });
1593
+ }
1594
+ function _uuid(Class, params) {
1595
+ return new Class({
1596
+ type: "string",
1597
+ format: "uuid",
1598
+ check: "string_format",
1599
+ abort: false,
1600
+ ...normalizeParams(params)
1601
+ });
1602
+ }
1603
+ function _uuidv4(Class, params) {
1604
+ return new Class({
1605
+ type: "string",
1606
+ format: "uuid",
1607
+ check: "string_format",
1608
+ abort: false,
1609
+ version: "v4",
1610
+ ...normalizeParams(params)
1611
+ });
1612
+ }
1613
+ function _uuidv6(Class, params) {
1614
+ return new Class({
1615
+ type: "string",
1616
+ format: "uuid",
1617
+ check: "string_format",
1618
+ abort: false,
1619
+ version: "v6",
1620
+ ...normalizeParams(params)
1621
+ });
1622
+ }
1623
+ function _uuidv7(Class, params) {
1624
+ return new Class({
1625
+ type: "string",
1626
+ format: "uuid",
1627
+ check: "string_format",
1628
+ abort: false,
1629
+ version: "v7",
1630
+ ...normalizeParams(params)
1631
+ });
1632
+ }
1633
+ function _url(Class, params) {
1634
+ return new Class({
1635
+ type: "string",
1636
+ format: "url",
1637
+ check: "string_format",
1638
+ abort: false,
1639
+ ...normalizeParams(params)
1640
+ });
1641
+ }
1642
+ function _emoji2(Class, params) {
1643
+ return new Class({
1644
+ type: "string",
1645
+ format: "emoji",
1646
+ check: "string_format",
1647
+ abort: false,
1648
+ ...normalizeParams(params)
1649
+ });
1650
+ }
1651
+ function _nanoid(Class, params) {
1652
+ return new Class({
1653
+ type: "string",
1654
+ format: "nanoid",
1655
+ check: "string_format",
1656
+ abort: false,
1657
+ ...normalizeParams(params)
1658
+ });
1659
+ }
1660
+ function _cuid(Class, params) {
1661
+ return new Class({
1662
+ type: "string",
1663
+ format: "cuid",
1664
+ check: "string_format",
1665
+ abort: false,
1666
+ ...normalizeParams(params)
1667
+ });
1668
+ }
1669
+ function _cuid2(Class, params) {
1670
+ return new Class({
1671
+ type: "string",
1672
+ format: "cuid2",
1673
+ check: "string_format",
1674
+ abort: false,
1675
+ ...normalizeParams(params)
1676
+ });
1677
+ }
1678
+ function _ulid(Class, params) {
1679
+ return new Class({
1680
+ type: "string",
1681
+ format: "ulid",
1682
+ check: "string_format",
1683
+ abort: false,
1684
+ ...normalizeParams(params)
1685
+ });
1686
+ }
1687
+ function _xid(Class, params) {
1688
+ return new Class({
1689
+ type: "string",
1690
+ format: "xid",
1691
+ check: "string_format",
1692
+ abort: false,
1693
+ ...normalizeParams(params)
1694
+ });
1695
+ }
1696
+ function _ksuid(Class, params) {
1697
+ return new Class({
1698
+ type: "string",
1699
+ format: "ksuid",
1700
+ check: "string_format",
1701
+ abort: false,
1702
+ ...normalizeParams(params)
1703
+ });
1704
+ }
1705
+ function _ipv4(Class, params) {
1706
+ return new Class({
1707
+ type: "string",
1708
+ format: "ipv4",
1709
+ check: "string_format",
1710
+ abort: false,
1711
+ ...normalizeParams(params)
1712
+ });
1713
+ }
1714
+ function _ipv6(Class, params) {
1715
+ return new Class({
1716
+ type: "string",
1717
+ format: "ipv6",
1718
+ check: "string_format",
1719
+ abort: false,
1720
+ ...normalizeParams(params)
1721
+ });
1722
+ }
1723
+ function _cidrv4(Class, params) {
1724
+ return new Class({
1725
+ type: "string",
1726
+ format: "cidrv4",
1727
+ check: "string_format",
1728
+ abort: false,
1729
+ ...normalizeParams(params)
1730
+ });
1731
+ }
1732
+ function _cidrv6(Class, params) {
1733
+ return new Class({
1734
+ type: "string",
1735
+ format: "cidrv6",
1736
+ check: "string_format",
1737
+ abort: false,
1738
+ ...normalizeParams(params)
1739
+ });
1740
+ }
1741
+ function _base64(Class, params) {
1742
+ return new Class({
1743
+ type: "string",
1744
+ format: "base64",
1745
+ check: "string_format",
1746
+ abort: false,
1747
+ ...normalizeParams(params)
1748
+ });
1749
+ }
1750
+ function _base64url(Class, params) {
1751
+ return new Class({
1752
+ type: "string",
1753
+ format: "base64url",
1754
+ check: "string_format",
1755
+ abort: false,
1756
+ ...normalizeParams(params)
1757
+ });
1758
+ }
1759
+ function _e164(Class, params) {
1760
+ return new Class({
1761
+ type: "string",
1762
+ format: "e164",
1763
+ check: "string_format",
1764
+ abort: false,
1765
+ ...normalizeParams(params)
1766
+ });
1767
+ }
1768
+ function _jwt(Class, params) {
1769
+ return new Class({
1770
+ type: "string",
1771
+ format: "jwt",
1772
+ check: "string_format",
1773
+ abort: false,
1774
+ ...normalizeParams(params)
1775
+ });
1776
+ }
1777
+ function _isoDateTime(Class, params) {
1778
+ return new Class({
1779
+ type: "string",
1780
+ format: "datetime",
1781
+ check: "string_format",
1782
+ offset: false,
1783
+ local: false,
1784
+ precision: null,
1785
+ ...normalizeParams(params)
1786
+ });
1787
+ }
1788
+ function _isoDate(Class, params) {
1789
+ return new Class({
1790
+ type: "string",
1791
+ format: "date",
1792
+ check: "string_format",
1793
+ ...normalizeParams(params)
1794
+ });
1795
+ }
1796
+ function _isoTime(Class, params) {
1797
+ return new Class({
1798
+ type: "string",
1799
+ format: "time",
1800
+ check: "string_format",
1801
+ precision: null,
1802
+ ...normalizeParams(params)
1803
+ });
1804
+ }
1805
+ function _isoDuration(Class, params) {
1806
+ return new Class({
1807
+ type: "string",
1808
+ format: "duration",
1809
+ check: "string_format",
1810
+ ...normalizeParams(params)
1811
+ });
1812
+ }
1813
+ function _maxLength(maximum, params) {
1814
+ const ch = new $ZodCheckMaxLength({
1815
+ check: "max_length",
1816
+ ...normalizeParams(params),
1817
+ maximum
1818
+ });
1819
+ return ch;
1820
+ }
1821
+ function _minLength(minimum, params) {
1822
+ return new $ZodCheckMinLength({
1823
+ check: "min_length",
1824
+ ...normalizeParams(params),
1825
+ minimum
1826
+ });
1827
+ }
1828
+ function _length(length, params) {
1829
+ return new $ZodCheckLengthEquals({
1830
+ check: "length_equals",
1831
+ ...normalizeParams(params),
1832
+ length
1833
+ });
1834
+ }
1835
+ function _regex(pattern, params) {
1836
+ return new $ZodCheckRegex({
1837
+ check: "string_format",
1838
+ format: "regex",
1839
+ ...normalizeParams(params),
1840
+ pattern
1841
+ });
1842
+ }
1843
+ function _lowercase(params) {
1844
+ return new $ZodCheckLowerCase({
1845
+ check: "string_format",
1846
+ format: "lowercase",
1847
+ ...normalizeParams(params)
1848
+ });
1849
+ }
1850
+ function _uppercase(params) {
1851
+ return new $ZodCheckUpperCase({
1852
+ check: "string_format",
1853
+ format: "uppercase",
1854
+ ...normalizeParams(params)
1855
+ });
1856
+ }
1857
+ function _includes(includes, params) {
1858
+ return new $ZodCheckIncludes({
1859
+ check: "string_format",
1860
+ format: "includes",
1861
+ ...normalizeParams(params),
1862
+ includes
1863
+ });
1864
+ }
1865
+ function _startsWith(prefix, params) {
1866
+ return new $ZodCheckStartsWith({
1867
+ check: "string_format",
1868
+ format: "starts_with",
1869
+ ...normalizeParams(params),
1870
+ prefix
1871
+ });
1872
+ }
1873
+ function _endsWith(suffix, params) {
1874
+ return new $ZodCheckEndsWith({
1875
+ check: "string_format",
1876
+ format: "ends_with",
1877
+ ...normalizeParams(params),
1878
+ suffix
1879
+ });
1880
+ }
1881
+ function _overwrite(tx) {
1882
+ return new $ZodCheckOverwrite({
1883
+ check: "overwrite",
1884
+ tx
1885
+ });
1886
+ }
1887
+ function _normalize(form) {
1888
+ return _overwrite((input) => input.normalize(form));
1889
+ }
1890
+ function _trim() {
1891
+ return _overwrite((input) => input.trim());
1892
+ }
1893
+ function _toLowerCase() {
1894
+ return _overwrite((input) => input.toLowerCase());
1895
+ }
1896
+ function _toUpperCase() {
1897
+ return _overwrite((input) => input.toUpperCase());
1898
+ }
1899
+ function _array(Class, element, params) {
1900
+ return new Class({
1901
+ type: "array",
1902
+ element,
1903
+ ...normalizeParams(params)
1904
+ });
1905
+ }
1906
+ function _refine(Class, fn, _params) {
1907
+ const schema = new Class({
1908
+ type: "custom",
1909
+ check: "custom",
1910
+ fn,
1911
+ ...normalizeParams(_params)
1912
+ });
1913
+ return schema;
1914
+ }
1915
+ function _superRefine(fn) {
1916
+ const ch = _check((payload) => {
1917
+ payload.addIssue = (issue2) => {
1918
+ if (typeof issue2 === "string") {
1919
+ payload.issues.push(issue(issue2, payload.value, ch._zod.def));
1920
+ } else {
1921
+ const _issue = issue2;
1922
+ if (_issue.fatal)
1923
+ _issue.continue = false;
1924
+ _issue.code ?? (_issue.code = "custom");
1925
+ _issue.input ?? (_issue.input = payload.value);
1926
+ _issue.inst ?? (_issue.inst = ch);
1927
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
1928
+ payload.issues.push(issue(_issue));
1929
+ }
1930
+ };
1931
+ return fn(payload.value, payload);
1932
+ });
1933
+ return ch;
1934
+ }
1935
+ function _check(fn, params) {
1936
+ const ch = new $ZodCheck({
1937
+ check: "custom",
1938
+ ...normalizeParams(params)
1939
+ });
1940
+ ch._zod.check = fn;
1941
+ return ch;
1942
+ }
1943
+ // node_modules/zod/v4/classic/iso.js
1944
+ var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
1945
+ $ZodISODateTime.init(inst, def);
1946
+ ZodStringFormat.init(inst, def);
1947
+ });
1948
+ function datetime2(params) {
1949
+ return _isoDateTime(ZodISODateTime, params);
1950
+ }
1951
+ var ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
1952
+ $ZodISODate.init(inst, def);
1953
+ ZodStringFormat.init(inst, def);
1954
+ });
1955
+ function date2(params) {
1956
+ return _isoDate(ZodISODate, params);
1957
+ }
1958
+ var ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
1959
+ $ZodISOTime.init(inst, def);
1960
+ ZodStringFormat.init(inst, def);
1961
+ });
1962
+ function time2(params) {
1963
+ return _isoTime(ZodISOTime, params);
1964
+ }
1965
+ var ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
1966
+ $ZodISODuration.init(inst, def);
1967
+ ZodStringFormat.init(inst, def);
1968
+ });
1969
+ function duration2(params) {
1970
+ return _isoDuration(ZodISODuration, params);
1971
+ }
1972
+
1973
+ // node_modules/zod/v4/classic/errors.js
1974
+ var initializer2 = (inst, issues) => {
1975
+ $ZodError.init(inst, issues);
1976
+ inst.name = "ZodError";
1977
+ Object.defineProperties(inst, {
1978
+ format: {
1979
+ value: (mapper) => formatError(inst, mapper)
1980
+ },
1981
+ flatten: {
1982
+ value: (mapper) => flattenError(inst, mapper)
1983
+ },
1984
+ addIssue: {
1985
+ value: (issue) => {
1986
+ inst.issues.push(issue);
1987
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
1988
+ }
1989
+ },
1990
+ addIssues: {
1991
+ value: (issues) => {
1992
+ inst.issues.push(...issues);
1993
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
1994
+ }
1995
+ },
1996
+ isEmpty: {
1997
+ get() {
1998
+ return inst.issues.length === 0;
1999
+ }
2000
+ }
2001
+ });
2002
+ };
2003
+ var ZodError = $constructor("ZodError", initializer2);
2004
+ var ZodRealError = $constructor("ZodError", initializer2, {
2005
+ Parent: Error
2006
+ });
2007
+
2008
+ // node_modules/zod/v4/classic/parse.js
2009
+ var parse3 = /* @__PURE__ */ _parse(ZodRealError);
2010
+ var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
2011
+ var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
2012
+ var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
2013
+ var encode = /* @__PURE__ */ _encode(ZodRealError);
2014
+ var decode = /* @__PURE__ */ _decode(ZodRealError);
2015
+ var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
2016
+ var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
2017
+ var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
2018
+ var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
2019
+ var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
2020
+ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
4
2021
 
2022
+ // node_modules/zod/v4/classic/schemas.js
2023
+ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2024
+ $ZodType.init(inst, def);
2025
+ inst.def = def;
2026
+ inst.type = def.type;
2027
+ Object.defineProperty(inst, "_def", { value: def });
2028
+ inst.check = (...checks) => {
2029
+ return inst.clone({
2030
+ ...def,
2031
+ checks: [
2032
+ ...def.checks ?? [],
2033
+ ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
2034
+ ]
2035
+ });
2036
+ };
2037
+ inst.clone = (def, params) => clone(inst, def, params);
2038
+ inst.brand = () => inst;
2039
+ inst.register = (reg, meta) => {
2040
+ reg.add(inst, meta);
2041
+ return inst;
2042
+ };
2043
+ inst.parse = (data, params) => parse3(inst, data, params, { callee: inst.parse });
2044
+ inst.safeParse = (data, params) => safeParse2(inst, data, params);
2045
+ inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
2046
+ inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
2047
+ inst.spa = inst.safeParseAsync;
2048
+ inst.encode = (data, params) => encode(inst, data, params);
2049
+ inst.decode = (data, params) => decode(inst, data, params);
2050
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
2051
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
2052
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
2053
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
2054
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
2055
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
2056
+ inst.refine = (check, params) => inst.check(refine(check, params));
2057
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
2058
+ inst.overwrite = (fn) => inst.check(_overwrite(fn));
2059
+ inst.optional = () => optional(inst);
2060
+ inst.nullable = () => nullable(inst);
2061
+ inst.nullish = () => optional(nullable(inst));
2062
+ inst.nonoptional = (params) => nonoptional(inst, params);
2063
+ inst.array = () => array(inst);
2064
+ inst.or = (arg) => union([inst, arg]);
2065
+ inst.and = (arg) => intersection(inst, arg);
2066
+ inst.transform = (tx) => pipe(inst, transform(tx));
2067
+ inst.default = (def) => _default(inst, def);
2068
+ inst.prefault = (def) => prefault(inst, def);
2069
+ inst.catch = (params) => _catch(inst, params);
2070
+ inst.pipe = (target) => pipe(inst, target);
2071
+ inst.readonly = () => readonly(inst);
2072
+ inst.describe = (description) => {
2073
+ const cl = inst.clone();
2074
+ globalRegistry.add(cl, { description });
2075
+ return cl;
2076
+ };
2077
+ Object.defineProperty(inst, "description", {
2078
+ get() {
2079
+ return globalRegistry.get(inst)?.description;
2080
+ },
2081
+ configurable: true
2082
+ });
2083
+ inst.meta = (...args) => {
2084
+ if (args.length === 0) {
2085
+ return globalRegistry.get(inst);
2086
+ }
2087
+ const cl = inst.clone();
2088
+ globalRegistry.add(cl, args[0]);
2089
+ return cl;
2090
+ };
2091
+ inst.isOptional = () => inst.safeParse(undefined).success;
2092
+ inst.isNullable = () => inst.safeParse(null).success;
2093
+ return inst;
2094
+ });
2095
+ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
2096
+ $ZodString.init(inst, def);
2097
+ ZodType.init(inst, def);
2098
+ const bag = inst._zod.bag;
2099
+ inst.format = bag.format ?? null;
2100
+ inst.minLength = bag.minimum ?? null;
2101
+ inst.maxLength = bag.maximum ?? null;
2102
+ inst.regex = (...args) => inst.check(_regex(...args));
2103
+ inst.includes = (...args) => inst.check(_includes(...args));
2104
+ inst.startsWith = (...args) => inst.check(_startsWith(...args));
2105
+ inst.endsWith = (...args) => inst.check(_endsWith(...args));
2106
+ inst.min = (...args) => inst.check(_minLength(...args));
2107
+ inst.max = (...args) => inst.check(_maxLength(...args));
2108
+ inst.length = (...args) => inst.check(_length(...args));
2109
+ inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
2110
+ inst.lowercase = (params) => inst.check(_lowercase(params));
2111
+ inst.uppercase = (params) => inst.check(_uppercase(params));
2112
+ inst.trim = () => inst.check(_trim());
2113
+ inst.normalize = (...args) => inst.check(_normalize(...args));
2114
+ inst.toLowerCase = () => inst.check(_toLowerCase());
2115
+ inst.toUpperCase = () => inst.check(_toUpperCase());
2116
+ });
2117
+ var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
2118
+ $ZodString.init(inst, def);
2119
+ _ZodString.init(inst, def);
2120
+ inst.email = (params) => inst.check(_email(ZodEmail, params));
2121
+ inst.url = (params) => inst.check(_url(ZodURL, params));
2122
+ inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
2123
+ inst.emoji = (params) => inst.check(_emoji2(ZodEmoji, params));
2124
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
2125
+ inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
2126
+ inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
2127
+ inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
2128
+ inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
2129
+ inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
2130
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
2131
+ inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
2132
+ inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
2133
+ inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
2134
+ inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
2135
+ inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
2136
+ inst.xid = (params) => inst.check(_xid(ZodXID, params));
2137
+ inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
2138
+ inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
2139
+ inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
2140
+ inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
2141
+ inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
2142
+ inst.e164 = (params) => inst.check(_e164(ZodE164, params));
2143
+ inst.datetime = (params) => inst.check(datetime2(params));
2144
+ inst.date = (params) => inst.check(date2(params));
2145
+ inst.time = (params) => inst.check(time2(params));
2146
+ inst.duration = (params) => inst.check(duration2(params));
2147
+ });
2148
+ function string2(params) {
2149
+ return _string(ZodString, params);
2150
+ }
2151
+ var ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
2152
+ $ZodStringFormat.init(inst, def);
2153
+ _ZodString.init(inst, def);
2154
+ });
2155
+ var ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
2156
+ $ZodEmail.init(inst, def);
2157
+ ZodStringFormat.init(inst, def);
2158
+ });
2159
+ var ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
2160
+ $ZodGUID.init(inst, def);
2161
+ ZodStringFormat.init(inst, def);
2162
+ });
2163
+ var ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
2164
+ $ZodUUID.init(inst, def);
2165
+ ZodStringFormat.init(inst, def);
2166
+ });
2167
+ var ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
2168
+ $ZodURL.init(inst, def);
2169
+ ZodStringFormat.init(inst, def);
2170
+ });
2171
+ var ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
2172
+ $ZodEmoji.init(inst, def);
2173
+ ZodStringFormat.init(inst, def);
2174
+ });
2175
+ var ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
2176
+ $ZodNanoID.init(inst, def);
2177
+ ZodStringFormat.init(inst, def);
2178
+ });
2179
+ var ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
2180
+ $ZodCUID.init(inst, def);
2181
+ ZodStringFormat.init(inst, def);
2182
+ });
2183
+ var ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
2184
+ $ZodCUID2.init(inst, def);
2185
+ ZodStringFormat.init(inst, def);
2186
+ });
2187
+ var ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
2188
+ $ZodULID.init(inst, def);
2189
+ ZodStringFormat.init(inst, def);
2190
+ });
2191
+ var ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
2192
+ $ZodXID.init(inst, def);
2193
+ ZodStringFormat.init(inst, def);
2194
+ });
2195
+ var ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
2196
+ $ZodKSUID.init(inst, def);
2197
+ ZodStringFormat.init(inst, def);
2198
+ });
2199
+ var ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
2200
+ $ZodIPv4.init(inst, def);
2201
+ ZodStringFormat.init(inst, def);
2202
+ });
2203
+ var ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
2204
+ $ZodIPv6.init(inst, def);
2205
+ ZodStringFormat.init(inst, def);
2206
+ });
2207
+ var ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
2208
+ $ZodCIDRv4.init(inst, def);
2209
+ ZodStringFormat.init(inst, def);
2210
+ });
2211
+ var ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
2212
+ $ZodCIDRv6.init(inst, def);
2213
+ ZodStringFormat.init(inst, def);
2214
+ });
2215
+ var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
2216
+ $ZodBase64.init(inst, def);
2217
+ ZodStringFormat.init(inst, def);
2218
+ });
2219
+ var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
2220
+ $ZodBase64URL.init(inst, def);
2221
+ ZodStringFormat.init(inst, def);
2222
+ });
2223
+ var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
2224
+ $ZodE164.init(inst, def);
2225
+ ZodStringFormat.init(inst, def);
2226
+ });
2227
+ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
2228
+ $ZodJWT.init(inst, def);
2229
+ ZodStringFormat.init(inst, def);
2230
+ });
2231
+ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2232
+ $ZodArray.init(inst, def);
2233
+ ZodType.init(inst, def);
2234
+ inst.element = def.element;
2235
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
2236
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
2237
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
2238
+ inst.length = (len, params) => inst.check(_length(len, params));
2239
+ inst.unwrap = () => inst.element;
2240
+ });
2241
+ function array(element, params) {
2242
+ return _array(ZodArray, element, params);
2243
+ }
2244
+ var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
2245
+ $ZodUnion.init(inst, def);
2246
+ ZodType.init(inst, def);
2247
+ inst.options = def.options;
2248
+ });
2249
+ function union(options, params) {
2250
+ return new ZodUnion({
2251
+ type: "union",
2252
+ options,
2253
+ ...normalizeParams(params)
2254
+ });
2255
+ }
2256
+ var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
2257
+ $ZodIntersection.init(inst, def);
2258
+ ZodType.init(inst, def);
2259
+ });
2260
+ function intersection(left, right) {
2261
+ return new ZodIntersection({
2262
+ type: "intersection",
2263
+ left,
2264
+ right
2265
+ });
2266
+ }
2267
+ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
2268
+ $ZodTransform.init(inst, def);
2269
+ ZodType.init(inst, def);
2270
+ inst._zod.parse = (payload, _ctx) => {
2271
+ if (_ctx.direction === "backward") {
2272
+ throw new $ZodEncodeError(inst.constructor.name);
2273
+ }
2274
+ payload.addIssue = (issue2) => {
2275
+ if (typeof issue2 === "string") {
2276
+ payload.issues.push(issue(issue2, payload.value, def));
2277
+ } else {
2278
+ const _issue = issue2;
2279
+ if (_issue.fatal)
2280
+ _issue.continue = false;
2281
+ _issue.code ?? (_issue.code = "custom");
2282
+ _issue.input ?? (_issue.input = payload.value);
2283
+ _issue.inst ?? (_issue.inst = inst);
2284
+ payload.issues.push(issue(_issue));
2285
+ }
2286
+ };
2287
+ const output = def.transform(payload.value, payload);
2288
+ if (output instanceof Promise) {
2289
+ return output.then((output) => {
2290
+ payload.value = output;
2291
+ return payload;
2292
+ });
2293
+ }
2294
+ payload.value = output;
2295
+ return payload;
2296
+ };
2297
+ });
2298
+ function transform(fn) {
2299
+ return new ZodTransform({
2300
+ type: "transform",
2301
+ transform: fn
2302
+ });
2303
+ }
2304
+ var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
2305
+ $ZodOptional.init(inst, def);
2306
+ ZodType.init(inst, def);
2307
+ inst.unwrap = () => inst._zod.def.innerType;
2308
+ });
2309
+ function optional(innerType) {
2310
+ return new ZodOptional({
2311
+ type: "optional",
2312
+ innerType
2313
+ });
2314
+ }
2315
+ var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
2316
+ $ZodNullable.init(inst, def);
2317
+ ZodType.init(inst, def);
2318
+ inst.unwrap = () => inst._zod.def.innerType;
2319
+ });
2320
+ function nullable(innerType) {
2321
+ return new ZodNullable({
2322
+ type: "nullable",
2323
+ innerType
2324
+ });
2325
+ }
2326
+ var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
2327
+ $ZodDefault.init(inst, def);
2328
+ ZodType.init(inst, def);
2329
+ inst.unwrap = () => inst._zod.def.innerType;
2330
+ inst.removeDefault = inst.unwrap;
2331
+ });
2332
+ function _default(innerType, defaultValue) {
2333
+ return new ZodDefault({
2334
+ type: "default",
2335
+ innerType,
2336
+ get defaultValue() {
2337
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
2338
+ }
2339
+ });
2340
+ }
2341
+ var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
2342
+ $ZodPrefault.init(inst, def);
2343
+ ZodType.init(inst, def);
2344
+ inst.unwrap = () => inst._zod.def.innerType;
2345
+ });
2346
+ function prefault(innerType, defaultValue) {
2347
+ return new ZodPrefault({
2348
+ type: "prefault",
2349
+ innerType,
2350
+ get defaultValue() {
2351
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
2352
+ }
2353
+ });
2354
+ }
2355
+ var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
2356
+ $ZodNonOptional.init(inst, def);
2357
+ ZodType.init(inst, def);
2358
+ inst.unwrap = () => inst._zod.def.innerType;
2359
+ });
2360
+ function nonoptional(innerType, params) {
2361
+ return new ZodNonOptional({
2362
+ type: "nonoptional",
2363
+ innerType,
2364
+ ...normalizeParams(params)
2365
+ });
2366
+ }
2367
+ var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
2368
+ $ZodCatch.init(inst, def);
2369
+ ZodType.init(inst, def);
2370
+ inst.unwrap = () => inst._zod.def.innerType;
2371
+ inst.removeCatch = inst.unwrap;
2372
+ });
2373
+ function _catch(innerType, catchValue) {
2374
+ return new ZodCatch({
2375
+ type: "catch",
2376
+ innerType,
2377
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
2378
+ });
2379
+ }
2380
+ var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
2381
+ $ZodPipe.init(inst, def);
2382
+ ZodType.init(inst, def);
2383
+ inst.in = def.in;
2384
+ inst.out = def.out;
2385
+ });
2386
+ function pipe(in_, out) {
2387
+ return new ZodPipe({
2388
+ type: "pipe",
2389
+ in: in_,
2390
+ out
2391
+ });
2392
+ }
2393
+ var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
2394
+ $ZodReadonly.init(inst, def);
2395
+ ZodType.init(inst, def);
2396
+ inst.unwrap = () => inst._zod.def.innerType;
2397
+ });
2398
+ function readonly(innerType) {
2399
+ return new ZodReadonly({
2400
+ type: "readonly",
2401
+ innerType
2402
+ });
2403
+ }
2404
+ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
2405
+ $ZodCustom.init(inst, def);
2406
+ ZodType.init(inst, def);
2407
+ });
2408
+ function refine(fn, _params = {}) {
2409
+ return _refine(ZodCustom, fn, _params);
2410
+ }
2411
+ function superRefine(fn) {
2412
+ return _superRefine(fn);
2413
+ }
5
2414
  // src/api.ts
6
2415
  var API_BASE = "https://api.commandcode.ai";
7
2416
  function authHeaders(key) {
@@ -180,6 +2589,107 @@ async function resolveKey(getAuth) {
180
2589
  } catch {}
181
2590
  throw new Error("No Command Code API key found. Run /connect, choose Command Code, and paste your key (or `cmd login` in a terminal, or set CMD_API_KEY).");
182
2591
  }
2592
+
2593
+ // src/catalog.ts
2594
+ var MODEL_CATALOG = {
2595
+ "claude-fable-5": { name: "Claude Fable 5", context: 1e6, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 }, modalities: ["text", "image"] },
2596
+ "claude-fable-5-1": { name: "Claude Fable 5.1", context: 1e6, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 10, output: 50, cacheRead: 0.25, cacheWrite: 12.5 }, modalities: ["text", "image"] },
2597
+ "claude-haiku-4-5-20251001": { name: "Claude Haiku 4.5", context: 200000, efforts: null, cost: { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 }, modalities: ["text", "image"] },
2598
+ "claude-opus-4-7": { name: "Claude Opus 4.7", context: 1e6, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, modalities: ["text", "image"] },
2599
+ "claude-opus-4-8": { name: "Claude Opus 4.8", context: 1e6, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, modalities: ["text", "image"] },
2600
+ "claude-opus-5": { name: "Claude Opus 5", context: 1e6, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, modalities: ["text", "image"] },
2601
+ "claude-opus-5-5": { name: "Claude Opus 5.5", context: 1e6, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 4, output: 20, cacheRead: 0.2, cacheWrite: 5 }, modalities: ["text", "image"] },
2602
+ "claude-sonnet-4-6": { name: "Claude Sonnet 4.6", context: 1e6, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, modalities: ["text", "image"] },
2603
+ "claude-sonnet-5": { name: "Claude Sonnet 5", context: 1e6, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 }, modalities: ["text", "image"] },
2604
+ "deepseek/deepseek-v4-flash": { name: "DeepSeek V4 Flash (latest)", context: 1e6, efforts: ["high", "max"], cost: { input: 0.15, output: 0.6, cacheRead: 0.003, cacheWrite: 0 }, modalities: ["text"] },
2605
+ "deepseek/deepseek-v4-flash-fast": { name: "DeepSeek V4 Flash Fast", context: 1e6, efforts: ["low", "high", "max"], cost: { input: 0.28, output: 0.56, cacheRead: 0.07, cacheWrite: 0 }, modalities: ["text"] },
2606
+ "deepseek/deepseek-v4-flash-vision-exp": { name: "DeepSeek V4 Flash Vision (exp)", context: 1e6, efforts: ["high", "max"], cost: { input: 0.15, output: 0.6, cacheRead: 0.003, cacheWrite: 0 }, modalities: ["text", "image"] },
2607
+ "deepseek/deepseek-v4-pro": { name: "DeepSeek V4 Pro (latest)", context: 1e6, efforts: ["high", "max"], cost: { input: 0.66, output: 1.98, cacheRead: 0.022, cacheWrite: 0 }, modalities: ["text"] },
2608
+ "deepseek/deepseek-v4.1-flash": { name: "DeepSeek V4.1 Flash", context: 1e6, efforts: ["low", "high", "max"], cost: { input: 0.15, output: 0.6, cacheRead: 0.003, cacheWrite: 0 }, modalities: ["text", "image"] },
2609
+ "google/gemini-3.1-flash-lite": { name: "Gemini 3.1 Flash Lite", context: 1e6, efforts: ["low", "medium", "high"], cost: { input: 0.25, output: 1.5, cacheRead: 0.03, cacheWrite: 0 }, modalities: ["text", "image"] },
2610
+ "google/gemini-3.5-flash": { name: "Gemini 3.5 Flash", context: 1e6, efforts: ["low", "medium", "high"], cost: { input: 1.5, output: 9, cacheRead: 0.15, cacheWrite: 0 }, modalities: ["text", "image"] },
2611
+ "google/gemini-3.5-flash-lite": { name: "Gemini 3.5 Flash Lite", context: 1e6, efforts: ["low", "medium", "high"], cost: { input: 0.3, output: 2.5, cacheRead: 0.03, cacheWrite: 0 }, modalities: ["text", "image"] },
2612
+ "google/gemini-3.6-flash": { name: "Gemini 3.6 Flash", context: 1e6, efforts: ["low", "medium", "high"], cost: { input: 1.5, output: 7.5, cacheRead: 0.15, cacheWrite: 0 }, modalities: ["text", "image"] },
2613
+ "google/gemini-3.7-flash": { name: "Gemini 3.7 Flash", context: 1050000, efforts: ["low", "medium", "high"], cost: { input: 1.5, output: 7.5, cacheRead: 0.15, cacheWrite: 0.08334 }, modalities: ["text", "image"] },
2614
+ "google/gemini-3.8-flash": { name: "Gemini 3.8 Flash", context: 1e6, efforts: ["low", "medium", "high"], cost: { input: 1.5, output: 7.5, cacheRead: 0.15, cacheWrite: 0 }, modalities: ["text", "image"] },
2615
+ "gpt-5.3-codex": { name: "GPT-5.3 Codex", context: 400000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 2, output: 8, cacheRead: 0.5, cacheWrite: 0 }, modalities: ["text", "image"] },
2616
+ "gpt-5.4": { name: "GPT-5.4", context: 400000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0 }, modalities: ["text", "image"] },
2617
+ "gpt-5.4-mini": { name: "GPT-5.4 Mini", context: 400000, efforts: ["low", "medium", "high"], cost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 }, modalities: ["text", "image"] },
2618
+ "gpt-5.5": { name: "GPT-5.5", context: 400000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 }, modalities: ["text", "image"] },
2619
+ "gpt-5.6-luna": { name: "GPT-5.6 Luna", context: 1050000, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25 }, modalities: ["text", "image"] },
2620
+ "gpt-5.6-sol": { name: "GPT-5.6 Sol", context: 1050000, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 6.25 }, modalities: ["text", "image"] },
2621
+ "gpt-5.6-terra": { name: "GPT-5.6 Terra", context: 1050000, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 2.5 }, modalities: ["text", "image"] },
2622
+ "gpt-6-astra": { name: "GPT-6 Astra", context: 1050000, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 }, modalities: ["text", "image"] },
2623
+ "gpt-6-luna": { name: "GPT-6 Luna", context: 1050000, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 0.1, output: 0.5, cacheRead: 0.01, cacheWrite: 0.125 }, modalities: ["text", "image"] },
2624
+ "gpt-6-sol": { name: "GPT-6 Sol", context: 1050000, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 }, modalities: ["text", "image"] },
2625
+ "inclusionai/ling-3.0-flash-sante:free": { name: "Ling 3.0 Flash Sante", context: 262000, efforts: null, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, modalities: ["text"] },
2626
+ "meituan/LongCat-2.0": { name: "LongCat 2.0", context: 1050000, efforts: null, cost: { input: 0.3, output: 1.2, cacheRead: 0.006, cacheWrite: 0 }, modalities: ["text"] },
2627
+ "meta/muse-spark-1.1": { name: "Muse Spark 1.1", context: 1050000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite: 0 }, modalities: ["text", "image"] },
2628
+ "meta/muse-spark-1.2": { name: "Muse Spark 1.2", context: 1050000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite: 0 }, modalities: ["text", "image"] },
2629
+ "meta/muse-spark-1.2-contributor": { name: "Muse Spark 1.2 Contributor", context: 1050000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 0.1, output: 0.2, cacheRead: 0.002, cacheWrite: 0 }, modalities: ["text", "image"] },
2630
+ "meta/muse-spark-1.3": { name: "Muse Spark 1.3", context: 1050000, efforts: ["low", "medium", "high", "xhigh", "max"], cost: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite: 0 }, modalities: ["text", "image"] },
2631
+ "meta/muse-spark-1.3-contributor": { name: "Muse Spark 1.3 Contributor", context: 1050000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 0.1, output: 0.2, cacheRead: 0.002, cacheWrite: 0 }, modalities: ["text", "image"] },
2632
+ "MiniMaxAI/MiniMax-M2.5": { name: "MiniMax M2.5", context: 200000, efforts: null, cost: { input: 0.3, output: 1.2, cacheRead: 0.03, cacheWrite: 0 }, modalities: ["text"] },
2633
+ "MiniMaxAI/MiniMax-M2.7": { name: "MiniMax M2.7", context: 0, efforts: null, cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0 }, modalities: ["text"] },
2634
+ "MiniMaxAI/MiniMax-M3": { name: "MiniMax M3", context: 1e6, efforts: ["low", "medium", "high"], cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0 }, modalities: ["text", "image"] },
2635
+ "moonshotai/Kimi-K2.5": { name: "Kimi K2.5", context: 256000, efforts: null, cost: { input: 0.6, output: 3, cacheRead: 0.1, cacheWrite: 0 }, modalities: ["text", "image"] },
2636
+ "moonshotai/Kimi-K2.6": { name: "Kimi K2.6", context: 256000, efforts: null, cost: { input: 0.95, output: 4, cacheRead: 0.16, cacheWrite: 0 }, modalities: ["text", "image"] },
2637
+ "moonshotai/Kimi-K2.7-Code": { name: "Kimi K2.7 Code", context: 256000, efforts: null, cost: { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0 }, modalities: ["text", "image"] },
2638
+ "moonshotai/Kimi-K2.7-Code-Highspeed": { name: "Kimi K2.7 Code HighSpeed", context: 262000, efforts: null, cost: { input: 1.9, output: 8, cacheRead: 0.38, cacheWrite: 0 }, modalities: ["text", "image"] },
2639
+ "moonshotai/Kimi-K3": { name: "Kimi K3", context: 1e6, efforts: ["low", "high", "max"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 0 }, modalities: ["text", "image"] },
2640
+ "nvidia/nemotron-3-ultra-550b-a55b": { name: "Nemotron 3 Ultra", context: 1e6, efforts: null, cost: { input: 0.6, output: 2.4, cacheRead: 0.12, cacheWrite: 0 }, modalities: ["text"] },
2641
+ "poolside/laguna-s-2.1-free": { name: "Laguna S 2.1", context: 256000, efforts: null, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, modalities: ["text"] },
2642
+ "Qwen/Qwen3.6-Max-Preview": { name: "Qwen 3.6 Max Preview", context: 0, efforts: null, cost: { input: 1.3, output: 7.8, cacheRead: 0.26, cacheWrite: 1.63 }, modalities: ["text"] },
2643
+ "Qwen/Qwen3.6-Plus": { name: "Qwen 3.6 Plus", context: 0, efforts: null, cost: { input: 0.5, output: 3, cacheRead: 0.1, cacheWrite: 0 }, modalities: ["text", "image"] },
2644
+ "Qwen/Qwen3.7-Flash": { name: "Qwen 3.7 Flash", context: 1e6, efforts: null, cost: { input: 0.03, output: 0.13, cacheRead: 0.006, cacheWrite: 0.038 }, modalities: ["text", "image"] },
2645
+ "Qwen/Qwen3.7-Max": { name: "Qwen 3.7 Max", context: 1e6, efforts: null, cost: { input: 2.5, output: 7.5, cacheRead: 0.5, cacheWrite: 3.13 }, modalities: ["text"] },
2646
+ "Qwen/Qwen3.7-Plus": { name: "Qwen 3.7 Plus", context: 1e6, efforts: null, cost: { input: 0.4, output: 1.6, cacheRead: 0.08, cacheWrite: 0.5 }, modalities: ["text", "image"] },
2647
+ "Qwen/Qwen3.8-27B": { name: "Qwen 3.8 27B", context: 262000, efforts: ["low", "medium", "xhigh"], cost: { input: 0.4, output: 3, cacheRead: 0.04, cacheWrite: 0 }, modalities: ["text", "image"] },
2648
+ "Qwen/Qwen3.8-Flash": { name: "Qwen 3.8 Flash", context: 1e6, efforts: ["low", "medium", "xhigh"], cost: { input: 0.16, output: 0.47, cacheRead: 0.016, cacheWrite: 0 }, modalities: ["text", "image"] },
2649
+ "Qwen/Qwen3.8-Max": { name: "Qwen 3.8 Max", context: 1e6, efforts: ["low", "medium", "xhigh"], cost: { input: 2, output: 6, cacheRead: 0.25, cacheWrite: 2.5 }, modalities: ["text", "image"] },
2650
+ "Qwen/Qwen3.8-Max-0902": { name: "Qwen 3.8 Max 0902", context: 1e6, efforts: ["low", "medium", "xhigh"], cost: { input: 2, output: 6, cacheRead: 0.25, cacheWrite: 0 }, modalities: ["text", "image"] },
2651
+ "Qwen/Qwen3.8-Omni-Flash": { name: "Qwen 3.8 Omni Flash", context: 1e6, efforts: ["low", "medium", "xhigh"], cost: { input: 0.15, output: 0.47, cacheRead: 0.016, cacheWrite: 0 }, modalities: ["text", "image"] },
2652
+ "sakana/fugu-ultra": { name: "Fugu Ultra", context: 1e6, efforts: ["high", "xhigh"], cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 }, modalities: ["text", "image"] },
2653
+ "stealth/space-bunny-alpha": { name: "Space Bunny Alpha", context: 1e6, efforts: ["low", "medium", "high"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, modalities: ["text", "image"] },
2654
+ "stepfun/Step-3.5-Flash": { name: "Step 3.5 Flash", context: 1e6, efforts: null, cost: { input: 0.1, output: 0.3, cacheRead: 0.02, cacheWrite: 0 }, modalities: ["text"] },
2655
+ "stepfun/Step-3.7-Flash": { name: "Step 3.7 Flash", context: 256000, efforts: null, cost: { input: 0.2, output: 1.15, cacheRead: 0.04, cacheWrite: 0 }, modalities: ["text", "image"] },
2656
+ "stepfun/Step-5-Preview": { name: "Step 5 Preview", context: 1e6, efforts: ["low", "medium", "high"], cost: { input: 1, output: 2.7, cacheRead: 0.05, cacheWrite: 0 }, modalities: ["text", "image"] },
2657
+ "tencent/hy3-paid": { name: "Tencent Hy3", context: 262000, efforts: null, cost: { input: 0.14, output: 0.58, cacheRead: 0.035, cacheWrite: 0 }, modalities: ["text"] },
2658
+ "tencent/hy4-preview": { name: "Tencent Hy4 Preview", context: 1050000, efforts: ["low", "medium", "high"], cost: { input: 0.834, output: 2.501, cacheRead: 0.042, cacheWrite: 0 }, modalities: ["text"] },
2659
+ "thinkingmachines/inkling": { name: "Inkling", context: 256000, efforts: null, cost: { input: 1, output: 4.05, cacheRead: 0.17, cacheWrite: 0 }, modalities: ["text", "image"] },
2660
+ "thinkingmachines/inkling-small": { name: "Inkling Small", context: 1e6, efforts: null, cost: { input: 0.5, output: 1.2, cacheRead: 0.1, cacheWrite: 0 }, modalities: ["text", "image"] },
2661
+ "xai/grok-4.5": { name: "Grok 4.5", context: 500000, efforts: ["low", "medium", "high"], cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 }, modalities: ["text", "image"] },
2662
+ "xai/grok-4.6": { name: "Grok 4.6", context: 500000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 }, modalities: ["text", "image"] },
2663
+ "xai/grok-4.7": { name: "Grok 4.7", context: 500000, efforts: ["low", "medium", "high", "xhigh"], cost: { input: 1.2, output: 3.6, cacheRead: 0.3, cacheWrite: 0 }, modalities: ["text", "image"] },
2664
+ "xiaomi/mimo-v2.5": { name: "MiMo V2.5", context: 1e6, efforts: null, cost: { input: 0.14, output: 0.28, cacheRead: 0.0028, cacheWrite: 0 }, modalities: ["text", "image"] },
2665
+ "xiaomi/mimo-v2.5-pro": { name: "MiMo V2.5 Pro", context: 1e6, efforts: null, cost: { input: 0.435, output: 0.87, cacheRead: 0.0036, cacheWrite: 0 }, modalities: ["text"] },
2666
+ "xiaomi/mimo-v2.6-flash": { name: "MiMo V2.6 Flash", context: 1050000, efforts: null, cost: { input: 0.14, output: 0.28, cacheRead: 0.0028, cacheWrite: 0 }, modalities: ["text", "image"] },
2667
+ "xiaomi/mimo-v2.6-pro": { name: "MiMo V2.6 Pro", context: 1050000, efforts: null, cost: { input: 0.435, output: 0.87, cacheRead: 0.0036, cacheWrite: 0 }, modalities: ["text", "image"] },
2668
+ "xiaomi/mimo-v2.6-pro-ultraspeed": { name: "MiMo V2.6 Pro UltraSpeed", context: 1050000, efforts: null, cost: { input: 4.35, output: 8.7, cacheRead: 0.036, cacheWrite: 0 }, modalities: ["text", "image"] },
2669
+ "z-ai/glm-5.3-flash": { name: "GLM-5.3 Flash", context: 1050000, efforts: ["low", "high", "max"], cost: { input: 0.15, output: 0.5, cacheRead: 0.03, cacheWrite: 0 }, modalities: ["text", "image"] },
2670
+ "z-ai/glm-5.3-flashx": { name: "GLM-5.3 FlashX", context: 1e6, efforts: ["low", "high", "max"], cost: { input: 0.37, output: 1.25, cacheRead: 0.075, cacheWrite: 0 }, modalities: ["text", "image"] },
2671
+ "zai-org/GLM-5": { name: "GLM-5", context: 200000, efforts: null, cost: { input: 1, output: 3.2, cacheRead: 0.2, cacheWrite: 0 }, modalities: ["text"] },
2672
+ "zai-org/GLM-5.1": { name: "GLM-5.1", context: 0, efforts: null, cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, modalities: ["text"] },
2673
+ "zai-org/GLM-5.2": { name: "GLM-5.2", context: 1e6, efforts: ["high", "max"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, modalities: ["text"] },
2674
+ "zai-org/GLM-5.2-Fast": { name: "GLM-5.2 Fast", context: 1e6, efforts: null, cost: { input: 3, output: 10.25, cacheRead: 0.5, cacheWrite: 0 }, modalities: ["text"] },
2675
+ "zai-org/GLM-5.3": { name: "GLM-5.3", context: 1e6, efforts: ["low", "high", "max"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, modalities: ["text"] }
2676
+ };
2677
+ var TEXT_ONLY = ["text"];
2678
+ function inputModalities(id) {
2679
+ return MODEL_CATALOG[id]?.modalities ?? TEXT_ONLY;
2680
+ }
2681
+ function supportsImage(id) {
2682
+ return inputModalities(id).includes("image");
2683
+ }
2684
+ function modelCost(id) {
2685
+ return MODEL_CATALOG[id]?.cost;
2686
+ }
2687
+ function reasoningVariants(id) {
2688
+ const efforts = MODEL_CATALOG[id]?.efforts;
2689
+ if (!efforts || efforts.length === 0)
2690
+ return;
2691
+ return Object.fromEntries(efforts.map((effort) => [effort, { reasoningEffort: effort }]));
2692
+ }
183
2693
  // ../core/gating.json
184
2694
  var gating_default = {
185
2695
  extractedAt: "2026-09-12T06:01:01.385Z",
@@ -544,8 +3054,655 @@ async function loadModels(key) {
544
3054
  return { claude, open };
545
3055
  }
546
3056
 
3057
+ // src/provider/stream.ts
3058
+ function sseDecoder(onEvent) {
3059
+ let buffer = "";
3060
+ return (text) => {
3061
+ buffer += text;
3062
+ for (;; ) {
3063
+ const nl = buffer.indexOf(`
3064
+ `);
3065
+ if (nl < 0)
3066
+ return;
3067
+ const line = buffer.slice(0, nl).replace(/\r$/, "");
3068
+ buffer = buffer.slice(nl + 1);
3069
+ const trimmed = line.trim();
3070
+ if (!trimmed || trimmed.startsWith(":") || trimmed.startsWith("event:"))
3071
+ continue;
3072
+ const payload = trimmed.startsWith("data:") ? trimmed.slice(5).trim() : trimmed;
3073
+ if (!payload || payload === "[DONE]")
3074
+ continue;
3075
+ try {
3076
+ const parsed = JSON.parse(payload);
3077
+ if (parsed && typeof parsed === "object")
3078
+ onEvent(parsed);
3079
+ } catch {}
3080
+ }
3081
+ };
3082
+ }
3083
+ var text = (v) => typeof v === "string" ? v : "";
3084
+ var num = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
3085
+ var rec = (v) => v && typeof v === "object" ? v : {};
3086
+ var TOOL_FINISH = new Set(["tool_use", "tool_calls", "tool-call", "function_call"]);
3087
+ var LENGTH_FINISH = new Set(["length", "max_tokens", "max_output_tokens", "model_context_window_exceeded"]);
3088
+ function finishReason(raw) {
3089
+ const value = (raw ?? "unknown").toLowerCase();
3090
+ if (TOOL_FINISH.has(value))
3091
+ return { unified: "tool-calls", raw };
3092
+ if (LENGTH_FINISH.has(value))
3093
+ return { unified: "length", raw };
3094
+ if (value === "error")
3095
+ return { unified: "error", raw };
3096
+ return { unified: "stop", raw };
3097
+ }
3098
+ function usageFrom(total, noCache, cacheRead, cacheWrite, output, reasoning) {
3099
+ return {
3100
+ inputTokens: { total, noCache, cacheRead, cacheWrite },
3101
+ outputTokens: { total: output, text: Math.max(0, output - reasoning), reasoning }
3102
+ };
3103
+ }
3104
+ function anthropicUsage(raw) {
3105
+ const total = num(raw.input_tokens);
3106
+ const cacheRead = num(raw.cache_read_input_tokens);
3107
+ const cacheWrite = num(raw.cache_creation_input_tokens);
3108
+ const output = num(raw.output_tokens);
3109
+ return usageFrom(total, Math.max(0, total - cacheRead - cacheWrite), cacheRead, cacheWrite, output, 0);
3110
+ }
3111
+ function openaiUsage(raw) {
3112
+ const total = num(raw.prompt_tokens);
3113
+ const cached = num(rec(raw.prompt_tokens_details).cached_tokens);
3114
+ const output = num(raw.completion_tokens);
3115
+ const reasoning = num(rec(raw.completion_tokens_details).reasoning_tokens);
3116
+ return usageFrom(total, Math.max(0, total - cached), cached, 0, output, reasoning);
3117
+ }
3118
+ function anthropicReducer() {
3119
+ const blocks = new Map;
3120
+ let finished = false;
3121
+ let warningsEmitted = false;
3122
+ let last = { unified: "stop", raw: "unknown" };
3123
+ const open = (index, kind) => {
3124
+ const id = `${kind === "text" ? "text" : "reasoning"}-${index}`;
3125
+ blocks.set(index, { type: kind, id });
3126
+ return [{ type: kind === "text" ? "text-start" : "reasoning-start", id }];
3127
+ };
3128
+ return {
3129
+ feed(event) {
3130
+ const type = text(event.type);
3131
+ if (type === "message_start") {
3132
+ if (warningsEmitted)
3133
+ return [];
3134
+ warningsEmitted = true;
3135
+ return [{ type: "stream-start", warnings: [] }];
3136
+ }
3137
+ if (type === "content_block_start") {
3138
+ const index = num(event.index);
3139
+ const block = rec(event.content_block);
3140
+ const blockType = text(block.type);
3141
+ if (blockType === "text")
3142
+ return open(index, "text");
3143
+ if (blockType === "thinking")
3144
+ return open(index, "thinking");
3145
+ if (blockType === "tool_use") {
3146
+ const id = text(block.id) || `tool-${index}`;
3147
+ blocks.set(index, { type: "tool_use", id });
3148
+ return [{ type: "tool-input-start", id, toolName: text(block.name) }];
3149
+ }
3150
+ blocks.set(index, { type: "other", id: `block-${index}` });
3151
+ return [];
3152
+ }
3153
+ if (type === "content_block_delta") {
3154
+ const index = num(event.index);
3155
+ const delta = rec(event.delta);
3156
+ const block = blocks.get(index);
3157
+ const textDelta = text(delta.text);
3158
+ if (textDelta) {
3159
+ const parts = block?.type === "text" ? [] : open(index, "text");
3160
+ const id = blocks.get(index)?.id ?? `text-${index}`;
3161
+ return [...parts, { type: "text-delta", id, delta: textDelta }];
3162
+ }
3163
+ const thinking = text(delta.thinking);
3164
+ if (thinking) {
3165
+ const parts = block?.type === "thinking" ? [] : open(index, "thinking");
3166
+ const id = blocks.get(index)?.id ?? `reasoning-${index}`;
3167
+ return [...parts, { type: "reasoning-delta", id, delta: thinking }];
3168
+ }
3169
+ const partial = text(delta.partial_json);
3170
+ if (partial && block?.type === "tool_use") {
3171
+ return [{ type: "tool-input-delta", id: block.id, delta: partial }];
3172
+ }
3173
+ return [];
3174
+ }
3175
+ if (type === "content_block_stop") {
3176
+ const index = num(event.index);
3177
+ const block = blocks.get(index);
3178
+ if (!block)
3179
+ return [];
3180
+ blocks.delete(index);
3181
+ if (block.type === "text")
3182
+ return [{ type: "text-end", id: block.id }];
3183
+ if (block.type === "thinking")
3184
+ return [{ type: "reasoning-end", id: block.id }];
3185
+ if (block.type === "tool_use")
3186
+ return [{ type: "tool-input-end", id: block.id }];
3187
+ return [];
3188
+ }
3189
+ if (type === "message_delta") {
3190
+ const delta = rec(event.delta);
3191
+ last = finishReason(text(delta.stop_reason) || undefined);
3192
+ if (text(delta.stop_reason) === "pause_turn")
3193
+ last = { unified: "stop", raw: "pause_turn" };
3194
+ if (finished)
3195
+ return [];
3196
+ finished = true;
3197
+ return [{ type: "finish", finishReason: last, usage: anthropicUsage(rec(event.usage)) }];
3198
+ }
3199
+ if (type === "message_stop" && !finished) {
3200
+ finished = true;
3201
+ return [{ type: "finish", finishReason: last, usage: usageFrom(0, 0, 0, 0, 0, 0) }];
3202
+ }
3203
+ return [];
3204
+ },
3205
+ close() {
3206
+ const parts = [];
3207
+ for (const block of blocks.values()) {
3208
+ if (block.type === "text")
3209
+ parts.push({ type: "text-end", id: block.id });
3210
+ if (block.type === "thinking")
3211
+ parts.push({ type: "reasoning-end", id: block.id });
3212
+ if (block.type === "tool_use")
3213
+ parts.push({ type: "tool-input-end", id: block.id });
3214
+ }
3215
+ blocks.clear();
3216
+ return parts;
3217
+ }
3218
+ };
3219
+ }
3220
+ function openaiReducer() {
3221
+ const tools = new Map;
3222
+ let textId;
3223
+ let reasoningId;
3224
+ let pending;
3225
+ let usage;
3226
+ let finished = false;
3227
+ const closeText = () => {
3228
+ if (!textId)
3229
+ return [];
3230
+ const id = textId;
3231
+ textId = undefined;
3232
+ return [{ type: "text-end", id }];
3233
+ };
3234
+ const closeReasoning = () => {
3235
+ if (!reasoningId)
3236
+ return [];
3237
+ const id = reasoningId;
3238
+ reasoningId = undefined;
3239
+ return [{ type: "reasoning-end", id }];
3240
+ };
3241
+ const completeIfParsed = (buffer) => {
3242
+ if (!buffer.opened || buffer.closed)
3243
+ return [];
3244
+ try {
3245
+ JSON.parse(buffer.input);
3246
+ } catch {
3247
+ return [];
3248
+ }
3249
+ buffer.closed = true;
3250
+ return [
3251
+ { type: "tool-input-end", id: buffer.id },
3252
+ { type: "tool-call", toolCallId: buffer.id, toolName: buffer.name, input: buffer.input }
3253
+ ];
3254
+ };
3255
+ const flushTools = () => {
3256
+ const parts = [];
3257
+ for (const [index, buffer] of tools) {
3258
+ if (buffer.opened && !buffer.closed) {
3259
+ parts.push({ type: "tool-input-end", id: buffer.id });
3260
+ parts.push({ type: "tool-call", toolCallId: buffer.id, toolName: buffer.name, input: buffer.input });
3261
+ buffer.closed = true;
3262
+ }
3263
+ tools.delete(index);
3264
+ }
3265
+ return parts;
3266
+ };
3267
+ return {
3268
+ feed(event) {
3269
+ if (text(event.type) === "error" || event.error !== undefined) {
3270
+ const message = text(rec(event.error).message) || text(event.message) || "provider stream error";
3271
+ return [{ type: "error", error: new Error(message) }];
3272
+ }
3273
+ const parts = [];
3274
+ const choices = Array.isArray(event.choices) ? event.choices : [];
3275
+ const choice = rec(choices[0]);
3276
+ const delta = rec(choice.delta);
3277
+ const reasoning = text(delta.reasoning) || text(delta.reasoning_content);
3278
+ if (reasoning) {
3279
+ if (!reasoningId) {
3280
+ parts.push(...closeText());
3281
+ reasoningId = "reasoning-0";
3282
+ parts.push({ type: "reasoning-start", id: reasoningId });
3283
+ }
3284
+ parts.push({ type: "reasoning-delta", id: reasoningId, delta: reasoning });
3285
+ }
3286
+ const content = text(delta.content);
3287
+ if (content) {
3288
+ if (reasoningId)
3289
+ parts.push(...closeReasoning());
3290
+ if (!textId) {
3291
+ textId = "text-0";
3292
+ parts.push({ type: "text-start", id: textId });
3293
+ }
3294
+ parts.push({ type: "text-delta", id: textId, delta: content });
3295
+ }
3296
+ const calls = Array.isArray(delta.tool_calls) ? delta.tool_calls : [];
3297
+ if (calls.length > 0) {
3298
+ parts.push(...closeReasoning(), ...closeText());
3299
+ for (const raw of calls) {
3300
+ const call = rec(raw);
3301
+ const fn = rec(call.function);
3302
+ const index = typeof call.index === "number" ? call.index : tools.size;
3303
+ let buffer = tools.get(index);
3304
+ if (!buffer) {
3305
+ buffer = { id: text(call.id) || `tool-${index}`, name: text(fn.name), input: "", opened: false, closed: false };
3306
+ tools.set(index, buffer);
3307
+ }
3308
+ if (text(call.id))
3309
+ buffer.id = text(call.id);
3310
+ if (text(fn.name))
3311
+ buffer.name = text(fn.name);
3312
+ const args = text(fn.arguments);
3313
+ if (!buffer.opened && buffer.name) {
3314
+ buffer.opened = true;
3315
+ parts.push({ type: "tool-input-start", id: buffer.id, toolName: buffer.name });
3316
+ if (buffer.input)
3317
+ parts.push({ type: "tool-input-delta", id: buffer.id, delta: buffer.input });
3318
+ } else if (args && !buffer.closed) {
3319
+ parts.push({ type: "tool-input-delta", id: buffer.id, delta: args });
3320
+ }
3321
+ if (!buffer.closed) {
3322
+ buffer.input += args;
3323
+ parts.push(...completeIfParsed(buffer));
3324
+ }
3325
+ }
3326
+ }
3327
+ const rawFinish = text(choice.finish_reason) || text(choice.finishReason) || text(event.finish_reason) || text(event.finishReason);
3328
+ if (rawFinish)
3329
+ pending = finishReason(rawFinish);
3330
+ if (event.usage !== undefined && event.usage !== null)
3331
+ usage = openaiUsage(rec(event.usage));
3332
+ if (pending && !finished && (usage !== undefined || choices.length === 0)) {
3333
+ finished = true;
3334
+ parts.push(...closeReasoning(), ...closeText(), ...flushTools());
3335
+ parts.push({ type: "finish", finishReason: pending, usage: usage ?? usageFrom(0, 0, 0, 0, 0, 0) });
3336
+ }
3337
+ return parts;
3338
+ },
3339
+ close() {
3340
+ const parts = [...closeReasoning(), ...closeText(), ...flushTools()];
3341
+ if (pending && !finished) {
3342
+ finished = true;
3343
+ parts.push({ type: "finish", finishReason: pending, usage: usage ?? usageFrom(0, 0, 0, 0, 0, 0) });
3344
+ }
3345
+ return parts;
3346
+ }
3347
+ };
3348
+ }
3349
+
3350
+ // src/provider/wire.ts
3351
+ var DEFAULT_MAX_TOKENS = 64000;
3352
+ function capTokens(value) {
3353
+ const n = typeof value === "number" && Number.isFinite(value) ? value : DEFAULT_MAX_TOKENS;
3354
+ return Math.min(n, DEFAULT_MAX_TOKENS);
3355
+ }
3356
+ function textOf(part) {
3357
+ const p = part;
3358
+ return typeof p.text === "string" ? p.text : "";
3359
+ }
3360
+ function resultText(part) {
3361
+ const output = part.output ?? part.result;
3362
+ if (typeof output === "string")
3363
+ return output;
3364
+ if (output && typeof output === "object") {
3365
+ const o = output;
3366
+ if (typeof o.value === "string")
3367
+ return o.value;
3368
+ if (o.value !== undefined)
3369
+ return JSON.stringify(o.value);
3370
+ if (typeof o.reason === "string")
3371
+ return o.reason;
3372
+ }
3373
+ return JSON.stringify(output ?? "");
3374
+ }
3375
+ function imageUrl(part) {
3376
+ const p = part;
3377
+ const mime = p.mediaType ?? p.mimeType ?? "application/octet-stream";
3378
+ const data = p.data;
3379
+ if (typeof data === "string")
3380
+ return data.startsWith("data:") ? data : `data:${mime};base64,${data}`;
3381
+ if (data instanceof Uint8Array)
3382
+ return `data:${mime};base64,${Buffer.from(data).toString("base64")}`;
3383
+ if (data instanceof URL)
3384
+ return data.href;
3385
+ return;
3386
+ }
3387
+ function pairedToolCallIds(prompt) {
3388
+ const calls = new Set;
3389
+ const results = new Set;
3390
+ for (const message of prompt) {
3391
+ for (const part of message.content) {
3392
+ if (part.type === "tool-call" && typeof part.toolCallId === "string")
3393
+ calls.add(part.toolCallId);
3394
+ if (part.type === "tool-result" && typeof part.toolCallId === "string")
3395
+ results.add(part.toolCallId);
3396
+ }
3397
+ }
3398
+ return new Set([...calls].filter((id) => results.has(id)));
3399
+ }
3400
+ function systemText(prompt) {
3401
+ return prompt.filter((m) => m.role === "system").map((m) => m.content).join(`
3402
+ `);
3403
+ }
3404
+ function anthropicUserContent(content, images) {
3405
+ if (typeof content === "string")
3406
+ return content;
3407
+ const parts = content ?? [];
3408
+ const blocks = [];
3409
+ for (const part of parts) {
3410
+ if (part.type === "text")
3411
+ blocks.push({ type: "text", text: textOf(part) });
3412
+ else if (part.type === "file" && images) {
3413
+ const url = imageUrl(part);
3414
+ if (url?.startsWith("data:")) {
3415
+ const [head, b64] = url.slice(5).split(";base64,");
3416
+ blocks.push({ type: "image", source: { type: "base64", media_type: head, data: b64 } });
3417
+ }
3418
+ }
3419
+ }
3420
+ if (blocks.length === 1 && blocks[0].type === "text") {
3421
+ return blocks[0].text;
3422
+ }
3423
+ return blocks;
3424
+ }
3425
+ function openaiUserContent(content, images) {
3426
+ if (typeof content === "string")
3427
+ return content;
3428
+ const parts = content ?? [];
3429
+ const blocks = [];
3430
+ for (const part of parts) {
3431
+ if (part.type === "text")
3432
+ blocks.push({ type: "text", text: textOf(part) });
3433
+ else if (part.type === "file" && images) {
3434
+ const url = imageUrl(part);
3435
+ if (url)
3436
+ blocks.push({ type: "image_url", image_url: { url } });
3437
+ }
3438
+ }
3439
+ if (blocks.every((b) => b.type === "text")) {
3440
+ return blocks.map((b) => b.text).join(`
3441
+ `);
3442
+ }
3443
+ return blocks;
3444
+ }
3445
+ function anthropicBody(model, prompt, options) {
3446
+ const paired = pairedToolCallIds(prompt);
3447
+ const messages = [];
3448
+ for (const message of prompt) {
3449
+ if (message.role === "system")
3450
+ continue;
3451
+ if (message.role === "user") {
3452
+ messages.push({ role: "user", content: anthropicUserContent(message.content, options.images) });
3453
+ continue;
3454
+ }
3455
+ if (message.role === "assistant") {
3456
+ const content = [];
3457
+ for (const part of message.content) {
3458
+ if (part.type === "text") {
3459
+ const text = textOf(part);
3460
+ if (text)
3461
+ content.push({ type: "text", text });
3462
+ } else if (part.type === "tool-call" && paired.has(String(part.toolCallId))) {
3463
+ content.push({ type: "tool_use", id: part.toolCallId, name: part.toolName, input: part.input ?? {} });
3464
+ }
3465
+ }
3466
+ if (content.length > 0)
3467
+ messages.push({ role: "assistant", content });
3468
+ continue;
3469
+ }
3470
+ for (const part of message.content) {
3471
+ if (part.type !== "tool-result" || !paired.has(String(part.toolCallId)))
3472
+ continue;
3473
+ messages.push({
3474
+ role: "user",
3475
+ content: [
3476
+ {
3477
+ type: "tool_result",
3478
+ tool_use_id: part.toolCallId,
3479
+ content: resultText(part)
3480
+ }
3481
+ ]
3482
+ });
3483
+ }
3484
+ }
3485
+ const system = systemText(prompt);
3486
+ const body = { model, stream: true, messages, max_tokens: capTokens(options.maxOutputTokens) };
3487
+ if (system)
3488
+ body.system = [{ type: "text", text: system, cache_control: { type: "ephemeral" } }];
3489
+ if (options.tools?.length) {
3490
+ body.tools = options.tools.map((t) => ({ name: t.name, description: t.description, input_schema: t.inputSchema ?? {} }));
3491
+ }
3492
+ if (options.temperature !== undefined)
3493
+ body.temperature = options.temperature;
3494
+ if (options.reasoningEffort)
3495
+ body.reasoning_effort = options.reasoningEffort;
3496
+ return body;
3497
+ }
3498
+ function openaiBody(model, prompt, options) {
3499
+ const paired = pairedToolCallIds(prompt);
3500
+ const messages = [];
3501
+ const system = systemText(prompt);
3502
+ if (system)
3503
+ messages.push({ role: "system", content: system });
3504
+ for (const message of prompt) {
3505
+ if (message.role === "system")
3506
+ continue;
3507
+ if (message.role === "user") {
3508
+ messages.push({ role: "user", content: openaiUserContent(message.content, options.images) });
3509
+ continue;
3510
+ }
3511
+ if (message.role === "assistant") {
3512
+ const calls = message.content.filter((p) => p.type === "tool-call" && paired.has(String(p.toolCallId)));
3513
+ const texts = message.content.filter((p) => p.type === "text").map(textOf).filter(Boolean);
3514
+ const reasoning = message.content.filter((p) => p.type === "reasoning").map(textOf).join("");
3515
+ if (calls.length > 0) {
3516
+ messages.push({
3517
+ role: "assistant",
3518
+ ...reasoning ? { reasoning_content: reasoning } : {},
3519
+ content: texts.length ? texts.join(`
3520
+ `) : null,
3521
+ tool_calls: calls.map((c) => ({
3522
+ id: c.toolCallId,
3523
+ type: "function",
3524
+ function: { name: c.toolName, arguments: JSON.stringify(c.input ?? {}) }
3525
+ }))
3526
+ });
3527
+ } else if (texts.length > 0) {
3528
+ messages.push({ role: "assistant", ...reasoning ? { reasoning_content: reasoning } : {}, content: texts.join(`
3529
+ `) });
3530
+ }
3531
+ continue;
3532
+ }
3533
+ for (const part of message.content) {
3534
+ if (part.type !== "tool-result" || !paired.has(String(part.toolCallId)))
3535
+ continue;
3536
+ messages.push({
3537
+ role: "tool",
3538
+ tool_call_id: part.toolCallId,
3539
+ content: resultText(part)
3540
+ });
3541
+ }
3542
+ }
3543
+ const body = { model, stream: true, messages, max_tokens: capTokens(options.maxOutputTokens) };
3544
+ if (options.tools?.length) {
3545
+ body.tools = options.tools.map((t) => ({
3546
+ type: "function",
3547
+ function: { name: t.name, description: t.description, parameters: t.inputSchema ?? {} }
3548
+ }));
3549
+ }
3550
+ if (options.temperature !== undefined)
3551
+ body.temperature = options.temperature;
3552
+ if (options.reasoningEffort)
3553
+ body.reasoning_effort = options.reasoningEffort;
3554
+ body.stream_options = { include_usage: true };
3555
+ return body;
3556
+ }
3557
+ function requestBody(lane, model, prompt, options) {
3558
+ return lane === "anthropic" ? anthropicBody(model, prompt, options) : openaiBody(model, prompt, options);
3559
+ }
3560
+
3561
+ // src/provider/index.ts
3562
+ var DEFAULT_BASE_URL = "https://api.commandcode.ai";
3563
+ function laneOf(modelId) {
3564
+ const bare = modelId.includes("/") ? modelId.slice(modelId.lastIndexOf("/") + 1) : modelId;
3565
+ return bare.toLowerCase().startsWith("claude") ? "anthropic" : "openai";
3566
+ }
3567
+ function endpoint(lane) {
3568
+ return lane === "anthropic" ? "/provider/v1/messages" : "/provider/v1/chat/completions";
3569
+ }
3570
+ function effortFrom(options) {
3571
+ const providerOptions = options.providerOptions ?? {};
3572
+ const top = providerOptions.reasoning ?? providerOptions.reasoningEffort;
3573
+ if (typeof top === "string")
3574
+ return top;
3575
+ const namespaced = providerOptions.commandcode;
3576
+ if (namespaced && typeof namespaced === "object") {
3577
+ const value = namespaced.reasoning ?? namespaced.reasoningEffort;
3578
+ if (typeof value === "string")
3579
+ return value;
3580
+ }
3581
+ return;
3582
+ }
3583
+ function toolsOf(options) {
3584
+ const tools = options.tools ?? [];
3585
+ if (tools.length === 0)
3586
+ return;
3587
+ return tools.map((tool) => ({
3588
+ name: tool.name,
3589
+ description: "description" in tool ? tool.description : undefined,
3590
+ inputSchema: tool.inputSchema ?? {}
3591
+ }));
3592
+ }
3593
+ function createCommandCode(options = {}, images = () => false) {
3594
+ const baseURL = (options.baseURL ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
3595
+ const doFetch = options.fetch ?? fetch;
3596
+ function model(modelId) {
3597
+ const lane = laneOf(modelId);
3598
+ return {
3599
+ specificationVersion: "v3",
3600
+ provider: "command-code",
3601
+ modelId,
3602
+ supportedUrls: {},
3603
+ async doStream(callOptions) {
3604
+ const body = requestBody(lane, modelId, callOptions.prompt, {
3605
+ maxOutputTokens: callOptions.maxOutputTokens,
3606
+ temperature: callOptions.temperature,
3607
+ tools: toolsOf(callOptions),
3608
+ reasoningEffort: effortFrom(callOptions) ?? options.reasoningEffort,
3609
+ images: images(modelId)
3610
+ });
3611
+ const response = await doFetch(`${baseURL}${endpoint(lane)}`, {
3612
+ method: "POST",
3613
+ headers: {
3614
+ "Content-Type": "application/json",
3615
+ Authorization: `Bearer ${options.apiKey ?? ""}`,
3616
+ ...options.headers ?? {},
3617
+ ...callOptions.headers ?? {}
3618
+ },
3619
+ body: JSON.stringify(body),
3620
+ signal: callOptions.abortSignal
3621
+ });
3622
+ if (!response.ok || !response.body) {
3623
+ const detail = await response.text().catch(() => "");
3624
+ throw new Error(`command-code ${lane} ${response.status}: ${detail.slice(0, 300)}`);
3625
+ }
3626
+ const reducer = lane === "anthropic" ? anthropicReducer() : openaiReducer();
3627
+ const stream = new ReadableStream({
3628
+ async start(controller) {
3629
+ const reader = response.body.getReader();
3630
+ const decoder = new TextDecoder;
3631
+ const emit = (parts) => {
3632
+ for (const part of parts)
3633
+ controller.enqueue(part);
3634
+ };
3635
+ const decode = sseDecoder((event) => emit(reducer.feed(event)));
3636
+ try {
3637
+ for (;; ) {
3638
+ const { done, value } = await reader.read();
3639
+ if (done)
3640
+ break;
3641
+ decode(decoder.decode(value, { stream: true }));
3642
+ }
3643
+ emit(reducer.close());
3644
+ controller.close();
3645
+ } catch (error) {
3646
+ controller.enqueue({ type: "error", error });
3647
+ controller.close();
3648
+ }
3649
+ }
3650
+ });
3651
+ return { stream, response: { headers: Object.fromEntries(response.headers) } };
3652
+ },
3653
+ async doGenerate(callOptions) {
3654
+ const { stream } = await this.doStream(callOptions);
3655
+ const reader = stream.getReader();
3656
+ const content = [];
3657
+ let finish = { unified: "stop", raw: "unknown" };
3658
+ let usage = {
3659
+ inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
3660
+ outputTokens: { total: 0, text: 0, reasoning: 0 }
3661
+ };
3662
+ const textOf = {};
3663
+ const toolsById = new Map;
3664
+ for (;; ) {
3665
+ const { done, value } = await reader.read();
3666
+ if (done)
3667
+ break;
3668
+ const part = value;
3669
+ if (part.type === "text-delta")
3670
+ textOf[String(part.id)] = (textOf[String(part.id)] ?? "") + String(part.delta);
3671
+ else if (part.type === "reasoning-delta") {
3672
+ content.push({ type: "reasoning", text: String(part.delta) });
3673
+ } else if (part.type === "tool-input-start") {
3674
+ toolsById.set(String(part.id), { name: String(part.toolName), input: "" });
3675
+ } else if (part.type === "tool-input-delta") {
3676
+ const buffer = toolsById.get(String(part.id));
3677
+ if (buffer)
3678
+ buffer.input += String(part.delta);
3679
+ } else if (part.type === "tool-call") {
3680
+ content.push({
3681
+ type: "tool-call",
3682
+ toolCallId: part.toolCallId,
3683
+ toolName: part.toolName,
3684
+ input: part.input
3685
+ });
3686
+ } else if (part.type === "finish") {
3687
+ finish = part;
3688
+ usage = part.usage;
3689
+ }
3690
+ }
3691
+ for (const [id, value] of Object.entries(textOf))
3692
+ content.push({ type: "text", text: value, id });
3693
+ return {
3694
+ content,
3695
+ finishReason: finish.finishReason,
3696
+ usage,
3697
+ warnings: []
3698
+ };
3699
+ }
3700
+ };
3701
+ }
3702
+ return { languageModel: model };
3703
+ }
3704
+
547
3705
  // src/v2.ts
548
- import { Plugin } from "@opencode/plugin";
549
3706
  var PLUGIN_ID = "command-code";
550
3707
  var PROVIDER_BASE = "https://api.commandcode.ai/provider/v1";
551
3708
  var INTEGRATION_ID = "command-code";
@@ -560,16 +3717,22 @@ var LANES = [
560
3717
  }
561
3718
  ];
562
3719
  var TOOL_DESCRIPTION = "Fetch live Command Code plan/usage: plan name, monthly credits, 5-hour & weekly windows, billing-period summary. Pass arg='plans' for the plan comparison table only, or extra cmduse flags (e.g. '--tz +05:30 daily').";
3720
+ function costEntry(id) {
3721
+ const cost = modelCost(id);
3722
+ return cost ? [{ input: cost.input, output: cost.output, cache: { read: cost.cacheRead, write: cost.cacheWrite } }] : [];
3723
+ }
563
3724
  function toV2Model(m, lane) {
3725
+ const efforts = reasoningVariants(m.id);
3726
+ const variants = efforts ? Object.entries(efforts).map(([id, settings]) => ({ id, settings })) : [];
564
3727
  const info = {
565
3728
  id: m.id,
566
3729
  modelID: m.id,
567
3730
  providerID: lane.id,
568
3731
  name: m.name,
569
- capabilities: { tools: true, input: ["text"], output: ["text"] },
570
- variants: [],
3732
+ capabilities: { tools: true, input: [...inputModalities(m.id)], output: ["text"] },
3733
+ variants,
571
3734
  time: { released: 0 },
572
- cost: [],
3735
+ cost: costEntry(m.id),
573
3736
  status: "active",
574
3737
  enabled: true,
575
3738
  limit: { context: m.contextLength || 128000, output: 32000 },
@@ -605,7 +3768,7 @@ async function credentialKey(ctx) {
605
3768
  return;
606
3769
  }
607
3770
  }
608
- var commandCodeV2 = Plugin.define({
3771
+ var commandCodeV2 = {
609
3772
  id: PLUGIN_ID,
610
3773
  async setup(ctx) {
611
3774
  let localKey;
@@ -634,6 +3797,17 @@ var commandCodeV2 = Plugin.define({
634
3797
  method: { type: "key", label: "Command Code API key" }
635
3798
  });
636
3799
  });
3800
+ const images = (modelId) => inputModalities(modelId).includes("image");
3801
+ for (const lane of LANES) {
3802
+ await ctx.aisdk.hook("sdk", (event) => {
3803
+ const options = event.options ?? {};
3804
+ event.sdk = createCommandCode({
3805
+ apiKey: typeof options.apiKey === "string" ? options.apiKey : undefined,
3806
+ baseURL: typeof options.baseURL === "string" ? options.baseURL : PROVIDER_BASE,
3807
+ headers: options.headers
3808
+ }, images);
3809
+ }, { providerID: lane.id });
3810
+ }
637
3811
  const seed = staticSeedModels();
638
3812
  await ctx.provider.transform((editor) => {
639
3813
  for (const lane of LANES) {
@@ -705,9 +3879,62 @@ var commandCodeV2 = Plugin.define({
705
3879
  clearInterval(timer);
706
3880
  };
707
3881
  }
708
- });
3882
+ };
3883
+ // package.json
3884
+ var package_default = {
3885
+ name: "@jeffreyjyz/opencode-command-code",
3886
+ version: "0.3.0",
3887
+ description: "Command Code provider + usage dashboard for opencode: two providers (Anthropic wire for Claude, OpenAI wire for everything else) against api.commandcode.ai, live model list, plan gating, /cmd-usage. Requires the cmduse CLI for usage rendering.",
3888
+ type: "module",
3889
+ main: "dist/index.js",
3890
+ types: "dist/index.d.ts",
3891
+ exports: {
3892
+ ".": "./dist/index.js",
3893
+ "./tui": "./dist/tui.js"
3894
+ },
3895
+ scripts: {
3896
+ build: "rm -rf dist && bun build src/index.ts --outdir dist --target bun --external @opencode-ai/plugin --external @opencode/plugin --external @opencode/plugin/tui && bun scripts/build-tui.ts && tsc -p tsconfig.build.json",
3897
+ test: "bun test",
3898
+ typecheck: "tsc --noEmit",
3899
+ "build:tui": "bun scripts/build-tui.ts",
3900
+ "extract:catalog": "bun scripts/extract-catalog.ts"
3901
+ },
3902
+ dependencies: {
3903
+ "@opentui/core": "^0.5.4",
3904
+ "@opentui/solid": "^0.5.4",
3905
+ "solid-js": "1.9.12",
3906
+ zod: "4.1.8"
3907
+ },
3908
+ devDependencies: {
3909
+ "@types/bun": "latest",
3910
+ typescript: "^5",
3911
+ "@opencode-ai/plugin": "*",
3912
+ "@opencode/plugin": "^2.0.11",
3913
+ "@ai-sdk/provider": "3.0.8"
3914
+ },
3915
+ files: [
3916
+ "dist",
3917
+ "tui.js",
3918
+ "LICENSE"
3919
+ ],
3920
+ keywords: [
3921
+ "opencode",
3922
+ "command-code",
3923
+ "plugin",
3924
+ "provider",
3925
+ "ai-sdk"
3926
+ ],
3927
+ license: "MIT",
3928
+ publishConfig: {
3929
+ access: "public"
3930
+ }
3931
+ };
709
3932
 
710
3933
  // src/index.ts
3934
+ var PROVIDER_NPM = `${package_default.name}@${package_default.version}`;
3935
+ function tool(input) {
3936
+ return input;
3937
+ }
711
3938
  var MODEL_CAPABILITIES = {
712
3939
  temperature: true,
713
3940
  reasoning: true,
@@ -716,6 +3943,14 @@ var MODEL_CAPABILITIES = {
716
3943
  input: { text: true, audio: false, image: false, video: false, pdf: false },
717
3944
  output: { text: true, audio: false, image: false, video: false, pdf: false }
718
3945
  };
3946
+ function costFor(id) {
3947
+ const cost = modelCost(id);
3948
+ return {
3949
+ input: cost?.input ?? 0,
3950
+ output: cost?.output ?? 0,
3951
+ cache: { read: cost?.cacheRead ?? 0, write: cost?.cacheWrite ?? 0 }
3952
+ };
3953
+ }
719
3954
  function toModelDefs(models, providerID, npm, interleaved = false) {
720
3955
  return Object.fromEntries(models.map((m) => [
721
3956
  m.id,
@@ -724,8 +3959,12 @@ function toModelDefs(models, providerID, npm, interleaved = false) {
724
3959
  providerID,
725
3960
  api: { id: m.id, url: PROVIDER_BASE, npm },
726
3961
  name: m.name,
727
- capabilities: { ...MODEL_CAPABILITIES, interleaved },
728
- cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
3962
+ capabilities: {
3963
+ ...MODEL_CAPABILITIES,
3964
+ interleaved,
3965
+ ...supportsImage(m.id) ? { attachment: true, input: { ...MODEL_CAPABILITIES.input, image: true } } : {}
3966
+ },
3967
+ cost: costFor(m.id),
729
3968
  limit: { context: m.contextLength || 128000, output: 32000 },
730
3969
  status: "active",
731
3970
  options: {},
@@ -788,18 +4027,18 @@ var CommandCodePlugin = async (_input) => {
788
4027
  console.warn("[command-code] model list unavailable:", e);
789
4028
  }
790
4029
  }
791
- const claudeDefs = split ? toModelDefs(split.claude, "command-code-anthropic", "@ai-sdk/anthropic") : {};
792
- const openDefs = split ? toModelDefs(split.open, "command-code-openai", "@ai-sdk/openai-compatible", { field: "reasoning_content" }) : {};
4030
+ const claudeDefs = split ? toModelDefs(split.claude, "command-code-anthropic", PROVIDER_NPM) : {};
4031
+ const openDefs = split ? toModelDefs(split.open, "command-code-openai", PROVIDER_NPM, { field: "reasoning_content" }) : {};
793
4032
  const userAnthropic = existing("command-code-anthropic");
794
4033
  cfg.provider["command-code-anthropic"] = {
795
- npm: userAnthropic.npm ?? "@ai-sdk/anthropic",
4034
+ npm: userAnthropic.npm ?? PROVIDER_NPM,
796
4035
  name: userAnthropic.name ?? "Command Code (Anthropic)",
797
4036
  options: { baseURL: PROVIDER_BASE, ...userAnthropic.options },
798
4037
  models: { ...claudeDefs, ...userAnthropic.models }
799
4038
  };
800
4039
  const userOpenai = existing("command-code-openai");
801
4040
  cfg.provider["command-code-openai"] = {
802
- npm: userOpenai.npm ?? "@ai-sdk/openai-compatible",
4041
+ npm: userOpenai.npm ?? PROVIDER_NPM,
803
4042
  name: userOpenai.name ?? "Command Code (OpenAI)",
804
4043
  options: {
805
4044
  baseURL: PROVIDER_BASE,
@@ -822,14 +4061,14 @@ var CommandCodePlugin = async (_input) => {
822
4061
  return a?.type === "api" && a.key ? { key: a.key } : undefined;
823
4062
  });
824
4063
  const split = await loadModels(key);
825
- return toModelDefs(split.claude, "command-code-anthropic", "@ai-sdk/anthropic");
4064
+ return toModelDefs(split.claude, "command-code-anthropic", PROVIDER_NPM);
826
4065
  }
827
4066
  },
828
4067
  tool: {
829
4068
  cmd_usage: tool({
830
- description: "Fetch live Command Code plan/usage: plan name, monthly credits, 5-hour & weekly windows, billing-period summary. Pass arg=plans for the plan comparison table only.",
4069
+ description: TOOL_DESCRIPTION,
831
4070
  args: {
832
- arg: tool.schema.string().optional().describe("Optional: 'plans' for the plan table only, or extra cmduse flags")
4071
+ arg: string2().optional().describe("Optional: 'plans' for the plan table only, or extra cmduse flags")
833
4072
  },
834
4073
  async execute(args) {
835
4074
  const key = await resolveKey();
@@ -845,5 +4084,6 @@ var src_default = {
845
4084
  };
846
4085
  export {
847
4086
  CommandCodePlugin,
4087
+ createCommandCode,
848
4088
  src_default as default
849
4089
  };