@aiyiran/myclaw 1.0.15 → 1.0.16

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 (2) hide show
  1. package/package.json +1 -1
  2. package/wsl2.js +12 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/wsl2.js CHANGED
@@ -41,10 +41,20 @@ const C = isWindows
41
41
  // ============================================================================
42
42
 
43
43
  function launchElevatedPS(script) {
44
- const b64 = Buffer.from(script, 'utf16le').toString('base64');
44
+ const fs = require('fs');
45
+ const path = require('path');
46
+
47
+ // 把脚本写到临时文件(避免 Windows 命令行长度限制)
48
+ const tmpDir = process.env.LOCALAPPDATA
49
+ ? path.join(process.env.LOCALAPPDATA, 'myclaw')
50
+ : path.join(os.tmpdir(), 'myclaw');
51
+ try { fs.mkdirSync(tmpDir, { recursive: true }); } catch {}
52
+ const scriptPath = path.join(tmpDir, 'wsl2_installer.ps1');
53
+ fs.writeFileSync(scriptPath, script, 'utf8');
54
+
45
55
  try {
46
56
  execSync(
47
- `powershell -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -EncodedCommand ${b64}' -Verb RunAs"`,
57
+ `powershell -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File \\"${scriptPath}\\"' -Verb RunAs"`,
48
58
  { stdio: 'inherit' }
49
59
  );
50
60
  return true;