openclawsetup 2.5.1 → 2.5.3

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 +29 -45
  2. package/package.json +1 -1
package/bin/cli.mjs CHANGED
@@ -512,48 +512,15 @@ async function installOpenClaw() {
512
512
  async function runOnboard(cliName) {
513
513
  console.log(colors.bold(colors.cyan('\n[2/2] 运行配置向导\n')));
514
514
 
515
- const options = parseArgs();
516
-
517
- // 让用户选择安装模式
518
- let mode = options.manual ? '2' : options.auto ? '1' : '';
519
- if (!mode) {
520
- console.log(colors.cyan('请选择安装模式:'));
521
- console.log(` ${colors.yellow('1')}. 自动安装(跳过所有配置,后续单独配置模型和渠道)`);
522
- console.log(` ${colors.yellow('2')}. 手动安装(走官方 onboard 完整流程)`);
523
- mode = await askQuestion('\n请选择 (1/2): ');
524
- }
525
-
526
- if (mode.trim() === '2') {
527
- // 手动模式:直接运行官方 onboard
528
- console.log(colors.gray('\n' + '-'.repeat(60)));
529
- console.log(colors.gray('以下是官方 openclaw onboard 界面:'));
530
- console.log(colors.gray('-'.repeat(60) + '\n'));
531
-
532
- const manualResult = runOnboardManual(cliName);
533
- console.log(colors.gray('\n' + '-'.repeat(60)));
534
- if (manualResult.status !== 0) {
535
- log.warn(`onboard 退出码: ${manualResult.status}`);
536
- log.hint('如果配置未完成,可以手动运行: ' + cliName + ' onboard');
537
- }
538
- } else {
539
- // 自动模式:只用最安全的参数
540
- console.log(colors.gray('\n正在自动安装(跳过模型和渠道配置)...\n'));
541
-
542
- const { file, args } = getOnboardCommand(cliName, ['onboard', '--install-daemon']);
543
- const result = spawnSync(file, args, { stdio: 'inherit' });
544
-
545
- if (result.status !== 0) {
546
- // 自动模式失败,回退到手动
547
- log.warn('自动安装未完成,切换到手动模式...');
548
- console.log(colors.gray('\n' + '-'.repeat(60)));
549
- console.log(colors.gray('以下是官方 openclaw onboard 界面:'));
550
- console.log(colors.gray('-'.repeat(60) + '\n'));
551
- const manualResult = runOnboardManual(cliName);
552
- if (manualResult.status !== 0) {
553
- log.warn(`onboard 退出码: ${manualResult.status}`);
554
- log.hint('如果配置未完成,可以手动运行: ' + cliName + ' onboard');
555
- }
556
- }
515
+ console.log(colors.gray('-'.repeat(60)));
516
+ console.log(colors.gray('以下是官方 openclaw onboard 界面:'));
517
+ console.log(colors.gray('-'.repeat(60) + '\n'));
518
+
519
+ const manualResult = runOnboardManual(cliName);
520
+ console.log(colors.gray('\n' + '-'.repeat(60)));
521
+ if (manualResult.status !== 0) {
522
+ log.warn(`onboard 退出码: ${manualResult.status}`);
523
+ log.hint('如果配置未完成,可以手动运行: ' + cliName + ' onboard');
557
524
  }
558
525
  }
559
526
 
@@ -1010,6 +977,8 @@ async function runHealthCheck(cliName, autoFix = false) {
1010
977
  console.log(colors.yellow(' 尝试启动 Gateway...'));
1011
978
  const startResult = safeExec(`${cliName} gateway start`);
1012
979
  if (startResult.ok) {
980
+ console.log(colors.gray(' 等待 Gateway 启动...'));
981
+ await new Promise(r => setTimeout(r, 5000));
1013
982
  log.success('Gateway 已启动');
1014
983
  fixed.push('Gateway 已自动启动');
1015
984
  } else {
@@ -1040,7 +1009,10 @@ async function runHealthCheck(cliName, autoFix = false) {
1040
1009
  log.success(`端口 ${port} 正在监听`);
1041
1010
  } else {
1042
1011
  // 检查是否有其他进程占用端口
1043
- const conflictCheck = safeExec(`lsof -i :${port} 2>/dev/null | head -5`);
1012
+ const conflictCmd = platform() === 'win32'
1013
+ ? `netstat -ano | findstr :${port} | findstr LISTENING`
1014
+ : `lsof -i :${port} 2>/dev/null | head -5`;
1015
+ const conflictCheck = safeExec(conflictCmd);
1044
1016
  if (conflictCheck.ok && conflictCheck.output && !conflictCheck.output.includes('openclaw') && !conflictCheck.output.includes('node')) {
1045
1017
  const issue = {
1046
1018
  level: 'error',
@@ -1074,8 +1046,18 @@ async function runHealthCheck(cliName, autoFix = false) {
1074
1046
  console.log(colors.yellow(' 尝试重启 Gateway...'));
1075
1047
  const restartResult = safeExec(`${cliName} gateway restart`);
1076
1048
  if (restartResult.ok) {
1077
- log.success('Gateway 已重启');
1078
- fixed.push('Gateway 已自动重启');
1049
+ // 等待 Gateway 绑定端口
1050
+ console.log(colors.gray(' 等待 Gateway 启动...'));
1051
+ await new Promise(r => setTimeout(r, 5000));
1052
+ // 重新检查端口
1053
+ const recheck = safeExec(portCheckCmd);
1054
+ if (recheck.ok && recheck.output) {
1055
+ log.success('Gateway 已重启,端口正常');
1056
+ fixed.push('Gateway 已自动重启');
1057
+ } else {
1058
+ log.warn('Gateway 已重启但端口仍未监听');
1059
+ issues.push({ ...issue, detail: 'Gateway 重启后端口仍未监听,可能配置有问题' });
1060
+ }
1079
1061
  } else {
1080
1062
  issues.push(issue);
1081
1063
  }
@@ -1120,6 +1102,8 @@ async function runHealthCheck(cliName, autoFix = false) {
1120
1102
  console.log(colors.yellow(' 尝试重启 Gateway...'));
1121
1103
  const restartResult = safeExec(`${cliName} gateway restart`);
1122
1104
  if (restartResult.ok) {
1105
+ console.log(colors.gray(' 等待 Gateway 启动...'));
1106
+ await new Promise(r => setTimeout(r, 5000));
1123
1107
  log.success('Gateway 已重启');
1124
1108
  fixed.push('Gateway 已自动重启(API 无响应)');
1125
1109
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawsetup",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "OpenClaw 安装向导 - 智能安装、诊断、自动修复",
5
5
  "type": "module",
6
6
  "bin": {