openclawapi 1.3.7 → 1.3.9
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 +48 -2
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -433,7 +433,20 @@ async function testConnection(paths) {
|
|
|
433
433
|
console.log(chalk.green(`\n✅ ${typeLabel} API 连接成功!`));
|
|
434
434
|
console.log(chalk.cyan(` 响应时间: ${latency}ms`));
|
|
435
435
|
console.log(chalk.yellow(` 模型回复: ${result.message}`));
|
|
436
|
-
|
|
436
|
+
|
|
437
|
+
// 询问是否重启 gateway
|
|
438
|
+
const { restart } = await inquirer.prompt([{
|
|
439
|
+
type: 'confirm',
|
|
440
|
+
name: 'restart',
|
|
441
|
+
message: '是否重启 OpenClaw Gateway 使配置生效?',
|
|
442
|
+
default: true
|
|
443
|
+
}]);
|
|
444
|
+
|
|
445
|
+
if (restart) {
|
|
446
|
+
await restartGateway();
|
|
447
|
+
} else {
|
|
448
|
+
console.log(chalk.gray(`\n💡 稍后可手动运行: openclaw gateway restart`));
|
|
449
|
+
}
|
|
437
450
|
} else {
|
|
438
451
|
console.log(chalk.red(`\n❌ ${typeLabel} API 连接失败`));
|
|
439
452
|
console.log(chalk.red(` 错误: ${result.error}`));
|
|
@@ -446,7 +459,20 @@ async function testConnection(paths) {
|
|
|
446
459
|
console.log(chalk.green(`\n✅ ${typeLabel} API 连接成功!`));
|
|
447
460
|
console.log(chalk.cyan(` 响应时间: ${latency}ms`));
|
|
448
461
|
console.log(chalk.yellow(` 模型回复: ${result.message}`));
|
|
449
|
-
|
|
462
|
+
|
|
463
|
+
// 询问是否重启 gateway
|
|
464
|
+
const { restart } = await inquirer.prompt([{
|
|
465
|
+
type: 'confirm',
|
|
466
|
+
name: 'restart',
|
|
467
|
+
message: '是否重启 OpenClaw Gateway 使配置生效?',
|
|
468
|
+
default: true
|
|
469
|
+
}]);
|
|
470
|
+
|
|
471
|
+
if (restart) {
|
|
472
|
+
await restartGateway();
|
|
473
|
+
} else {
|
|
474
|
+
console.log(chalk.gray(`\n💡 稍后可手动运行: openclaw gateway restart`));
|
|
475
|
+
}
|
|
450
476
|
} else {
|
|
451
477
|
console.log(chalk.red(`\n❌ ${typeLabel} API 连接失败`));
|
|
452
478
|
console.log(chalk.red(` 错误: ${result.error}`));
|
|
@@ -457,6 +483,26 @@ async function testConnection(paths) {
|
|
|
457
483
|
}
|
|
458
484
|
}
|
|
459
485
|
|
|
486
|
+
// ============ 重启 Gateway ============
|
|
487
|
+
async function restartGateway() {
|
|
488
|
+
console.log(chalk.cyan('\n🔄 正在重启 OpenClaw Gateway...'));
|
|
489
|
+
|
|
490
|
+
const { exec } = require('child_process');
|
|
491
|
+
|
|
492
|
+
return new Promise((resolve) => {
|
|
493
|
+
exec('openclaw gateway restart', { timeout: 30000 }, (error, stdout, stderr) => {
|
|
494
|
+
if (error) {
|
|
495
|
+
console.log(chalk.red(`❌ 重启失败: ${error.message}`));
|
|
496
|
+
console.log(chalk.gray(` 请手动运行: openclaw gateway restart`));
|
|
497
|
+
} else {
|
|
498
|
+
console.log(chalk.green(`✅ Gateway 已重启`));
|
|
499
|
+
console.log(chalk.gray(` 现在可以在 Web/Telegram/Discord 等渠道测试对话了`));
|
|
500
|
+
}
|
|
501
|
+
resolve();
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
460
506
|
// Claude API 测试
|
|
461
507
|
function testClaudeApi(baseUrl, apiKey, model) {
|
|
462
508
|
return new Promise((resolve) => {
|