@mastra/schema-compat 0.0.0-fix-fetch-workflow-runs-20250624231457 → 0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806184630

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/provider-compats/google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,iBAAiB,EASlB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAiC9C"}
@@ -0,0 +1,11 @@
1
+ import type { LanguageModelV1 } from 'ai';
2
+ import type { ZodTypeAny } from 'zod';
3
+ import type { Targets } from 'zod-to-json-schema';
4
+ import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ export declare class MetaSchemaCompatLayer extends SchemaCompatLayer {
6
+ constructor(model: LanguageModelV1);
7
+ getSchemaTarget(): Targets | undefined;
8
+ shouldApply(): boolean;
9
+ processZodType(value: ZodTypeAny): ZodTypeAny;
10
+ }
11
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/provider-compats/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAyD,MAAM,yBAAyB,CAAC;AAEnH,qBAAa,qBAAsB,SAAQ,iBAAiB;gBAC9C,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAiB9C"}
@@ -0,0 +1,12 @@
1
+ import type { LanguageModelV1 } from 'ai';
2
+ import type { ZodTypeAny } from 'zod';
3
+ import type { Targets } from 'zod-to-json-schema';
4
+ import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ export declare class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {
6
+ constructor(model: LanguageModelV1);
7
+ getSchemaTarget(): Targets | undefined;
8
+ isReasoningModel(): boolean;
9
+ shouldApply(): boolean;
10
+ processZodType(value: ZodTypeAny): ZodTypeAny;
11
+ }
12
+ //# sourceMappingURL=openai-reasoning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-reasoning.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai-reasoning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,iBAAiB,EASlB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,gCAAiC,SAAQ,iBAAiB;gBACzD,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,gBAAgB,IAAI,OAAO;IAU3B,WAAW,IAAI,OAAO;IAWtB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CA4C9C"}
@@ -0,0 +1,11 @@
1
+ import type { LanguageModelV1 } from 'ai';
2
+ import type { ZodTypeAny } from 'zod';
3
+ import type { Targets } from 'zod-to-json-schema';
4
+ import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ export declare class OpenAISchemaCompatLayer extends SchemaCompatLayer {
6
+ constructor(model: LanguageModelV1);
7
+ getSchemaTarget(): Targets | undefined;
8
+ shouldApply(): boolean;
9
+ processZodType(value: ZodTypeAny): ZodTypeAny;
10
+ }
11
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA+C,MAAM,yBAAyB,CAAC;AAGzG,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAWtB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CA6B9C"}
@@ -0,0 +1,280 @@
1
+ import type { Schema, LanguageModelV1 } from 'ai';
2
+ import type { JSONSchema7 } from 'json-schema';
3
+ import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod';
4
+ import type { ZodTypeAny } from 'zod';
5
+ import type { Targets } from 'zod-to-json-schema';
6
+ /**
7
+ * All supported string validation check types that can be processed or converted to descriptions.
8
+ * @constant
9
+ */
10
+ export declare const ALL_STRING_CHECKS: readonly ["regex", "emoji", "email", "url", "uuid", "cuid", "min", "max"];
11
+ /**
12
+ * All supported number validation check types that can be processed or converted to descriptions.
13
+ * @constant
14
+ */
15
+ export declare const ALL_NUMBER_CHECKS: readonly ["min", "max", "multipleOf"];
16
+ /**
17
+ * All supported array validation check types that can be processed or converted to descriptions.
18
+ * @constant
19
+ */
20
+ export declare const ALL_ARRAY_CHECKS: readonly ["min", "max", "length"];
21
+ export declare const isOptional: (v: ZodTypeAny) => v is ZodOptional<any>;
22
+ export declare const isObj: (v: ZodTypeAny) => v is ZodObject<any, any, any>;
23
+ export declare const isNull: (v: ZodTypeAny) => v is ZodNull;
24
+ export declare const isArr: (v: ZodTypeAny) => v is ZodArray<any, any>;
25
+ export declare const isUnion: (v: ZodTypeAny) => v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>;
26
+ export declare const isString: (v: ZodTypeAny) => v is ZodString;
27
+ export declare const isNumber: (v: ZodTypeAny) => v is ZodNumber;
28
+ export declare const isDate: (v: ZodTypeAny) => v is ZodDate;
29
+ export declare const isDefault: (v: ZodTypeAny) => v is ZodDefault<any>;
30
+ /**
31
+ * Zod types that are not supported by most AI model providers and should be avoided.
32
+ * @constant
33
+ */
34
+ export declare const UNSUPPORTED_ZOD_TYPES: readonly ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
35
+ /**
36
+ * Zod types that are generally supported by AI model providers.
37
+ * @constant
38
+ */
39
+ export declare const SUPPORTED_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault"];
40
+ /**
41
+ * All Zod types (both supported and unsupported).
42
+ * @constant
43
+ */
44
+ export declare const ALL_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault", "ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
45
+ /**
46
+ * Type representing string validation checks.
47
+ */
48
+ export type StringCheckType = (typeof ALL_STRING_CHECKS)[number];
49
+ /**
50
+ * Type representing number validation checks.
51
+ */
52
+ export type NumberCheckType = (typeof ALL_NUMBER_CHECKS)[number];
53
+ /**
54
+ * Type representing array validation checks.
55
+ */
56
+ export type ArrayCheckType = (typeof ALL_ARRAY_CHECKS)[number];
57
+ /**
58
+ * Type representing unsupported Zod schema types.
59
+ */
60
+ export type UnsupportedZodType = (typeof UNSUPPORTED_ZOD_TYPES)[number];
61
+ /**
62
+ * Type representing supported Zod schema types.
63
+ */
64
+ export type SupportedZodType = (typeof SUPPORTED_ZOD_TYPES)[number];
65
+ /**
66
+ * Type representing all Zod schema types (supported and unsupported).
67
+ */
68
+ export type AllZodType = (typeof ALL_ZOD_TYPES)[number];
69
+ /**
70
+ * Utility type to extract the shape of a Zod object schema.
71
+ */
72
+ export type ZodShape<T extends z.AnyZodObject> = T['shape'];
73
+ /**
74
+ * Utility type to extract the keys from a Zod object shape.
75
+ */
76
+ export type ShapeKey<T extends z.AnyZodObject> = keyof ZodShape<T>;
77
+ /**
78
+ * Utility type to extract the value types from a Zod object shape.
79
+ */
80
+ export type ShapeValue<T extends z.AnyZodObject> = ZodShape<T>[ShapeKey<T>];
81
+ type StringConstraints = {
82
+ minLength?: number;
83
+ maxLength?: number;
84
+ email?: boolean;
85
+ url?: boolean;
86
+ uuid?: boolean;
87
+ cuid?: boolean;
88
+ emoji?: boolean;
89
+ regex?: {
90
+ pattern: string;
91
+ flags?: string;
92
+ };
93
+ };
94
+ type NumberConstraints = {
95
+ gt?: number;
96
+ gte?: number;
97
+ lt?: number;
98
+ lte?: number;
99
+ multipleOf?: number;
100
+ };
101
+ type ArrayConstraints = {
102
+ minLength?: number;
103
+ maxLength?: number;
104
+ exactLength?: number;
105
+ };
106
+ type DateConstraints = {
107
+ minDate?: string;
108
+ maxDate?: string;
109
+ dateFormat?: string;
110
+ };
111
+ /**
112
+ * Abstract base class for creating schema compatibility layers for different AI model providers.
113
+ *
114
+ * This class provides a framework for transforming Zod schemas to work with specific AI model
115
+ * provider requirements and limitations. Each provider may have different support levels for
116
+ * JSON Schema features, validation constraints, and data types.
117
+ *
118
+ * @abstract
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * import { SchemaCompatLayer } from '@mastra/schema-compat';
123
+ * import type { LanguageModelV1 } from 'ai';
124
+ *
125
+ * class CustomProviderCompat extends SchemaCompatLayer {
126
+ * constructor(model: LanguageModelV1) {
127
+ * super(model);
128
+ * }
129
+ *
130
+ * shouldApply(): boolean {
131
+ * return this.getModel().provider === 'custom-provider';
132
+ * }
133
+ *
134
+ * getSchemaTarget() {
135
+ * return 'jsonSchema7';
136
+ * }
137
+ *
138
+ * processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T> {
139
+ * // Custom processing logic for this provider
140
+ * switch (value._def.typeName) {
141
+ * case 'ZodString':
142
+ * return this.defaultZodStringHandler(value, ['email', 'url']);
143
+ * default:
144
+ * return this.defaultUnsupportedZodTypeHandler(value);
145
+ * }
146
+ * }
147
+ * }
148
+ * ```
149
+ */
150
+ export declare abstract class SchemaCompatLayer {
151
+ private model;
152
+ /**
153
+ * Creates a new schema compatibility instance.
154
+ *
155
+ * @param model - The language model this compatibility layer applies to
156
+ */
157
+ constructor(model: LanguageModelV1);
158
+ /**
159
+ * Gets the language model associated with this compatibility layer.
160
+ *
161
+ * @returns The language model instance
162
+ */
163
+ getModel(): LanguageModelV1;
164
+ /**
165
+ * Determines whether this compatibility layer should be applied for the current model.
166
+ *
167
+ * @returns True if this compatibility layer should be used, false otherwise
168
+ * @abstract
169
+ */
170
+ abstract shouldApply(): boolean;
171
+ /**
172
+ * Returns the JSON Schema target format for this provider.
173
+ *
174
+ * @returns The schema target format, or undefined to use the default 'jsonSchema7'
175
+ * @abstract
176
+ */
177
+ abstract getSchemaTarget(): Targets | undefined;
178
+ /**
179
+ * Processes a specific Zod type according to the provider's requirements.
180
+ *
181
+ * @param value - The Zod type to process
182
+ * @returns The processed Zod type
183
+ * @abstract
184
+ */
185
+ abstract processZodType(value: ZodTypeAny): ZodTypeAny;
186
+ /**
187
+ * Default handler for Zod object types. Recursively processes all properties in the object.
188
+ *
189
+ * @param value - The Zod object to process
190
+ * @returns The processed Zod object
191
+ */
192
+ defaultZodObjectHandler(value: ZodObject<any, any, any>, options?: {
193
+ passthrough?: boolean;
194
+ }): ZodObject<any, any, any>;
195
+ /**
196
+ * Merges validation constraints into a parameter description.
197
+ *
198
+ * This helper method converts validation constraints that may not be supported
199
+ * by a provider into human-readable descriptions.
200
+ *
201
+ * @param description - The existing parameter description
202
+ * @param constraints - The validation constraints to merge
203
+ * @returns The updated description with constraints, or undefined if no constraints
204
+ */
205
+ mergeParameterDescription(description: string | undefined, constraints: NumberConstraints | StringConstraints | ArrayConstraints | DateConstraints | {
206
+ defaultValue?: unknown;
207
+ }): string | undefined;
208
+ /**
209
+ * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
210
+ *
211
+ * @param value - The Zod type to check
212
+ * @param throwOnTypes - Array of type names to throw errors for
213
+ * @returns The original value if not in the throw list
214
+ * @throws Error if the type is in the unsupported list
215
+ */
216
+ defaultUnsupportedZodTypeHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny, throwOnTypes?: readonly UnsupportedZodType[]): ShapeValue<T>;
217
+ /**
218
+ * Default handler for Zod array types. Processes array constraints according to provider support.
219
+ *
220
+ * @param value - The Zod array to process
221
+ * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
222
+ * @returns The processed Zod array
223
+ */
224
+ defaultZodArrayHandler(value: ZodArray<any, any>, handleChecks?: readonly ArrayCheckType[]): ZodArray<any, any>;
225
+ /**
226
+ * Default handler for Zod union types. Processes all union options.
227
+ *
228
+ * @param value - The Zod union to process
229
+ * @returns The processed Zod union
230
+ * @throws Error if union has fewer than 2 options
231
+ */
232
+ defaultZodUnionHandler(value: ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>): ZodTypeAny;
233
+ /**
234
+ * Default handler for Zod string types. Processes string validation constraints.
235
+ *
236
+ * @param value - The Zod string to process
237
+ * @param handleChecks - String constraints to convert to descriptions vs keep as validation
238
+ * @returns The processed Zod string
239
+ */
240
+ defaultZodStringHandler(value: ZodString, handleChecks?: readonly StringCheckType[]): ZodString;
241
+ /**
242
+ * Default handler for Zod number types. Processes number validation constraints.
243
+ *
244
+ * @param value - The Zod number to process
245
+ * @param handleChecks - Number constraints to convert to descriptions vs keep as validation
246
+ * @returns The processed Zod number
247
+ */
248
+ defaultZodNumberHandler(value: ZodNumber, handleChecks?: readonly NumberCheckType[]): ZodNumber;
249
+ /**
250
+ * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
251
+ *
252
+ * @param value - The Zod date to process
253
+ * @returns A Zod string schema representing the date in ISO format
254
+ */
255
+ defaultZodDateHandler(value: ZodDate): ZodString;
256
+ /**
257
+ * Default handler for Zod optional types. Processes the inner type and maintains optionality.
258
+ *
259
+ * @param value - The Zod optional to process
260
+ * @param handleTypes - Types that should be processed vs passed through
261
+ * @returns The processed Zod optional
262
+ */
263
+ defaultZodOptionalHandler(value: ZodOptional<any>, handleTypes?: readonly AllZodType[]): ZodTypeAny;
264
+ /**
265
+ * Processes a Zod object schema and converts it to an AI SDK Schema.
266
+ *
267
+ * @param zodSchema - The Zod object schema to process
268
+ * @returns An AI SDK Schema with provider-specific compatibility applied
269
+ */
270
+ processToAISDKSchema(zodSchema: z.ZodSchema): Schema;
271
+ /**
272
+ * Processes a Zod object schema and converts it to a JSON Schema.
273
+ *
274
+ * @param zodSchema - The Zod object schema to process
275
+ * @returns A JSONSchema7 object with provider-specific compatibility applied
276
+ */
277
+ processToJSONSchema(zodSchema: z.ZodSchema): JSONSchema7;
278
+ }
279
+ export {};
280
+ //# sourceMappingURL=schema-compatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-compatibility.d.ts","sourceRoot":"","sources":["../src/schema-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,Q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OAKG;IACI,oBAAoB,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,MAAM;IAM3D;;;;;OAKG;IACI,mBAAmB,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,WAAW;CAGhE"}
@@ -0,0 +1,84 @@
1
+ import type { Schema } from 'ai';
2
+ import type { JSONSchema7 } from 'json-schema';
3
+ import type { z, ZodSchema } from 'zod';
4
+ import type { Targets } from 'zod-to-json-schema';
5
+ import type { SchemaCompatLayer } from './schema-compatibility.js';
6
+ /**
7
+ * Converts a Zod schema to an AI SDK Schema with validation support.
8
+ *
9
+ * This function mirrors the behavior of Vercel's AI SDK zod-schema utility but allows
10
+ * customization of the JSON Schema target format.
11
+ *
12
+ * @param zodSchema - The Zod schema to convert
13
+ * @param target - The JSON Schema target format (defaults to 'jsonSchema7')
14
+ * @returns An AI SDK Schema object with built-in validation
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { z } from 'zod';
19
+ * import { convertZodSchemaToAISDKSchema } from '@mastra/schema-compat';
20
+ *
21
+ * const userSchema = z.object({
22
+ * name: z.string(),
23
+ * age: z.number().min(0)
24
+ * });
25
+ *
26
+ * const aiSchema = convertZodSchemaToAISDKSchema(userSchema);
27
+ * ```
28
+ */
29
+ export declare function convertZodSchemaToAISDKSchema(zodSchema: ZodSchema, target?: Targets): Schema<any>;
30
+ /**
31
+ * Converts an AI SDK Schema or Zod schema to a Zod schema.
32
+ *
33
+ * If the input is already a Zod schema, it returns it unchanged.
34
+ * If the input is an AI SDK Schema, it extracts the JSON schema and converts it to Zod.
35
+ *
36
+ * @param schema - The schema to convert (AI SDK Schema or Zod schema)
37
+ * @returns A Zod schema equivalent of the input
38
+ * @throws Error if the conversion fails
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * import { jsonSchema } from 'ai';
43
+ * import { convertSchemaToZod } from '@mastra/schema-compat';
44
+ *
45
+ * const aiSchema = jsonSchema({
46
+ * type: 'object',
47
+ * properties: {
48
+ * name: { type: 'string' }
49
+ * }
50
+ * });
51
+ *
52
+ * const zodSchema = convertSchemaToZod(aiSchema);
53
+ * ```
54
+ */
55
+ export declare function convertSchemaToZod(schema: Schema | z.ZodSchema): z.ZodType;
56
+ /**
57
+ * Processes a schema using provider compatibility layers and converts it to an AI SDK Schema.
58
+ *
59
+ * @param options - Configuration object for schema processing
60
+ * @param options.schema - The schema to process (AI SDK Schema or Zod object schema)
61
+ * @param options.compatLayers - Array of compatibility layers to try
62
+ * @param options.mode - Must be 'aiSdkSchema'
63
+ * @returns Processed schema as an AI SDK Schema
64
+ */
65
+ export declare function applyCompatLayer(options: {
66
+ schema: Schema | z.ZodSchema;
67
+ compatLayers: SchemaCompatLayer[];
68
+ mode: 'aiSdkSchema';
69
+ }): Schema;
70
+ /**
71
+ * Processes a schema using provider compatibility layers and converts it to a JSON Schema.
72
+ *
73
+ * @param options - Configuration object for schema processing
74
+ * @param options.schema - The schema to process (AI SDK Schema or Zod object schema)
75
+ * @param options.compatLayers - Array of compatibility layers to try
76
+ * @param options.mode - Must be 'jsonSchema'
77
+ * @returns Processed schema as a JSONSchema7
78
+ */
79
+ export declare function applyCompatLayer(options: {
80
+ schema: Schema | z.ZodSchema;
81
+ compatLayers: SchemaCompatLayer[];
82
+ mode: 'jsonSchema';
83
+ }): JSONSchema7;
84
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,GAAE,OAAuB,eAalG;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,CAa1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC;IAC7B,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,IAAI,EAAE,aAAa,CAAC;CACrB,GAAG,MAAM,CAAC;AAEX;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC;IAC7B,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,IAAI,EAAE,YAAY,CAAC;CACpB,GAAG,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/schema-compat",
3
- "version": "0.0.0-fix-fetch-workflow-runs-20250624231457",
3
+ "version": "0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806184630",
4
4
  "description": "Tool schema compatibility layer for Mastra.ai",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "default": "./dist/index.js"
13
13
  },
14
14
  "require": {
15
- "types": "./dist/index.d.cts",
15
+ "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.cjs"
17
17
  }
18
18
  },
@@ -26,7 +26,7 @@
26
26
  "zod"
27
27
  ],
28
28
  "author": "",
29
- "license": "Elastic-2.0",
29
+ "license": "Apache-2.0",
30
30
  "dependencies": {
31
31
  "json-schema": "^0.4.0",
32
32
  "zod-from-json-schema": "^0.0.5",
@@ -40,16 +40,17 @@
40
40
  "@types/json-schema": "^7.0.15",
41
41
  "@types/node": "^20.19.0",
42
42
  "ai": "4.3.16",
43
- "eslint": "^9.29.0",
43
+ "eslint": "^9.30.1",
44
44
  "tsup": "^8.5.0",
45
45
  "typescript": "^5.8.3",
46
- "vitest": "^3.2.3",
46
+ "vitest": "^3.2.4",
47
47
  "zod": "^3.25.67",
48
- "@internal/lint": "0.0.0-fix-fetch-workflow-runs-20250624231457"
48
+ "@internal/types-builder": "0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806184630",
49
+ "@internal/lint": "0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806184630"
49
50
  },
50
51
  "scripts": {
51
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
52
- "build:watch": "pnpm build --watch",
52
+ "build": "tsup --silent --config tsup.config.ts",
53
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
53
54
  "test": "vitest run",
54
55
  "lint": "eslint ."
55
56
  }
@@ -1,10 +1,12 @@
1
1
  import type { LanguageModelV1 } from 'ai';
2
2
  import type { ZodTypeAny } from 'zod';
3
+ import { z } from 'zod';
3
4
  import type { Targets } from 'zod-to-json-schema';
4
5
  import {
5
6
  SchemaCompatLayer,
6
7
  UNSUPPORTED_ZOD_TYPES,
7
8
  isArr,
9
+ isNull,
8
10
  isNumber,
9
11
  isObj,
10
12
  isOptional,
@@ -35,6 +37,12 @@ export class GoogleSchemaCompatLayer extends SchemaCompatLayer {
35
37
  'ZodNumber',
36
38
  ...UNSUPPORTED_ZOD_TYPES,
37
39
  ]);
40
+ } else if (isNull(value)) {
41
+ // Google models don't support null, so we need to convert it to any and then refine it to null
42
+ return z
43
+ .any()
44
+ .refine(v => v === null, { message: 'must be null' })
45
+ .describe(value._def.description || 'must be null');
38
46
  } else if (isObj(value)) {
39
47
  return this.defaultZodObjectHandler(value);
40
48
  } else if (isArr(value)) {
@@ -26,7 +26,11 @@ export class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {
26
26
  isReasoningModel(): boolean {
27
27
  // there isn't a good way to automatically detect reasoning models besides doing this.
28
28
  // in the future when o5 is released this compat wont apply and we'll want to come back and update this class + our tests
29
- return this.getModel().modelId.includes(`o3`) || this.getModel().modelId.includes(`o4`);
29
+ return (
30
+ this.getModel().modelId.includes(`o3`) ||
31
+ this.getModel().modelId.includes(`o4`) ||
32
+ this.getModel().modelId.includes(`o1`)
33
+ );
30
34
  }
31
35
 
32
36
  shouldApply(): boolean {
@@ -1,6 +1,6 @@
1
1
  import type { Schema, LanguageModelV1 } from 'ai';
2
2
  import type { JSONSchema7 } from 'json-schema';
3
- import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault } from 'zod';
3
+ import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod';
4
4
  import type { ZodTypeAny } from 'zod';
5
5
  import type { Targets } from 'zod-to-json-schema';
6
6
  import { convertZodSchemaToAISDKSchema } from './utils';
@@ -29,6 +29,7 @@ export const ALL_ARRAY_CHECKS = ['min', 'max', 'length'] as const;
29
29
 
30
30
  export const isOptional = (v: ZodTypeAny): v is ZodOptional<any> => v instanceof ZodOptional;
31
31
  export const isObj = (v: ZodTypeAny): v is ZodObject<any, any, any> => v instanceof ZodObject;
32
+ export const isNull = (v: ZodTypeAny): v is ZodNull => v instanceof ZodNull;
32
33
  export const isArr = (v: ZodTypeAny): v is ZodArray<any, any> => v instanceof ZodArray;
33
34
  export const isUnion = (v: ZodTypeAny): v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]> => v instanceof ZodUnion;
34
35
  export const isString = (v: ZodTypeAny): v is ZodString => v instanceof ZodString;
@@ -299,8 +300,8 @@ export abstract class SchemaCompatLayer {
299
300
  value: z.ZodTypeAny,
300
301
  throwOnTypes: readonly UnsupportedZodType[] = UNSUPPORTED_ZOD_TYPES,
301
302
  ): ShapeValue<T> {
302
- if (throwOnTypes.includes(value._def.typeName as UnsupportedZodType)) {
303
- throw new Error(`${this.model.modelId} does not support zod type: ${value._def.typeName}`);
303
+ if (throwOnTypes.includes(value._def?.typeName as UnsupportedZodType)) {
304
+ throw new Error(`${this.model.modelId} does not support zod type: ${value._def?.typeName}`);
304
305
  }
305
306
  return value as ShapeValue<T>;
306
307
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
3
+ "include": ["src/**/*", "tsup.config.ts"],
4
4
  "exclude": ["node_modules", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { generateTypes } from '@internal/types-builder';
2
+ import { defineConfig } from 'tsup';
3
+
4
+ export default defineConfig({
5
+ entry: ['src/index.ts'],
6
+ format: ['esm', 'cjs'],
7
+ clean: true,
8
+ dts: false,
9
+ splitting: true,
10
+ treeshake: {
11
+ preset: 'smallest',
12
+ },
13
+ sourcemap: true,
14
+ onSuccess: async () => {
15
+ await generateTypes(process.cwd());
16
+ },
17
+ });