openclawapi 1.3.11 → 1.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +16 -7
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -417,29 +417,38 @@ async function testConnection(paths) {
|
|
|
417
417
|
|
|
418
418
|
// 获取 Gateway 配置
|
|
419
419
|
const gatewayPort = config.gateway?.port || 18789;
|
|
420
|
-
const gatewayToken = config.gateway?.auth?.token || '';
|
|
421
420
|
|
|
422
421
|
console.log(chalk.gray(`当前激活: ${typeLabel}`));
|
|
423
422
|
console.log(chalk.gray(`中转节点: ${provider.baseUrl}`));
|
|
424
423
|
console.log(chalk.gray(`模型: ${primary}`));
|
|
425
424
|
console.log(chalk.gray(`Gateway: http://localhost:${gatewayPort}\n`));
|
|
426
425
|
|
|
427
|
-
//
|
|
428
|
-
console.log(chalk.cyan(
|
|
426
|
+
// 步骤1: 先重启 Gateway 使配置生效
|
|
427
|
+
console.log(chalk.cyan('步骤 1/2: 重启 Gateway 使配置生效...'));
|
|
428
|
+
await restartGateway();
|
|
429
|
+
|
|
430
|
+
// 步骤2: 直接测试中转 API 验证配置
|
|
431
|
+
console.log(chalk.cyan(`\n步骤 2/2: 测试 ${typeLabel} 中转 API...`));
|
|
429
432
|
|
|
430
433
|
try {
|
|
431
434
|
const startTime = Date.now();
|
|
432
|
-
|
|
435
|
+
let result;
|
|
436
|
+
|
|
437
|
+
if (type === 'claude') {
|
|
438
|
+
result = await testClaudeApi(provider.baseUrl, provider.apiKey, provider.models?.[0]?.id);
|
|
439
|
+
} else {
|
|
440
|
+
result = await testCodexApi(provider.baseUrl, provider.apiKey, provider.models?.[0]?.id);
|
|
441
|
+
}
|
|
442
|
+
|
|
433
443
|
const latency = Date.now() - startTime;
|
|
434
444
|
|
|
435
445
|
if (result.success) {
|
|
436
|
-
console.log(chalk.green(`\n✅
|
|
446
|
+
console.log(chalk.green(`\n✅ 测试成功!配置已生效`));
|
|
437
447
|
console.log(chalk.cyan(` 响应时间: ${latency}ms`));
|
|
438
448
|
console.log(chalk.yellow(` 模型回复: ${result.message}`));
|
|
439
449
|
} else {
|
|
440
|
-
console.log(chalk.red(`\n❌
|
|
450
|
+
console.log(chalk.red(`\n❌ ${typeLabel} API 连接失败`));
|
|
441
451
|
console.log(chalk.red(` 错误: ${result.error}`));
|
|
442
|
-
console.log(chalk.gray(`\n💡 请确保 Gateway 正在运行: openclaw gateway`));
|
|
443
452
|
}
|
|
444
453
|
} catch (error) {
|
|
445
454
|
console.log(chalk.red(`❌ 测试失败: ${error.message}`));
|