@inkeep/ai-sdk-provider 0.0.0-dev-20251222193816 → 0.0.0-dev-20251222214618

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/convert-to-inkeep-messages.cjs +82 -0
  2. package/dist/convert-to-inkeep-messages.d.cts +7 -0
  3. package/dist/convert-to-inkeep-messages.d.ts +7 -0
  4. package/dist/convert-to-inkeep-messages.js +81 -0
  5. package/dist/get-response-metadata.cjs +12 -0
  6. package/dist/get-response-metadata.d.cts +10 -0
  7. package/dist/get-response-metadata.d.ts +10 -0
  8. package/dist/get-response-metadata.js +11 -0
  9. package/dist/index.cjs +5 -3511
  10. package/dist/index.d.cts +6 -197
  11. package/dist/index.d.ts +6 -198
  12. package/dist/index.js +3 -3510
  13. package/dist/inkeep-chat-language-model.cjs +270 -0
  14. package/dist/inkeep-chat-language-model.d.cts +81 -0
  15. package/dist/inkeep-chat-language-model.d.ts +81 -0
  16. package/dist/inkeep-chat-language-model.js +269 -0
  17. package/dist/inkeep-chat-options.cjs +0 -0
  18. package/dist/inkeep-chat-options.d.cts +8 -0
  19. package/dist/inkeep-chat-options.d.ts +8 -0
  20. package/dist/inkeep-chat-options.js +1 -0
  21. package/dist/inkeep-chat-prompt.cjs +0 -0
  22. package/dist/inkeep-chat-prompt.d.cts +84 -0
  23. package/dist/inkeep-chat-prompt.d.ts +84 -0
  24. package/dist/inkeep-chat-prompt.js +1 -0
  25. package/dist/inkeep-error.cjs +20 -0
  26. package/dist/inkeep-error.d.cts +18 -0
  27. package/dist/inkeep-error.d.ts +18 -0
  28. package/dist/inkeep-error.js +20 -0
  29. package/dist/inkeep-provider.cjs +35 -0
  30. package/dist/inkeep-provider.d.cts +18 -0
  31. package/dist/inkeep-provider.d.ts +18 -0
  32. package/dist/inkeep-provider.js +34 -0
  33. package/dist/map-inkeep-finish-reason.cjs +15 -0
  34. package/dist/map-inkeep-finish-reason.d.cts +7 -0
  35. package/dist/map-inkeep-finish-reason.d.ts +7 -0
  36. package/dist/map-inkeep-finish-reason.js +14 -0
  37. package/package.json +4 -3
  38. package/dist/index.d.cts.map +0 -1
  39. package/dist/index.d.ts.map +0 -1
  40. package/dist/index.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,3511 +1,4 @@
1
- import { createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, loadSetting, postJsonToApi, withoutTrailingSlash } from "@ai-sdk/provider-utils";
2
- import { StreamEventSchema } from "@inkeep/agents-core";
1
+ import { InkeepChatLanguageModel } from "./inkeep-chat-language-model.js";
2
+ import { createInkeep, inkeep } from "./inkeep-provider.js";
3
3
 
4
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/core.js
5
- /** A special constant with type `never` */
6
- const NEVER = Object.freeze({ status: "aborted" });
7
- function $constructor(name, initializer$2, params) {
8
- function init(inst, def) {
9
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
10
- value: {
11
- def,
12
- constr: _,
13
- traits: /* @__PURE__ */ new Set()
14
- },
15
- enumerable: false
16
- });
17
- if (inst._zod.traits.has(name)) return;
18
- inst._zod.traits.add(name);
19
- initializer$2(inst, def);
20
- const proto = _.prototype;
21
- const keys = Object.keys(proto);
22
- for (let i = 0; i < keys.length; i++) {
23
- const k = keys[i];
24
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
25
- }
26
- }
27
- const Parent = params?.Parent ?? Object;
28
- class Definition extends Parent {}
29
- Object.defineProperty(Definition, "name", { value: name });
30
- function _(def) {
31
- var _a$1;
32
- const inst = params?.Parent ? new Definition() : this;
33
- init(inst, def);
34
- (_a$1 = inst._zod).deferred ?? (_a$1.deferred = []);
35
- for (const fn of inst._zod.deferred) fn();
36
- return inst;
37
- }
38
- Object.defineProperty(_, "init", { value: init });
39
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
40
- if (params?.Parent && inst instanceof params.Parent) return true;
41
- return inst?._zod?.traits?.has(name);
42
- } });
43
- Object.defineProperty(_, "name", { value: name });
44
- return _;
45
- }
46
- var $ZodAsyncError = class extends Error {
47
- constructor() {
48
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
49
- }
50
- };
51
- var $ZodEncodeError = class extends Error {
52
- constructor(name) {
53
- super(`Encountered unidirectional transform during encode: ${name}`);
54
- this.name = "ZodEncodeError";
55
- }
56
- };
57
- const globalConfig = {};
58
- function config(newConfig) {
59
- if (newConfig) Object.assign(globalConfig, newConfig);
60
- return globalConfig;
61
- }
62
-
63
- //#endregion
64
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/util.js
65
- function getEnumValues(entries) {
66
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
67
- return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
68
- }
69
- function jsonStringifyReplacer(_, value) {
70
- if (typeof value === "bigint") return value.toString();
71
- return value;
72
- }
73
- function cached(getter) {
74
- return { get value() {
75
- {
76
- const value = getter();
77
- Object.defineProperty(this, "value", { value });
78
- return value;
79
- }
80
- throw new Error("cached value already set");
81
- } };
82
- }
83
- function nullish(input) {
84
- return input === null || input === void 0;
85
- }
86
- function cleanRegex(source) {
87
- const start = source.startsWith("^") ? 1 : 0;
88
- const end = source.endsWith("$") ? source.length - 1 : source.length;
89
- return source.slice(start, end);
90
- }
91
- function floatSafeRemainder(val, step) {
92
- const valDecCount = (val.toString().split(".")[1] || "").length;
93
- const stepString = step.toString();
94
- let stepDecCount = (stepString.split(".")[1] || "").length;
95
- if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
96
- const match = stepString.match(/\d?e-(\d?)/);
97
- if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
98
- }
99
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
100
- return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
101
- }
102
- const EVALUATING = Symbol("evaluating");
103
- function defineLazy(object$1, key, getter) {
104
- let value = void 0;
105
- Object.defineProperty(object$1, key, {
106
- get() {
107
- if (value === EVALUATING) return;
108
- if (value === void 0) {
109
- value = EVALUATING;
110
- value = getter();
111
- }
112
- return value;
113
- },
114
- set(v) {
115
- Object.defineProperty(object$1, key, { value: v });
116
- },
117
- configurable: true
118
- });
119
- }
120
- function assignProp(target, prop, value) {
121
- Object.defineProperty(target, prop, {
122
- value,
123
- writable: true,
124
- enumerable: true,
125
- configurable: true
126
- });
127
- }
128
- function mergeDefs(...defs) {
129
- const mergedDescriptors = {};
130
- for (const def of defs) {
131
- const descriptors = Object.getOwnPropertyDescriptors(def);
132
- Object.assign(mergedDescriptors, descriptors);
133
- }
134
- return Object.defineProperties({}, mergedDescriptors);
135
- }
136
- function esc(str) {
137
- return JSON.stringify(str);
138
- }
139
- function slugify(input) {
140
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
141
- }
142
- const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
143
- function isObject(data) {
144
- return typeof data === "object" && data !== null && !Array.isArray(data);
145
- }
146
- const allowsEval = cached(() => {
147
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
148
- try {
149
- new Function("");
150
- return true;
151
- } catch (_) {
152
- return false;
153
- }
154
- });
155
- function isPlainObject(o) {
156
- if (isObject(o) === false) return false;
157
- const ctor = o.constructor;
158
- if (ctor === void 0) return true;
159
- if (typeof ctor !== "function") return true;
160
- const prot = ctor.prototype;
161
- if (isObject(prot) === false) return false;
162
- if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
163
- return true;
164
- }
165
- function shallowClone(o) {
166
- if (isPlainObject(o)) return { ...o };
167
- if (Array.isArray(o)) return [...o];
168
- return o;
169
- }
170
- const propertyKeyTypes = new Set([
171
- "string",
172
- "number",
173
- "symbol"
174
- ]);
175
- function escapeRegex(str) {
176
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
177
- }
178
- function clone(inst, def, params) {
179
- const cl = new inst._zod.constr(def ?? inst._zod.def);
180
- if (!def || params?.parent) cl._zod.parent = inst;
181
- return cl;
182
- }
183
- function normalizeParams(_params) {
184
- const params = _params;
185
- if (!params) return {};
186
- if (typeof params === "string") return { error: () => params };
187
- if (params?.message !== void 0) {
188
- if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
189
- params.error = params.message;
190
- }
191
- delete params.message;
192
- if (typeof params.error === "string") return {
193
- ...params,
194
- error: () => params.error
195
- };
196
- return params;
197
- }
198
- function optionalKeys(shape) {
199
- return Object.keys(shape).filter((k) => {
200
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
201
- });
202
- }
203
- const NUMBER_FORMAT_RANGES = {
204
- safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
205
- int32: [-2147483648, 2147483647],
206
- uint32: [0, 4294967295],
207
- float32: [-34028234663852886e22, 34028234663852886e22],
208
- float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
209
- };
210
- function pick(schema, mask) {
211
- const currDef = schema._zod.def;
212
- return clone(schema, mergeDefs(schema._zod.def, {
213
- get shape() {
214
- const newShape = {};
215
- for (const key in mask) {
216
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
217
- if (!mask[key]) continue;
218
- newShape[key] = currDef.shape[key];
219
- }
220
- assignProp(this, "shape", newShape);
221
- return newShape;
222
- },
223
- checks: []
224
- }));
225
- }
226
- function omit(schema, mask) {
227
- const currDef = schema._zod.def;
228
- return clone(schema, mergeDefs(schema._zod.def, {
229
- get shape() {
230
- const newShape = { ...schema._zod.def.shape };
231
- for (const key in mask) {
232
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
233
- if (!mask[key]) continue;
234
- delete newShape[key];
235
- }
236
- assignProp(this, "shape", newShape);
237
- return newShape;
238
- },
239
- checks: []
240
- }));
241
- }
242
- function extend(schema, shape) {
243
- if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
244
- const checks = schema._zod.def.checks;
245
- if (checks && checks.length > 0) throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
246
- return clone(schema, mergeDefs(schema._zod.def, {
247
- get shape() {
248
- const _shape = {
249
- ...schema._zod.def.shape,
250
- ...shape
251
- };
252
- assignProp(this, "shape", _shape);
253
- return _shape;
254
- },
255
- checks: []
256
- }));
257
- }
258
- function safeExtend(schema, shape) {
259
- if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
260
- return clone(schema, {
261
- ...schema._zod.def,
262
- get shape() {
263
- const _shape = {
264
- ...schema._zod.def.shape,
265
- ...shape
266
- };
267
- assignProp(this, "shape", _shape);
268
- return _shape;
269
- },
270
- checks: schema._zod.def.checks
271
- });
272
- }
273
- function merge(a, b) {
274
- return clone(a, mergeDefs(a._zod.def, {
275
- get shape() {
276
- const _shape = {
277
- ...a._zod.def.shape,
278
- ...b._zod.def.shape
279
- };
280
- assignProp(this, "shape", _shape);
281
- return _shape;
282
- },
283
- get catchall() {
284
- return b._zod.def.catchall;
285
- },
286
- checks: []
287
- }));
288
- }
289
- function partial(Class, schema, mask) {
290
- return clone(schema, mergeDefs(schema._zod.def, {
291
- get shape() {
292
- const oldShape = schema._zod.def.shape;
293
- const shape = { ...oldShape };
294
- if (mask) for (const key in mask) {
295
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
296
- if (!mask[key]) continue;
297
- shape[key] = Class ? new Class({
298
- type: "optional",
299
- innerType: oldShape[key]
300
- }) : oldShape[key];
301
- }
302
- else for (const key in oldShape) shape[key] = Class ? new Class({
303
- type: "optional",
304
- innerType: oldShape[key]
305
- }) : oldShape[key];
306
- assignProp(this, "shape", shape);
307
- return shape;
308
- },
309
- checks: []
310
- }));
311
- }
312
- function required(Class, schema, mask) {
313
- return clone(schema, mergeDefs(schema._zod.def, {
314
- get shape() {
315
- const oldShape = schema._zod.def.shape;
316
- const shape = { ...oldShape };
317
- if (mask) for (const key in mask) {
318
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
319
- if (!mask[key]) continue;
320
- shape[key] = new Class({
321
- type: "nonoptional",
322
- innerType: oldShape[key]
323
- });
324
- }
325
- else for (const key in oldShape) shape[key] = new Class({
326
- type: "nonoptional",
327
- innerType: oldShape[key]
328
- });
329
- assignProp(this, "shape", shape);
330
- return shape;
331
- },
332
- checks: []
333
- }));
334
- }
335
- function aborted(x, startIndex = 0) {
336
- if (x.aborted === true) return true;
337
- for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
338
- return false;
339
- }
340
- function prefixIssues(path, issues) {
341
- return issues.map((iss) => {
342
- var _a$1;
343
- (_a$1 = iss).path ?? (_a$1.path = []);
344
- iss.path.unshift(path);
345
- return iss;
346
- });
347
- }
348
- function unwrapMessage(message) {
349
- return typeof message === "string" ? message : message?.message;
350
- }
351
- function finalizeIssue(iss, ctx, config$1) {
352
- const full = {
353
- ...iss,
354
- path: iss.path ?? []
355
- };
356
- if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config$1.customError?.(iss)) ?? unwrapMessage(config$1.localeError?.(iss)) ?? "Invalid input";
357
- delete full.inst;
358
- delete full.continue;
359
- if (!ctx?.reportInput) delete full.input;
360
- return full;
361
- }
362
- function getLengthableOrigin(input) {
363
- if (Array.isArray(input)) return "array";
364
- if (typeof input === "string") return "string";
365
- return "unknown";
366
- }
367
- function issue(...args) {
368
- const [iss, input, inst] = args;
369
- if (typeof iss === "string") return {
370
- message: iss,
371
- code: "custom",
372
- input,
373
- inst
374
- };
375
- return { ...iss };
376
- }
377
-
378
- //#endregion
379
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/errors.js
380
- const initializer$1 = (inst, def) => {
381
- inst.name = "$ZodError";
382
- Object.defineProperty(inst, "_zod", {
383
- value: inst._zod,
384
- enumerable: false
385
- });
386
- Object.defineProperty(inst, "issues", {
387
- value: def,
388
- enumerable: false
389
- });
390
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
391
- Object.defineProperty(inst, "toString", {
392
- value: () => inst.message,
393
- enumerable: false
394
- });
395
- };
396
- const $ZodError = $constructor("$ZodError", initializer$1);
397
- const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
398
- function flattenError(error, mapper = (issue$1) => issue$1.message) {
399
- const fieldErrors = {};
400
- const formErrors = [];
401
- for (const sub of error.issues) if (sub.path.length > 0) {
402
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
403
- fieldErrors[sub.path[0]].push(mapper(sub));
404
- } else formErrors.push(mapper(sub));
405
- return {
406
- formErrors,
407
- fieldErrors
408
- };
409
- }
410
- function formatError(error, mapper = (issue$1) => issue$1.message) {
411
- const fieldErrors = { _errors: [] };
412
- const processError = (error$1) => {
413
- for (const issue$1 of error$1.issues) if (issue$1.code === "invalid_union" && issue$1.errors.length) issue$1.errors.map((issues) => processError({ issues }));
414
- else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues });
415
- else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues });
416
- else if (issue$1.path.length === 0) fieldErrors._errors.push(mapper(issue$1));
417
- else {
418
- let curr = fieldErrors;
419
- let i = 0;
420
- while (i < issue$1.path.length) {
421
- const el = issue$1.path[i];
422
- if (!(i === issue$1.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
423
- else {
424
- curr[el] = curr[el] || { _errors: [] };
425
- curr[el]._errors.push(mapper(issue$1));
426
- }
427
- curr = curr[el];
428
- i++;
429
- }
430
- }
431
- };
432
- processError(error);
433
- return fieldErrors;
434
- }
435
-
436
- //#endregion
437
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/parse.js
438
- const _parse = (_Err) => (schema, value, _ctx, _params) => {
439
- const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
440
- const result = schema._zod.run({
441
- value,
442
- issues: []
443
- }, ctx);
444
- if (result instanceof Promise) throw new $ZodAsyncError();
445
- if (result.issues.length) {
446
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
447
- captureStackTrace(e, _params?.callee);
448
- throw e;
449
- }
450
- return result.value;
451
- };
452
- const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
453
- const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
454
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
455
- let result = schema._zod.run({
456
- value,
457
- issues: []
458
- }, ctx);
459
- if (result instanceof Promise) result = await result;
460
- if (result.issues.length) {
461
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
462
- captureStackTrace(e, params?.callee);
463
- throw e;
464
- }
465
- return result.value;
466
- };
467
- const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
468
- const _safeParse = (_Err) => (schema, value, _ctx) => {
469
- const ctx = _ctx ? {
470
- ..._ctx,
471
- async: false
472
- } : { async: false };
473
- const result = schema._zod.run({
474
- value,
475
- issues: []
476
- }, ctx);
477
- if (result instanceof Promise) throw new $ZodAsyncError();
478
- return result.issues.length ? {
479
- success: false,
480
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
481
- } : {
482
- success: true,
483
- data: result.value
484
- };
485
- };
486
- const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
487
- const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
488
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
489
- let result = schema._zod.run({
490
- value,
491
- issues: []
492
- }, ctx);
493
- if (result instanceof Promise) result = await result;
494
- return result.issues.length ? {
495
- success: false,
496
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
497
- } : {
498
- success: true,
499
- data: result.value
500
- };
501
- };
502
- const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
503
- const _encode = (_Err) => (schema, value, _ctx) => {
504
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
505
- return _parse(_Err)(schema, value, ctx);
506
- };
507
- const encode$1 = /* @__PURE__ */ _encode($ZodRealError);
508
- const _decode = (_Err) => (schema, value, _ctx) => {
509
- return _parse(_Err)(schema, value, _ctx);
510
- };
511
- const decode$1 = /* @__PURE__ */ _decode($ZodRealError);
512
- const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
513
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
514
- return _parseAsync(_Err)(schema, value, ctx);
515
- };
516
- const encodeAsync$1 = /* @__PURE__ */ _encodeAsync($ZodRealError);
517
- const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
518
- return _parseAsync(_Err)(schema, value, _ctx);
519
- };
520
- const decodeAsync$1 = /* @__PURE__ */ _decodeAsync($ZodRealError);
521
- const _safeEncode = (_Err) => (schema, value, _ctx) => {
522
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
523
- return _safeParse(_Err)(schema, value, ctx);
524
- };
525
- const safeEncode$1 = /* @__PURE__ */ _safeEncode($ZodRealError);
526
- const _safeDecode = (_Err) => (schema, value, _ctx) => {
527
- return _safeParse(_Err)(schema, value, _ctx);
528
- };
529
- const safeDecode$1 = /* @__PURE__ */ _safeDecode($ZodRealError);
530
- const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
531
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
532
- return _safeParseAsync(_Err)(schema, value, ctx);
533
- };
534
- const safeEncodeAsync$1 = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
535
- const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
536
- return _safeParseAsync(_Err)(schema, value, _ctx);
537
- };
538
- const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
539
-
540
- //#endregion
541
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/regexes.js
542
- const cuid = /^[cC][^\s-]{8,}$/;
543
- const cuid2 = /^[0-9a-z]+$/;
544
- const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
545
- const xid = /^[0-9a-vA-V]{20}$/;
546
- const ksuid = /^[A-Za-z0-9]{27}$/;
547
- const nanoid = /^[a-zA-Z0-9_-]{21}$/;
548
- /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
549
- const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
550
- /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
551
- const 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})$/;
552
- /** Returns a regex for validating an RFC 9562/4122 UUID.
553
- *
554
- * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
555
- const uuid = (version$1) => {
556
- if (!version$1) 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)$/;
557
- return /* @__PURE__ */ new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version$1}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
558
- };
559
- /** Practical email validation */
560
- const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
561
- const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
562
- function emoji() {
563
- return new RegExp(_emoji$1, "u");
564
- }
565
- const 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])$/;
566
- const 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}|:))$/;
567
- const 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])$/;
568
- const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
569
- const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
570
- const base64url = /^[A-Za-z0-9_-]*$/;
571
- const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
572
- const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
573
- const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
574
- function timeSource(args) {
575
- const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
576
- return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
577
- }
578
- function time$1(args) {
579
- return /* @__PURE__ */ new RegExp(`^${timeSource(args)}$`);
580
- }
581
- function datetime$1(args) {
582
- const time$2 = timeSource({ precision: args.precision });
583
- const opts = ["Z"];
584
- if (args.local) opts.push("");
585
- if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
586
- const timeRegex = `${time$2}(?:${opts.join("|")})`;
587
- return /* @__PURE__ */ new RegExp(`^${dateSource}T(?:${timeRegex})$`);
588
- }
589
- const string$1 = (params) => {
590
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
591
- return /* @__PURE__ */ new RegExp(`^${regex}$`);
592
- };
593
- const integer = /^-?\d+$/;
594
- const number$1 = /^-?\d+(?:\.\d+)?/;
595
- const lowercase = /^[^A-Z]*$/;
596
- const uppercase = /^[^a-z]*$/;
597
-
598
- //#endregion
599
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/checks.js
600
- const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
601
- var _a$1;
602
- inst._zod ?? (inst._zod = {});
603
- inst._zod.def = def;
604
- (_a$1 = inst._zod).onattach ?? (_a$1.onattach = []);
605
- });
606
- const numericOriginMap = {
607
- number: "number",
608
- bigint: "bigint",
609
- object: "date"
610
- };
611
- const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
612
- $ZodCheck.init(inst, def);
613
- const origin = numericOriginMap[typeof def.value];
614
- inst._zod.onattach.push((inst$1) => {
615
- const bag = inst$1._zod.bag;
616
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
617
- if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
618
- else bag.exclusiveMaximum = def.value;
619
- });
620
- inst._zod.check = (payload) => {
621
- if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
622
- payload.issues.push({
623
- origin,
624
- code: "too_big",
625
- maximum: def.value,
626
- input: payload.value,
627
- inclusive: def.inclusive,
628
- inst,
629
- continue: !def.abort
630
- });
631
- };
632
- });
633
- const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
634
- $ZodCheck.init(inst, def);
635
- const origin = numericOriginMap[typeof def.value];
636
- inst._zod.onattach.push((inst$1) => {
637
- const bag = inst$1._zod.bag;
638
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
639
- if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
640
- else bag.exclusiveMinimum = def.value;
641
- });
642
- inst._zod.check = (payload) => {
643
- if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
644
- payload.issues.push({
645
- origin,
646
- code: "too_small",
647
- minimum: def.value,
648
- input: payload.value,
649
- inclusive: def.inclusive,
650
- inst,
651
- continue: !def.abort
652
- });
653
- };
654
- });
655
- const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
656
- $ZodCheck.init(inst, def);
657
- inst._zod.onattach.push((inst$1) => {
658
- var _a$1;
659
- (_a$1 = inst$1._zod.bag).multipleOf ?? (_a$1.multipleOf = def.value);
660
- });
661
- inst._zod.check = (payload) => {
662
- if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
663
- if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
664
- payload.issues.push({
665
- origin: typeof payload.value,
666
- code: "not_multiple_of",
667
- divisor: def.value,
668
- input: payload.value,
669
- inst,
670
- continue: !def.abort
671
- });
672
- };
673
- });
674
- const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
675
- $ZodCheck.init(inst, def);
676
- def.format = def.format || "float64";
677
- const isInt = def.format?.includes("int");
678
- const origin = isInt ? "int" : "number";
679
- const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
680
- inst._zod.onattach.push((inst$1) => {
681
- const bag = inst$1._zod.bag;
682
- bag.format = def.format;
683
- bag.minimum = minimum;
684
- bag.maximum = maximum;
685
- if (isInt) bag.pattern = integer;
686
- });
687
- inst._zod.check = (payload) => {
688
- const input = payload.value;
689
- if (isInt) {
690
- if (!Number.isInteger(input)) {
691
- payload.issues.push({
692
- expected: origin,
693
- format: def.format,
694
- code: "invalid_type",
695
- continue: false,
696
- input,
697
- inst
698
- });
699
- return;
700
- }
701
- if (!Number.isSafeInteger(input)) {
702
- if (input > 0) payload.issues.push({
703
- input,
704
- code: "too_big",
705
- maximum: Number.MAX_SAFE_INTEGER,
706
- note: "Integers must be within the safe integer range.",
707
- inst,
708
- origin,
709
- continue: !def.abort
710
- });
711
- else payload.issues.push({
712
- input,
713
- code: "too_small",
714
- minimum: Number.MIN_SAFE_INTEGER,
715
- note: "Integers must be within the safe integer range.",
716
- inst,
717
- origin,
718
- continue: !def.abort
719
- });
720
- return;
721
- }
722
- }
723
- if (input < minimum) payload.issues.push({
724
- origin: "number",
725
- input,
726
- code: "too_small",
727
- minimum,
728
- inclusive: true,
729
- inst,
730
- continue: !def.abort
731
- });
732
- if (input > maximum) payload.issues.push({
733
- origin: "number",
734
- input,
735
- code: "too_big",
736
- maximum,
737
- inst
738
- });
739
- };
740
- });
741
- const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
742
- var _a$1;
743
- $ZodCheck.init(inst, def);
744
- (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
745
- const val = payload.value;
746
- return !nullish(val) && val.length !== void 0;
747
- });
748
- inst._zod.onattach.push((inst$1) => {
749
- const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
750
- if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
751
- });
752
- inst._zod.check = (payload) => {
753
- const input = payload.value;
754
- if (input.length <= def.maximum) return;
755
- const origin = getLengthableOrigin(input);
756
- payload.issues.push({
757
- origin,
758
- code: "too_big",
759
- maximum: def.maximum,
760
- inclusive: true,
761
- input,
762
- inst,
763
- continue: !def.abort
764
- });
765
- };
766
- });
767
- const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
768
- var _a$1;
769
- $ZodCheck.init(inst, def);
770
- (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
771
- const val = payload.value;
772
- return !nullish(val) && val.length !== void 0;
773
- });
774
- inst._zod.onattach.push((inst$1) => {
775
- const curr = inst$1._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
776
- if (def.minimum > curr) inst$1._zod.bag.minimum = def.minimum;
777
- });
778
- inst._zod.check = (payload) => {
779
- const input = payload.value;
780
- if (input.length >= def.minimum) return;
781
- const origin = getLengthableOrigin(input);
782
- payload.issues.push({
783
- origin,
784
- code: "too_small",
785
- minimum: def.minimum,
786
- inclusive: true,
787
- input,
788
- inst,
789
- continue: !def.abort
790
- });
791
- };
792
- });
793
- const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
794
- var _a$1;
795
- $ZodCheck.init(inst, def);
796
- (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
797
- const val = payload.value;
798
- return !nullish(val) && val.length !== void 0;
799
- });
800
- inst._zod.onattach.push((inst$1) => {
801
- const bag = inst$1._zod.bag;
802
- bag.minimum = def.length;
803
- bag.maximum = def.length;
804
- bag.length = def.length;
805
- });
806
- inst._zod.check = (payload) => {
807
- const input = payload.value;
808
- const length = input.length;
809
- if (length === def.length) return;
810
- const origin = getLengthableOrigin(input);
811
- const tooBig = length > def.length;
812
- payload.issues.push({
813
- origin,
814
- ...tooBig ? {
815
- code: "too_big",
816
- maximum: def.length
817
- } : {
818
- code: "too_small",
819
- minimum: def.length
820
- },
821
- inclusive: true,
822
- exact: true,
823
- input: payload.value,
824
- inst,
825
- continue: !def.abort
826
- });
827
- };
828
- });
829
- const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
830
- var _a$1, _b;
831
- $ZodCheck.init(inst, def);
832
- inst._zod.onattach.push((inst$1) => {
833
- const bag = inst$1._zod.bag;
834
- bag.format = def.format;
835
- if (def.pattern) {
836
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
837
- bag.patterns.add(def.pattern);
838
- }
839
- });
840
- if (def.pattern) (_a$1 = inst._zod).check ?? (_a$1.check = (payload) => {
841
- def.pattern.lastIndex = 0;
842
- if (def.pattern.test(payload.value)) return;
843
- payload.issues.push({
844
- origin: "string",
845
- code: "invalid_format",
846
- format: def.format,
847
- input: payload.value,
848
- ...def.pattern ? { pattern: def.pattern.toString() } : {},
849
- inst,
850
- continue: !def.abort
851
- });
852
- });
853
- else (_b = inst._zod).check ?? (_b.check = () => {});
854
- });
855
- const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
856
- $ZodCheckStringFormat.init(inst, def);
857
- inst._zod.check = (payload) => {
858
- def.pattern.lastIndex = 0;
859
- if (def.pattern.test(payload.value)) return;
860
- payload.issues.push({
861
- origin: "string",
862
- code: "invalid_format",
863
- format: "regex",
864
- input: payload.value,
865
- pattern: def.pattern.toString(),
866
- inst,
867
- continue: !def.abort
868
- });
869
- };
870
- });
871
- const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
872
- def.pattern ?? (def.pattern = lowercase);
873
- $ZodCheckStringFormat.init(inst, def);
874
- });
875
- const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
876
- def.pattern ?? (def.pattern = uppercase);
877
- $ZodCheckStringFormat.init(inst, def);
878
- });
879
- const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
880
- $ZodCheck.init(inst, def);
881
- const escapedRegex = escapeRegex(def.includes);
882
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
883
- def.pattern = pattern;
884
- inst._zod.onattach.push((inst$1) => {
885
- const bag = inst$1._zod.bag;
886
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
887
- bag.patterns.add(pattern);
888
- });
889
- inst._zod.check = (payload) => {
890
- if (payload.value.includes(def.includes, def.position)) return;
891
- payload.issues.push({
892
- origin: "string",
893
- code: "invalid_format",
894
- format: "includes",
895
- includes: def.includes,
896
- input: payload.value,
897
- inst,
898
- continue: !def.abort
899
- });
900
- };
901
- });
902
- const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
903
- $ZodCheck.init(inst, def);
904
- const pattern = /* @__PURE__ */ new RegExp(`^${escapeRegex(def.prefix)}.*`);
905
- def.pattern ?? (def.pattern = pattern);
906
- inst._zod.onattach.push((inst$1) => {
907
- const bag = inst$1._zod.bag;
908
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
909
- bag.patterns.add(pattern);
910
- });
911
- inst._zod.check = (payload) => {
912
- if (payload.value.startsWith(def.prefix)) return;
913
- payload.issues.push({
914
- origin: "string",
915
- code: "invalid_format",
916
- format: "starts_with",
917
- prefix: def.prefix,
918
- input: payload.value,
919
- inst,
920
- continue: !def.abort
921
- });
922
- };
923
- });
924
- const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
925
- $ZodCheck.init(inst, def);
926
- const pattern = /* @__PURE__ */ new RegExp(`.*${escapeRegex(def.suffix)}$`);
927
- def.pattern ?? (def.pattern = pattern);
928
- inst._zod.onattach.push((inst$1) => {
929
- const bag = inst$1._zod.bag;
930
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
931
- bag.patterns.add(pattern);
932
- });
933
- inst._zod.check = (payload) => {
934
- if (payload.value.endsWith(def.suffix)) return;
935
- payload.issues.push({
936
- origin: "string",
937
- code: "invalid_format",
938
- format: "ends_with",
939
- suffix: def.suffix,
940
- input: payload.value,
941
- inst,
942
- continue: !def.abort
943
- });
944
- };
945
- });
946
- const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
947
- $ZodCheck.init(inst, def);
948
- inst._zod.check = (payload) => {
949
- payload.value = def.tx(payload.value);
950
- };
951
- });
952
-
953
- //#endregion
954
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/doc.js
955
- var Doc = class {
956
- constructor(args = []) {
957
- this.content = [];
958
- this.indent = 0;
959
- if (this) this.args = args;
960
- }
961
- indented(fn) {
962
- this.indent += 1;
963
- fn(this);
964
- this.indent -= 1;
965
- }
966
- write(arg) {
967
- if (typeof arg === "function") {
968
- arg(this, { execution: "sync" });
969
- arg(this, { execution: "async" });
970
- return;
971
- }
972
- const lines = arg.split("\n").filter((x) => x);
973
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
974
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
975
- for (const line of dedented) this.content.push(line);
976
- }
977
- compile() {
978
- const F = Function;
979
- const args = this?.args;
980
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
981
- return new F(...args, lines.join("\n"));
982
- }
983
- };
984
-
985
- //#endregion
986
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/versions.js
987
- const version = {
988
- major: 4,
989
- minor: 1,
990
- patch: 13
991
- };
992
-
993
- //#endregion
994
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/schemas.js
995
- const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
996
- var _a$1;
997
- inst ?? (inst = {});
998
- inst._zod.def = def;
999
- inst._zod.bag = inst._zod.bag || {};
1000
- inst._zod.version = version;
1001
- const checks = [...inst._zod.def.checks ?? []];
1002
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1003
- for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1004
- if (checks.length === 0) {
1005
- (_a$1 = inst._zod).deferred ?? (_a$1.deferred = []);
1006
- inst._zod.deferred?.push(() => {
1007
- inst._zod.run = inst._zod.parse;
1008
- });
1009
- } else {
1010
- const runChecks = (payload, checks$1, ctx) => {
1011
- let isAborted = aborted(payload);
1012
- let asyncResult;
1013
- for (const ch of checks$1) {
1014
- if (ch._zod.def.when) {
1015
- if (!ch._zod.def.when(payload)) continue;
1016
- } else if (isAborted) continue;
1017
- const currLen = payload.issues.length;
1018
- const _ = ch._zod.check(payload);
1019
- if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
1020
- if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1021
- await _;
1022
- if (payload.issues.length === currLen) return;
1023
- if (!isAborted) isAborted = aborted(payload, currLen);
1024
- });
1025
- else {
1026
- if (payload.issues.length === currLen) continue;
1027
- if (!isAborted) isAborted = aborted(payload, currLen);
1028
- }
1029
- }
1030
- if (asyncResult) return asyncResult.then(() => {
1031
- return payload;
1032
- });
1033
- return payload;
1034
- };
1035
- const handleCanaryResult = (canary, payload, ctx) => {
1036
- if (aborted(canary)) {
1037
- canary.aborted = true;
1038
- return canary;
1039
- }
1040
- const checkResult = runChecks(payload, checks, ctx);
1041
- if (checkResult instanceof Promise) {
1042
- if (ctx.async === false) throw new $ZodAsyncError();
1043
- return checkResult.then((checkResult$1) => inst._zod.parse(checkResult$1, ctx));
1044
- }
1045
- return inst._zod.parse(checkResult, ctx);
1046
- };
1047
- inst._zod.run = (payload, ctx) => {
1048
- if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
1049
- if (ctx.direction === "backward") {
1050
- const canary = inst._zod.parse({
1051
- value: payload.value,
1052
- issues: []
1053
- }, {
1054
- ...ctx,
1055
- skipChecks: true
1056
- });
1057
- if (canary instanceof Promise) return canary.then((canary$1) => {
1058
- return handleCanaryResult(canary$1, payload, ctx);
1059
- });
1060
- return handleCanaryResult(canary, payload, ctx);
1061
- }
1062
- const result = inst._zod.parse(payload, ctx);
1063
- if (result instanceof Promise) {
1064
- if (ctx.async === false) throw new $ZodAsyncError();
1065
- return result.then((result$1) => runChecks(result$1, checks, ctx));
1066
- }
1067
- return runChecks(result, checks, ctx);
1068
- };
1069
- }
1070
- inst["~standard"] = {
1071
- validate: (value) => {
1072
- try {
1073
- const r = safeParse$1(inst, value);
1074
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1075
- } catch (_) {
1076
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1077
- }
1078
- },
1079
- vendor: "zod",
1080
- version: 1
1081
- };
1082
- });
1083
- const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1084
- $ZodType.init(inst, def);
1085
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1086
- inst._zod.parse = (payload, _) => {
1087
- if (def.coerce) try {
1088
- payload.value = String(payload.value);
1089
- } catch (_$1) {}
1090
- if (typeof payload.value === "string") return payload;
1091
- payload.issues.push({
1092
- expected: "string",
1093
- code: "invalid_type",
1094
- input: payload.value,
1095
- inst
1096
- });
1097
- return payload;
1098
- };
1099
- });
1100
- const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
1101
- $ZodCheckStringFormat.init(inst, def);
1102
- $ZodString.init(inst, def);
1103
- });
1104
- const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
1105
- def.pattern ?? (def.pattern = guid);
1106
- $ZodStringFormat.init(inst, def);
1107
- });
1108
- const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
1109
- if (def.version) {
1110
- const v = {
1111
- v1: 1,
1112
- v2: 2,
1113
- v3: 3,
1114
- v4: 4,
1115
- v5: 5,
1116
- v6: 6,
1117
- v7: 7,
1118
- v8: 8
1119
- }[def.version];
1120
- if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
1121
- def.pattern ?? (def.pattern = uuid(v));
1122
- } else def.pattern ?? (def.pattern = uuid());
1123
- $ZodStringFormat.init(inst, def);
1124
- });
1125
- const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
1126
- def.pattern ?? (def.pattern = email);
1127
- $ZodStringFormat.init(inst, def);
1128
- });
1129
- const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1130
- $ZodStringFormat.init(inst, def);
1131
- inst._zod.check = (payload) => {
1132
- try {
1133
- const trimmed = payload.value.trim();
1134
- const url = new URL(trimmed);
1135
- if (def.hostname) {
1136
- def.hostname.lastIndex = 0;
1137
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1138
- code: "invalid_format",
1139
- format: "url",
1140
- note: "Invalid hostname",
1141
- pattern: def.hostname.source,
1142
- input: payload.value,
1143
- inst,
1144
- continue: !def.abort
1145
- });
1146
- }
1147
- if (def.protocol) {
1148
- def.protocol.lastIndex = 0;
1149
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1150
- code: "invalid_format",
1151
- format: "url",
1152
- note: "Invalid protocol",
1153
- pattern: def.protocol.source,
1154
- input: payload.value,
1155
- inst,
1156
- continue: !def.abort
1157
- });
1158
- }
1159
- if (def.normalize) payload.value = url.href;
1160
- else payload.value = trimmed;
1161
- return;
1162
- } catch (_) {
1163
- payload.issues.push({
1164
- code: "invalid_format",
1165
- format: "url",
1166
- input: payload.value,
1167
- inst,
1168
- continue: !def.abort
1169
- });
1170
- }
1171
- };
1172
- });
1173
- const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
1174
- def.pattern ?? (def.pattern = emoji());
1175
- $ZodStringFormat.init(inst, def);
1176
- });
1177
- const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
1178
- def.pattern ?? (def.pattern = nanoid);
1179
- $ZodStringFormat.init(inst, def);
1180
- });
1181
- const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
1182
- def.pattern ?? (def.pattern = cuid);
1183
- $ZodStringFormat.init(inst, def);
1184
- });
1185
- const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
1186
- def.pattern ?? (def.pattern = cuid2);
1187
- $ZodStringFormat.init(inst, def);
1188
- });
1189
- const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
1190
- def.pattern ?? (def.pattern = ulid);
1191
- $ZodStringFormat.init(inst, def);
1192
- });
1193
- const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
1194
- def.pattern ?? (def.pattern = xid);
1195
- $ZodStringFormat.init(inst, def);
1196
- });
1197
- const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
1198
- def.pattern ?? (def.pattern = ksuid);
1199
- $ZodStringFormat.init(inst, def);
1200
- });
1201
- const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1202
- def.pattern ?? (def.pattern = datetime$1(def));
1203
- $ZodStringFormat.init(inst, def);
1204
- });
1205
- const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1206
- def.pattern ?? (def.pattern = date$1);
1207
- $ZodStringFormat.init(inst, def);
1208
- });
1209
- const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
1210
- def.pattern ?? (def.pattern = time$1(def));
1211
- $ZodStringFormat.init(inst, def);
1212
- });
1213
- const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
1214
- def.pattern ?? (def.pattern = duration$1);
1215
- $ZodStringFormat.init(inst, def);
1216
- });
1217
- const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1218
- def.pattern ?? (def.pattern = ipv4);
1219
- $ZodStringFormat.init(inst, def);
1220
- inst._zod.bag.format = `ipv4`;
1221
- });
1222
- const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1223
- def.pattern ?? (def.pattern = ipv6);
1224
- $ZodStringFormat.init(inst, def);
1225
- inst._zod.bag.format = `ipv6`;
1226
- inst._zod.check = (payload) => {
1227
- try {
1228
- new URL(`http://[${payload.value}]`);
1229
- } catch {
1230
- payload.issues.push({
1231
- code: "invalid_format",
1232
- format: "ipv6",
1233
- input: payload.value,
1234
- inst,
1235
- continue: !def.abort
1236
- });
1237
- }
1238
- };
1239
- });
1240
- const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
1241
- def.pattern ?? (def.pattern = cidrv4);
1242
- $ZodStringFormat.init(inst, def);
1243
- });
1244
- const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1245
- def.pattern ?? (def.pattern = cidrv6);
1246
- $ZodStringFormat.init(inst, def);
1247
- inst._zod.check = (payload) => {
1248
- const parts = payload.value.split("/");
1249
- try {
1250
- if (parts.length !== 2) throw new Error();
1251
- const [address, prefix] = parts;
1252
- if (!prefix) throw new Error();
1253
- const prefixNum = Number(prefix);
1254
- if (`${prefixNum}` !== prefix) throw new Error();
1255
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1256
- new URL(`http://[${address}]`);
1257
- } catch {
1258
- payload.issues.push({
1259
- code: "invalid_format",
1260
- format: "cidrv6",
1261
- input: payload.value,
1262
- inst,
1263
- continue: !def.abort
1264
- });
1265
- }
1266
- };
1267
- });
1268
- function isValidBase64(data) {
1269
- if (data === "") return true;
1270
- if (data.length % 4 !== 0) return false;
1271
- try {
1272
- atob(data);
1273
- return true;
1274
- } catch {
1275
- return false;
1276
- }
1277
- }
1278
- const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1279
- def.pattern ?? (def.pattern = base64);
1280
- $ZodStringFormat.init(inst, def);
1281
- inst._zod.bag.contentEncoding = "base64";
1282
- inst._zod.check = (payload) => {
1283
- if (isValidBase64(payload.value)) return;
1284
- payload.issues.push({
1285
- code: "invalid_format",
1286
- format: "base64",
1287
- input: payload.value,
1288
- inst,
1289
- continue: !def.abort
1290
- });
1291
- };
1292
- });
1293
- function isValidBase64URL(data) {
1294
- if (!base64url.test(data)) return false;
1295
- const base64$1 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1296
- return isValidBase64(base64$1.padEnd(Math.ceil(base64$1.length / 4) * 4, "="));
1297
- }
1298
- const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1299
- def.pattern ?? (def.pattern = base64url);
1300
- $ZodStringFormat.init(inst, def);
1301
- inst._zod.bag.contentEncoding = "base64url";
1302
- inst._zod.check = (payload) => {
1303
- if (isValidBase64URL(payload.value)) return;
1304
- payload.issues.push({
1305
- code: "invalid_format",
1306
- format: "base64url",
1307
- input: payload.value,
1308
- inst,
1309
- continue: !def.abort
1310
- });
1311
- };
1312
- });
1313
- const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1314
- def.pattern ?? (def.pattern = e164);
1315
- $ZodStringFormat.init(inst, def);
1316
- });
1317
- function isValidJWT(token, algorithm = null) {
1318
- try {
1319
- const tokensParts = token.split(".");
1320
- if (tokensParts.length !== 3) return false;
1321
- const [header] = tokensParts;
1322
- if (!header) return false;
1323
- const parsedHeader = JSON.parse(atob(header));
1324
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1325
- if (!parsedHeader.alg) return false;
1326
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
1327
- return true;
1328
- } catch {
1329
- return false;
1330
- }
1331
- }
1332
- const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1333
- $ZodStringFormat.init(inst, def);
1334
- inst._zod.check = (payload) => {
1335
- if (isValidJWT(payload.value, def.alg)) return;
1336
- payload.issues.push({
1337
- code: "invalid_format",
1338
- format: "jwt",
1339
- input: payload.value,
1340
- inst,
1341
- continue: !def.abort
1342
- });
1343
- };
1344
- });
1345
- const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1346
- $ZodType.init(inst, def);
1347
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1348
- inst._zod.parse = (payload, _ctx) => {
1349
- if (def.coerce) try {
1350
- payload.value = Number(payload.value);
1351
- } catch (_) {}
1352
- const input = payload.value;
1353
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1354
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1355
- payload.issues.push({
1356
- expected: "number",
1357
- code: "invalid_type",
1358
- input,
1359
- inst,
1360
- ...received ? { received } : {}
1361
- });
1362
- return payload;
1363
- };
1364
- });
1365
- const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1366
- $ZodCheckNumberFormat.init(inst, def);
1367
- $ZodNumber.init(inst, def);
1368
- });
1369
- const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1370
- $ZodType.init(inst, def);
1371
- inst._zod.parse = (payload) => payload;
1372
- });
1373
- const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1374
- $ZodType.init(inst, def);
1375
- inst._zod.parse = (payload, _ctx) => {
1376
- payload.issues.push({
1377
- expected: "never",
1378
- code: "invalid_type",
1379
- input: payload.value,
1380
- inst
1381
- });
1382
- return payload;
1383
- };
1384
- });
1385
- function handleArrayResult(result, final, index) {
1386
- if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1387
- final.value[index] = result.value;
1388
- }
1389
- const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1390
- $ZodType.init(inst, def);
1391
- inst._zod.parse = (payload, ctx) => {
1392
- const input = payload.value;
1393
- if (!Array.isArray(input)) {
1394
- payload.issues.push({
1395
- expected: "array",
1396
- code: "invalid_type",
1397
- input,
1398
- inst
1399
- });
1400
- return payload;
1401
- }
1402
- payload.value = Array(input.length);
1403
- const proms = [];
1404
- for (let i = 0; i < input.length; i++) {
1405
- const item = input[i];
1406
- const result = def.element._zod.run({
1407
- value: item,
1408
- issues: []
1409
- }, ctx);
1410
- if (result instanceof Promise) proms.push(result.then((result$1) => handleArrayResult(result$1, payload, i)));
1411
- else handleArrayResult(result, payload, i);
1412
- }
1413
- if (proms.length) return Promise.all(proms).then(() => payload);
1414
- return payload;
1415
- };
1416
- });
1417
- function handlePropertyResult(result, final, key, input) {
1418
- if (result.issues.length) final.issues.push(...prefixIssues(key, result.issues));
1419
- if (result.value === void 0) {
1420
- if (key in input) final.value[key] = void 0;
1421
- } else final.value[key] = result.value;
1422
- }
1423
- function normalizeDef(def) {
1424
- const keys = Object.keys(def.shape);
1425
- for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1426
- const okeys = optionalKeys(def.shape);
1427
- return {
1428
- ...def,
1429
- keys,
1430
- keySet: new Set(keys),
1431
- numKeys: keys.length,
1432
- optionalKeys: new Set(okeys)
1433
- };
1434
- }
1435
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1436
- const unrecognized = [];
1437
- const keySet = def.keySet;
1438
- const _catchall = def.catchall._zod;
1439
- const t = _catchall.def.type;
1440
- for (const key in input) {
1441
- if (keySet.has(key)) continue;
1442
- if (t === "never") {
1443
- unrecognized.push(key);
1444
- continue;
1445
- }
1446
- const r = _catchall.run({
1447
- value: input[key],
1448
- issues: []
1449
- }, ctx);
1450
- if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input)));
1451
- else handlePropertyResult(r, payload, key, input);
1452
- }
1453
- if (unrecognized.length) payload.issues.push({
1454
- code: "unrecognized_keys",
1455
- keys: unrecognized,
1456
- input,
1457
- inst
1458
- });
1459
- if (!proms.length) return payload;
1460
- return Promise.all(proms).then(() => {
1461
- return payload;
1462
- });
1463
- }
1464
- const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1465
- $ZodType.init(inst, def);
1466
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1467
- const sh = def.shape;
1468
- Object.defineProperty(def, "shape", { get: () => {
1469
- const newSh = { ...sh };
1470
- Object.defineProperty(def, "shape", { value: newSh });
1471
- return newSh;
1472
- } });
1473
- }
1474
- const _normalized = cached(() => normalizeDef(def));
1475
- defineLazy(inst._zod, "propValues", () => {
1476
- const shape = def.shape;
1477
- const propValues = {};
1478
- for (const key in shape) {
1479
- const field = shape[key]._zod;
1480
- if (field.values) {
1481
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1482
- for (const v of field.values) propValues[key].add(v);
1483
- }
1484
- }
1485
- return propValues;
1486
- });
1487
- const isObject$1 = isObject;
1488
- const catchall = def.catchall;
1489
- let value;
1490
- inst._zod.parse = (payload, ctx) => {
1491
- value ?? (value = _normalized.value);
1492
- const input = payload.value;
1493
- if (!isObject$1(input)) {
1494
- payload.issues.push({
1495
- expected: "object",
1496
- code: "invalid_type",
1497
- input,
1498
- inst
1499
- });
1500
- return payload;
1501
- }
1502
- payload.value = {};
1503
- const proms = [];
1504
- const shape = value.shape;
1505
- for (const key of value.keys) {
1506
- const r = shape[key]._zod.run({
1507
- value: input[key],
1508
- issues: []
1509
- }, ctx);
1510
- if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input)));
1511
- else handlePropertyResult(r, payload, key, input);
1512
- }
1513
- if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1514
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1515
- };
1516
- });
1517
- const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
1518
- $ZodObject.init(inst, def);
1519
- const superParse = inst._zod.parse;
1520
- const _normalized = cached(() => normalizeDef(def));
1521
- const generateFastpass = (shape) => {
1522
- const doc = new Doc([
1523
- "shape",
1524
- "payload",
1525
- "ctx"
1526
- ]);
1527
- const normalized = _normalized.value;
1528
- const parseStr = (key) => {
1529
- const k = esc(key);
1530
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1531
- };
1532
- doc.write(`const input = payload.value;`);
1533
- const ids = Object.create(null);
1534
- let counter = 0;
1535
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1536
- doc.write(`const newResult = {};`);
1537
- for (const key of normalized.keys) {
1538
- const id = ids[key];
1539
- const k = esc(key);
1540
- doc.write(`const ${id} = ${parseStr(key)};`);
1541
- doc.write(`
1542
- if (${id}.issues.length) {
1543
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1544
- ...iss,
1545
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1546
- })));
1547
- }
1548
-
1549
-
1550
- if (${id}.value === undefined) {
1551
- if (${k} in input) {
1552
- newResult[${k}] = undefined;
1553
- }
1554
- } else {
1555
- newResult[${k}] = ${id}.value;
1556
- }
1557
-
1558
- `);
1559
- }
1560
- doc.write(`payload.value = newResult;`);
1561
- doc.write(`return payload;`);
1562
- const fn = doc.compile();
1563
- return (payload, ctx) => fn(shape, payload, ctx);
1564
- };
1565
- let fastpass;
1566
- const isObject$1 = isObject;
1567
- const jit = !globalConfig.jitless;
1568
- const allowsEval$1 = allowsEval;
1569
- const fastEnabled = jit && allowsEval$1.value;
1570
- const catchall = def.catchall;
1571
- let value;
1572
- inst._zod.parse = (payload, ctx) => {
1573
- value ?? (value = _normalized.value);
1574
- const input = payload.value;
1575
- if (!isObject$1(input)) {
1576
- payload.issues.push({
1577
- expected: "object",
1578
- code: "invalid_type",
1579
- input,
1580
- inst
1581
- });
1582
- return payload;
1583
- }
1584
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1585
- if (!fastpass) fastpass = generateFastpass(def.shape);
1586
- payload = fastpass(payload, ctx);
1587
- if (!catchall) return payload;
1588
- return handleCatchall([], input, payload, ctx, value, inst);
1589
- }
1590
- return superParse(payload, ctx);
1591
- };
1592
- });
1593
- function handleUnionResults(results, final, inst, ctx) {
1594
- for (const result of results) if (result.issues.length === 0) {
1595
- final.value = result.value;
1596
- return final;
1597
- }
1598
- const nonaborted = results.filter((r) => !aborted(r));
1599
- if (nonaborted.length === 1) {
1600
- final.value = nonaborted[0].value;
1601
- return nonaborted[0];
1602
- }
1603
- final.issues.push({
1604
- code: "invalid_union",
1605
- input: final.value,
1606
- inst,
1607
- errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1608
- });
1609
- return final;
1610
- }
1611
- const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1612
- $ZodType.init(inst, def);
1613
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1614
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1615
- defineLazy(inst._zod, "values", () => {
1616
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1617
- });
1618
- defineLazy(inst._zod, "pattern", () => {
1619
- if (def.options.every((o) => o._zod.pattern)) {
1620
- const patterns = def.options.map((o) => o._zod.pattern);
1621
- return /* @__PURE__ */ new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1622
- }
1623
- });
1624
- const single = def.options.length === 1;
1625
- const first = def.options[0]._zod.run;
1626
- inst._zod.parse = (payload, ctx) => {
1627
- if (single) return first(payload, ctx);
1628
- let async = false;
1629
- const results = [];
1630
- for (const option of def.options) {
1631
- const result = option._zod.run({
1632
- value: payload.value,
1633
- issues: []
1634
- }, ctx);
1635
- if (result instanceof Promise) {
1636
- results.push(result);
1637
- async = true;
1638
- } else {
1639
- if (result.issues.length === 0) return result;
1640
- results.push(result);
1641
- }
1642
- }
1643
- if (!async) return handleUnionResults(results, payload, inst, ctx);
1644
- return Promise.all(results).then((results$1) => {
1645
- return handleUnionResults(results$1, payload, inst, ctx);
1646
- });
1647
- };
1648
- });
1649
- const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1650
- $ZodType.init(inst, def);
1651
- inst._zod.parse = (payload, ctx) => {
1652
- const input = payload.value;
1653
- const left = def.left._zod.run({
1654
- value: input,
1655
- issues: []
1656
- }, ctx);
1657
- const right = def.right._zod.run({
1658
- value: input,
1659
- issues: []
1660
- }, ctx);
1661
- if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left$1, right$1]) => {
1662
- return handleIntersectionResults(payload, left$1, right$1);
1663
- });
1664
- return handleIntersectionResults(payload, left, right);
1665
- };
1666
- });
1667
- function mergeValues(a, b) {
1668
- if (a === b) return {
1669
- valid: true,
1670
- data: a
1671
- };
1672
- if (a instanceof Date && b instanceof Date && +a === +b) return {
1673
- valid: true,
1674
- data: a
1675
- };
1676
- if (isPlainObject(a) && isPlainObject(b)) {
1677
- const bKeys = Object.keys(b);
1678
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1679
- const newObj = {
1680
- ...a,
1681
- ...b
1682
- };
1683
- for (const key of sharedKeys) {
1684
- const sharedValue = mergeValues(a[key], b[key]);
1685
- if (!sharedValue.valid) return {
1686
- valid: false,
1687
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1688
- };
1689
- newObj[key] = sharedValue.data;
1690
- }
1691
- return {
1692
- valid: true,
1693
- data: newObj
1694
- };
1695
- }
1696
- if (Array.isArray(a) && Array.isArray(b)) {
1697
- if (a.length !== b.length) return {
1698
- valid: false,
1699
- mergeErrorPath: []
1700
- };
1701
- const newArray = [];
1702
- for (let index = 0; index < a.length; index++) {
1703
- const itemA = a[index];
1704
- const itemB = b[index];
1705
- const sharedValue = mergeValues(itemA, itemB);
1706
- if (!sharedValue.valid) return {
1707
- valid: false,
1708
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1709
- };
1710
- newArray.push(sharedValue.data);
1711
- }
1712
- return {
1713
- valid: true,
1714
- data: newArray
1715
- };
1716
- }
1717
- return {
1718
- valid: false,
1719
- mergeErrorPath: []
1720
- };
1721
- }
1722
- function handleIntersectionResults(result, left, right) {
1723
- if (left.issues.length) result.issues.push(...left.issues);
1724
- if (right.issues.length) result.issues.push(...right.issues);
1725
- if (aborted(result)) return result;
1726
- const merged = mergeValues(left.value, right.value);
1727
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
1728
- result.value = merged.data;
1729
- return result;
1730
- }
1731
- const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
1732
- $ZodType.init(inst, def);
1733
- const values = getEnumValues(def.entries);
1734
- const valuesSet = new Set(values);
1735
- inst._zod.values = valuesSet;
1736
- inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
1737
- inst._zod.parse = (payload, _ctx) => {
1738
- const input = payload.value;
1739
- if (valuesSet.has(input)) return payload;
1740
- payload.issues.push({
1741
- code: "invalid_value",
1742
- values,
1743
- input,
1744
- inst
1745
- });
1746
- return payload;
1747
- };
1748
- });
1749
- const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
1750
- $ZodType.init(inst, def);
1751
- if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
1752
- const values = new Set(def.values);
1753
- inst._zod.values = values;
1754
- inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
1755
- inst._zod.parse = (payload, _ctx) => {
1756
- const input = payload.value;
1757
- if (values.has(input)) return payload;
1758
- payload.issues.push({
1759
- code: "invalid_value",
1760
- values: def.values,
1761
- input,
1762
- inst
1763
- });
1764
- return payload;
1765
- };
1766
- });
1767
- const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
1768
- $ZodType.init(inst, def);
1769
- inst._zod.parse = (payload, ctx) => {
1770
- if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1771
- const _out = def.transform(payload.value, payload);
1772
- if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1773
- payload.value = output;
1774
- return payload;
1775
- });
1776
- if (_out instanceof Promise) throw new $ZodAsyncError();
1777
- payload.value = _out;
1778
- return payload;
1779
- };
1780
- });
1781
- function handleOptionalResult(result, input) {
1782
- if (result.issues.length && input === void 0) return {
1783
- issues: [],
1784
- value: void 0
1785
- };
1786
- return result;
1787
- }
1788
- const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
1789
- $ZodType.init(inst, def);
1790
- inst._zod.optin = "optional";
1791
- inst._zod.optout = "optional";
1792
- defineLazy(inst._zod, "values", () => {
1793
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
1794
- });
1795
- defineLazy(inst._zod, "pattern", () => {
1796
- const pattern = def.innerType._zod.pattern;
1797
- return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
1798
- });
1799
- inst._zod.parse = (payload, ctx) => {
1800
- if (def.innerType._zod.optin === "optional") {
1801
- const result = def.innerType._zod.run(payload, ctx);
1802
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
1803
- return handleOptionalResult(result, payload.value);
1804
- }
1805
- if (payload.value === void 0) return payload;
1806
- return def.innerType._zod.run(payload, ctx);
1807
- };
1808
- });
1809
- const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
1810
- $ZodType.init(inst, def);
1811
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1812
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1813
- defineLazy(inst._zod, "pattern", () => {
1814
- const pattern = def.innerType._zod.pattern;
1815
- return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
1816
- });
1817
- defineLazy(inst._zod, "values", () => {
1818
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
1819
- });
1820
- inst._zod.parse = (payload, ctx) => {
1821
- if (payload.value === null) return payload;
1822
- return def.innerType._zod.run(payload, ctx);
1823
- };
1824
- });
1825
- const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
1826
- $ZodType.init(inst, def);
1827
- inst._zod.optin = "optional";
1828
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1829
- inst._zod.parse = (payload, ctx) => {
1830
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1831
- if (payload.value === void 0) {
1832
- payload.value = def.defaultValue;
1833
- /**
1834
- * $ZodDefault returns the default value immediately in forward direction.
1835
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
1836
- return payload;
1837
- }
1838
- const result = def.innerType._zod.run(payload, ctx);
1839
- if (result instanceof Promise) return result.then((result$1) => handleDefaultResult(result$1, def));
1840
- return handleDefaultResult(result, def);
1841
- };
1842
- });
1843
- function handleDefaultResult(payload, def) {
1844
- if (payload.value === void 0) payload.value = def.defaultValue;
1845
- return payload;
1846
- }
1847
- const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
1848
- $ZodType.init(inst, def);
1849
- inst._zod.optin = "optional";
1850
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1851
- inst._zod.parse = (payload, ctx) => {
1852
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1853
- if (payload.value === void 0) payload.value = def.defaultValue;
1854
- return def.innerType._zod.run(payload, ctx);
1855
- };
1856
- });
1857
- const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
1858
- $ZodType.init(inst, def);
1859
- defineLazy(inst._zod, "values", () => {
1860
- const v = def.innerType._zod.values;
1861
- return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
1862
- });
1863
- inst._zod.parse = (payload, ctx) => {
1864
- const result = def.innerType._zod.run(payload, ctx);
1865
- if (result instanceof Promise) return result.then((result$1) => handleNonOptionalResult(result$1, inst));
1866
- return handleNonOptionalResult(result, inst);
1867
- };
1868
- });
1869
- function handleNonOptionalResult(payload, inst) {
1870
- if (!payload.issues.length && payload.value === void 0) payload.issues.push({
1871
- code: "invalid_type",
1872
- expected: "nonoptional",
1873
- input: payload.value,
1874
- inst
1875
- });
1876
- return payload;
1877
- }
1878
- const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
1879
- $ZodType.init(inst, def);
1880
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1881
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1882
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1883
- inst._zod.parse = (payload, ctx) => {
1884
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1885
- const result = def.innerType._zod.run(payload, ctx);
1886
- if (result instanceof Promise) return result.then((result$1) => {
1887
- payload.value = result$1.value;
1888
- if (result$1.issues.length) {
1889
- payload.value = def.catchValue({
1890
- ...payload,
1891
- error: { issues: result$1.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
1892
- input: payload.value
1893
- });
1894
- payload.issues = [];
1895
- }
1896
- return payload;
1897
- });
1898
- payload.value = result.value;
1899
- if (result.issues.length) {
1900
- payload.value = def.catchValue({
1901
- ...payload,
1902
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
1903
- input: payload.value
1904
- });
1905
- payload.issues = [];
1906
- }
1907
- return payload;
1908
- };
1909
- });
1910
- const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
1911
- $ZodType.init(inst, def);
1912
- defineLazy(inst._zod, "values", () => def.in._zod.values);
1913
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1914
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1915
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
1916
- inst._zod.parse = (payload, ctx) => {
1917
- if (ctx.direction === "backward") {
1918
- const right = def.out._zod.run(payload, ctx);
1919
- if (right instanceof Promise) return right.then((right$1) => handlePipeResult(right$1, def.in, ctx));
1920
- return handlePipeResult(right, def.in, ctx);
1921
- }
1922
- const left = def.in._zod.run(payload, ctx);
1923
- if (left instanceof Promise) return left.then((left$1) => handlePipeResult(left$1, def.out, ctx));
1924
- return handlePipeResult(left, def.out, ctx);
1925
- };
1926
- });
1927
- function handlePipeResult(left, next, ctx) {
1928
- if (left.issues.length) {
1929
- left.aborted = true;
1930
- return left;
1931
- }
1932
- return next._zod.run({
1933
- value: left.value,
1934
- issues: left.issues
1935
- }, ctx);
1936
- }
1937
- const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
1938
- $ZodType.init(inst, def);
1939
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1940
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1941
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
1942
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
1943
- inst._zod.parse = (payload, ctx) => {
1944
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1945
- const result = def.innerType._zod.run(payload, ctx);
1946
- if (result instanceof Promise) return result.then(handleReadonlyResult);
1947
- return handleReadonlyResult(result);
1948
- };
1949
- });
1950
- function handleReadonlyResult(payload) {
1951
- payload.value = Object.freeze(payload.value);
1952
- return payload;
1953
- }
1954
- const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
1955
- $ZodCheck.init(inst, def);
1956
- $ZodType.init(inst, def);
1957
- inst._zod.parse = (payload, _) => {
1958
- return payload;
1959
- };
1960
- inst._zod.check = (payload) => {
1961
- const input = payload.value;
1962
- const r = def.fn(input);
1963
- if (r instanceof Promise) return r.then((r$1) => handleRefineResult(r$1, payload, input, inst));
1964
- handleRefineResult(r, payload, input, inst);
1965
- };
1966
- });
1967
- function handleRefineResult(result, payload, input, inst) {
1968
- if (!result) {
1969
- const _iss = {
1970
- code: "custom",
1971
- input,
1972
- inst,
1973
- path: [...inst._zod.def.path ?? []],
1974
- continue: !inst._zod.def.abort
1975
- };
1976
- if (inst._zod.def.params) _iss.params = inst._zod.def.params;
1977
- payload.issues.push(issue(_iss));
1978
- }
1979
- }
1980
-
1981
- //#endregion
1982
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/registries.js
1983
- var _a;
1984
- var $ZodRegistry = class {
1985
- constructor() {
1986
- this._map = /* @__PURE__ */ new WeakMap();
1987
- this._idmap = /* @__PURE__ */ new Map();
1988
- }
1989
- add(schema, ..._meta) {
1990
- const meta$2 = _meta[0];
1991
- this._map.set(schema, meta$2);
1992
- if (meta$2 && typeof meta$2 === "object" && "id" in meta$2) {
1993
- if (this._idmap.has(meta$2.id)) throw new Error(`ID ${meta$2.id} already exists in the registry`);
1994
- this._idmap.set(meta$2.id, schema);
1995
- }
1996
- return this;
1997
- }
1998
- clear() {
1999
- this._map = /* @__PURE__ */ new WeakMap();
2000
- this._idmap = /* @__PURE__ */ new Map();
2001
- return this;
2002
- }
2003
- remove(schema) {
2004
- const meta$2 = this._map.get(schema);
2005
- if (meta$2 && typeof meta$2 === "object" && "id" in meta$2) this._idmap.delete(meta$2.id);
2006
- this._map.delete(schema);
2007
- return this;
2008
- }
2009
- get(schema) {
2010
- const p = schema._zod.parent;
2011
- if (p) {
2012
- const pm = { ...this.get(p) ?? {} };
2013
- delete pm.id;
2014
- const f = {
2015
- ...pm,
2016
- ...this._map.get(schema)
2017
- };
2018
- return Object.keys(f).length ? f : void 0;
2019
- }
2020
- return this._map.get(schema);
2021
- }
2022
- has(schema) {
2023
- return this._map.has(schema);
2024
- }
2025
- };
2026
- function registry() {
2027
- return new $ZodRegistry();
2028
- }
2029
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2030
- const globalRegistry = globalThis.__zod_globalRegistry;
2031
-
2032
- //#endregion
2033
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/api.js
2034
- function _string(Class, params) {
2035
- return new Class({
2036
- type: "string",
2037
- ...normalizeParams(params)
2038
- });
2039
- }
2040
- function _email(Class, params) {
2041
- return new Class({
2042
- type: "string",
2043
- format: "email",
2044
- check: "string_format",
2045
- abort: false,
2046
- ...normalizeParams(params)
2047
- });
2048
- }
2049
- function _guid(Class, params) {
2050
- return new Class({
2051
- type: "string",
2052
- format: "guid",
2053
- check: "string_format",
2054
- abort: false,
2055
- ...normalizeParams(params)
2056
- });
2057
- }
2058
- function _uuid(Class, params) {
2059
- return new Class({
2060
- type: "string",
2061
- format: "uuid",
2062
- check: "string_format",
2063
- abort: false,
2064
- ...normalizeParams(params)
2065
- });
2066
- }
2067
- function _uuidv4(Class, params) {
2068
- return new Class({
2069
- type: "string",
2070
- format: "uuid",
2071
- check: "string_format",
2072
- abort: false,
2073
- version: "v4",
2074
- ...normalizeParams(params)
2075
- });
2076
- }
2077
- function _uuidv6(Class, params) {
2078
- return new Class({
2079
- type: "string",
2080
- format: "uuid",
2081
- check: "string_format",
2082
- abort: false,
2083
- version: "v6",
2084
- ...normalizeParams(params)
2085
- });
2086
- }
2087
- function _uuidv7(Class, params) {
2088
- return new Class({
2089
- type: "string",
2090
- format: "uuid",
2091
- check: "string_format",
2092
- abort: false,
2093
- version: "v7",
2094
- ...normalizeParams(params)
2095
- });
2096
- }
2097
- function _url(Class, params) {
2098
- return new Class({
2099
- type: "string",
2100
- format: "url",
2101
- check: "string_format",
2102
- abort: false,
2103
- ...normalizeParams(params)
2104
- });
2105
- }
2106
- function _emoji(Class, params) {
2107
- return new Class({
2108
- type: "string",
2109
- format: "emoji",
2110
- check: "string_format",
2111
- abort: false,
2112
- ...normalizeParams(params)
2113
- });
2114
- }
2115
- function _nanoid(Class, params) {
2116
- return new Class({
2117
- type: "string",
2118
- format: "nanoid",
2119
- check: "string_format",
2120
- abort: false,
2121
- ...normalizeParams(params)
2122
- });
2123
- }
2124
- function _cuid(Class, params) {
2125
- return new Class({
2126
- type: "string",
2127
- format: "cuid",
2128
- check: "string_format",
2129
- abort: false,
2130
- ...normalizeParams(params)
2131
- });
2132
- }
2133
- function _cuid2(Class, params) {
2134
- return new Class({
2135
- type: "string",
2136
- format: "cuid2",
2137
- check: "string_format",
2138
- abort: false,
2139
- ...normalizeParams(params)
2140
- });
2141
- }
2142
- function _ulid(Class, params) {
2143
- return new Class({
2144
- type: "string",
2145
- format: "ulid",
2146
- check: "string_format",
2147
- abort: false,
2148
- ...normalizeParams(params)
2149
- });
2150
- }
2151
- function _xid(Class, params) {
2152
- return new Class({
2153
- type: "string",
2154
- format: "xid",
2155
- check: "string_format",
2156
- abort: false,
2157
- ...normalizeParams(params)
2158
- });
2159
- }
2160
- function _ksuid(Class, params) {
2161
- return new Class({
2162
- type: "string",
2163
- format: "ksuid",
2164
- check: "string_format",
2165
- abort: false,
2166
- ...normalizeParams(params)
2167
- });
2168
- }
2169
- function _ipv4(Class, params) {
2170
- return new Class({
2171
- type: "string",
2172
- format: "ipv4",
2173
- check: "string_format",
2174
- abort: false,
2175
- ...normalizeParams(params)
2176
- });
2177
- }
2178
- function _ipv6(Class, params) {
2179
- return new Class({
2180
- type: "string",
2181
- format: "ipv6",
2182
- check: "string_format",
2183
- abort: false,
2184
- ...normalizeParams(params)
2185
- });
2186
- }
2187
- function _cidrv4(Class, params) {
2188
- return new Class({
2189
- type: "string",
2190
- format: "cidrv4",
2191
- check: "string_format",
2192
- abort: false,
2193
- ...normalizeParams(params)
2194
- });
2195
- }
2196
- function _cidrv6(Class, params) {
2197
- return new Class({
2198
- type: "string",
2199
- format: "cidrv6",
2200
- check: "string_format",
2201
- abort: false,
2202
- ...normalizeParams(params)
2203
- });
2204
- }
2205
- function _base64(Class, params) {
2206
- return new Class({
2207
- type: "string",
2208
- format: "base64",
2209
- check: "string_format",
2210
- abort: false,
2211
- ...normalizeParams(params)
2212
- });
2213
- }
2214
- function _base64url(Class, params) {
2215
- return new Class({
2216
- type: "string",
2217
- format: "base64url",
2218
- check: "string_format",
2219
- abort: false,
2220
- ...normalizeParams(params)
2221
- });
2222
- }
2223
- function _e164(Class, params) {
2224
- return new Class({
2225
- type: "string",
2226
- format: "e164",
2227
- check: "string_format",
2228
- abort: false,
2229
- ...normalizeParams(params)
2230
- });
2231
- }
2232
- function _jwt(Class, params) {
2233
- return new Class({
2234
- type: "string",
2235
- format: "jwt",
2236
- check: "string_format",
2237
- abort: false,
2238
- ...normalizeParams(params)
2239
- });
2240
- }
2241
- function _isoDateTime(Class, params) {
2242
- return new Class({
2243
- type: "string",
2244
- format: "datetime",
2245
- check: "string_format",
2246
- offset: false,
2247
- local: false,
2248
- precision: null,
2249
- ...normalizeParams(params)
2250
- });
2251
- }
2252
- function _isoDate(Class, params) {
2253
- return new Class({
2254
- type: "string",
2255
- format: "date",
2256
- check: "string_format",
2257
- ...normalizeParams(params)
2258
- });
2259
- }
2260
- function _isoTime(Class, params) {
2261
- return new Class({
2262
- type: "string",
2263
- format: "time",
2264
- check: "string_format",
2265
- precision: null,
2266
- ...normalizeParams(params)
2267
- });
2268
- }
2269
- function _isoDuration(Class, params) {
2270
- return new Class({
2271
- type: "string",
2272
- format: "duration",
2273
- check: "string_format",
2274
- ...normalizeParams(params)
2275
- });
2276
- }
2277
- function _number(Class, params) {
2278
- return new Class({
2279
- type: "number",
2280
- checks: [],
2281
- ...normalizeParams(params)
2282
- });
2283
- }
2284
- function _int(Class, params) {
2285
- return new Class({
2286
- type: "number",
2287
- check: "number_format",
2288
- abort: false,
2289
- format: "safeint",
2290
- ...normalizeParams(params)
2291
- });
2292
- }
2293
- function _unknown(Class) {
2294
- return new Class({ type: "unknown" });
2295
- }
2296
- function _never(Class, params) {
2297
- return new Class({
2298
- type: "never",
2299
- ...normalizeParams(params)
2300
- });
2301
- }
2302
- function _lt(value, params) {
2303
- return new $ZodCheckLessThan({
2304
- check: "less_than",
2305
- ...normalizeParams(params),
2306
- value,
2307
- inclusive: false
2308
- });
2309
- }
2310
- function _lte(value, params) {
2311
- return new $ZodCheckLessThan({
2312
- check: "less_than",
2313
- ...normalizeParams(params),
2314
- value,
2315
- inclusive: true
2316
- });
2317
- }
2318
- function _gt(value, params) {
2319
- return new $ZodCheckGreaterThan({
2320
- check: "greater_than",
2321
- ...normalizeParams(params),
2322
- value,
2323
- inclusive: false
2324
- });
2325
- }
2326
- function _gte(value, params) {
2327
- return new $ZodCheckGreaterThan({
2328
- check: "greater_than",
2329
- ...normalizeParams(params),
2330
- value,
2331
- inclusive: true
2332
- });
2333
- }
2334
- function _multipleOf(value, params) {
2335
- return new $ZodCheckMultipleOf({
2336
- check: "multiple_of",
2337
- ...normalizeParams(params),
2338
- value
2339
- });
2340
- }
2341
- function _maxLength(maximum, params) {
2342
- return new $ZodCheckMaxLength({
2343
- check: "max_length",
2344
- ...normalizeParams(params),
2345
- maximum
2346
- });
2347
- }
2348
- function _minLength(minimum, params) {
2349
- return new $ZodCheckMinLength({
2350
- check: "min_length",
2351
- ...normalizeParams(params),
2352
- minimum
2353
- });
2354
- }
2355
- function _length(length, params) {
2356
- return new $ZodCheckLengthEquals({
2357
- check: "length_equals",
2358
- ...normalizeParams(params),
2359
- length
2360
- });
2361
- }
2362
- function _regex(pattern, params) {
2363
- return new $ZodCheckRegex({
2364
- check: "string_format",
2365
- format: "regex",
2366
- ...normalizeParams(params),
2367
- pattern
2368
- });
2369
- }
2370
- function _lowercase(params) {
2371
- return new $ZodCheckLowerCase({
2372
- check: "string_format",
2373
- format: "lowercase",
2374
- ...normalizeParams(params)
2375
- });
2376
- }
2377
- function _uppercase(params) {
2378
- return new $ZodCheckUpperCase({
2379
- check: "string_format",
2380
- format: "uppercase",
2381
- ...normalizeParams(params)
2382
- });
2383
- }
2384
- function _includes(includes, params) {
2385
- return new $ZodCheckIncludes({
2386
- check: "string_format",
2387
- format: "includes",
2388
- ...normalizeParams(params),
2389
- includes
2390
- });
2391
- }
2392
- function _startsWith(prefix, params) {
2393
- return new $ZodCheckStartsWith({
2394
- check: "string_format",
2395
- format: "starts_with",
2396
- ...normalizeParams(params),
2397
- prefix
2398
- });
2399
- }
2400
- function _endsWith(suffix, params) {
2401
- return new $ZodCheckEndsWith({
2402
- check: "string_format",
2403
- format: "ends_with",
2404
- ...normalizeParams(params),
2405
- suffix
2406
- });
2407
- }
2408
- function _overwrite(tx) {
2409
- return new $ZodCheckOverwrite({
2410
- check: "overwrite",
2411
- tx
2412
- });
2413
- }
2414
- function _normalize(form) {
2415
- return _overwrite((input) => input.normalize(form));
2416
- }
2417
- function _trim() {
2418
- return _overwrite((input) => input.trim());
2419
- }
2420
- function _toLowerCase() {
2421
- return _overwrite((input) => input.toLowerCase());
2422
- }
2423
- function _toUpperCase() {
2424
- return _overwrite((input) => input.toUpperCase());
2425
- }
2426
- function _slugify() {
2427
- return _overwrite((input) => slugify(input));
2428
- }
2429
- function _array(Class, element, params) {
2430
- return new Class({
2431
- type: "array",
2432
- element,
2433
- ...normalizeParams(params)
2434
- });
2435
- }
2436
- function _refine(Class, fn, _params) {
2437
- return new Class({
2438
- type: "custom",
2439
- check: "custom",
2440
- fn,
2441
- ...normalizeParams(_params)
2442
- });
2443
- }
2444
- function _superRefine(fn) {
2445
- const ch = _check((payload) => {
2446
- payload.addIssue = (issue$1) => {
2447
- if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
2448
- else {
2449
- const _issue = issue$1;
2450
- if (_issue.fatal) _issue.continue = false;
2451
- _issue.code ?? (_issue.code = "custom");
2452
- _issue.input ?? (_issue.input = payload.value);
2453
- _issue.inst ?? (_issue.inst = ch);
2454
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2455
- payload.issues.push(issue(_issue));
2456
- }
2457
- };
2458
- return fn(payload.value, payload);
2459
- });
2460
- return ch;
2461
- }
2462
- function _check(fn, params) {
2463
- const ch = new $ZodCheck({
2464
- check: "custom",
2465
- ...normalizeParams(params)
2466
- });
2467
- ch._zod.check = fn;
2468
- return ch;
2469
- }
2470
- function describe$1(description) {
2471
- const ch = new $ZodCheck({ check: "describe" });
2472
- ch._zod.onattach = [(inst) => {
2473
- const existing = globalRegistry.get(inst) ?? {};
2474
- globalRegistry.add(inst, {
2475
- ...existing,
2476
- description
2477
- });
2478
- }];
2479
- ch._zod.check = () => {};
2480
- return ch;
2481
- }
2482
- function meta$1(metadata) {
2483
- const ch = new $ZodCheck({ check: "meta" });
2484
- ch._zod.onattach = [(inst) => {
2485
- const existing = globalRegistry.get(inst) ?? {};
2486
- globalRegistry.add(inst, {
2487
- ...existing,
2488
- ...metadata
2489
- });
2490
- }];
2491
- ch._zod.check = () => {};
2492
- return ch;
2493
- }
2494
-
2495
- //#endregion
2496
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/iso.js
2497
- const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
2498
- $ZodISODateTime.init(inst, def);
2499
- ZodStringFormat.init(inst, def);
2500
- });
2501
- function datetime(params) {
2502
- return _isoDateTime(ZodISODateTime, params);
2503
- }
2504
- const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
2505
- $ZodISODate.init(inst, def);
2506
- ZodStringFormat.init(inst, def);
2507
- });
2508
- function date(params) {
2509
- return _isoDate(ZodISODate, params);
2510
- }
2511
- const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
2512
- $ZodISOTime.init(inst, def);
2513
- ZodStringFormat.init(inst, def);
2514
- });
2515
- function time(params) {
2516
- return _isoTime(ZodISOTime, params);
2517
- }
2518
- const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
2519
- $ZodISODuration.init(inst, def);
2520
- ZodStringFormat.init(inst, def);
2521
- });
2522
- function duration(params) {
2523
- return _isoDuration(ZodISODuration, params);
2524
- }
2525
-
2526
- //#endregion
2527
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/errors.js
2528
- const initializer = (inst, issues) => {
2529
- $ZodError.init(inst, issues);
2530
- inst.name = "ZodError";
2531
- Object.defineProperties(inst, {
2532
- format: { value: (mapper) => formatError(inst, mapper) },
2533
- flatten: { value: (mapper) => flattenError(inst, mapper) },
2534
- addIssue: { value: (issue$1) => {
2535
- inst.issues.push(issue$1);
2536
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
2537
- } },
2538
- addIssues: { value: (issues$1) => {
2539
- inst.issues.push(...issues$1);
2540
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
2541
- } },
2542
- isEmpty: { get() {
2543
- return inst.issues.length === 0;
2544
- } }
2545
- });
2546
- };
2547
- const ZodError = $constructor("ZodError", initializer);
2548
- const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
2549
-
2550
- //#endregion
2551
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/parse.js
2552
- const parse = /* @__PURE__ */ _parse(ZodRealError);
2553
- const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
2554
- const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
2555
- const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
2556
- const encode = /* @__PURE__ */ _encode(ZodRealError);
2557
- const decode = /* @__PURE__ */ _decode(ZodRealError);
2558
- const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
2559
- const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
2560
- const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
2561
- const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
2562
- const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
2563
- const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
2564
-
2565
- //#endregion
2566
- //#region ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/schemas.js
2567
- const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2568
- $ZodType.init(inst, def);
2569
- inst.def = def;
2570
- inst.type = def.type;
2571
- Object.defineProperty(inst, "_def", { value: def });
2572
- inst.check = (...checks) => {
2573
- return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
2574
- check: ch,
2575
- def: { check: "custom" },
2576
- onattach: []
2577
- } } : ch)] }));
2578
- };
2579
- inst.clone = (def$1, params) => clone(inst, def$1, params);
2580
- inst.brand = () => inst;
2581
- inst.register = ((reg, meta$2) => {
2582
- reg.add(inst, meta$2);
2583
- return inst;
2584
- });
2585
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
2586
- inst.safeParse = (data, params) => safeParse(inst, data, params);
2587
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
2588
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
2589
- inst.spa = inst.safeParseAsync;
2590
- inst.encode = (data, params) => encode(inst, data, params);
2591
- inst.decode = (data, params) => decode(inst, data, params);
2592
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
2593
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
2594
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
2595
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
2596
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
2597
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
2598
- inst.refine = (check, params) => inst.check(refine(check, params));
2599
- inst.superRefine = (refinement) => inst.check(superRefine(refinement));
2600
- inst.overwrite = (fn) => inst.check(_overwrite(fn));
2601
- inst.optional = () => optional(inst);
2602
- inst.nullable = () => nullable(inst);
2603
- inst.nullish = () => optional(nullable(inst));
2604
- inst.nonoptional = (params) => nonoptional(inst, params);
2605
- inst.array = () => array(inst);
2606
- inst.or = (arg) => union([inst, arg]);
2607
- inst.and = (arg) => intersection(inst, arg);
2608
- inst.transform = (tx) => pipe(inst, transform(tx));
2609
- inst.default = (def$1) => _default(inst, def$1);
2610
- inst.prefault = (def$1) => prefault(inst, def$1);
2611
- inst.catch = (params) => _catch(inst, params);
2612
- inst.pipe = (target) => pipe(inst, target);
2613
- inst.readonly = () => readonly(inst);
2614
- inst.describe = (description) => {
2615
- const cl = inst.clone();
2616
- globalRegistry.add(cl, { description });
2617
- return cl;
2618
- };
2619
- Object.defineProperty(inst, "description", {
2620
- get() {
2621
- return globalRegistry.get(inst)?.description;
2622
- },
2623
- configurable: true
2624
- });
2625
- inst.meta = (...args) => {
2626
- if (args.length === 0) return globalRegistry.get(inst);
2627
- const cl = inst.clone();
2628
- globalRegistry.add(cl, args[0]);
2629
- return cl;
2630
- };
2631
- inst.isOptional = () => inst.safeParse(void 0).success;
2632
- inst.isNullable = () => inst.safeParse(null).success;
2633
- return inst;
2634
- });
2635
- /** @internal */
2636
- const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
2637
- $ZodString.init(inst, def);
2638
- ZodType.init(inst, def);
2639
- const bag = inst._zod.bag;
2640
- inst.format = bag.format ?? null;
2641
- inst.minLength = bag.minimum ?? null;
2642
- inst.maxLength = bag.maximum ?? null;
2643
- inst.regex = (...args) => inst.check(_regex(...args));
2644
- inst.includes = (...args) => inst.check(_includes(...args));
2645
- inst.startsWith = (...args) => inst.check(_startsWith(...args));
2646
- inst.endsWith = (...args) => inst.check(_endsWith(...args));
2647
- inst.min = (...args) => inst.check(_minLength(...args));
2648
- inst.max = (...args) => inst.check(_maxLength(...args));
2649
- inst.length = (...args) => inst.check(_length(...args));
2650
- inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
2651
- inst.lowercase = (params) => inst.check(_lowercase(params));
2652
- inst.uppercase = (params) => inst.check(_uppercase(params));
2653
- inst.trim = () => inst.check(_trim());
2654
- inst.normalize = (...args) => inst.check(_normalize(...args));
2655
- inst.toLowerCase = () => inst.check(_toLowerCase());
2656
- inst.toUpperCase = () => inst.check(_toUpperCase());
2657
- inst.slugify = () => inst.check(_slugify());
2658
- });
2659
- const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
2660
- $ZodString.init(inst, def);
2661
- _ZodString.init(inst, def);
2662
- inst.email = (params) => inst.check(_email(ZodEmail, params));
2663
- inst.url = (params) => inst.check(_url(ZodURL, params));
2664
- inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
2665
- inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
2666
- inst.guid = (params) => inst.check(_guid(ZodGUID, params));
2667
- inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
2668
- inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
2669
- inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
2670
- inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
2671
- inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
2672
- inst.guid = (params) => inst.check(_guid(ZodGUID, params));
2673
- inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
2674
- inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
2675
- inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
2676
- inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
2677
- inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
2678
- inst.xid = (params) => inst.check(_xid(ZodXID, params));
2679
- inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
2680
- inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
2681
- inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
2682
- inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
2683
- inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
2684
- inst.e164 = (params) => inst.check(_e164(ZodE164, params));
2685
- inst.datetime = (params) => inst.check(datetime(params));
2686
- inst.date = (params) => inst.check(date(params));
2687
- inst.time = (params) => inst.check(time(params));
2688
- inst.duration = (params) => inst.check(duration(params));
2689
- });
2690
- function string(params) {
2691
- return _string(ZodString, params);
2692
- }
2693
- const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
2694
- $ZodStringFormat.init(inst, def);
2695
- _ZodString.init(inst, def);
2696
- });
2697
- const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
2698
- $ZodEmail.init(inst, def);
2699
- ZodStringFormat.init(inst, def);
2700
- });
2701
- const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
2702
- $ZodGUID.init(inst, def);
2703
- ZodStringFormat.init(inst, def);
2704
- });
2705
- const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
2706
- $ZodUUID.init(inst, def);
2707
- ZodStringFormat.init(inst, def);
2708
- });
2709
- const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
2710
- $ZodURL.init(inst, def);
2711
- ZodStringFormat.init(inst, def);
2712
- });
2713
- const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
2714
- $ZodEmoji.init(inst, def);
2715
- ZodStringFormat.init(inst, def);
2716
- });
2717
- const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
2718
- $ZodNanoID.init(inst, def);
2719
- ZodStringFormat.init(inst, def);
2720
- });
2721
- const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
2722
- $ZodCUID.init(inst, def);
2723
- ZodStringFormat.init(inst, def);
2724
- });
2725
- const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
2726
- $ZodCUID2.init(inst, def);
2727
- ZodStringFormat.init(inst, def);
2728
- });
2729
- const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
2730
- $ZodULID.init(inst, def);
2731
- ZodStringFormat.init(inst, def);
2732
- });
2733
- const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
2734
- $ZodXID.init(inst, def);
2735
- ZodStringFormat.init(inst, def);
2736
- });
2737
- const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
2738
- $ZodKSUID.init(inst, def);
2739
- ZodStringFormat.init(inst, def);
2740
- });
2741
- const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
2742
- $ZodIPv4.init(inst, def);
2743
- ZodStringFormat.init(inst, def);
2744
- });
2745
- const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
2746
- $ZodIPv6.init(inst, def);
2747
- ZodStringFormat.init(inst, def);
2748
- });
2749
- const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
2750
- $ZodCIDRv4.init(inst, def);
2751
- ZodStringFormat.init(inst, def);
2752
- });
2753
- const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
2754
- $ZodCIDRv6.init(inst, def);
2755
- ZodStringFormat.init(inst, def);
2756
- });
2757
- const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
2758
- $ZodBase64.init(inst, def);
2759
- ZodStringFormat.init(inst, def);
2760
- });
2761
- const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
2762
- $ZodBase64URL.init(inst, def);
2763
- ZodStringFormat.init(inst, def);
2764
- });
2765
- const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
2766
- $ZodE164.init(inst, def);
2767
- ZodStringFormat.init(inst, def);
2768
- });
2769
- const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
2770
- $ZodJWT.init(inst, def);
2771
- ZodStringFormat.init(inst, def);
2772
- });
2773
- const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
2774
- $ZodNumber.init(inst, def);
2775
- ZodType.init(inst, def);
2776
- inst.gt = (value, params) => inst.check(_gt(value, params));
2777
- inst.gte = (value, params) => inst.check(_gte(value, params));
2778
- inst.min = (value, params) => inst.check(_gte(value, params));
2779
- inst.lt = (value, params) => inst.check(_lt(value, params));
2780
- inst.lte = (value, params) => inst.check(_lte(value, params));
2781
- inst.max = (value, params) => inst.check(_lte(value, params));
2782
- inst.int = (params) => inst.check(int(params));
2783
- inst.safe = (params) => inst.check(int(params));
2784
- inst.positive = (params) => inst.check(_gt(0, params));
2785
- inst.nonnegative = (params) => inst.check(_gte(0, params));
2786
- inst.negative = (params) => inst.check(_lt(0, params));
2787
- inst.nonpositive = (params) => inst.check(_lte(0, params));
2788
- inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
2789
- inst.step = (value, params) => inst.check(_multipleOf(value, params));
2790
- inst.finite = () => inst;
2791
- const bag = inst._zod.bag;
2792
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
2793
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
2794
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
2795
- inst.isFinite = true;
2796
- inst.format = bag.format ?? null;
2797
- });
2798
- function number(params) {
2799
- return _number(ZodNumber, params);
2800
- }
2801
- const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
2802
- $ZodNumberFormat.init(inst, def);
2803
- ZodNumber.init(inst, def);
2804
- });
2805
- function int(params) {
2806
- return _int(ZodNumberFormat, params);
2807
- }
2808
- const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2809
- $ZodUnknown.init(inst, def);
2810
- ZodType.init(inst, def);
2811
- });
2812
- function unknown() {
2813
- return _unknown(ZodUnknown);
2814
- }
2815
- const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
2816
- $ZodNever.init(inst, def);
2817
- ZodType.init(inst, def);
2818
- });
2819
- function never(params) {
2820
- return _never(ZodNever, params);
2821
- }
2822
- const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2823
- $ZodArray.init(inst, def);
2824
- ZodType.init(inst, def);
2825
- inst.element = def.element;
2826
- inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
2827
- inst.nonempty = (params) => inst.check(_minLength(1, params));
2828
- inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
2829
- inst.length = (len, params) => inst.check(_length(len, params));
2830
- inst.unwrap = () => inst.element;
2831
- });
2832
- function array(element, params) {
2833
- return _array(ZodArray, element, params);
2834
- }
2835
- const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
2836
- $ZodObjectJIT.init(inst, def);
2837
- ZodType.init(inst, def);
2838
- defineLazy(inst, "shape", () => {
2839
- return def.shape;
2840
- });
2841
- inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
2842
- inst.catchall = (catchall) => inst.clone({
2843
- ...inst._zod.def,
2844
- catchall
2845
- });
2846
- inst.passthrough = () => inst.clone({
2847
- ...inst._zod.def,
2848
- catchall: unknown()
2849
- });
2850
- inst.loose = () => inst.clone({
2851
- ...inst._zod.def,
2852
- catchall: unknown()
2853
- });
2854
- inst.strict = () => inst.clone({
2855
- ...inst._zod.def,
2856
- catchall: never()
2857
- });
2858
- inst.strip = () => inst.clone({
2859
- ...inst._zod.def,
2860
- catchall: void 0
2861
- });
2862
- inst.extend = (incoming) => {
2863
- return extend(inst, incoming);
2864
- };
2865
- inst.safeExtend = (incoming) => {
2866
- return safeExtend(inst, incoming);
2867
- };
2868
- inst.merge = (other) => merge(inst, other);
2869
- inst.pick = (mask) => pick(inst, mask);
2870
- inst.omit = (mask) => omit(inst, mask);
2871
- inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
2872
- inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
2873
- });
2874
- function object(shape, params) {
2875
- return new ZodObject({
2876
- type: "object",
2877
- shape: shape ?? {},
2878
- ...normalizeParams(params)
2879
- });
2880
- }
2881
- const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
2882
- $ZodUnion.init(inst, def);
2883
- ZodType.init(inst, def);
2884
- inst.options = def.options;
2885
- });
2886
- function union(options, params) {
2887
- return new ZodUnion({
2888
- type: "union",
2889
- options,
2890
- ...normalizeParams(params)
2891
- });
2892
- }
2893
- const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
2894
- $ZodIntersection.init(inst, def);
2895
- ZodType.init(inst, def);
2896
- });
2897
- function intersection(left, right) {
2898
- return new ZodIntersection({
2899
- type: "intersection",
2900
- left,
2901
- right
2902
- });
2903
- }
2904
- const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
2905
- $ZodEnum.init(inst, def);
2906
- ZodType.init(inst, def);
2907
- inst.enum = def.entries;
2908
- inst.options = Object.values(def.entries);
2909
- const keys = new Set(Object.keys(def.entries));
2910
- inst.extract = (values, params) => {
2911
- const newEntries = {};
2912
- for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
2913
- else throw new Error(`Key ${value} not found in enum`);
2914
- return new ZodEnum({
2915
- ...def,
2916
- checks: [],
2917
- ...normalizeParams(params),
2918
- entries: newEntries
2919
- });
2920
- };
2921
- inst.exclude = (values, params) => {
2922
- const newEntries = { ...def.entries };
2923
- for (const value of values) if (keys.has(value)) delete newEntries[value];
2924
- else throw new Error(`Key ${value} not found in enum`);
2925
- return new ZodEnum({
2926
- ...def,
2927
- checks: [],
2928
- ...normalizeParams(params),
2929
- entries: newEntries
2930
- });
2931
- };
2932
- });
2933
- function _enum(values, params) {
2934
- return new ZodEnum({
2935
- type: "enum",
2936
- entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
2937
- ...normalizeParams(params)
2938
- });
2939
- }
2940
- const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
2941
- $ZodLiteral.init(inst, def);
2942
- ZodType.init(inst, def);
2943
- inst.values = new Set(def.values);
2944
- Object.defineProperty(inst, "value", { get() {
2945
- if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
2946
- return def.values[0];
2947
- } });
2948
- });
2949
- function literal(value, params) {
2950
- return new ZodLiteral({
2951
- type: "literal",
2952
- values: Array.isArray(value) ? value : [value],
2953
- ...normalizeParams(params)
2954
- });
2955
- }
2956
- const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
2957
- $ZodTransform.init(inst, def);
2958
- ZodType.init(inst, def);
2959
- inst._zod.parse = (payload, _ctx) => {
2960
- if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2961
- payload.addIssue = (issue$1) => {
2962
- if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
2963
- else {
2964
- const _issue = issue$1;
2965
- if (_issue.fatal) _issue.continue = false;
2966
- _issue.code ?? (_issue.code = "custom");
2967
- _issue.input ?? (_issue.input = payload.value);
2968
- _issue.inst ?? (_issue.inst = inst);
2969
- payload.issues.push(issue(_issue));
2970
- }
2971
- };
2972
- const output = def.transform(payload.value, payload);
2973
- if (output instanceof Promise) return output.then((output$1) => {
2974
- payload.value = output$1;
2975
- return payload;
2976
- });
2977
- payload.value = output;
2978
- return payload;
2979
- };
2980
- });
2981
- function transform(fn) {
2982
- return new ZodTransform({
2983
- type: "transform",
2984
- transform: fn
2985
- });
2986
- }
2987
- const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
2988
- $ZodOptional.init(inst, def);
2989
- ZodType.init(inst, def);
2990
- inst.unwrap = () => inst._zod.def.innerType;
2991
- });
2992
- function optional(innerType) {
2993
- return new ZodOptional({
2994
- type: "optional",
2995
- innerType
2996
- });
2997
- }
2998
- const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
2999
- $ZodNullable.init(inst, def);
3000
- ZodType.init(inst, def);
3001
- inst.unwrap = () => inst._zod.def.innerType;
3002
- });
3003
- function nullable(innerType) {
3004
- return new ZodNullable({
3005
- type: "nullable",
3006
- innerType
3007
- });
3008
- }
3009
- const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
3010
- $ZodDefault.init(inst, def);
3011
- ZodType.init(inst, def);
3012
- inst.unwrap = () => inst._zod.def.innerType;
3013
- inst.removeDefault = inst.unwrap;
3014
- });
3015
- function _default(innerType, defaultValue) {
3016
- return new ZodDefault({
3017
- type: "default",
3018
- innerType,
3019
- get defaultValue() {
3020
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3021
- }
3022
- });
3023
- }
3024
- const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
3025
- $ZodPrefault.init(inst, def);
3026
- ZodType.init(inst, def);
3027
- inst.unwrap = () => inst._zod.def.innerType;
3028
- });
3029
- function prefault(innerType, defaultValue) {
3030
- return new ZodPrefault({
3031
- type: "prefault",
3032
- innerType,
3033
- get defaultValue() {
3034
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3035
- }
3036
- });
3037
- }
3038
- const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
3039
- $ZodNonOptional.init(inst, def);
3040
- ZodType.init(inst, def);
3041
- inst.unwrap = () => inst._zod.def.innerType;
3042
- });
3043
- function nonoptional(innerType, params) {
3044
- return new ZodNonOptional({
3045
- type: "nonoptional",
3046
- innerType,
3047
- ...normalizeParams(params)
3048
- });
3049
- }
3050
- const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
3051
- $ZodCatch.init(inst, def);
3052
- ZodType.init(inst, def);
3053
- inst.unwrap = () => inst._zod.def.innerType;
3054
- inst.removeCatch = inst.unwrap;
3055
- });
3056
- function _catch(innerType, catchValue) {
3057
- return new ZodCatch({
3058
- type: "catch",
3059
- innerType,
3060
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
3061
- });
3062
- }
3063
- const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
3064
- $ZodPipe.init(inst, def);
3065
- ZodType.init(inst, def);
3066
- inst.in = def.in;
3067
- inst.out = def.out;
3068
- });
3069
- function pipe(in_, out) {
3070
- return new ZodPipe({
3071
- type: "pipe",
3072
- in: in_,
3073
- out
3074
- });
3075
- }
3076
- const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
3077
- $ZodReadonly.init(inst, def);
3078
- ZodType.init(inst, def);
3079
- inst.unwrap = () => inst._zod.def.innerType;
3080
- });
3081
- function readonly(innerType) {
3082
- return new ZodReadonly({
3083
- type: "readonly",
3084
- innerType
3085
- });
3086
- }
3087
- const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
3088
- $ZodCustom.init(inst, def);
3089
- ZodType.init(inst, def);
3090
- });
3091
- function refine(fn, _params = {}) {
3092
- return _refine(ZodCustom, fn, _params);
3093
- }
3094
- function superRefine(fn) {
3095
- return _superRefine(fn);
3096
- }
3097
- const describe = describe$1;
3098
- const meta = meta$1;
3099
-
3100
- //#endregion
3101
- //#region src/convert-to-inkeep-messages.ts
3102
- function convertToInkeepChatMessages(prompt) {
3103
- const messages = [];
3104
- for (const { role, content } of prompt) switch (role) {
3105
- case "system":
3106
- messages.push({
3107
- role: "system",
3108
- content
3109
- });
3110
- break;
3111
- case "user": {
3112
- const contentParts = [];
3113
- for (const part of content) switch (part.type) {
3114
- case "text":
3115
- contentParts.push({
3116
- type: "text",
3117
- text: part.text
3118
- });
3119
- break;
3120
- case "file": throw new Error("File content is not yet supported by Inkeep provider");
3121
- default: {
3122
- const _exhaustiveCheck = part;
3123
- throw new Error(`Unsupported content part type: ${_exhaustiveCheck}`);
3124
- }
3125
- }
3126
- messages.push({
3127
- role: "user",
3128
- content: contentParts.length === 1 ? contentParts[0].text ?? "" : contentParts
3129
- });
3130
- break;
3131
- }
3132
- case "assistant": {
3133
- let text = "";
3134
- const toolCalls = [];
3135
- for (const part of content) switch (part.type) {
3136
- case "text":
3137
- text += part.text;
3138
- break;
3139
- case "tool-call":
3140
- toolCalls.push({
3141
- id: part.toolCallId,
3142
- type: "function",
3143
- function: {
3144
- name: part.toolName,
3145
- arguments: JSON.stringify(part.input)
3146
- }
3147
- });
3148
- break;
3149
- case "file": throw new Error("File content is not yet supported by Inkeep provider");
3150
- case "reasoning":
3151
- text += part.text;
3152
- break;
3153
- case "tool-result": throw new Error("Tool result content should not appear in assistant messages");
3154
- default: {
3155
- const _exhaustiveCheck = part;
3156
- throw new Error(`Unsupported content part type: ${_exhaustiveCheck}`);
3157
- }
3158
- }
3159
- messages.push({
3160
- role: "assistant",
3161
- content: text || ""
3162
- });
3163
- break;
3164
- }
3165
- case "tool":
3166
- for (const toolResponse of content) messages.push({
3167
- role: "tool",
3168
- content: JSON.stringify(toolResponse.output),
3169
- name: toolResponse.toolName
3170
- });
3171
- break;
3172
- default: {
3173
- const _exhaustiveCheck = role;
3174
- throw new Error(`Unsupported message role: ${_exhaustiveCheck}`);
3175
- }
3176
- }
3177
- return messages;
3178
- }
3179
-
3180
- //#endregion
3181
- //#region src/get-response-metadata.ts
3182
- function getResponseMetadata(response) {
3183
- return {
3184
- id: response.id,
3185
- modelId: response.model,
3186
- timestamp: /* @__PURE__ */ new Date(response.created * 1e3)
3187
- };
3188
- }
3189
-
3190
- //#endregion
3191
- //#region src/inkeep-error.ts
3192
- const inkeepErrorDataSchema = object({
3193
- error: string(),
3194
- message: string().optional(),
3195
- details: array(object({
3196
- field: string(),
3197
- message: string(),
3198
- value: unknown().optional()
3199
- })).optional()
3200
- });
3201
- const inkeepFailedResponseHandler = createJsonErrorResponseHandler({
3202
- errorSchema: inkeepErrorDataSchema,
3203
- errorToMessage: (data) => data.message || data.error
3204
- });
3205
-
3206
- //#endregion
3207
- //#region src/map-inkeep-finish-reason.ts
3208
- function mapInkeepFinishReason(finishReason) {
3209
- switch (finishReason) {
3210
- case "stop": return "stop";
3211
- case "length": return "length";
3212
- case "tool_calls": return "tool-calls";
3213
- case "content_filter": return "content-filter";
3214
- case null: return "unknown";
3215
- default: return "unknown";
3216
- }
3217
- }
3218
-
3219
- //#endregion
3220
- //#region src/inkeep-chat-language-model.ts
3221
- /**
3222
- * Converts data-operation events to AI SDK tool events (tool-call or tool-result).
3223
- *
3224
- * Handles:
3225
- * - tool_call: Direct tool invocation (tool-call)
3226
- * - tool_result: Direct tool result (tool-result)
3227
- * - transfer: Agent transfers control to another agent (tool-call)
3228
- * - delegation_sent: Agent delegates a task to another agent (tool-call)
3229
- * - delegation_returned: Delegated task completes and returns (tool-result)
3230
- */
3231
- function convertDataOperationToToolEvent(opData) {
3232
- if (!opData || typeof opData !== "object" || !("type" in opData)) return null;
3233
- const eventType = opData.type;
3234
- const data = opData.details?.data;
3235
- if (!data) return null;
3236
- switch (eventType) {
3237
- case "tool_call": return {
3238
- type: "tool-call",
3239
- toolCallId: data.toolCallId,
3240
- toolName: data.toolName,
3241
- input: JSON.stringify(data.input)
3242
- };
3243
- case "tool_result": return {
3244
- type: "tool-result",
3245
- toolCallId: data.toolCallId,
3246
- toolName: data.toolName,
3247
- result: data.output?.result ?? data.output
3248
- };
3249
- case "transfer": {
3250
- const transferData = data;
3251
- return {
3252
- type: "tool-call",
3253
- toolCallId: `transfer_${Date.now()}`,
3254
- toolName: transferData.targetSubAgent,
3255
- input: JSON.stringify({
3256
- fromSubAgent: transferData.fromSubAgent,
3257
- reason: transferData.reason,
3258
- context: transferData.context
3259
- })
3260
- };
3261
- }
3262
- case "delegation_sent": {
3263
- const delegationData = data;
3264
- return {
3265
- type: "tool-call",
3266
- toolCallId: delegationData.delegationId,
3267
- toolName: delegationData.targetSubAgent,
3268
- input: JSON.stringify({
3269
- fromSubAgent: delegationData.fromSubAgent,
3270
- taskDescription: delegationData.taskDescription,
3271
- context: delegationData.context
3272
- })
3273
- };
3274
- }
3275
- case "delegation_returned": {
3276
- const returnedData = data;
3277
- return {
3278
- type: "tool-result",
3279
- toolCallId: returnedData.delegationId,
3280
- toolName: returnedData.targetSubAgent,
3281
- result: returnedData.result
3282
- };
3283
- }
3284
- default: return null;
3285
- }
3286
- }
3287
- var InkeepChatLanguageModel = class {
3288
- specificationVersion = "v2";
3289
- defaultObjectGenerationMode = void 0;
3290
- supportsImageUrls = false;
3291
- supportedUrls = {};
3292
- modelId;
3293
- options;
3294
- config;
3295
- get provider() {
3296
- return this.config.provider;
3297
- }
3298
- constructor(options, config$1) {
3299
- this.modelId = "inkeep-agent";
3300
- this.options = options;
3301
- this.config = config$1;
3302
- }
3303
- getArgs(options) {
3304
- return {
3305
- args: {
3306
- messages: convertToInkeepChatMessages(options.prompt),
3307
- conversationId: this.options.conversationId,
3308
- headers: this.options.headers,
3309
- runConfig: this.options.runConfig
3310
- },
3311
- warnings: []
3312
- };
3313
- }
3314
- async doGenerate(options) {
3315
- const { args, warnings } = this.getArgs(options);
3316
- const response = await postJsonToApi({
3317
- url: `${this.config.baseURL}/api/chat`,
3318
- headers: this.config.headers(),
3319
- body: {
3320
- ...args,
3321
- stream: false
3322
- },
3323
- failedResponseHandler: inkeepFailedResponseHandler,
3324
- successfulResponseHandler: createJsonResponseHandler(inkeepChatCompletionSchema),
3325
- abortSignal: options.abortSignal,
3326
- fetch: this.config.fetch
3327
- });
3328
- const { value: completion } = response;
3329
- const choice = completion.choices[0];
3330
- const content = [];
3331
- if (choice.message.content) content.push({
3332
- type: "text",
3333
- text: choice.message.content
3334
- });
3335
- return {
3336
- content,
3337
- finishReason: mapInkeepFinishReason(choice.finish_reason),
3338
- usage: {
3339
- promptTokens: completion.usage?.prompt_tokens ?? 0,
3340
- completionTokens: completion.usage?.completion_tokens ?? 0,
3341
- inputTokens: completion.usage?.prompt_tokens ?? 0,
3342
- outputTokens: completion.usage?.completion_tokens ?? 0,
3343
- totalTokens: completion.usage?.total_tokens ?? 0
3344
- },
3345
- rawCall: {
3346
- rawPrompt: args.messages,
3347
- rawSettings: args
3348
- },
3349
- rawResponse: { headers: response.responseHeaders },
3350
- response: getResponseMetadata(completion),
3351
- warnings
3352
- };
3353
- }
3354
- async doStream(options) {
3355
- const { args, warnings } = this.getArgs(options);
3356
- const response = await postJsonToApi({
3357
- url: `${this.config.baseURL}/api/chat`,
3358
- headers: this.config.headers(),
3359
- body: {
3360
- ...args,
3361
- stream: true
3362
- },
3363
- failedResponseHandler: inkeepFailedResponseHandler,
3364
- successfulResponseHandler: createEventSourceResponseHandler(StreamEventSchema),
3365
- abortSignal: options.abortSignal,
3366
- fetch: this.config.fetch
3367
- });
3368
- const { value: stream } = response;
3369
- let finishReason = "unknown";
3370
- let usage = {
3371
- promptTokens: 0,
3372
- completionTokens: 0,
3373
- inputTokens: 0,
3374
- outputTokens: 0,
3375
- totalTokens: 0
3376
- };
3377
- return {
3378
- stream: stream.pipeThrough(new TransformStream({
3379
- start(controller) {
3380
- controller.enqueue({
3381
- type: "stream-start",
3382
- warnings
3383
- });
3384
- },
3385
- transform(chunk, controller) {
3386
- if (!chunk.success) {
3387
- controller.enqueue({
3388
- type: "error",
3389
- error: chunk.error
3390
- });
3391
- return;
3392
- }
3393
- const event = chunk.value;
3394
- switch (event.type) {
3395
- case "text-start":
3396
- controller.enqueue({
3397
- type: "text-start",
3398
- id: event.id
3399
- });
3400
- break;
3401
- case "text-delta":
3402
- controller.enqueue({
3403
- type: "text-delta",
3404
- id: event.id,
3405
- delta: event.delta
3406
- });
3407
- break;
3408
- case "text-end":
3409
- controller.enqueue({
3410
- type: "text-end",
3411
- id: event.id
3412
- });
3413
- break;
3414
- case "data-component":
3415
- case "data-summary": break;
3416
- case "data-operation": {
3417
- const toolEvent = convertDataOperationToToolEvent(event.data);
3418
- if (toolEvent) controller.enqueue(toolEvent);
3419
- break;
3420
- }
3421
- case "error":
3422
- controller.enqueue({
3423
- type: "error",
3424
- error: new Error(event.error)
3425
- });
3426
- break;
3427
- case "finish":
3428
- if (event.finishReason) finishReason = mapInkeepFinishReason(event.finishReason);
3429
- if (event.usage) usage = {
3430
- promptTokens: event.usage.promptTokens ?? 0,
3431
- completionTokens: event.usage.completionTokens ?? 0,
3432
- inputTokens: event.usage.promptTokens ?? 0,
3433
- outputTokens: event.usage.completionTokens ?? 0,
3434
- totalTokens: event.usage.totalTokens ?? 0
3435
- };
3436
- break;
3437
- default:
3438
- console.warn("Unhandled stream event type");
3439
- break;
3440
- }
3441
- },
3442
- flush(controller) {
3443
- controller.enqueue({
3444
- type: "finish",
3445
- finishReason,
3446
- usage
3447
- });
3448
- }
3449
- })),
3450
- rawCall: {
3451
- rawPrompt: args.messages,
3452
- rawSettings: args
3453
- },
3454
- rawResponse: { headers: response.responseHeaders },
3455
- warnings
3456
- };
3457
- }
3458
- };
3459
- const inkeepChatCompletionSchema = object({
3460
- id: string(),
3461
- object: literal("chat.completion"),
3462
- created: number(),
3463
- model: string().optional(),
3464
- choices: array(object({
3465
- index: number(),
3466
- message: object({
3467
- role: literal("assistant"),
3468
- content: string()
3469
- }),
3470
- finish_reason: string()
3471
- })),
3472
- usage: object({
3473
- prompt_tokens: number().optional(),
3474
- completion_tokens: number().optional(),
3475
- total_tokens: number().optional()
3476
- }).optional()
3477
- });
3478
-
3479
- //#endregion
3480
- //#region src/inkeep-provider.ts
3481
- function createInkeep(options = {}) {
3482
- const getBaseURL = () => {
3483
- return withoutTrailingSlash(loadSetting({
3484
- settingValue: options.baseURL,
3485
- environmentVariableName: "INKEEP_AGENTS_RUN_API_URL",
3486
- settingName: "baseURL",
3487
- description: "Inkeep Agents API base URL"
3488
- }));
3489
- };
3490
- const getHeaders = () => {
3491
- const apiKey = options.apiKey;
3492
- return {
3493
- Authorization: apiKey ? `Bearer ${apiKey}` : void 0,
3494
- ...options.headers
3495
- };
3496
- };
3497
- const createChatModel = (chatOptions) => new InkeepChatLanguageModel(chatOptions ?? {}, {
3498
- provider: "inkeep",
3499
- baseURL: getBaseURL(),
3500
- headers: getHeaders,
3501
- fetch: options.fetch
3502
- });
3503
- const provider = (chatOptions) => createChatModel(chatOptions);
3504
- provider.languageModel = createChatModel;
3505
- return provider;
3506
- }
3507
- const inkeep = createInkeep();
3508
-
3509
- //#endregion
3510
- export { InkeepChatLanguageModel, createInkeep, inkeep };
3511
- //# sourceMappingURL=index.js.map
4
+ export { InkeepChatLanguageModel, createInkeep, inkeep };