dsh-browser-cdp 1.7.2 → 1.7.4

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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [简体中文](README.md) | [Français](README.fr.md) | [Deutsch](README.de.md) | [Italiano](README.it.md) | [Русский](README.ru.md) | [Español](README.es.md)
4
4
 
5
5
  <p align="center">
6
- <img src="https://img.shields.io/badge/DSH-0.1.7--rc.1~0.2.1--rc.3-blue" alt="DSH 0.1.7-rc.1 ~ 0.2.1-rc.3">
6
+ <img src="https://img.shields.io/badge/DSH-0.1.7--rc.1~0.2.1--rc.4-blue" alt="DSH 0.1.7-rc.1 ~ 0.2.1-rc.4">
7
7
  <img src="https://img.shields.io/badge/DSH--better--sidebar-%3E%3D0.12.2(optional)-red" alt="dsh-better-sidebar >= 0.12.2 (optional)">
8
8
  <img src="https://img.shields.io/badge/Node-%3E%3D22-brightgreen?logo=node.js&logoColor=white" alt="Node >= 22">
9
9
  </p>
@@ -14,11 +14,11 @@
14
14
 
15
15
  | 依赖 | 最低版本 | 推荐版本 | 说明 |
16
16
  |---|---|---|---|
17
- | **DSH** (DeepSeek Harness) | `0.1.7-rc.1` | `0.1.7-rc.1 ~ 0.2.1-rc.3`(精确枚举) | 精确枚举 7 个 rc 版本,engines 与全部 dsh peer 同串(无区间/caret):`0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3`;宿主对插件 API 向后兼容(0.2.0 的 composer/`forkSession` 为签名扩展,插件仅作调用方,免改)。声明式设置面自 0.1.7 引入(Config `.volatile()` 字段自动生成设置表单),0.2.0/0.2.1 延续该形态。DSH `0.1.2-rc.1` ~ `0.1.5-rc.3` 请使用 **0.17.x** 版本线,0.1.0-rc.x / 0.1.1-rc.x 请使用 v0.8.0 及更早版本 |
17
+ | **DSH** (DeepSeek Harness) | `0.1.7-rc.1` | `0.1.7-rc.1 ~ 0.2.1-rc.4`(精确枚举) | 精确枚举 8 个 rc 版本,engines 与全部 dsh peer 同串(无区间/caret):`0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4`;宿主对插件 API 向后兼容(0.2.0 的 composer/`forkSession` 为签名扩展,插件仅作调用方,免改)。声明式设置面自 0.1.7 引入(Config `.volatile()` 字段自动生成设置表单),0.2.0/0.2.1 延续该形态。DSH `0.1.2-rc.1` ~ `0.1.5-rc.3` 请使用 **0.17.x** 版本线,0.1.0-rc.x / 0.1.1-rc.x 请使用 v0.8.0 及更早版本 |
18
18
  | **dsh-better-sidebar** | `0.12.2`(可选) | `≥ 0.17.1` | 未安装时自动回退浮动观察球;`< 0.12.2` 可运行但外部链接拦截(`urlTarget`)静默降级 |
19
19
  | **Node.js** | `22` | — | harness 环境自带 |
20
20
 
21
- **DSH 全版本适配说明**:本版本(**1.2.1 起**;1.2.2 起追加 0.2.1-rc.2)面向 DSH `0.1.7-rc.1 ~ 0.2.1-rc.3`(精确枚举 7 个 rc):相对 0.1.7 线(v0.17.x)**零代码改动**,纯依赖/元数据换代——0.2.0 宿主对插件 API 向后兼容,本插件经 `ctx.get('conversation').input` 门面投递选区(不调 `submit()`、不 override),不在 0.2.0 变更影响面内。声明式设置面自 0.1.7 引入:插件不再注册任何设置节(`ctx.settings` 注册类 API 已被宿主删除),改为在 Config schema 上以 `.volatile()` 标记可配置字段,由宿主设置页自动生成表单;volatile 字段变更通过 `loader/volatile-update` 事件热生效,无需重载插件。核心宿主 API(`defineTool`、`ctx.tools.register`、`ctx.subprocess.spawn`、`ctx.webServer.register`、`ctx.inject`、`ModuleLoader` CJS factory、`cordis.patch.yml`)沿用 0.1.2 以来形态。DSH `0.1.2-rc.1` ~ `0.1.5-rc.3` 请使用 **0.17.x** 版本线。
21
+ **DSH 全版本适配说明**:本版本(**1.2.1 起**;1.2.2 起追加 0.2.1-rc.2)面向 DSH `0.1.7-rc.1 ~ 0.2.1-rc.4`(精确枚举 8 个 rc):相对 0.1.7 线(v0.17.x)**零代码改动**,纯依赖/元数据换代——0.2.0 宿主对插件 API 向后兼容,本插件经 `ctx.get('conversation').input` 门面投递选区(不调 `submit()`、不 override),不在 0.2.0 变更影响面内。声明式设置面自 0.1.7 引入:插件不再注册任何设置节(`ctx.settings` 注册类 API 已被宿主删除),改为在 Config schema 上以 `.volatile()` 标记可配置字段,由宿主设置页自动生成表单;volatile 字段变更通过 `loader/volatile-update` 事件热生效,无需重载插件。核心宿主 API(`defineTool`、`ctx.tools.register`、`ctx.subprocess.spawn`、`ctx.webServer.register`、`ctx.inject`、`ModuleLoader` CJS factory、`cordis.patch.yml`)沿用 0.1.2 以来形态。DSH `0.1.2-rc.1` ~ `0.1.5-rc.3` 请使用 **0.17.x** 版本线。
22
22
 
23
23
  **dsh-better-sidebar 适配说明**:本插件通过 `ctx.betterSidebar` 服务(try-catch 防御性获取)注册侧边栏 Tab 并监听外部链接。关键 API 引入版本:
24
24
 
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.7.2",
5
+ "version": "1.7.4",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
package/lib/client.js CHANGED
@@ -364,6 +364,57 @@ function claimFamilyHostIfOrphaned(slots, isHeld, label, log) {
364
364
  };
365
365
  }
366
366
 
367
+ //#endregion
368
+ //#region src/client/fab-pos.ts
369
+ const clamp01 = (v) => Math.max(0, Math.min(1, v));
370
+ const isFin = (v) => typeof v === "number" && Number.isFinite(v);
371
+ /** 除法结果的归一化兜底:±Infinity 夹到 1/0,NaN 视为无效。 */
372
+ const divClamp = (px, vpSize) => {
373
+ const q = px / vpSize;
374
+ if (q === Infinity) return 1;
375
+ if (q === -Infinity) return 0;
376
+ if (!Number.isFinite(q)) return null;
377
+ return clamp01(q);
378
+ };
379
+ /**
380
+ * 读入 localStorage 存量形状并归一为比例态:
381
+ * - {fx,fy} 均有限 → 夹回 [0,1] 直用;
382
+ * - 否则 {x,y} 均有限(旧像素格式)→ 按当前视口除法换算(±Infinity 夹 1/0,NaN 拒);
383
+ * - 其余(非对象/数组/字段缺失/脏值)→ null,由调用方走默认位。
384
+ */
385
+ function normalizeStored(raw, vp) {
386
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return null;
387
+ const r = raw;
388
+ if (isFin(r.fx) && isFin(r.fy)) return {
389
+ fx: clamp01(r.fx),
390
+ fy: clamp01(r.fy)
391
+ };
392
+ if (!isFin(r.x) || !isFin(r.y)) return null;
393
+ const fx = divClamp(r.x, vp.vw);
394
+ const fy = divClamp(r.y, vp.vh);
395
+ if (fx === null || fy === null) return null;
396
+ return {
397
+ fx,
398
+ fy
399
+ };
400
+ }
401
+ /** 像素 → 比例,4 位小数舍入;像素本身可为 clamp 后越内值(先夹再存)。 */
402
+ function toRatio(pos, vp) {
403
+ const fx = divClamp(pos.x, vp.vw);
404
+ const fy = divClamp(pos.y, vp.vh);
405
+ return {
406
+ fx: fx === null ? 0 : fx,
407
+ fy: fy === null ? 0 : fy
408
+ };
409
+ }
410
+ /** 比例 → 像素(不做 clamp——落位后由接线层既有 clamp 收边)。 */
411
+ function fromRatio(r, vp) {
412
+ return {
413
+ x: Math.round(clamp01(r.fx) * vp.vw),
414
+ y: Math.round(clamp01(r.fy) * vp.vh)
415
+ };
416
+ }
417
+
367
418
  //#endregion
368
419
  //#region src/client/fam-write.ts
369
420
  const defaultSleep = (ms) => new Promise((resolve) => {
@@ -3324,28 +3375,51 @@ function mountFloatingWatch(ctx) {
3324
3375
  const DRAG_PANEL_KEY = "dsh.ego.watch.panelPos";
3325
3376
  const FAB_W = 48, FAB_H = 48;
3326
3377
  const PANEL_W = 408, PANEL_GAP = 8;
3327
- const loadPos = (key) => {
3378
+ const vpFab = () => ({
3379
+ vw: window.innerWidth,
3380
+ vh: window.innerHeight,
3381
+ w: FAB_W,
3382
+ h: FAB_H
3383
+ });
3384
+ const vpPanel = () => ({
3385
+ vw: window.innerWidth,
3386
+ vh: window.innerHeight,
3387
+ w: PANEL_W,
3388
+ h: 520
3389
+ });
3390
+ const loadRatio = (key, vp) => {
3328
3391
  try {
3329
- const s = JSON.parse(localStorage.getItem(key) || "null");
3330
- if (s && Number.isFinite(s.x) && Number.isFinite(s.y)) return s;
3331
- } catch {}
3332
- return null;
3392
+ return normalizeStored(JSON.parse(localStorage.getItem(key) || "null"), vp);
3393
+ } catch {
3394
+ return null;
3395
+ }
3333
3396
  };
3334
- let pos = loadPos(DRAG_KEY) || {
3397
+ let ratio = loadRatio(DRAG_KEY, vpFab());
3398
+ let pos = ratio ? fromRatio(ratio, vpFab()) : {
3335
3399
  x: window.innerWidth - 18 - FAB_W,
3336
3400
  y: window.innerHeight - 104 - FAB_H
3337
3401
  };
3338
- let panelPos = loadPos(DRAG_PANEL_KEY);
3402
+ let panelRatio = loadRatio(DRAG_PANEL_KEY, vpPanel());
3403
+ let panelPos = panelRatio ? fromRatio(panelRatio, vpPanel()) : null;
3339
3404
  const clampFab = () => {
3340
3405
  const vw = window.innerWidth, vh = window.innerHeight;
3341
3406
  pos.x = Math.max(4, Math.min(vw - FAB_W - 4, pos.x));
3342
3407
  pos.y = Math.max(4, Math.min(vh - FAB_H - 4, pos.y));
3343
3408
  };
3344
- const placeFab = () => {
3409
+ /** Paint current pixel state: clamp, mirror into ratio, write style.
3410
+ * Used by drags (which set pos directly) — never re-derives from ratio. */
3411
+ const paintFab = () => {
3345
3412
  clampFab();
3413
+ ratio = toRatio(pos, vpFab());
3346
3414
  fab.style.left = pos.x + "px";
3347
3415
  fab.style.top = pos.y + "px";
3348
3416
  };
3417
+ /** Full re-layout from the stored ratio (init + viewport resize): the ball
3418
+ * keeps its corner at any window size, then clamps back on-screen. */
3419
+ const placeFab = () => {
3420
+ if (ratio) pos = fromRatio(ratio, vpFab());
3421
+ paintFab();
3422
+ };
3349
3423
  const placePanel = () => {
3350
3424
  panel.style.left = panelPos.x + "px";
3351
3425
  panel.style.top = panelPos.y + "px";
@@ -3369,6 +3443,10 @@ function mountFloatingWatch(ctx) {
3369
3443
  };
3370
3444
  placeFab();
3371
3445
  if (panelPos) placePanel();
3446
+ window.addEventListener("resize", () => {
3447
+ placeFab();
3448
+ if (!panel.hidden) snapPanelToFab();
3449
+ });
3372
3450
  let suppressFabClick = false;
3373
3451
  /**
3374
3452
  * Make `el` drag the FAB or the panel (`which` = 'fab' | 'panel').
@@ -3405,7 +3483,7 @@ function mountFloatingWatch(ctx) {
3405
3483
  const s = state();
3406
3484
  s.x = bx + dx;
3407
3485
  s.y = by + dy;
3408
- which === "fab" ? placeFab() : placePanel();
3486
+ which === "fab" ? paintFab() : placePanel();
3409
3487
  }
3410
3488
  };
3411
3489
  const up = (e) => {
@@ -3418,7 +3496,10 @@ function mountFloatingWatch(ctx) {
3418
3496
  if (dragged) {
3419
3497
  if (which === "fab") suppressFabClick = true;
3420
3498
  try {
3421
- localStorage.setItem(which === "fab" ? DRAG_KEY : DRAG_PANEL_KEY, JSON.stringify(state()));
3499
+ const r = toRatio(state(), which === "fab" ? vpFab() : vpPanel());
3500
+ if (which === "fab") ratio = r;
3501
+ else panelRatio = r;
3502
+ localStorage.setItem(which === "fab" ? DRAG_KEY : DRAG_PANEL_KEY, JSON.stringify(r));
3422
3503
  } catch {}
3423
3504
  }
3424
3505
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "dsh-browser-cdp: DSH browser plugin — attach to a running Chrome/Edge over CDP (no bundled browser needed); structured browser-automation tools (30+ bcdp_*) that drive the vendored ego runtime through ctx.subprocess, plus a realtime watch panel (live SSE screencast + direct mouse interaction + download capture + human-verification notice). Web shell: floating watch panel without dsh-better-sidebar, sidebar tab with it. Headless/TUI hosts: tools-only. [DSH 0.1.7-rc.1 ~ 0.2.1-rc.1 line (exact rc enumeration): declarative settings via Config .volatile() fields; for DSH 0.1.2-rc.1 ~ 0.1.5-rc.3 use the 0.17.x line]",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "dsh": {
23
23
  "engines": {
24
- "dsh": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3"
24
+ "dsh": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4"
25
25
  },
26
26
  "bundle": {
27
27
  "patch": "./cordis.patch.yml"
@@ -52,12 +52,12 @@
52
52
  "@deepseek-ai/schemastery": "^3.18.4"
53
53
  },
54
54
  "peerDependencies": {
55
- "@deepseek-ai/dsh-client-locale": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
56
- "@deepseek-ai/dsh-client-store": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
57
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
58
- "@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
59
- "@deepseek-ai/dsh-settings": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
60
- "@deepseek-ai/dsh-tools": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
55
+ "@deepseek-ai/dsh-client-locale": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4",
56
+ "@deepseek-ai/dsh-client-store": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4",
57
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4",
58
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4",
59
+ "@deepseek-ai/dsh-settings": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4",
60
+ "@deepseek-ai/dsh-tools": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4",
61
61
  "react": "^18.2.0"
62
62
  },
63
63
  "peerDependenciesMeta": {
@@ -95,7 +95,7 @@
95
95
  },
96
96
  "engines": {
97
97
  "node": ">=22",
98
- "dsh": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3"
98
+ "dsh": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4"
99
99
  },
100
100
  "license": "MIT",
101
101
  "repository": {
@@ -104,6 +104,6 @@
104
104
  },
105
105
  "publishConfig": {
106
106
  "registry": "https://registry.npmjs.org",
107
- "tag": "latest"
107
+ "tag": "dsh-0.2.1"
108
108
  }
109
109
  }