dsh-browser-cdp 1.12.0 → 1.12.1
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/CHANGELOG.md +10 -0
- package/dsh-plugin.json +1 -1
- package/lib/client.js +1 -1
- package/lib/index.js +102 -32
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 1.12.1 (2026-11-15)
|
|
2
|
+
|
|
3
|
+
**修掉面板 × 在 ego-cli 通道上点了没反应。**
|
|
4
|
+
|
|
5
|
+
- **根因不是权限,是硬闸**:`/api/bcdp/close` 的 CLI 分支调 `closeCliTab`,而它第一行是 `if (channel.tabbitInventory !== true) return 'channel-cannot-close'`——ego-cli 通道恒被拒(实测 409)。但运行时**确实提供** `browser.closeTab(targetId)`(实测 5 个标签 → 3 个,新标签页与百度都真关掉了),所以错的是这道闸,不是通道能力。
|
|
6
|
+
- **ego-cli 走 panel-action heredoc 关闭**:新增 `buildEgoCloseTabScript`(`src/cast/panel-actions.ts`),与 size/navigate/switch 同一套 `taskSpaces.useOrCreate` + `browser.*` + sentinel 协议;`PanelActionRunner` 增加 `closeTab`,`closeCliTab` 在 `egoRuntime === true` 时先试它,只有两者都不具备的通道才答 `channel-cannot-close`。
|
|
7
|
+
- **共用同一个 runner 实例**:把 `makePanelActions(ctx, cfg)` 提到 `initCastServer` 之前存成局部变量,关闭与尺寸/导航/切页串行在**同一把 ego 锁**上,不再各建一个。
|
|
8
|
+
- **两道守卫**:`last-tab`(只剩一个标签时拒绝,避免把面板吊死在空清单)、`tab-not-found`(陈旧行不抛异常,让客户端能安静丢行)。关闭后**回读 inventory 验证**,真没了才答 `closed`。
|
|
9
|
+
- 新增 10 条契约测试(`tests/ego-close-contract.test.ts`):走 facade 不走裸 CDP、拒绝最后标签、陈旧行降级、sentinel 分支齐全、ego 分支先于拒绝分支、runner 唯一构造点。
|
|
10
|
+
|
|
1
11
|
## 1.12.0 (2026-11-15)
|
|
2
12
|
|
|
3
13
|
**设置分节排版:连接目标置顶,评审(JEV / Laya)组可抽屉折叠。**
|
package/dsh-plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -326,7 +326,7 @@ function shouldShowGen1SettingsGear(hasConfigForms, hasOpenSettingsDocument) {
|
|
|
326
326
|
*
|
|
327
327
|
* Keep in sync with package.json — `node scripts/bump.mjs <version>` writes both.
|
|
328
328
|
*/
|
|
329
|
-
const CLIENT_BUILD = "1.12.
|
|
329
|
+
const CLIENT_BUILD = "1.12.1";
|
|
330
330
|
|
|
331
331
|
//#endregion
|
|
332
332
|
//#region src/client/index.ts
|
package/lib/index.js
CHANGED
|
@@ -2169,7 +2169,7 @@ function focusIdFrom(value) {
|
|
|
2169
2169
|
*
|
|
2170
2170
|
* Keep in sync with package.json — `node scripts/bump.mjs <version>` writes both.
|
|
2171
2171
|
*/
|
|
2172
|
-
const CLIENT_BUILD = "1.12.
|
|
2172
|
+
const CLIENT_BUILD = "1.12.1";
|
|
2173
2173
|
|
|
2174
2174
|
//#endregion
|
|
2175
2175
|
//#region src/cast-server.ts
|
|
@@ -3938,6 +3938,26 @@ function buildEgoSwitchTabScript(spaceJson, body) {
|
|
|
3938
3938
|
return `const __bcdpTarget = ${js$1(pickTargetId(body))}\ntry {\n if (__bcdpTarget === '') throw new Error('targetId required')\n await taskSpaces.useOrCreate(${spaceJson})\n const __tabs = await browser.listTabs()\n const __hit = __tabs.find((t) => t.targetId === __bcdpTarget)\n if (!__hit) throw new Error('tab not found: ' + __bcdpTarget)\n if (__hit.active !== true) await browser.switchTab({ targetId: __bcdpTarget })\n console.log(${js$1(PANEL_SENTINEL)} + JSON.stringify({ ok: true, targetId: __bcdpTarget, url: __hit.url || '', title: __hit.title || '' }))\n} catch (__bcdpErr) {\n console.log(${js$1(PANEL_SENTINEL)} + JSON.stringify({ ok: false, error: String((__bcdpErr && __bcdpErr.message) || __bcdpErr) }))\n}\n`;
|
|
3939
3939
|
}
|
|
3940
3940
|
/**
|
|
3941
|
+
* close-tab heredoc — the user clicked × in the panel.
|
|
3942
|
+
*
|
|
3943
|
+
* An `ego-cli` link injects no CDP websocket, so `/api/bcdp/close` used to
|
|
3944
|
+
* answer 409 `channel-cannot-close` for it: the × looked dead. The runtime does
|
|
3945
|
+
* expose `browser.closeTab(targetId)` (measured: two tabs closed, inventory went
|
|
3946
|
+
* 5 → 3), so the same operation runs here as a heredoc on the channel real tools
|
|
3947
|
+
* use.
|
|
3948
|
+
*
|
|
3949
|
+
* Two guards, both learned the hard way:
|
|
3950
|
+
* - **Last tab is refused.** Closing the only page leaves the space with nothing
|
|
3951
|
+
* to show, and the panel renders a strip no tool can recover from without
|
|
3952
|
+
* opening a new tab first.
|
|
3953
|
+
* - **Only close what is really there.** A stale panel row (tab already gone from
|
|
3954
|
+
* another window) answers `tab-not-found` instead of throwing, so the client can
|
|
3955
|
+
* drop the row rather than retry forever.
|
|
3956
|
+
*/
|
|
3957
|
+
function buildEgoCloseTabScript(spaceJson, body) {
|
|
3958
|
+
return `const __bcdpTarget = ${js$1(pickTargetId(body))}\ntry {\n if (__bcdpTarget === '') throw new Error('targetId required')\n await taskSpaces.useOrCreate(${spaceJson})\n const __tabs = await browser.listTabs()\n const __hit = __tabs.find((t) => t.targetId === __bcdpTarget)\n if (!__hit) {\n console.log(${js$1(PANEL_SENTINEL)} + JSON.stringify({ ok: false, reason: 'tab-not-found', targetId: __bcdpTarget }))\n } else if (__tabs.length <= 1) {\n console.log(${js$1(PANEL_SENTINEL)} + JSON.stringify({ ok: false, reason: 'last-tab', targetId: __bcdpTarget }))\n } else {\n await browser.closeTab(__bcdpTarget)\n const __left = await browser.listTabs()\n const __gone = !__left.some((t) => t.targetId === __bcdpTarget)\n console.log(${js$1(PANEL_SENTINEL)} + JSON.stringify({ ok: __gone, closed: __gone, reason: __gone ? '' : 'still-open', targetId: __bcdpTarget, remaining: __left.length }))\n }\n} catch (__bcdpErr) {\n console.log(${js$1(PANEL_SENTINEL)} + JSON.stringify({ ok: false, error: String((__bcdpErr && __bcdpErr.message) || __bcdpErr) }))\n}\n`;
|
|
3959
|
+
}
|
|
3960
|
+
/**
|
|
3941
3961
|
* navigate heredoc — panel refresh / manual URL. Uses the runtime facades
|
|
3942
3962
|
* (`page.reload` / `page.goto`) rather than raw CDP so the CLI keeps its own
|
|
3943
3963
|
* load-state semantics and navigation guards.
|
|
@@ -8014,6 +8034,14 @@ async function runRefreshSync(plan, deps) {
|
|
|
8014
8034
|
//#endregion
|
|
8015
8035
|
//#region src/runtime/close-plan.ts
|
|
8016
8036
|
const CLOSE_SCRATCH_TASK = "dsh-panel-shot";
|
|
8037
|
+
function planCloseTasks(tasks, tabId, lastTaskName) {
|
|
8038
|
+
const ordered = [
|
|
8039
|
+
tasks.find((task) => task.ownedTabIds.includes(tabId))?.taskName ?? "",
|
|
8040
|
+
lastTaskName,
|
|
8041
|
+
CLOSE_SCRATCH_TASK
|
|
8042
|
+
].map((name$1) => name$1.trim()).filter((name$1) => name$1 !== "");
|
|
8043
|
+
return [...new Set(ordered)];
|
|
8044
|
+
}
|
|
8017
8045
|
|
|
8018
8046
|
//#endregion
|
|
8019
8047
|
//#region src/cast/run-queue.ts
|
|
@@ -11501,7 +11529,8 @@ function makePanelActions(ctx, cfg) {
|
|
|
11501
11529
|
return {
|
|
11502
11530
|
windowSize: (body) => run((spaceJson) => buildEgoWindowSizeScript(spaceJson, body)),
|
|
11503
11531
|
navigate: (body) => run((spaceJson) => buildEgoNavigateScript(spaceJson, body)),
|
|
11504
|
-
switchTab: (body) => run((spaceJson) => buildEgoSwitchTabScript(spaceJson, body))
|
|
11532
|
+
switchTab: (body) => run((spaceJson) => buildEgoSwitchTabScript(spaceJson, body)),
|
|
11533
|
+
closeTab: (body) => run((spaceJson) => buildEgoCloseTabScript(spaceJson, body))
|
|
11505
11534
|
};
|
|
11506
11535
|
}
|
|
11507
11536
|
/**
|
|
@@ -11792,6 +11821,10 @@ let _tabbitWindowId = 0;
|
|
|
11792
11821
|
const TABBIT_PANEL_TASK = "dsh-panel";
|
|
11793
11822
|
/** Upper bound on pages one task may own; each extra page slows every call. */
|
|
11794
11823
|
const TABBIT_MAX_OWNED_PAGES = 2;
|
|
11824
|
+
/** How long the close guard may stay armed. A tabbit snippet that never resolves
|
|
11825
|
+
* must not stall the frame poller forever; 15 s is comfortably past the measured
|
|
11826
|
+
* fast path (~560 ms) and the claim-release path (~47 ms + close). */
|
|
11827
|
+
const CLOSE_INFLIGHT_MAX_MS = 15e3;
|
|
11795
11828
|
/** Last close attempt, echoed in the stats snapshot: the panel's × is verified by
|
|
11796
11829
|
* INVENTORY, not by the receipt status (page.close() kills the receipt). */
|
|
11797
11830
|
let lastClose = null;
|
|
@@ -13411,12 +13444,27 @@ function apply(ctx, config = {}) {
|
|
|
13411
13444
|
});
|
|
13412
13445
|
ctx.inject?.(["webServer"], (wctx) => {
|
|
13413
13446
|
try {
|
|
13414
|
-
|
|
13447
|
+
const panelActions = makePanelActions(ctx, cfg);
|
|
13448
|
+
initCastServer(wctx, cfg, bridge, ffmpegManager, () => openAgentWindow(ctx, cfg), (opts) => importLoginCookies(opts, { subprocess: ctx.subprocess }), cliPoller, panelActions, () => tabbitSpaceRows(), async (targetId) => {
|
|
13415
13449
|
const eff = resolveEffectiveLink(cfg.links, cfg.activeTargetId);
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13450
|
+
const __ch = runtimeOfLink(eff?.link)?.channel;
|
|
13451
|
+
if (__ch?.tabbitInventory !== true) {
|
|
13452
|
+
if (__ch?.egoRuntime === true) {
|
|
13453
|
+
const out = await panelActions.closeTab({ targetId });
|
|
13454
|
+
if (out.ok === true) return {
|
|
13455
|
+
ok: true,
|
|
13456
|
+
reason: "closed"
|
|
13457
|
+
};
|
|
13458
|
+
return {
|
|
13459
|
+
ok: false,
|
|
13460
|
+
reason: typeof out.reason === "string" && out.reason !== "" ? out.reason : "close-failed"
|
|
13461
|
+
};
|
|
13462
|
+
}
|
|
13463
|
+
return {
|
|
13464
|
+
ok: false,
|
|
13465
|
+
reason: "channel-cannot-close"
|
|
13466
|
+
};
|
|
13467
|
+
}
|
|
13420
13468
|
const cli = resolveTabbitCli((eff?.link)?.cliPath);
|
|
13421
13469
|
if (!cli.found) return {
|
|
13422
13470
|
ok: false,
|
|
@@ -13427,33 +13475,51 @@ function apply(ctx, config = {}) {
|
|
|
13427
13475
|
ok: false,
|
|
13428
13476
|
reason: "bad-target"
|
|
13429
13477
|
};
|
|
13478
|
+
const invNow = tabbitSpaceRows();
|
|
13479
|
+
if (invNow.tabs.length <= 1 && invNow.complete) return {
|
|
13480
|
+
ok: false,
|
|
13481
|
+
reason: "last-tab"
|
|
13482
|
+
};
|
|
13430
13483
|
const startedAt = Date.now();
|
|
13431
13484
|
const withDeadline = async (work, ms, fallback) => {
|
|
13432
13485
|
return Promise.race([work, new Promise((resolve$1) => setTimeout(() => resolve$1(fallback), ms))]);
|
|
13433
13486
|
};
|
|
13434
13487
|
_closeInFlight = true;
|
|
13488
|
+
let released = false;
|
|
13489
|
+
const release = () => {
|
|
13490
|
+
if (released) return;
|
|
13491
|
+
released = true;
|
|
13492
|
+
_closeInFlight = false;
|
|
13493
|
+
};
|
|
13494
|
+
const watchdog = setTimeout(release, CLOSE_INFLIGHT_MAX_MS);
|
|
13435
13495
|
let state$1 = "";
|
|
13436
13496
|
let closer = CLOSE_SCRATCH_TASK;
|
|
13497
|
+
let owner = "";
|
|
13437
13498
|
try {
|
|
13438
13499
|
const inv = await withDeadline(tabbitListTabs(ctx.subprocess, cli.cliPath, TABBIT_PANEL_TASK), 3e3, null);
|
|
13439
13500
|
state$1 = String(inv?.tabs.find((t) => t.tabId === tabId)?.state ?? "");
|
|
13440
|
-
if (state$1 === "owned") {
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
} else if (state$1 === "claimed") {
|
|
13447
|
-
let owner = _tabbitOwnerCache.owners.get(tabId);
|
|
13448
|
-
if (owner === void 0) {
|
|
13501
|
+
if (state$1 === "owned" || state$1 === "claimed") {
|
|
13502
|
+
let tasks = _tabbitOwnerCache.at !== 0 && _tabbitOwnerCache.owners.has(tabId) ? [{
|
|
13503
|
+
taskName: String(_tabbitOwnerCache.owners.get(tabId) ?? ""),
|
|
13504
|
+
ownedTabIds: [tabId]
|
|
13505
|
+
}] : [];
|
|
13506
|
+
if (tasks.length === 0) {
|
|
13449
13507
|
const diag = await withDeadline(tabbitDiagnose(ctx.subprocess, cli.cliPath), 3e3, null);
|
|
13450
|
-
if (diag)
|
|
13508
|
+
if (diag) tasks = parseTabbitTasks(diag.raw);
|
|
13509
|
+
}
|
|
13510
|
+
owner = planCloseTasks(tasks, tabId, _tabbitLastTaskName)[0] ?? "";
|
|
13511
|
+
if (state$1 === "owned" && owner !== "") {
|
|
13512
|
+
await withDeadline(tabbitFinishTask(ctx.subprocess, cli.cliPath, owner, false), 3e3, void 0);
|
|
13513
|
+
forgetTabbitTaskState();
|
|
13514
|
+
if (_tabbitLastTaskName === owner) _tabbitLastTaskName = "";
|
|
13515
|
+
_tabbitOwnerCache = {
|
|
13516
|
+
at: 0,
|
|
13517
|
+
owners: /* @__PURE__ */ new Map()
|
|
13518
|
+
};
|
|
13451
13519
|
}
|
|
13452
|
-
if (owner !==
|
|
13520
|
+
if (owner !== "") closer = owner;
|
|
13453
13521
|
}
|
|
13454
|
-
}
|
|
13455
|
-
_closeInFlight = false;
|
|
13456
|
-
}
|
|
13522
|
+
} catch {}
|
|
13457
13523
|
runTabbitSnippet$1(ctx.subprocess, "await page.close().catch(() => {}); return { closed: page.isClosed() };", {
|
|
13458
13524
|
cliPath: cli.cliPath,
|
|
13459
13525
|
taskName: closer,
|
|
@@ -13480,17 +13546,21 @@ function apply(ctx, config = {}) {
|
|
|
13480
13546
|
_tabbitTabCache.total = _tabbitTabCache.tabs.length;
|
|
13481
13547
|
broadcastCliSpaces(tabbitSpaceRows().tabs);
|
|
13482
13548
|
} else ctx.logger?.info?.(`dsh-browser-cdp: close tab ${tabId} via ${closer} did not close (${fired.receipt.status})`);
|
|
13483
|
-
}).catch(() =>
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13549
|
+
}).catch(() => {
|
|
13550
|
+
lastClose = {
|
|
13551
|
+
tabId,
|
|
13552
|
+
task: closer,
|
|
13553
|
+
state: state$1 || "unknown",
|
|
13554
|
+
status: "error",
|
|
13555
|
+
closedByReceipt: false,
|
|
13556
|
+
stillThere: true,
|
|
13557
|
+
ms: Date.now() - startedAt,
|
|
13558
|
+
at: Date.now()
|
|
13559
|
+
};
|
|
13560
|
+
}).finally(() => {
|
|
13561
|
+
clearTimeout(watchdog);
|
|
13562
|
+
release();
|
|
13563
|
+
});
|
|
13494
13564
|
return {
|
|
13495
13565
|
ok: true,
|
|
13496
13566
|
reason: "dispatched"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "dsh-browser-cdp: visible agent browser for DSH — drives the vendored ego-compatible Chromium over CDP, and can also attach to a running Chrome/Edge/Brave or route through egolite, Tabbit and Lightpanda backends. 35 structured bcdp_* tools; only bcdp_status stays resident by default (lazy injection, −91.9% schema per turn for non-browser sessions). Realtime watch panel with direct click/scroll/IME input, element picks quoted into the composer, human-verification notices; non-CDP channels sync frames by 3s polling. Web shell: floating watch ball without dsh-better-sidebar, sidebar tab with it. Headless/TUI hosts: tools-only. [DSH 0.1.0-rc.2 ~ 0.2.2-rc.1: declarative settings via Config .volatile() fields on 0.1.7+; imperative installSection / module-level registration + describe/mutate bridge on 0.1.0 ~ 0.1.5 (experimental, pending farm). Client peers stay optional so gen-1 hosts without dsh-client-store still load; for a production install on the current line use the 0.17.x line]",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"@deepseek-ai/dsh-session": "^0.2.1-rc.3",
|
|
125
125
|
"@deepseek-ai/dsh-skill": "^0.2.1-rc.3",
|
|
126
126
|
"@deepseek-ai/dsh-system-prompt": "^0.2.1-rc.3",
|
|
127
|
-
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.1
|
|
127
|
+
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.1 <=0.2.2-rc.3",
|
|
128
128
|
"@deepseek-ai/dsh-user-approval": "^0.2.1-rc.3",
|
|
129
129
|
"@deepseek-ai/dsh-working-directory": "^0.2.1-rc.3",
|
|
130
130
|
"@types/node": "^22.20.1",
|