(schema: z.ZodType)
| 338 | } |
| 339 | |
| 340 | function zodJsonSchema(schema: z.ZodType): JSONSchema7 { |
| 341 | const result = normalizeZodJsonSchema(z.toJSONSchema(schema, { io: "input", metadata: zodMetadataRegistry(schema) })) |
| 342 | if (!isJsonSchemaObject(result)) throw new Error("plugin tool Zod schema produced a non-object JSON Schema") |
| 343 | const { $defs, ...rest } = result |
| 344 | return ( |
| 345 | $defs && isJsonSchemaObject($defs) ? { ...rest, definitions: $defs as JSONSchema7["definitions"] } : rest |
| 346 | ) as JSONSchema7 |
| 347 | } |
| 348 | |
| 349 | function zodMetadataRegistry(schema: z.ZodType) { |
| 350 | const registry = z.registry<Record<string, unknown>>() |
no test coverage detected