cicy-desktop 2.1.170 → 2.1.171

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cicy-desktop",
3
- "version": "2.1.170",
3
+ "version": "2.1.171",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -125,6 +125,21 @@ function register({ sidecarLogPath } = {}) {
125
125
  log.info("[docker-daemon] installed but :8009 down → auto-starting (bootstrap idempotent)");
126
126
  try { await appDocker.bootstrap(await appOpts()); } catch (e) { log.warn(`[docker-daemon] auto-start failed: ${e.message}`); }
127
127
  await refreshDockerStatus();
128
+ } else if (s.running) {
129
+ // 自愈:容器在跑,但很可能是「首次启动时还没登录 / key 还没就位就建好了」的没 key 容器
130
+ // —— runContainer 见到 :8009 健康就直接 adopt 不重建,key 永远进不去(Windows 实测的
131
+ // 'llm key 没拿到')。这里:已能拿到 key + 容器里确实没 key → 带 key 重建一次(volume
132
+ // 数据保留)。mac/win 同一套(hasGatewayKey 两个 docker 模块都实现了)。
133
+ try {
134
+ const opts = await appOpts();
135
+ if (opts.env && opts.env.CICY_AI_GATEWAY_LLM_API_KEY && appDocker.hasGatewayKey
136
+ && !(await appDocker.hasGatewayKey(APP_CONTAINER))) {
137
+ log.info("[docker-daemon] 容器在跑但没网关 key → 带 key 重建(数据保留)");
138
+ await appDocker.recreate(opts);
139
+ try { await registerAppTeam(); } catch {}
140
+ await refreshDockerStatus();
141
+ }
142
+ } catch (e) { log.warn(`[docker-daemon] key self-heal failed: ${e.message}`); }
128
143
  }
129
144
  } finally { _dockerDaemonBusy = false; }
130
145
  return _dockerStatusCache;
@@ -446,7 +446,13 @@ async function upgrade({ onProgress, port = 8009, container = "cicy-code-docker-
446
446
  return await _bootstrap({ onProgress, port, container, volume, env });
447
447
  }
448
448
 
449
+ // 容器里有没有注入网关 key(reconcile 自愈用):printenv 看 CICY_AI_GATEWAY_LLM_API_KEY。
450
+ async function hasGatewayKey(container = "cicy-code-docker-8009") {
451
+ try { const { stdout } = await dk(`exec ${container} printenv CICY_AI_GATEWAY_LLM_API_KEY`, { timeout: 8000 }); return /sk-/.test(String(stdout || "")); }
452
+ catch { return false; }
453
+ }
454
+
449
455
  module.exports = {
450
456
  bootstrap, status, restart, stop, dockerRestart, recreate, update, upgrade, runContainer, readContainerToken,
451
- vmExists, colimaInstalled, dockerCliInstalled, engineUp, imagePresent, probeHealth,
457
+ vmExists, colimaInstalled, dockerCliInstalled, engineUp, imagePresent, probeHealth, hasGatewayKey,
452
458
  };
@@ -727,7 +727,13 @@ async function upgrade({ onProgress, port = 8009, container = "cicy-code-docker"
727
727
  return await _bootstrap({ onProgress, port, container, volume, env });
728
728
  }
729
729
 
730
+ // 容器里有没有注入网关 key(reconcile 自愈用):printenv 看 CICY_AI_GATEWAY_LLM_API_KEY。
731
+ async function hasGatewayKey(container = "cicy-code-docker") {
732
+ try { const { stdout } = await wslRun(`docker exec ${container} printenv CICY_AI_GATEWAY_LLM_API_KEY`, { timeout: 8000 }); return /sk-/.test(String(stdout || "")); }
733
+ catch { return false; }
734
+ }
735
+
730
736
  module.exports = {
731
737
  bootstrap, status, restart, stop, dockerRestart, recreate, update, upgrade, runContainer, readContainerToken,
732
- distroInstalled, dockerInstalled, dockerEngineUp, imagePresent, probeHealth, wslRun,
738
+ distroInstalled, dockerInstalled, dockerEngineUp, imagePresent, probeHealth, wslRun, hasGatewayKey,
733
739
  };