@mastra/schema-compat 0.10.7 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +0 -4
  4. package/dist/chunk-FTKGHMGD.js +27 -0
  5. package/dist/chunk-FTKGHMGD.js.map +1 -0
  6. package/dist/chunk-LNR4XKDU.cjs +33 -0
  7. package/dist/chunk-LNR4XKDU.cjs.map +1 -0
  8. package/dist/index.cjs +846 -84
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.ts +10 -8
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +845 -85
  13. package/dist/index.js.map +1 -1
  14. package/dist/provider-compats/anthropic.d.ts +6 -4
  15. package/dist/provider-compats/anthropic.d.ts.map +1 -1
  16. package/dist/provider-compats/deepseek.d.ts +6 -4
  17. package/dist/provider-compats/deepseek.d.ts.map +1 -1
  18. package/dist/provider-compats/google.d.ts +6 -4
  19. package/dist/provider-compats/google.d.ts.map +1 -1
  20. package/dist/provider-compats/meta.d.ts +6 -4
  21. package/dist/provider-compats/meta.d.ts.map +1 -1
  22. package/dist/provider-compats/openai-reasoning.d.ts +6 -4
  23. package/dist/provider-compats/openai-reasoning.d.ts.map +1 -1
  24. package/dist/provider-compats/openai.d.ts +6 -4
  25. package/dist/provider-compats/openai.d.ts.map +1 -1
  26. package/dist/schema-compatibility-v3.d.ts +319 -0
  27. package/dist/schema-compatibility-v3.d.ts.map +1 -0
  28. package/dist/schema-compatibility-v4.d.ts +310 -0
  29. package/dist/schema-compatibility-v4.d.ts.map +1 -0
  30. package/dist/schema-compatibility.d.ts +80 -134
  31. package/dist/schema-compatibility.d.ts.map +1 -1
  32. package/dist/types.d.ts +6 -0
  33. package/dist/types.d.ts.map +1 -0
  34. package/dist/utils-test-suite.d.ts +2 -0
  35. package/dist/utils-test-suite.d.ts.map +1 -0
  36. package/dist/utils.d.ts +17 -5
  37. package/dist/utils.d.ts.map +1 -1
  38. package/dist/zod-to-json.cjs +12 -0
  39. package/dist/zod-to-json.cjs.map +1 -0
  40. package/dist/zod-to-json.d.ts +6 -0
  41. package/dist/zod-to-json.d.ts.map +1 -0
  42. package/dist/zod-to-json.js +3 -0
  43. package/dist/zod-to-json.js.map +1 -0
  44. package/dist/zodTypes.d.ts +21 -0
  45. package/dist/zodTypes.d.ts.map +1 -0
  46. package/package.json +16 -6
  47. package/src/index.ts +4 -3
  48. package/src/provider-compats/anthropic.ts +29 -11
  49. package/src/provider-compats/deepseek.ts +14 -9
  50. package/src/provider-compats/google.ts +18 -32
  51. package/src/provider-compats/meta.ts +15 -10
  52. package/src/provider-compats/openai-reasoning.ts +18 -24
  53. package/src/provider-compats/openai.ts +22 -12
  54. package/src/schema-compatibility-v3.ts +664 -0
  55. package/src/schema-compatibility-v4.test.ts +476 -0
  56. package/src/schema-compatibility-v4.ts +706 -0
  57. package/src/schema-compatibility.test.ts +12 -28
  58. package/src/schema-compatibility.ts +263 -383
  59. package/src/types.ts +5 -0
  60. package/src/utils-test-suite.ts +467 -0
  61. package/src/utils-v3.test.ts +9 -0
  62. package/src/utils-v4.test.ts +9 -0
  63. package/src/utils.ts +30 -24
  64. package/src/zod-to-json.ts +27 -0
  65. package/src/zodTypes.ts +56 -0
  66. package/tsup.config.ts +8 -3
  67. package/src/utils.test.ts +0 -460
package/dist/index.js CHANGED
@@ -1,22 +1,18 @@
1
- import { ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, z, ZodNull, ZodDefault, ZodDate } from 'zod';
1
+ import { zodToJsonSchema } from './chunk-FTKGHMGD.js';
2
+ import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodNull, ZodDate, ZodDefault } from 'zod';
2
3
  import { jsonSchema } from 'ai';
3
4
  import { convertJsonSchemaToZod } from 'zod-from-json-schema';
4
- import { zodToJsonSchema } from 'zod-to-json-schema';
5
+ import { convertJsonSchemaToZod as convertJsonSchemaToZod$1 } from 'zod-from-json-schema-v3';
6
+ import { ZodOptional as ZodOptional$1, ZodObject as ZodObject$1, ZodNull as ZodNull$1, ZodArray as ZodArray$1, ZodUnion as ZodUnion$1, ZodString as ZodString$1, ZodNumber as ZodNumber$1, ZodDate as ZodDate$1, ZodDefault as ZodDefault$1, z as z$1 } from 'zod/v4';
5
7
 
6
- // src/schema-compatibility.ts
7
8
  function convertZodSchemaToAISDKSchema(zodSchema, target = "jsonSchema7") {
8
- return jsonSchema(
9
- zodToJsonSchema(zodSchema, {
10
- $refStrategy: "none",
11
- target
12
- }),
13
- {
14
- validate: (value) => {
15
- const result = zodSchema.safeParse(value);
16
- return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
17
- }
9
+ const jsonSchemaToUse = zodToJsonSchema(zodSchema, target);
10
+ return jsonSchema(jsonSchemaToUse, {
11
+ validate: (value) => {
12
+ const result = zodSchema.safeParse(value);
13
+ return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
18
14
  }
19
- );
15
+ });
20
16
  }
21
17
  function isZodType(value) {
22
18
  return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
@@ -27,7 +23,11 @@ function convertSchemaToZod(schema) {
27
23
  } else {
28
24
  const jsonSchemaToConvert = "jsonSchema" in schema ? schema.jsonSchema : schema;
29
25
  try {
30
- return convertJsonSchemaToZod(jsonSchemaToConvert);
26
+ if ("toJSONSchema" in z) {
27
+ return convertJsonSchemaToZod(jsonSchemaToConvert);
28
+ } else {
29
+ return convertJsonSchemaToZod$1(jsonSchemaToConvert);
30
+ }
31
31
  } catch (e) {
32
32
  const errorMessage = `[Schema Builder] Failed to convert schema parameters to Zod. Original schema: ${JSON.stringify(jsonSchemaToConvert)}`;
33
33
  console.error(errorMessage, e);
@@ -53,13 +53,13 @@ function applyCompatLayer({
53
53
  }
54
54
  }
55
55
  if (mode === "jsonSchema") {
56
- return zodToJsonSchema(zodSchema, { $refStrategy: "none", target: "jsonSchema7" });
56
+ return zodToJsonSchema(zodSchema, "jsonSchema7");
57
57
  } else {
58
58
  return convertZodSchemaToAISDKSchema(zodSchema);
59
59
  }
60
60
  }
61
61
 
62
- // src/schema-compatibility.ts
62
+ // src/schema-compatibility-v3.ts
63
63
  var ALL_STRING_CHECKS = ["regex", "emoji", "email", "url", "uuid", "cuid", "min", "max"];
64
64
  var ALL_NUMBER_CHECKS = [
65
65
  "min",
@@ -71,13 +71,10 @@ var ALL_NUMBER_CHECKS = [
71
71
  var ALL_ARRAY_CHECKS = ["min", "max", "length"];
72
72
  var isOptional = (v) => v instanceof ZodOptional;
73
73
  var isObj = (v) => v instanceof ZodObject;
74
- var isNull = (v) => v instanceof ZodNull;
75
74
  var isArr = (v) => v instanceof ZodArray;
76
75
  var isUnion = (v) => v instanceof ZodUnion;
77
76
  var isString = (v) => v instanceof ZodString;
78
77
  var isNumber = (v) => v instanceof ZodNumber;
79
- var isDate = (v) => v instanceof ZodDate;
80
- var isDefault = (v) => v instanceof ZodDefault;
81
78
  var UNSUPPORTED_ZOD_TYPES = ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
82
79
  var SUPPORTED_ZOD_TYPES = [
83
80
  "ZodObject",
@@ -92,13 +89,15 @@ var SUPPORTED_ZOD_TYPES = [
92
89
  var ALL_ZOD_TYPES = [...SUPPORTED_ZOD_TYPES, ...UNSUPPORTED_ZOD_TYPES];
93
90
  var SchemaCompatLayer = class {
94
91
  model;
92
+ parent;
95
93
  /**
96
94
  * Creates a new schema compatibility instance.
97
95
  *
98
96
  * @param model - The language model this compatibility layer applies to
99
97
  */
100
- constructor(model) {
98
+ constructor(model, parent) {
101
99
  this.model = model;
100
+ this.parent = parent;
102
101
  }
103
102
  /**
104
103
  * Gets the language model associated with this compatibility layer.
@@ -108,6 +107,91 @@ var SchemaCompatLayer = class {
108
107
  getModel() {
109
108
  return this.model;
110
109
  }
110
+ getUnsupportedZodTypes() {
111
+ return UNSUPPORTED_ZOD_TYPES;
112
+ }
113
+ /**
114
+ * Type guard for optional Zod types
115
+ */
116
+ isOptional(v) {
117
+ return v instanceof ZodOptional;
118
+ }
119
+ /**
120
+ * Type guard for object Zod types
121
+ */
122
+ isObj(v) {
123
+ return v instanceof ZodObject;
124
+ }
125
+ /**
126
+ * Type guard for null Zod types
127
+ */
128
+ isNull(v) {
129
+ return v instanceof ZodNull;
130
+ }
131
+ /**
132
+ * Type guard for array Zod types
133
+ */
134
+ isArr(v) {
135
+ return v instanceof ZodArray;
136
+ }
137
+ /**
138
+ * Type guard for union Zod types
139
+ */
140
+ isUnion(v) {
141
+ return v instanceof ZodUnion;
142
+ }
143
+ /**
144
+ * Type guard for string Zod types
145
+ */
146
+ isString(v) {
147
+ return v instanceof ZodString;
148
+ }
149
+ /**
150
+ * Type guard for number Zod types
151
+ */
152
+ isNumber(v) {
153
+ return v instanceof ZodNumber;
154
+ }
155
+ /**
156
+ * Type guard for date Zod types
157
+ */
158
+ isDate(v) {
159
+ return v instanceof ZodDate;
160
+ }
161
+ /**
162
+ * Type guard for default Zod types
163
+ */
164
+ isDefault(v) {
165
+ return v instanceof ZodDefault;
166
+ }
167
+ /**
168
+ * Determines whether this compatibility layer should be applied for the current model.
169
+ *
170
+ * @returns True if this compatibility layer should be used, false otherwise
171
+ * @abstract
172
+ */
173
+ shouldApply() {
174
+ return this.parent.shouldApply();
175
+ }
176
+ /**
177
+ * Returns the JSON Schema target format for this provider.
178
+ *
179
+ * @returns The schema target format, or undefined to use the default 'jsonSchema7'
180
+ * @abstract
181
+ */
182
+ getSchemaTarget() {
183
+ return this.parent.getSchemaTarget();
184
+ }
185
+ /**
186
+ * Processes a specific Zod type according to the provider's requirements.
187
+ *
188
+ * @param value - The Zod type to process
189
+ * @returns The processed Zod type
190
+ * @abstract
191
+ */
192
+ processZodType(value) {
193
+ return this.parent.processZodType(value);
194
+ }
111
195
  /**
112
196
  * Default handler for Zod object types. Recursively processes all properties in the object.
113
197
  *
@@ -236,7 +320,10 @@ var SchemaCompatLayer = class {
236
320
  if (handleChecks.includes(check.kind)) {
237
321
  switch (check.kind) {
238
322
  case "regex": {
239
- constraints.regex = `A string that must match the regex pattern: ${check.regex.source}, with flags: ${check.regex.flags}`;
323
+ constraints.regex = {
324
+ pattern: check.regex.source,
325
+ flags: check.regex.flags
326
+ };
240
327
  break;
241
328
  }
242
329
  case "emoji": {
@@ -410,9 +497,680 @@ var SchemaCompatLayer = class {
410
497
  return this.processToAISDKSchema(zodSchema).jsonSchema;
411
498
  }
412
499
  };
500
+ var ALL_STRING_CHECKS2 = [
501
+ "regex",
502
+ "emoji",
503
+ "email",
504
+ "url",
505
+ "uuid",
506
+ "cuid",
507
+ "min_length",
508
+ "max_length",
509
+ "string_format"
510
+ ];
511
+ var ALL_NUMBER_CHECKS2 = ["greater_than", "less_than", "multiple_of"];
512
+ var ALL_ARRAY_CHECKS2 = ["min", "max", "length"];
513
+ var UNSUPPORTED_ZOD_TYPES2 = ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
514
+ var SUPPORTED_ZOD_TYPES2 = [
515
+ "ZodObject",
516
+ "ZodArray",
517
+ "ZodUnion",
518
+ "ZodString",
519
+ "ZodNumber",
520
+ "ZodDate",
521
+ "ZodAny",
522
+ "ZodDefault"
523
+ ];
524
+ var SchemaCompatLayer2 = class {
525
+ model;
526
+ parent;
527
+ /**
528
+ * Creates a new schema compatibility instance.
529
+ *
530
+ * @param model - The language model this compatibility layer applies to
531
+ */
532
+ constructor(model, parent) {
533
+ this.model = model;
534
+ this.parent = parent;
535
+ }
536
+ /**
537
+ * Gets the language model associated with this compatibility layer.
538
+ *
539
+ * @returns The language model instance
540
+ */
541
+ getModel() {
542
+ return this.model;
543
+ }
544
+ getUnsupportedZodTypes() {
545
+ return UNSUPPORTED_ZOD_TYPES2;
546
+ }
547
+ /**
548
+ * Type guard for optional Zod types
549
+ */
550
+ isOptional(v) {
551
+ return v instanceof ZodOptional$1;
552
+ }
553
+ /**
554
+ * Type guard for object Zod types
555
+ */
556
+ isObj(v) {
557
+ return v instanceof ZodObject$1;
558
+ }
559
+ /**
560
+ * Type guard for null Zod types
561
+ */
562
+ isNull(v) {
563
+ return v instanceof ZodNull$1;
564
+ }
565
+ /**
566
+ * Type guard for array Zod types
567
+ */
568
+ isArr(v) {
569
+ return v instanceof ZodArray$1;
570
+ }
571
+ /**
572
+ * Type guard for union Zod types
573
+ */
574
+ isUnion(v) {
575
+ return v instanceof ZodUnion$1;
576
+ }
577
+ /**
578
+ * Type guard for string Zod types
579
+ */
580
+ isString(v) {
581
+ return v instanceof ZodString$1;
582
+ }
583
+ /**
584
+ * Type guard for number Zod types
585
+ */
586
+ isNumber(v) {
587
+ return v instanceof ZodNumber$1;
588
+ }
589
+ /**
590
+ * Type guard for date Zod types
591
+ */
592
+ isDate(v) {
593
+ return v instanceof ZodDate$1;
594
+ }
595
+ /**
596
+ * Type guard for default Zod types
597
+ */
598
+ isDefault(v) {
599
+ return v instanceof ZodDefault$1;
600
+ }
601
+ /**
602
+ * Determines whether this compatibility layer should be applied for the current model.
603
+ *
604
+ * @returns True if this compatibility layer should be used, false otherwise
605
+ * @abstract
606
+ */
607
+ shouldApply() {
608
+ return this.parent.shouldApply();
609
+ }
610
+ /**
611
+ * Returns the JSON Schema target format for this provider.
612
+ *
613
+ * @returns The schema target format, or undefined to use the default 'jsonSchema7'
614
+ * @abstract
615
+ */
616
+ getSchemaTarget() {
617
+ return this.parent.getSchemaTarget();
618
+ }
619
+ /**
620
+ * Processes a specific Zod type according to the provider's requirements.
621
+ *
622
+ * @param value - The Zod type to process
623
+ * @returns The processed Zod type
624
+ * @abstract
625
+ */
626
+ processZodType(value) {
627
+ return this.parent.processZodType(value);
628
+ }
629
+ /**
630
+ * Default handler for Zod object types. Recursively processes all properties in the object.
631
+ *
632
+ * @param value - The Zod object to process
633
+ * @returns The processed Zod object
634
+ */
635
+ defaultZodObjectHandler(value, options = { passthrough: true }) {
636
+ const processedShape = Object.entries(value.shape).reduce((acc, [key, propValue]) => {
637
+ acc[key] = this.processZodType(propValue);
638
+ return acc;
639
+ }, {});
640
+ let result = z$1.object(processedShape);
641
+ if (value._zod.def.catchall instanceof z$1.ZodNever) {
642
+ result = z$1.strictObject(processedShape);
643
+ }
644
+ if (value._zod.def.catchall && !(value._zod.def.catchall instanceof z$1.ZodNever)) {
645
+ result = result.catchall(value._zod.def.catchall);
646
+ }
647
+ if (value.description) {
648
+ result = result.describe(value.description);
649
+ }
650
+ if (options.passthrough && value._zod.def.catchall instanceof z$1.ZodUnknown) {
651
+ result = z$1.looseObject(processedShape);
652
+ }
653
+ return result;
654
+ }
655
+ /**
656
+ * Merges validation constraints into a parameter description.
657
+ *
658
+ * This helper method converts validation constraints that may not be supported
659
+ * by a provider into human-readable descriptions.
660
+ *
661
+ * @param description - The existing parameter description
662
+ * @param constraints - The validation constraints to merge
663
+ * @returns The updated description with constraints, or undefined if no constraints
664
+ */
665
+ mergeParameterDescription(description, constraints) {
666
+ if (Object.keys(constraints).length > 0) {
667
+ return (description ? description + "\n" : "") + JSON.stringify(constraints);
668
+ } else {
669
+ return description;
670
+ }
671
+ }
672
+ /**
673
+ * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
674
+ *
675
+ * @param value - The Zod type to check
676
+ * @param throwOnTypes - Array of type names to throw errors for
677
+ * @returns The original value if not in the throw list
678
+ * @throws Error if the type is in the unsupported list
679
+ */
680
+ defaultUnsupportedZodTypeHandler(value, throwOnTypes = UNSUPPORTED_ZOD_TYPES2) {
681
+ if (throwOnTypes.includes(value.constructor.name)) {
682
+ throw new Error(`${this.model.modelId} does not support zod type: ${value.constructor.name}`);
683
+ }
684
+ return value;
685
+ }
686
+ /**
687
+ * Default handler for Zod array types. Processes array constraints according to provider support.
688
+ *
689
+ * @param value - The Zod array to process
690
+ * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
691
+ * @returns The processed Zod array
692
+ */
693
+ defaultZodArrayHandler(value, handleChecks = ALL_ARRAY_CHECKS2) {
694
+ const zodArrayDef = value._zod.def;
695
+ const processedType = this.processZodType(zodArrayDef.element);
696
+ let result = z$1.array(processedType);
697
+ const constraints = {};
698
+ if (zodArrayDef.checks) {
699
+ for (const check of zodArrayDef.checks) {
700
+ if (check._zod.def.check === "min_length") {
701
+ if (handleChecks.includes("min")) {
702
+ constraints.minLength = check._zod.def.minimum;
703
+ } else {
704
+ result = result.min(check._zod.def.minimum);
705
+ }
706
+ }
707
+ if (check._zod.def.check === "max_length") {
708
+ if (handleChecks.includes("max")) {
709
+ constraints.maxLength = check._zod.def.maximum;
710
+ } else {
711
+ result = result.max(check._zod.def.maximum);
712
+ }
713
+ }
714
+ if (check._zod.def.check === "length_equals") {
715
+ if (handleChecks.includes("length")) {
716
+ constraints.exactLength = check._zod.def.length;
717
+ } else {
718
+ result = result.length(check._zod.def.length);
719
+ }
720
+ }
721
+ }
722
+ }
723
+ const metaDescription = value.meta()?.description;
724
+ const legacyDescription = value.description;
725
+ const description = this.mergeParameterDescription(metaDescription || legacyDescription, constraints);
726
+ if (description) {
727
+ result = result.describe(description);
728
+ }
729
+ return result;
730
+ }
731
+ /**
732
+ * Default handler for Zod union types. Processes all union options.
733
+ *
734
+ * @param value - The Zod union to process
735
+ * @returns The processed Zod union
736
+ * @throws Error if union has fewer than 2 options
737
+ */
738
+ defaultZodUnionHandler(value) {
739
+ const processedOptions = value._zod.def.options.map((option) => this.processZodType(option));
740
+ if (processedOptions.length < 2) throw new Error("Union must have at least 2 options");
741
+ let result = z$1.union(processedOptions);
742
+ if (value.description) {
743
+ result = result.describe(value.description);
744
+ }
745
+ return result;
746
+ }
747
+ /**
748
+ * Default handler for Zod string types. Processes string validation constraints.
749
+ *
750
+ * @param value - The Zod string to process
751
+ * @param handleChecks - String constraints to convert to descriptions vs keep as validation
752
+ * @returns The processed Zod string
753
+ */
754
+ defaultZodStringHandler(value, handleChecks = ALL_STRING_CHECKS2) {
755
+ const constraints = {};
756
+ const checks = value._zod.def.checks || [];
757
+ const newChecks = [];
758
+ if (checks) {
759
+ for (const check of checks) {
760
+ if (handleChecks.includes(check._zod.def.check)) {
761
+ switch (check._zod.def.check) {
762
+ case "min_length":
763
+ constraints.minLength = check._zod.def.minimum;
764
+ break;
765
+ case "max_length":
766
+ constraints.maxLength = check._zod.def.maximum;
767
+ break;
768
+ case "string_format":
769
+ {
770
+ switch (check._zod.def.format) {
771
+ case "email":
772
+ constraints.email = true;
773
+ break;
774
+ case "url":
775
+ constraints.url = true;
776
+ break;
777
+ case "emoji":
778
+ constraints.emoji = true;
779
+ break;
780
+ case "uuid":
781
+ constraints.uuid = true;
782
+ break;
783
+ case "cuid":
784
+ constraints.cuid = true;
785
+ break;
786
+ case "regex":
787
+ constraints.regex = {
788
+ // @ts-expect-error - fix later
789
+ pattern: check._zod.def.pattern,
790
+ // @ts-expect-error - fix later
791
+ flags: check._zod.def.flags
792
+ };
793
+ break;
794
+ }
795
+ }
796
+ break;
797
+ }
798
+ } else {
799
+ newChecks.push(check);
800
+ }
801
+ }
802
+ }
803
+ let result = z$1.string();
804
+ for (const check of newChecks) {
805
+ result = result.check(check);
806
+ }
807
+ const metaDescription = value.meta()?.description;
808
+ const legacyDescription = value.description;
809
+ const description = this.mergeParameterDescription(metaDescription || legacyDescription, constraints);
810
+ if (description) {
811
+ result = result.describe(description);
812
+ }
813
+ return result;
814
+ }
815
+ /**
816
+ * Default handler for Zod number types. Processes number validation constraints.
817
+ *
818
+ * @param value - The Zod number to process
819
+ * @param handleChecks - Number constraints to convert to descriptions vs keep as validation
820
+ * @returns The processed Zod number
821
+ */
822
+ defaultZodNumberHandler(value, handleChecks = ALL_NUMBER_CHECKS2) {
823
+ const constraints = {};
824
+ const checks = value._zod.def.checks || [];
825
+ const newChecks = [];
826
+ if (checks) {
827
+ for (const check of checks) {
828
+ if (handleChecks.includes(check._zod.def.check)) {
829
+ switch (check._zod.def.check) {
830
+ case "greater_than":
831
+ if (check._zod.def.inclusive) {
832
+ constraints.gte = check._zod.def.value;
833
+ } else {
834
+ constraints.gt = check._zod.def.value;
835
+ }
836
+ break;
837
+ case "less_than":
838
+ if (check._zod.def.inclusive) {
839
+ constraints.lte = check._zod.def.value;
840
+ } else {
841
+ constraints.lt = check._zod.def.value;
842
+ }
843
+ break;
844
+ case "multiple_of": {
845
+ constraints.multipleOf = check._zod.def.value;
846
+ break;
847
+ }
848
+ }
849
+ } else {
850
+ newChecks.push(check);
851
+ }
852
+ }
853
+ }
854
+ let result = z$1.number();
855
+ for (const check of newChecks) {
856
+ switch (check._zod.def.check) {
857
+ case "number_format": {
858
+ switch (check._zod.def.format) {
859
+ case "safeint":
860
+ result = result.int();
861
+ break;
862
+ }
863
+ break;
864
+ }
865
+ default:
866
+ result = result.check(check);
867
+ }
868
+ }
869
+ const description = this.mergeParameterDescription(value.description, constraints);
870
+ if (description) {
871
+ result = result.describe(description);
872
+ }
873
+ return result;
874
+ }
875
+ /**
876
+ * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
877
+ *
878
+ * @param value - The Zod date to process
879
+ * @returns A Zod string schema representing the date in ISO format
880
+ */
881
+ defaultZodDateHandler(value) {
882
+ const constraints = {};
883
+ const checks = value._zod.def.checks || [];
884
+ if (checks) {
885
+ for (const check of checks) {
886
+ switch (check._zod.def.check) {
887
+ case "less_than":
888
+ const minDate = new Date(check._zod.def.value);
889
+ if (!isNaN(minDate.getTime())) {
890
+ constraints.minDate = minDate.toISOString();
891
+ }
892
+ break;
893
+ case "greater_than":
894
+ const maxDate = new Date(check._zod.def.value);
895
+ if (!isNaN(maxDate.getTime())) {
896
+ constraints.maxDate = maxDate.toISOString();
897
+ }
898
+ break;
899
+ }
900
+ }
901
+ }
902
+ constraints.dateFormat = "date-time";
903
+ let result = z$1.string().describe("date-time");
904
+ const description = this.mergeParameterDescription(value.description, constraints);
905
+ if (description) {
906
+ result = result.describe(description);
907
+ }
908
+ return result;
909
+ }
910
+ /**
911
+ * Default handler for Zod optional types. Processes the inner type and maintains optionality.
912
+ *
913
+ * @param value - The Zod optional to process
914
+ * @param handleTypes - Types that should be processed vs passed through
915
+ * @returns The processed Zod optional
916
+ */
917
+ defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES2) {
918
+ if (handleTypes.includes(value.constructor.name)) {
919
+ return this.processZodType(value._zod.def.innerType).optional();
920
+ } else {
921
+ return value;
922
+ }
923
+ }
924
+ /**
925
+ * Processes a Zod object schema and converts it to an AI SDK Schema.
926
+ *
927
+ * @param zodSchema - The Zod object schema to process
928
+ * @returns An AI SDK Schema with provider-specific compatibility applied
929
+ */
930
+ processToAISDKSchema(zodSchema) {
931
+ const processedSchema = this.processZodType(zodSchema);
932
+ return convertZodSchemaToAISDKSchema(processedSchema, this.getSchemaTarget());
933
+ }
934
+ /**
935
+ * Processes a Zod object schema and converts it to a JSON Schema.
936
+ *
937
+ * @param zodSchema - The Zod object schema to process
938
+ * @returns A JSONSchema7 object with provider-specific compatibility applied
939
+ */
940
+ processToJSONSchema(zodSchema) {
941
+ return this.processToAISDKSchema(zodSchema).jsonSchema;
942
+ }
943
+ };
944
+
945
+ // src/schema-compatibility.ts
946
+ var SchemaCompatLayer3 = class {
947
+ model;
948
+ v3Layer;
949
+ v4Layer;
950
+ /**
951
+ * Creates a new schema compatibility instance.
952
+ *
953
+ * @param model - The language model this compatibility layer applies to
954
+ */
955
+ constructor(model) {
956
+ this.model = model;
957
+ this.v3Layer = new SchemaCompatLayer(model, this);
958
+ this.v4Layer = new SchemaCompatLayer2(model, this);
959
+ }
960
+ /**
961
+ * Gets the language model associated with this compatibility layer.
962
+ *
963
+ * @returns The language model instance
964
+ */
965
+ getModel() {
966
+ return this.model;
967
+ }
968
+ getUnsupportedZodTypes(v) {
969
+ if ("_zod" in v) {
970
+ return this.v4Layer.getUnsupportedZodTypes();
971
+ } else {
972
+ return this.v3Layer.getUnsupportedZodTypes();
973
+ }
974
+ }
975
+ isOptional(v) {
976
+ if ("_zod" in v) {
977
+ return this.v4Layer.isOptional(v);
978
+ } else {
979
+ return this.v3Layer.isOptional(v);
980
+ }
981
+ }
982
+ isObj(v) {
983
+ if ("_zod" in v) {
984
+ return this.v4Layer.isObj(v);
985
+ } else {
986
+ return this.v3Layer.isObj(v);
987
+ }
988
+ }
989
+ isNull(v) {
990
+ if ("_zod" in v) {
991
+ return this.v4Layer.isNull(v);
992
+ } else {
993
+ return this.v3Layer.isNull(v);
994
+ }
995
+ }
996
+ isArr(v) {
997
+ if ("_zod" in v) {
998
+ return this.v4Layer.isArr(v);
999
+ } else {
1000
+ return this.v3Layer.isArr(v);
1001
+ }
1002
+ }
1003
+ isUnion(v) {
1004
+ if ("_zod" in v) {
1005
+ return this.v4Layer.isUnion(v);
1006
+ } else {
1007
+ return this.v3Layer.isUnion(v);
1008
+ }
1009
+ }
1010
+ isString(v) {
1011
+ if ("_zod" in v) {
1012
+ return this.v4Layer.isString(v);
1013
+ } else {
1014
+ return this.v3Layer.isString(v);
1015
+ }
1016
+ }
1017
+ isNumber(v) {
1018
+ if ("_zod" in v) {
1019
+ return this.v4Layer.isNumber(v);
1020
+ } else {
1021
+ return this.v3Layer.isNumber(v);
1022
+ }
1023
+ }
1024
+ isDate(v) {
1025
+ if ("_zod" in v) {
1026
+ return this.v4Layer.isDate(v);
1027
+ } else {
1028
+ return this.v3Layer.isDate(v);
1029
+ }
1030
+ }
1031
+ isDefault(v) {
1032
+ if ("_zod" in v) {
1033
+ return this.v4Layer.isDefault(v);
1034
+ } else {
1035
+ return this.v3Layer.isDefault(v);
1036
+ }
1037
+ }
1038
+ defaultZodObjectHandler(value, options = { passthrough: true }) {
1039
+ if ("_zod" in value) {
1040
+ return this.v4Layer.defaultZodObjectHandler(value, options);
1041
+ } else {
1042
+ return this.v3Layer.defaultZodObjectHandler(value, options);
1043
+ }
1044
+ }
1045
+ /**
1046
+ * Merges validation constraints into a parameter description.
1047
+ *
1048
+ * This helper method converts validation constraints that may not be supported
1049
+ * by a provider into human-readable descriptions.
1050
+ *
1051
+ * @param description - The existing parameter description
1052
+ * @param constraints - The validation constraints to merge
1053
+ * @returns The updated description with constraints, or undefined if no constraints
1054
+ */
1055
+ mergeParameterDescription(description, constraints) {
1056
+ return this.v3Layer.mergeParameterDescription(description, constraints);
1057
+ }
1058
+ /**
1059
+ * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
1060
+ *
1061
+ * @param value - The Zod type to check
1062
+ * @param throwOnTypes - Array of type names to throw errors for
1063
+ * @returns The original value if not in the throw list
1064
+ * @throws Error if the type is in the unsupported list
1065
+ */
1066
+ defaultUnsupportedZodTypeHandler(value, throwOnTypes) {
1067
+ if ("_zod" in value) {
1068
+ return this.v4Layer.defaultUnsupportedZodTypeHandler(
1069
+ // @ts-expect-error - fix later
1070
+ value,
1071
+ throwOnTypes ?? UNSUPPORTED_ZOD_TYPES2
1072
+ );
1073
+ } else {
1074
+ return this.v3Layer.defaultUnsupportedZodTypeHandler(
1075
+ value,
1076
+ throwOnTypes ?? UNSUPPORTED_ZOD_TYPES
1077
+ );
1078
+ }
1079
+ }
1080
+ defaultZodArrayHandler(value, handleChecks = ALL_ARRAY_CHECKS) {
1081
+ if ("_zod" in value) {
1082
+ return this.v4Layer.defaultZodArrayHandler(value, handleChecks);
1083
+ } else {
1084
+ return this.v3Layer.defaultZodArrayHandler(value, handleChecks);
1085
+ }
1086
+ }
1087
+ defaultZodUnionHandler(value) {
1088
+ if ("_zod" in value) {
1089
+ return this.v4Layer.defaultZodUnionHandler(value);
1090
+ } else {
1091
+ return this.v3Layer.defaultZodUnionHandler(value);
1092
+ }
1093
+ }
1094
+ defaultZodStringHandler(value, handleChecks = ALL_STRING_CHECKS) {
1095
+ if ("_zod" in value) {
1096
+ return this.v4Layer.defaultZodStringHandler(value);
1097
+ } else {
1098
+ return this.v3Layer.defaultZodStringHandler(value, handleChecks);
1099
+ }
1100
+ }
1101
+ defaultZodNumberHandler(value, handleChecks = ALL_NUMBER_CHECKS) {
1102
+ if ("_zod" in value) {
1103
+ return this.v4Layer.defaultZodNumberHandler(value);
1104
+ } else {
1105
+ return this.v3Layer.defaultZodNumberHandler(value, handleChecks);
1106
+ }
1107
+ }
1108
+ defaultZodDateHandler(value) {
1109
+ if ("_zod" in value) {
1110
+ return this.v4Layer.defaultZodDateHandler(value);
1111
+ } else {
1112
+ return this.v3Layer.defaultZodDateHandler(value);
1113
+ }
1114
+ }
1115
+ defaultZodOptionalHandler(value, handleTypes) {
1116
+ if ("_zod" in value) {
1117
+ return this.v4Layer.defaultZodOptionalHandler(value, handleTypes ?? SUPPORTED_ZOD_TYPES2);
1118
+ } else {
1119
+ return this.v3Layer.defaultZodOptionalHandler(value, handleTypes ?? SUPPORTED_ZOD_TYPES);
1120
+ }
1121
+ }
1122
+ /**
1123
+ * Processes a Zod object schema and converts it to an AI SDK Schema.
1124
+ *
1125
+ * @param zodSchema - The Zod object schema to process
1126
+ * @returns An AI SDK Schema with provider-specific compatibility applied
1127
+ */
1128
+ processToAISDKSchema(zodSchema) {
1129
+ const processedSchema = this.processZodType(zodSchema);
1130
+ return convertZodSchemaToAISDKSchema(processedSchema, this.getSchemaTarget());
1131
+ }
1132
+ /**
1133
+ * Processes a Zod object schema and converts it to a JSON Schema.
1134
+ *
1135
+ * @param zodSchema - The Zod object schema to process
1136
+ * @returns A JSONSchema7 object with provider-specific compatibility applied
1137
+ */
1138
+ processToJSONSchema(zodSchema) {
1139
+ return this.processToAISDKSchema(zodSchema).jsonSchema;
1140
+ }
1141
+ };
1142
+
1143
+ // src/zodTypes.ts
1144
+ function isOptional2(z10) {
1145
+ return (v) => v instanceof z10["ZodOptional"];
1146
+ }
1147
+ function isObj2(z10) {
1148
+ return (v) => v instanceof z10["ZodObject"];
1149
+ }
1150
+ function isNull(z10) {
1151
+ return (v) => v instanceof z10["ZodNull"];
1152
+ }
1153
+ function isArr2(z10) {
1154
+ return (v) => v instanceof z10["ZodArray"];
1155
+ }
1156
+ function isUnion2(z10) {
1157
+ return (v) => v instanceof z10["ZodUnion"];
1158
+ }
1159
+ function isString2(z10) {
1160
+ return (v) => v instanceof z10["ZodString"];
1161
+ }
1162
+ function isNumber2(z10) {
1163
+ return (v) => v instanceof z10["ZodNumber"];
1164
+ }
1165
+ function isDate(z10) {
1166
+ return (v) => v instanceof z10["ZodDate"];
1167
+ }
1168
+ function isDefault(z10) {
1169
+ return (v) => v instanceof z10["ZodDefault"];
1170
+ }
413
1171
 
414
1172
  // src/provider-compats/anthropic.ts
415
- var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
1173
+ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer3 {
416
1174
  constructor(model) {
417
1175
  super(model);
418
1176
  }
@@ -423,29 +1181,38 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
423
1181
  return this.getModel().modelId.includes("claude");
424
1182
  }
425
1183
  processZodType(value) {
426
- if (isOptional(value)) {
427
- const handleTypes = ["ZodObject", "ZodArray", "ZodUnion", "ZodNever", "ZodUndefined", "ZodTuple"];
1184
+ if (isOptional2(z)(value)) {
1185
+ const handleTypes = [
1186
+ "ZodObject",
1187
+ "ZodArray",
1188
+ "ZodUnion",
1189
+ "ZodNever",
1190
+ "ZodUndefined",
1191
+ "ZodTuple"
1192
+ ];
428
1193
  if (this.getModel().modelId.includes("claude-3.5-haiku")) handleTypes.push("ZodString");
429
1194
  return this.defaultZodOptionalHandler(value, handleTypes);
430
- } else if (isObj(value)) {
1195
+ } else if (isObj2(z)(value)) {
431
1196
  return this.defaultZodObjectHandler(value);
432
- } else if (isArr(value)) {
1197
+ } else if (isArr2(z)(value)) {
433
1198
  return this.defaultZodArrayHandler(value, []);
434
- } else if (isUnion(value)) {
1199
+ } else if (isUnion2(z)(value)) {
435
1200
  return this.defaultZodUnionHandler(value);
436
- } else if (isString(value)) {
1201
+ } else if (isString2(z)(value)) {
437
1202
  if (this.getModel().modelId.includes("claude-3.5-haiku")) {
438
1203
  return this.defaultZodStringHandler(value, ["max", "min"]);
439
1204
  } else {
440
1205
  return value;
441
1206
  }
442
1207
  }
443
- return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodTuple", "ZodUndefined"]);
1208
+ return this.defaultUnsupportedZodTypeHandler(value, [
1209
+ "ZodNever",
1210
+ "ZodTuple",
1211
+ "ZodUndefined"
1212
+ ]);
444
1213
  }
445
1214
  };
446
-
447
- // src/provider-compats/deepseek.ts
448
- var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
1215
+ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer3 {
449
1216
  constructor(model) {
450
1217
  super(model);
451
1218
  }
@@ -456,21 +1223,21 @@ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
456
1223
  return this.getModel().modelId.includes("deepseek") && !this.getModel().modelId.includes("r1");
457
1224
  }
458
1225
  processZodType(value) {
459
- if (isOptional(value)) {
1226
+ if (isOptional2(z)(value)) {
460
1227
  return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
461
- } else if (isObj(value)) {
1228
+ } else if (isObj2(z)(value)) {
462
1229
  return this.defaultZodObjectHandler(value);
463
- } else if (isArr(value)) {
1230
+ } else if (isArr2(z)(value)) {
464
1231
  return this.defaultZodArrayHandler(value, ["min", "max"]);
465
- } else if (isUnion(value)) {
1232
+ } else if (isUnion2(z)(value)) {
466
1233
  return this.defaultZodUnionHandler(value);
467
- } else if (isString(value)) {
1234
+ } else if (isString2(z)(value)) {
468
1235
  return this.defaultZodStringHandler(value);
469
1236
  }
470
1237
  return value;
471
1238
  }
472
1239
  };
473
- var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
1240
+ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer3 {
474
1241
  constructor(model) {
475
1242
  super(model);
476
1243
  }
@@ -481,34 +1248,25 @@ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
481
1248
  return this.getModel().provider.includes("google") || this.getModel().modelId.includes("google");
482
1249
  }
483
1250
  processZodType(value) {
484
- if (isOptional(value)) {
485
- return this.defaultZodOptionalHandler(value, [
486
- "ZodObject",
487
- "ZodArray",
488
- "ZodUnion",
489
- "ZodString",
490
- "ZodNumber",
491
- ...UNSUPPORTED_ZOD_TYPES
492
- ]);
493
- } else if (isNull(value)) {
494
- return z.any().refine((v) => v === null, { message: "must be null" }).describe(value._def.description || "must be null");
495
- } else if (isObj(value)) {
1251
+ if (isOptional2(z)(value)) {
1252
+ return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
1253
+ } else if (isNull(z)(value)) {
1254
+ return z.any().refine((v) => v === null, { message: "must be null" }).describe(value.description || "must be null");
1255
+ } else if (isObj2(z)(value)) {
496
1256
  return this.defaultZodObjectHandler(value);
497
- } else if (isArr(value)) {
1257
+ } else if (isArr2(z)(value)) {
498
1258
  return this.defaultZodArrayHandler(value, []);
499
- } else if (isUnion(value)) {
1259
+ } else if (isUnion2(z)(value)) {
500
1260
  return this.defaultZodUnionHandler(value);
501
- } else if (isString(value)) {
1261
+ } else if (isString2(z)(value)) {
502
1262
  return this.defaultZodStringHandler(value);
503
- } else if (isNumber(value)) {
1263
+ } else if (isNumber2(z)(value)) {
504
1264
  return this.defaultZodNumberHandler(value);
505
1265
  }
506
1266
  return this.defaultUnsupportedZodTypeHandler(value);
507
1267
  }
508
1268
  };
509
-
510
- // src/provider-compats/meta.ts
511
- var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
1269
+ var MetaSchemaCompatLayer = class extends SchemaCompatLayer3 {
512
1270
  constructor(model) {
513
1271
  super(model);
514
1272
  }
@@ -519,25 +1277,23 @@ var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
519
1277
  return this.getModel().modelId.includes("meta");
520
1278
  }
521
1279
  processZodType(value) {
522
- if (isOptional(value)) {
1280
+ if (isOptional2(z)(value)) {
523
1281
  return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
524
- } else if (isObj(value)) {
1282
+ } else if (isObj2(z)(value)) {
525
1283
  return this.defaultZodObjectHandler(value);
526
- } else if (isArr(value)) {
1284
+ } else if (isArr2(z)(value)) {
527
1285
  return this.defaultZodArrayHandler(value, ["min", "max"]);
528
- } else if (isUnion(value)) {
1286
+ } else if (isUnion2(z)(value)) {
529
1287
  return this.defaultZodUnionHandler(value);
530
- } else if (isNumber(value)) {
1288
+ } else if (isNumber2(z)(value)) {
531
1289
  return this.defaultZodNumberHandler(value);
532
- } else if (isString(value)) {
1290
+ } else if (isString2(z)(value)) {
533
1291
  return this.defaultZodStringHandler(value);
534
1292
  }
535
1293
  return value;
536
1294
  }
537
1295
  };
538
-
539
- // src/provider-compats/openai.ts
540
- var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
1296
+ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer3 {
541
1297
  constructor(model) {
542
1298
  super(model);
543
1299
  }
@@ -551,7 +1307,7 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
551
1307
  return false;
552
1308
  }
553
1309
  processZodType(value) {
554
- if (isOptional(value)) {
1310
+ if (isOptional2(z)(value)) {
555
1311
  return this.defaultZodOptionalHandler(value, [
556
1312
  "ZodObject",
557
1313
  "ZodArray",
@@ -561,24 +1317,28 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
561
1317
  "ZodUndefined",
562
1318
  "ZodTuple"
563
1319
  ]);
564
- } else if (isObj(value)) {
1320
+ } else if (isObj2(z)(value)) {
565
1321
  return this.defaultZodObjectHandler(value);
566
- } else if (isUnion(value)) {
1322
+ } else if (isUnion2(z)(value)) {
567
1323
  return this.defaultZodUnionHandler(value);
568
- } else if (isArr(value)) {
1324
+ } else if (isArr2(z)(value)) {
569
1325
  return this.defaultZodArrayHandler(value);
570
- } else if (isString(value)) {
1326
+ } else if (isString2(z)(value)) {
571
1327
  const model = this.getModel();
572
1328
  const checks = ["emoji"];
573
1329
  if (model.modelId.includes("gpt-4o-mini")) {
574
- checks.push("regex");
1330
+ return this.defaultZodStringHandler(value, ["emoji", "regex"]);
575
1331
  }
576
1332
  return this.defaultZodStringHandler(value, checks);
577
1333
  }
578
- return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodUndefined", "ZodTuple"]);
1334
+ return this.defaultUnsupportedZodTypeHandler(value, [
1335
+ "ZodNever",
1336
+ "ZodUndefined",
1337
+ "ZodTuple"
1338
+ ]);
579
1339
  }
580
1340
  };
581
- var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
1341
+ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer3 {
582
1342
  constructor(model) {
583
1343
  super(model);
584
1344
  }
@@ -595,16 +1355,16 @@ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
595
1355
  return false;
596
1356
  }
597
1357
  processZodType(value) {
598
- if (isOptional(value)) {
1358
+ if (isOptional2(z)(value)) {
599
1359
  const innerZodType = this.processZodType(value._def.innerType);
600
1360
  return innerZodType.nullable();
601
- } else if (isObj(value)) {
1361
+ } else if (isObj2(z)(value)) {
602
1362
  return this.defaultZodObjectHandler(value, { passthrough: false });
603
- } else if (isArr(value)) {
1363
+ } else if (isArr2(z)(value)) {
604
1364
  return this.defaultZodArrayHandler(value);
605
- } else if (isUnion(value)) {
1365
+ } else if (isUnion2(z)(value)) {
606
1366
  return this.defaultZodUnionHandler(value);
607
- } else if (isDefault(value)) {
1367
+ } else if (isDefault(z)(value)) {
608
1368
  const defaultDef = value._def;
609
1369
  const innerType = defaultDef.innerType;
610
1370
  const defaultValue = defaultDef.defaultValue();
@@ -618,13 +1378,13 @@ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
618
1378
  result = result.describe(description);
619
1379
  }
620
1380
  return result;
621
- } else if (isNumber(value)) {
1381
+ } else if (isNumber2(z)(value)) {
622
1382
  return this.defaultZodNumberHandler(value);
623
- } else if (isString(value)) {
1383
+ } else if (isString2(z)(value)) {
624
1384
  return this.defaultZodStringHandler(value);
625
- } else if (isDate(value)) {
1385
+ } else if (isDate(z)(value)) {
626
1386
  return this.defaultZodDateHandler(value);
627
- } else if (value._def.typeName === "ZodAny") {
1387
+ } else if (value.constructor.name === "ZodAny") {
628
1388
  return z.string().describe(
629
1389
  (value.description ?? "") + `
630
1390
  Argument was an "any" type, but you (the LLM) do not support "any", so it was cast to a "string" type`
@@ -634,6 +1394,6 @@ Argument was an "any" type, but you (the LLM) do not support "any", so it was ca
634
1394
  }
635
1395
  };
636
1396
 
637
- export { ALL_ARRAY_CHECKS, ALL_NUMBER_CHECKS, ALL_STRING_CHECKS, ALL_ZOD_TYPES, AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, GoogleSchemaCompatLayer, MetaSchemaCompatLayer, OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, SUPPORTED_ZOD_TYPES, SchemaCompatLayer, UNSUPPORTED_ZOD_TYPES, applyCompatLayer, convertSchemaToZod, convertZodSchemaToAISDKSchema, isArr, isNumber, isObj, isOptional, isString, isUnion };
1397
+ export { ALL_ARRAY_CHECKS, ALL_NUMBER_CHECKS, ALL_STRING_CHECKS, ALL_ZOD_TYPES, AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, GoogleSchemaCompatLayer, MetaSchemaCompatLayer, OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, SUPPORTED_ZOD_TYPES, SchemaCompatLayer3 as SchemaCompatLayer, SchemaCompatLayer as SchemaCompatLayerV3, SchemaCompatLayer2 as SchemaCompatLayerV4, UNSUPPORTED_ZOD_TYPES, applyCompatLayer, convertSchemaToZod, convertZodSchemaToAISDKSchema, isArr, isNumber, isObj, isOptional, isString, isUnion };
638
1398
  //# sourceMappingURL=index.js.map
639
1399
  //# sourceMappingURL=index.js.map