dsh-browser-cdp 0.18.0 → 0.18.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/README.de.md +286 -0
- package/README.es.md +286 -0
- package/README.fr.md +286 -0
- package/README.it.md +286 -0
- package/README.md +4 -0
- package/README.ru.md +286 -0
- package/dsh-plugin.json +1 -1
- package/lib/client.js +556 -50
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -1,6 +1,172 @@
|
|
|
1
1
|
window.__ModuleLoader__.load({ id: "dsh-browser-cdp", factory: (require) => {
|
|
2
2
|
var module = { exports: {} }; var exports = module.exports;
|
|
3
3
|
|
|
4
|
+
//#region src/client/fam-links.ts
|
|
5
|
+
/**
|
|
6
|
+
* Pure link-sequence operations behind the settings card's 连接目标 editor.
|
|
7
|
+
*
|
|
8
|
+
* The client bundle cannot reach `src/cdp-targets.ts` (its import graph drags
|
|
9
|
+
* node-side modules into the browser build), so the small rules the card needs
|
|
10
|
+
* live here — deliberately the SAME rules the host enforces on read
|
|
11
|
+
* (`sanitizeLinks`/`coerceLink`): ego-cli singleton, MAX cap, unusable-row
|
|
12
|
+
* rejection. The card writes the WHOLE `links` array in one `scope.set`
|
|
13
|
+
* (row-level volatile writes don't exist), which BYPASSES the host's
|
|
14
|
+
* `upsertLink` rejections — these prechecks are therefore the only guard, and
|
|
15
|
+
* the tests pin them to the host semantics.
|
|
16
|
+
*
|
|
17
|
+
* Two hard invariants (see plan `compat-0.2.0-dsh-browser-cdp` / findings
|
|
18
|
+
* Agent C §3):
|
|
19
|
+
* - a stored row's keys are all optional at runtime; edits must spread the
|
|
20
|
+
* original row (`{...row, ...patch}`) so probe state survives — a rebuilt
|
|
21
|
+
* thin row loses badges, and a bad `probeStatus` enum gets the WHOLE write
|
|
22
|
+
* rejected by the settings layer;
|
|
23
|
+
* - a cdp row with an empty/invalid endpoint is silently dropped by the host's
|
|
24
|
+
* `coerceLink` on next resolve — the card must refuse to persist one.
|
|
25
|
+
*
|
|
26
|
+
* No react import: this module is unit-tested directly under vitest's node
|
|
27
|
+
* environment (the client entry's `require('react')` makes index.ts
|
|
28
|
+
* un-importable there).
|
|
29
|
+
*/
|
|
30
|
+
/** Hard ceiling on the sequence length — mirrors host `MAX_TARGETS`. */
|
|
31
|
+
const MAX_LINKS = 32;
|
|
32
|
+
/** Local ego CLI singleton default label — mirrors host `EGO_CLI_LABEL`. */
|
|
33
|
+
const EGO_CLI_LABEL = "本机 ego CLI";
|
|
34
|
+
/** Fresh id, same shape as the host `newTargetId()` (uuid, `t-` fallback). */
|
|
35
|
+
function newLinkId() {
|
|
36
|
+
const cryptoObj = globalThis.crypto;
|
|
37
|
+
if (cryptoObj && typeof cryptoObj.randomUUID === "function") return cryptoObj.randomUUID();
|
|
38
|
+
return `t-${Math.random().toString(36).slice(2, 10)}${Date.now().toString(36)}`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The card-side gate for persisting a cdp endpoint: non-empty and explicitly
|
|
42
|
+
* scheme-qualified. Anything else would pass the settings write and then be
|
|
43
|
+
* dropped by the host's `coerceLink` on the next resolve — invisible loss.
|
|
44
|
+
*/
|
|
45
|
+
function isValidEndpoint(value) {
|
|
46
|
+
if (typeof value !== "string") return false;
|
|
47
|
+
const v = value.trim();
|
|
48
|
+
if (v === "") return false;
|
|
49
|
+
return /^(https?|wss?):\/\//i.test(v);
|
|
50
|
+
}
|
|
51
|
+
function trimmed(value) {
|
|
52
|
+
return typeof value === "string" ? value.trim() : "";
|
|
53
|
+
}
|
|
54
|
+
/** Full-field cdp row: probe five-piece defaults so the write passes the union. */
|
|
55
|
+
function buildCdpRow(input) {
|
|
56
|
+
const endpoint = trimmed(input.endpoint);
|
|
57
|
+
return {
|
|
58
|
+
kind: "cdp",
|
|
59
|
+
id: newLinkId(),
|
|
60
|
+
label: trimmed(input.label) || endpoint,
|
|
61
|
+
endpoint,
|
|
62
|
+
enabled: true,
|
|
63
|
+
note: "",
|
|
64
|
+
probeStatus: "unknown",
|
|
65
|
+
probeLatencyMs: 0,
|
|
66
|
+
probeError: "",
|
|
67
|
+
probeCode: "",
|
|
68
|
+
probeAt: 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Full-field ego-cli row (`cliPath` '' = host auto-resolve chain). */
|
|
72
|
+
function buildCliRow(input) {
|
|
73
|
+
const cliPath = trimmed(input.cliPath);
|
|
74
|
+
return {
|
|
75
|
+
kind: "ego-cli",
|
|
76
|
+
id: newLinkId(),
|
|
77
|
+
label: trimmed(input.label) || cliPath || EGO_CLI_LABEL,
|
|
78
|
+
cliPath,
|
|
79
|
+
useSdkPath: false,
|
|
80
|
+
enabled: true,
|
|
81
|
+
note: "",
|
|
82
|
+
probeStatus: "unknown",
|
|
83
|
+
probeLatencyMs: 0,
|
|
84
|
+
probeError: "",
|
|
85
|
+
probeCode: "",
|
|
86
|
+
probeAt: 0
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Second ego-cli anywhere in the array would be silently dropped on read. */
|
|
90
|
+
function hasCliLink(links) {
|
|
91
|
+
return links.some(function(row) {
|
|
92
|
+
return row.kind === "ego-cli";
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function isFull(links) {
|
|
96
|
+
return links.length >= MAX_LINKS;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Append a pre-built row behind the host's structured rejections: the card
|
|
100
|
+
* bypasses `upsertLink`, so the singleton and cap checks here are the only
|
|
101
|
+
* guard before the write.
|
|
102
|
+
*/
|
|
103
|
+
function addRow(links, row) {
|
|
104
|
+
if (row.kind === "ego-cli" && hasCliLink(links)) return {
|
|
105
|
+
links,
|
|
106
|
+
code: "ego-cli-already-exists"
|
|
107
|
+
};
|
|
108
|
+
if (links.length >= MAX_LINKS) return {
|
|
109
|
+
links,
|
|
110
|
+
code: "link-limit-reached"
|
|
111
|
+
};
|
|
112
|
+
if (row.kind === "cdp" && !isValidEndpoint(row.endpoint)) return {
|
|
113
|
+
links,
|
|
114
|
+
code: "unusable-row"
|
|
115
|
+
};
|
|
116
|
+
return { links: links.concat([row]) };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Patch one row by id, spreading the ORIGINAL row so probe state and any
|
|
120
|
+
* field the patch omits survive verbatim. Unknown id → array returned
|
|
121
|
+
* unchanged (new reference only if the map ran; callers treat it as no-op).
|
|
122
|
+
*/
|
|
123
|
+
function updateRow(links, id, patch) {
|
|
124
|
+
return links.map(function(row) {
|
|
125
|
+
return row.id === id ? Object.assign({}, row, patch) : row;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Filter one row out. Returns the removed row so the caller can clear
|
|
130
|
+
* `activeTargetId` when it was the activated one (clear, never advance —
|
|
131
|
+
* re-pointing every bcdp_* call at another browser is the host's job to
|
|
132
|
+
* refuse, not the card's to decide).
|
|
133
|
+
*/
|
|
134
|
+
function removeRow(links, id) {
|
|
135
|
+
const removed = links.find(function(row) {
|
|
136
|
+
return row.id === id;
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
links: links.filter(function(row) {
|
|
140
|
+
return row.id !== id;
|
|
141
|
+
}),
|
|
142
|
+
removed
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/** ±1 neighbour swap; out-of-range leaves the order untouched. */
|
|
146
|
+
function moveRow(links, id, delta) {
|
|
147
|
+
const index = links.findIndex(function(row) {
|
|
148
|
+
return row.id === id;
|
|
149
|
+
});
|
|
150
|
+
const target = index + delta;
|
|
151
|
+
if (index < 0 || target < 0 || target >= links.length) return links;
|
|
152
|
+
const next = links.slice();
|
|
153
|
+
const tmp = next[index];
|
|
154
|
+
next[index] = next[target];
|
|
155
|
+
next[target] = tmp;
|
|
156
|
+
return next;
|
|
157
|
+
}
|
|
158
|
+
/** Write one probe outcome back into its row (spread-safe, full fields kept). */
|
|
159
|
+
function applyProbe(links, id, outcome, at) {
|
|
160
|
+
return updateRow(links, id, {
|
|
161
|
+
probeStatus: outcome.ok ? "ok" : "error",
|
|
162
|
+
probeLatencyMs: typeof outcome.latencyMs === "number" ? outcome.latencyMs : 0,
|
|
163
|
+
probeError: outcome.ok ? "" : outcome.message || "",
|
|
164
|
+
probeCode: outcome.ok ? "" : outcome.code || "",
|
|
165
|
+
probeAt: at
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
4
170
|
//#region src/client/index.ts
|
|
5
171
|
var React = require("react");
|
|
6
172
|
var createSnapshotStore = require("@deepseek-ai/dsh-client-store").createSnapshotStore;
|
|
@@ -90,7 +256,32 @@ var watchEn = {
|
|
|
90
256
|
famIsolate: "Space isolation",
|
|
91
257
|
famIsolateDesc: "Off = persistent profile (logins survive restarts); on = isolated sandbox",
|
|
92
258
|
famIdle: "Auto-stop idle browser (minutes, 0 = off)",
|
|
93
|
-
famIdleDesc: "Stops the backing browser after N minutes without a bcdp_* call; relaunches on demand"
|
|
259
|
+
famIdleDesc: "Stops the backing browser after N minutes without a bcdp_* call; relaunches on demand",
|
|
260
|
+
linksTitle: "Connection targets (order = priority)",
|
|
261
|
+
linksEmpty: "No targets yet — add the first one with the form below",
|
|
262
|
+
linksEnabled: "Enabled",
|
|
263
|
+
linksActive: "active",
|
|
264
|
+
linksAddCdp: "Add CDP endpoint",
|
|
265
|
+
linksAddCli: "Add local ego CLI",
|
|
266
|
+
linksAddCliExists: "The local ego CLI link already exists — local-only, one per machine",
|
|
267
|
+
linksEndpoint: "Endpoint",
|
|
268
|
+
linksEndpointHint: "http(s)://host:port or ws(s)://…",
|
|
269
|
+
linksEndpointInvalid: "Invalid endpoint — not saved",
|
|
270
|
+
linksCliPath: "ego CLI path",
|
|
271
|
+
linksCliPathHint: "Empty = auto-detect (PATH → app bundle → bundled runtime)",
|
|
272
|
+
linksLabel: "Label",
|
|
273
|
+
linksRemove: "Remove",
|
|
274
|
+
linksMoveUp: "Move up",
|
|
275
|
+
linksMoveDown: "Move down",
|
|
276
|
+
linksProbe: "Probe",
|
|
277
|
+
linksProbing: "Probing…",
|
|
278
|
+
linksProbeOk: "reachable",
|
|
279
|
+
linksProbeFail: "unreachable",
|
|
280
|
+
linksLimitReached: "The sequence is capped at {n} entries",
|
|
281
|
+
linksWriteFailed: "Save failed — the settings layer rejected this write",
|
|
282
|
+
linksCliRemoteWarn: "Activating an ego CLI link under cdpMode=remote fails with mode-kind-mismatch",
|
|
283
|
+
linksCliSdk: "Use bundled harness",
|
|
284
|
+
linksDisabledHint: "Disabled — enable it before activating"
|
|
94
285
|
};
|
|
95
286
|
var watchDict = {
|
|
96
287
|
en: watchEn,
|
|
@@ -148,7 +339,32 @@ var watchDict = {
|
|
|
148
339
|
famIsolate: "空间隔离",
|
|
149
340
|
famIsolateDesc: "关 = 持久化配置(重启保留登录态);开 = 每次隔离沙箱",
|
|
150
341
|
famIdle: "空闲自动停止(分钟,0 = 不停)",
|
|
151
|
-
famIdleDesc: "超过 N 分钟没有 bcdp_* 调用即停止后台浏览器,下次调用按需重启"
|
|
342
|
+
famIdleDesc: "超过 N 分钟没有 bcdp_* 调用即停止后台浏览器,下次调用按需重启",
|
|
343
|
+
linksTitle: "连接目标(顺序即优先级)",
|
|
344
|
+
linksEmpty: "暂无目标——用下方表单添加第一个连接目标",
|
|
345
|
+
linksEnabled: "启用",
|
|
346
|
+
linksActive: "已激活",
|
|
347
|
+
linksAddCdp: "添加 CDP 端点",
|
|
348
|
+
linksAddCli: "添加本机 ego CLI",
|
|
349
|
+
linksAddCliExists: "本机 ego CLI 连接已存在——仅限本机,一台机器只允许一条",
|
|
350
|
+
linksEndpoint: "端点",
|
|
351
|
+
linksEndpointHint: "http(s)://主机:端口 或 ws(s)://…",
|
|
352
|
+
linksEndpointInvalid: "端点无效,未保存",
|
|
353
|
+
linksCliPath: "ego CLI 路径",
|
|
354
|
+
linksCliPathHint: "留空 = 自动检测(PATH → 应用包 → 内置运行时)",
|
|
355
|
+
linksLabel: "标签",
|
|
356
|
+
linksRemove: "删除",
|
|
357
|
+
linksMoveUp: "上移",
|
|
358
|
+
linksMoveDown: "下移",
|
|
359
|
+
linksProbe: "探测",
|
|
360
|
+
linksProbing: "探测中…",
|
|
361
|
+
linksProbeOk: "可达",
|
|
362
|
+
linksProbeFail: "不可达",
|
|
363
|
+
linksLimitReached: "连接序列最多 {n} 条",
|
|
364
|
+
linksWriteFailed: "保存失败——设置层拒绝了这次写入",
|
|
365
|
+
linksCliRemoteWarn: "cdpMode=remote 时激活 ego CLI 会报 mode-kind-mismatch",
|
|
366
|
+
linksCliSdk: "使用内置 harness",
|
|
367
|
+
linksDisabledHint: "已停用——先勾选启用才能激活"
|
|
152
368
|
}
|
|
153
369
|
};
|
|
154
370
|
function wt(key, params = void 0) {
|
|
@@ -691,6 +907,20 @@ function mountFamilySettingsCard(ctx) {
|
|
|
691
907
|
}, FamilySettingsCard);
|
|
692
908
|
}, "dsh-browser-cdp: family settings tab");
|
|
693
909
|
}
|
|
910
|
+
function mountPluginsPageCard(ctx) {
|
|
911
|
+
var forms = typeof ctx.get === "function" ? ctx.get("configForms") : void 0;
|
|
912
|
+
if (!forms || typeof forms.get !== "function") return;
|
|
913
|
+
var scope = forms.get("dsh-browser-cdp");
|
|
914
|
+
ctx.slots.inject("plugins.bundle.config", function() {
|
|
915
|
+
return ctx.slots.register({
|
|
916
|
+
name: "plugins.bundle.config",
|
|
917
|
+
key: "dsh-browser-cdp",
|
|
918
|
+
inject: function() {
|
|
919
|
+
return { scope };
|
|
920
|
+
}
|
|
921
|
+
}, FamilySettingsCard);
|
|
922
|
+
}, "dsh-browser-cdp: plugins-page config card");
|
|
923
|
+
}
|
|
694
924
|
var FAM_FIELD_GROUPS = [
|
|
695
925
|
{
|
|
696
926
|
gk: "gBasic",
|
|
@@ -1206,6 +1436,42 @@ function FamStrInput(props) {
|
|
|
1206
1436
|
}
|
|
1207
1437
|
});
|
|
1208
1438
|
}
|
|
1439
|
+
function FamRowInput(props) {
|
|
1440
|
+
var h = React.createElement;
|
|
1441
|
+
var empty = props.v === void 0 || props.v === null ? "" : String(props.v);
|
|
1442
|
+
var draft = React.useState(empty);
|
|
1443
|
+
var v = draft[0], setV = draft[1];
|
|
1444
|
+
React.useEffect(function() {
|
|
1445
|
+
setV(props.v === void 0 || props.v === null ? "" : String(props.v));
|
|
1446
|
+
}, [props.v]);
|
|
1447
|
+
function commit() {
|
|
1448
|
+
if (v !== empty) props.onCommit(v);
|
|
1449
|
+
}
|
|
1450
|
+
return h("input", {
|
|
1451
|
+
type: "text",
|
|
1452
|
+
value: v,
|
|
1453
|
+
disabled: !props.writable,
|
|
1454
|
+
placeholder: props.placeholder || "",
|
|
1455
|
+
style: {
|
|
1456
|
+
flex: "1 1 140px",
|
|
1457
|
+
minWidth: 0,
|
|
1458
|
+
font: "inherit",
|
|
1459
|
+
fontSize: "12px",
|
|
1460
|
+
color: "inherit",
|
|
1461
|
+
background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.08))",
|
|
1462
|
+
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
|
|
1463
|
+
borderRadius: "8px",
|
|
1464
|
+
padding: "3px 8px"
|
|
1465
|
+
},
|
|
1466
|
+
onChange: function(e) {
|
|
1467
|
+
setV(e.target.value);
|
|
1468
|
+
},
|
|
1469
|
+
onBlur: commit,
|
|
1470
|
+
onKeyDown: function(e) {
|
|
1471
|
+
if (e.key === "Enter") commit();
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1209
1475
|
function FamLinks(props) {
|
|
1210
1476
|
var value = props.value;
|
|
1211
1477
|
var writable = props.writable;
|
|
@@ -1213,85 +1479,325 @@ function FamLinks(props) {
|
|
|
1213
1479
|
var h = React.createElement;
|
|
1214
1480
|
var links = Array.isArray(value.links) ? value.links : [];
|
|
1215
1481
|
var activeId = typeof value.activeTargetId === "string" ? value.activeTargetId : "";
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1482
|
+
var cdpMode = typeof value.cdpMode === "string" ? value.cdpMode : "auto";
|
|
1483
|
+
var errState = React.useState("");
|
|
1484
|
+
var errText = errState[0], setErrText = errState[1];
|
|
1485
|
+
var probeState = React.useState("");
|
|
1486
|
+
var probingId = probeState[0], setProbingId = probeState[1];
|
|
1487
|
+
var addLabelState = React.useState("");
|
|
1488
|
+
var addLabel = addLabelState[0], setAddLabel = addLabelState[1];
|
|
1489
|
+
var addEndpointState = React.useState("");
|
|
1490
|
+
var addEndpoint = addEndpointState[0], setAddEndpoint = addEndpointState[1];
|
|
1491
|
+
var addCliPathState = React.useState("");
|
|
1492
|
+
var addCliPath = addCliPathState[0], setAddCliPath = addCliPathState[1];
|
|
1493
|
+
var btnStyle = {
|
|
1494
|
+
font: "inherit",
|
|
1495
|
+
fontSize: "12px",
|
|
1496
|
+
cursor: writable ? "pointer" : "not-allowed",
|
|
1497
|
+
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
|
|
1498
|
+
background: "none",
|
|
1499
|
+
color: "var(--dsw-alias-label-primary, inherit)",
|
|
1500
|
+
borderRadius: "8px",
|
|
1501
|
+
padding: "2px 8px",
|
|
1502
|
+
flex: "0 0 auto"
|
|
1503
|
+
};
|
|
1504
|
+
var badgeStyle = {
|
|
1505
|
+
fontSize: "10px",
|
|
1506
|
+
fontWeight: 600,
|
|
1507
|
+
letterSpacing: ".04em",
|
|
1508
|
+
flex: "0 0 auto",
|
|
1509
|
+
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))",
|
|
1510
|
+
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.25))",
|
|
1511
|
+
borderRadius: "6px",
|
|
1512
|
+
padding: "0 5px",
|
|
1513
|
+
lineHeight: "16px"
|
|
1514
|
+
};
|
|
1515
|
+
var inputStyle = {
|
|
1516
|
+
font: "inherit",
|
|
1517
|
+
fontSize: "12px",
|
|
1518
|
+
color: "inherit",
|
|
1519
|
+
background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.08))",
|
|
1520
|
+
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
|
|
1521
|
+
borderRadius: "8px",
|
|
1522
|
+
padding: "3px 8px"
|
|
1523
|
+
};
|
|
1524
|
+
function writeLinks(next) {
|
|
1525
|
+
Promise.resolve(scope.set("links", next)).then(function(ok) {
|
|
1526
|
+
if (ok === false) setErrText(wt("linksWriteFailed"));
|
|
1527
|
+
}, function() {
|
|
1528
|
+
setErrText(wt("linksWriteFailed"));
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
function limitText() {
|
|
1532
|
+
return wt("linksLimitReached", { n: MAX_LINKS });
|
|
1533
|
+
}
|
|
1534
|
+
function addCdp() {
|
|
1535
|
+
if (!isValidEndpoint(addEndpoint)) {
|
|
1536
|
+
setErrText(wt("linksEndpointInvalid"));
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
var res = addRow(links, buildCdpRow({
|
|
1540
|
+
label: addLabel,
|
|
1541
|
+
endpoint: addEndpoint
|
|
1542
|
+
}));
|
|
1543
|
+
if (res.code) {
|
|
1544
|
+
setErrText(res.code === "link-limit-reached" ? limitText() : wt("linksEndpointInvalid"));
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
writeLinks(res.links);
|
|
1548
|
+
setAddLabel("");
|
|
1549
|
+
setAddEndpoint("");
|
|
1550
|
+
setErrText("");
|
|
1551
|
+
}
|
|
1552
|
+
function addCli() {
|
|
1553
|
+
var res = addRow(links, buildCliRow({
|
|
1554
|
+
label: "",
|
|
1555
|
+
cliPath: addCliPath
|
|
1556
|
+
}));
|
|
1557
|
+
if (res.code) {
|
|
1558
|
+
setErrText(res.code === "link-limit-reached" ? limitText() : wt("linksAddCliExists"));
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
writeLinks(res.links);
|
|
1562
|
+
setAddCliPath("");
|
|
1563
|
+
setErrText("");
|
|
1564
|
+
}
|
|
1565
|
+
function removeOne(row) {
|
|
1566
|
+
var res = removeRow(links, row.id);
|
|
1567
|
+
writeLinks(res.links);
|
|
1568
|
+
if (res.removed && res.removed.id !== void 0 && res.removed.id === activeId) scope.set("activeTargetId", "");
|
|
1569
|
+
}
|
|
1570
|
+
function probeOne(row) {
|
|
1571
|
+
if (probingId !== "" || !isValidEndpoint(row.endpoint)) return;
|
|
1572
|
+
setProbingId(row.id);
|
|
1573
|
+
setErrText("");
|
|
1574
|
+
postJson("/bcdp/api/cdp-probe", { endpoint: row.endpoint }).then(function(data) {
|
|
1575
|
+
var outcome = data && data.value && data.value.outcome ? data.value.outcome : {
|
|
1576
|
+
ok: false,
|
|
1577
|
+
code: "probe-failed",
|
|
1578
|
+
message: "no outcome"
|
|
1579
|
+
};
|
|
1580
|
+
writeLinks(applyProbe(links, row.id, outcome, Date.now()));
|
|
1581
|
+
}).catch(function(error) {
|
|
1582
|
+
writeLinks(applyProbe(links, row.id, {
|
|
1583
|
+
ok: false,
|
|
1584
|
+
code: "probe-failed",
|
|
1585
|
+
message: String(error && error.message || error)
|
|
1586
|
+
}, Date.now()));
|
|
1587
|
+
}).then(function() {
|
|
1588
|
+
setProbingId("");
|
|
1222
1589
|
});
|
|
1223
|
-
scope.set("links", next);
|
|
1224
1590
|
}
|
|
1225
1591
|
return h("div", { style: {
|
|
1226
1592
|
borderTop: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.25))",
|
|
1227
|
-
paddingTop: "6px"
|
|
1593
|
+
paddingTop: "6px",
|
|
1594
|
+
display: "grid",
|
|
1595
|
+
gap: "4px"
|
|
1228
1596
|
} }, h("div", { style: {
|
|
1229
1597
|
fontSize: "12px",
|
|
1230
1598
|
fontWeight: 600,
|
|
1231
1599
|
color: "var(--dsw-alias-label-secondary, rgba(127,127,127,.9))",
|
|
1232
1600
|
padding: "2px 0 4px"
|
|
1233
|
-
} },
|
|
1601
|
+
} }, wt("linksTitle")), links.length === 0 ? h("div", { style: {
|
|
1234
1602
|
fontSize: "12px",
|
|
1235
1603
|
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.8))",
|
|
1236
|
-
padding: "
|
|
1237
|
-
} },
|
|
1238
|
-
var
|
|
1239
|
-
var detail = row.kind === "ego-cli" ? row.cliPath || "" : row.endpoint || "";
|
|
1604
|
+
padding: "2px 0"
|
|
1605
|
+
} }, wt("linksEmpty")) : links.map(function(row, idx) {
|
|
1606
|
+
var isCli = row.kind === "ego-cli";
|
|
1240
1607
|
var isActive = row.id !== void 0 && row.id === activeId;
|
|
1608
|
+
var probeBadge = null;
|
|
1609
|
+
if (row.probeStatus === "ok" || row.probeStatus === "error") probeBadge = h("span", {
|
|
1610
|
+
title: row.probeError || row.probeCode || "",
|
|
1611
|
+
style: {
|
|
1612
|
+
fontSize: "11px",
|
|
1613
|
+
flex: "0 0 auto",
|
|
1614
|
+
color: row.probeStatus === "ok" ? "#30d158" : "#ff453a"
|
|
1615
|
+
}
|
|
1616
|
+
}, wt(row.probeStatus === "ok" ? "linksProbeOk" : "linksProbeFail") + (row.probeStatus === "ok" && row.probeLatencyMs ? " · " + row.probeLatencyMs + "ms" : ""));
|
|
1241
1617
|
return h("div", {
|
|
1242
1618
|
key: row.id || idx,
|
|
1243
1619
|
style: {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
flexWrap: "wrap"
|
|
1620
|
+
borderTop: "1px dashed var(--dsw-alias-border-l2, rgba(127,127,127,.18))",
|
|
1621
|
+
padding: "6px 0",
|
|
1622
|
+
display: "grid",
|
|
1623
|
+
gap: "4px"
|
|
1249
1624
|
}
|
|
1250
|
-
}, h("
|
|
1625
|
+
}, h("div", { style: {
|
|
1626
|
+
display: "flex",
|
|
1627
|
+
alignItems: "center",
|
|
1628
|
+
gap: "8px",
|
|
1629
|
+
flexWrap: "wrap"
|
|
1630
|
+
} }, h("input", {
|
|
1251
1631
|
type: "checkbox",
|
|
1252
1632
|
checked: row.enabled === true,
|
|
1253
1633
|
disabled: !writable,
|
|
1254
|
-
title:
|
|
1634
|
+
title: wt("linksEnabled"),
|
|
1255
1635
|
onChange: function(e) {
|
|
1256
|
-
|
|
1636
|
+
writeLinks(updateRow(links, row.id, { enabled: e.target.checked }));
|
|
1257
1637
|
}
|
|
1258
|
-
}), h("span", { style: {
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
textOverflow: "ellipsis",
|
|
1267
|
-
whiteSpace: "nowrap",
|
|
1268
|
-
flex: "1 1 120px"
|
|
1269
|
-
} }, detail), isActive ? h("span", { style: {
|
|
1638
|
+
}), h("span", { style: badgeStyle }, isCli ? "CLI" : "CDP"), h(FamRowInput, {
|
|
1639
|
+
v: row.label || "",
|
|
1640
|
+
writable,
|
|
1641
|
+
placeholder: wt("linksLabel"),
|
|
1642
|
+
onCommit: function(v) {
|
|
1643
|
+
writeLinks(updateRow(links, row.id, { label: v }));
|
|
1644
|
+
}
|
|
1645
|
+
}), probeBadge, isActive ? h("span", { style: {
|
|
1270
1646
|
fontSize: "11px",
|
|
1271
1647
|
color: "#30d158",
|
|
1272
1648
|
flex: "0 0 auto"
|
|
1273
|
-
} },
|
|
1649
|
+
} }, wt("linksActive")) : h("button", {
|
|
1274
1650
|
type: "button",
|
|
1275
|
-
disabled: !writable,
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
fontSize: "12px",
|
|
1279
|
-
cursor: writable ? "pointer" : "not-allowed",
|
|
1280
|
-
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
|
|
1281
|
-
background: "none",
|
|
1282
|
-
color: "var(--dsw-alias-label-primary, inherit)",
|
|
1283
|
-
borderRadius: "8px",
|
|
1284
|
-
padding: "2px 10px",
|
|
1285
|
-
flex: "0 0 auto"
|
|
1286
|
-
},
|
|
1651
|
+
disabled: !writable || row.enabled === false,
|
|
1652
|
+
title: row.enabled === false ? wt("linksDisabledHint") : void 0,
|
|
1653
|
+
style: btnStyle,
|
|
1287
1654
|
onClick: function() {
|
|
1288
1655
|
scope.set("activeTargetId", row.id);
|
|
1289
1656
|
}
|
|
1290
|
-
},
|
|
1291
|
-
|
|
1657
|
+
}, wt("linksActivate"))), h("div", { style: {
|
|
1658
|
+
display: "flex",
|
|
1659
|
+
alignItems: "center",
|
|
1660
|
+
gap: "8px",
|
|
1661
|
+
flexWrap: "wrap"
|
|
1662
|
+
} }, h(FamRowInput, {
|
|
1663
|
+
v: (isCli ? row.cliPath : row.endpoint) || "",
|
|
1664
|
+
writable,
|
|
1665
|
+
placeholder: isCli ? wt("linksCliPathHint") : wt("linksEndpointHint"),
|
|
1666
|
+
onCommit: function(v) {
|
|
1667
|
+
if (isCli) {
|
|
1668
|
+
writeLinks(updateRow(links, row.id, { cliPath: v }));
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
if (!isValidEndpoint(v)) {
|
|
1672
|
+
setErrText(wt("linksEndpointInvalid"));
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
writeLinks(updateRow(links, row.id, { endpoint: v }));
|
|
1676
|
+
}
|
|
1677
|
+
}), isCli ? h("label", { style: {
|
|
1678
|
+
display: "flex",
|
|
1679
|
+
alignItems: "center",
|
|
1680
|
+
gap: "4px",
|
|
1681
|
+
fontSize: "11px",
|
|
1682
|
+
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))",
|
|
1683
|
+
flex: "0 0 auto"
|
|
1684
|
+
} }, h("input", {
|
|
1685
|
+
type: "checkbox",
|
|
1686
|
+
checked: row.useSdkPath === true,
|
|
1687
|
+
disabled: !writable,
|
|
1688
|
+
title: wt("linksCliSdk"),
|
|
1689
|
+
onChange: function(e) {
|
|
1690
|
+
writeLinks(updateRow(links, row.id, { useSdkPath: e.target.checked }));
|
|
1691
|
+
}
|
|
1692
|
+
}), wt("linksCliSdk")) : null, !isCli ? h("button", {
|
|
1693
|
+
type: "button",
|
|
1694
|
+
disabled: !writable || probingId === row.id,
|
|
1695
|
+
style: btnStyle,
|
|
1696
|
+
onClick: function() {
|
|
1697
|
+
probeOne(row);
|
|
1698
|
+
}
|
|
1699
|
+
}, probingId === row.id ? wt("linksProbing") : wt("linksProbe")) : null, h("button", {
|
|
1700
|
+
type: "button",
|
|
1701
|
+
disabled: !writable || idx === 0,
|
|
1702
|
+
title: wt("linksMoveUp"),
|
|
1703
|
+
style: btnStyle,
|
|
1704
|
+
onClick: function() {
|
|
1705
|
+
writeLinks(moveRow(links, row.id, -1));
|
|
1706
|
+
}
|
|
1707
|
+
}, "↑"), h("button", {
|
|
1708
|
+
type: "button",
|
|
1709
|
+
disabled: !writable || idx === links.length - 1,
|
|
1710
|
+
title: wt("linksMoveDown"),
|
|
1711
|
+
style: btnStyle,
|
|
1712
|
+
onClick: function() {
|
|
1713
|
+
writeLinks(moveRow(links, row.id, 1));
|
|
1714
|
+
}
|
|
1715
|
+
}, "↓"), h("button", {
|
|
1716
|
+
type: "button",
|
|
1717
|
+
disabled: !writable,
|
|
1718
|
+
title: wt("linksRemove"),
|
|
1719
|
+
style: btnStyle,
|
|
1720
|
+
onClick: function() {
|
|
1721
|
+
removeOne(row);
|
|
1722
|
+
}
|
|
1723
|
+
}, "✕"), isCli && cdpMode === "remote" ? h("span", { style: {
|
|
1724
|
+
fontSize: "11px",
|
|
1725
|
+
color: "#ff9f0a",
|
|
1726
|
+
flex: "1 1 100%"
|
|
1727
|
+
} }, wt("linksCliRemoteWarn")) : null));
|
|
1728
|
+
}), h("div", { style: {
|
|
1729
|
+
display: "grid",
|
|
1730
|
+
gap: "6px",
|
|
1731
|
+
paddingTop: "4px"
|
|
1732
|
+
} }, h("div", { style: {
|
|
1733
|
+
display: "flex",
|
|
1734
|
+
gap: "8px",
|
|
1735
|
+
alignItems: "center",
|
|
1736
|
+
flexWrap: "wrap"
|
|
1737
|
+
} }, h("input", {
|
|
1738
|
+
type: "text",
|
|
1739
|
+
value: addLabel,
|
|
1740
|
+
disabled: !writable || isFull(links),
|
|
1741
|
+
placeholder: wt("linksLabel"),
|
|
1742
|
+
style: Object.assign({ width: "96px" }, inputStyle),
|
|
1743
|
+
onChange: function(e) {
|
|
1744
|
+
setAddLabel(e.target.value);
|
|
1745
|
+
}
|
|
1746
|
+
}), h("input", {
|
|
1747
|
+
type: "text",
|
|
1748
|
+
value: addEndpoint,
|
|
1749
|
+
disabled: !writable || isFull(links),
|
|
1750
|
+
placeholder: wt("linksEndpointHint"),
|
|
1751
|
+
style: Object.assign({
|
|
1752
|
+
flex: "1 1 160px",
|
|
1753
|
+
minWidth: 0
|
|
1754
|
+
}, inputStyle),
|
|
1755
|
+
onChange: function(e) {
|
|
1756
|
+
setAddEndpoint(e.target.value);
|
|
1757
|
+
},
|
|
1758
|
+
onKeyDown: function(e) {
|
|
1759
|
+
if (e.key === "Enter") addCdp();
|
|
1760
|
+
}
|
|
1761
|
+
}), h("button", {
|
|
1762
|
+
type: "button",
|
|
1763
|
+
disabled: !writable || isFull(links),
|
|
1764
|
+
title: isFull(links) ? limitText() : void 0,
|
|
1765
|
+
style: btnStyle,
|
|
1766
|
+
onClick: addCdp
|
|
1767
|
+
}, wt("linksAddCdp"))), h("div", { style: {
|
|
1768
|
+
display: "flex",
|
|
1769
|
+
gap: "8px",
|
|
1770
|
+
alignItems: "center",
|
|
1771
|
+
flexWrap: "wrap"
|
|
1772
|
+
} }, h("input", {
|
|
1773
|
+
type: "text",
|
|
1774
|
+
value: addCliPath,
|
|
1775
|
+
disabled: !writable || isFull(links) || hasCliLink(links),
|
|
1776
|
+
placeholder: wt("linksCliPathHint"),
|
|
1777
|
+
style: Object.assign({
|
|
1778
|
+
flex: "1 1 160px",
|
|
1779
|
+
minWidth: 0
|
|
1780
|
+
}, inputStyle),
|
|
1781
|
+
onChange: function(e) {
|
|
1782
|
+
setAddCliPath(e.target.value);
|
|
1783
|
+
},
|
|
1784
|
+
onKeyDown: function(e) {
|
|
1785
|
+
if (e.key === "Enter") addCli();
|
|
1786
|
+
}
|
|
1787
|
+
}), h("button", {
|
|
1788
|
+
type: "button",
|
|
1789
|
+
disabled: !writable || isFull(links) || hasCliLink(links),
|
|
1790
|
+
title: hasCliLink(links) ? wt("linksAddCliExists") : isFull(links) ? limitText() : void 0,
|
|
1791
|
+
style: btnStyle,
|
|
1792
|
+
onClick: addCli
|
|
1793
|
+
}, wt("linksAddCli"))), errText ? h("div", { style: {
|
|
1794
|
+
fontSize: "11px",
|
|
1795
|
+
color: "#ff453a"
|
|
1796
|
+
} }, errText) : null));
|
|
1292
1797
|
}
|
|
1293
1798
|
function apply(ctx) {
|
|
1294
1799
|
mountFamilySettingsCard(ctx);
|
|
1800
|
+
mountPluginsPageCard(ctx);
|
|
1295
1801
|
var betterSidebarService;
|
|
1296
1802
|
try {
|
|
1297
1803
|
betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1",
|
|
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.2.0-rc.1+ line: declarative settings via Config .volatile() fields; for DSH 0.1.2-rc.1 ~ 0.1.7 use the 0.17.x line]",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -94,6 +94,6 @@
|
|
|
94
94
|
"url": "git+https://github.com/drscrewdriver/dsh-browser-cdp.git"
|
|
95
95
|
},
|
|
96
96
|
"publishConfig": {
|
|
97
|
-
"tag": "dsh-0.
|
|
97
|
+
"tag": "dsh-0.2.0"
|
|
98
98
|
}
|
|
99
99
|
}
|