* 基础使用示例
()
| 11 | * 基础使用示例 |
| 12 | */ |
| 13 | async function basicExample() { |
| 14 | console.log('=== 基础使用示例 ===\n'); |
| 15 | |
| 16 | // 创建工具管理器 |
| 17 | const toolManager = await createToolManager({ |
| 18 | debug: true, |
| 19 | maxConcurrency: 5, |
| 20 | }); |
| 21 | |
| 22 | // 获取所有工具 |
| 23 | const tools = toolManager.getTools(); |
| 24 | console.log(`已加载 ${tools.length} 个工具\n`); |
| 25 | |
| 26 | // 按分类显示工具 |
| 27 | const categories = tools.reduce( |
| 28 | (acc, tool) => { |
| 29 | const category = tool.category || 'other'; |
| 30 | if (!acc[category]) acc[category] = []; |
| 31 | acc[category].push(tool.name); |
| 32 | return acc; |
| 33 | }, |
| 34 | {} as Record<string, string[]> |
| 35 | ); |
| 36 | |
| 37 | for (const [category, toolNames] of Object.entries(categories)) { |
| 38 | console.log(`${category}: ${toolNames.join(', ')}`); |
| 39 | } |
| 40 | console.log(''); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * 文本处理工具示例 |
no test coverage detected