( schema: StandardSchemaV1, )
| 42 | * most LLM tool-call APIs reject composite `$ref` schemas. |
| 43 | */ |
| 44 | export function toJsonSchema( |
| 45 | schema: StandardSchemaV1, |
| 46 | ): Record<string, unknown> { |
| 47 | return sharedSchemaToJsonSchema(schema, { |
| 48 | // Adapt `zod-to-json-schema`'s `(schema: ZodType, ...)` signature to |
| 49 | // shared's `(schema: unknown, ...)` injection point. Only invoked for |
| 50 | // Zod v3 inputs that don't emit Standard JSON Schema themselves. |
| 51 | zodToJsonSchema: (s, options) => |
| 52 | zodToJsonSchema( |
| 53 | s as Parameters<typeof zodToJsonSchema>[0], |
| 54 | options as never, |
| 55 | ) as Record<string, unknown>, |
| 56 | }); |
| 57 | } |
| 58 | |
| 59 | /** Discriminated result of validating a value against a Standard Schema. */ |
| 60 | export type SchemaParseResult<T> = |
no outgoing calls
no test coverage detected
searching dependent graphs…