dsh-browser-cdp 1.14.6 → 1.14.8

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 CHANGED
@@ -1,3 +1,27 @@
1
+ ## 1.14.8 (2026-11-22)
2
+
3
+ **面板路由 base 化(上游 #100 同构,修法沿用):反向代理子路径部署下 `/api/bcdp/*` 不再打到代理根。**
4
+
5
+ 反向审计确认的第四个平行面。client 内 27 处根绝对路径 `/api/bcdp/...`(18 个路由常量 + 6 处散装 fetch + 3 处 EventSource)在 DSH 被挂在反向代理前缀(如 `/app/dsh/`)下时全部指向代理根——上游 #100 已实证并修复。
6
+
7
+ - **修复**:client 顶部加 `bcdpRouteBase`/`bcdpRoute`/`fetchBcdp`(沿用上游已验证形态):读部署页 `<base href>`,经 `new URL(href, document.baseURI)` 取 pathname 作前缀;**无 `<base>` 时回退 `''`**——桌面根路径部署行为逐字节不变,子路径部署自动生效。全部路由常量值包 `bcdpRoute(...)`,散装 fetch 改 `fetchBcdp(...)`,`EventSource('/api/bcdp/stream')` 改 `EventSource(bcdpRoute(...))`。
8
+ - **契约测试**:client-render-contract 套件新增 route base 用例——bcdpRouteBase 存在(base href + document.baseURI 回退)、**无裸 `fetch('/api/bcdp` / 裸 `= '/api/bcdp` 残留**、SSE 走 bcdpRoute。
9
+ - **实施注记**:批量替换在多行 fetch(URL 后跟 `, {init}`)处产生孤立括号——tsc 语法错 25 处当场暴露,两类定向修复(孤立 init、多余右括号)后归零;typecheck 是这类批量改形的真实门禁。
10
+
11
+ 门禁:`npm run typecheck` 干净(修复后);`npm test` **1344 passed / 13 skipped**(+1 route base 契约用例);`npm run build` 后 lib/client.js 含 bcdpRouteBase ×2。
12
+
13
+ ## 1.14.7 (2026-11-22)
14
+
15
+ **观察窗帧解码预换(上游 #82/#81 同构,预防性):`img.src` 直换的解码空白窗口收口。**
16
+
17
+ 反向审计确认的第三个平行面。两处实时帧 flush(浮动观察窗 + 侧栏控制器)此前直接 `img.src = dataUrl`——换帧瞬间旧位图被丢弃、新帧解码期间出现空白窗口,即上游在有头 macOS(M1/M5)实测的面板黑闪(他们以 canvas 合成修复)。我们的 flush 已有 rAF 合帧(一展示一解码,频次已降),但单次直换的空白窗口仍在。
18
+
19
+ - **修复**:两处 flush 改为先经 detached `Image` + `decode()` 预解码新帧,成功后才换 `liveImg.src`——旧画面保留到新位图就绪;`decode()` 不可用或失败时降级为原直换(不劣于从前)。解码期间新到帧保持 `pendingLiveFrame` 语义(apply 只清自己那一帧),最新帧由下一次 rAF 呈现,不丢帧。
20
+ - **诚实声明**:黑闪是视觉缺陷,本地无 DSH 宿主可自动目验——验收 = 构建 + 契约测试 + 所有者目验三段承担;修复取上游同面板架构的实证结论,归类预防性。
21
+ - **契约测试**:新增 `tests/client-render-contract.test.ts`——两处 flush 均须走 `probe.decode().then(apply, apply)`、降级路径存在、`apply` 内换帧仍在。
22
+
23
+ 门禁:`npm run typecheck` 干净;`npm test` **1343 passed / 13 skipped**(+1 契约用例);`npm run build` 后 lib/client.js 含 decode ×2。
24
+
1
25
  ## 1.14.6 (2026-11-22)
2
26
 
3
27
  **JS 弹窗可见性(上游 #104 同构):卡住的步骤从裸超时变成自带「dialog 类型 + 页面 message + 处置指引」的诊断。**
package/dsh-plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://dsh.community/schemas/dsh-plugin-0.15.json",
3
3
  "id": "dsh-browser-cdp",
4
4
  "name": "dsh-browser-cdp",
5
- "version": "1.14.6",
5
+ "version": "1.14.8",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
package/lib/client.js CHANGED
@@ -330,6 +330,22 @@ const CLIENT_BUILD = "1.12.2";
330
330
 
331
331
  //#endregion
332
332
  //#region src/client/index.ts
333
+ const bcdpRouteBase = (function() {
334
+ try {
335
+ const base = document.querySelector("base[href]");
336
+ if (!base) return "";
337
+ const path = new URL(base.getAttribute("href") || "./", document.baseURI).pathname.replace(/\/+$/, "");
338
+ return path === "/" ? "" : path;
339
+ } catch (e) {
340
+ return "";
341
+ }
342
+ })();
343
+ const bcdpRoute = function(path) {
344
+ return bcdpRouteBase + path;
345
+ };
346
+ const fetchBcdp = function(path, init) {
347
+ return fetch(bcdpRoute(path), init);
348
+ };
333
349
  var React = require("react");
334
350
  var runtimeClient = null;
335
351
  var createSnapshotStore = null;
@@ -687,16 +703,16 @@ function linkFlushable(link) {
687
703
  var kind = link && link.kind || "";
688
704
  return kind !== "ego-cli" && kind !== "tabbit-cli" && kind !== "lightpanda";
689
705
  }
690
- const SPACES_ROUTE = "/api/bcdp/spaces";
691
- const TRACKING_ROUTE = "/api/bcdp/tracking";
692
- const SWITCH_TAB_ROUTE = "/api/bcdp/switch-tab";
693
- const EGO_CLOSE_ROUTE = "/api/bcdp/close";
694
- const WATCH_START_ROUTE = "/api/bcdp/watch/start";
695
- const WATCH_SWITCH_ROUTE = "/api/bcdp/watch/switch";
696
- const WATCH_STOP_ROUTE = "/api/bcdp/watch/stop";
697
- const WATCH_STATUS_ROUTE = "/api/bcdp/watch/status";
698
- const VIDEO_ROUTE = "/api/bcdp/video";
699
- const CLI_FRAME_ROUTE = "/api/bcdp/cli-frame";
706
+ const SPACES_ROUTE = bcdpRoute("/api/bcdp/spaces");
707
+ const TRACKING_ROUTE = bcdpRoute("/api/bcdp/tracking");
708
+ const SWITCH_TAB_ROUTE = bcdpRoute("/api/bcdp/switch-tab");
709
+ const EGO_CLOSE_ROUTE = bcdpRoute("/api/bcdp/close");
710
+ const WATCH_START_ROUTE = bcdpRoute("/api/bcdp/watch/start");
711
+ const WATCH_SWITCH_ROUTE = bcdpRoute("/api/bcdp/watch/switch");
712
+ const WATCH_STOP_ROUTE = bcdpRoute("/api/bcdp/watch/stop");
713
+ const WATCH_STATUS_ROUTE = bcdpRoute("/api/bcdp/watch/status");
714
+ const VIDEO_ROUTE = bcdpRoute("/api/bcdp/video");
715
+ const CLI_FRAME_ROUTE = bcdpRoute("/api/bcdp/cli-frame");
700
716
  const CLI_FRAME_TARGET_ID = "__cli_frame__";
701
717
  function postJson(path, body) {
702
718
  return fetch(path, {
@@ -2931,16 +2947,16 @@ function mountFloatingWatch(ctx) {
2931
2947
  const captchaEl = panel.querySelector("#dsh-ego-captcha");
2932
2948
  const captchaKindEl = panel.querySelector("#dsh-ego-captcha-kind");
2933
2949
  const captchaHintEl = panel.querySelector("#dsh-ego-captcha-hint");
2934
- const FLUSH_ROUTE$1 = "/api/bcdp/flush";
2935
- const SYNC_ROUTE = "/api/bcdp/sync";
2936
- const CAPTURE_ROUTE = "/api/bcdp/capture";
2950
+ const FLUSH_ROUTE$1 = bcdpRoute("/api/bcdp/flush");
2951
+ const SYNC_ROUTE = bcdpRoute("/api/bcdp/sync");
2952
+ const CAPTURE_ROUTE = bcdpRoute("/api/bcdp/capture");
2937
2953
  const captureTab = (targetId) => fetch(CAPTURE_ROUTE, {
2938
2954
  method: "POST",
2939
2955
  headers: { "content-type": "application/json" },
2940
2956
  cache: "no-store",
2941
2957
  body: JSON.stringify({ targetId })
2942
2958
  }).catch(() => null);
2943
- fetch("/api/bcdp/hello", {
2959
+ fetchBcdp("/api/bcdp/hello", {
2944
2960
  method: "POST",
2945
2961
  headers: { "content-type": "application/json" },
2946
2962
  cache: "no-store",
@@ -3163,7 +3179,7 @@ function mountFloatingWatch(ctx) {
3163
3179
  watchStopTimer = window.setTimeout(stop, 1500);
3164
3180
  }
3165
3181
  };
3166
- const INPUT_ROUTE$1 = "/api/bcdp/input";
3182
+ const INPUT_ROUTE$1 = bcdpRoute("/api/bcdp/input");
3167
3183
  let inputBusy = false;
3168
3184
  /**
3169
3185
  * Send a pointer/wheel intention to the agent browser. Coordinates
@@ -3661,7 +3677,7 @@ function mountFloatingWatch(ctx) {
3661
3677
  raiseBtn.title = wt("raiseWindowHint");
3662
3678
  raiseBtn.textContent = wt("raiseWindow");
3663
3679
  raiseBtn.addEventListener("click", () => {
3664
- fetch("/api/bcdp/raise", {
3680
+ fetchBcdp("/api/bcdp/raise", {
3665
3681
  method: "POST",
3666
3682
  headers: { "content-type": "application/json" },
3667
3683
  body: "{}"
@@ -3836,10 +3852,18 @@ function mountFloatingWatch(ctx) {
3836
3852
  if (!liveFlushRaf && !disposed) liveFlushRaf = window.requestAnimationFrame(() => {
3837
3853
  liveFlushRaf = null;
3838
3854
  if (disposed || !liveImg || pendingLiveFrame == null) return;
3839
- try {
3840
- liveImg.src = pendingLiveFrame;
3841
- } catch {}
3842
- pendingLiveFrame = null;
3855
+ const frame = pendingLiveFrame;
3856
+ const apply$1 = () => {
3857
+ if (disposed || !liveImg) return;
3858
+ try {
3859
+ liveImg.src = frame;
3860
+ } catch {}
3861
+ if (pendingLiveFrame === frame) pendingLiveFrame = null;
3862
+ };
3863
+ const probe = new window.Image();
3864
+ probe.src = frame;
3865
+ if (typeof probe.decode === "function") probe.decode().then(apply$1, apply$1);
3866
+ else apply$1();
3843
3867
  });
3844
3868
  return;
3845
3869
  }
@@ -3870,7 +3894,7 @@ function mountFloatingWatch(ctx) {
3870
3894
  if (sse) sse.close();
3871
3895
  } catch {}
3872
3896
  doConnected = false;
3873
- sse = new EventSource("/api/bcdp/stream");
3897
+ sse = new EventSource(bcdpRoute("/api/bcdp/stream"));
3874
3898
  sse.onopen = () => {
3875
3899
  doConnected = true;
3876
3900
  };
@@ -4178,10 +4202,10 @@ function mountFloatingWatch(ctx) {
4178
4202
  style.remove();
4179
4203
  };
4180
4204
  }
4181
- var INPUT_ROUTE = "/api/bcdp/input";
4182
- var FLUSH_ROUTE = "/api/bcdp/flush";
4183
- var WINDOW_SIZE_ROUTE = "/api/bcdp/window-size";
4184
- var PANEL_NAVIGATE_ROUTE = "/api/bcdp/navigate";
4205
+ var INPUT_ROUTE = bcdpRoute("/api/bcdp/input");
4206
+ var FLUSH_ROUTE = bcdpRoute("/api/bcdp/flush");
4207
+ var WINDOW_SIZE_ROUTE = bcdpRoute("/api/bcdp/window-size");
4208
+ var PANEL_NAVIGATE_ROUTE = bcdpRoute("/api/bcdp/navigate");
4185
4209
  var FRAME_FOLLOW_MIN_MS = 350;
4186
4210
  var SIZE_SYNC_KEY = "dsh-browser-cdp:size-sync";
4187
4211
  function sizeSyncStored() {
@@ -5182,7 +5206,7 @@ function createPickControl(onState, deliver) {
5182
5206
  function post(enabledNow, targetId) {
5183
5207
  var body = { enabled: enabledNow };
5184
5208
  if (targetId) body.targetId = targetId;
5185
- return fetch("/api/bcdp/pick", {
5209
+ return fetchBcdp("/api/bcdp/pick", {
5186
5210
  method: "POST",
5187
5211
  headers: { "content-type": "application/json" },
5188
5212
  body: JSON.stringify(body)
@@ -5217,7 +5241,7 @@ function createPickControl(onState, deliver) {
5217
5241
  }
5218
5242
  function pollOnce() {
5219
5243
  if (request) return;
5220
- request = fetch("/api/bcdp/pick").then(function(r) {
5244
+ request = fetchBcdp("/api/bcdp/pick").then(function(r) {
5221
5245
  return r.json().catch(function() {
5222
5246
  return null;
5223
5247
  });
@@ -5263,7 +5287,7 @@ function createPickControl(onState, deliver) {
5263
5287
  }
5264
5288
  function clickAt(x, y, targetId) {
5265
5289
  if (!enabled || !targetId) return;
5266
- fetch("/api/bcdp/pick/click", {
5290
+ fetchBcdp("/api/bcdp/pick/click", {
5267
5291
  method: "POST",
5268
5292
  headers: { "content-type": "application/json" },
5269
5293
  body: JSON.stringify({
@@ -5765,7 +5789,7 @@ LivePreviewController.prototype.openStream = function() {
5765
5789
  self._applyCaptureStatus(status);
5766
5790
  }).catch(function() {});
5767
5791
  try {
5768
- this.sse = new EventSource("/api/bcdp/stream");
5792
+ this.sse = new EventSource(bcdpRoute("/api/bcdp/stream"));
5769
5793
  } catch (e) {
5770
5794
  return;
5771
5795
  }
@@ -5836,10 +5860,18 @@ LivePreviewController.prototype.applyFrame = function(targetId, dataUrl, vw, vh)
5836
5860
  if (!this.liveFlushRaf && !this.disposed) this.liveFlushRaf = window.requestAnimationFrame(function() {
5837
5861
  self2.liveFlushRaf = null;
5838
5862
  if (self2.disposed || !self2.liveImg || self2.pendingLiveFrame == null) return;
5839
- try {
5840
- self2.liveImg.src = self2.pendingLiveFrame;
5841
- } catch (e) {}
5842
- self2.pendingLiveFrame = null;
5863
+ var frame = self2.pendingLiveFrame;
5864
+ var apply$1 = function() {
5865
+ if (self2.disposed || !self2.liveImg) return;
5866
+ try {
5867
+ self2.liveImg.src = frame;
5868
+ } catch (e) {}
5869
+ if (self2.pendingLiveFrame === frame) self2.pendingLiveFrame = null;
5870
+ };
5871
+ var probe = new window.Image();
5872
+ probe.src = frame;
5873
+ if (typeof probe.decode === "function") probe.decode().then(apply$1, apply$1);
5874
+ else apply$1();
5843
5875
  });
5844
5876
  return;
5845
5877
  }
@@ -6550,7 +6582,7 @@ function EgoBrowserTab(props) {
6550
6582
  type: "button",
6551
6583
  title: wt("raiseWindowHint"),
6552
6584
  onClick: function() {
6553
- fetch("/api/bcdp/raise", {
6585
+ fetchBcdp("/api/bcdp/raise", {
6554
6586
  method: "POST",
6555
6587
  headers: { "content-type": "application/json" },
6556
6588
  body: "{}"
@@ -6711,7 +6743,7 @@ function mountSidebarTab(ctx, betterSidebar) {
6711
6743
  })();
6712
6744
  var probeSse = null;
6713
6745
  try {
6714
- probeSse = new EventSource("/api/bcdp/stream");
6746
+ probeSse = new EventSource(bcdpRoute("/api/bcdp/stream"));
6715
6747
  } catch (e) {}
6716
6748
  if (probeSse) probeSse.addEventListener("tool-call", function(ev) {
6717
6749
  if (probeDisposed) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "1.14.6",
3
+ "version": "1.14.8",
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",