cicy-desktop 2.1.250 → 2.1.251
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.
|
|
3
|
+
"version": "2.1.251",
|
|
4
4
|
"description": "CiCy - AI-powered operating system browser",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -139,10 +139,10 @@
|
|
|
139
139
|
"//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 着无害。",
|
|
140
140
|
"optionalDependencies": {
|
|
141
141
|
"electron": "41.0.3",
|
|
142
|
-
"cicy-code-darwin-x64": "2.3.
|
|
143
|
-
"cicy-code-darwin-arm64": "2.3.
|
|
144
|
-
"cicy-code-linux-x64": "2.3.
|
|
145
|
-
"cicy-code-linux-arm64": "2.3.
|
|
142
|
+
"cicy-code-darwin-x64": "2.3.234",
|
|
143
|
+
"cicy-code-darwin-arm64": "2.3.234",
|
|
144
|
+
"cicy-code-linux-x64": "2.3.234",
|
|
145
|
+
"cicy-code-linux-arm64": "2.3.234",
|
|
146
146
|
"cicy-code-windows-x64": "2.3.193",
|
|
147
147
|
"cicy-mihomo-darwin-x64": "1.10.4",
|
|
148
148
|
"cicy-mihomo-darwin-arm64": "1.10.4",
|
package/src/tools/hook-gemini.js
CHANGED
|
@@ -15,7 +15,7 @@ async function ensureGeminiWindow(win_id, accountIdx = 0) {
|
|
|
15
15
|
if (win_id) {
|
|
16
16
|
throw new Error(`Window ${win_id} not found`);
|
|
17
17
|
}
|
|
18
|
-
win = createWindow({ url: GEMINI_URL }, accountIdx, false);
|
|
18
|
+
win = createWindow({ url: GEMINI_URL, background: true }, accountIdx, false); // agent 驱动:后台开,不抢用户焦点
|
|
19
19
|
await new Promise((r) => setTimeout(r, 3000));
|
|
20
20
|
return win;
|
|
21
21
|
}
|
|
@@ -208,7 +208,10 @@ class TabManager {
|
|
|
208
208
|
if (opts.navigate && ex.url !== target) {
|
|
209
209
|
try { ex.view.webContents.loadURL(target); ex.url = target; } catch (e) {}
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
// activate:false(agent 后台开 tab)→ 命中已有 tab 也不切视图,绝不打断用户正看的 tab。
|
|
212
|
+
if (opts.activate !== false || this.activeId == null) this.activate(ex.id);
|
|
213
|
+
else this.pushState(); // 列表里仍要出现/更新这个 tab
|
|
214
|
+
return ex.id;
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
217
|
// Privilege gate: only the system profile (accountIdx 0) may get a Node-capable
|
|
@@ -282,7 +285,10 @@ class TabManager {
|
|
|
282
285
|
});
|
|
283
286
|
}
|
|
284
287
|
wc.loadURL(target);
|
|
285
|
-
|
|
288
|
+
// activate:false(agent/程序化后台开 tab)→ 新 tab 在后台加载,**不切走用户当前 tab**
|
|
289
|
+
// (BrowserView 不挂上也照常加载)。没有任何 active tab 时仍激活,否则窗口空白。
|
|
290
|
+
if (opts.activate !== false || this.activeId == null) this.activate(id);
|
|
291
|
+
else this.pushState(); // tab 条上要出现新 tab(非激活态)
|
|
286
292
|
return id;
|
|
287
293
|
}
|
|
288
294
|
|
|
@@ -384,7 +390,7 @@ function findManagerByTab(webContentsId) {
|
|
|
384
390
|
// button / electron_tab_open / the panel can add tabs to profile 0 too.
|
|
385
391
|
async function openTab(accountIdx, url, opts = {}) {
|
|
386
392
|
const m = ensureManager(accountIdx);
|
|
387
|
-
const id = m.addTab(url, { trusted: !!opts.trusted, home: !!opts.home, title: opts.title || "", navigate: !!opts.navigate, avatar: opts.avatar || "", team: !!opts.team, colorKey: opts.colorKey || "" });
|
|
393
|
+
const id = m.addTab(url, { trusted: !!opts.trusted, home: !!opts.home, title: opts.title || "", navigate: !!opts.navigate, avatar: opts.avatar || "", team: !!opts.team, colorKey: opts.colorKey || "", activate: opts.activate });
|
|
388
394
|
try { m.surfaceQuiet(); } catch (e) {}
|
|
389
395
|
// 记下这个团队 tab 的 webContentsId(打开 → set;关闭/销毁 → delete)。
|
|
390
396
|
try {
|
|
@@ -486,15 +492,16 @@ function registerTabBrowserTools(registerTool) {
|
|
|
486
492
|
|
|
487
493
|
registerTool(
|
|
488
494
|
"electron_tab_open",
|
|
489
|
-
"在某 profile 的标签窗口新开一个标签(窗口不在则先建)。打开=开 tab
|
|
495
|
+
"在某 profile 的标签窗口新开一个标签(窗口不在则先建)。打开=开 tab,不弹新窗口。**默认后台打开**:不切走用户正在看的 tab、不抢焦点(agent 干活不打扰用户);要立即展示给用户传 activate:true。trusted=true 给 cicy-code 等受信任页注入 electronRPC 桥。",
|
|
490
496
|
z.object({
|
|
491
497
|
accountIdx: z.number().describe("账户索引(profile)"),
|
|
492
498
|
url: z.string().optional().describe("网址;省略则起始页"),
|
|
493
499
|
trusted: z.boolean().optional().describe("受信任页面才注入桥;默认 false"),
|
|
500
|
+
activate: z.boolean().optional().describe("true=切到该标签并置前;默认 false(后台开,不打扰用户)"),
|
|
494
501
|
}),
|
|
495
|
-
async ({ accountIdx, url, trusted }) => {
|
|
502
|
+
async ({ accountIdx, url, trusted, activate }) => {
|
|
496
503
|
try {
|
|
497
|
-
const r = await openTab(accountIdx, url, { trusted: !!trusted });
|
|
504
|
+
const r = await openTab(accountIdx, url, { trusted: !!trusted, activate: activate === true });
|
|
498
505
|
return ok({ success: true, accountIdx, winId: r.winId, tabId: r.tabId, tabs: ensureManager(accountIdx).list() });
|
|
499
506
|
} catch (e) { return ok({ error: e.message }, true); }
|
|
500
507
|
},
|
|
@@ -134,17 +134,22 @@ function registerTools(registerTool) {
|
|
|
134
134
|
.optional()
|
|
135
135
|
.default(true)
|
|
136
136
|
.describe("是否复用现有窗口。true=复用(默认),false=创建新窗口"),
|
|
137
|
+
background: z
|
|
138
|
+
.boolean()
|
|
139
|
+
.optional()
|
|
140
|
+
.default(true)
|
|
141
|
+
.describe("后台打开(默认 true):窗口不夺焦点、不把 cicy-desktop 激活到用户当前应用之前 —— agent 干活不打扰用户。要弹到前台给用户看传 false。"),
|
|
137
142
|
options: z.object({}).optional().describe("Electron BrowserWindow options"),
|
|
138
143
|
}),
|
|
139
|
-
async ({ url, accountIdx, reuseWindow, options }) => {
|
|
144
|
+
async ({ url, accountIdx, reuseWindow, background, options }) => {
|
|
140
145
|
// Determine if we should create a new window
|
|
141
146
|
const forceNew = reuseWindow === false;
|
|
142
147
|
|
|
143
148
|
// Get existing windows count before creating
|
|
144
149
|
const existingCount = BrowserWindow.getAllWindows().length;
|
|
145
150
|
|
|
146
|
-
// Create or reuse window
|
|
147
|
-
const win = createWindow({ url, ...options }, accountIdx, forceNew);
|
|
151
|
+
// Create or reuse window (agent 默认后台开,不抢用户焦点)
|
|
152
|
+
const win = createWindow({ url, background: background !== false, ...options }, accountIdx, forceNew);
|
|
148
153
|
|
|
149
154
|
// Check if window was reused (count didn't change)
|
|
150
155
|
const newCount = BrowserWindow.getAllWindows().length;
|
|
@@ -250,8 +250,10 @@ function isTrustedUrl(url) {
|
|
|
250
250
|
// platform's own/system windows; callers that want the system slot pass 0
|
|
251
251
|
// explicitly (e.g. local-teams). Agents opening windows should use >0.
|
|
252
252
|
function createWindow(options = {}, accountIdx = 1, forceNew = false) {
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
// background:true(agent/程序化开窗)→ 窗口后台出现:不抢焦点、mac 上不激活 app、不把
|
|
254
|
+
// cicy-desktop 拉到用户正用的应用前面。用户主动点开的路径不传 → 行为不变(照常置前)。
|
|
255
|
+
const { width = 1200, height = 800, url, webPreferences = {}, x, y, background = false } = options;
|
|
256
|
+
console.log("[createWindow] url:", url, "isTrusted:", isTrustedUrl(url), "background:", background);
|
|
255
257
|
|
|
256
258
|
// Check if oneWindow mode is enabled - execute before coordinate logic
|
|
257
259
|
if (config.oneWindow && !forceNew) {
|
|
@@ -262,8 +264,10 @@ function createWindow(options = {}, accountIdx = 1, forceNew = false) {
|
|
|
262
264
|
`[WindowUtils] Single window mode enabled. Reusing existing window ${existingWin.id}`
|
|
263
265
|
);
|
|
264
266
|
|
|
265
|
-
if (
|
|
266
|
-
|
|
267
|
+
if (!background) {
|
|
268
|
+
if (existingWin.isMinimized()) existingWin.restore();
|
|
269
|
+
existingWin.focus();
|
|
270
|
+
}
|
|
267
271
|
|
|
268
272
|
if (url) {
|
|
269
273
|
const currentUrl = existingWin.webContents.getURL();
|
|
@@ -311,6 +315,8 @@ function createWindow(options = {}, accountIdx = 1, forceNew = false) {
|
|
|
311
315
|
height: winHeight,
|
|
312
316
|
x: posX,
|
|
313
317
|
y: posY,
|
|
318
|
+
// 后台开窗:先不显示,渲染好后 showInactive(可见但不夺焦点、不激活 app)。
|
|
319
|
+
show: !background,
|
|
314
320
|
icon: require("./app-icon").appIconPath(), // npx/unpackaged → set our own icon
|
|
315
321
|
// (Windows has no built .exe to embed it; default electron icon otherwise).
|
|
316
322
|
// Native menu bar collapses by default on win/linux; press Alt to
|
|
@@ -349,6 +355,15 @@ function createWindow(options = {}, accountIdx = 1, forceNew = false) {
|
|
|
349
355
|
// reliably readable back.
|
|
350
356
|
try { win.cicyAccountIdx = accountIdx; win.webContents.cicyAccountIdx = accountIdx; } catch (e) {}
|
|
351
357
|
|
|
358
|
+
// 后台开窗:渲染好再 showInactive(不夺焦点/不激活 app)。ready-to-show 偶发不触发
|
|
359
|
+
// (页面挂了等)→ 3s 兜底照样 showInactive,窗口绝不会永远隐身。
|
|
360
|
+
if (background) {
|
|
361
|
+
let shown = false;
|
|
362
|
+
const quiet = () => { if (shown || win.isDestroyed()) return; shown = true; try { win.showInactive(); } catch (e) {} };
|
|
363
|
+
try { win.once("ready-to-show", quiet); } catch (e) {}
|
|
364
|
+
setTimeout(quiet, 3000);
|
|
365
|
+
}
|
|
366
|
+
|
|
352
367
|
// 监听窗口状态变化并自动保存(基于URL)
|
|
353
368
|
watchWindowState(win, accountIdx);
|
|
354
369
|
|