* 实用工具示例
()
| 90 | * 实用工具示例 |
| 91 | */ |
| 92 | async function utilityToolsExample() { |
| 93 | console.log('=== 实用工具示例 ===\n'); |
| 94 | |
| 95 | const toolManager = await createToolManager(); |
| 96 | |
| 97 | // 时间戳工具 |
| 98 | console.log('1. 获取当前时间戳:'); |
| 99 | const timestampResult = await toolManager.callTool({ |
| 100 | toolName: 'timestamp', |
| 101 | parameters: { |
| 102 | operation: 'now', |
| 103 | format: 'iso', |
| 104 | }, |
| 105 | }); |
| 106 | console.log('结果:', JSON.stringify(timestampResult.result.data, null, 2)); |
| 107 | console.log(''); |
| 108 | |
| 109 | // UUID 生成 |
| 110 | console.log('2. 生成 UUID:'); |
| 111 | const uuidResult = await toolManager.callTool({ |
| 112 | toolName: 'uuid', |
| 113 | parameters: { |
| 114 | count: 3, |
| 115 | }, |
| 116 | }); |
| 117 | console.log('结果:', JSON.stringify(uuidResult.result.data, null, 2)); |
| 118 | console.log(''); |
| 119 | |
| 120 | // 随机数生成 |
| 121 | console.log('3. 生成随机数:'); |
| 122 | const randomResult = await toolManager.callTool({ |
| 123 | toolName: 'random', |
| 124 | parameters: { |
| 125 | type: 'number', |
| 126 | min: 1, |
| 127 | max: 100, |
| 128 | count: 5, |
| 129 | }, |
| 130 | }); |
| 131 | console.log('结果:', JSON.stringify(randomResult.result.data, null, 2)); |
| 132 | console.log(''); |
| 133 | |
| 134 | // Base64 编码 |
| 135 | console.log('4. Base64 编码:'); |
| 136 | const base64Result = await toolManager.callTool({ |
| 137 | toolName: 'base64', |
| 138 | parameters: { |
| 139 | operation: 'encode', |
| 140 | input: 'Hello, 世界!', |
| 141 | }, |
| 142 | }); |
| 143 | console.log('结果:', JSON.stringify(base64Result.result.data, null, 2)); |
| 144 | console.log(''); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * 网络工具示例 |
no test coverage detected