cicy-desktop 2.1.157 → 2.1.159
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 +1 -1
- package/src/backends/sidecar-ipc.js +18 -9
- package/src/main.js +5 -0
- package/src/sidecar/cicy-code.js +7 -16
package/package.json
CHANGED
|
@@ -39,7 +39,13 @@ const PORT = Number(process.env.CICY_CODE_PORT || 8008);
|
|
|
39
39
|
// Desktop is missing the card installs it first (installer downloads to the
|
|
40
40
|
// user's Desktop). The whole cicy home is persisted to a named volume so the
|
|
41
41
|
// entire container state survives recreation (主人: "把整个 docker 挂出来").
|
|
42
|
-
|
|
42
|
+
// macOS is DOCKER-ONLY (主人指令: native 退役 — native 跑在宿主机无隔离会动用户数据).
|
|
43
|
+
// So on darwin the docker cicy-code IS the PRIMARY on :8008 (the slot the rest of the app
|
|
44
|
+
// already talks to; native no longer spawns there — see src/sidecar/cicy-code.js). The
|
|
45
|
+
// existing daemon/reconcile/ensureDockerTeam/appOpts machinery below just retargets to 8008
|
|
46
|
+
// — independent cloud team key, named-volume isolation, auto-start all come for free.
|
|
47
|
+
// win32 keeps the Docker-版 as an optional 2nd instance on :8009 alongside native :8008 (next).
|
|
48
|
+
const APP_PORT = Number(process.env.CICY_DOCKER_APP_PORT || (process.platform === "darwin" ? 8008 : 8009));
|
|
43
49
|
// container / volume 名都带上 port —— 一台机可以跑多个 docker(不同端口),各自
|
|
44
50
|
// 独立容器 + 独立 volume(数据隔离)+ 独立云端 team。docker-teams.json 也按 volume
|
|
45
51
|
// (含 port)区分。
|
|
@@ -77,6 +83,9 @@ const DOCKER_TEAMS_FILE = path.join(os.homedir(), "cicy-ai", "db", "docker-teams
|
|
|
77
83
|
function readDockerTeams() { try { return JSON.parse(fs.readFileSync(DOCKER_TEAMS_FILE, "utf8")) || {}; } catch { return {}; } }
|
|
78
84
|
function writeDockerTeams(obj) { try { fs.mkdirSync(path.dirname(DOCKER_TEAMS_FILE), { recursive: true }); fs.writeFileSync(DOCKER_TEAMS_FILE, JSON.stringify(obj, null, 2)); } catch {} }
|
|
79
85
|
let dockerTeamReg = null; // { teamId, title, apiKey } — 缓存,appOpts 读它
|
|
86
|
+
// 主实例(APP_PORT===PORT,即 darwin docker-only 的 :8008)就是「本地团队」,不该叫
|
|
87
|
+
// 「Docker 团队」(那是第二实例 :8009 用的)。docker-only 下它是唯一/主团队。
|
|
88
|
+
const APP_TEAM_TITLE = (APP_PORT === PORT) ? "本地团队" : "Docker 团队";
|
|
80
89
|
|
|
81
90
|
// 确保这个 docker(按 volume)有独立云端 team;返回 { teamId, title, apiKey } 或 null。
|
|
82
91
|
async function ensureDockerTeam() {
|
|
@@ -85,21 +94,21 @@ async function ensureDockerTeam() {
|
|
|
85
94
|
const store = readDockerTeams();
|
|
86
95
|
let rec = store[APP_VOLUME];
|
|
87
96
|
if (!rec || !rec.teamId) {
|
|
88
|
-
const created = await cc.createTeam({ title:
|
|
97
|
+
const created = await cc.createTeam({ title: APP_TEAM_TITLE, kind: "cloud" });
|
|
89
98
|
if (!created || !created.ok) return null;
|
|
90
|
-
// 强制把云端标题设成
|
|
91
|
-
// 回退成 owner/device
|
|
92
|
-
try { await cc.renameTeam(created.teamId,
|
|
93
|
-
store[APP_VOLUME] = { teamId: created.teamId, title:
|
|
99
|
+
// 强制把云端标题设成 APP_TEAM_TITLE:POST /api/teams 常忽略我们传的 title、
|
|
100
|
+
// 回退成 owner/device 名,卡片就显示错了。PATCH 一下盖掉。
|
|
101
|
+
try { await cc.renameTeam(created.teamId, APP_TEAM_TITLE); } catch {}
|
|
102
|
+
store[APP_VOLUME] = { teamId: created.teamId, title: APP_TEAM_TITLE, titleForced: true };
|
|
94
103
|
writeDockerTeams(store);
|
|
95
|
-
dockerTeamReg = { teamId: created.teamId, title:
|
|
104
|
+
dockerTeamReg = { teamId: created.teamId, title: APP_TEAM_TITLE, apiKey: created.apiKey };
|
|
96
105
|
return dockerTeamReg;
|
|
97
106
|
}
|
|
98
107
|
// 既有 team:若还没强制过标题(老数据/上面那个 bug 建的),补一次 PATCH 成 "Docker
|
|
99
108
|
// 团队",然后打上 titleForced 标记 —— 只补这一次,之后用户自己改名不会被覆盖。
|
|
100
109
|
if (!rec.titleForced) {
|
|
101
|
-
try { await cc.renameTeam(rec.teamId,
|
|
102
|
-
rec.title =
|
|
110
|
+
try { await cc.renameTeam(rec.teamId, APP_TEAM_TITLE); } catch {}
|
|
111
|
+
rec.title = APP_TEAM_TITLE; rec.titleForced = true;
|
|
103
112
|
store[APP_VOLUME] = rec; writeDockerTeams(store);
|
|
104
113
|
}
|
|
105
114
|
const apiKey = await cc.getTeamApiKey(rec.teamId);
|
package/src/main.js
CHANGED
|
@@ -817,6 +817,11 @@ X-GNOME-Autostart-enabled=true
|
|
|
817
817
|
let _sidecarWatchdogTimer = null;
|
|
818
818
|
function startSidecarWatchdog({ intervalMs = 30_000 } = {}) {
|
|
819
819
|
if (_sidecarWatchdogTimer) return;
|
|
820
|
+
// macOS is docker-only: cicy-code lives in the Colima container on :8008, kept alive by
|
|
821
|
+
// the docker daemon's reconcile (sidecar-ipc) + the container's --restart unless-stopped.
|
|
822
|
+
// The native restart this watchdog does is a no-op on darwin (start() returns null), so it
|
|
823
|
+
// would just spam "sidecar unreachable → restart" every tick. Skip it entirely on darwin.
|
|
824
|
+
if (process.platform === "darwin") return;
|
|
820
825
|
let consecutiveFailures = 0;
|
|
821
826
|
let restartInFlight = false;
|
|
822
827
|
|
package/src/sidecar/cicy-code.js
CHANGED
|
@@ -100,22 +100,13 @@ async function startFromRuntime({ logPath, port }) {
|
|
|
100
100
|
async function start({ logPath, port = DEFAULT_PORT, force = false, version = null } = {}) {
|
|
101
101
|
if (child && !force) return child;
|
|
102
102
|
|
|
103
|
-
// macOS: DOCKER-ONLY (主人指令: native 退役). The native
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
if (process.platform === "darwin") {
|
|
111
|
-
try {
|
|
112
|
-
const docker = require("./docker");
|
|
113
|
-
const r = await docker.start({ port });
|
|
114
|
-
if (r) console.log(`[cicy-code-sidecar] docker cicy-code on :${port} (${r.adopted ? "adopted" : r.id || "started"})`);
|
|
115
|
-
else console.warn("[cicy-code-sidecar] docker not ready — homepage docker card will guide install");
|
|
116
|
-
} catch (e) { console.warn(`[cicy-code-sidecar] docker start failed: ${e.message}`); }
|
|
117
|
-
return null; // no native child on mac
|
|
118
|
-
}
|
|
103
|
+
// macOS: DOCKER-ONLY (主人指令: native 退役). The native daemon runs cicy-code directly
|
|
104
|
+
// on the host with full access to the user's real files — no isolation. On darwin we no
|
|
105
|
+
// longer spawn it; the docker cicy-code (Colima container, named-volume isolated) IS the
|
|
106
|
+
// primary on :8008, brought up + kept alive by the docker daemon in src/backends/
|
|
107
|
+
// sidecar-ipc.js (APP_PORT=8008 on darwin). probeExisting()/watchdog still work — they
|
|
108
|
+
// just observe the container's :8008. Returning null here = "no native child".
|
|
109
|
+
if (process.platform === "darwin") return null;
|
|
119
110
|
|
|
120
111
|
if (!force && await probeExisting(port)) {
|
|
121
112
|
console.log(`[cicy-code-sidecar] existing instance on :${port}, reusing`);
|