(schema: unknown)
| 2330 | * `$schema` marker so the result is safe to embed in LLM tool definitions. |
| 2331 | */ |
| 2332 | export const toolSchemaToJsonSchema = (schema: unknown): ToolJsonSchema => { |
| 2333 | if (schema == null) return { type: 'object', properties: {} } |
| 2334 | const jsonSchema: ToolJsonSchema = isZodSchema(schema) |
| 2335 | ? (zodToJsonSchema(schema) as ToolJsonSchema) |
| 2336 | : cloneDeep(schema as ToolJsonSchema) |
| 2337 | if (jsonSchema.$schema) { |
| 2338 | delete jsonSchema.$schema |
| 2339 | } |
| 2340 | return jsonSchema |
| 2341 | } |
no test coverage detected