( schema: z.ZodType | Record<string, unknown>, )
| 22 | * (from SDK custom tools that were serialized), converts it to Zod. |
| 23 | */ |
| 24 | export function ensureZodSchema( |
| 25 | schema: z.ZodType | Record<string, unknown>, |
| 26 | ): z.ZodType { |
| 27 | // Check if it's already a Zod schema by looking for the safeParse method |
| 28 | if ( |
| 29 | schema && |
| 30 | typeof (schema as { safeParse?: unknown }).safeParse === 'function' |
| 31 | ) { |
| 32 | return schema as z.ZodType |
| 33 | } |
| 34 | // JSON Schema object - convert to Zod |
| 35 | return convertJsonSchemaToZod(schema as Record<string, unknown>) |
| 36 | } |
| 37 | |
| 38 | function ensureJsonSchemaCompatible(schema: z.ZodType): z.ZodType { |
| 39 | try { |
no outgoing calls
no test coverage detected