@aiyiran/myclaw 1.0.125 → 1.0.127
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/package.json +1 -1
- package/patch-manifest.json +1 -1
- package/wsl2.js +81 -64
package/package.json
CHANGED
package/patch-manifest.json
CHANGED
package/wsl2.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* MyClaw WSL2 一键安装器
|
|
6
6
|
* ============================================================================
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* 采用"固定流程 + 状态标记"机制,避免使用容易出错的环境嗅探(wsl --status)。
|
|
9
9
|
* 标记文件:~/.myclaw_wsl_state
|
|
10
10
|
*
|
|
11
|
-
* Phase 1:
|
|
12
|
-
* Phase 2:
|
|
11
|
+
* Phase 1: 启用底层功能 + 安装 WSL + 下载 Linux 镜像 → 需要重启
|
|
12
|
+
* Phase 2: 导入已下载的 Linux 环境 → 自动启动 Gateway(极快)
|
|
13
13
|
* ============================================================================
|
|
14
14
|
*/
|
|
15
15
|
|
|
@@ -34,6 +34,7 @@ const C = isWindows
|
|
|
34
34
|
: { r: '\x1b[31m', g: '\x1b[32m', y: '\x1b[33m', b: '\x1b[34m', nc: '\x1b[0m' };
|
|
35
35
|
|
|
36
36
|
const STATE_FILE = path.join(os.homedir(), '.myclaw_wsl_state');
|
|
37
|
+
const MARKER_PATH_PS = STATE_FILE.replace(/\\/g, '\\\\');
|
|
37
38
|
|
|
38
39
|
// ============================================================================
|
|
39
40
|
// 工具函数
|
|
@@ -51,7 +52,6 @@ function setState(state) {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
function launchElevatedPS(script) {
|
|
54
|
-
// 把脚本写到临时文件(避免 Windows 命令行长度限制)
|
|
55
55
|
const tmpDir = process.env.LOCALAPPDATA
|
|
56
56
|
? path.join(process.env.LOCALAPPDATA, 'myclaw')
|
|
57
57
|
: path.join(os.tmpdir(), 'myclaw');
|
|
@@ -62,7 +62,6 @@ function launchElevatedPS(script) {
|
|
|
62
62
|
const BOM = '\uFEFF';
|
|
63
63
|
fs.writeFileSync(scriptPath, BOM + script, 'utf8');
|
|
64
64
|
|
|
65
|
-
// 用 -NoExit 确保即使脚本出错窗口也不会关闭
|
|
66
65
|
const escaped = scriptPath.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
67
66
|
const cmd = `powershell -Command "Start-Process powershell -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-NoExit','-File','${escaped}') -Verb RunAs"`;
|
|
68
67
|
|
|
@@ -128,17 +127,15 @@ if ($resolved) {
|
|
|
128
127
|
Write-Host ' 将改为从网络下载...'
|
|
129
128
|
}
|
|
130
129
|
Write-Host ''
|
|
131
|
-
Write-Host '
|
|
132
|
-
Write-Host ' [
|
|
133
|
-
Write-Host '
|
|
134
|
-
Write-Host '
|
|
135
|
-
Write-Host ' ⚠️ 如果你觉得进度条卡住不动了,请在键盘上按一下【回车键】即可解冻!'
|
|
136
|
-
Write-Host ' ============================================================='
|
|
130
|
+
Write-Host ' -------------------------------------------------------------'
|
|
131
|
+
Write-Host ' [提示] 下载中请勿点击窗口内部(会导致卡死)。'
|
|
132
|
+
Write-Host ' [恢复] 若进度条长时间不动,请按一下 [回车键] 即可恢复。'
|
|
133
|
+
Write-Host ' -------------------------------------------------------------'
|
|
137
134
|
try {
|
|
138
|
-
Start-BitsTransfer -Source '${cdnUrl}' -Destination ${destVar} -Description '下载
|
|
135
|
+
Start-BitsTransfer -Source '${cdnUrl}' -Destination ${destVar} -Description '下载 ${desc}' -DisplayName 'OpenClaw'
|
|
139
136
|
Write-Host ' 下载完成!'
|
|
140
137
|
} catch {
|
|
141
|
-
Write-Host ' [失败] 下载失败,请检查网络后重试
|
|
138
|
+
Write-Host ' [失败] 下载失败,请检查网络后重试'
|
|
142
139
|
throw '下载失败'
|
|
143
140
|
}
|
|
144
141
|
}
|
|
@@ -146,16 +143,17 @@ if ($resolved) {
|
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
// ============================================================================
|
|
149
|
-
// Phase 1: 启用功能 + 安装 WSL
|
|
146
|
+
// Phase 1: 启用功能 + 安装 WSL + 下载 Linux 镜像(全部在重启前完成)
|
|
150
147
|
// ============================================================================
|
|
151
148
|
|
|
152
149
|
function runPhase1() {
|
|
153
150
|
console.log('');
|
|
154
|
-
console.log('[当前进度] WSL 功能
|
|
155
|
-
console.log(' WSL 组件
|
|
156
|
-
console.log(' Linux
|
|
151
|
+
console.log('[当前进度] WSL 功能 ' + C.y + '[安装/覆盖]' + C.nc);
|
|
152
|
+
console.log(' WSL 组件 ' + C.y + '[安装/重置]' + C.nc);
|
|
153
|
+
console.log(' Linux 镜像 ' + C.y + '[待下载]' + C.nc);
|
|
154
|
+
console.log(' Linux 环境 ' + C.r + '[未安装]' + C.nc);
|
|
157
155
|
console.log('');
|
|
158
|
-
console.log('阶段 1/2:
|
|
156
|
+
console.log('阶段 1/2: 配置系统组件 + 下载全部安装素材');
|
|
159
157
|
console.log(' 完成后需要 ' + C.y + '重启电脑' + C.nc);
|
|
160
158
|
console.log('');
|
|
161
159
|
console.log('[' + C.y + '注意' + C.nc + '] 请在 UAC 弹窗中点击【是】');
|
|
@@ -169,6 +167,14 @@ function runPhase1() {
|
|
|
169
167
|
'wsl_full.msi'
|
|
170
168
|
);
|
|
171
169
|
|
|
170
|
+
const askTar = makeAskLocalOrCDN(
|
|
171
|
+
'拖拽 tar 包或回车下载',
|
|
172
|
+
'$tarPath',
|
|
173
|
+
WSL_CDN.rootfs,
|
|
174
|
+
'Linux 环境包 (openclaw-rootfs.tar)',
|
|
175
|
+
'openclaw-rootfs.tar'
|
|
176
|
+
);
|
|
177
|
+
|
|
172
178
|
const ps = `
|
|
173
179
|
$ErrorActionPreference = 'Continue'
|
|
174
180
|
$Host.UI.RawUI.WindowTitle = 'MyClaw WSL2 Installer - Phase 1'
|
|
@@ -176,14 +182,16 @@ try {
|
|
|
176
182
|
Write-Host ''
|
|
177
183
|
Write-Host '========================================'
|
|
178
184
|
Write-Host ' MyClaw WSL2 安装 - 阶段 1/2'
|
|
185
|
+
Write-Host ' 配置系统 + 下载全部安装素材'
|
|
179
186
|
Write-Host '========================================'
|
|
180
187
|
Write-Host ''
|
|
181
188
|
|
|
182
|
-
$dir = "$env:LOCALAPPDATA
|
|
189
|
+
$dir = "$env:LOCALAPPDATA\\\\myclaw"
|
|
183
190
|
New-Item -ItemType Directory -Force -Path $dir | Out-Null
|
|
184
|
-
$msi = "$dir
|
|
191
|
+
$msi = "$dir\\\\wsl_full.msi"
|
|
192
|
+
$tarPath = "$dir\\\\openclaw-rootfs.tar"
|
|
185
193
|
|
|
186
|
-
Write-Host '[1/
|
|
194
|
+
Write-Host '[1/5] 启用 Windows Subsystem for Linux...'
|
|
187
195
|
try {
|
|
188
196
|
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart | Out-Null
|
|
189
197
|
Write-Host ' [OK]'
|
|
@@ -192,7 +200,7 @@ try {
|
|
|
192
200
|
}
|
|
193
201
|
Write-Host ''
|
|
194
202
|
|
|
195
|
-
Write-Host '[2/
|
|
203
|
+
Write-Host '[2/5] 启用虚拟机平台...'
|
|
196
204
|
try {
|
|
197
205
|
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart | Out-Null
|
|
198
206
|
Write-Host ' [OK]'
|
|
@@ -201,14 +209,13 @@ try {
|
|
|
201
209
|
}
|
|
202
210
|
Write-Host ''
|
|
203
211
|
|
|
204
|
-
Write-Host '[3/
|
|
205
|
-
# 移除文件以保证不做本地缓存
|
|
212
|
+
Write-Host '[3/5] 获取 WSL 安装包...'
|
|
206
213
|
if (Test-Path $msi) { Remove-Item $msi -Force }
|
|
207
214
|
|
|
208
215
|
${askMsi}
|
|
209
216
|
|
|
210
217
|
Write-Host ''
|
|
211
|
-
Write-Host '[4/
|
|
218
|
+
Write-Host '[4/5] 强制覆盖安装 WSL...'
|
|
212
219
|
try {
|
|
213
220
|
Start-Process msiexec.exe -ArgumentList @('/i', $msi, '/quiet', '/norestart') -Wait -NoNewWindow
|
|
214
221
|
if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne 3010) {
|
|
@@ -221,20 +228,27 @@ try {
|
|
|
221
228
|
throw 'MSI 安装失败'
|
|
222
229
|
}
|
|
223
230
|
|
|
224
|
-
#
|
|
231
|
+
# MSI 装完立即删除
|
|
225
232
|
if (Test-Path $msi) { Remove-Item $msi -Force }
|
|
233
|
+
Write-Host ''
|
|
226
234
|
|
|
227
|
-
|
|
228
|
-
|
|
235
|
+
Write-Host '[5/5] 下载 Linux 环境镜像...'
|
|
236
|
+
Write-Host ' (此文件较大,下载完成后会保留到重启后使用)'
|
|
237
|
+
if (Test-Path $tarPath) { Remove-Item $tarPath -Force }
|
|
238
|
+
|
|
239
|
+
${askTar}
|
|
240
|
+
|
|
241
|
+
# 写入状态标记(使用普通用户路径)
|
|
242
|
+
$markerPath = "${MARKER_PATH_PS}"
|
|
229
243
|
Out-File -FilePath "$markerPath" -InputObject "phase1-done" -Encoding utf8 -Force
|
|
230
244
|
|
|
231
245
|
Write-Host ''
|
|
232
246
|
Write-Host '========================================'
|
|
233
|
-
Write-Host ' 阶段 1/2 完成!'
|
|
247
|
+
Write-Host ' 阶段 1/2 完成! 所有文件已准备就绪!'
|
|
234
248
|
Write-Host ''
|
|
235
249
|
Write-Host ' >>> 请立即 [重启电脑] <<<'
|
|
236
250
|
Write-Host ''
|
|
237
|
-
Write-Host '
|
|
251
|
+
Write-Host ' 重启后请点击桌面上的 [龙虾图标] 继续安装'
|
|
238
252
|
Write-Host '========================================'
|
|
239
253
|
|
|
240
254
|
} catch {
|
|
@@ -253,33 +267,26 @@ Write-Host '========================================'
|
|
|
253
267
|
if (launchElevatedPS(ps)) {
|
|
254
268
|
console.log('[' + C.g + '已启动' + C.nc + '] 请查看新弹出的蓝色窗口');
|
|
255
269
|
console.log('');
|
|
256
|
-
console.log('执行完请 ' + C.y + '重启电脑' + C.nc + '
|
|
270
|
+
console.log('执行完请 ' + C.y + '重启电脑' + C.nc + ',然后点击桌面上的 ' + C.y + '龙虾图标' + C.nc + ' 继续安装');
|
|
257
271
|
console.log('');
|
|
258
272
|
}
|
|
259
273
|
}
|
|
260
274
|
|
|
261
275
|
// ============================================================================
|
|
262
|
-
// Phase 2:
|
|
276
|
+
// Phase 2: 导入已下载的 Linux 环境(重启后,纯本地操作,极快)
|
|
263
277
|
// ============================================================================
|
|
264
278
|
|
|
265
279
|
function runPhase2() {
|
|
266
280
|
console.log('');
|
|
267
|
-
console.log('[当前进度] WSL 功能
|
|
268
|
-
console.log(' WSL 组件
|
|
269
|
-
console.log(' Linux
|
|
281
|
+
console.log('[当前进度] WSL 功能 ' + C.g + '[已就绪]' + C.nc);
|
|
282
|
+
console.log(' WSL 组件 ' + C.g + '[已就绪]' + C.nc);
|
|
283
|
+
console.log(' Linux 镜像 ' + C.g + '[已下载]' + C.nc);
|
|
284
|
+
console.log(' Linux 环境 ' + C.y + '[待导入]' + C.nc);
|
|
270
285
|
console.log('');
|
|
271
|
-
console.log('即将导入预制 Linux
|
|
286
|
+
console.log('即将导入预制 Linux 环境(纯本地操作,很快)...');
|
|
272
287
|
console.log('[' + C.y + '注意' + C.nc + '] 请在 UAC 弹窗中点击【是】');
|
|
273
288
|
console.log('');
|
|
274
289
|
|
|
275
|
-
const askTar = makeAskLocalOrCDN(
|
|
276
|
-
'拖拽 tar 包或回车下载',
|
|
277
|
-
'$tarPath',
|
|
278
|
-
WSL_CDN.rootfs,
|
|
279
|
-
'Linux 环境包 (openclaw-rootfs.tar)',
|
|
280
|
-
'openclaw-rootfs.tar'
|
|
281
|
-
);
|
|
282
|
-
|
|
283
290
|
const ps = `
|
|
284
291
|
$ErrorActionPreference = 'Continue'
|
|
285
292
|
$Host.UI.RawUI.WindowTitle = 'MyClaw WSL2 Installer - Phase 2'
|
|
@@ -291,27 +298,37 @@ Write-Host ' 导入预制 Linux 环境'
|
|
|
291
298
|
Write-Host '========================================'
|
|
292
299
|
Write-Host ''
|
|
293
300
|
|
|
294
|
-
$dir = "$env:LOCALAPPDATA
|
|
301
|
+
$dir = "$env:LOCALAPPDATA\\\\myclaw"
|
|
295
302
|
New-Item -ItemType Directory -Force -Path $dir | Out-Null
|
|
296
|
-
$tarPath = "$dir
|
|
303
|
+
$tarPath = "$dir\\\\openclaw-rootfs.tar"
|
|
304
|
+
$distroName = 'OpenClaw'
|
|
305
|
+
$installDir = "$dir\\\\OpenClaw"
|
|
306
|
+
$installed = $false
|
|
297
307
|
|
|
298
|
-
Write-Host '[1/
|
|
308
|
+
Write-Host '[1/4] 设置 WSL2 为默认版本...'
|
|
299
309
|
try { wsl --set-default-version 2 2>$null } catch {}
|
|
300
310
|
Write-Host ' [OK]'
|
|
301
311
|
Write-Host ''
|
|
302
312
|
|
|
303
|
-
Write-Host '[2/
|
|
304
|
-
$
|
|
305
|
-
$
|
|
306
|
-
$
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
${
|
|
312
|
-
|
|
313
|
-
|
|
313
|
+
Write-Host '[2/4] 检查 Linux 镜像文件...'
|
|
314
|
+
if (Test-Path $tarPath) {
|
|
315
|
+
$size = (Get-Item $tarPath).Length / 1MB
|
|
316
|
+
Write-Host " 找到本地镜像 ($([math]::Round($size, 1)) MB)"
|
|
317
|
+
Write-Host ' [OK]'
|
|
318
|
+
} else {
|
|
319
|
+
Write-Host ' [警告] 未找到已下载的镜像文件,需要重新获取...'
|
|
320
|
+
Write-Host ''
|
|
321
|
+
${makeAskLocalOrCDN(
|
|
322
|
+
'拖拽 tar 包或回车下载',
|
|
323
|
+
'$tarPath',
|
|
324
|
+
WSL_CDN.rootfs,
|
|
325
|
+
'Linux 环境包 (openclaw-rootfs.tar)',
|
|
326
|
+
'openclaw-rootfs.tar'
|
|
327
|
+
)}
|
|
328
|
+
}
|
|
329
|
+
Write-Host ''
|
|
314
330
|
|
|
331
|
+
Write-Host '[3/4] 导入 Linux 环境 (可能需要几分钟)...'
|
|
315
332
|
Write-Host ' 清理旧版本...'
|
|
316
333
|
try { wsl --unregister $distroName 2>$null } catch {}
|
|
317
334
|
Write-Host ' [OK]'
|
|
@@ -330,10 +347,10 @@ try {
|
|
|
330
347
|
}
|
|
331
348
|
Write-Host ''
|
|
332
349
|
|
|
333
|
-
# 导入完毕清理
|
|
350
|
+
# 导入完毕清理 tar 文件
|
|
334
351
|
if (Test-Path $tarPath) { Remove-Item $tarPath -Force }
|
|
335
352
|
|
|
336
|
-
Write-Host '[
|
|
353
|
+
Write-Host '[4/4] 验证安装结果...'
|
|
337
354
|
try {
|
|
338
355
|
$result = wsl -l -v 2>&1 | Out-String
|
|
339
356
|
Write-Host $result
|
|
@@ -348,7 +365,7 @@ if ($installed) {
|
|
|
348
365
|
Write-Host '========================================'
|
|
349
366
|
Write-Host ''
|
|
350
367
|
|
|
351
|
-
$markerPath = "${
|
|
368
|
+
$markerPath = "${MARKER_PATH_PS}"
|
|
352
369
|
Out-File -FilePath "$markerPath" -InputObject "phase2-done" -Encoding utf8 -Force
|
|
353
370
|
|
|
354
371
|
Write-Host '[镜像信息]'
|
|
@@ -362,7 +379,7 @@ if ($installed) {
|
|
|
362
379
|
|
|
363
380
|
wsl -d $distroName -- myclaw launch
|
|
364
381
|
} else {
|
|
365
|
-
Write-Host ' [失败]
|
|
382
|
+
Write-Host ' [失败] 请截图此窗口并联系老师'
|
|
366
383
|
Write-Host '========================================'
|
|
367
384
|
}
|
|
368
385
|
|
|
@@ -397,7 +414,7 @@ function run() {
|
|
|
397
414
|
process.exit(0);
|
|
398
415
|
}
|
|
399
416
|
|
|
400
|
-
//
|
|
417
|
+
// 隐藏的高级玩家后门
|
|
401
418
|
if (process.argv.includes('--force-phase1')) {
|
|
402
419
|
setState('needs-features');
|
|
403
420
|
}
|
|
@@ -423,7 +440,7 @@ function run() {
|
|
|
423
440
|
console.log('(运行 wsl -l -v 查看详情)');
|
|
424
441
|
}
|
|
425
442
|
console.log('');
|
|
426
|
-
console.log('
|
|
443
|
+
console.log('点击桌面上的 ' + C.y + '龙虾图标' + C.nc + ' 即可启动。');
|
|
427
444
|
console.log('');
|
|
428
445
|
|
|
429
446
|
const readline = require('readline');
|