openclawsetup 2.8.6 → 2.8.8
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/bin/cli.mjs +40 -21
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -1127,7 +1127,7 @@ function ensureConfigFilePresent(config, cliName) {
|
|
|
1127
1127
|
}
|
|
1128
1128
|
const result = safeExec(`${cliName} onboard --install-daemon`, { timeout: 240000 });
|
|
1129
1129
|
if (!result.ok && process.stdin.isTTY && process.stdout.isTTY) {
|
|
1130
|
-
spawnSync(cliName
|
|
1130
|
+
spawnSync(`${cliName} onboard`, { stdio: 'inherit', shell: true });
|
|
1131
1131
|
}
|
|
1132
1132
|
const recheck = getConfigInfo();
|
|
1133
1133
|
if (recheck.configPath && existsSync(recheck.configPath)) {
|
|
@@ -1153,8 +1153,8 @@ async function repairBrokenConfig(config, cliName, strongMode = false) {
|
|
|
1153
1153
|
} catch {
|
|
1154
1154
|
try {
|
|
1155
1155
|
const backupPath = backupBrokenConfig(config.configPath);
|
|
1156
|
-
const
|
|
1157
|
-
spawnSync(
|
|
1156
|
+
const onboardCmd = strongMode ? `${cliName} onboard --install-daemon` : `${cliName} onboard`;
|
|
1157
|
+
spawnSync(onboardCmd, { stdio: 'inherit', shell: true });
|
|
1158
1158
|
const recheck = getConfigInfo();
|
|
1159
1159
|
if (recheck.configPath && existsSync(recheck.configPath)) {
|
|
1160
1160
|
return {
|
|
@@ -1404,7 +1404,7 @@ async function validateModelConfig(autoFix = false, strongMode = false) {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
}
|
|
1406
1406
|
|
|
1407
|
-
spawnSync('npx
|
|
1407
|
+
spawnSync('npx openclawapi@latest', { stdio: 'inherit', shell: true });
|
|
1408
1408
|
const recheck = getConfigInfo();
|
|
1409
1409
|
const recheckHasModels = recheck.raw.includes('"models"') || recheck.raw.includes('"providers"');
|
|
1410
1410
|
const recheckHasApiKey = recheck.raw.includes('"apiKey"') || recheck.raw.includes('"api_key"');
|
|
@@ -1614,7 +1614,7 @@ async function installOpenClaw() {
|
|
|
1614
1614
|
// 有权限:直接安装
|
|
1615
1615
|
console.log(colors.gray('正在安装 openclaw...\n'));
|
|
1616
1616
|
|
|
1617
|
-
const result = spawnSync('npm
|
|
1617
|
+
const result = spawnSync('npm install -g openclaw@latest', {
|
|
1618
1618
|
stdio: 'inherit',
|
|
1619
1619
|
shell: true,
|
|
1620
1620
|
});
|
|
@@ -1627,7 +1627,7 @@ async function installOpenClaw() {
|
|
|
1627
1627
|
// 安装失败,可能是权限问题,尝试 sudo(非 Windows)
|
|
1628
1628
|
if (platform() !== 'win32') {
|
|
1629
1629
|
log.warn('安装失败,可能是权限不足,尝试使用 sudo...');
|
|
1630
|
-
const sudoResult = spawnSync('sudo
|
|
1630
|
+
const sudoResult = spawnSync('sudo npm install -g openclaw@latest', {
|
|
1631
1631
|
stdio: 'inherit',
|
|
1632
1632
|
shell: true,
|
|
1633
1633
|
});
|
|
@@ -1640,7 +1640,7 @@ async function installOpenClaw() {
|
|
|
1640
1640
|
|
|
1641
1641
|
// 尝试 clawdbot
|
|
1642
1642
|
log.warn('openclaw 安装失败,尝试 clawdbot...');
|
|
1643
|
-
const fallback = spawnSync('npm
|
|
1643
|
+
const fallback = spawnSync('npm install -g clawdbot@latest', {
|
|
1644
1644
|
stdio: 'inherit',
|
|
1645
1645
|
shell: true,
|
|
1646
1646
|
});
|
|
@@ -1939,7 +1939,7 @@ async function updateOpenClaw(cliName) {
|
|
|
1939
1939
|
console.log(colors.green(` ${cliName} gateway restart\n`));
|
|
1940
1940
|
} else {
|
|
1941
1941
|
console.log(colors.gray('\n正在更新...\n'));
|
|
1942
|
-
spawnSync(
|
|
1942
|
+
spawnSync(`npm install -g ${cliName}@latest`, {
|
|
1943
1943
|
stdio: 'inherit',
|
|
1944
1944
|
shell: true,
|
|
1945
1945
|
});
|
|
@@ -2087,7 +2087,7 @@ async function uninstallOpenClaw(existing) {
|
|
|
2087
2087
|
console.log(colors.green(' rm -rf ~/.openclaw ~/.clawdbot\n'));
|
|
2088
2088
|
await waitForEnter('卸载完成后按回车继续...');
|
|
2089
2089
|
} else {
|
|
2090
|
-
spawnSync(
|
|
2090
|
+
spawnSync(`npm uninstall -g ${cliName}`, { stdio: 'inherit', shell: true });
|
|
2091
2091
|
}
|
|
2092
2092
|
|
|
2093
2093
|
const config = getConfigInfo();
|
|
@@ -2319,9 +2319,21 @@ async function runHealthCheck(cliName, autoFix = false, strongMode = false) {
|
|
|
2319
2319
|
console.log(colors.yellow(' 尝试重启并恢复端口监听...'));
|
|
2320
2320
|
const recovered = await ensureGatewayRunning(activeCli, 'restart');
|
|
2321
2321
|
if (recovered.ok) {
|
|
2322
|
-
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2322
|
+
// Windows 上 Gateway 启动较慢,轮询等待端口就绪
|
|
2323
|
+
const maxWait = platform() === 'win32' ? 15000 : 8000;
|
|
2324
|
+
const interval = 1500;
|
|
2325
|
+
let waited = 0;
|
|
2326
|
+
let portReady = false;
|
|
2327
|
+
while (waited < maxWait) {
|
|
2328
|
+
await sleep(interval);
|
|
2329
|
+
waited += interval;
|
|
2330
|
+
const recheck = getPortCheckOutput(port);
|
|
2331
|
+
if (recheck.ok && recheck.output && hasListeningState(recheck.output)) {
|
|
2332
|
+
portReady = true;
|
|
2333
|
+
break;
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
if (portReady) {
|
|
2325
2337
|
log.success(`端口 ${port} 已恢复监听`);
|
|
2326
2338
|
fixed.push(`端口监听已恢复(${port})`);
|
|
2327
2339
|
portHealthy = true;
|
|
@@ -2537,7 +2549,16 @@ function testModelChat(cliName, timeoutMs = MODEL_CHAT_TIMEOUT_MS) {
|
|
|
2537
2549
|
const message = parsed?.result?.payloads?.[0]?.text || '';
|
|
2538
2550
|
const provider = parsed?.result?.meta?.agentMeta?.provider || '';
|
|
2539
2551
|
const modelId = parsed?.result?.meta?.agentMeta?.model || '';
|
|
2540
|
-
|
|
2552
|
+
|
|
2553
|
+
// 检查回复内容是否实际上是错误信息
|
|
2554
|
+
const msgLower = message.toLowerCase();
|
|
2555
|
+
if (msgLower.includes('401') && (msgLower.includes('invalid api key') || msgLower.includes('unauthorized'))) {
|
|
2556
|
+
resolve({ success: false, error: 'API Key 无效 (401)' });
|
|
2557
|
+
} else if (msgLower.includes('403') && (msgLower.includes('forbidden') || msgLower.includes('access denied'))) {
|
|
2558
|
+
resolve({ success: false, error: 'API 访问被拒绝 (403)' });
|
|
2559
|
+
} else if (/^http\s+\d{3}:/i.test(message.trim())) {
|
|
2560
|
+
resolve({ success: false, error: message.substring(0, 200) });
|
|
2561
|
+
} else if (message || (provider && modelId)) {
|
|
2541
2562
|
resolve({ success: true, message, provider, model: modelId });
|
|
2542
2563
|
} else {
|
|
2543
2564
|
resolve({ success: false, error: '模型未返回内容' });
|
|
@@ -2763,7 +2784,7 @@ async function showInteractiveMenu(existing) {
|
|
|
2763
2784
|
break;
|
|
2764
2785
|
case '7':
|
|
2765
2786
|
console.log(colors.cyan('\n启动模型配置...'));
|
|
2766
|
-
spawnSync('npx
|
|
2787
|
+
spawnSync('npx openclawapi@latest', {
|
|
2767
2788
|
stdio: 'inherit',
|
|
2768
2789
|
shell: true,
|
|
2769
2790
|
});
|
|
@@ -2778,13 +2799,13 @@ async function showInteractiveMenu(existing) {
|
|
|
2778
2799
|
const chatChoice = await askQuestion('\n请选择 (a/b/c/0): ');
|
|
2779
2800
|
switch (chatChoice.trim().toLowerCase()) {
|
|
2780
2801
|
case 'a':
|
|
2781
|
-
spawnSync('npx
|
|
2802
|
+
spawnSync('npx openclawdc@latest', { stdio: 'inherit', shell: true });
|
|
2782
2803
|
break;
|
|
2783
2804
|
case 'b':
|
|
2784
|
-
spawnSync('npx
|
|
2805
|
+
spawnSync('npx openclaw-chat-cn@latest feishu', { stdio: 'inherit', shell: true });
|
|
2785
2806
|
break;
|
|
2786
2807
|
case 'c':
|
|
2787
|
-
spawnSync(cliName
|
|
2808
|
+
spawnSync(`${cliName} onboard`, { stdio: 'inherit', shell: true });
|
|
2788
2809
|
break;
|
|
2789
2810
|
}
|
|
2790
2811
|
await waitForEnter('\n按回车返回菜单...');
|
|
@@ -2849,10 +2870,8 @@ async function main() {
|
|
|
2849
2870
|
if (latestVersion && compareSemver(currentVersion, latestVersion) < 0) {
|
|
2850
2871
|
console.log(colors.yellow(`\n⚠ 当前版本 ${currentVersion},最新版本 ${latestVersion}`));
|
|
2851
2872
|
console.log(colors.yellow(' 正在更新到最新版本...\n'));
|
|
2852
|
-
const updateCmd =
|
|
2853
|
-
|
|
2854
|
-
: `npx --yes openclawsetup@${latestVersion}`;
|
|
2855
|
-
spawnSync(updateCmd.split(' ')[0], updateCmd.split(' ').slice(1), {
|
|
2873
|
+
const updateCmd = `npx --yes openclawsetup@${latestVersion}`;
|
|
2874
|
+
spawnSync(updateCmd, {
|
|
2856
2875
|
stdio: 'inherit',
|
|
2857
2876
|
shell: true,
|
|
2858
2877
|
});
|