| 501 | const allResults = []; |
| 502 | |
| 503 | async function test(name, fn) { |
| 504 | const t0 = Date.now(); |
| 505 | process.stdout.write(`\n ${C.blue}▶${C.reset} ${C.bold}${name}${C.reset}\n`); |
| 506 | try { |
| 507 | const result = await fn(); |
| 508 | const ms = ((Date.now() - t0) / 1000).toFixed(1); |
| 509 | console.log(` ${ok('通过')} (${ms}s, ${result?.turns || '?'} 轮工具调用)`); |
| 510 | if (result?.toolCallLog) { |
| 511 | const summary = result.toolCallLog |
| 512 | .filter(t => t.tool !== '__DONE__') |
| 513 | .map(t => `${t.turn}:${t.tool}`) |
| 514 | .join(' → '); |
| 515 | console.log(info(` 路径: ${summary}`)); |
| 516 | } |
| 517 | if (result?.finalResult) { |
| 518 | console.log(info(` 结果: "${String(result.finalResult).substring(0, 120)}..."`)); |
| 519 | } |
| 520 | passed++; |
| 521 | allResults.push({ name, ok: true }); |
| 522 | } catch (e) { |
| 523 | const ms = ((Date.now() - t0) / 1000).toFixed(1); |
| 524 | console.log(` ${fail('失败')} (${ms}s)`); |
| 525 | console.log(` ${C.red}${e.message}${C.reset}`); |
| 526 | failed++; |
| 527 | allResults.push({ name, ok: false, error: e.message }); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | // ════════════════════════════════════════════════════════════════════ |
| 532 | // 检测服务器 |