cicy-desktop 2.1.305 → 2.1.307

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/.gitattributes ADDED
@@ -0,0 +1,4 @@
1
+ *.js text eol=lf
2
+ *.json text eol=lf
3
+ *.sh text eol=lf
4
+ *.yml text eol=lf
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cicy-desktop",
3
- "version": "2.1.305",
3
+ "version": "2.1.307",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -144,10 +144,10 @@
144
144
  "//optionalDependencies": "(2026-06 回调): mac/linux 改回 native cicy-code(:8008,colima 在 16G mac 上压垮内存)→ 重新内置 cicy-code-<plat> / cicy-mihomo-<plat>,localbin.fromBundle 零网络 seed(npm 仅作更新通道,带 npmmirror→npmjs 回退)。这些由 scripts/sync-runtime-deps.cjs 在 tag-push 时同步到最新版。npm 的 os/cpu 字段保证每个平台只装自己那份。Windows 仍走 docker(WSL :8009),它那份 cicy-code-windows 用不到但 bundle 着无害。",
145
145
  "optionalDependencies": {
146
146
  "electron": "41.0.3",
147
- "cicy-code-darwin-x64": "2.3.575",
148
- "cicy-code-darwin-arm64": "2.3.575",
149
- "cicy-code-linux-x64": "2.3.575",
150
- "cicy-code-linux-arm64": "2.3.575",
147
+ "cicy-code-darwin-x64": "2.3.578",
148
+ "cicy-code-darwin-arm64": "2.3.578",
149
+ "cicy-code-linux-x64": "2.3.578",
150
+ "cicy-code-linux-arm64": "2.3.578",
151
151
  "cicy-code-windows-x64": "2.3.193",
152
152
  "cicy-mihomo-darwin-x64": "1.10.4",
153
153
  "cicy-mihomo-darwin-arm64": "1.10.4",
@@ -90,12 +90,24 @@ async function ensureWslKernel({ emit } = {}) {
90
90
  // Run a bash command as root inside the distro. execFile (no host shell) → the
91
91
  // command string is passed verbatim to `bash -lc`, so only bash-level quoting
92
92
  // matters inside `cmd`.
93
+ // wsl.exe 连不上发行版的 VM(注册了、显示 Running,但 init 不可达):任何 `wsl -d` 立刻以
94
+ // 4294967295(-1)退出,stdout 是 UTF-16 的 Windows 套接字错误「由于连接方在一段时间后没有正确答复
95
+ // …连接尝试失败」。实测 `wsl --shutdown` 后恢复。据此标记,bootstrap 遇到就重置一次再重试。
96
+ function isWslVmUnreachable(err) {
97
+ if (!err) return false;
98
+ const code = err.code === 4294967295 || err.code === -1 || err.code === 0xffffffff;
99
+ let text = "";
100
+ try { const raw = err.stdout || ""; text = Buffer.isBuffer(raw) ? raw.toString("utf16le") : String(raw); } catch {}
101
+ try { text += Buffer.from(String(err.stdout || ""), "binary").toString("utf16le"); } catch {}
102
+ const msg = /连接尝试失败|connection attempt failed|没有正确答复|did not properly respond|0x80072746|0x8007274c/i.test(text + " " + (err.message || ""));
103
+ return code && msg || (code && /^Command failed: [^\n]*wsl[^\n]*\n?\s*$/.test(err.message || "") && !err.stderr);
104
+ }
93
105
  function wslRun(cmd, { timeout = 60000, distro = DISTRO } = {}) {
94
106
  return new Promise((resolve, reject) => {
95
107
  execFile(docker.wslExe(), ["-d", distro, "-u", "root", "--", "bash", "-lc", cmd],
96
108
  { timeout, windowsHide: true, maxBuffer: 1 << 26 },
97
109
  (err, stdout, stderr) => {
98
- if (err) { err.stdout = String(stdout || ""); err.stderr = String(stderr || ""); return reject(err); }
110
+ if (err) { err.stdout = String(stdout || ""); err.stderr = String(stderr || ""); err.wslVmUnreachable = isWslVmUnreachable(err); return reject(err); }
99
111
  resolve({ stdout: String(stdout), stderr: String(stderr) });
100
112
  });
101
113
  });
@@ -1297,7 +1309,16 @@ async function _bootstrap({ onProgress, port = 8008, container = "cicy-code-dock
1297
1309
  // 3) Docker Engine inside Ubuntu
1298
1310
  begin("install-docker-engine");
1299
1311
  if (!(await dockerInstalled())) {
1300
- try { await installDockerEngine({ emit }); } catch (e) { fail("docker_install_failed", e.message); emit({ phase: "install-docker", status: "error", message: `Docker 安装失败:${e.message}(点重试)${errTail(e)}` }); finish(false, "docker_install_failed"); return { ok: false, reason: "docker_install_failed" }; }
1312
+ try { await installDockerEngine({ emit }); } catch (e) {
1313
+ if (e && e.wslVmUnreachable) {
1314
+ // VM 半死:wsl.exe 连不上 init。重置 WSL(terminate + shutdown)后由下一轮自动重试。
1315
+ fail("wsl_vm_unreachable", e.message);
1316
+ emit({ phase: "install-docker", status: "running", message: "wsl.exe 连不上 WSL 虚拟机(半死状态),正在重置 WSL 后自动重试…" });
1317
+ try { await wslTerminate(); } catch {}
1318
+ try { await wslShutdown(); } catch {}
1319
+ finish(false, "wsl_vm_unreachable"); return { ok: false, reason: "wsl_vm_unreachable", message: "WSL 虚拟机无响应,已重置,稍后自动重试" };
1320
+ }
1321
+ fail("docker_install_failed", e.message); emit({ phase: "install-docker", status: "error", message: `Docker 安装失败:${e.message}(点重试)${errTail(e)}` }); finish(false, "docker_install_failed"); return { ok: false, reason: "docker_install_failed" }; }
1301
1322
  done();
1302
1323
  } else done(true);
1303
1324
 
@@ -1489,7 +1510,7 @@ async function update({ onProgress, container = "cicy-code-docker", port = 8008
1489
1510
  emit({ phase: "image", status: "running", message: latest ? t("docker.updating.toVersion", { v: latest }) : t("docker.updating.pulling") });
1490
1511
  // cp 结果出到 drawer(诊断:之前静默失败 → 回落镜像内旧脚本 → 又卡 2 分钟,看不出来)。
1491
1512
  try {
1492
- const b64 = fs.readFileSync(path.join(__dirname, "container-scripts", "cicy-code-update.sh")).toString("base64");
1513
+ const b64 = Buffer.from(fs.readFileSync(path.join(__dirname, "container-scripts", "cicy-code-update.sh"), "utf8").replace(/\r\n?/g, "\n"), "utf8").toString("base64"); // CI 的 Windows runner 会把 .sh 转成 CRLF → 容器里 shebang 变 /bin/bash\r 执行不了
1493
1514
  await wslRun(buildPushUpdateScriptCommand(b64, container), { timeout: 30000 });
1494
1515
  emit({ phase: "image", status: "running", message: t("docker.updating.scriptReady") });
1495
1516
  } catch (e) {
@@ -127,3 +127,15 @@ test("readContainerToken throttles after a failure so a wedged WSL is not hammer
127
127
  const w = read("src/sidecar/wsl-docker.js");
128
128
  assert.match(w, /if \(Date\.now\(\) - _tokenFailAt < 60000\) return "";/);
129
129
  });
130
+
131
+ test("an unreachable WSL VM (socket timeout from wsl.exe) resets WSL and retries instead of failing docker install", () => {
132
+ const w = read("src/sidecar/wsl-docker.js");
133
+ assert.match(w, /function isWslVmUnreachable\(err\)/);
134
+ assert.match(w, /err\.wslVmUnreachable = isWslVmUnreachable\(err\)/);
135
+ assert.match(w, /if \(e && e\.wslVmUnreachable\) \{[^]*await wslTerminate\(\)[^]*await wslShutdown\(\)[^]*reason: "wsl_vm_unreachable"/);
136
+ });
137
+
138
+ test("the container update script is pushed with LF endings even from a CRLF checkout", () => {
139
+ assert.match(read("src/sidecar/wsl-docker.js"), /cicy-code-update\.sh"\), "utf8"\)\.replace\(\/\\r\\n\?\/g, "\\n"\)/);
140
+ assert.match(read(".gitattributes"), /\*\.sh text eol=lf/);
141
+ });