dsh-browser-cdp 1.2.1 → 1.2.3
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 +3 -3
- package/dsh-plugin.json +1 -1
- package/lib/client.js +23 -2
- package/lib/index.js +53 -8
- package/package.json +9 -9
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.
|
|
6
|
+
<img src="https://img.shields.io/badge/DSH-0.1.7--rc.1~0.2.1--rc.2-blue" alt="DSH 0.1.7-rc.1 ~ 0.2.1-rc.2">
|
|
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.1`(精确枚举) | 精确枚举 5 个 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`;宿主对插件 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.1`(精确枚举) | 精确枚举 5 个 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`;宿主对插件 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
|
|
21
|
+
**DSH 全版本适配说明**:本版本(**1.2.1 起**;1.2.2 起追加 0.2.1-rc.2)面向 DSH `0.1.7-rc.1 ~ 0.2.1-rc.2`(精确枚举 6 个 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
package/lib/client.js
CHANGED
|
@@ -239,6 +239,18 @@ const FAMILY_CLAIM_DELAY_MS = FAMILY_CLAIM_BASE_MS + FAMILY_CLAIM_RANK * FAMILY_
|
|
|
239
239
|
* 这样 owner 一旦上位就自然遮蔽本兜底行(宿主规则:同 cell 最低者渲染)。 */
|
|
240
240
|
const FAMILY_HOST_PRIORITY = 50;
|
|
241
241
|
const NO_TABS = [];
|
|
242
|
+
/**
|
|
243
|
+
* uSES 浅比较(issue #2 的 C 案加固):引用不同但行内容一致时视为未变。
|
|
244
|
+
* 主修法是按 getVersion 缓存快照(引用稳定),这里只兑底宿主绑定语义再变的情形。
|
|
245
|
+
*/
|
|
246
|
+
function eqRows(a, b) {
|
|
247
|
+
if (a === b) return true;
|
|
248
|
+
if (a.length !== b.length) return false;
|
|
249
|
+
return a.every((row, i) => {
|
|
250
|
+
const other = b[i];
|
|
251
|
+
return other !== void 0 && row.id === other.id && row.order === other.order && row.label === other.label;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
242
254
|
/** 通用容器渲染:按 order 依次画出账本里每张贡献卡,不含任何"本插件特例"。 */
|
|
243
255
|
function FamilyHostSection(props) {
|
|
244
256
|
const raw = props.hooks?.tabs;
|
|
@@ -250,7 +262,7 @@ function FamilyHostSection(props) {
|
|
|
250
262
|
return (0, react.createElement)("div", { style: {
|
|
251
263
|
display: "grid",
|
|
252
264
|
gap: "12px"
|
|
253
|
-
} }, (props.useTabs !== void 0 ? props.useTabs((value) => value) : polled).map((row) => (0, react.createElement)("div", { key: row.id }, props.renderSlot ? props.renderSlot(FAMILY_CHILD_KEY, {}, {
|
|
265
|
+
} }, (props.useTabs !== void 0 ? props.useTabs((value) => value, eqRows) : polled).map((row) => (0, react.createElement)("div", { key: row.id }, props.renderSlot ? props.renderSlot(FAMILY_CHILD_KEY, {}, {
|
|
254
266
|
only: row.id,
|
|
255
267
|
fallback: null
|
|
256
268
|
}) : props.renderContributor?.(row.id) ?? null)));
|
|
@@ -298,8 +310,17 @@ function claimFamilyHostIfOrphaned(slots, isHeld, label, log) {
|
|
|
298
310
|
let claimed = false;
|
|
299
311
|
const timer = setTimeout(() => {
|
|
300
312
|
if (isHeld()) return;
|
|
313
|
+
let cachedVersion = -1;
|
|
314
|
+
let cachedRows = NO_TABS;
|
|
301
315
|
const ledger = {
|
|
302
|
-
getSnapshot: () =>
|
|
316
|
+
getSnapshot: () => {
|
|
317
|
+
const v = typeof slots.getVersion === "function" ? slots.getVersion(FAMILY_CHILD_KEY) : NaN;
|
|
318
|
+
if (v !== cachedVersion || Number.isNaN(v)) {
|
|
319
|
+
cachedRows = projectLedger(slots);
|
|
320
|
+
cachedVersion = v;
|
|
321
|
+
}
|
|
322
|
+
return cachedRows;
|
|
323
|
+
},
|
|
303
324
|
subscribe: (listener) => slots.subscribe ? slots.subscribe(FAMILY_CHILD_KEY, listener) : () => void 0
|
|
304
325
|
};
|
|
305
326
|
/** ≤0.1.5 壳没有 renderSlot:从账本条目现挂组件,失败一律 null。 */
|
package/lib/index.js
CHANGED
|
@@ -271,12 +271,25 @@ async function connectCdp(wsUrl, timeoutMs) {
|
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
|
-
async function browserWsUrl(port) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
274
|
+
async function browserWsUrl(port, retries = 2) {
|
|
275
|
+
for (let attempt = 0;; attempt++) try {
|
|
276
|
+
const r = await fetch(`http://127.0.0.1:${port}/json/version`, { signal: AbortSignal.timeout(3e3) });
|
|
277
|
+
if (!r.ok) throw new Error(`/json/version HTTP ${r.status} on port ${port}`);
|
|
278
|
+
const j$1 = await r.json();
|
|
279
|
+
if (!j$1.webSocketDebuggerUrl) throw new Error("browser did not expose webSocketDebuggerUrl");
|
|
280
|
+
return j$1.webSocketDebuggerUrl;
|
|
281
|
+
} catch (err) {
|
|
282
|
+
const nm = err?.name;
|
|
283
|
+
const timedOut = nm === "TimeoutError" || nm === "AbortError";
|
|
284
|
+
const refused = err instanceof TypeError;
|
|
285
|
+
if ((timedOut || refused) && attempt < retries) {
|
|
286
|
+
await sleep(500);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (timedOut) throw new Error(`/json/version on port ${port} timed out after ${retries + 1} attempts`);
|
|
290
|
+
if (refused) throw new Error(`DevTools HTTP endpoint unreachable on port ${port} after ${retries + 1} attempts (connection refused — the browser may have exited right after publishing the port)`);
|
|
291
|
+
throw err;
|
|
292
|
+
}
|
|
280
293
|
}
|
|
281
294
|
function sleep(ms) {
|
|
282
295
|
return new Promise((resolve$1) => setTimeout(resolve$1, ms));
|
|
@@ -423,6 +436,7 @@ async function importLoginCookies(opts, deps) {
|
|
|
423
436
|
}
|
|
424
437
|
let closedSource = false;
|
|
425
438
|
let srcHandle = null;
|
|
439
|
+
let exited = null;
|
|
426
440
|
let tempCdp = null;
|
|
427
441
|
let egoCdp = null;
|
|
428
442
|
let linkDir = null;
|
|
@@ -483,7 +497,7 @@ async function importLoginCookies(opts, deps) {
|
|
|
483
497
|
}
|
|
484
498
|
}
|
|
485
499
|
let port = null;
|
|
486
|
-
for (let attempt = 0; attempt < 2 && port === null; attempt++) {
|
|
500
|
+
for (let attempt = 0; attempt < 2 && port === null && exited === null; attempt++) {
|
|
487
501
|
if (attempt > 0) {
|
|
488
502
|
await sleep(6e3);
|
|
489
503
|
try {
|
|
@@ -518,8 +532,18 @@ async function importLoginCookies(opts, deps) {
|
|
|
518
532
|
graceMs: 8e3
|
|
519
533
|
});
|
|
520
534
|
srcHandle.done.catch(() => null);
|
|
535
|
+
exited = null;
|
|
536
|
+
srcHandle.done.then((r) => {
|
|
537
|
+
exited = r;
|
|
538
|
+
}, () => {
|
|
539
|
+
exited = {
|
|
540
|
+
exitCode: null,
|
|
541
|
+
signal: null
|
|
542
|
+
};
|
|
543
|
+
});
|
|
521
544
|
const deadline = Date.now() + timeoutMs;
|
|
522
|
-
while (Date.now() < deadline) {
|
|
545
|
+
while (Date.now() < deadline && port === null) {
|
|
546
|
+
if (exited !== null) break;
|
|
523
547
|
try {
|
|
524
548
|
port = parseDevToolsActivePort(await readFile(portFile, "utf8"));
|
|
525
549
|
if (port !== null) break;
|
|
@@ -527,6 +551,19 @@ async function importLoginCookies(opts, deps) {
|
|
|
527
551
|
await sleep(250);
|
|
528
552
|
}
|
|
529
553
|
}
|
|
554
|
+
const earlyExit = exited;
|
|
555
|
+
if (port === null && earlyExit !== null) {
|
|
556
|
+
let tail = "";
|
|
557
|
+
try {
|
|
558
|
+
tail = srcHandle?.collected?.stderr?.readFrom(0).text ?? "";
|
|
559
|
+
} catch {}
|
|
560
|
+
tail = tail.slice(-500);
|
|
561
|
+
return {
|
|
562
|
+
ok: false,
|
|
563
|
+
closedSource,
|
|
564
|
+
error: `${browser.label} headless instance exited early (code=${earlyExit.exitCode ?? "null"}, signal=${earlyExit.signal ?? "none"})${tail ? `: ${tail}` : ""} — a lingering background instance may have swallowed the throwaway debug port`
|
|
565
|
+
};
|
|
566
|
+
}
|
|
530
567
|
if (port === null) return {
|
|
531
568
|
ok: false,
|
|
532
569
|
closedSource,
|
|
@@ -8076,6 +8113,8 @@ function registerLoginImport(ctx, cfg, reg) {
|
|
|
8076
8113
|
matched: { type: "integer" },
|
|
8077
8114
|
written: { type: "integer" },
|
|
8078
8115
|
domains: { type: "json" },
|
|
8116
|
+
closedSource: { type: "boolean" },
|
|
8117
|
+
restoredFromBackup: { type: "boolean" },
|
|
8079
8118
|
error: { type: "string" }
|
|
8080
8119
|
}
|
|
8081
8120
|
},
|
|
@@ -8696,6 +8735,10 @@ function registerActionTools(ctx, cfg, reg) {
|
|
|
8696
8735
|
type: "string",
|
|
8697
8736
|
description: "'browser' (default) runs via the page context; 'server' uses Node-side fetch.server."
|
|
8698
8737
|
},
|
|
8738
|
+
credentials: {
|
|
8739
|
+
type: "string",
|
|
8740
|
+
description: "Browser mode only: 'include' attaches the page profile's cookies even cross-origin (reuse login state on API endpoints); 'omit' / 'same-origin' also accepted. Omitted = engine default (cross-origin credentials not sent). Ignored in server mode."
|
|
8741
|
+
},
|
|
8699
8742
|
space: spaceParam
|
|
8700
8743
|
},
|
|
8701
8744
|
buildScript: (args) => {
|
|
@@ -8706,6 +8749,8 @@ function registerActionTools(ctx, cfg, reg) {
|
|
|
8706
8749
|
};
|
|
8707
8750
|
if (str(args.body, "") !== "") opts.body = str(args.body, "");
|
|
8708
8751
|
const mode = str(args.mode, "browser");
|
|
8752
|
+
const cred = str(args.credentials, "");
|
|
8753
|
+
if (mode !== "server" && (cred === "include" || cred === "omit" || cred === "same-origin")) opts.credentials = cred;
|
|
8709
8754
|
return `${mode === "server" ? "" : `${useSpace(str(args.space, cfg.defaultSpace))}${ensureRealTab()}`}${SAFE_FN}const __r = await fetch.${mode === "server" ? "server" : "browser"}(${j(str(args.url, ""))}, ${j(opts)})\nconst __status = typeof __r.status !== "undefined" ? __r.status : 200\nlet __body = null\ntry { __body = typeof __r.text === "function" ? await __r.text() : (typeof __r === "string" ? __r : JSON.stringify(safe(__r))) } catch { __body = null }\nconsole.log('${SENTINEL}' + JSON.stringify({ ok: true, mode: ${j(mode)}, status: __status, body: __body, url: ${j(str(args.url, ""))} }))\n`;
|
|
8710
8755
|
}
|
|
8711
8756
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
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"
|
|
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"
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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"
|
|
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"
|
|
99
99
|
},
|
|
100
100
|
"license": "MIT",
|
|
101
101
|
"repository": {
|