openclawapi 1.3.9 → 1.3.10
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 +35 -11
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -489,17 +489,41 @@ async function restartGateway() {
|
|
|
489
489
|
|
|
490
490
|
const { exec } = require('child_process');
|
|
491
491
|
|
|
492
|
+
// 尝试多种命令
|
|
493
|
+
const commands = [
|
|
494
|
+
'openclaw gateway restart',
|
|
495
|
+
'clawdbot gateway restart',
|
|
496
|
+
'npx openclaw gateway restart',
|
|
497
|
+
'npx clawdbot gateway restart'
|
|
498
|
+
];
|
|
499
|
+
|
|
492
500
|
return new Promise((resolve) => {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
501
|
+
let tried = 0;
|
|
502
|
+
|
|
503
|
+
const tryNext = () => {
|
|
504
|
+
if (tried >= commands.length) {
|
|
505
|
+
console.log(chalk.red(`❌ 重启失败: 找不到 openclaw/clawdbot 命令`));
|
|
496
506
|
console.log(chalk.gray(` 请手动运行: openclaw gateway restart`));
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
507
|
+
console.log(chalk.gray(` 或: clawdbot gateway restart`));
|
|
508
|
+
resolve();
|
|
509
|
+
return;
|
|
500
510
|
}
|
|
501
|
-
|
|
502
|
-
|
|
511
|
+
|
|
512
|
+
const cmd = commands[tried];
|
|
513
|
+
tried++;
|
|
514
|
+
|
|
515
|
+
exec(cmd, { timeout: 30000 }, (error) => {
|
|
516
|
+
if (error) {
|
|
517
|
+
tryNext();
|
|
518
|
+
} else {
|
|
519
|
+
console.log(chalk.green(`✅ Gateway 已重启`));
|
|
520
|
+
console.log(chalk.gray(` 现在可以在 Web/Telegram/Discord 等渠道测试对话了`));
|
|
521
|
+
resolve();
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
tryNext();
|
|
503
527
|
});
|
|
504
528
|
}
|
|
505
529
|
|
|
@@ -511,8 +535,8 @@ function testClaudeApi(baseUrl, apiKey, model) {
|
|
|
511
535
|
|
|
512
536
|
const postData = JSON.stringify({
|
|
513
537
|
model: model || 'claude-sonnet-4-5',
|
|
514
|
-
max_tokens:
|
|
515
|
-
messages: [{ role: 'user', content: '
|
|
538
|
+
max_tokens: 150,
|
|
539
|
+
messages: [{ role: 'user', content: '你是哪个模型?请用一句话回答你的模型名称和版本。' }]
|
|
516
540
|
});
|
|
517
541
|
|
|
518
542
|
const options = {
|
|
@@ -571,7 +595,7 @@ function testCodexApi(baseUrl, apiKey, model) {
|
|
|
571
595
|
|
|
572
596
|
const postData = JSON.stringify({
|
|
573
597
|
model: model || 'gpt-5.2',
|
|
574
|
-
input: '
|
|
598
|
+
input: '你是哪个模型?请用一句话回答你的模型名称和版本。'
|
|
575
599
|
});
|
|
576
600
|
|
|
577
601
|
const options = {
|