openclawsetup 2.4.2 → 2.4.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.
- package/bin/cli.mjs +33 -6
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -895,13 +895,20 @@ async function runHealthCheck(cliName, autoFix = false) {
|
|
|
895
895
|
// 1. 检查配置文件
|
|
896
896
|
console.log(colors.cyan('检查配置文件...'));
|
|
897
897
|
if (!config.configPath || !existsSync(config.configPath)) {
|
|
898
|
-
|
|
898
|
+
const issue = {
|
|
899
899
|
level: 'error',
|
|
900
900
|
title: '配置文件不存在',
|
|
901
901
|
detail: '未找到 openclaw.json 配置文件',
|
|
902
902
|
solution: '运行 openclaw onboard 重新配置',
|
|
903
903
|
fixCmd: `${cliName} onboard`,
|
|
904
|
-
}
|
|
904
|
+
};
|
|
905
|
+
if (autoFix) {
|
|
906
|
+
console.log(colors.yellow(' 尝试运行 onboard 生成配置...'));
|
|
907
|
+
spawnSync(cliName, ['onboard'], { stdio: 'inherit', shell: true });
|
|
908
|
+
fixed.push('已运行 onboard 生成配置');
|
|
909
|
+
} else {
|
|
910
|
+
issues.push(issue);
|
|
911
|
+
}
|
|
905
912
|
} else {
|
|
906
913
|
try {
|
|
907
914
|
const raw = readFileSync(config.configPath, 'utf8');
|
|
@@ -983,13 +990,26 @@ async function runHealthCheck(cliName, autoFix = false) {
|
|
|
983
990
|
// 检查是否有其他进程占用端口
|
|
984
991
|
const conflictCheck = safeExec(`lsof -i :${port} 2>/dev/null | head -5`);
|
|
985
992
|
if (conflictCheck.ok && conflictCheck.output && !conflictCheck.output.includes('openclaw') && !conflictCheck.output.includes('node')) {
|
|
986
|
-
|
|
993
|
+
const issue = {
|
|
987
994
|
level: 'error',
|
|
988
995
|
title: `端口 ${port} 被其他程序占用`,
|
|
989
996
|
detail: conflictCheck.output.slice(0, 100),
|
|
990
997
|
solution: `更换端口: ${cliName} config set gateway.port 18790`,
|
|
991
998
|
fixCmd: `${cliName} config set gateway.port 18790 && ${cliName} gateway restart`,
|
|
992
|
-
}
|
|
999
|
+
};
|
|
1000
|
+
if (autoFix) {
|
|
1001
|
+
console.log(colors.yellow(' 尝试更换端口到 18790...'));
|
|
1002
|
+
const portResult = safeExec(`${cliName} config set gateway.port 18790`);
|
|
1003
|
+
const restartResult = safeExec(`${cliName} gateway restart`);
|
|
1004
|
+
if (portResult.ok && restartResult.ok) {
|
|
1005
|
+
log.success('已更换端口到 18790 并重启 Gateway');
|
|
1006
|
+
fixed.push('端口冲突已自动解决(更换到 18790)');
|
|
1007
|
+
} else {
|
|
1008
|
+
issues.push(issue);
|
|
1009
|
+
}
|
|
1010
|
+
} else {
|
|
1011
|
+
issues.push(issue);
|
|
1012
|
+
}
|
|
993
1013
|
} else {
|
|
994
1014
|
const issue = {
|
|
995
1015
|
level: 'error',
|
|
@@ -1064,13 +1084,20 @@ async function runHealthCheck(cliName, autoFix = false) {
|
|
|
1064
1084
|
const hasModels = config.raw.includes('"models"') || config.raw.includes('"providers"');
|
|
1065
1085
|
const hasApiKey = config.raw.includes('"apiKey"') || config.raw.includes('"api_key"');
|
|
1066
1086
|
if (!hasModels && !hasApiKey) {
|
|
1067
|
-
|
|
1087
|
+
const issue = {
|
|
1068
1088
|
level: 'warning',
|
|
1069
1089
|
title: '未配置 AI 模型',
|
|
1070
1090
|
detail: '配置文件中未找到模型或 API Key 配置',
|
|
1071
1091
|
solution: '运行 npx openclawapi@latest 配置模型',
|
|
1072
1092
|
fixCmd: 'npx openclawapi@latest',
|
|
1073
|
-
}
|
|
1093
|
+
};
|
|
1094
|
+
if (autoFix) {
|
|
1095
|
+
console.log(colors.yellow(' 启动模型配置...'));
|
|
1096
|
+
spawnSync('npx', ['openclawapi@latest'], { stdio: 'inherit', shell: true });
|
|
1097
|
+
fixed.push('已启动模型配置向导');
|
|
1098
|
+
} else {
|
|
1099
|
+
issues.push(issue);
|
|
1100
|
+
}
|
|
1074
1101
|
} else {
|
|
1075
1102
|
log.success('已配置模型');
|
|
1076
1103
|
}
|