(params: { schema: z.ZodType; endsAgentStep: boolean })
| 75 | } |
| 76 | |
| 77 | function paramsSection(params: { schema: z.ZodType; endsAgentStep: boolean }) { |
| 78 | const { schema, endsAgentStep } = params |
| 79 | const safeSchema = ensureJsonSchemaCompatible(schema) |
| 80 | const schemaWithEndsAgentStepParam = endsAgentStep |
| 81 | ? safeSchema.and( |
| 82 | z.object({ |
| 83 | [endsAgentStepParam]: z |
| 84 | .literal(endsAgentStep) |
| 85 | .describe('Easp flag must be set to true'), |
| 86 | }), |
| 87 | ) |
| 88 | : safeSchema |
| 89 | const jsonSchema = toJsonSchemaSafe(schemaWithEndsAgentStepParam) |
| 90 | delete jsonSchema.description |
| 91 | delete jsonSchema['$schema'] |
| 92 | const paramsDescription = hasMeaningfulJsonSchema(jsonSchema) |
| 93 | ? JSON.stringify(jsonSchema, null, 2) |
| 94 | : 'None' |
| 95 | |
| 96 | let paramsSection = '' |
| 97 | if (paramsDescription.length === 1 && paramsDescription[0] === 'None') { |
| 98 | paramsSection = 'Params: None' |
| 99 | } else if (paramsDescription.length > 0) { |
| 100 | paramsSection = `Params: ${paramsDescription}` |
| 101 | } |
| 102 | return paramsSection |
| 103 | } |
| 104 | |
| 105 | // Helper function to build the full tool description markdown |
| 106 | export function buildToolDescription(params: { |
no test coverage detected