@mastra/schema-compat 0.0.0-fix-fetching-workflow-snapshots-20250625000954 → 0.0.0-fix-zod-to-json-schema-ref-strategy-20250910193441

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 (65) hide show
  1. package/CHANGELOG.md +139 -1
  2. package/LICENSE.md +11 -42
  3. package/README.md +0 -4
  4. package/dist/chunk-7YUR5KZ5.cjs +34 -0
  5. package/dist/chunk-7YUR5KZ5.cjs.map +1 -0
  6. package/dist/chunk-GWTUXMDD.js +28 -0
  7. package/dist/chunk-GWTUXMDD.js.map +1 -0
  8. package/dist/index.cjs +847 -85
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +11 -31
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +846 -86
  13. package/dist/index.js.map +1 -0
  14. package/dist/provider-compats/anthropic.d.ts +13 -0
  15. package/dist/provider-compats/anthropic.d.ts.map +1 -0
  16. package/dist/provider-compats/deepseek.d.ts +13 -0
  17. package/dist/provider-compats/deepseek.d.ts.map +1 -0
  18. package/dist/provider-compats/google.d.ts +13 -0
  19. package/dist/provider-compats/google.d.ts.map +1 -0
  20. package/dist/provider-compats/meta.d.ts +13 -0
  21. package/dist/provider-compats/meta.d.ts.map +1 -0
  22. package/dist/provider-compats/openai-reasoning.d.ts +14 -0
  23. package/dist/provider-compats/openai-reasoning.d.ts.map +1 -0
  24. package/dist/provider-compats/openai.d.ts +13 -0
  25. package/dist/provider-compats/openai.d.ts.map +1 -0
  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 +228 -0
  31. package/dist/schema-compatibility.d.ts.map +1 -0
  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 +96 -0
  37. package/dist/utils.d.ts.map +1 -0
  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 +37 -13
  47. package/.turbo/turbo-build.log +0 -23
  48. package/dist/_tsup-dts-rollup.d.cts +0 -504
  49. package/dist/_tsup-dts-rollup.d.ts +0 -504
  50. package/dist/index.d.cts +0 -31
  51. package/eslint.config.js +0 -6
  52. package/src/index.ts +0 -39
  53. package/src/provider-compats/anthropic.ts +0 -44
  54. package/src/provider-compats/deepseek.ts +0 -35
  55. package/src/provider-compats/google.ts +0 -55
  56. package/src/provider-compats/meta.ts +0 -36
  57. package/src/provider-compats/openai-reasoning.ts +0 -87
  58. package/src/provider-compats/openai.ts +0 -56
  59. package/src/provider-compats.test.ts +0 -312
  60. package/src/schema-compatibility.test.ts +0 -471
  61. package/src/schema-compatibility.ts +0 -587
  62. package/src/utils.test.ts +0 -434
  63. package/src/utils.ts +0 -205
  64. package/tsconfig.json +0 -5
  65. package/vitest.config.ts +0 -7
package/dist/index.js CHANGED
@@ -1,22 +1,18 @@
1
- import { ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, z, ZodDefault, ZodDate } from 'zod';
1
+ import { zodToJsonSchema } from './chunk-GWTUXMDD.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",
@@ -75,8 +75,6 @@ var isArr = (v) => v instanceof ZodArray;
75
75
  var isUnion = (v) => v instanceof ZodUnion;
76
76
  var isString = (v) => v instanceof ZodString;
77
77
  var isNumber = (v) => v instanceof ZodNumber;
78
- var isDate = (v) => v instanceof ZodDate;
79
- var isDefault = (v) => v instanceof ZodDefault;
80
78
  var UNSUPPORTED_ZOD_TYPES = ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
81
79
  var SUPPORTED_ZOD_TYPES = [
82
80
  "ZodObject",
@@ -91,13 +89,15 @@ var SUPPORTED_ZOD_TYPES = [
91
89
  var ALL_ZOD_TYPES = [...SUPPORTED_ZOD_TYPES, ...UNSUPPORTED_ZOD_TYPES];
92
90
  var SchemaCompatLayer = class {
93
91
  model;
92
+ parent;
94
93
  /**
95
94
  * Creates a new schema compatibility instance.
96
95
  *
97
96
  * @param model - The language model this compatibility layer applies to
98
97
  */
99
- constructor(model) {
98
+ constructor(model, parent) {
100
99
  this.model = model;
100
+ this.parent = parent;
101
101
  }
102
102
  /**
103
103
  * Gets the language model associated with this compatibility layer.
@@ -107,6 +107,91 @@ var SchemaCompatLayer = class {
107
107
  getModel() {
108
108
  return this.model;
109
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
+ }
110
195
  /**
111
196
  * Default handler for Zod object types. Recursively processes all properties in the object.
112
197
  *
@@ -159,8 +244,8 @@ var SchemaCompatLayer = class {
159
244
  * @throws Error if the type is in the unsupported list
160
245
  */
161
246
  defaultUnsupportedZodTypeHandler(value, throwOnTypes = UNSUPPORTED_ZOD_TYPES) {
162
- if (throwOnTypes.includes(value._def.typeName)) {
163
- throw new Error(`${this.model.modelId} does not support zod type: ${value._def.typeName}`);
247
+ if (throwOnTypes.includes(value._def?.typeName)) {
248
+ throw new Error(`${this.model.modelId} does not support zod type: ${value._def?.typeName}`);
164
249
  }
165
250
  return value;
166
251
  }
@@ -412,9 +497,680 @@ var SchemaCompatLayer = class {
412
497
  return this.processToAISDKSchema(zodSchema).jsonSchema;
413
498
  }
414
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
+ }
415
1171
 
416
1172
  // src/provider-compats/anthropic.ts
417
- var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
1173
+ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer3 {
418
1174
  constructor(model) {
419
1175
  super(model);
420
1176
  }
@@ -425,29 +1181,38 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
425
1181
  return this.getModel().modelId.includes("claude");
426
1182
  }
427
1183
  processZodType(value) {
428
- if (isOptional(value)) {
429
- 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
+ ];
430
1193
  if (this.getModel().modelId.includes("claude-3.5-haiku")) handleTypes.push("ZodString");
431
1194
  return this.defaultZodOptionalHandler(value, handleTypes);
432
- } else if (isObj(value)) {
1195
+ } else if (isObj2(z)(value)) {
433
1196
  return this.defaultZodObjectHandler(value);
434
- } else if (isArr(value)) {
1197
+ } else if (isArr2(z)(value)) {
435
1198
  return this.defaultZodArrayHandler(value, []);
436
- } else if (isUnion(value)) {
1199
+ } else if (isUnion2(z)(value)) {
437
1200
  return this.defaultZodUnionHandler(value);
438
- } else if (isString(value)) {
1201
+ } else if (isString2(z)(value)) {
439
1202
  if (this.getModel().modelId.includes("claude-3.5-haiku")) {
440
1203
  return this.defaultZodStringHandler(value, ["max", "min"]);
441
1204
  } else {
442
1205
  return value;
443
1206
  }
444
1207
  }
445
- return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodTuple", "ZodUndefined"]);
1208
+ return this.defaultUnsupportedZodTypeHandler(value, [
1209
+ "ZodNever",
1210
+ "ZodTuple",
1211
+ "ZodUndefined"
1212
+ ]);
446
1213
  }
447
1214
  };
448
-
449
- // src/provider-compats/deepseek.ts
450
- var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
1215
+ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer3 {
451
1216
  constructor(model) {
452
1217
  super(model);
453
1218
  }
@@ -458,23 +1223,21 @@ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
458
1223
  return this.getModel().modelId.includes("deepseek") && !this.getModel().modelId.includes("r1");
459
1224
  }
460
1225
  processZodType(value) {
461
- if (isOptional(value)) {
1226
+ if (isOptional2(z)(value)) {
462
1227
  return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
463
- } else if (isObj(value)) {
1228
+ } else if (isObj2(z)(value)) {
464
1229
  return this.defaultZodObjectHandler(value);
465
- } else if (isArr(value)) {
1230
+ } else if (isArr2(z)(value)) {
466
1231
  return this.defaultZodArrayHandler(value, ["min", "max"]);
467
- } else if (isUnion(value)) {
1232
+ } else if (isUnion2(z)(value)) {
468
1233
  return this.defaultZodUnionHandler(value);
469
- } else if (isString(value)) {
1234
+ } else if (isString2(z)(value)) {
470
1235
  return this.defaultZodStringHandler(value);
471
1236
  }
472
1237
  return value;
473
1238
  }
474
1239
  };
475
-
476
- // src/provider-compats/google.ts
477
- var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
1240
+ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer3 {
478
1241
  constructor(model) {
479
1242
  super(model);
480
1243
  }
@@ -485,32 +1248,25 @@ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
485
1248
  return this.getModel().provider.includes("google") || this.getModel().modelId.includes("google");
486
1249
  }
487
1250
  processZodType(value) {
488
- if (isOptional(value)) {
489
- return this.defaultZodOptionalHandler(value, [
490
- "ZodObject",
491
- "ZodArray",
492
- "ZodUnion",
493
- "ZodString",
494
- "ZodNumber",
495
- ...UNSUPPORTED_ZOD_TYPES
496
- ]);
497
- } 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)) {
498
1256
  return this.defaultZodObjectHandler(value);
499
- } else if (isArr(value)) {
1257
+ } else if (isArr2(z)(value)) {
500
1258
  return this.defaultZodArrayHandler(value, []);
501
- } else if (isUnion(value)) {
1259
+ } else if (isUnion2(z)(value)) {
502
1260
  return this.defaultZodUnionHandler(value);
503
- } else if (isString(value)) {
1261
+ } else if (isString2(z)(value)) {
504
1262
  return this.defaultZodStringHandler(value);
505
- } else if (isNumber(value)) {
1263
+ } else if (isNumber2(z)(value)) {
506
1264
  return this.defaultZodNumberHandler(value);
507
1265
  }
508
1266
  return this.defaultUnsupportedZodTypeHandler(value);
509
1267
  }
510
1268
  };
511
-
512
- // src/provider-compats/meta.ts
513
- var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
1269
+ var MetaSchemaCompatLayer = class extends SchemaCompatLayer3 {
514
1270
  constructor(model) {
515
1271
  super(model);
516
1272
  }
@@ -521,25 +1277,23 @@ var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
521
1277
  return this.getModel().modelId.includes("meta");
522
1278
  }
523
1279
  processZodType(value) {
524
- if (isOptional(value)) {
1280
+ if (isOptional2(z)(value)) {
525
1281
  return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
526
- } else if (isObj(value)) {
1282
+ } else if (isObj2(z)(value)) {
527
1283
  return this.defaultZodObjectHandler(value);
528
- } else if (isArr(value)) {
1284
+ } else if (isArr2(z)(value)) {
529
1285
  return this.defaultZodArrayHandler(value, ["min", "max"]);
530
- } else if (isUnion(value)) {
1286
+ } else if (isUnion2(z)(value)) {
531
1287
  return this.defaultZodUnionHandler(value);
532
- } else if (isNumber(value)) {
1288
+ } else if (isNumber2(z)(value)) {
533
1289
  return this.defaultZodNumberHandler(value);
534
- } else if (isString(value)) {
1290
+ } else if (isString2(z)(value)) {
535
1291
  return this.defaultZodStringHandler(value);
536
1292
  }
537
1293
  return value;
538
1294
  }
539
1295
  };
540
-
541
- // src/provider-compats/openai.ts
542
- var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
1296
+ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer3 {
543
1297
  constructor(model) {
544
1298
  super(model);
545
1299
  }
@@ -553,7 +1307,7 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
553
1307
  return false;
554
1308
  }
555
1309
  processZodType(value) {
556
- if (isOptional(value)) {
1310
+ if (isOptional2(z)(value)) {
557
1311
  return this.defaultZodOptionalHandler(value, [
558
1312
  "ZodObject",
559
1313
  "ZodArray",
@@ -563,24 +1317,28 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
563
1317
  "ZodUndefined",
564
1318
  "ZodTuple"
565
1319
  ]);
566
- } else if (isObj(value)) {
1320
+ } else if (isObj2(z)(value)) {
567
1321
  return this.defaultZodObjectHandler(value);
568
- } else if (isUnion(value)) {
1322
+ } else if (isUnion2(z)(value)) {
569
1323
  return this.defaultZodUnionHandler(value);
570
- } else if (isArr(value)) {
1324
+ } else if (isArr2(z)(value)) {
571
1325
  return this.defaultZodArrayHandler(value);
572
- } else if (isString(value)) {
1326
+ } else if (isString2(z)(value)) {
573
1327
  const model = this.getModel();
574
1328
  const checks = ["emoji"];
575
1329
  if (model.modelId.includes("gpt-4o-mini")) {
576
- checks.push("regex");
1330
+ return this.defaultZodStringHandler(value, ["emoji", "regex"]);
577
1331
  }
578
1332
  return this.defaultZodStringHandler(value, checks);
579
1333
  }
580
- return this.defaultUnsupportedZodTypeHandler(value, ["ZodNever", "ZodUndefined", "ZodTuple"]);
1334
+ return this.defaultUnsupportedZodTypeHandler(value, [
1335
+ "ZodNever",
1336
+ "ZodUndefined",
1337
+ "ZodTuple"
1338
+ ]);
581
1339
  }
582
1340
  };
583
- var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
1341
+ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer3 {
584
1342
  constructor(model) {
585
1343
  super(model);
586
1344
  }
@@ -588,7 +1346,7 @@ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
588
1346
  return `openApi3`;
589
1347
  }
590
1348
  isReasoningModel() {
591
- return this.getModel().modelId.includes(`o3`) || this.getModel().modelId.includes(`o4`);
1349
+ return this.getModel().modelId.includes(`o3`) || this.getModel().modelId.includes(`o4`) || this.getModel().modelId.includes(`o1`);
592
1350
  }
593
1351
  shouldApply() {
594
1352
  if ((this.getModel().supportsStructuredOutputs || this.isReasoningModel()) && (this.getModel().provider.includes(`openai`) || this.getModel().modelId.includes(`openai`))) {
@@ -597,16 +1355,16 @@ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
597
1355
  return false;
598
1356
  }
599
1357
  processZodType(value) {
600
- if (isOptional(value)) {
1358
+ if (isOptional2(z)(value)) {
601
1359
  const innerZodType = this.processZodType(value._def.innerType);
602
1360
  return innerZodType.nullable();
603
- } else if (isObj(value)) {
1361
+ } else if (isObj2(z)(value)) {
604
1362
  return this.defaultZodObjectHandler(value, { passthrough: false });
605
- } else if (isArr(value)) {
1363
+ } else if (isArr2(z)(value)) {
606
1364
  return this.defaultZodArrayHandler(value);
607
- } else if (isUnion(value)) {
1365
+ } else if (isUnion2(z)(value)) {
608
1366
  return this.defaultZodUnionHandler(value);
609
- } else if (isDefault(value)) {
1367
+ } else if (isDefault(z)(value)) {
610
1368
  const defaultDef = value._def;
611
1369
  const innerType = defaultDef.innerType;
612
1370
  const defaultValue = defaultDef.defaultValue();
@@ -620,13 +1378,13 @@ var OpenAIReasoningSchemaCompatLayer = class extends SchemaCompatLayer {
620
1378
  result = result.describe(description);
621
1379
  }
622
1380
  return result;
623
- } else if (isNumber(value)) {
1381
+ } else if (isNumber2(z)(value)) {
624
1382
  return this.defaultZodNumberHandler(value);
625
- } else if (isString(value)) {
1383
+ } else if (isString2(z)(value)) {
626
1384
  return this.defaultZodStringHandler(value);
627
- } else if (isDate(value)) {
1385
+ } else if (isDate(z)(value)) {
628
1386
  return this.defaultZodDateHandler(value);
629
- } else if (value._def.typeName === "ZodAny") {
1387
+ } else if (value.constructor.name === "ZodAny") {
630
1388
  return z.string().describe(
631
1389
  (value.description ?? "") + `
632
1390
  Argument was an "any" type, but you (the LLM) do not support "any", so it was cast to a "string" type`
@@ -636,4 +1394,6 @@ Argument was an "any" type, but you (the LLM) do not support "any", so it was ca
636
1394
  }
637
1395
  };
638
1396
 
639
- 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 };
1398
+ //# sourceMappingURL=index.js.map
1399
+ //# sourceMappingURL=index.js.map