@mastra/schema-compat 0.0.0-ai-v5-20250625173645

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,670 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+ var ai = require('ai');
5
+ var zodFromJsonSchema = require('zod-from-json-schema');
6
+ var zodToJsonSchema = require('zod-to-json-schema');
7
+
8
+ // src/schema-compatibility.ts
9
+ function convertZodSchemaToAISDKSchema(zodSchema, target = "jsonSchema7") {
10
+ return ai.jsonSchema(
11
+ zodToJsonSchema.zodToJsonSchema(zodSchema, {
12
+ $refStrategy: "none",
13
+ target
14
+ }),
15
+ {
16
+ validate: (value) => {
17
+ const result = zodSchema.safeParse(value);
18
+ return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
19
+ }
20
+ }
21
+ );
22
+ }
23
+ function isZodType(value) {
24
+ return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
25
+ }
26
+ function convertSchemaToZod(schema) {
27
+ if (isZodType(schema)) {
28
+ return schema;
29
+ } else {
30
+ const jsonSchemaToConvert = "jsonSchema" in schema ? schema.jsonSchema : schema;
31
+ try {
32
+ return zodFromJsonSchema.convertJsonSchemaToZod(jsonSchemaToConvert);
33
+ } catch (e) {
34
+ const errorMessage = `[Schema Builder] Failed to convert schema parameters to Zod. Original schema: ${JSON.stringify(jsonSchemaToConvert)}`;
35
+ console.error(errorMessage, e);
36
+ throw new Error(errorMessage + (e instanceof Error ? `
37
+ ${e.stack}` : "\nUnknown error object"));
38
+ }
39
+ }
40
+ }
41
+ function applyCompatLayer({
42
+ schema,
43
+ compatLayers,
44
+ mode
45
+ }) {
46
+ let zodSchema;
47
+ if (!isZodType(schema)) {
48
+ zodSchema = convertSchemaToZod(schema);
49
+ } else {
50
+ zodSchema = schema;
51
+ }
52
+ for (const compat of compatLayers) {
53
+ if (compat.shouldApply()) {
54
+ return mode === "jsonSchema" ? compat.processToJSONSchema(zodSchema) : compat.processToAISDKSchema(zodSchema);
55
+ }
56
+ }
57
+ if (mode === "jsonSchema") {
58
+ return zodToJsonSchema.zodToJsonSchema(zodSchema, { $refStrategy: "none", target: "jsonSchema7" });
59
+ } else {
60
+ return convertZodSchemaToAISDKSchema(zodSchema);
61
+ }
62
+ }
63
+
64
+ // src/schema-compatibility.ts
65
+ var ALL_STRING_CHECKS = ["regex", "emoji", "email", "url", "uuid", "cuid", "min", "max"];
66
+ var ALL_NUMBER_CHECKS = [
67
+ "min",
68
+ // gte internally
69
+ "max",
70
+ // lte internally
71
+ "multipleOf"
72
+ ];
73
+ var ALL_ARRAY_CHECKS = ["min", "max", "length"];
74
+ var isOptional = (v) => v instanceof zod.ZodOptional;
75
+ var isObj = (v) => v instanceof zod.ZodObject;
76
+ var isArr = (v) => v instanceof zod.ZodArray;
77
+ var isUnion = (v) => v instanceof zod.ZodUnion;
78
+ var isString = (v) => v instanceof zod.ZodString;
79
+ var isNumber = (v) => v instanceof zod.ZodNumber;
80
+ var isDate = (v) => v instanceof zod.ZodDate;
81
+ var isDefault = (v) => v instanceof zod.ZodDefault;
82
+ var UNSUPPORTED_ZOD_TYPES = ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
83
+ var SUPPORTED_ZOD_TYPES = [
84
+ "ZodObject",
85
+ "ZodArray",
86
+ "ZodUnion",
87
+ "ZodString",
88
+ "ZodNumber",
89
+ "ZodDate",
90
+ "ZodAny",
91
+ "ZodDefault"
92
+ ];
93
+ var ALL_ZOD_TYPES = [...SUPPORTED_ZOD_TYPES, ...UNSUPPORTED_ZOD_TYPES];
94
+ var SchemaCompatLayer = class {
95
+ model;
96
+ /**
97
+ * Creates a new schema compatibility instance.
98
+ *
99
+ * @param model - The language model this compatibility layer applies to
100
+ */
101
+ constructor(model) {
102
+ this.model = model;
103
+ }
104
+ /**
105
+ * Gets the language model associated with this compatibility layer.
106
+ *
107
+ * @returns The language model instance
108
+ */
109
+ getModel() {
110
+ return this.model;
111
+ }
112
+ /**
113
+ * Default handler for Zod object types. Recursively processes all properties in the object.
114
+ *
115
+ * @param value - The Zod object to process
116
+ * @returns The processed Zod object
117
+ */
118
+ defaultZodObjectHandler(value) {
119
+ const processedShape = Object.entries(value.shape).reduce((acc, [key, propValue]) => {
120
+ acc[key] = this.processZodType(propValue);
121
+ return acc;
122
+ }, {});
123
+ let result = zod.z.object(processedShape);
124
+ if (value._def.unknownKeys === "strict") {
125
+ result = result.strict();
126
+ }
127
+ if (value._def.catchall && !(value._def.catchall instanceof zod.z.ZodNever)) {
128
+ result = result.catchall(value._def.catchall);
129
+ }
130
+ if (value.description) {
131
+ result = result.describe(value.description);
132
+ }
133
+ return result;
134
+ }
135
+ /**
136
+ * Merges validation constraints into a parameter description.
137
+ *
138
+ * This helper method converts validation constraints that may not be supported
139
+ * by a provider into human-readable descriptions.
140
+ *
141
+ * @param description - The existing parameter description
142
+ * @param constraints - The validation constraints to merge
143
+ * @returns The updated description with constraints, or undefined if no constraints
144
+ */
145
+ mergeParameterDescription(description, constraints) {
146
+ if (Object.keys(constraints).length > 0) {
147
+ return (description ? description + "\n" : "") + JSON.stringify(constraints);
148
+ } else {
149
+ return description;
150
+ }
151
+ }
152
+ /**
153
+ * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
154
+ *
155
+ * @param value - The Zod type to check
156
+ * @param throwOnTypes - Array of type names to throw errors for
157
+ * @returns The original value if not in the throw list
158
+ * @throws Error if the type is in the unsupported list
159
+ */
160
+ defaultUnsupportedZodTypeHandler(value, throwOnTypes = UNSUPPORTED_ZOD_TYPES) {
161
+ if (throwOnTypes.includes(value._def.typeName)) {
162
+ throw new Error(`${this.model.modelId} does not support zod type: ${value._def.typeName}`);
163
+ }
164
+ return value;
165
+ }
166
+ /**
167
+ * Default handler for Zod array types. Processes array constraints according to provider support.
168
+ *
169
+ * @param value - The Zod array to process
170
+ * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
171
+ * @returns The processed Zod array
172
+ */
173
+ defaultZodArrayHandler(value, handleChecks = ALL_ARRAY_CHECKS) {
174
+ const zodArrayDef = value._def;
175
+ const processedType = this.processZodType(zodArrayDef.type);
176
+ let result = zod.z.array(processedType);
177
+ const constraints = {};
178
+ if (zodArrayDef.minLength?.value !== void 0) {
179
+ if (handleChecks.includes("min")) {
180
+ constraints.minLength = zodArrayDef.minLength.value;
181
+ } else {
182
+ result = result.min(zodArrayDef.minLength.value);
183
+ }
184
+ }
185
+ if (zodArrayDef.maxLength?.value !== void 0) {
186
+ if (handleChecks.includes("max")) {
187
+ constraints.maxLength = zodArrayDef.maxLength.value;
188
+ } else {
189
+ result = result.max(zodArrayDef.maxLength.value);
190
+ }
191
+ }
192
+ if (zodArrayDef.exactLength?.value !== void 0) {
193
+ if (handleChecks.includes("length")) {
194
+ constraints.exactLength = zodArrayDef.exactLength.value;
195
+ } else {
196
+ result = result.length(zodArrayDef.exactLength.value);
197
+ }
198
+ }
199
+ const description = this.mergeParameterDescription(value.description, constraints);
200
+ if (description) {
201
+ result = result.describe(description);
202
+ }
203
+ return result;
204
+ }
205
+ /**
206
+ * Default handler for Zod union types. Processes all union options.
207
+ *
208
+ * @param value - The Zod union to process
209
+ * @returns The processed Zod union
210
+ * @throws Error if union has fewer than 2 options
211
+ */
212
+ defaultZodUnionHandler(value) {
213
+ const processedOptions = value._def.options.map((option) => this.processZodType(option));
214
+ if (processedOptions.length < 2) throw new Error("Union must have at least 2 options");
215
+ let result = zod.z.union(processedOptions);
216
+ if (value.description) {
217
+ result = result.describe(value.description);
218
+ }
219
+ return result;
220
+ }
221
+ /**
222
+ * Default handler for Zod string types. Processes string validation constraints.
223
+ *
224
+ * @param value - The Zod string to process
225
+ * @param handleChecks - String constraints to convert to descriptions vs keep as validation
226
+ * @returns The processed Zod string
227
+ */
228
+ defaultZodStringHandler(value, handleChecks = ALL_STRING_CHECKS) {
229
+ const constraints = {};
230
+ const checks = value._def.checks || [];
231
+ const newChecks = [];
232
+ for (const check of checks) {
233
+ if ("kind" in check) {
234
+ if (handleChecks.includes(check.kind)) {
235
+ switch (check.kind) {
236
+ case "regex": {
237
+ constraints.regex = {
238
+ pattern: check.regex.source,
239
+ flags: check.regex.flags
240
+ };
241
+ break;
242
+ }
243
+ case "emoji": {
244
+ constraints.emoji = true;
245
+ break;
246
+ }
247
+ case "email": {
248
+ constraints.email = true;
249
+ break;
250
+ }
251
+ case "url": {
252
+ constraints.url = true;
253
+ break;
254
+ }
255
+ case "uuid": {
256
+ constraints.uuid = true;
257
+ break;
258
+ }
259
+ case "cuid": {
260
+ constraints.cuid = true;
261
+ break;
262
+ }
263
+ case "min": {
264
+ constraints.minLength = check.value;
265
+ break;
266
+ }
267
+ case "max": {
268
+ constraints.maxLength = check.value;
269
+ break;
270
+ }
271
+ }
272
+ } else {
273
+ newChecks.push(check);
274
+ }
275
+ }
276
+ }
277
+ let result = zod.z.string();
278
+ for (const check of newChecks) {
279
+ result = result._addCheck(check);
280
+ }
281
+ const description = this.mergeParameterDescription(value.description, constraints);
282
+ if (description) {
283
+ result = result.describe(description);
284
+ }
285
+ return result;
286
+ }
287
+ /**
288
+ * Default handler for Zod number types. Processes number validation constraints.
289
+ *
290
+ * @param value - The Zod number to process
291
+ * @param handleChecks - Number constraints to convert to descriptions vs keep as validation
292
+ * @returns The processed Zod number
293
+ */
294
+ defaultZodNumberHandler(value, handleChecks = ALL_NUMBER_CHECKS) {
295
+ const constraints = {};
296
+ const checks = value._def.checks || [];
297
+ const newChecks = [];
298
+ for (const check of checks) {
299
+ if ("kind" in check) {
300
+ if (handleChecks.includes(check.kind)) {
301
+ switch (check.kind) {
302
+ case "min":
303
+ if (check.inclusive) {
304
+ constraints.gte = check.value;
305
+ } else {
306
+ constraints.gt = check.value;
307
+ }
308
+ break;
309
+ case "max":
310
+ if (check.inclusive) {
311
+ constraints.lte = check.value;
312
+ } else {
313
+ constraints.lt = check.value;
314
+ }
315
+ break;
316
+ case "multipleOf": {
317
+ constraints.multipleOf = check.value;
318
+ break;
319
+ }
320
+ }
321
+ } else {
322
+ newChecks.push(check);
323
+ }
324
+ }
325
+ }
326
+ let result = zod.z.number();
327
+ for (const check of newChecks) {
328
+ switch (check.kind) {
329
+ case "int":
330
+ result = result.int();
331
+ break;
332
+ case "finite":
333
+ result = result.finite();
334
+ break;
335
+ default:
336
+ result = result._addCheck(check);
337
+ }
338
+ }
339
+ const description = this.mergeParameterDescription(value.description, constraints);
340
+ if (description) {
341
+ result = result.describe(description);
342
+ }
343
+ return result;
344
+ }
345
+ /**
346
+ * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
347
+ *
348
+ * @param value - The Zod date to process
349
+ * @returns A Zod string schema representing the date in ISO format
350
+ */
351
+ defaultZodDateHandler(value) {
352
+ const constraints = {};
353
+ const checks = value._def.checks || [];
354
+ for (const check of checks) {
355
+ if ("kind" in check) {
356
+ switch (check.kind) {
357
+ case "min":
358
+ const minDate = new Date(check.value);
359
+ if (!isNaN(minDate.getTime())) {
360
+ constraints.minDate = minDate.toISOString();
361
+ }
362
+ break;
363
+ case "max":
364
+ const maxDate = new Date(check.value);
365
+ if (!isNaN(maxDate.getTime())) {
366
+ constraints.maxDate = maxDate.toISOString();
367
+ }
368
+ break;
369
+ }
370
+ }
371
+ }
372
+ constraints.dateFormat = "date-time";
373
+ let result = zod.z.string().describe("date-time");
374
+ const description = this.mergeParameterDescription(value.description, constraints);
375
+ if (description) {
376
+ result = result.describe(description);
377
+ }
378
+ return result;
379
+ }
380
+ /**
381
+ * Default handler for Zod optional types. Processes the inner type and maintains optionality.
382
+ *
383
+ * @param value - The Zod optional to process
384
+ * @param handleTypes - Types that should be processed vs passed through
385
+ * @returns The processed Zod optional
386
+ */
387
+ defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES) {
388
+ if (handleTypes.includes(value._def.innerType._def.typeName)) {
389
+ return this.processZodType(value._def.innerType).optional();
390
+ } else {
391
+ return value;
392
+ }
393
+ }
394
+ /**
395
+ * Processes a Zod object schema and converts it to an AI SDK Schema.
396
+ *
397
+ * @param zodSchema - The Zod object schema to process
398
+ * @returns An AI SDK Schema with provider-specific compatibility applied
399
+ */
400
+ processToAISDKSchema(zodSchema) {
401
+ const processedSchema = this.processZodType(zodSchema);
402
+ return convertZodSchemaToAISDKSchema(processedSchema, this.getSchemaTarget());
403
+ }
404
+ /**
405
+ * Processes a Zod object schema and converts it to a JSON Schema.
406
+ *
407
+ * @param zodSchema - The Zod object schema to process
408
+ * @returns A JSONSchema7 object with provider-specific compatibility applied
409
+ */
410
+ processToJSONSchema(zodSchema) {
411
+ return this.processToAISDKSchema(zodSchema).jsonSchema;
412
+ }
413
+ };
414
+
415
+ // src/provider-compats/anthropic.ts
416
+ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
417
+ constructor(model) {
418
+ super(model);
419
+ }
420
+ getSchemaTarget() {
421
+ return "jsonSchema7";
422
+ }
423
+ shouldApply() {
424
+ return this.getModel().modelId.includes("claude");
425
+ }
426
+ processZodType(value) {
427
+ if (isOptional(value)) {
428
+ const handleTypes = ["ZodObject", "ZodArray", "ZodUnion", "ZodNever", "ZodUndefined"];
429
+ if (this.getModel().modelId.includes("claude-3.5-haiku")) handleTypes.push("ZodString");
430
+ if (this.getModel().modelId.includes("claude-3.7")) handleTypes.push("ZodTuple");
431
+ return this.defaultZodOptionalHandler(value, handleTypes);
432
+ } else if (isObj(value)) {
433
+ return this.defaultZodObjectHandler(value);
434
+ } else if (isArr(value)) {
435
+ return this.defaultZodArrayHandler(value, []);
436
+ } else if (isUnion(value)) {
437
+ return this.defaultZodUnionHandler(value);
438
+ } else if (isString(value)) {
439
+ if (this.getModel().modelId.includes("claude-3.5-haiku")) {
440
+ return this.defaultZodStringHandler(value, ["max", "min"]);
441
+ } else {
442
+ return value;
443
+ }
444
+ }
445
+ if (this.getModel().modelId.includes("claude-3.7")) {
446
+ return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodTuple", "ZodUndefined"]);
447
+ } else {
448
+ return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodUndefined"]);
449
+ }
450
+ }
451
+ };
452
+
453
+ // src/provider-compats/deepseek.ts
454
+ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
455
+ constructor(model) {
456
+ super(model);
457
+ }
458
+ getSchemaTarget() {
459
+ return "jsonSchema7";
460
+ }
461
+ shouldApply() {
462
+ return this.getModel().modelId.includes("deepseek") && !this.getModel().modelId.includes("r1");
463
+ }
464
+ processZodType(value) {
465
+ if (isOptional(value)) {
466
+ return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
467
+ } else if (isObj(value)) {
468
+ return this.defaultZodObjectHandler(value);
469
+ } else if (isArr(value)) {
470
+ return this.defaultZodArrayHandler(value, ["min", "max"]);
471
+ } else if (isUnion(value)) {
472
+ return this.defaultZodUnionHandler(value);
473
+ } else if (isString(value)) {
474
+ return this.defaultZodStringHandler(value);
475
+ }
476
+ return value;
477
+ }
478
+ };
479
+
480
+ // src/provider-compats/google.ts
481
+ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
482
+ constructor(model) {
483
+ super(model);
484
+ }
485
+ getSchemaTarget() {
486
+ return "jsonSchema7";
487
+ }
488
+ shouldApply() {
489
+ return this.getModel().provider.includes("google") || this.getModel().modelId.includes("google");
490
+ }
491
+ processZodType(value) {
492
+ if (isOptional(value)) {
493
+ return this.defaultZodOptionalHandler(value, [
494
+ "ZodObject",
495
+ "ZodArray",
496
+ "ZodUnion",
497
+ "ZodString",
498
+ "ZodNumber",
499
+ ...UNSUPPORTED_ZOD_TYPES
500
+ ]);
501
+ } else if (isObj(value)) {
502
+ return this.defaultZodObjectHandler(value);
503
+ } else if (isArr(value)) {
504
+ return this.defaultZodArrayHandler(value, []);
505
+ } else if (isUnion(value)) {
506
+ return this.defaultZodUnionHandler(value);
507
+ } else if (isString(value)) {
508
+ return this.defaultZodStringHandler(value);
509
+ } else if (isNumber(value)) {
510
+ return this.defaultZodNumberHandler(value);
511
+ }
512
+ return this.defaultUnsupportedZodTypeHandler(value);
513
+ }
514
+ };
515
+
516
+ // src/provider-compats/meta.ts
517
+ var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
518
+ constructor(model) {
519
+ super(model);
520
+ }
521
+ getSchemaTarget() {
522
+ return "jsonSchema7";
523
+ }
524
+ shouldApply() {
525
+ return this.getModel().modelId.includes("meta");
526
+ }
527
+ processZodType(value) {
528
+ if (isOptional(value)) {
529
+ return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
530
+ } else if (isObj(value)) {
531
+ return this.defaultZodObjectHandler(value);
532
+ } else if (isArr(value)) {
533
+ return this.defaultZodArrayHandler(value, ["min", "max"]);
534
+ } else if (isUnion(value)) {
535
+ return this.defaultZodUnionHandler(value);
536
+ } else if (isNumber(value)) {
537
+ return this.defaultZodNumberHandler(value);
538
+ } else if (isString(value)) {
539
+ return this.defaultZodStringHandler(value);
540
+ }
541
+ return value;
542
+ }
543
+ };
544
+
545
+ // src/provider-compats/openai.ts
546
+ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
547
+ constructor(model) {
548
+ super(model);
549
+ }
550
+ getSchemaTarget() {
551
+ return `jsonSchema7`;
552
+ }
553
+ shouldApply() {
554
+ if (
555
+ // !this.getModel().supportsStructuredOutputs && // <- TODO: this no longer exists, do we need it?
556
+ this.getModel().provider.includes(`openai`) || this.getModel().modelId.includes(`openai`)
557
+ ) {
558
+ return true;
559
+ }
560
+ return false;
561
+ }
562
+ processZodType(value) {
563
+ if (isOptional(value)) {
564
+ return this.defaultZodOptionalHandler(value, [
565
+ "ZodObject",
566
+ "ZodArray",
567
+ "ZodUnion",
568
+ "ZodString",
569
+ "ZodNever",
570
+ "ZodUndefined",
571
+ "ZodTuple"
572
+ ]);
573
+ } else if (isObj(value)) {
574
+ return this.defaultZodObjectHandler(value);
575
+ } else if (isUnion(value)) {
576
+ return this.defaultZodUnionHandler(value);
577
+ } else if (isArr(value)) {
578
+ return this.defaultZodArrayHandler(value);
579
+ } else if (isString(value)) {
580
+ const model = this.getModel();
581
+ const checks = ["emoji"];
582
+ if (model.modelId.includes("gpt-4o-mini")) {
583
+ checks.push("regex");
584
+ }
585
+ return this.defaultZodStringHandler(value, checks);
586
+ }
587
+ return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodUndefined", "ZodTuple"]);
588
+ }
589
+ };
590
+ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
591
+ constructor(model) {
592
+ super(model);
593
+ }
594
+ getSchemaTarget() {
595
+ return `openApi3`;
596
+ }
597
+ isReasoningModel() {
598
+ return this.getModel().modelId.includes(`o3`) || this.getModel().modelId.includes(`o4`);
599
+ }
600
+ shouldApply() {
601
+ if (
602
+ // (this.getModel().supportsStructuredOutputs || this.isReasoningModel()) && // <- supportsStructuredOutputs no longer exists
603
+ this.isReasoningModel() && (this.getModel().provider.includes(`openai`) || this.getModel().modelId.includes(`openai`))
604
+ ) {
605
+ return true;
606
+ }
607
+ return false;
608
+ }
609
+ processZodType(value) {
610
+ if (isOptional(value)) {
611
+ const innerZodType = this.processZodType(value._def.innerType);
612
+ return innerZodType.nullable();
613
+ } else if (isObj(value)) {
614
+ return this.defaultZodObjectHandler(value);
615
+ } else if (isArr(value)) {
616
+ return this.defaultZodArrayHandler(value);
617
+ } else if (isUnion(value)) {
618
+ return this.defaultZodUnionHandler(value);
619
+ } else if (isDefault(value)) {
620
+ const defaultDef = value._def;
621
+ const innerType = defaultDef.innerType;
622
+ const defaultValue = defaultDef.defaultValue();
623
+ const constraints = {};
624
+ if (defaultValue !== void 0) {
625
+ constraints.defaultValue = defaultValue;
626
+ }
627
+ const description = this.mergeParameterDescription(value.description, constraints);
628
+ let result = this.processZodType(innerType);
629
+ if (description) {
630
+ result = result.describe(description);
631
+ }
632
+ return result;
633
+ } else if (isNumber(value)) {
634
+ return this.defaultZodNumberHandler(value);
635
+ } else if (isString(value)) {
636
+ return this.defaultZodStringHandler(value);
637
+ } else if (isDate(value)) {
638
+ return this.defaultZodDateHandler(value);
639
+ } else if (value._def.typeName === "ZodAny") {
640
+ return zod.z.string().describe(
641
+ (value.description ?? "") + `
642
+ Argument was an "any" type, but you (the LLM) do not support "any", so it was cast to a "string" type`
643
+ );
644
+ }
645
+ return this.defaultUnsupportedZodTypeHandler(value);
646
+ }
647
+ };
648
+
649
+ exports.ALL_ARRAY_CHECKS = ALL_ARRAY_CHECKS;
650
+ exports.ALL_NUMBER_CHECKS = ALL_NUMBER_CHECKS;
651
+ exports.ALL_STRING_CHECKS = ALL_STRING_CHECKS;
652
+ exports.ALL_ZOD_TYPES = ALL_ZOD_TYPES;
653
+ exports.AnthropicSchemaCompatLayer = AnthropicSchemaCompatLayer;
654
+ exports.DeepSeekSchemaCompatLayer = DeepSeekSchemaCompatLayer;
655
+ exports.GoogleSchemaCompatLayer = GoogleSchemaCompatLayer;
656
+ exports.MetaSchemaCompatLayer = MetaSchemaCompatLayer;
657
+ exports.OpenAIReasoningSchemaCompatLayer = OpenAIReasoningSchemaCompatLayer;
658
+ exports.OpenAISchemaCompatLayer = OpenAISchemaCompatLayer;
659
+ exports.SUPPORTED_ZOD_TYPES = SUPPORTED_ZOD_TYPES;
660
+ exports.SchemaCompatLayer = SchemaCompatLayer;
661
+ exports.UNSUPPORTED_ZOD_TYPES = UNSUPPORTED_ZOD_TYPES;
662
+ exports.applyCompatLayer = applyCompatLayer;
663
+ exports.convertSchemaToZod = convertSchemaToZod;
664
+ exports.convertZodSchemaToAISDKSchema = convertZodSchemaToAISDKSchema;
665
+ exports.isArr = isArr;
666
+ exports.isNumber = isNumber;
667
+ exports.isObj = isObj;
668
+ exports.isOptional = isOptional;
669
+ exports.isString = isString;
670
+ exports.isUnion = isUnion;
@@ -0,0 +1,31 @@
1
+ export { SchemaCompatLayer } from './_tsup-dts-rollup.cjs';
2
+ export { ALL_STRING_CHECKS } from './_tsup-dts-rollup.cjs';
3
+ export { ALL_NUMBER_CHECKS } from './_tsup-dts-rollup.cjs';
4
+ export { ALL_ARRAY_CHECKS } from './_tsup-dts-rollup.cjs';
5
+ export { UNSUPPORTED_ZOD_TYPES } from './_tsup-dts-rollup.cjs';
6
+ export { SUPPORTED_ZOD_TYPES } from './_tsup-dts-rollup.cjs';
7
+ export { ALL_ZOD_TYPES } from './_tsup-dts-rollup.cjs';
8
+ export { StringCheckType } from './_tsup-dts-rollup.cjs';
9
+ export { NumberCheckType } from './_tsup-dts-rollup.cjs';
10
+ export { ArrayCheckType } from './_tsup-dts-rollup.cjs';
11
+ export { UnsupportedZodType } from './_tsup-dts-rollup.cjs';
12
+ export { SupportedZodType } from './_tsup-dts-rollup.cjs';
13
+ export { AllZodType } from './_tsup-dts-rollup.cjs';
14
+ export { ZodShape } from './_tsup-dts-rollup.cjs';
15
+ export { ShapeKey } from './_tsup-dts-rollup.cjs';
16
+ export { ShapeValue } from './_tsup-dts-rollup.cjs';
17
+ export { isOptional } from './_tsup-dts-rollup.cjs';
18
+ export { isObj } from './_tsup-dts-rollup.cjs';
19
+ export { isArr } from './_tsup-dts-rollup.cjs';
20
+ export { isUnion } from './_tsup-dts-rollup.cjs';
21
+ export { isString } from './_tsup-dts-rollup.cjs';
22
+ export { isNumber } from './_tsup-dts-rollup.cjs';
23
+ export { convertZodSchemaToAISDKSchema } from './_tsup-dts-rollup.cjs';
24
+ export { applyCompatLayer } from './_tsup-dts-rollup.cjs';
25
+ export { convertSchemaToZod } from './_tsup-dts-rollup.cjs';
26
+ export { AnthropicSchemaCompatLayer } from './_tsup-dts-rollup.cjs';
27
+ export { DeepSeekSchemaCompatLayer } from './_tsup-dts-rollup.cjs';
28
+ export { GoogleSchemaCompatLayer } from './_tsup-dts-rollup.cjs';
29
+ export { MetaSchemaCompatLayer } from './_tsup-dts-rollup.cjs';
30
+ export { OpenAISchemaCompatLayer } from './_tsup-dts-rollup.cjs';
31
+ export { OpenAIReasoningSchemaCompatLayer } from './_tsup-dts-rollup.cjs';