| 13 | import type { AgentDefinition } from './loadAgentsDir.js' |
| 14 | |
| 15 | function getToolsDescription(agent: AgentDefinition): string { |
| 16 | const { tools, disallowedTools } = agent |
| 17 | const hasAllowlist = tools && tools.length > 0 |
| 18 | const hasDenylist = disallowedTools && disallowedTools.length > 0 |
| 19 | |
| 20 | if (hasAllowlist && hasDenylist) { |
| 21 | // Both defined: filter allowlist by denylist to match runtime behavior |
| 22 | const denySet = new Set(disallowedTools) |
| 23 | const effectiveTools = tools.filter(t => !denySet.has(t)) |
| 24 | if (effectiveTools.length === 0) { |
| 25 | return 'None' |
| 26 | } |
| 27 | return effectiveTools.join(', ') |
| 28 | } else if (hasAllowlist) { |
| 29 | // Allowlist only: show the specific tools available |
| 30 | return tools.join(', ') |
| 31 | } else if (hasDenylist) { |
| 32 | // Denylist only: show "All tools except X, Y, Z" |
| 33 | return `All tools except ${disallowedTools.join(', ')}` |
| 34 | } |
| 35 | // No restrictions |
| 36 | return 'All tools' |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Format one agent line for the agent_listing_delta attachment message: |