openclawsetup 2.8.6 → 2.8.7

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.
Files changed (2) hide show
  1. package/bin/cli.mjs +30 -20
  2. 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, ['onboard'], { stdio: 'inherit', shell: true });
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 onboardArgs = strongMode ? ['onboard', '--install-daemon'] : ['onboard'];
1157
- spawnSync(cliName, onboardArgs, { stdio: 'inherit', shell: true });
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', ['openclawapi@latest'], { stdio: 'inherit', shell: true });
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', ['install', '-g', 'openclaw@latest'], {
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', ['npm', 'install', '-g', 'openclaw@latest'], {
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', ['install', '-g', 'clawdbot@latest'], {
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('npm', ['install', '-g', `${cliName}@latest`], {
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('npm', ['uninstall', '-g', cliName], { stdio: 'inherit', shell: true });
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
- await sleep(2500);
2323
- const recheck = getPortCheckOutput(port);
2324
- if (recheck.ok && recheck.output && hasListeningState(recheck.output)) {
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;
@@ -2763,7 +2775,7 @@ async function showInteractiveMenu(existing) {
2763
2775
  break;
2764
2776
  case '7':
2765
2777
  console.log(colors.cyan('\n启动模型配置...'));
2766
- spawnSync('npx', ['openclawapi@latest'], {
2778
+ spawnSync('npx openclawapi@latest', {
2767
2779
  stdio: 'inherit',
2768
2780
  shell: true,
2769
2781
  });
@@ -2778,13 +2790,13 @@ async function showInteractiveMenu(existing) {
2778
2790
  const chatChoice = await askQuestion('\n请选择 (a/b/c/0): ');
2779
2791
  switch (chatChoice.trim().toLowerCase()) {
2780
2792
  case 'a':
2781
- spawnSync('npx', ['openclawdc@latest'], { stdio: 'inherit', shell: true });
2793
+ spawnSync('npx openclawdc@latest', { stdio: 'inherit', shell: true });
2782
2794
  break;
2783
2795
  case 'b':
2784
- spawnSync('npx', ['openclaw-chat-cn@latest', 'feishu'], { stdio: 'inherit', shell: true });
2796
+ spawnSync('npx openclaw-chat-cn@latest feishu', { stdio: 'inherit', shell: true });
2785
2797
  break;
2786
2798
  case 'c':
2787
- spawnSync(cliName, ['onboard'], { stdio: 'inherit', shell: true });
2799
+ spawnSync(`${cliName} onboard`, { stdio: 'inherit', shell: true });
2788
2800
  break;
2789
2801
  }
2790
2802
  await waitForEnter('\n按回车返回菜单...');
@@ -2849,10 +2861,8 @@ async function main() {
2849
2861
  if (latestVersion && compareSemver(currentVersion, latestVersion) < 0) {
2850
2862
  console.log(colors.yellow(`\n⚠ 当前版本 ${currentVersion},最新版本 ${latestVersion}`));
2851
2863
  console.log(colors.yellow(' 正在更新到最新版本...\n'));
2852
- const updateCmd = platform() === 'win32'
2853
- ? `npx --yes openclawsetup@${latestVersion}`
2854
- : `npx --yes openclawsetup@${latestVersion}`;
2855
- spawnSync(updateCmd.split(' ')[0], updateCmd.split(' ').slice(1), {
2864
+ const updateCmd = `npx --yes openclawsetup@${latestVersion}`;
2865
+ spawnSync(updateCmd, {
2856
2866
  stdio: 'inherit',
2857
2867
  shell: true,
2858
2868
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawsetup",
3
- "version": "2.8.6",
3
+ "version": "2.8.7",
4
4
  "description": "OpenClaw 安装向导 - 智能安装、诊断、自动修复",
5
5
  "type": "module",
6
6
  "bin": {