(schema: Record<string, unknown>)
| 292 | * @returns A normalized schema object that is JSON Schema draft 2020-12 compliant |
| 293 | */ |
| 294 | export function normalizeToolSchema(schema: Record<string, unknown>): Record<string, unknown> { |
| 295 | if (typeof schema !== "object" || schema === null) { |
| 296 | return schema |
| 297 | } |
| 298 | |
| 299 | // First, flatten any top-level composition keywords before normalizing |
| 300 | const flattenedSchema = flattenTopLevelComposition(schema) |
| 301 | |
| 302 | const result = NormalizedToolSchemaInternal.safeParse(flattenedSchema) |
| 303 | return result.success ? result.data : flattenedSchema |
| 304 | } |
no test coverage detected