{"version":3,"sources":["jsdelivr-header.js","/npm/@mastra/schema-compat@0.11.9/src/utils.ts","/npm/@mastra/schema-compat@0.11.9/src/schema-compatibility-v3.ts","/npm/@mastra/schema-compat@0.11.9/src/schema-compatibility-v4.ts","/npm/@mastra/schema-compat@0.11.9/src/schema-compatibility.ts","/npm/@mastra/schema-compat@0.11.9/src/zodTypes.ts","/npm/@mastra/schema-compat@0.11.9/src/provider-compats/anthropic.ts","/npm/@mastra/schema-compat@0.11.9/src/provider-compats/deepseek.ts","/npm/@mastra/schema-compat@0.11.9/src/provider-compats/google.ts","/npm/@mastra/schema-compat@0.11.9/src/provider-compats/meta.ts","/npm/@mastra/schema-compat@0.11.9/src/provider-compats/openai.ts","/npm/@mastra/schema-compat@0.11.9/src/provider-compats/openai-reasoning.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,2kBCkCO,SAAS,8BAA8B,EAAsB,EAAkB,eACpF,MAAM,EAAkB,gBAAgB,EAAW,GAEnD,OAAO,WAAW,EAAiB,CACjC,SAAU,IACR,MAAM,EAAS,EAAU,UAAU,GACnC,OAAO,EAAO,QAAU,CAAE,SAAS,EAAM,MAAO,EAAO,MAAS,CAAE,SAAS,EAAO,MAAO,EAAO,MAAM,GAG5G,CASO,SAAS,UAAU,GAExB,MACmB,iBAAV,GACG,OAAV,GACA,SAAU,GACV,UAAW,GACqB,mBAAxB,EAAc,OACtB,cAAe,GACqB,mBAA5B,EAAc,SAE1B,CA2BO,SAAS,mBAAmB,GACjC,GAAI,UAAU,GACZ,OAAO,EACF,CACL,MAAM,EAAuB,eAAgB,EAAS,EAAO,WAAa,EAC1E,IACE,MAAI,iBAAkB,EAEb,uBAAuB,GAEvB,yBAAyB,EAEpC,OAAS,GACP,MAAM,EAAe,iFAAiF,KAAK,UAAU,KAErH,MADA,QAAQ,MAAM,EAAc,GACtB,IAAI,MAAM,GAAgB,aAAa,MAAQ,KAAK,EAAE,QAAU,0BACxE,CACF,CACF,CAmEO,S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KAAK,eAAe,GACrB,UACxB,CACA,OAAO,CACT,IAAW,OAAM,EAAN,CAAS,GAClB,OAAO,KAAK,wBAAwB,EAAO,CAAE,aAAa,IAC5D,GAAW,OAAM,EAAN,CAAS,GAClB,OAAO,KAAK,uBAAuB,GACrC,GAAW,SAAQ,EAAR,CAAW,GACpB,OAAO,KAAK,uBAAuB,GACrC,GAAW,UAAU,EAAV,CAAa,GAAQ,CAC9B,MAAM,EAAa,EAAM,KACnB,EAAY,EAAW,UAEvB,EAC+B,mBAA5B,EAAW,aAA8B,EAAW,eAAiB,EAAW,aACnF,EAAwB,QACT,IAAjB,GACF,EAAY,KAAK,wBAAwB,KAG3C,MAAM,EAAc,KAAK,0BAA0B,EAAM,YAAa,GACtE,IAAI,EAAS,KAAK,eAAe,GAIjC,OAHI,IACF,EAAS,EAAO,SAAS,IAEpB,CACT,QAAW,UAAS,EAAT,CAAY,GACd,KAAK,wBAAwB,GAC3B,UAAS,EAAT,CAAY,GACd,KAAK,wBAAwB,GAC3B,OAAO,EAAP,CAAU,GACZ,KAAK,sBAAsB,GACE,WAA3B,EAAM,YAAY,KAGpB,EACJ,SACA,UACE,EAAM,aAAe,IACpB,2GAID,KAAK,iCAAiC,EAC/C,U","file":"/npm/@mastra/schema-compat@0.11.9/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@mastra/schema-compat@0.11.9/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { jsonSchema } from 'ai';\nimport type { Schema } from 'ai';\nimport type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { ZodSchema as ZodSchemaV3, ZodType as ZodTypeV3 } from 'zod/v3';\nimport type { ZodType as ZodSchemaV4, ZodType as ZodTypeV4 } from 'zod/v4';\nimport { convertJsonSchemaToZod } from 'zod-from-json-schema';\nimport { convertJsonSchemaToZod as convertJsonSchemaToZodV3 } from 'zod-from-json-schema-v3';\nimport type { JSONSchema } from 'zod-from-json-schema-v3';\nimport type { Targets } from 'zod-to-json-schema';\nimport type { SchemaCompatLayer } from './schema-compatibility';\nimport { zodToJsonSchema } from './zod-to-json';\n\ntype ZodSchema = ZodSchemaV3 | ZodSchemaV4;\ntype ZodType = ZodTypeV3 | ZodTypeV4;\n\n/**\n * Converts a Zod schema to an AI SDK Schema with validation support.\n *\n * This function mirrors the behavior of Vercel's AI SDK zod-schema utility but allows\n * customization of the JSON Schema target format.\n *\n * @param zodSchema - The Zod schema to convert\n * @param target - The JSON Schema target format (defaults to 'jsonSchema7')\n * @returns An AI SDK Schema object with built-in validation\n *\n * @example\n * ```typescript\n * import { z } from 'zod';\n * import { convertZodSchemaToAISDKSchema } from '@mastra/schema-compat';\n *\n * const userSchema = z.object({\n *   name: z.string(),\n *   age: z.number().min(0)\n * });\n *\n * const aiSchema = convertZodSchemaToAISDKSchema(userSchema);\n * ```\n */\n// mirrors https://github.com/vercel/ai/blob/main/packages/ui-utils/src/zod-schema.ts#L21 but with a custom target\nexport function convertZodSchemaToAISDKSchema(zodSchema: ZodSchema, target: Targets = 'jsonSchema7'): Schema<any> {\n  const jsonSchemaToUse = zodToJsonSchema(zodSchema, target) as JSONSchema7;\n\n  return jsonSchema(jsonSchemaToUse, {\n    validate: value => {\n      const result = zodSchema.safeParse(value);\n      return result.success ? { success: true, value: result.data } : { success: false, error: result.error };\n    },\n  });\n}\n\n/**\n * Checks if a value is a Zod type by examining its properties and methods.\n *\n * @param value - The value to check\n * @returns True if the value is a Zod type, false otherwise\n * @internal\n */\nexport function isZodType(value: unknown): value is ZodType {\n  // Check if it's a Zod schema by looking for common Zod properties and methods\n  return (\n    typeof value === 'object' &&\n    value !== null &&\n    '_def' in value &&\n    'parse' in value &&\n    typeof (value as any).parse === 'function' &&\n    'safeParse' in value &&\n    typeof (value as any).safeParse === 'function'\n  );\n}\n\n/**\n * Converts an AI SDK Schema or Zod schema to a Zod schema.\n *\n * If the input is already a Zod schema, it returns it unchanged.\n * If the input is an AI SDK Schema, it extracts the JSON schema and converts it to Zod.\n *\n * @param schema - The schema to convert (AI SDK Schema or Zod schema)\n * @returns A Zod schema equivalent of the input\n * @throws Error if the conversion fails\n *\n * @example\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { convertSchemaToZod } from '@mastra/schema-compat';\n *\n * const aiSchema = jsonSchema({\n *   type: 'object',\n *   properties: {\n *     name: { type: 'string' }\n *   }\n * });\n *\n * const zodSchema = convertSchemaToZod(aiSchema);\n * ```\n */\nexport function convertSchemaToZod(schema: Schema | ZodSchema): ZodType {\n  if (isZodType(schema)) {\n    return schema;\n  } else {\n    const jsonSchemaToConvert = ('jsonSchema' in schema ? schema.jsonSchema : schema) as JSONSchema;\n    try {\n      if ('toJSONSchema' in z) {\n        // @ts-expect-error - zod type issue\n        return convertJsonSchemaToZod(jsonSchemaToConvert);\n      } else {\n        return convertJsonSchemaToZodV3(jsonSchemaToConvert);\n      }\n    } catch (e: unknown) {\n      const errorMessage = `[Schema Builder] Failed to convert schema parameters to Zod. Original schema: ${JSON.stringify(jsonSchemaToConvert)}`;\n      console.error(errorMessage, e);\n      throw new Error(errorMessage + (e instanceof Error ? `\\n${e.stack}` : '\\nUnknown error object'));\n    }\n  }\n}\n\n/**\n * Processes a schema using provider compatibility layers and converts it to an AI SDK Schema.\n *\n * @param options - Configuration object for schema processing\n * @param options.schema - The schema to process (AI SDK Schema or Zod object schema)\n * @param options.compatLayers - Array of compatibility layers to try\n * @param options.mode - Must be 'aiSdkSchema'\n * @returns Processed schema as an AI SDK Schema\n */\nexport function applyCompatLayer(options: {\n  schema: Schema | ZodSchema;\n  compatLayers: SchemaCompatLayer[];\n  mode: 'aiSdkSchema';\n}): Schema;\n\n/**\n * Processes a schema using provider compatibility layers and converts it to a JSON Schema.\n *\n * @param options - Configuration object for schema processing\n * @param options.schema - The schema to process (AI SDK Schema or Zod object schema)\n * @param options.compatLayers - Array of compatibility layers to try\n * @param options.mode - Must be 'jsonSchema'\n * @returns Processed schema as a JSONSchema7\n */\nexport function applyCompatLayer(options: {\n  schema: Schema | ZodSchema;\n  compatLayers: SchemaCompatLayer[];\n  mode: 'jsonSchema';\n}): JSONSchema7;\n\n/**\n * Processes a schema using provider compatibility layers and converts it to the specified format.\n *\n * This function automatically applies the first matching compatibility layer from the provided\n * list based on the model configuration. If no compatibility applies, it falls back to\n * standard conversion.\n *\n * @param options - Configuration object for schema processing\n * @param options.schema - The schema to process (AI SDK Schema or Zod object schema)\n * @param options.compatLayers - Array of compatibility layers to try\n * @param options.mode - Output format: 'jsonSchema' for JSONSchema7 or 'aiSdkSchema' for AI SDK Schema\n * @returns Processed schema in the requested format\n *\n * @example\n * ```typescript\n * import { z } from 'zod';\n * import { applyCompatLayer, OpenAISchemaCompatLayer, AnthropicSchemaCompatLayer } from '@mastra/schema-compat';\n *\n * const schema = z.object({\n *   query: z.string().email(),\n *   limit: z.number().min(1).max(100)\n * });\n *\n * const compatLayers = [\n *   new OpenAISchemaCompatLayer(model),\n *   new AnthropicSchemaCompatLayer(model)\n * ];\n *\n * const result = applyCompatLayer({\n *   schema,\n *   compatLayers,\n *   mode: 'aiSdkSchema'\n * });\n * ```\n */\nexport function applyCompatLayer({\n  schema,\n  compatLayers,\n  mode,\n}: {\n  schema: Schema | ZodSchema;\n  compatLayers: SchemaCompatLayer[];\n  mode: 'jsonSchema' | 'aiSdkSchema';\n}): JSONSchema7 | Schema {\n  let zodSchema: ZodSchema;\n\n  if (!isZodType(schema)) {\n    // Convert non-zod schema to Zod\n    zodSchema = convertSchemaToZod(schema);\n  } else {\n    zodSchema = schema;\n  }\n\n  for (const compat of compatLayers) {\n    if (compat.shouldApply()) {\n      return mode === 'jsonSchema' ? compat.processToJSONSchema(zodSchema) : compat.processToAISDKSchema(zodSchema);\n    }\n  }\n  // If no compatibility applied, convert back to appropriate format\n  if (mode === 'jsonSchema') {\n    return zodToJsonSchema(zodSchema, 'jsonSchema7') as JSONSchema7;\n  } else {\n    return convertZodSchemaToAISDKSchema(zodSchema);\n  }\n}\n","import type { Schema } from 'ai';\nimport type { JSONSchema7 } from 'json-schema';\nimport {\n  z,\n  ZodOptional,\n  ZodObject,\n  ZodArray,\n  ZodUnion,\n  ZodString,\n  ZodNumber,\n  ZodDate,\n  ZodDefault,\n  ZodNull,\n  ZodNullable,\n} from 'zod';\nimport type { ZodTypeAny } from 'zod';\nimport type { Targets } from 'zod-to-json-schema';\nimport type { SchemaCompatLayer as ParentSchemaCompatLayer } from './schema-compatibility';\nimport type { ModelInformation } from './types';\nimport { convertZodSchemaToAISDKSchema } from './utils';\n\n/**\n * All supported string validation check types that can be processed or converted to descriptions.\n * @constant\n */\nexport const ALL_STRING_CHECKS = ['regex', 'emoji', 'email', 'url', 'uuid', 'cuid', 'min', 'max'] as const;\n\n/**\n * All supported number validation check types that can be processed or converted to descriptions.\n * @constant\n */\nexport const ALL_NUMBER_CHECKS = [\n  'min', // gte internally\n  'max', // lte internally\n  'multipleOf',\n] as const;\n\n/**\n * All supported array validation check types that can be processed or converted to descriptions.\n * @constant\n */\nexport const ALL_ARRAY_CHECKS = ['min', 'max', 'length'] as const;\n\nexport const isOptional = (v: ZodTypeAny): v is ZodOptional<any> => v instanceof ZodOptional;\nexport const isObj = (v: ZodTypeAny): v is ZodObject<any, any, any> => v instanceof ZodObject;\nexport const isNull = (v: ZodTypeAny): v is ZodNull => v instanceof ZodNull;\nexport const isNullable = (v: ZodTypeAny): v is ZodNullable<any> => v instanceof ZodNullable;\nexport const isArr = (v: ZodTypeAny): v is ZodArray<any, any> => v instanceof ZodArray;\nexport const isUnion = (v: ZodTypeAny): v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]> => v instanceof ZodUnion;\nexport const isString = (v: ZodTypeAny): v is ZodString => v instanceof ZodString;\nexport const isNumber = (v: ZodTypeAny): v is ZodNumber => v instanceof ZodNumber;\nexport const isDate = (v: ZodTypeAny): v is ZodDate => v instanceof ZodDate;\nexport const isDefault = (v: ZodTypeAny): v is ZodDefault<any> => v instanceof ZodDefault;\n\n/**\n * Zod types that are not supported by most AI model providers and should be avoided.\n * @constant\n */\nexport const UNSUPPORTED_ZOD_TYPES = ['ZodIntersection', 'ZodNever', 'ZodNull', 'ZodTuple', 'ZodUndefined'] as const;\n\n/**\n * Zod types that are generally supported by AI model providers.\n * @constant\n */\nexport const SUPPORTED_ZOD_TYPES = [\n  'ZodObject',\n  'ZodArray',\n  'ZodUnion',\n  'ZodString',\n  'ZodNumber',\n  'ZodDate',\n  'ZodAny',\n  'ZodDefault',\n  'ZodNullable',\n] as const;\n\n/**\n * All Zod types (both supported and unsupported).\n * @constant\n */\nexport const ALL_ZOD_TYPES = [...SUPPORTED_ZOD_TYPES, ...UNSUPPORTED_ZOD_TYPES] as const;\n\n/**\n * Type representing string validation checks.\n */\nexport type StringCheckType = (typeof ALL_STRING_CHECKS)[number];\n\n/**\n * Type representing number validation checks.\n */\nexport type NumberCheckType = (typeof ALL_NUMBER_CHECKS)[number];\n\n/**\n * Type representing array validation checks.\n */\nexport type ArrayCheckType = (typeof ALL_ARRAY_CHECKS)[number];\n\n/**\n * Type representing unsupported Zod schema types.\n */\nexport type UnsupportedZodType = (typeof UNSUPPORTED_ZOD_TYPES)[number];\n\n/**\n * Type representing supported Zod schema types.\n */\nexport type SupportedZodType = (typeof SUPPORTED_ZOD_TYPES)[number];\n\n/**\n * Type representing all Zod schema types (supported and unsupported).\n */\nexport type AllZodType = (typeof ALL_ZOD_TYPES)[number];\n\n/**\n * Utility type to extract the shape of a Zod object schema.\n */\nexport type ZodShape<T extends z.AnyZodObject> = T['shape'];\n\n/**\n * Utility type to extract the keys from a Zod object shape.\n */\nexport type ShapeKey<T extends z.AnyZodObject> = keyof ZodShape<T>;\n\n/**\n * Utility type to extract the value types from a Zod object shape.\n */\nexport type ShapeValue<T extends z.AnyZodObject> = ZodShape<T>[ShapeKey<T>];\n\n// Add constraint types at the top\n\ntype ConstraintHelperText = string[];\n\n/**\n * Abstract base class for creating schema compatibility layers for different AI model providers.\n *\n * This class provides a framework for transforming Zod schemas to work with specific AI model\n * provider requirements and limitations. Each provider may have different support levels for\n * JSON Schema features, validation constraints, and data types.\n *\n *\n * @example\n * ```typescript\n * import { SchemaCompatLayer } from '@mastra/schema-compat';\n * import type { LanguageModelV1 } from 'ai';\n *\n * class CustomProviderCompat extends SchemaCompatLayer {\n *   constructor(model: ModelInformation) {\n *     super(model);\n *   }\n *\n *   shouldApply(): boolean {\n *     return this.getModel().provider === 'custom-provider';\n *   }\n *\n *   getSchemaTarget() {\n *     return 'jsonSchema7';\n *   }\n *\n *   processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T> {\n *     // Custom processing logic for this provider\n *     switch (value._def.typeName) {\n *       case 'ZodString':\n *         return this.defaultZodStringHandler(value, ['email', 'url']);\n *       default:\n *         return this.defaultUnsupportedZodTypeHandler(value);\n *     }\n *   }\n * }\n * ```\n */\nexport class SchemaCompatLayer {\n  private model: ModelInformation;\n  private parent: ParentSchemaCompatLayer;\n\n  /**\n   * Creates a new schema compatibility instance.\n   *\n   * @param model - The language model this compatibility layer applies to\n   */\n  constructor(model: ModelInformation, parent: ParentSchemaCompatLayer) {\n    this.model = model;\n    this.parent = parent;\n  }\n\n  /**\n   * Gets the language model associated with this compatibility layer.\n   *\n   * @returns The language model instance\n   */\n  getModel(): ModelInformation {\n    return this.model;\n  }\n\n  getUnsupportedZodTypes(): readonly string[] {\n    return UNSUPPORTED_ZOD_TYPES;\n  }\n\n  /**\n   * Type guard for optional Zod types\n   */\n  isOptional(v: ZodTypeAny): v is ZodOptional<any> {\n    return v instanceof ZodOptional;\n  }\n\n  /**\n   * Type guard for object Zod types\n   */\n  isObj(v: ZodTypeAny): v is ZodObject<any, any, any> {\n    return v instanceof ZodObject;\n  }\n\n  /**\n   * Type guard for null Zod types\n   */\n  isNull(v: ZodTypeAny): v is ZodNull {\n    return v instanceof ZodNull;\n  }\n\n  /**\n   * Type guard for array Zod types\n   */\n  isArr(v: ZodTypeAny): v is ZodArray<any, any> {\n    return v instanceof ZodArray;\n  }\n\n  /**\n   * Type guard for union Zod types\n   */\n  isUnion(v: ZodTypeAny): v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]> {\n    return v instanceof ZodUnion;\n  }\n\n  /**\n   * Type guard for string Zod types\n   */\n  isString(v: ZodTypeAny): v is ZodString {\n    return v instanceof ZodString;\n  }\n\n  /**\n   * Type guard for number Zod types\n   */\n  isNumber(v: ZodTypeAny): v is ZodNumber {\n    return v instanceof ZodNumber;\n  }\n\n  /**\n   * Type guard for date Zod types\n   */\n  isDate(v: ZodTypeAny): v is ZodDate {\n    return v instanceof ZodDate;\n  }\n\n  /**\n   * Type guard for default Zod types\n   */\n  isDefault(v: ZodTypeAny): v is ZodDefault<any> {\n    return v instanceof ZodDefault;\n  }\n\n  /**\n   * Determines whether this compatibility layer should be applied for the current model.\n   *\n   * @returns True if this compatibility layer should be used, false otherwise\n   * @abstract\n   */\n  shouldApply(): boolean {\n    return this.parent.shouldApply();\n  }\n\n  /**\n   * Returns the JSON Schema target format for this provider.\n   *\n   * @returns The schema target format, or undefined to use the default 'jsonSchema7'\n   * @abstract\n   */\n  getSchemaTarget(): Targets | undefined {\n    return this.parent.getSchemaTarget();\n  }\n\n  /**\n   * Processes a specific Zod type according to the provider's requirements.\n   *\n   * @param value - The Zod type to process\n   * @returns The processed Zod type\n   * @abstract\n   */\n  processZodType(value: ZodTypeAny): ZodTypeAny {\n    return this.parent.processZodType(value);\n  }\n\n  /**\n   * Default handler for Zod object types. Recursively processes all properties in the object.\n   *\n   * @param value - The Zod object to process\n   * @returns The processed Zod object\n   */\n  public defaultZodObjectHandler(\n    value: ZodObject<any, any, any>,\n    options: { passthrough?: boolean } = { passthrough: true },\n  ): ZodObject<any, any, any> {\n    const processedShape = Object.entries(value.shape).reduce<Record<string, ZodTypeAny>>((acc, [key, propValue]) => {\n      acc[key] = this.processZodType(propValue as ZodTypeAny);\n      return acc;\n    }, {});\n\n    let result: ZodObject<any, any, any> = z.object(processedShape);\n\n    if (value._def.unknownKeys === 'strict') {\n      result = result.strict();\n    }\n    if (value._def.catchall && !(value._def.catchall instanceof z.ZodNever)) {\n      result = result.catchall(value._def.catchall);\n    }\n\n    if (value.description) {\n      result = result.describe(value.description);\n    }\n\n    if (options.passthrough && value._def.unknownKeys === 'passthrough') {\n      result = result.passthrough();\n    }\n\n    return result;\n  }\n\n  /**\n   * Merges validation constraints into a parameter description.\n   *\n   * This helper method converts validation constraints that may not be supported\n   * by a provider into human-readable descriptions.\n   *\n   * @param description - The existing parameter description\n   * @param constraints - The validation constraints to merge\n   * @returns The updated description with constraints, or undefined if no constraints\n   */\n  public mergeParameterDescription(\n    description: string | undefined,\n    constraints: ConstraintHelperText,\n  ): string | undefined {\n    if (constraints.length > 0) {\n      return (description ? description + '\\n' : '') + `constraints: ${constraints.join(`, `)}`;\n    } else {\n      return description;\n    }\n  }\n\n  /**\n   * Default handler for unsupported Zod types. Throws an error for specified unsupported types.\n   *\n   * @param value - The Zod type to check\n   * @param throwOnTypes - Array of type names to throw errors for\n   * @returns The original value if not in the throw list\n   * @throws Error if the type is in the unsupported list\n   */\n  public defaultUnsupportedZodTypeHandler<T extends z.AnyZodObject>(\n    value: z.ZodTypeAny,\n    throwOnTypes: readonly UnsupportedZodType[] = UNSUPPORTED_ZOD_TYPES,\n  ): ShapeValue<T> {\n    if (throwOnTypes.includes(value._def?.typeName as UnsupportedZodType)) {\n      throw new Error(`${this.model.modelId} does not support zod type: ${value._def?.typeName}`);\n    }\n    return value as ShapeValue<T>;\n  }\n\n  /**\n   * Default handler for Zod array types. Processes array constraints according to provider support.\n   *\n   * @param value - The Zod array to process\n   * @param handleChecks - Array constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod array\n   */\n  public defaultZodArrayHandler(\n    value: ZodArray<any, any>,\n    handleChecks: readonly ArrayCheckType[] = ALL_ARRAY_CHECKS,\n  ): ZodArray<any, any> {\n    const zodArrayDef = value._def;\n    const processedType = this.processZodType(zodArrayDef.type);\n\n    let result = z.array(processedType);\n\n    const constraints: ConstraintHelperText = [];\n\n    if (zodArrayDef.minLength?.value !== undefined) {\n      if (handleChecks.includes('min')) {\n        constraints.push(`minimum length ${zodArrayDef.minLength.value}`);\n      } else {\n        result = result.min(zodArrayDef.minLength.value);\n      }\n    }\n\n    if (zodArrayDef.maxLength?.value !== undefined) {\n      if (handleChecks.includes('max')) {\n        constraints.push(`maximum length ${zodArrayDef.maxLength.value}`);\n      } else {\n        result = result.max(zodArrayDef.maxLength.value);\n      }\n    }\n\n    if (zodArrayDef.exactLength?.value !== undefined) {\n      if (handleChecks.includes('length')) {\n        constraints.push(`exact length ${zodArrayDef.exactLength.value}`);\n      } else {\n        result = result.length(zodArrayDef.exactLength.value);\n      }\n    }\n\n    const description = this.mergeParameterDescription(value.description, constraints);\n    if (description) {\n      result = result.describe(description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod union types. Processes all union options.\n   *\n   * @param value - The Zod union to process\n   * @returns The processed Zod union\n   * @throws Error if union has fewer than 2 options\n   */\n  public defaultZodUnionHandler(value: ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>): ZodTypeAny {\n    const processedOptions = value._def.options.map((option: ZodTypeAny) => this.processZodType(option));\n    if (processedOptions.length < 2) throw new Error('Union must have at least 2 options');\n    let result = z.union(processedOptions as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]);\n    if (value.description) {\n      result = result.describe(value.description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod string types. Processes string validation constraints.\n   *\n   * @param value - The Zod string to process\n   * @param handleChecks - String constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod string\n   */\n  public defaultZodStringHandler(\n    value: ZodString,\n    handleChecks: readonly StringCheckType[] = ALL_STRING_CHECKS,\n  ): ZodString {\n    const constraints: ConstraintHelperText = [];\n    const checks = value._def.checks || [];\n    type ZodStringCheck = (typeof checks)[number];\n    const newChecks: ZodStringCheck[] = [];\n    for (const check of checks) {\n      if ('kind' in check) {\n        if (handleChecks.includes(check.kind as StringCheckType)) {\n          switch (check.kind) {\n            case 'regex': {\n              constraints.push(`input must match this regex ${check.regex.source}`);\n              break;\n            }\n            case 'emoji':\n            case 'email':\n            case 'url':\n            case 'uuid':\n            case 'cuid': {\n              constraints.push(`a valid ${check.kind}`);\n              break;\n            }\n            case 'min':\n            case 'max': {\n              constraints.push(`${check.kind}imum length ${check.value}`);\n              break;\n            }\n          }\n        } else {\n          newChecks.push(check);\n        }\n      }\n    }\n    let result = z.string();\n    for (const check of newChecks) {\n      result = result._addCheck(check);\n    }\n    const description = this.mergeParameterDescription(value.description, constraints);\n    if (description) {\n      result = result.describe(description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod number types. Processes number validation constraints.\n   *\n   * @param value - The Zod number to process\n   * @param handleChecks - Number constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod number\n   */\n  public defaultZodNumberHandler(\n    value: ZodNumber,\n    handleChecks: readonly NumberCheckType[] = ALL_NUMBER_CHECKS,\n  ): ZodNumber {\n    const constraints: ConstraintHelperText = [];\n    const checks = value._def.checks || [];\n    type ZodNumberCheck = (typeof checks)[number];\n    const newChecks: ZodNumberCheck[] = [];\n    for (const check of checks) {\n      if ('kind' in check) {\n        if (handleChecks.includes(check.kind as NumberCheckType)) {\n          switch (check.kind) {\n            case 'min':\n              if (check.inclusive) {\n                constraints.push(`greater than or equal to ${check.value}`);\n              } else {\n                constraints.push(`greater than ${check.value}`);\n              }\n              break;\n            case 'max':\n              if (check.inclusive) {\n                constraints.push(`lower than or equal to ${check.value}`);\n              } else {\n                constraints.push(`lower than ${check.value}`);\n              }\n              break;\n            case 'multipleOf': {\n              constraints.push(`multiple of ${check.value}`);\n              break;\n            }\n          }\n        } else {\n          newChecks.push(check);\n        }\n      }\n    }\n    let result = z.number();\n    for (const check of newChecks) {\n      switch (check.kind) {\n        case 'int':\n          result = result.int();\n          break;\n        case 'finite':\n          result = result.finite();\n          break;\n        default:\n          result = result._addCheck(check);\n      }\n    }\n    const description = this.mergeParameterDescription(value.description, constraints);\n    if (description) {\n      result = result.describe(description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.\n   *\n   * @param value - The Zod date to process\n   * @returns A Zod string schema representing the date in ISO format\n   */\n  public defaultZodDateHandler(value: ZodDate): ZodString {\n    const constraints: ConstraintHelperText = [];\n    const checks = value._def.checks || [];\n    type ZodDateCheck = (typeof checks)[number];\n    const newChecks: ZodDateCheck[] = [];\n    for (const check of checks) {\n      if ('kind' in check) {\n        switch (check.kind) {\n          case 'min':\n            const minDate = new Date(check.value);\n            if (!isNaN(minDate.getTime())) {\n              constraints.push(`Date must be newer than ${minDate.toISOString()} (ISO)`);\n            }\n            break;\n          case 'max':\n            const maxDate = new Date(check.value);\n            if (!isNaN(maxDate.getTime())) {\n              constraints.push(`Date must be older than ${maxDate.toISOString()} (ISO)`);\n            }\n            break;\n          default:\n            newChecks.push(check);\n        }\n      }\n    }\n    constraints.push(`Date format is date-time`);\n    let result = z.string().describe('date-time');\n    const description = this.mergeParameterDescription(value.description, constraints);\n    if (description) {\n      result = result.describe(description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod optional types. Processes the inner type and maintains optionality.\n   *\n   * @param value - The Zod optional to process\n   * @param handleTypes - Types that should be processed vs passed through\n   * @returns The processed Zod optional\n   */\n  public defaultZodOptionalHandler(\n    value: ZodOptional<any>,\n    handleTypes: readonly AllZodType[] = SUPPORTED_ZOD_TYPES,\n  ): ZodTypeAny {\n    if (handleTypes.includes(value._def.innerType._def.typeName as AllZodType)) {\n      return this.processZodType(value._def.innerType).optional();\n    } else {\n      return value;\n    }\n  }\n\n  /**\n   * Processes a Zod object schema and converts it to an AI SDK Schema.\n   *\n   * @param zodSchema - The Zod object schema to process\n   * @returns An AI SDK Schema with provider-specific compatibility applied\n   */\n  public processToAISDKSchema(zodSchema: z.ZodSchema): Schema {\n    const processedSchema = this.processZodType(zodSchema);\n\n    return convertZodSchemaToAISDKSchema(processedSchema, this.getSchemaTarget());\n  }\n\n  /**\n   * Processes a Zod object schema and converts it to a JSON Schema.\n   *\n   * @param zodSchema - The Zod object schema to process\n   * @returns A JSONSchema7 object with provider-specific compatibility applied\n   */\n  public processToJSONSchema(zodSchema: z.ZodSchema): JSONSchema7 {\n    return this.processToAISDKSchema(zodSchema).jsonSchema;\n  }\n}\n","import type { Schema } from 'ai';\nimport type { JSONSchema7 } from 'json-schema';\nimport {\n  z,\n  ZodOptional,\n  ZodObject,\n  ZodArray,\n  ZodUnion,\n  ZodString,\n  ZodNumber,\n  ZodDate,\n  ZodDefault,\n  ZodNull,\n  ZodNullable,\n} from 'zod/v4';\nimport type { ZodAny, ZodType } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport type { SchemaCompatLayer as ParentSchemaCompatLayer } from './schema-compatibility';\nimport type { ModelInformation } from './types';\nimport { convertZodSchemaToAISDKSchema } from './utils';\n\n/**\n * All supported string validation check types that can be processed or converted to descriptions.\n * @constant\n */\nexport const ALL_STRING_CHECKS = [\n  'regex',\n  'emoji',\n  'email',\n  'url',\n  'uuid',\n  'cuid',\n  'min_length',\n  'max_length',\n  'string_format',\n] as const;\n\n/**\n * All supported number validation check types that can be processed or converted to descriptions.\n * @constant\n */\nexport const ALL_NUMBER_CHECKS = ['greater_than', 'less_than', 'multiple_of'] as const;\n\n/**\n * All supported array validation check types that can be processed or converted to descriptions.\n * @constant\n */\nexport const ALL_ARRAY_CHECKS = ['min', 'max', 'length'] as const;\n\n/**\n * Zod types that are not supported by most AI model providers and should be avoided.\n * @constant\n */\nexport const UNSUPPORTED_ZOD_TYPES = ['ZodIntersection', 'ZodNever', 'ZodNull', 'ZodTuple', 'ZodUndefined'] as const;\n\n/**\n * Zod types that are generally supported by AI model providers.\n * @constant\n */\nexport const SUPPORTED_ZOD_TYPES = [\n  'ZodObject',\n  'ZodArray',\n  'ZodUnion',\n  'ZodString',\n  'ZodNumber',\n  'ZodDate',\n  'ZodAny',\n  'ZodDefault',\n  'ZodNullable',\n] as const;\n\n/**\n * All Zod types (both supported and unsupported).\n * @constant\n */\nexport const ALL_ZOD_TYPES = [...SUPPORTED_ZOD_TYPES, ...UNSUPPORTED_ZOD_TYPES] as const;\n\n/**\n * Type representing string validation checks.\n */\nexport type StringCheckType = (typeof ALL_STRING_CHECKS)[number];\n\n/**\n * Type representing number validation checks.\n */\nexport type NumberCheckType = (typeof ALL_NUMBER_CHECKS)[number];\n\n/**\n * Type representing array validation checks.\n */\nexport type ArrayCheckType = (typeof ALL_ARRAY_CHECKS)[number];\n\n/**\n * Type representing unsupported Zod schema types.\n */\nexport type UnsupportedZodType = (typeof UNSUPPORTED_ZOD_TYPES)[number];\n\n/**\n * Type representing supported Zod schema types.\n */\nexport type SupportedZodType = (typeof SUPPORTED_ZOD_TYPES)[number];\n\n/**\n * Type representing all Zod schema types (supported and unsupported).\n */\nexport type AllZodType = (typeof ALL_ZOD_TYPES)[number];\n\n/**\n * Utility type to extract the shape of a Zod object schema.\n */\nexport type ZodShape<T extends z.ZodObject<any, any>> = T['shape'];\n\n/**\n * Utility type to extract the keys from a Zod object shape.\n */\nexport type ShapeKey<T extends z.ZodObject<any, any>> = keyof ZodShape<T>;\n\n/**\n * Utility type to extract the value types from a Zod object shape.\n */\nexport type ShapeValue<T extends z.ZodObject<any, any>> = ZodShape<T>[ShapeKey<T>];\n\ntype ConstraintHelperText = string[];\n\n/**\n * Abstract base class for creating schema compatibility layers for different AI model providers.\n *\n * This class provides a framework for transforming Zod schemas to work with specific AI model\n * provider requirements and limitations. Each provider may have different support levels for\n * JSON Schema features, validation constraints, and data types.\n *\n *\n * @example\n * ```typescript\n * import { SchemaCompatLayer } from '@mastra/schema-compat';\n * import type { LanguageModelV1 } from 'ai';\n *\n * class CustomProviderCompat extends SchemaCompatLayer {\n *   constructor(model: LanguageModelV1) {\n *     super(model);\n *   }\n *\n *   shouldApply(): boolean {\n *     return this.getModel().provider === 'custom-provider';\n *   }\n *\n *   getSchemaTarget() {\n *     return 'jsonSchema7';\n *   }\n *\n *   processZodType<T extends z.AnyZodObject>(value: z.ZodAny): ShapeValue<T> {\n *     // Custom processing logic for this provider\n *     switch (value._def.typeName) {\n *       case 'ZodString':\n *         return this.defaultZodStringHandler(value, ['email', 'url']);\n *       default:\n *         return this.defaultUnsupportedZodTypeHandler(value);\n *     }\n *   }\n * }\n * ```\n */\nexport class SchemaCompatLayer {\n  private model: ModelInformation;\n  private parent: ParentSchemaCompatLayer;\n\n  /**\n   * Creates a new schema compatibility instance.\n   *\n   * @param model - The language model this compatibility layer applies to\n   */\n  constructor(model: ModelInformation, parent: ParentSchemaCompatLayer) {\n    this.model = model;\n    this.parent = parent;\n  }\n\n  /**\n   * Gets the language model associated with this compatibility layer.\n   *\n   * @returns The language model instance\n   */\n  getModel(): ModelInformation {\n    return this.model;\n  }\n\n  getUnsupportedZodTypes(): readonly string[] {\n    return UNSUPPORTED_ZOD_TYPES;\n  }\n\n  /**\n   * Type guard for optional Zod types\n   */\n  isOptional(v: ZodAny | ZodOptional<any>): v is ZodOptional<any> {\n    return v instanceof ZodOptional;\n  }\n\n  /**\n   * Type guard for object Zod types\n   */\n  isObj(v: ZodAny | ZodObject<any, any>): v is ZodObject<any, any> {\n    return v instanceof ZodObject;\n  }\n\n  /**\n   * Type guard for null Zod types\n   */\n  isNull(v: ZodAny | ZodNull): v is ZodNull {\n    return v instanceof ZodNull;\n  }\n\n  /**\n   * Type guard for nullable Zod types\n   */\n  isNullable(v: ZodAny | ZodNullable<any>): v is ZodNullable<any> {\n    return v instanceof ZodNullable;\n  }\n\n  /**\n   * Type guard for array Zod types\n   */\n  isArr(v: ZodAny | ZodArray<any>): v is ZodArray<any> {\n    return v instanceof ZodArray;\n  }\n\n  /**\n   * Type guard for union Zod types\n   */\n  isUnion(v: ZodAny | ZodUnion<[ZodAny, ...ZodAny[]]>): v is ZodUnion<[ZodAny, ...ZodAny[]]> {\n    return v instanceof ZodUnion;\n  }\n\n  /**\n   * Type guard for string Zod types\n   */\n  isString(v: ZodAny | ZodString): v is ZodString {\n    return v instanceof ZodString;\n  }\n\n  /**\n   * Type guard for number Zod types\n   */\n  isNumber(v: ZodAny | ZodNumber): v is ZodNumber {\n    return v instanceof ZodNumber;\n  }\n\n  /**\n   * Type guard for date Zod types\n   */\n  isDate(v: ZodAny | ZodDate): v is ZodDate {\n    return v instanceof ZodDate;\n  }\n\n  /**\n   * Type guard for default Zod types\n   */\n  isDefault(v: ZodAny | ZodDefault<any>): v is ZodDefault<any> {\n    return v instanceof ZodDefault;\n  }\n\n  /**\n   * Determines whether this compatibility layer should be applied for the current model.\n   *\n   * @returns True if this compatibility layer should be used, false otherwise\n   * @abstract\n   */\n  shouldApply(): boolean {\n    return this.parent.shouldApply();\n  }\n\n  /**\n   * Returns the JSON Schema target format for this provider.\n   *\n   * @returns The schema target format, or undefined to use the default 'jsonSchema7'\n   * @abstract\n   */\n  getSchemaTarget(): Targets | undefined {\n    return this.parent.getSchemaTarget();\n  }\n\n  /**\n   * Processes a specific Zod type according to the provider's requirements.\n   *\n   * @param value - The Zod type to process\n   * @returns The processed Zod type\n   * @abstract\n   */\n  processZodType(value: ZodType): ZodType {\n    return this.parent.processZodType(value);\n  }\n\n  /**\n   * Default handler for Zod object types. Recursively processes all properties in the object.\n   *\n   * @param value - The Zod object to process\n   * @returns The processed Zod object\n   */\n  public defaultZodObjectHandler(\n    value: ZodObject<any, any>,\n    options: { passthrough?: boolean } = { passthrough: true },\n  ): ZodObject<any, any> {\n    const processedShape = Object.entries(value.shape).reduce<Record<string, ZodType>>((acc, [key, propValue]) => {\n      acc[key] = this.processZodType(propValue as ZodAny);\n      return acc;\n    }, {});\n\n    let result: ZodObject<any, any> = z.object(processedShape);\n\n    if (value._zod.def.catchall instanceof z.ZodNever) {\n      result = z.strictObject(processedShape);\n    }\n    if (value._zod.def.catchall && !(value._zod.def.catchall instanceof z.ZodNever)) {\n      result = result.catchall(value._zod.def.catchall);\n    }\n\n    if (value.description) {\n      result = result.describe(value.description);\n    }\n\n    if (options.passthrough && value._zod.def.catchall instanceof z.ZodUnknown) {\n      result = z.looseObject(processedShape);\n    }\n\n    return result;\n  }\n\n  /**\n   * Merges validation constraints into a parameter description.\n   *\n   * This helper method converts validation constraints that may not be supported\n   * by a provider into human-readable descriptions.\n   *\n   * @param description - The existing parameter description\n   * @param constraints - The validation constraints to merge\n   * @returns The updated description with constraints, or undefined if no constraints\n   */\n  public mergeParameterDescription(\n    description: string | undefined,\n    constraints: ConstraintHelperText,\n  ): string | undefined {\n    if (constraints.length > 0) {\n      return (description ? description + '\\n' : '') + `constraints: ${constraints.join(`, `)}`;\n    } else {\n      return description;\n    }\n  }\n\n  /**\n   * Default handler for unsupported Zod types. Throws an error for specified unsupported types.\n   *\n   * @param value - The Zod type to check\n   * @param throwOnTypes - Array of type names to throw errors for\n   * @returns The original value if not in the throw list\n   * @throws Error if the type is in the unsupported list\n   */\n  public defaultUnsupportedZodTypeHandler<T extends z.ZodObject<any, any>>(\n    value: z.ZodAny,\n    throwOnTypes: readonly UnsupportedZodType[] = UNSUPPORTED_ZOD_TYPES,\n  ): ShapeValue<T> {\n    if (throwOnTypes.includes(value.constructor.name as UnsupportedZodType)) {\n      throw new Error(`${this.model.modelId} does not support zod type: ${value.constructor.name}`);\n    }\n    return value as ShapeValue<T>;\n  }\n\n  /**\n   * Default handler for Zod array types. Processes array constraints according to provider support.\n   *\n   * @param value - The Zod array to process\n   * @param handleChecks - Array constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod array\n   */\n  public defaultZodArrayHandler(\n    value: ZodArray<any>,\n    handleChecks: readonly ArrayCheckType[] = ALL_ARRAY_CHECKS,\n  ): ZodArray<any> {\n    const zodArrayDef = value._zod.def;\n    const processedType = this.processZodType(zodArrayDef.element);\n\n    let result = z.array(processedType);\n\n    const constraints: ConstraintHelperText = [];\n    if (zodArrayDef.checks) {\n      for (const check of zodArrayDef.checks) {\n        if (check._zod.def.check === 'min_length') {\n          if (handleChecks.includes('min')) {\n            // @ts-expect-error - fix later\n            constraints.push(`minimum length ${check._zod.def.minimum}`);\n          } else {\n            // @ts-expect-error - fix later\n            result = result.min(check._zod.def.minimum);\n          }\n        }\n        if (check._zod.def.check === 'max_length') {\n          if (handleChecks.includes('max')) {\n            // @ts-expect-error - fix later\n            constraints.push(`maximum length ${check._zod.def.maximum}`);\n          } else {\n            // @ts-expect-error - fix later\n            result = result.max(check._zod.def.maximum);\n          }\n        }\n        if (check._zod.def.check === 'length_equals') {\n          if (handleChecks.includes('length')) {\n            // @ts-expect-error - fix later\n            constraints.push(`exact length ${check._zod.def.length}`);\n          } else {\n            // @ts-expect-error - fix later\n            result = result.length(check._zod.def.length);\n          }\n        }\n      }\n    }\n\n    const metaDescription = value.meta()?.description;\n    const legacyDescription = value.description;\n\n    const description = this.mergeParameterDescription(metaDescription || legacyDescription, constraints);\n    if (description) {\n      result = result.describe(description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod union types. Processes all union options.\n   *\n   * @param value - The Zod union to process\n   * @returns The processed Zod union\n   * @throws Error if union has fewer than 2 options\n   */\n  public defaultZodUnionHandler(value: ZodUnion<[ZodAny, ...ZodAny[]]>): ZodAny {\n    const processedOptions = value._zod.def.options.map((option: ZodAny) => this.processZodType(option));\n    if (processedOptions.length < 2) throw new Error('Union must have at least 2 options');\n    let result = z.union(processedOptions as [ZodAny, ZodAny, ...ZodAny[]]);\n    if (value.description) {\n      result = result.describe(value.description);\n    }\n    // @ts-expect-error - fix later\n    return result;\n  }\n\n  /**\n   * Default handler for Zod string types. Processes string validation constraints.\n   *\n   * @param value - The Zod string to process\n   * @param handleChecks - String constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod string\n   */\n  public defaultZodStringHandler(\n    value: ZodString,\n    handleChecks: readonly StringCheckType[] = ALL_STRING_CHECKS,\n  ): ZodString {\n    const constraints: ConstraintHelperText = [];\n    const checks = value._zod.def.checks || [];\n    type ZodStringCheck = (typeof checks)[number];\n    const newChecks: ZodStringCheck[] = [];\n\n    if (checks) {\n      for (const check of checks) {\n        if (handleChecks.includes(check._zod.def.check as StringCheckType)) {\n          switch (check._zod.def.check) {\n            case 'min_length':\n              // @ts-expect-error - fix later\n              constraints.push(`minimum length ${check._zod.def.minimum}`);\n              break;\n            case 'max_length':\n              // @ts-expect-error - fix later\n              constraints.push(`maximum length ${check._zod.def.maximum}`);\n              break;\n            case 'string_format':\n              {\n                // @ts-expect-error - fix later\n                switch (check._zod.def.format) {\n                  case 'email':\n                  case 'url':\n                  case 'emoji':\n                  case 'uuid':\n                  case 'cuid':\n                    // @ts-expect-error - fix later\n                    constraints.push(`a valid ${check._zod.def.format}`);\n                    break;\n                  case 'regex':\n                    // @ts-expect-error - fix later\n                    constraints.push(`input must match this regex ${check._zod.def.pattern}`);\n                    break;\n                }\n              }\n              break;\n          }\n        } else {\n          newChecks.push(check);\n        }\n      }\n    }\n\n    let result = z.string();\n    for (const check of newChecks) {\n      result = result.check(check);\n    }\n\n    const metaDescription = value.meta()?.description;\n    const legacyDescription = value.description;\n\n    const description = this.mergeParameterDescription(metaDescription || legacyDescription, constraints);\n    if (description) {\n      result = result.describe(description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod number types. Processes number validation constraints.\n   *\n   * @param value - The Zod number to process\n   * @param handleChecks - Number constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod number\n   */\n  public defaultZodNumberHandler(\n    value: ZodNumber,\n    handleChecks: readonly NumberCheckType[] = ALL_NUMBER_CHECKS,\n  ): ZodNumber {\n    const constraints: ConstraintHelperText = [];\n    const checks = value._zod.def.checks || [];\n    type ZodNumberCheck = (typeof checks)[number];\n    const newChecks: ZodNumberCheck[] = [];\n\n    if (checks) {\n      for (const check of checks) {\n        if (handleChecks.includes(check._zod.def.check as NumberCheckType)) {\n          switch (check._zod.def.check) {\n            case 'greater_than':\n              // @ts-expect-error - fix later\n              if (check._zod.def.inclusive) {\n                // @ts-expect-error - fix later\n                constraints.push(`greater than or equal to ${check._zod.def.value}`);\n              } else {\n                // @ts-expect-error - fix later\n                constraints.push(`greater than ${check._zod.def.value}`);\n              }\n              break;\n            case 'less_than':\n              // @ts-expect-error - fix later\n              if (check._zod.def.inclusive) {\n                // @ts-expect-error - fix later\n                constraints.push(`lower than or equal to ${check._zod.def.value}`);\n              } else {\n                // @ts-expect-error - fix later\n                constraints.push(`lower than ${check._zod.def.value}`);\n              }\n              break;\n            case 'multiple_of': {\n              // @ts-expect-error - fix later\n              constraints.push(`multiple of ${check._zod.def.value}`);\n              break;\n            }\n          }\n        } else {\n          newChecks.push(check);\n        }\n      }\n    }\n    let result = z.number();\n\n    for (const check of newChecks) {\n      switch (check._zod.def.check) {\n        case 'number_format': {\n          // @ts-expect-error - fix later\n          switch (check._zod.def.format) {\n            case 'safeint':\n              result = result.int();\n              break;\n          }\n          break;\n        }\n        default:\n          // @ts-expect-error - fix later\n          result = result.check(check);\n      }\n    }\n    const description = this.mergeParameterDescription(value.description, constraints);\n    if (description) {\n      result = result.describe(description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.\n   *\n   * @param value - The Zod date to process\n   * @returns A Zod string schema representing the date in ISO format\n   */\n  public defaultZodDateHandler(value: ZodDate): ZodString {\n    const constraints: ConstraintHelperText = [];\n    const checks = value._zod.def.checks || [];\n    type ZodDateCheck = (typeof checks)[number];\n    const newChecks: ZodDateCheck[] = [];\n    if (checks) {\n      for (const check of checks) {\n        switch (check._zod.def.check) {\n          case 'less_than':\n            // @ts-expect-error - fix later\n            const minDate = new Date(check._zod.def.value);\n            if (!isNaN(minDate.getTime())) {\n              constraints.push(`Date must be newer than ${minDate.toISOString()} (ISO)`);\n            }\n            break;\n          case 'greater_than':\n            // @ts-expect-error - fix later\n            const maxDate = new Date(check._zod.def.value);\n            if (!isNaN(maxDate.getTime())) {\n              constraints.push(`Date must be older than ${maxDate.toISOString()} (ISO)`);\n            }\n            break;\n          default:\n            newChecks.push(check);\n        }\n      }\n    }\n    constraints.push(`Date format is date-time`);\n    let result = z.string().describe('date-time');\n    const description = this.mergeParameterDescription(value.description, constraints);\n    if (description) {\n      result = result.describe(description);\n    }\n    return result;\n  }\n\n  /**\n   * Default handler for Zod optional types. Processes the inner type and maintains optionality.\n   *\n   * @param value - The Zod optional to process\n   * @param handleTypes - Types that should be processed vs passed through\n   * @returns The processed Zod optional\n   */\n  public defaultZodOptionalHandler(\n    value: ZodOptional<any>,\n    handleTypes: readonly AllZodType[] = SUPPORTED_ZOD_TYPES,\n  ): ZodType {\n    if (handleTypes.includes(value.constructor.name as AllZodType)) {\n      return this.processZodType(value._zod.def.innerType).optional();\n    } else {\n      return value;\n    }\n  }\n\n  /**\n   * Processes a Zod object schema and converts it to an AI SDK Schema.\n   *\n   * @param zodSchema - The Zod object schema to process\n   * @returns An AI SDK Schema with provider-specific compatibility applied\n   */\n  public processToAISDKSchema(zodSchema: ZodType): Schema {\n    const processedSchema = this.processZodType(zodSchema);\n\n    return convertZodSchemaToAISDKSchema(processedSchema, this.getSchemaTarget());\n  }\n\n  /**\n   * Processes a Zod object schema and converts it to a JSON Schema.\n   *\n   * @param zodSchema - The Zod object schema to process\n   * @returns A JSONSchema7 object with provider-specific compatibility applied\n   */\n  public processToJSONSchema(zodSchema: ZodType): JSONSchema7 {\n    return this.processToAISDKSchema(zodSchema).jsonSchema;\n  }\n}\n","import type { Schema } from 'ai';\nimport type { JSONSchema7 } from 'json-schema';\nimport type { z as zV3 } from 'zod/v3';\nimport type { z as zV4, ZodType } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport {\n  SchemaCompatLayer as SchemaCompatLayerV3,\n  ALL_STRING_CHECKS,\n  ALL_NUMBER_CHECKS,\n  ALL_ARRAY_CHECKS,\n  UNSUPPORTED_ZOD_TYPES as UNSUPPORTED_ZOD_TYPES_V3,\n  SUPPORTED_ZOD_TYPES as SUPPORTED_ZOD_TYPES_V3,\n} from './schema-compatibility-v3';\nimport type {\n  UnsupportedZodType as UnsupportedZodTypeV3,\n  ShapeValue as ShapeValueV3,\n  StringCheckType,\n  NumberCheckType,\n  ArrayCheckType,\n  AllZodType as AllZodTypeV3,\n} from './schema-compatibility-v3';\nimport {\n  SchemaCompatLayer as SchemaCompatLayerV4,\n  UNSUPPORTED_ZOD_TYPES as UNSUPPORTED_ZOD_TYPES_V4,\n  SUPPORTED_ZOD_TYPES as SUPPORTED_ZOD_TYPES_V4,\n} from './schema-compatibility-v4';\nimport type {\n  UnsupportedZodType as UnsupportedZodTypeV4,\n  ShapeValue as ShapeValueV4,\n  AllZodType as AllZodTypeV4,\n} from './schema-compatibility-v4';\n\nimport type { ModelInformation } from './types';\nimport { convertZodSchemaToAISDKSchema } from './utils';\n\ntype ConstraintHelperText = string[];\n\nexport abstract class SchemaCompatLayer {\n  private model: ModelInformation;\n  private v3Layer: SchemaCompatLayerV3;\n  private v4Layer: SchemaCompatLayerV4;\n\n  /**\n   * Creates a new schema compatibility instance.\n   *\n   * @param model - The language model this compatibility layer applies to\n   */\n  constructor(model: ModelInformation) {\n    this.model = model;\n    this.v3Layer = new SchemaCompatLayerV3(model, this);\n    this.v4Layer = new SchemaCompatLayerV4(model, this);\n  }\n\n  /**\n   * Gets the language model associated with this compatibility layer.\n   *\n   * @returns The language model instance\n   */\n  getModel(): ModelInformation {\n    return this.model;\n  }\n\n  getUnsupportedZodTypes(v: ZodType): readonly string[] {\n    if ('_zod' in v) {\n      return this.v4Layer.getUnsupportedZodTypes();\n    } else {\n      return this.v3Layer.getUnsupportedZodTypes();\n    }\n  }\n\n  /**\n   * Type guard for optional Zod types\n   */\n  isOptional(v: zV4.ZodType): v is zV4.ZodOptional<any>;\n  isOptional(v: zV3.ZodType): v is zV3.ZodOptional<any>;\n  isOptional(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isOptional(v);\n    } else {\n      return this.v3Layer.isOptional(v);\n    }\n  }\n\n  /**\n   * Type guard for object Zod types\n   */\n  isObj(v: zV4.ZodType): v is zV4.ZodObject<any, any>;\n  isObj(v: zV3.ZodType): v is zV3.ZodObject<any, any, any, any, any>;\n  isObj(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isObj(v);\n    } else {\n      return this.v3Layer.isObj(v);\n    }\n  }\n\n  /**\n   * Type guard for null Zod types\n   */\n  isNull(v: zV4.ZodType): v is zV4.ZodNull;\n  isNull(v: zV3.ZodType): v is zV3.ZodNull;\n  isNull(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isNull(v);\n    } else {\n      return this.v3Layer.isNull(v);\n    }\n  }\n\n  /**\n   * Type guard for array Zod types\n   */\n  isArr(v: zV4.ZodType): v is zV4.ZodArray<any>;\n  isArr(v: zV3.ZodType): v is zV3.ZodArray<any, any>;\n  isArr(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isArr(v);\n    } else {\n      return this.v3Layer.isArr(v);\n    }\n  }\n\n  /**\n   * Type guard for union Zod types\n   */\n  isUnion(v: zV4.ZodType): v is zV4.ZodUnion<[zV4.ZodType, ...zV4.ZodType[]]>;\n  isUnion(v: zV3.ZodType): v is zV3.ZodUnion<[zV3.ZodType, ...zV3.ZodType[]]>;\n  isUnion(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isUnion(v);\n    } else {\n      return this.v3Layer.isUnion(v);\n    }\n  }\n\n  /**\n   * Type guard for string Zod types\n   */\n  isString(v: zV4.ZodType): v is zV4.ZodString;\n  isString(v: zV3.ZodType): v is zV3.ZodString;\n  isString(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isString(v);\n    } else {\n      return this.v3Layer.isString(v);\n    }\n  }\n\n  /**\n   * Type guard for number Zod types\n   */\n  isNumber(v: zV4.ZodType): v is zV4.ZodNumber;\n  isNumber(v: zV3.ZodType): v is zV3.ZodNumber;\n  isNumber(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isNumber(v);\n    } else {\n      return this.v3Layer.isNumber(v);\n    }\n  }\n\n  /**\n   * Type guard for date Zod types\n   */\n  isDate(v: zV4.ZodType): v is zV4.ZodDate;\n  isDate(v: zV3.ZodType): v is zV3.ZodDate;\n  isDate(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isDate(v);\n    } else {\n      return this.v3Layer.isDate(v);\n    }\n  }\n\n  /**\n   * Type guard for default Zod types\n   */\n  isDefault(v: zV4.ZodType): v is zV4.ZodDefault<any>;\n  isDefault(v: zV3.ZodType): v is zV3.ZodDefault<any>;\n  isDefault(v: zV3.ZodType | zV4.ZodType) {\n    if ('_zod' in v) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.isDefault(v);\n    } else {\n      return this.v3Layer.isDefault(v);\n    }\n  }\n\n  /**\n   * Determines whether this compatibility layer should be applied for the current model.\n   *\n   * @returns True if this compatibility layer should be used, false otherwise\n   * @abstract\n   */\n  abstract shouldApply(): boolean;\n\n  /**\n   * Returns the JSON Schema target format for this provider.\n   *\n   * @returns The schema target format, or undefined to use the default 'jsonSchema7'\n   * @abstract\n   */\n  abstract getSchemaTarget(): Targets | undefined;\n\n  /**\n   * Processes a specific Zod type according to the provider's requirements.\n   *\n   * @param value - The Zod type to process\n   * @returns The processed Zod type\n   * @abstract\n   */\n  abstract processZodType(value: zV4.ZodType): zV4.ZodType;\n  abstract processZodType(value: zV3.ZodType): zV3.ZodType;\n  abstract processZodType(value: zV4.ZodType | zV3.ZodType): zV4.ZodType | zV3.ZodType;\n\n  /**\n   * Default handler for Zod object types. Recursively processes all properties in the object.\n   *\n   * @param value - The Zod object to process\n   * @returns The processed Zod object\n   */\n  public defaultZodObjectHandler(\n    value: zV4.ZodObject<any, any>,\n    options?: { passthrough?: boolean },\n  ): zV4.ZodObject<any, any>;\n  public defaultZodObjectHandler(\n    value: zV3.ZodObject<any, any>,\n    options?: { passthrough?: boolean },\n  ): zV3.ZodObject<any, any>;\n  public defaultZodObjectHandler(\n    value: zV3.ZodObject<any, any, any, any, any> | zV4.ZodObject<any, any>,\n    options: { passthrough?: boolean } = { passthrough: true },\n  ): zV3.ZodObject<any, any, any, any, any> | zV4.ZodObject<any, any> {\n    if ('_zod' in value) {\n      return this.v4Layer.defaultZodObjectHandler(value, options);\n    } else {\n      return this.v3Layer.defaultZodObjectHandler(value, options);\n    }\n  }\n\n  /**\n   * Merges validation constraints into a parameter description.\n   *\n   * This helper method converts validation constraints that may not be supported\n   * by a provider into human-readable descriptions.\n   *\n   * @param description - The existing parameter description\n   * @param constraints - The validation constraints to merge\n   * @returns The updated description with constraints, or undefined if no constraints\n   */\n  public mergeParameterDescription(\n    description: string | undefined,\n    constraints: ConstraintHelperText,\n  ): string | undefined {\n    // This method doesn't depend on Zod version, so we can use either layer\n    return this.v3Layer.mergeParameterDescription(description, constraints);\n  }\n\n  /**\n   * Default handler for unsupported Zod types. Throws an error for specified unsupported types.\n   *\n   * @param value - The Zod type to check\n   * @param throwOnTypes - Array of type names to throw errors for\n   * @returns The original value if not in the throw list\n   * @throws Error if the type is in the unsupported list\n   */\n  public defaultUnsupportedZodTypeHandler<T extends zV4.ZodObject | zV3.AnyZodObject>(\n    value: T,\n    throwOnTypes?: T extends zV4.ZodObject\n      ? UnsupportedZodTypeV4[]\n      : T extends zV3.AnyZodObject\n        ? UnsupportedZodTypeV3[]\n        : never,\n  ): T extends zV4.ZodObject ? ShapeValueV4<T> : T extends zV3.AnyZodObject ? ShapeValueV3<T> : never {\n    if ('_zod' in value) {\n      return this.v4Layer.defaultUnsupportedZodTypeHandler(\n        // @ts-expect-error - fix later\n        value,\n        (throwOnTypes ?? UNSUPPORTED_ZOD_TYPES_V4) as typeof UNSUPPORTED_ZOD_TYPES_V4,\n      );\n    } else {\n      return this.v3Layer.defaultUnsupportedZodTypeHandler(\n        value,\n        (throwOnTypes ?? UNSUPPORTED_ZOD_TYPES_V3) as typeof UNSUPPORTED_ZOD_TYPES_V3,\n      );\n    }\n  }\n\n  /**\n   * Default handler for Zod array types. Processes array constraints according to provider support.\n   *\n   * @param value - The Zod array to process\n   * @param handleChecks - Array constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod array\n   */\n  public defaultZodArrayHandler(value: zV4.ZodArray<any>, handleChecks?: readonly ArrayCheckType[]): zV4.ZodArray<any>;\n  public defaultZodArrayHandler(\n    value: zV3.ZodArray<any, any>,\n    handleChecks?: readonly ArrayCheckType[],\n  ): zV3.ZodArray<any, any>;\n  public defaultZodArrayHandler(\n    value: zV4.ZodArray<any> | zV3.ZodArray<any, any>,\n    handleChecks: readonly ArrayCheckType[] = ALL_ARRAY_CHECKS,\n  ): zV4.ZodArray<any> | zV3.ZodArray<any, any> {\n    if ('_zod' in value) {\n      return this.v4Layer.defaultZodArrayHandler(value, handleChecks);\n    } else {\n      return this.v3Layer.defaultZodArrayHandler(value, handleChecks);\n    }\n  }\n\n  /**\n   * Default handler for Zod union types. Processes all union options.\n   *\n   * @param value - The Zod union to process\n   * @returns The processed Zod union\n   * @throws Error if union has fewer than 2 options\n   */\n  public defaultZodUnionHandler(value: zV4.ZodUnion<[zV4.ZodType, ...zV4.ZodType[]]>): zV4.ZodType;\n  public defaultZodUnionHandler(value: zV3.ZodUnion<[zV3.ZodType, ...zV3.ZodType[]]>): zV3.ZodType;\n  public defaultZodUnionHandler(\n    value: zV4.ZodUnion<[zV4.ZodType, ...zV4.ZodType[]]> | zV3.ZodUnion<[zV3.ZodType, ...zV3.ZodType[]]>,\n  ): zV4.ZodType | zV3.ZodType {\n    if ('_zod' in value) {\n      // @ts-expect-error - fix later\n      return this.v4Layer.defaultZodUnionHandler(value);\n    } else {\n      return this.v3Layer.defaultZodUnionHandler(value);\n    }\n  }\n\n  /**\n   * Default handler for Zod string types. Processes string validation constraints.\n   *\n   * @param value - The Zod string to process\n   * @param handleChecks - String constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod string\n   */\n  public defaultZodStringHandler(value: zV4.ZodString, handleChecks?: readonly StringCheckType[]): zV4.ZodString;\n  public defaultZodStringHandler(value: zV3.ZodString, handleChecks?: readonly StringCheckType[]): zV3.ZodString;\n  public defaultZodStringHandler(\n    value: zV4.ZodString | zV3.ZodString,\n    handleChecks: readonly StringCheckType[] = ALL_STRING_CHECKS,\n  ): zV4.ZodString | zV3.ZodString {\n    if ('_zod' in value) {\n      return this.v4Layer.defaultZodStringHandler(value);\n    } else {\n      return this.v3Layer.defaultZodStringHandler(value, handleChecks);\n    }\n  }\n\n  /**\n   * Default handler for Zod number types. Processes number validation constraints.\n   *\n   * @param value - The Zod number to process\n   * @param handleChecks - Number constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod number\n   */\n  public defaultZodNumberHandler(value: zV4.ZodNumber, handleChecks?: readonly NumberCheckType[]): zV4.ZodNumber;\n  public defaultZodNumberHandler(value: zV3.ZodNumber, handleChecks?: readonly NumberCheckType[]): zV3.ZodNumber;\n  public defaultZodNumberHandler(\n    value: zV4.ZodNumber | zV3.ZodNumber,\n    handleChecks: readonly NumberCheckType[] = ALL_NUMBER_CHECKS,\n  ): zV4.ZodNumber | zV3.ZodNumber {\n    if ('_zod' in value) {\n      return this.v4Layer.defaultZodNumberHandler(value);\n    } else {\n      return this.v3Layer.defaultZodNumberHandler(value, handleChecks);\n    }\n  }\n\n  /**\n   * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.\n   *\n   * @param value - The Zod date to process\n   * @returns A Zod string schema representing the date in ISO format\n   */\n  public defaultZodDateHandler(value: zV4.ZodDate): zV4.ZodString;\n  public defaultZodDateHandler(value: zV3.ZodDate): zV3.ZodString;\n  public defaultZodDateHandler(value: zV4.ZodDate | zV3.ZodDate): zV4.ZodString | zV3.ZodString {\n    if ('_zod' in value) {\n      return this.v4Layer.defaultZodDateHandler(value);\n    } else {\n      return this.v3Layer.defaultZodDateHandler(value);\n    }\n  }\n\n  /**\n   * Default handler for Zod optional types. Processes the inner type and maintains optionality.\n   *\n   * @param value - The Zod optional to process\n   * @param handleTypes - Types that should be processed vs passed through\n   * @returns The processed Zod optional\n   */\n  public defaultZodOptionalHandler(value: zV4.ZodOptional<any>, handleTypes?: readonly AllZodTypeV4[]): zV4.ZodType;\n  public defaultZodOptionalHandler(value: zV3.ZodOptional<any>, handleTypes?: readonly AllZodTypeV3[]): zV3.ZodType;\n  public defaultZodOptionalHandler(\n    value: zV4.ZodOptional<any> | zV3.ZodOptional<any>,\n    handleTypes?: readonly AllZodTypeV3[] | readonly AllZodTypeV4[],\n  ): zV4.ZodType | zV3.ZodType {\n    if ('_zod' in value) {\n      return this.v4Layer.defaultZodOptionalHandler(value, handleTypes ?? SUPPORTED_ZOD_TYPES_V4);\n    } else {\n      return this.v3Layer.defaultZodOptionalHandler(value, handleTypes ?? SUPPORTED_ZOD_TYPES_V3);\n    }\n  }\n\n  /**\n   * Processes a Zod object schema and converts it to an AI SDK Schema.\n   *\n   * @param zodSchema - The Zod object schema to process\n   * @returns An AI SDK Schema with provider-specific compatibility applied\n   */\n  public processToAISDKSchema(zodSchema: zV3.ZodSchema | zV4.ZodType): Schema {\n    const processedSchema = this.processZodType(zodSchema);\n\n    return convertZodSchemaToAISDKSchema(processedSchema, this.getSchemaTarget());\n  }\n\n  /**\n   * Processes a Zod object schema and converts it to a JSON Schema.\n   *\n   * @param zodSchema - The Zod object schema to process\n   * @returns A JSONSchema7 object with provider-specific compatibility applied\n   */\n  public processToJSONSchema(zodSchema: zV3.ZodSchema | zV4.ZodType): JSONSchema7 {\n    return this.processToAISDKSchema(zodSchema).jsonSchema;\n  }\n}\n","import type { z as zV3 } from 'zod/v3';\nimport type { z as zV4 } from 'zod/v4';\n\nexport function isOptional<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodOptional<any>;\nexport function isOptional<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodOptional<any>;\nexport function isOptional<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodOptional'] => v instanceof z['ZodOptional'];\n}\n\nexport function isObj<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodObject<any>;\nexport function isObj<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodObject;\nexport function isObj<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodObject'] => v instanceof z['ZodObject'];\n}\n\nexport function isNull<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodNull;\nexport function isNull<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodNull;\nexport function isNull<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodNull'] => v instanceof z['ZodNull'];\n}\n\nexport function isArr<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodArray<any>;\nexport function isArr<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodArray;\nexport function isArr<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodArray'] => v instanceof z['ZodArray'];\n}\n\nexport function isUnion<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodUnion<any>;\nexport function isUnion<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodUnion;\nexport function isUnion<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodUnion'] => v instanceof z['ZodUnion'];\n}\n\nexport function isString<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodString;\nexport function isString<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodString;\nexport function isString<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodString'] => v instanceof z['ZodString'];\n}\n\nexport function isNumber<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodNumber;\nexport function isNumber<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodNumber;\nexport function isNumber<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodNumber'] => v instanceof z['ZodNumber'];\n}\n\nexport function isDate<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodDate;\nexport function isDate<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodDate;\nexport function isDate<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodDate'] => v instanceof z['ZodDate'];\n}\n\nexport function isDefault<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodDefault<any>;\nexport function isDefault<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodDefault;\nexport function isDefault<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodDefault'] => v instanceof z['ZodDefault'];\n}\n\nexport function isNullable<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodNullable<any>;\nexport function isNullable<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodNullable;\nexport function isNullable<Z extends typeof zV3 | typeof zV4>(z: Z) {\n  return (v: any): v is Z['ZodNullable'] => v instanceof z['ZodNullable'];\n}\n","import { z } from 'zod';\nimport type { ZodType as ZodTypeV3, ZodObject as ZodObjectV3 } from 'zod/v3';\nimport type { ZodType as ZodTypeV4, ZodObject as ZodObjectV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport { SchemaCompatLayer } from '../schema-compatibility';\nimport type { AllZodType as AllZodTypeV3 } from '../schema-compatibility-v3';\nimport type { AllZodType as AllZodTypeV4 } from '../schema-compatibility-v4';\nimport type { ModelInformation } from '../types';\nimport { isOptional, isObj, isArr, isUnion, isString } from '../zodTypes';\n\nexport class AnthropicSchemaCompatLayer extends SchemaCompatLayer {\n  constructor(model: ModelInformation) {\n    super(model);\n  }\n\n  getSchemaTarget(): Targets | undefined {\n    return 'jsonSchema7';\n  }\n\n  shouldApply(): boolean {\n    return this.getModel().modelId.includes('claude');\n  }\n\n  processZodType(value: ZodTypeV3): ZodTypeV3;\n  processZodType(value: ZodTypeV4): ZodTypeV4;\n  processZodType(value: ZodTypeV3 | ZodTypeV4): ZodTypeV3 | ZodTypeV4 {\n    if (isOptional(z)(value)) {\n      const handleTypes: AllZodTypeV3[] | AllZodTypeV4 = [\n        'ZodObject',\n        'ZodArray',\n        'ZodUnion',\n        'ZodNever',\n        'ZodUndefined',\n        'ZodTuple',\n      ];\n      if (this.getModel().modelId.includes('claude-3.5-haiku')) handleTypes.push('ZodString');\n      return this.defaultZodOptionalHandler(value, handleTypes);\n    } else if (isObj(z)(value)) {\n      return this.defaultZodObjectHandler(value);\n    } else if (isArr(z)(value)) {\n      return this.defaultZodArrayHandler(value, []);\n    } else if (isUnion(z)(value)) {\n      return this.defaultZodUnionHandler(value);\n    } else if (isString(z)(value)) {\n      // the claude-3.5-haiku model support these properties but the model doesn't respect them, but it respects them when they're\n      // added to the tool description\n\n      if (this.getModel().modelId.includes('claude-3.5-haiku')) {\n        return this.defaultZodStringHandler(value, ['max', 'min']);\n      } else {\n        return value;\n      }\n    }\n\n    return this.defaultUnsupportedZodTypeHandler(value as ZodObjectV4<any> | ZodObjectV3<any>, [\n      'ZodNever',\n      'ZodTuple',\n      'ZodUndefined',\n    ]);\n  }\n}\n","import { z } from 'zod';\nimport type { ZodType as ZodTypeV3 } from 'zod/v3';\nimport type { ZodType as ZodTypeV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport { SchemaCompatLayer } from '../schema-compatibility';\nimport type { ModelInformation } from '../types';\nimport { isOptional, isObj, isArr, isUnion, isString } from '../zodTypes';\n\nexport class DeepSeekSchemaCompatLayer extends SchemaCompatLayer {\n  constructor(model: ModelInformation) {\n    super(model);\n  }\n\n  getSchemaTarget(): Targets | undefined {\n    return 'jsonSchema7';\n  }\n\n  shouldApply(): boolean {\n    // Deepseek R1 performs perfectly without this compat layer\n    return this.getModel().modelId.includes('deepseek') && !this.getModel().modelId.includes('r1');\n  }\n\n  processZodType(value: ZodTypeV3): ZodTypeV3;\n  processZodType(value: ZodTypeV4): ZodTypeV4;\n  processZodType(value: ZodTypeV3 | ZodTypeV4): ZodTypeV3 | ZodTypeV4 {\n    if (isOptional(z)(value)) {\n      return this.defaultZodOptionalHandler(value, ['ZodObject', 'ZodArray', 'ZodUnion', 'ZodString', 'ZodNumber']);\n    } else if (isObj(z)(value)) {\n      return this.defaultZodObjectHandler(value);\n    } else if (isArr(z)(value)) {\n      return this.defaultZodArrayHandler(value, ['min', 'max']);\n    } else if (isUnion(z)(value)) {\n      return this.defaultZodUnionHandler(value);\n    } else if (isString(z)(value)) {\n      return this.defaultZodStringHandler(value);\n    }\n\n    return value;\n  }\n}\n","import { z } from 'zod';\nimport type { ZodType as ZodTypeV3, ZodObject as ZodObjectV3 } from 'zod/v3';\nimport type { ZodType as ZodTypeV4, ZodObject as ZodObjectV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport { SchemaCompatLayer } from '../schema-compatibility';\nimport type { ModelInformation } from '../types';\nimport { isOptional, isNull, isObj, isArr, isUnion, isString, isNumber } from '../zodTypes';\n\nexport class GoogleSchemaCompatLayer extends SchemaCompatLayer {\n  constructor(model: ModelInformation) {\n    super(model);\n  }\n\n  getSchemaTarget(): Targets | undefined {\n    return 'jsonSchema7';\n  }\n\n  shouldApply(): boolean {\n    return this.getModel().provider.includes('google') || this.getModel().modelId.includes('google');\n  }\n  processZodType(value: ZodTypeV3): ZodTypeV3;\n  processZodType(value: ZodTypeV4): ZodTypeV4;\n  processZodType(value: ZodTypeV3 | ZodTypeV4): ZodTypeV3 | ZodTypeV4 {\n    if (isOptional(z)(value)) {\n      return this.defaultZodOptionalHandler(value, ['ZodObject', 'ZodArray', 'ZodUnion', 'ZodString', 'ZodNumber']);\n    } else if (isNull(z)(value)) {\n      // Google models don't support null, so we need to convert it to any and then refine it to null\n      return z\n        .any()\n        .refine(v => v === null, { message: 'must be null' })\n        .describe(value.description || 'must be null');\n    } else if (isObj(z)(value)) {\n      return this.defaultZodObjectHandler(value);\n    } else if (isArr(z)(value)) {\n      return this.defaultZodArrayHandler(value, []);\n    } else if (isUnion(z)(value)) {\n      return this.defaultZodUnionHandler(value);\n    } else if (isString(z)(value)) {\n      // Google models support these properties but the model doesn't respect them, but it respects them when they're\n      // added to the tool description\n      return this.defaultZodStringHandler(value);\n    } else if (isNumber(z)(value)) {\n      // Google models support these properties but the model doesn't respect them, but it respects them when they're\n      // added to the tool description\n      return this.defaultZodNumberHandler(value);\n    }\n    return this.defaultUnsupportedZodTypeHandler(value as ZodObjectV4<any> | ZodObjectV3<any>);\n  }\n}\n","import { z } from 'zod';\nimport type { ZodType as ZodTypeV3 } from 'zod/v3';\nimport type { ZodType as ZodTypeV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport { SchemaCompatLayer } from '../schema-compatibility';\nimport type { ModelInformation } from '../types';\nimport { isOptional, isObj, isArr, isUnion, isNumber, isString } from '../zodTypes';\n\nexport class MetaSchemaCompatLayer extends SchemaCompatLayer {\n  constructor(model: ModelInformation) {\n    super(model);\n  }\n\n  getSchemaTarget(): Targets | undefined {\n    return 'jsonSchema7';\n  }\n\n  shouldApply(): boolean {\n    return this.getModel().modelId.includes('meta');\n  }\n\n  processZodType(value: ZodTypeV3): ZodTypeV3;\n  processZodType(value: ZodTypeV4): ZodTypeV4;\n  processZodType(value: ZodTypeV3 | ZodTypeV4): ZodTypeV3 | ZodTypeV4 {\n    if (isOptional(z)(value)) {\n      return this.defaultZodOptionalHandler(value, ['ZodObject', 'ZodArray', 'ZodUnion', 'ZodString', 'ZodNumber']);\n    } else if (isObj(z)(value)) {\n      return this.defaultZodObjectHandler(value);\n    } else if (isArr(z)(value)) {\n      return this.defaultZodArrayHandler(value, ['min', 'max']);\n    } else if (isUnion(z)(value)) {\n      return this.defaultZodUnionHandler(value);\n    } else if (isNumber(z)(value)) {\n      return this.defaultZodNumberHandler(value);\n    } else if (isString(z)(value)) {\n      return this.defaultZodStringHandler(value);\n    }\n\n    return value;\n  }\n}\n","import { z } from 'zod';\nimport type { ZodType as ZodTypeV3, ZodObject as ZodObjectV3 } from 'zod/v3';\nimport type { ZodType as ZodTypeV4, ZodObject as ZodObjectV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport { SchemaCompatLayer } from '../schema-compatibility';\nimport type { ModelInformation } from '../types';\nimport { isOptional, isObj, isUnion, isArr, isString, isNullable } from '../zodTypes';\n\nexport class OpenAISchemaCompatLayer extends SchemaCompatLayer {\n  constructor(model: ModelInformation) {\n    super(model);\n  }\n\n  getSchemaTarget(): Targets | undefined {\n    return `jsonSchema7`;\n  }\n\n  shouldApply(): boolean {\n    if (\n      !this.getModel().supportsStructuredOutputs &&\n      (this.getModel().provider.includes(`openai`) || this.getModel().modelId.includes(`openai`))\n    ) {\n      return true;\n    }\n\n    return false;\n  }\n\n  processZodType(value: ZodTypeV3): ZodTypeV3;\n  processZodType(value: ZodTypeV4): ZodTypeV4;\n  processZodType(value: ZodTypeV3 | ZodTypeV4): ZodTypeV3 | ZodTypeV4 {\n    if (isOptional(z)(value)) {\n      // For OpenAI strict mode, convert .optional() to .nullable() with transform\n      // This ensures all fields are in the required array but can accept null values\n      // The transform converts null -> undefined to match original .optional() semantics\n      const innerType = '_def' in value ? value._def.innerType : (value as any)._zod?.def?.innerType;\n\n      if (innerType) {\n        // If inner is nullable, just process and return it with transform (strips the optional wrapper)\n        // This converts .optional().nullable() -> .nullable() with transform\n        if (isNullable(z)(innerType)) {\n          const processed = this.processZodType(innerType);\n          return processed.transform((val: any) => (val === null ? undefined : val));\n        }\n\n        // Otherwise, process inner, make it nullable, and add transform\n        // This converts .optional() -> .nullable() with transform that converts null to undefined\n        const processedInner = this.processZodType(innerType);\n        return processedInner.nullable().transform((val: any) => (val === null ? undefined : val));\n      }\n\n      return value;\n    } else if (isNullable(z)(value)) {\n      // Process nullable: unwrap, process inner, and re-wrap with nullable\n      const innerType = '_def' in value ? value._def.innerType : (value as any)._zod?.def?.innerType;\n      if (innerType) {\n        // Special case: if inner is optional, strip it and add transform for OpenAI strict mode\n        // This converts .nullable().optional() -> .nullable() with transform\n        if (isOptional(z)(innerType)) {\n          const innerInnerType =\n            '_def' in innerType ? innerType._def.innerType : (innerType as any)._zod?.def?.innerType;\n          if (innerInnerType) {\n            const processedInnerInner = this.processZodType(innerInnerType);\n            return processedInnerInner.nullable().transform((val: any) => (val === null ? undefined : val));\n          }\n        }\n\n        const processedInner = this.processZodType(innerType);\n        return processedInner.nullable();\n      }\n      return value;\n    } else if (isObj(z)(value)) {\n      return this.defaultZodObjectHandler(value);\n    } else if (isUnion(z)(value)) {\n      return this.defaultZodUnionHandler(value);\n    } else if (isArr(z)(value)) {\n      return this.defaultZodArrayHandler(value);\n    } else if (isString(z)(value)) {\n      const model = this.getModel();\n      const checks = ['emoji'] as const;\n\n      if (model.modelId.includes('gpt-4o-mini')) {\n        return this.defaultZodStringHandler(value, ['emoji', 'regex']);\n      }\n\n      return this.defaultZodStringHandler(value, checks);\n    }\n\n    return this.defaultUnsupportedZodTypeHandler(value as ZodObjectV4<any> | ZodObjectV3<any>, [\n      'ZodNever',\n      'ZodUndefined',\n      'ZodTuple',\n    ]);\n  }\n}\n","import { z } from 'zod';\nimport type { ZodType as ZodTypeV3, ZodObject as ZodObjectV3 } from 'zod/v3';\nimport type { ZodType as ZodTypeV4, ZodObject as ZodObjectV4 } from 'zod/v4';\nimport type { Targets } from 'zod-to-json-schema';\nimport { SchemaCompatLayer } from '../schema-compatibility';\nimport type { ModelInformation } from '../types';\nimport { isOptional, isObj, isArr, isUnion, isDefault, isNumber, isString, isDate, isNullable } from '../zodTypes';\n\nexport class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {\n  constructor(model: ModelInformation) {\n    super(model);\n  }\n\n  getSchemaTarget(): Targets | undefined {\n    return `openApi3`;\n  }\n\n  isReasoningModel(): boolean {\n    // there isn't a good way to automatically detect reasoning models besides doing this.\n    // in the future when o5 is released this compat wont apply and we'll want to come back and update this class + our tests\n    return (\n      this.getModel().modelId.includes(`o3`) ||\n      this.getModel().modelId.includes(`o4`) ||\n      this.getModel().modelId.includes(`o1`)\n    );\n  }\n\n  shouldApply(): boolean {\n    if (\n      (this.getModel().supportsStructuredOutputs || this.isReasoningModel()) &&\n      (this.getModel().provider.includes(`openai`) || this.getModel().modelId.includes(`openai`))\n    ) {\n      return true;\n    }\n\n    return false;\n  }\n\n  processZodType(value: ZodTypeV3): ZodTypeV3;\n  processZodType(value: ZodTypeV4): ZodTypeV4;\n  processZodType(value: ZodTypeV3 | ZodTypeV4): ZodTypeV3 | ZodTypeV4 {\n    if (isOptional(z)(value)) {\n      // For OpenAI reasoning models strict mode, convert .optional() to .nullable() with transform\n      // The transform converts null -> undefined to match original .optional() semantics\n      const innerType = '_def' in value ? value._def.innerType : (value as any)._zod?.def?.innerType;\n\n      if (innerType) {\n        // If inner is nullable, just process and return it with transform (strips the optional wrapper)\n        if (isNullable(z)(innerType)) {\n          const processed = this.processZodType(innerType);\n          return processed.transform((val: any) => (val === null ? undefined : val));\n        }\n\n        // Otherwise, process inner, make it nullable, and add transform\n        const processedInner = this.processZodType(innerType);\n        return processedInner.nullable().transform((val: any) => (val === null ? undefined : val));\n      }\n\n      return value;\n    } else if (isNullable(z)(value)) {\n      // Handle nullable: if inner is optional, strip it and add transform\n      // This converts .optional().nullable() -> .nullable() with transform\n      const innerType = '_def' in value ? value._def.innerType : (value as any)._zod?.def?.innerType;\n      if (innerType && isOptional(z)(innerType)) {\n        const innerInnerType = '_def' in innerType ? innerType._def.innerType : (innerType as any)._zod?.def?.innerType;\n        if (innerInnerType) {\n          const processedInnerInner = this.processZodType(innerInnerType);\n          return processedInnerInner.nullable().transform((val: any) => (val === null ? undefined : val));\n        }\n      }\n      // Otherwise process inner and re-wrap with nullable (no transform - intentionally nullable)\n      if (innerType) {\n        const processedInner = this.processZodType(innerType);\n        return processedInner.nullable();\n      }\n      return value;\n    } else if (isObj(z)(value)) {\n      return this.defaultZodObjectHandler(value, { passthrough: false });\n    } else if (isArr(z)(value)) {\n      return this.defaultZodArrayHandler(value);\n    } else if (isUnion(z)(value)) {\n      return this.defaultZodUnionHandler(value);\n    } else if (isDefault(z)(value)) {\n      const defaultDef = value._def;\n      const innerType = defaultDef.innerType;\n      // Handle both Zod v3 (function) and v4 (direct value)\n      const defaultValue =\n        typeof defaultDef.defaultValue === 'function' ? defaultDef.defaultValue() : defaultDef.defaultValue;\n      const constraints: string[] = [];\n      if (defaultValue !== undefined) {\n        constraints.push(`the default value is ${defaultValue}`);\n      }\n\n      const description = this.mergeParameterDescription(value.description, constraints);\n      let result = this.processZodType(innerType);\n      if (description) {\n        result = result.describe(description);\n      }\n      return result;\n    } else if (isNumber(z)(value)) {\n      return this.defaultZodNumberHandler(value);\n    } else if (isString(z)(value)) {\n      return this.defaultZodStringHandler(value);\n    } else if (isDate(z)(value)) {\n      return this.defaultZodDateHandler(value);\n    } else if (value.constructor.name === 'ZodAny') {\n      // It's bad practice in the tool to use any, it's not reasonable for models that don't support that OOTB, to cast every single possible type\n      // in the schema. Usually when it's \"any\" it could be a json object or a union of specific types.\n      return z\n        .string()\n        .describe(\n          (value.description ?? '') +\n            `\\nArgument was an \"any\" type, but you (the LLM) do not support \"any\", so it was cast to a \"string\" type`,\n        );\n    }\n\n    return this.defaultUnsupportedZodTypeHandler(value as ZodObjectV4<any> | ZodObjectV3<any>);\n  }\n}\n"]}