* 验证工具定义
(tool: ToolDefinition)
| 315 | * 验证工具定义 |
| 316 | */ |
| 317 | private validateToolDefinition(tool: ToolDefinition): void { |
| 318 | if (!tool.name || typeof tool.name !== 'string') { |
| 319 | throw new ToolRegistrationError('工具名称必须是非空字符串'); |
| 320 | } |
| 321 | |
| 322 | if (!tool.description || typeof tool.description !== 'string') { |
| 323 | throw new ToolRegistrationError('工具描述必须是非空字符串'); |
| 324 | } |
| 325 | |
| 326 | if (!tool.parameters || typeof tool.parameters !== 'object') { |
| 327 | throw new ToolRegistrationError('工具参数定义必须是对象'); |
| 328 | } |
| 329 | |
| 330 | if (typeof tool.execute !== 'function') { |
| 331 | throw new ToolRegistrationError('工具执行函数必须是函数'); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * 执行工具并设置超时 |