cicy-desktop 2.1.61 → 2.1.62

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.61",
3
+ "version": "2.1.62",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -50,11 +50,17 @@ function register({ sidecarLogPath } = {}) {
50
50
  onProgress: (ev) => { try { e.sender.send("docker:bootstrap-progress", ev); } catch {} },
51
51
  });
52
52
  // Healthy local stack → make sure it shows up as a team ("本地团队就加
53
- // 上去了"). addTeam dedups by host:port, so re-runs are no-ops.
53
+ // 上去了"). addTeam dedups by host:port, so re-runs are no-ops. The
54
+ // api_token must be the CONTAINER's own (volume global.json) — the
55
+ // host's token is a different credential and fails verify.
54
56
  if (result && result.ok) {
55
57
  try {
56
58
  const lt = require("./local-teams");
57
- await lt.addTeam({ base_url: `http://127.0.0.1:${PORT}`, name: "本地团队" });
59
+ const tok = await docker.readContainerToken(PORT);
60
+ await lt.addTeam({
61
+ base_url: `http://127.0.0.1:${PORT}`, name: "本地团队",
62
+ ...(tok ? { api_token: tok } : {}),
63
+ });
58
64
  } catch { /* best-effort — the stack itself is up */ }
59
65
  }
60
66
  return result;
@@ -189,6 +189,20 @@ async function ensureDownloaded(url, dest, mirror, { emit, phase, label } = {})
189
189
  });
190
190
  }
191
191
 
192
+ // The container's cicy-code mints its own api_token in its volume-persisted
193
+ // global.json — the HOST's global.json token is a different credential and
194
+ // won't verify. Read the real one out of whatever container publishes :port
195
+ // (works for adopted legacy-named containers too).
196
+ async function readContainerToken(port = 8008) {
197
+ try {
198
+ const { stdout } = await run(["ps", "--filter", `publish=${port}`, "--format", "{{.Names}}"]);
199
+ const name = stdout.trim().split("\n")[0];
200
+ if (!name) return "";
201
+ const r = await run(["exec", name, "cat", "/home/cicy/cicy-ai/global.json"], { timeout: 10000 });
202
+ return (JSON.parse(r.stdout).api_token || "");
203
+ } catch { return ""; }
204
+ }
205
+
192
206
  // HTTP /health probe of the container on :port.
193
207
  function probeHealth(port = 8008, timeoutMs = 2500) {
194
208
  return new Promise((resolve) => {
@@ -358,4 +372,4 @@ async function bootstrap({ onProgress, port = 8008 } = {}) {
358
372
  return { ok: healthy, container: CONTAINER };
359
373
  }
360
374
 
361
- module.exports = { start, stop, checkStatus, loadImage, imagePresent, dockerOk, installDocker, bootstrap, probeHealth };
375
+ module.exports = { start, stop, checkStatus, loadImage, imagePresent, dockerOk, installDocker, bootstrap, probeHealth, readContainerToken };