openclawsetup 2.4.3 → 2.4.4
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 +112 -15
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -1168,6 +1168,98 @@ async function runHealthCheck(cliName, autoFix = false) {
|
|
|
1168
1168
|
|
|
1169
1169
|
// ============ 交互式菜单 ============
|
|
1170
1170
|
|
|
1171
|
+
async function showStatusInfo(cliName) {
|
|
1172
|
+
const config = getConfigInfo();
|
|
1173
|
+
const port = config.port || 18789;
|
|
1174
|
+
const token = config.token || '<未配置>';
|
|
1175
|
+
const dashboardUrl = `http://127.0.0.1:${port}/?token=${token}`;
|
|
1176
|
+
|
|
1177
|
+
console.log(colors.bold(colors.cyan('\n📊 OpenClaw 状态信息\n')));
|
|
1178
|
+
|
|
1179
|
+
// 服务状态
|
|
1180
|
+
const statusResult = safeExec(`${cliName} status`);
|
|
1181
|
+
const output = statusResult.ok ? statusResult.output : '';
|
|
1182
|
+
const isRunning = output.toLowerCase().includes('running') || output.toLowerCase().includes('active');
|
|
1183
|
+
|
|
1184
|
+
if (isRunning) {
|
|
1185
|
+
console.log(colors.green(' ✓ Gateway 服务正在运行'));
|
|
1186
|
+
} else {
|
|
1187
|
+
console.log(colors.red(' ✗ Gateway 服务未运行'));
|
|
1188
|
+
console.log(colors.yellow(' → 请先选择「检查修复」自动修复此问题\n'));
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// 端口检查
|
|
1193
|
+
const portCmd = platform() === 'win32'
|
|
1194
|
+
? `netstat -an | findstr :${port}`
|
|
1195
|
+
: `lsof -i :${port} 2>/dev/null || netstat -tlnp 2>/dev/null | grep :${port}`;
|
|
1196
|
+
const portResult = safeExec(portCmd);
|
|
1197
|
+
if (portResult.ok && portResult.output) {
|
|
1198
|
+
console.log(colors.green(` ✓ 端口 ${port} 正在监听`));
|
|
1199
|
+
} else {
|
|
1200
|
+
console.log(colors.red(` ✗ 端口 ${port} 未监听`));
|
|
1201
|
+
console.log(colors.yellow(' → 请先选择「检查修复」自动修复此问题\n'));
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// 模型配置
|
|
1206
|
+
if (config.raw) {
|
|
1207
|
+
const hasProviders = config.raw.includes('"providers"');
|
|
1208
|
+
if (hasProviders) {
|
|
1209
|
+
console.log(colors.green(' ✓ 已配置 AI 模型'));
|
|
1210
|
+
} else {
|
|
1211
|
+
console.log(colors.yellow(' ⚠ 未配置模型,请先选择「配置模型」'));
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// Dashboard 访问指南
|
|
1216
|
+
console.log(colors.bold(colors.cyan('\n' + '─'.repeat(46))));
|
|
1217
|
+
console.log(colors.bold(colors.cyan(' 🌐 Web Dashboard 访问方法')));
|
|
1218
|
+
console.log(colors.bold(colors.cyan('─'.repeat(46))));
|
|
1219
|
+
|
|
1220
|
+
if (detectVps()) {
|
|
1221
|
+
const serverIp = getServerIp() || '<服务器IP>';
|
|
1222
|
+
const user = process.env.USER || 'root';
|
|
1223
|
+
|
|
1224
|
+
console.log(colors.gray('\n Gateway 绑定在 127.0.0.1(安全设计),需要通过'));
|
|
1225
|
+
console.log(colors.gray(' SSH 隧道从本地电脑访问。\n'));
|
|
1226
|
+
|
|
1227
|
+
console.log(colors.bold(' 第 1 步:在本地电脑打开终端,执行:\n'));
|
|
1228
|
+
|
|
1229
|
+
console.log(colors.yellow(' macOS / Linux:'));
|
|
1230
|
+
console.log(colors.green(` ssh -N -L ${port}:127.0.0.1:${port} ${user}@${serverIp}`));
|
|
1231
|
+
console.log('');
|
|
1232
|
+
console.log(colors.yellow(' Windows PowerShell:'));
|
|
1233
|
+
console.log(colors.green(` ssh -N -L ${port}:127.0.0.1:${port} ${user}@${serverIp}`));
|
|
1234
|
+
console.log('');
|
|
1235
|
+
console.log(colors.gray(' 保持这个终端窗口不要关闭。'));
|
|
1236
|
+
|
|
1237
|
+
console.log(colors.bold('\n 第 2 步:在本地浏览器打开:\n'));
|
|
1238
|
+
console.log(colors.green(` ${dashboardUrl}`));
|
|
1239
|
+
|
|
1240
|
+
console.log(colors.bold('\n 注意事项:'));
|
|
1241
|
+
console.log(colors.gray(' • SSH 窗口关闭后 Dashboard 无法访问,需重新执行第 1 步'));
|
|
1242
|
+
console.log(colors.gray(' • 如果连接断开,重新执行 SSH 命令即可'));
|
|
1243
|
+
console.log(colors.gray(' • 不建议将端口直接暴露到公网'));
|
|
1244
|
+
} else if (platform() === 'win32') {
|
|
1245
|
+
console.log(colors.gray('\n OpenClaw 运行在本机,直接用浏览器访问即可。\n'));
|
|
1246
|
+
console.log(colors.bold(' 在浏览器打开:\n'));
|
|
1247
|
+
console.log(colors.green(` ${dashboardUrl}`));
|
|
1248
|
+
console.log(colors.bold('\n 注意事项:'));
|
|
1249
|
+
console.log(colors.gray(' • 确保 Gateway 服务正在运行'));
|
|
1250
|
+
console.log(colors.gray(' • 如果无法访问,选择「检查修复」排查问题'));
|
|
1251
|
+
} else {
|
|
1252
|
+
console.log(colors.gray('\n OpenClaw 运行在本机,直接用浏览器访问即可。\n'));
|
|
1253
|
+
console.log(colors.bold(' 在浏览器打开:\n'));
|
|
1254
|
+
console.log(colors.green(` ${dashboardUrl}`));
|
|
1255
|
+
console.log(colors.bold('\n 注意事项:'));
|
|
1256
|
+
console.log(colors.gray(' • 确保 Gateway 服务正在运行'));
|
|
1257
|
+
console.log(colors.gray(' • 如果无法访问,选择「检查修复」排查问题'));
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
console.log('');
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1171
1263
|
async function showInteractiveMenu(existing) {
|
|
1172
1264
|
const cliName = existing.name || 'openclaw';
|
|
1173
1265
|
|
|
@@ -1179,27 +1271,32 @@ async function showInteractiveMenu(existing) {
|
|
|
1179
1271
|
showDashboardAccessInfo();
|
|
1180
1272
|
|
|
1181
1273
|
console.log(colors.cyan('\n请选择操作:'));
|
|
1182
|
-
console.log(` ${colors.yellow('1')}.
|
|
1183
|
-
console.log(` ${colors.yellow('2')}.
|
|
1184
|
-
console.log(` ${colors.yellow('3')}.
|
|
1185
|
-
console.log(` ${colors.yellow('4')}.
|
|
1186
|
-
console.log(` ${colors.yellow('5')}.
|
|
1187
|
-
console.log(` ${colors.yellow('6')}.
|
|
1188
|
-
console.log(` ${colors.yellow('7')}.
|
|
1274
|
+
console.log(` ${colors.yellow('1')}. 状态信息`);
|
|
1275
|
+
console.log(` ${colors.yellow('2')}. 检查修复`);
|
|
1276
|
+
console.log(` ${colors.yellow('3')}. 检查更新`);
|
|
1277
|
+
console.log(` ${colors.yellow('4')}. 配置模型`);
|
|
1278
|
+
console.log(` ${colors.yellow('5')}. 配置 Chat`);
|
|
1279
|
+
console.log(` ${colors.yellow('6')}. 配置技能`);
|
|
1280
|
+
console.log(` ${colors.yellow('7')}. 重新安装`);
|
|
1281
|
+
console.log(` ${colors.yellow('8')}. 完全卸载`);
|
|
1189
1282
|
console.log(` ${colors.yellow('0')}. 退出`);
|
|
1190
1283
|
|
|
1191
|
-
const choice = await askQuestion('\n请输入选项 (0-
|
|
1284
|
+
const choice = await askQuestion('\n请输入选项 (0-8): ');
|
|
1192
1285
|
|
|
1193
1286
|
switch (choice.trim()) {
|
|
1194
1287
|
case '1':
|
|
1195
|
-
await
|
|
1288
|
+
await showStatusInfo(cliName);
|
|
1196
1289
|
await waitForEnter('\n按回车返回菜单...');
|
|
1197
1290
|
break;
|
|
1198
1291
|
case '2':
|
|
1199
|
-
await
|
|
1292
|
+
await runHealthCheck(cliName, true);
|
|
1200
1293
|
await waitForEnter('\n按回车返回菜单...');
|
|
1201
1294
|
break;
|
|
1202
1295
|
case '3':
|
|
1296
|
+
await updateOpenClaw(cliName);
|
|
1297
|
+
await waitForEnter('\n按回车返回菜单...');
|
|
1298
|
+
break;
|
|
1299
|
+
case '4':
|
|
1203
1300
|
console.log(colors.cyan('\n启动模型配置...'));
|
|
1204
1301
|
spawnSync('npx', ['openclawapi@latest'], {
|
|
1205
1302
|
stdio: 'inherit',
|
|
@@ -1207,7 +1304,7 @@ async function showInteractiveMenu(existing) {
|
|
|
1207
1304
|
});
|
|
1208
1305
|
await waitForEnter('\n按回车返回菜单...');
|
|
1209
1306
|
break;
|
|
1210
|
-
case '
|
|
1307
|
+
case '5':
|
|
1211
1308
|
console.log(colors.cyan('\n选择聊天渠道:'));
|
|
1212
1309
|
console.log(` ${colors.yellow('a')}. Discord`);
|
|
1213
1310
|
console.log(` ${colors.yellow('b')}. 飞书`);
|
|
@@ -1227,13 +1324,13 @@ async function showInteractiveMenu(existing) {
|
|
|
1227
1324
|
}
|
|
1228
1325
|
await waitForEnter('\n按回车返回菜单...');
|
|
1229
1326
|
break;
|
|
1230
|
-
case '
|
|
1327
|
+
case '6':
|
|
1231
1328
|
console.log(colors.cyan('\n配置技能(即将支持)...'));
|
|
1232
1329
|
// TODO: 等待技能地址提供后实现
|
|
1233
1330
|
log.warn('技能配置功能即将上线,请稍后再试');
|
|
1234
1331
|
await waitForEnter('\n按回车返回菜单...');
|
|
1235
1332
|
break;
|
|
1236
|
-
case '
|
|
1333
|
+
case '7':
|
|
1237
1334
|
console.log(colors.yellow('\n即将重新安装 OpenClaw...'));
|
|
1238
1335
|
const confirmReinstall = await askQuestion('确认重新安装?(y/N): ');
|
|
1239
1336
|
if (confirmReinstall.toLowerCase() === 'y') {
|
|
@@ -1243,7 +1340,7 @@ async function showInteractiveMenu(existing) {
|
|
|
1243
1340
|
showCompletionInfo(newCliName);
|
|
1244
1341
|
}
|
|
1245
1342
|
break;
|
|
1246
|
-
case '
|
|
1343
|
+
case '8':
|
|
1247
1344
|
console.log(colors.red('\n⚠ 警告:卸载将删除所有配置!'));
|
|
1248
1345
|
const confirmUninstall = await askQuestion('确认卸载?(y/N): ');
|
|
1249
1346
|
if (confirmUninstall.toLowerCase() === 'y') {
|
|
@@ -1257,7 +1354,7 @@ async function showInteractiveMenu(existing) {
|
|
|
1257
1354
|
console.log(colors.gray('\n再见!'));
|
|
1258
1355
|
process.exit(0);
|
|
1259
1356
|
default:
|
|
1260
|
-
log.warn('无效选项,请输入 0-
|
|
1357
|
+
log.warn('无效选项,请输入 0-8');
|
|
1261
1358
|
}
|
|
1262
1359
|
}
|
|
1263
1360
|
}
|