(toolName: string, experiments?: Record<string, boolean>)
| 12 | * only that the tool actually exists. |
| 13 | */ |
| 14 | export function isValidToolName(toolName: string, experiments?: Record<string, boolean>): toolName is ToolName { |
| 15 | // Check if it's a valid static tool |
| 16 | if ((validToolNames as readonly string[]).includes(toolName)) { |
| 17 | return true |
| 18 | } |
| 19 | |
| 20 | if (experiments?.customTools && customToolRegistry.has(toolName)) { |
| 21 | return true |
| 22 | } |
| 23 | |
| 24 | // Check if it's a dynamic MCP tool (mcp_serverName_toolName format). |
| 25 | if (toolName.startsWith("mcp_")) { |
| 26 | return true |
| 27 | } |
| 28 | |
| 29 | return false |
| 30 | } |
| 31 | |
| 32 | export function validateToolUse( |
| 33 | toolName: ToolName, |
no test coverage detected