openclawsetup 2.4.9 → 2.5.1
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 +54 -48
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -512,64 +512,48 @@ async function installOpenClaw() {
|
|
|
512
512
|
async function runOnboard(cliName) {
|
|
513
513
|
console.log(colors.bold(colors.cyan('\n[2/2] 运行配置向导\n')));
|
|
514
514
|
|
|
515
|
-
// 显示指引
|
|
516
|
-
showInstallGuide();
|
|
517
|
-
|
|
518
|
-
await waitForEnter('准备好了吗?按回车开始配置...');
|
|
519
|
-
|
|
520
|
-
console.log(colors.gray('\n' + '-'.repeat(60)));
|
|
521
|
-
console.log(colors.gray('以下是官方 openclaw onboard 界面:'));
|
|
522
|
-
console.log(colors.gray('-'.repeat(60) + '\n'));
|
|
523
|
-
|
|
524
515
|
const options = parseArgs();
|
|
525
|
-
const preferAuto = !options.manual;
|
|
526
|
-
let usedAuto = false;
|
|
527
|
-
|
|
528
|
-
if (preferAuto) {
|
|
529
|
-
const flagResult = runOnboardFlags(cliName, options);
|
|
530
|
-
if (flagResult.ran) {
|
|
531
|
-
usedAuto = true;
|
|
532
|
-
console.log(colors.gray('\n' + '-'.repeat(60)));
|
|
533
|
-
if (!flagResult.ok) {
|
|
534
|
-
log.warn(`onboard 退出码: ${flagResult.exitCode}`);
|
|
535
|
-
log.hint('如果配置未完成,可以手动运行: ' + cliName + ' onboard');
|
|
536
|
-
}
|
|
537
|
-
} else {
|
|
538
|
-
const autoResult = await runOnboardAuto(cliName, options);
|
|
539
|
-
if (autoResult.ok) {
|
|
540
|
-
usedAuto = true;
|
|
541
|
-
console.log(colors.gray('\n' + '-'.repeat(60)));
|
|
542
|
-
if (autoResult.exitCode !== 0) {
|
|
543
|
-
log.warn(`onboard 退出码: ${autoResult.exitCode}`);
|
|
544
|
-
log.hint('如果配置未完成,可以手动运行: ' + cliName + ' onboard');
|
|
545
|
-
}
|
|
546
|
-
} else if (options.auto) {
|
|
547
|
-
exitWithError('PTY_UNAVAILABLE', `
|
|
548
|
-
原因: ${autoResult.reason || '未能启用自动应答'}
|
|
549
516
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
npm install -g openclaw@latest
|
|
558
|
-
openclaw onboard --install-daemon`);
|
|
559
|
-
} else {
|
|
560
|
-
log.warn('自动模式不可用,已切换为手动模式');
|
|
561
|
-
log.hint(autoResult.reason || '未能启用自动应答');
|
|
562
|
-
}
|
|
563
|
-
}
|
|
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): ');
|
|
564
524
|
}
|
|
565
525
|
|
|
566
|
-
if (
|
|
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
|
+
|
|
567
532
|
const manualResult = runOnboardManual(cliName);
|
|
568
533
|
console.log(colors.gray('\n' + '-'.repeat(60)));
|
|
569
534
|
if (manualResult.status !== 0) {
|
|
570
535
|
log.warn(`onboard 退出码: ${manualResult.status}`);
|
|
571
536
|
log.hint('如果配置未完成,可以手动运行: ' + cliName + ' onboard');
|
|
572
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
|
+
}
|
|
573
557
|
}
|
|
574
558
|
}
|
|
575
559
|
|
|
@@ -1517,6 +1501,28 @@ function askQuestion(prompt) {
|
|
|
1517
1501
|
async function main() {
|
|
1518
1502
|
const options = parseArgs();
|
|
1519
1503
|
|
|
1504
|
+
// 检查是否为最新版本,提示用户更新
|
|
1505
|
+
try {
|
|
1506
|
+
const pkgJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
1507
|
+
const currentVersion = pkgJson.version;
|
|
1508
|
+
const latestResult = safeExec('npm view openclawsetup version 2>/dev/null');
|
|
1509
|
+
if (latestResult.ok && latestResult.output) {
|
|
1510
|
+
const latestVersion = latestResult.output.trim();
|
|
1511
|
+
if (latestVersion && latestVersion !== currentVersion) {
|
|
1512
|
+
console.log(colors.yellow(`\n⚠ 当前版本 ${currentVersion},最新版本 ${latestVersion}`));
|
|
1513
|
+
console.log(colors.yellow(' 正在更新到最新版本...\n'));
|
|
1514
|
+
const updateCmd = platform() === 'win32'
|
|
1515
|
+
? `npx --yes openclawsetup@${latestVersion}`
|
|
1516
|
+
: `npx --yes openclawsetup@${latestVersion}`;
|
|
1517
|
+
spawnSync(updateCmd.split(' ')[0], updateCmd.split(' ').slice(1), {
|
|
1518
|
+
stdio: 'inherit',
|
|
1519
|
+
shell: true,
|
|
1520
|
+
});
|
|
1521
|
+
process.exit(0);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
} catch { /* ignore version check errors */ }
|
|
1525
|
+
|
|
1520
1526
|
if (options.help) {
|
|
1521
1527
|
showHelp();
|
|
1522
1528
|
process.exit(0);
|