| 54 | } |
| 55 | |
| 56 | function hasMeaningfulJsonSchema(jsonSchema: Record<string, unknown>): boolean { |
| 57 | const properties = jsonSchema.properties |
| 58 | if (properties && typeof properties === 'object' && Object.keys(properties).length > 0) { |
| 59 | return true |
| 60 | } |
| 61 | |
| 62 | for (const key of ['allOf', 'anyOf', 'oneOf']) { |
| 63 | const value = jsonSchema[key] |
| 64 | if (Array.isArray(value) && value.length > 0) { |
| 65 | return true |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | const required = jsonSchema.required |
| 70 | if (Array.isArray(required) && required.length > 0) { |
| 71 | return true |
| 72 | } |
| 73 | |
| 74 | return false |
| 75 | } |
| 76 | |
| 77 | function paramsSection(params: { schema: z.ZodType; endsAgentStep: boolean }) { |
| 78 | const { schema, endsAgentStep } = params |