@mastra/schema-compat 0.10.2-alpha.2

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,23 @@
1
+
2
+ > @mastra/schema-compat@0.10.2-alpha.2 build /home/runner/work/mastra/mastra/packages/schema-compat
3
+ > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
+
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.0
8
+ TSC Build start
9
+ TSC ⚡️ Build success in 2215ms
10
+ DTS Build start
11
+ CLI Target: es2022
12
+ Analysis will use the bundled TypeScript version 5.8.3
13
+ Writing package typings: /home/runner/work/mastra/mastra/packages/schema-compat/dist/_tsup-dts-rollup.d.ts
14
+ Analysis will use the bundled TypeScript version 5.8.3
15
+ Writing package typings: /home/runner/work/mastra/mastra/packages/schema-compat/dist/_tsup-dts-rollup.d.cts
16
+ DTS ⚡️ Build success in 1992ms
17
+ CLI Cleaning output folder
18
+ ESM Build start
19
+ CJS Build start
20
+ CJS dist/index.cjs 22.96 KB
21
+ CJS ⚡️ Build success in 175ms
22
+ ESM dist/index.js 22.37 KB
23
+ ESM ⚡️ Build success in 175ms
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @mastra/schema-compat
2
+
3
+ ## 0.10.2-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - f9816ae: Create @mastra/schema-compat package to extract the schema compatibility layer to be used outside of mastra
package/LICENSE.md ADDED
@@ -0,0 +1,46 @@
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
4
+
5
+ **Acceptance**
6
+ By using the software, you agree to all of the terms and conditions below.
7
+
8
+ **Copyright License**
9
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
10
+
11
+ **Limitations**
12
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
13
+
14
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
15
+
16
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
17
+
18
+ **Patents**
19
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
20
+
21
+ **Notices**
22
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
23
+
24
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
25
+
26
+ **No Other Rights**
27
+ These terms do not imply any licenses other than those expressly granted in these terms.
28
+
29
+ **Termination**
30
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
31
+
32
+ **No Liability**
33
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
34
+
35
+ **Definitions**
36
+ The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
37
+
38
+ _you_ refers to the individual or entity agreeing to these terms.
39
+
40
+ _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
41
+
42
+ _your licenses_ are all the licenses granted to you for the software under these terms.
43
+
44
+ _use_ means anything you do with the software requiring one of your licenses.
45
+
46
+ _trademark_ means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @mastra/schema-compat
2
+
3
+ Schema compatibility layer for Mastra.ai that provides compatibility fixes for different AI model providers when using Zod schemas with tools.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @mastra/schema-compat
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Usage
14
+
15
+ The package provides a base `SchemaCompatLayer` class that you can extend to create custom compatibility layers for different AI model providers:
16
+
17
+ ```typescript
18
+ import { SchemaCompatLayer } from '@mastra/schema-compat';
19
+ import type { LanguageModelV1 } from 'ai';
20
+
21
+ class MyCustomCompat extends SchemaCompatLayer {
22
+ constructor(model: LanguageModelV1) {
23
+ super(model);
24
+ }
25
+
26
+ shouldApply(): boolean {
27
+ return this.getModel().provider === 'my-provider';
28
+ }
29
+
30
+ getSchemaTarget() {
31
+ return 'jsonSchema7';
32
+ }
33
+
34
+ processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T> {
35
+ // Your custom processing logic here
36
+ return value;
37
+ }
38
+ }
39
+ ```
40
+
41
+ ### Schema Processing
42
+
43
+ The package includes pre-built compatibility layers for popular AI providers:
44
+
45
+ Use the `applyCompatLayer` function to automatically apply the right compatibility layer:
46
+
47
+ ```typescript
48
+ import { applyCompatLayer, OpenAISchemaCompatLayer, AnthropicSchemaCompatLayer } from '@mastra/schema-compat';
49
+ import { yourCustomCompatibilityLayer } from './customCompatibilityLayer';
50
+ import { z } from 'zod';
51
+
52
+ const schema = z.object({
53
+ name: z.string().email(),
54
+ preferences: z.array(z.string()).min(1),
55
+ });
56
+
57
+ const compatLayers = [
58
+ new OpenAISchemaCompatLayer(model),
59
+ new AnthropicSchemaCompatLayer(model),
60
+ new yourCustomCompatibilityLayer(model),
61
+ ];
62
+
63
+ // Automatically applies the first matching compatibility
64
+ const result = applyCompatLayer({
65
+ schema,
66
+ compatLayers,
67
+ mode: 'aiSdkSchema', // or 'jsonSchema'
68
+ });
69
+ ```
70
+
71
+ ### Schema Building Utilities
72
+
73
+ The package also provides utility functions for schema conversion:
74
+
75
+ ```typescript
76
+ import { convertZodSchemaToAISDKSchema, convertSchemaToZod } from '@mastra/schema-compat';
77
+ import { z } from 'zod';
78
+ import { jsonSchema } from 'ai';
79
+
80
+ const zodSchema = z.object({
81
+ name: z.string(),
82
+ age: z.number(),
83
+ });
84
+
85
+ // Convert Zod to AI SDK Schema
86
+ const aiSchema = convertZodSchemaToAISDKSchema(zodSchema);
87
+
88
+ // Convert AI SDK Schema back to Zod
89
+ const aiSdkSchema = jsonSchema({
90
+ type: 'object',
91
+ properties: {
92
+ name: { type: 'string' },
93
+ },
94
+ });
95
+ const backToZod = convertSchemaToZod(aiSdkSchema);
96
+ ```
97
+
98
+ ## API Reference
99
+
100
+ ### Classes
101
+
102
+ - `SchemaCompatLayer` - Base abstract class for creating compatibility layers
103
+ - `AnthropicSchemaCompatLayer` - Compatibility for Anthropic Claude models
104
+ - `OpenAISchemaCompatLayer` - Compatibility for OpenAI models (without structured outputs)
105
+ - `OpenAIReasoningSchemaCompatLayer` - Compatibility for OpenAI reasoning models (o1 series)
106
+ - `GoogleSchemaCompatLayer` - Compatibility for Google Gemini models
107
+ - `DeepSeekSchemaCompatLayer` - Compatibility for DeepSeek models
108
+ - `MetaSchemaCompatLayer` - Compatibility for Meta Llama models
109
+
110
+ ### Functions
111
+
112
+ - `applyCompatLayer(options)` - Process schema with automatic compatibility detection
113
+ - `convertZodSchemaToAISDKSchema(zodSchema, target?)` - Convert Zod schema to AI SDK Schema
114
+ - `convertSchemaToZod(schema)` - Convert AI SDK Schema to Zod schema
115
+
116
+ ### Types and Constants
117
+
118
+ - `StringCheckType`, `NumberCheckType`, `ArrayCheckType` - Check types for validation
119
+ - `UnsupportedZodType`, `SupportedZodType`, `AllZodType` - Zod type classifications
120
+ - `ZodShape`, `ShapeKey`, `ShapeValue` - Utility types for Zod schemas
121
+ - `ALL_STRING_CHECKS`, `ALL_NUMBER_CHECKS`, `ALL_ARRAY_CHECKS` - Validation constraint arrays
122
+ - `SUPPORTED_ZOD_TYPES`, `UNSUPPORTED_ZOD_TYPES` - Type classification arrays
123
+
124
+ ## Provider-Specific Behavior
125
+
126
+ Different AI providers have varying levels of support for JSON Schema features. This package handles these differences automatically:
127
+
128
+ - **OpenAI**: Removes certain string validations for models without structured outputs
129
+ - **Anthropic**: Handles complex nested schemas with proper constraint descriptions
130
+ - **Google**: Uses OpenAPI 3.0 schema format for better compatibility
131
+ - **DeepSeek**: Converts advanced string patterns to descriptions
132
+ - **Meta**: Optimizes array and union type handling
133
+
134
+ ## Testing
135
+
136
+ The package includes comprehensive tests covering all functionality:
137
+
138
+ ```bash
139
+ # Run tests
140
+ pnpm test
141
+
142
+ # Run tests in watch mode
143
+ pnpm test --watch
144
+ ```
145
+
146
+ ## License
147
+
148
+ Elastic-2.0
@@ -0,0 +1,473 @@
1
+ import type { JSONSchema7 } from 'json-schema';
2
+ import type { LanguageModelV1 } from 'ai';
3
+ import type { Schema } from 'ai';
4
+ import type { Targets } from 'zod-to-json-schema';
5
+ import { z } from 'zod';
6
+ import type { ZodSchema } from 'zod';
7
+
8
+ /**
9
+ * All supported array validation check types that can be processed or converted to descriptions.
10
+ * @constant
11
+ */
12
+ declare const ALL_ARRAY_CHECKS: readonly ["min", "max", "length"];
13
+ export { ALL_ARRAY_CHECKS }
14
+ export { ALL_ARRAY_CHECKS as ALL_ARRAY_CHECKS_alias_1 }
15
+
16
+ /**
17
+ * All supported number validation check types that can be processed or converted to descriptions.
18
+ * @constant
19
+ */
20
+ declare const ALL_NUMBER_CHECKS: readonly ["min", "max", "multipleOf"];
21
+ export { ALL_NUMBER_CHECKS }
22
+ export { ALL_NUMBER_CHECKS as ALL_NUMBER_CHECKS_alias_1 }
23
+
24
+ /**
25
+ * All supported string validation check types that can be processed or converted to descriptions.
26
+ * @constant
27
+ */
28
+ declare const ALL_STRING_CHECKS: readonly ["regex", "emoji", "email", "url", "uuid", "cuid", "min", "max"];
29
+ export { ALL_STRING_CHECKS }
30
+ export { ALL_STRING_CHECKS as ALL_STRING_CHECKS_alias_1 }
31
+
32
+ /**
33
+ * All Zod types (both supported and unsupported).
34
+ * @constant
35
+ */
36
+ declare const ALL_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault", "ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
37
+ export { ALL_ZOD_TYPES }
38
+ export { ALL_ZOD_TYPES as ALL_ZOD_TYPES_alias_1 }
39
+
40
+ /**
41
+ * Type representing all Zod schema types (supported and unsupported).
42
+ */
43
+ declare type AllZodType = (typeof ALL_ZOD_TYPES)[number];
44
+ export { AllZodType }
45
+ export { AllZodType as AllZodType_alias_1 }
46
+
47
+ declare class AnthropicSchemaCompatLayer extends SchemaCompatLayer {
48
+ constructor(model: LanguageModelV1);
49
+ getSchemaTarget(): Targets | undefined;
50
+ shouldApply(): boolean;
51
+ processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
52
+ }
53
+ export { AnthropicSchemaCompatLayer }
54
+ export { AnthropicSchemaCompatLayer as AnthropicSchemaCompatLayer_alias_1 }
55
+
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
+ declare function applyCompatLayer(options: {
66
+ schema: Schema | z.AnyZodObject;
67
+ compatLayers: SchemaCompatLayer[];
68
+ mode: 'aiSdkSchema';
69
+ }): Schema;
70
+
71
+ /**
72
+ * Processes a schema using provider compatibility layers and converts it to a JSON Schema.
73
+ *
74
+ * @param options - Configuration object for schema processing
75
+ * @param options.schema - The schema to process (AI SDK Schema or Zod object schema)
76
+ * @param options.compatLayers - Array of compatibility layers to try
77
+ * @param options.mode - Must be 'jsonSchema'
78
+ * @returns Processed schema as a JSONSchema7
79
+ */
80
+ declare function applyCompatLayer(options: {
81
+ schema: Schema | z.AnyZodObject;
82
+ compatLayers: SchemaCompatLayer[];
83
+ mode: 'jsonSchema';
84
+ }): JSONSchema7;
85
+ export { applyCompatLayer }
86
+ export { applyCompatLayer as applyCompatLayer_alias_1 }
87
+
88
+ /**
89
+ * Type representing array validation checks.
90
+ */
91
+ declare type ArrayCheckType = (typeof ALL_ARRAY_CHECKS)[number];
92
+ export { ArrayCheckType }
93
+ export { ArrayCheckType as ArrayCheckType_alias_1 }
94
+
95
+ declare type ArrayConstraints = {
96
+ minLength?: number;
97
+ maxLength?: number;
98
+ exactLength?: number;
99
+ };
100
+
101
+ /**
102
+ * Converts an AI SDK Schema or Zod schema to a Zod schema.
103
+ *
104
+ * If the input is already a Zod schema, it returns it unchanged.
105
+ * If the input is an AI SDK Schema, it extracts the JSON schema and converts it to Zod.
106
+ *
107
+ * @param schema - The schema to convert (AI SDK Schema or Zod schema)
108
+ * @returns A Zod schema equivalent of the input
109
+ * @throws Error if the conversion fails
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * import { jsonSchema } from 'ai';
114
+ * import { convertSchemaToZod } from '@mastra/schema-compat';
115
+ *
116
+ * const aiSchema = jsonSchema({
117
+ * type: 'object',
118
+ * properties: {
119
+ * name: { type: 'string' }
120
+ * }
121
+ * });
122
+ *
123
+ * const zodSchema = convertSchemaToZod(aiSchema);
124
+ * ```
125
+ */
126
+ declare function convertSchemaToZod(schema: Schema | z.ZodSchema): z.ZodType;
127
+ export { convertSchemaToZod }
128
+ export { convertSchemaToZod as convertSchemaToZod_alias_1 }
129
+
130
+ /**
131
+ * Converts a Zod schema to an AI SDK Schema with validation support.
132
+ *
133
+ * This function mirrors the behavior of Vercel's AI SDK zod-schema utility but allows
134
+ * customization of the JSON Schema target format.
135
+ *
136
+ * @param zodSchema - The Zod schema to convert
137
+ * @param target - The JSON Schema target format (defaults to 'jsonSchema7')
138
+ * @returns An AI SDK Schema object with built-in validation
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * import { z } from 'zod';
143
+ * import { convertZodSchemaToAISDKSchema } from '@mastra/schema-compat';
144
+ *
145
+ * const userSchema = z.object({
146
+ * name: z.string(),
147
+ * age: z.number().min(0)
148
+ * });
149
+ *
150
+ * const aiSchema = convertZodSchemaToAISDKSchema(userSchema);
151
+ * ```
152
+ */
153
+ declare function convertZodSchemaToAISDKSchema(zodSchema: ZodSchema, target?: Targets): Schema<any>;
154
+ export { convertZodSchemaToAISDKSchema }
155
+ export { convertZodSchemaToAISDKSchema as convertZodSchemaToAISDKSchema_alias_1 }
156
+
157
+ declare type DateConstraints = {
158
+ minDate?: string;
159
+ maxDate?: string;
160
+ dateFormat?: string;
161
+ };
162
+
163
+ declare class DeepSeekSchemaCompatLayer extends SchemaCompatLayer {
164
+ constructor(model: LanguageModelV1);
165
+ getSchemaTarget(): Targets | undefined;
166
+ shouldApply(): boolean;
167
+ processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
168
+ }
169
+ export { DeepSeekSchemaCompatLayer }
170
+ export { DeepSeekSchemaCompatLayer as DeepSeekSchemaCompatLayer_alias_1 }
171
+
172
+ declare class GoogleSchemaCompatLayer extends SchemaCompatLayer {
173
+ constructor(model: LanguageModelV1);
174
+ getSchemaTarget(): Targets | undefined;
175
+ shouldApply(): boolean;
176
+ processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
177
+ }
178
+ export { GoogleSchemaCompatLayer }
179
+ export { GoogleSchemaCompatLayer as GoogleSchemaCompatLayer_alias_1 }
180
+
181
+ declare class MetaSchemaCompatLayer extends SchemaCompatLayer {
182
+ constructor(model: LanguageModelV1);
183
+ getSchemaTarget(): Targets | undefined;
184
+ shouldApply(): boolean;
185
+ processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
186
+ }
187
+ export { MetaSchemaCompatLayer }
188
+ export { MetaSchemaCompatLayer as MetaSchemaCompatLayer_alias_1 }
189
+
190
+ /**
191
+ * Type representing number validation checks.
192
+ */
193
+ declare type NumberCheckType = (typeof ALL_NUMBER_CHECKS)[number];
194
+ export { NumberCheckType }
195
+ export { NumberCheckType as NumberCheckType_alias_1 }
196
+
197
+ declare type NumberConstraints = {
198
+ gt?: number;
199
+ gte?: number;
200
+ lt?: number;
201
+ lte?: number;
202
+ multipleOf?: number;
203
+ };
204
+
205
+ declare class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {
206
+ constructor(model: LanguageModelV1);
207
+ getSchemaTarget(): Targets | undefined;
208
+ isReasoningModel(): boolean;
209
+ shouldApply(): boolean;
210
+ processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
211
+ }
212
+ export { OpenAIReasoningSchemaCompatLayer }
213
+ export { OpenAIReasoningSchemaCompatLayer as OpenAIReasoningSchemaCompatLayer_alias_1 }
214
+
215
+ declare class OpenAISchemaCompatLayer extends SchemaCompatLayer {
216
+ constructor(model: LanguageModelV1);
217
+ getSchemaTarget(): Targets | undefined;
218
+ shouldApply(): boolean;
219
+ processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
220
+ }
221
+ export { OpenAISchemaCompatLayer }
222
+ export { OpenAISchemaCompatLayer as OpenAISchemaCompatLayer_alias_1 }
223
+
224
+ /**
225
+ * Abstract base class for creating schema compatibility layers for different AI model providers.
226
+ *
227
+ * This class provides a framework for transforming Zod schemas to work with specific AI model
228
+ * provider requirements and limitations. Each provider may have different support levels for
229
+ * JSON Schema features, validation constraints, and data types.
230
+ *
231
+ * @abstract
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * import { SchemaCompatLayer } from '@mastra/schema-compat';
236
+ * import type { LanguageModelV1 } from 'ai';
237
+ *
238
+ * class CustomProviderCompat extends SchemaCompatLayer {
239
+ * constructor(model: LanguageModelV1) {
240
+ * super(model);
241
+ * }
242
+ *
243
+ * shouldApply(): boolean {
244
+ * return this.getModel().provider === 'custom-provider';
245
+ * }
246
+ *
247
+ * getSchemaTarget() {
248
+ * return 'jsonSchema7';
249
+ * }
250
+ *
251
+ * processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T> {
252
+ * // Custom processing logic for this provider
253
+ * switch (value._def.typeName) {
254
+ * case 'ZodString':
255
+ * return this.defaultZodStringHandler(value, ['email', 'url']);
256
+ * default:
257
+ * return this.defaultUnsupportedZodTypeHandler(value);
258
+ * }
259
+ * }
260
+ * }
261
+ * ```
262
+ */
263
+ declare abstract class SchemaCompatLayer {
264
+ private model;
265
+ /**
266
+ * Creates a new schema compatibility instance.
267
+ *
268
+ * @param model - The language model this compatibility layer applies to
269
+ */
270
+ constructor(model: LanguageModelV1);
271
+ /**
272
+ * Gets the language model associated with this compatibility layer.
273
+ *
274
+ * @returns The language model instance
275
+ */
276
+ getModel(): LanguageModelV1;
277
+ /**
278
+ * Determines whether this compatibility layer should be applied for the current model.
279
+ *
280
+ * @returns True if this compatibility layer should be used, false otherwise
281
+ * @abstract
282
+ */
283
+ abstract shouldApply(): boolean;
284
+ /**
285
+ * Returns the JSON Schema target format for this provider.
286
+ *
287
+ * @returns The schema target format, or undefined to use the default 'jsonSchema7'
288
+ * @abstract
289
+ */
290
+ abstract getSchemaTarget(): Targets | undefined;
291
+ /**
292
+ * Processes a specific Zod type according to the provider's requirements.
293
+ *
294
+ * @param value - The Zod type to process
295
+ * @returns The processed Zod type
296
+ * @abstract
297
+ */
298
+ abstract processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
299
+ /**
300
+ * Applies compatibility transformations to a Zod object schema.
301
+ *
302
+ * @param zodSchema - The Zod object schema to transform
303
+ * @returns Object containing the transformed schema
304
+ * @private
305
+ */
306
+ private applyZodSchemaCompatibility;
307
+ /**
308
+ * Default handler for Zod object types. Recursively processes all properties in the object.
309
+ *
310
+ * @param value - The Zod object to process
311
+ * @returns The processed Zod object
312
+ */
313
+ defaultZodObjectHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
314
+ /**
315
+ * Merges validation constraints into a parameter description.
316
+ *
317
+ * This helper method converts validation constraints that may not be supported
318
+ * by a provider into human-readable descriptions.
319
+ *
320
+ * @param description - The existing parameter description
321
+ * @param constraints - The validation constraints to merge
322
+ * @returns The updated description with constraints, or undefined if no constraints
323
+ */
324
+ mergeParameterDescription(description: string | undefined, constraints: NumberConstraints | StringConstraints | ArrayConstraints | DateConstraints | {
325
+ defaultValue?: unknown;
326
+ }): string | undefined;
327
+ /**
328
+ * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
329
+ *
330
+ * @param value - The Zod type to check
331
+ * @param throwOnTypes - Array of type names to throw errors for
332
+ * @returns The original value if not in the throw list
333
+ * @throws Error if the type is in the unsupported list
334
+ */
335
+ defaultUnsupportedZodTypeHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny, throwOnTypes?: readonly UnsupportedZodType[]): ShapeValue<T>;
336
+ /**
337
+ * Default handler for Zod array types. Processes array constraints according to provider support.
338
+ *
339
+ * @param value - The Zod array to process
340
+ * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
341
+ * @returns The processed Zod array
342
+ */
343
+ defaultZodArrayHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny, handleChecks?: readonly ArrayCheckType[]): ShapeValue<T>;
344
+ /**
345
+ * Default handler for Zod union types. Processes all union options.
346
+ *
347
+ * @param value - The Zod union to process
348
+ * @returns The processed Zod union
349
+ * @throws Error if union has fewer than 2 options
350
+ */
351
+ defaultZodUnionHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
352
+ /**
353
+ * Default handler for Zod string types. Processes string validation constraints.
354
+ *
355
+ * @param value - The Zod string to process
356
+ * @param handleChecks - String constraints to convert to descriptions vs keep as validation
357
+ * @returns The processed Zod string
358
+ */
359
+ defaultZodStringHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny, handleChecks?: readonly StringCheckType[]): ShapeValue<T>;
360
+ /**
361
+ * Default handler for Zod number types. Processes number validation constraints.
362
+ *
363
+ * @param value - The Zod number to process
364
+ * @param handleChecks - Number constraints to convert to descriptions vs keep as validation
365
+ * @returns The processed Zod number
366
+ */
367
+ defaultZodNumberHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny, handleChecks?: readonly NumberCheckType[]): ShapeValue<T>;
368
+ /**
369
+ * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
370
+ *
371
+ * @param value - The Zod date to process
372
+ * @returns A Zod string schema representing the date in ISO format
373
+ */
374
+ defaultZodDateHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T>;
375
+ /**
376
+ * Default handler for Zod optional types. Processes the inner type and maintains optionality.
377
+ *
378
+ * @param value - The Zod optional to process
379
+ * @param handleTypes - Types that should be processed vs passed through
380
+ * @returns The processed Zod optional
381
+ */
382
+ defaultZodOptionalHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny, handleTypes?: readonly AllZodType[]): ShapeValue<T>;
383
+ /**
384
+ * Processes a Zod object schema and converts it to an AI SDK Schema.
385
+ *
386
+ * @param zodSchema - The Zod object schema to process
387
+ * @returns An AI SDK Schema with provider-specific compatibility applied
388
+ */
389
+ processToAISDKSchema(zodSchema: z.AnyZodObject): Schema;
390
+ /**
391
+ * Processes a Zod object schema and converts it to a JSON Schema.
392
+ *
393
+ * @param zodSchema - The Zod object schema to process
394
+ * @returns A JSONSchema7 object with provider-specific compatibility applied
395
+ */
396
+ processToJSONSchema(zodSchema: z.AnyZodObject): JSONSchema7;
397
+ }
398
+ export { SchemaCompatLayer }
399
+ export { SchemaCompatLayer as SchemaCompatLayer_alias_1 }
400
+
401
+ /**
402
+ * Utility type to extract the keys from a Zod object shape.
403
+ */
404
+ declare type ShapeKey<T extends z.AnyZodObject> = keyof ZodShape<T>;
405
+ export { ShapeKey }
406
+ export { ShapeKey as ShapeKey_alias_1 }
407
+
408
+ /**
409
+ * Utility type to extract the value types from a Zod object shape.
410
+ */
411
+ declare type ShapeValue<T extends z.AnyZodObject> = ZodShape<T>[ShapeKey<T>];
412
+ export { ShapeValue }
413
+ export { ShapeValue as ShapeValue_alias_1 }
414
+
415
+ /**
416
+ * Type representing string validation checks.
417
+ */
418
+ declare type StringCheckType = (typeof ALL_STRING_CHECKS)[number];
419
+ export { StringCheckType }
420
+ export { StringCheckType as StringCheckType_alias_1 }
421
+
422
+ declare type StringConstraints = {
423
+ minLength?: number;
424
+ maxLength?: number;
425
+ email?: boolean;
426
+ url?: boolean;
427
+ uuid?: boolean;
428
+ cuid?: boolean;
429
+ emoji?: boolean;
430
+ regex?: {
431
+ pattern: string;
432
+ flags?: string;
433
+ };
434
+ };
435
+
436
+ /**
437
+ * Zod types that are generally supported by AI model providers.
438
+ * @constant
439
+ */
440
+ declare const SUPPORTED_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault"];
441
+ export { SUPPORTED_ZOD_TYPES }
442
+ export { SUPPORTED_ZOD_TYPES as SUPPORTED_ZOD_TYPES_alias_1 }
443
+
444
+ /**
445
+ * Type representing supported Zod schema types.
446
+ */
447
+ declare type SupportedZodType = (typeof SUPPORTED_ZOD_TYPES)[number];
448
+ export { SupportedZodType }
449
+ export { SupportedZodType as SupportedZodType_alias_1 }
450
+
451
+ /**
452
+ * Zod types that are not supported by most AI model providers and should be avoided.
453
+ * @constant
454
+ */
455
+ declare const UNSUPPORTED_ZOD_TYPES: readonly ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
456
+ export { UNSUPPORTED_ZOD_TYPES }
457
+ export { UNSUPPORTED_ZOD_TYPES as UNSUPPORTED_ZOD_TYPES_alias_1 }
458
+
459
+ /**
460
+ * Type representing unsupported Zod schema types.
461
+ */
462
+ declare type UnsupportedZodType = (typeof UNSUPPORTED_ZOD_TYPES)[number];
463
+ export { UnsupportedZodType }
464
+ export { UnsupportedZodType as UnsupportedZodType_alias_1 }
465
+
466
+ /**
467
+ * Utility type to extract the shape of a Zod object schema.
468
+ */
469
+ declare type ZodShape<T extends z.AnyZodObject> = T['shape'];
470
+ export { ZodShape }
471
+ export { ZodShape as ZodShape_alias_1 }
472
+
473
+ export { }