@aiyiran/myclaw 1.0.162 → 1.0.164
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/index.js +1 -1
- package/package.json +1 -1
- package/start.js +19 -0
- package/wsl2.js +48 -11
package/index.js
CHANGED
|
@@ -1131,7 +1131,7 @@ function showHelp() {
|
|
|
1131
1131
|
console.log(' up 升级 + 刷新桌面快捷方式 (= update + bat)');
|
|
1132
1132
|
console.log(' open 打开浏览器控制台(自动带 token)');
|
|
1133
1133
|
console.log(' fix 兜底修复(自动补装 WSL + Chrome,仅限 Windows)');
|
|
1134
|
-
console.log(' wsl2 WSL2 一键安装/修复 (仅限 Windows, 可选: --cli)');
|
|
1134
|
+
console.log(' wsl2 WSL2 一键安装/修复 (仅限 Windows, 可选: --cli, --remote)');
|
|
1135
1135
|
console.log(' safe 开启虚拟机屏蔽 (禁止自动挂载 Windows 盘符)');
|
|
1136
1136
|
console.log(' bat 在桌面生成一键启动脚本 (仅限 Windows)');
|
|
1137
1137
|
console.log(' list 查看注入资源管理列表(智能体/技能/配置)');
|
package/package.json
CHANGED
package/start.js
CHANGED
|
@@ -66,6 +66,25 @@ function startWindows() {
|
|
|
66
66
|
}
|
|
67
67
|
console.log('');
|
|
68
68
|
|
|
69
|
+
// Step 2.5: 自动检测虚拟机屏蔽(safe)
|
|
70
|
+
console.log('[safe] 虚拟机屏蔽...');
|
|
71
|
+
try {
|
|
72
|
+
const conf = execSync('wsl -d OpenClaw -u root -- cat /etc/wsl.conf 2>/dev/null', {
|
|
73
|
+
encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'],
|
|
74
|
+
});
|
|
75
|
+
if (conf.includes('enabled = false') || conf.includes('enabled=false')) {
|
|
76
|
+
console.log(' ' + C.g + '[已开启]' + C.nc);
|
|
77
|
+
} else {
|
|
78
|
+
console.log(' ' + C.y + '[未开启,正在启用...]' + C.nc);
|
|
79
|
+
try { execSync('myclaw safe', { stdio: 'inherit', timeout: 30000 }); } catch {}
|
|
80
|
+
}
|
|
81
|
+
} catch {
|
|
82
|
+
// wsl.conf 不存在,说明还没开启
|
|
83
|
+
console.log(' ' + C.y + '[未开启,正在启用...]' + C.nc);
|
|
84
|
+
try { execSync('myclaw safe', { stdio: 'inherit', timeout: 30000 }); } catch {}
|
|
85
|
+
}
|
|
86
|
+
console.log('');
|
|
87
|
+
|
|
69
88
|
// Step 3: 检查 Gateway
|
|
70
89
|
console.log('[3/4] Gateway...');
|
|
71
90
|
let gatewayRunning = false;
|
package/wsl2.js
CHANGED
|
@@ -97,10 +97,31 @@ function launchElevatedPS(script) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function makeAskLocalOrCDN(prompt, destVar, cdnUrl, desc, fileName) {
|
|
100
|
+
function makeAskLocalOrCDN(prompt, destVar, cdnUrl, desc, fileName, forceRemote) {
|
|
101
101
|
const config = getConfig();
|
|
102
102
|
const callerDir = (config.installerDir || process.env.MYCLAW_INSTALLER_DIR || process.cwd()).replace(/\\/g, '\\\\');
|
|
103
103
|
const cdnFilename = cdnUrl.split('/').pop();
|
|
104
|
+
|
|
105
|
+
// --remote 模式:跳过所有本地检测,直接从 CDN 下载
|
|
106
|
+
if (forceRemote) {
|
|
107
|
+
return `
|
|
108
|
+
Write-Host ""
|
|
109
|
+
Write-Host " [强制远程] 跳过本地文件检测,从网络下载..."
|
|
110
|
+
Write-Host ""
|
|
111
|
+
Write-Host ' -------------------------------------------------------------'
|
|
112
|
+
Write-Host ' [提示] 下载中请勿点击窗口内部(会导致卡死)。'
|
|
113
|
+
Write-Host ' [恢复] 若进度条长时间不动,请按一下 [回车键] 即可恢复。'
|
|
114
|
+
Write-Host ' -------------------------------------------------------------'
|
|
115
|
+
try {
|
|
116
|
+
Start-BitsTransfer -Source '${cdnUrl}' -Destination ${destVar} -Description '下载 ${desc}' -DisplayName 'OpenClaw'
|
|
117
|
+
Write-Host ' 下载完成!'
|
|
118
|
+
} catch {
|
|
119
|
+
Write-Host ' [失败] 下载失败,请检查网络后重试'
|
|
120
|
+
throw '下载失败'
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
|
|
104
125
|
return `
|
|
105
126
|
$callerDir = "${callerDir}"
|
|
106
127
|
|
|
@@ -190,7 +211,7 @@ if ($resolved) {
|
|
|
190
211
|
// Phase 1: 启用功能 + 安装 WSL + 下载 Linux 镜像(全部在重启前完成)
|
|
191
212
|
// ============================================================================
|
|
192
213
|
|
|
193
|
-
function runPhase1() {
|
|
214
|
+
function runPhase1(forceRemote) {
|
|
194
215
|
console.log('');
|
|
195
216
|
console.log('[当前进度] WSL 功能 ' + C.y + '[安装/覆盖]' + C.nc);
|
|
196
217
|
console.log(' WSL 组件 ' + C.y + '[安装/重置]' + C.nc);
|
|
@@ -208,7 +229,8 @@ function runPhase1() {
|
|
|
208
229
|
'$msi',
|
|
209
230
|
WSL_CDN.wsl,
|
|
210
231
|
'WSL 安装包 (wsl_full.msi)',
|
|
211
|
-
'wsl_full.msi'
|
|
232
|
+
'wsl_full.msi',
|
|
233
|
+
forceRemote
|
|
212
234
|
);
|
|
213
235
|
|
|
214
236
|
const askTar = makeAskLocalOrCDN(
|
|
@@ -216,7 +238,8 @@ function runPhase1() {
|
|
|
216
238
|
'$tarPath',
|
|
217
239
|
WSL_CDN.rootfs,
|
|
218
240
|
'Linux 环境包 (openclaw-rootfs.tar)',
|
|
219
|
-
'openclaw-rootfs.tar'
|
|
241
|
+
'openclaw-rootfs.tar',
|
|
242
|
+
forceRemote
|
|
220
243
|
);
|
|
221
244
|
|
|
222
245
|
const ps = `
|
|
@@ -327,7 +350,7 @@ Write-Host '========================================'
|
|
|
327
350
|
// Phase 2: 导入已下载的 Linux 环境(重启后,纯本地操作,极快)
|
|
328
351
|
// ============================================================================
|
|
329
352
|
|
|
330
|
-
function runPhase2() {
|
|
353
|
+
function runPhase2(forceRemote) {
|
|
331
354
|
console.log('');
|
|
332
355
|
console.log('[当前进度] WSL 功能 ' + C.g + '[已就绪]' + C.nc);
|
|
333
356
|
console.log(' WSL 组件 ' + C.g + '[已就绪]' + C.nc);
|
|
@@ -374,7 +397,8 @@ if (Test-Path $tarPath) {
|
|
|
374
397
|
'$tarPath',
|
|
375
398
|
WSL_CDN.rootfs,
|
|
376
399
|
'Linux 环境包 (openclaw-rootfs.tar)',
|
|
377
|
-
'openclaw-rootfs.tar'
|
|
400
|
+
'openclaw-rootfs.tar',
|
|
401
|
+
forceRemote
|
|
378
402
|
)}
|
|
379
403
|
}
|
|
380
404
|
Write-Host ''
|
|
@@ -482,10 +506,11 @@ function runCliMode() {
|
|
|
482
506
|
console.log(' 1. 重新安装 Phase 1 (启用功能 + 下载)');
|
|
483
507
|
console.log(' 2. 重新安装 Phase 2 (导入 Linux 环境)');
|
|
484
508
|
console.log(' 3. 重新设置安装包路径');
|
|
509
|
+
console.log(' 4. WSL2虚拟机重装 (强制远程 + 阶段1重启)');
|
|
485
510
|
console.log(' 0. 退出');
|
|
486
511
|
console.log('');
|
|
487
512
|
|
|
488
|
-
const choice = await question('请输入选项 (0-
|
|
513
|
+
const choice = await question('请输入选项 (0-4): ');
|
|
489
514
|
|
|
490
515
|
switch (choice.trim()) {
|
|
491
516
|
case '1':
|
|
@@ -493,7 +518,7 @@ function runCliMode() {
|
|
|
493
518
|
console.log('[' + C.y + '执行' + C.nc + '] 开始 Phase 1 安装...');
|
|
494
519
|
setState('needs-features');
|
|
495
520
|
rl.close();
|
|
496
|
-
runPhase1();
|
|
521
|
+
runPhase1(false);
|
|
497
522
|
break;
|
|
498
523
|
|
|
499
524
|
case '2':
|
|
@@ -501,7 +526,7 @@ function runCliMode() {
|
|
|
501
526
|
console.log('[' + C.y + '执行' + C.nc + '] 开始 Phase 2 安装...');
|
|
502
527
|
setState('phase1-done');
|
|
503
528
|
rl.close();
|
|
504
|
-
runPhase2();
|
|
529
|
+
runPhase2(false);
|
|
505
530
|
break;
|
|
506
531
|
|
|
507
532
|
case '3':
|
|
@@ -519,6 +544,15 @@ function runCliMode() {
|
|
|
519
544
|
rl.close();
|
|
520
545
|
break;
|
|
521
546
|
|
|
547
|
+
case '4':
|
|
548
|
+
console.log('');
|
|
549
|
+
console.log('[' + C.y + '执行' + C.nc + '] WSL2虚拟机重装 (强制远程下载)...');
|
|
550
|
+
console.log('');
|
|
551
|
+
setState('needs-features');
|
|
552
|
+
rl.close();
|
|
553
|
+
runPhase1(true);
|
|
554
|
+
break;
|
|
555
|
+
|
|
522
556
|
case '0':
|
|
523
557
|
console.log('');
|
|
524
558
|
console.log('已退出。');
|
|
@@ -560,6 +594,9 @@ function run() {
|
|
|
560
594
|
setState('phase1-done');
|
|
561
595
|
}
|
|
562
596
|
|
|
597
|
+
// --remote: 强制从 CDN 下载,不信任本地文件
|
|
598
|
+
const forceRemote = process.argv.includes('--remote');
|
|
599
|
+
|
|
563
600
|
const bar = '========================================';
|
|
564
601
|
const state = getState();
|
|
565
602
|
|
|
@@ -599,9 +636,9 @@ function run() {
|
|
|
599
636
|
}
|
|
600
637
|
|
|
601
638
|
if (state === 'phase1-done') {
|
|
602
|
-
runPhase2();
|
|
639
|
+
runPhase2(forceRemote);
|
|
603
640
|
} else {
|
|
604
|
-
runPhase1();
|
|
641
|
+
runPhase1(forceRemote);
|
|
605
642
|
}
|
|
606
643
|
}
|
|
607
644
|
|