@aiyiran/myclaw 1.0.32 → 1.0.34

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.
Files changed (3) hide show
  1. package/index.js +24 -19
  2. package/package.json +1 -1
  3. package/prepare.js +5 -78
package/index.js CHANGED
@@ -265,7 +265,10 @@ function runWsl2() {
265
265
 
266
266
  function runPrepare() {
267
267
  const prepare = require('./prepare');
268
- prepare.run();
268
+ prepare.run().catch((err) => {
269
+ console.error('[错误] ' + err.message);
270
+ process.exit(1);
271
+ });
269
272
  }
270
273
 
271
274
  // ============================================================================
@@ -300,8 +303,13 @@ echo OpenClaw 智能启动器
300
303
  echo ============================================
301
304
  echo.
302
305
 
303
- REM ---- Step 1: 检测 WSL 是否可用 ----
304
- echo [1/4] 检测 WSL 状态...
306
+ REM ---- Step 1: 自动更新 MyClaw ----
307
+ echo [1/5] 检查 MyClaw 更新...
308
+ call npm update -g @aiyiran/myclaw >nul 2>&1
309
+ echo [OK]
310
+
311
+ REM ---- Step 2: 检测 WSL 是否可用 ----
312
+ echo [2/5] 检测 WSL 状态...
305
313
  wsl --version >nul 2>&1
306
314
  if errorlevel 1 (
307
315
  echo.
@@ -320,8 +328,8 @@ if errorlevel 1 (
320
328
  )
321
329
  echo [OK] WSL 已安装
322
330
 
323
- REM ---- Step 2: 检测 OpenClaw 发行版 ----
324
- echo [2/4] 检测 OpenClaw Linux 环境...
331
+ REM ---- Step 3: 检测 OpenClaw 发行版 ----
332
+ echo [3/5] 检测 OpenClaw Linux 环境...
325
333
  wsl -l -q 2>nul | findstr /i "OpenClaw" >nul 2>&1
326
334
  if errorlevel 1 (
327
335
  echo.
@@ -337,40 +345,37 @@ if errorlevel 1 (
337
345
  )
338
346
  echo [OK] OpenClaw Linux 环境已就绪
339
347
 
340
- REM ---- Step 3: 检测 Gateway 是否已运行 ----
341
- echo [3/4] 检测 OpenClaw Gateway...
342
- curl -s -o nul -w "%%{http_code}" http://127.0.0.1:18789 2>nul | findstr "200 301 302" >nul 2>&1
348
+ REM ---- Step 4: myclaw open 打开浏览器(带 token) ----
349
+ echo [4/5] 打开浏览器(带 Token)...
350
+ call myclaw open
351
+ echo [OK]
352
+
353
+ REM ---- Step 5: 检测并启动 Gateway ----
354
+ echo [5/5] 检测 OpenClaw Gateway...
355
+ netstat -an | findstr "18789" | findstr "LISTENING" >nul 2>&1
343
356
  if not errorlevel 1 (
344
357
  echo [OK] Gateway 已在运行中
345
358
  echo.
346
- echo [4/4] 打开浏览器...
347
- start http://127.0.0.1:18789
348
- echo.
349
359
  echo ============================================
350
360
  echo OpenClaw 已在运行!浏览器已打开
351
- echo 关闭此窗口不影响服务
352
361
  echo ============================================
353
362
  echo.
354
- timeout /t 5
363
+ wsl -d OpenClaw
355
364
  exit /b
356
365
  )
357
- echo Gateway 未运行,准备启动...
358
366
 
359
- REM ---- Step 4: 启动 Gateway ----
360
- echo [4/4] 启动 OpenClaw Gateway...
367
+ echo Gateway 未运行,正在启动...
361
368
  echo.
362
369
  echo ============================================
363
370
  echo 正在启动 OpenClaw 服务...
364
- echo 启动后浏览器会自动打开
365
371
  echo 关闭此窗口将停止服务
366
372
  echo ============================================
367
373
  echo.
368
-
369
- start http://127.0.0.1:18789
370
374
  wsl -d OpenClaw -- openclaw gateway
371
375
  pause
372
376
  `;
373
377
 
378
+
374
379
  // 写入 bat 文件
375
380
  fs.writeFileSync(batPath, batContent, 'utf8');
376
381
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/prepare.js CHANGED
@@ -284,87 +284,14 @@ function runPatchStep(env) {
284
284
 
285
285
  function createDesktopLauncher() {
286
286
  log('Step 5', '生成桌面启动器...');
287
-
287
+ console.log('');
288
288
  try {
289
- // 直接调用 index.js 里的 bat 逻辑太耦合,这里独立实现
290
- const fs = require('fs');
291
- const myClawDir = path.join(process.env.LOCALAPPDATA || os.tmpdir(), 'myclaw');
292
- try { fs.mkdirSync(myClawDir, { recursive: true }); } catch {}
293
-
294
- const batPath = path.join(myClawDir, 'openclaw-launcher.bat');
295
- const desktopPath = path.join(os.homedir(), 'Desktop');
296
- const lnkPath = path.join(desktopPath, 'OpenClaw.lnk');
297
-
298
- const batContent = `@echo off
299
- chcp 65001 >nul 2>&1
300
- title OpenClaw
301
- color 0A
302
- echo.
303
- echo ============================================
304
- echo OpenClaw 智能启动器
305
- echo ============================================
306
- echo.
307
-
308
- echo [1/4] 检测 WSL...
309
- wsl --version >nul 2>&1
310
- if errorlevel 1 (
311
- echo [!] WSL 未安装,正在启动安装...
312
- call myclaw wsl2
313
- echo 请重启电脑后再次双击此图标
314
- pause
315
- exit /b
316
- )
317
- echo [OK]
318
-
319
- echo [2/4] 检测 OpenClaw 环境...
320
- wsl -l -q 2>nul | findstr /i "OpenClaw" >nul 2>&1
321
- if errorlevel 1 (
322
- echo [!] OpenClaw 环境未导入,正在安装...
323
- call myclaw wsl2
324
- echo 请再次双击此图标启动
325
- pause
326
- exit /b
327
- )
328
- echo [OK]
329
-
330
- echo [3/4] 检测 Gateway...
331
- curl -s -o nul -w "%%%%{http_code}" http://127.0.0.1:18789 2>nul | findstr "200 301 302" >nul 2>&1
332
- if not errorlevel 1 (
333
- echo [OK] 已在运行
334
- echo [4/4] 打开浏览器...
335
- start http://127.0.0.1:18789
336
- timeout /t 3
337
- exit /b
338
- )
339
-
340
- echo [4/4] 启动 OpenClaw...
341
- start http://127.0.0.1:18789
342
- wsl -d OpenClaw -- openclaw gateway
343
- pause
344
- `;
345
-
346
- fs.writeFileSync(batPath, batContent, 'utf8');
347
-
348
- // 创建带图标的快捷方式
349
- const psCmd = [
350
- "$ws = New-Object -ComObject WScript.Shell",
351
- "$sc = $ws.CreateShortcut('" + lnkPath.replace(/\\/g, '\\\\') + "')",
352
- "$sc.TargetPath = '" + batPath.replace(/\\/g, '\\\\') + "'",
353
- "$sc.WorkingDirectory = '" + myClawDir.replace(/\\/g, '\\\\') + "'",
354
- "$sc.WindowStyle = 1",
355
- "$sc.IconLocation = '%SystemRoot%\\System32\\shell32.dll,176'",
356
- "$sc.Description = 'OpenClaw'",
357
- "$sc.Save()",
358
- ].join('; ');
359
-
360
- execSync('powershell -NoProfile -Command "' + psCmd.replace(/"/g, '\\"') + '"', {
361
- stdio: 'pipe',
362
- });
363
-
364
- logOK('桌面快捷方式已创建: OpenClaw.lnk');
289
+ // 直接调用 myclaw bat,它是桌面启动器的唯一入口
290
+ execSync('node "' + path.join(__dirname, 'index.js') + '" bat', { stdio: 'inherit' });
365
291
  return true;
366
292
  } catch (err) {
367
- logWarn('桌面快捷方式创建失败: ' + err.message);
293
+ logWarn('桌面启动器创建失败');
294
+ console.log(' 你可以手动运行: ' + C.y + 'myclaw bat' + C.nc);
368
295
  return false;
369
296
  }
370
297
  }