dsh-browser-cdp 0.18.0 → 0.18.2

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/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,35 @@ 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",
285
+ linksActivate: "activate",
286
+ linksLocalRow: "Local Chrome (managed)",
287
+ linksLocalEnableHint: "Checked = auto mode may fall back to the managed local browser when the activated target is unreachable"
94
288
  };
95
289
  var watchDict = {
96
290
  en: watchEn,
@@ -148,7 +342,35 @@ var watchDict = {
148
342
  famIsolate: "空间隔离",
149
343
  famIsolateDesc: "关 = 持久化配置(重启保留登录态);开 = 每次隔离沙箱",
150
344
  famIdle: "空闲自动停止(分钟,0 = 不停)",
151
- famIdleDesc: "超过 N 分钟没有 bcdp_* 调用即停止后台浏览器,下次调用按需重启"
345
+ famIdleDesc: "超过 N 分钟没有 bcdp_* 调用即停止后台浏览器,下次调用按需重启",
346
+ linksTitle: "连接目标(顺序即优先级)",
347
+ linksEmpty: "暂无目标——用下方表单添加第一个连接目标",
348
+ linksEnabled: "启用",
349
+ linksActive: "已激活",
350
+ linksAddCdp: "添加 CDP 端点",
351
+ linksAddCli: "添加本机 ego CLI",
352
+ linksAddCliExists: "本机 ego CLI 连接已存在——仅限本机,一台机器只允许一条",
353
+ linksEndpoint: "端点",
354
+ linksEndpointHint: "http(s)://主机:端口 或 ws(s)://…",
355
+ linksEndpointInvalid: "端点无效,未保存",
356
+ linksCliPath: "ego CLI 路径",
357
+ linksCliPathHint: "留空 = 自动检测(PATH → 应用包 → 内置运行时)",
358
+ linksLabel: "标签",
359
+ linksRemove: "删除",
360
+ linksMoveUp: "上移",
361
+ linksMoveDown: "下移",
362
+ linksProbe: "探测",
363
+ linksProbing: "探测中…",
364
+ linksProbeOk: "可达",
365
+ linksProbeFail: "不可达",
366
+ linksLimitReached: "连接序列最多 {n} 条",
367
+ linksWriteFailed: "保存失败——设置层拒绝了这次写入",
368
+ linksCliRemoteWarn: "cdpMode=remote 时激活 ego CLI 会报 mode-kind-mismatch",
369
+ linksCliSdk: "使用内置 harness",
370
+ linksDisabledHint: "已停用——先勾选启用才能激活",
371
+ linksActivate: "激活",
372
+ linksLocalRow: "本机 Chrome(受管启动)",
373
+ linksLocalEnableHint: "勾选 = 允许 auto 模式在激活目标不可达时回落本机启动"
152
374
  }
153
375
  };
154
376
  function wt(key, params = void 0) {
@@ -691,6 +913,20 @@ function mountFamilySettingsCard(ctx) {
691
913
  }, FamilySettingsCard);
692
914
  }, "dsh-browser-cdp: family settings tab");
693
915
  }
916
+ function mountPluginsPageCard(ctx) {
917
+ var forms = typeof ctx.get === "function" ? ctx.get("configForms") : void 0;
918
+ if (!forms || typeof forms.get !== "function") return;
919
+ var scope = forms.get("dsh-browser-cdp");
920
+ ctx.slots.inject("plugins.bundle.config", function() {
921
+ return ctx.slots.register({
922
+ name: "plugins.bundle.config",
923
+ key: "dsh-browser-cdp",
924
+ inject: function() {
925
+ return { scope };
926
+ }
927
+ }, FamilySettingsCard);
928
+ }, "dsh-browser-cdp: plugins-page config card");
929
+ }
694
930
  var FAM_FIELD_GROUPS = [
695
931
  {
696
932
  gk: "gBasic",
@@ -1206,6 +1442,42 @@ function FamStrInput(props) {
1206
1442
  }
1207
1443
  });
1208
1444
  }
1445
+ function FamRowInput(props) {
1446
+ var h = React.createElement;
1447
+ var empty = props.v === void 0 || props.v === null ? "" : String(props.v);
1448
+ var draft = React.useState(empty);
1449
+ var v = draft[0], setV = draft[1];
1450
+ React.useEffect(function() {
1451
+ setV(props.v === void 0 || props.v === null ? "" : String(props.v));
1452
+ }, [props.v]);
1453
+ function commit() {
1454
+ if (v !== empty) props.onCommit(v);
1455
+ }
1456
+ return h("input", {
1457
+ type: "text",
1458
+ value: v,
1459
+ disabled: !props.writable,
1460
+ placeholder: props.placeholder || "",
1461
+ style: {
1462
+ flex: "1 1 140px",
1463
+ minWidth: 0,
1464
+ font: "inherit",
1465
+ fontSize: "12px",
1466
+ color: "inherit",
1467
+ background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.08))",
1468
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
1469
+ borderRadius: "8px",
1470
+ padding: "3px 8px"
1471
+ },
1472
+ onChange: function(e) {
1473
+ setV(e.target.value);
1474
+ },
1475
+ onBlur: commit,
1476
+ onKeyDown: function(e) {
1477
+ if (e.key === "Enter") commit();
1478
+ }
1479
+ });
1480
+ }
1209
1481
  function FamLinks(props) {
1210
1482
  var value = props.value;
1211
1483
  var writable = props.writable;
@@ -1213,85 +1485,369 @@ function FamLinks(props) {
1213
1485
  var h = React.createElement;
1214
1486
  var links = Array.isArray(value.links) ? value.links : [];
1215
1487
  var activeId = typeof value.activeTargetId === "string" ? value.activeTargetId : "";
1216
- function setEnabled(idx, on) {
1217
- var next = links.map(function(row, i) {
1218
- return i === idx ? {
1219
- ...row,
1220
- enabled: on
1221
- } : row;
1488
+ var cdpMode = typeof value.cdpMode === "string" ? value.cdpMode : "auto";
1489
+ var errState = React.useState("");
1490
+ var errText = errState[0], setErrText = errState[1];
1491
+ var probeState = React.useState("");
1492
+ var probingId = probeState[0], setProbingId = probeState[1];
1493
+ var addLabelState = React.useState("");
1494
+ var addLabel = addLabelState[0], setAddLabel = addLabelState[1];
1495
+ var addEndpointState = React.useState("");
1496
+ var addEndpoint = addEndpointState[0], setAddEndpoint = addEndpointState[1];
1497
+ var addCliPathState = React.useState("");
1498
+ var addCliPath = addCliPathState[0], setAddCliPath = addCliPathState[1];
1499
+ var btnStyle = {
1500
+ font: "inherit",
1501
+ fontSize: "12px",
1502
+ cursor: writable ? "pointer" : "not-allowed",
1503
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
1504
+ background: "none",
1505
+ color: "var(--dsw-alias-label-primary, inherit)",
1506
+ borderRadius: "8px",
1507
+ padding: "2px 8px",
1508
+ flex: "0 0 auto"
1509
+ };
1510
+ var badgeStyle = {
1511
+ fontSize: "10px",
1512
+ fontWeight: 600,
1513
+ letterSpacing: ".04em",
1514
+ flex: "0 0 auto",
1515
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))",
1516
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.25))",
1517
+ borderRadius: "6px",
1518
+ padding: "0 5px",
1519
+ lineHeight: "16px"
1520
+ };
1521
+ var inputStyle = {
1522
+ font: "inherit",
1523
+ fontSize: "12px",
1524
+ color: "inherit",
1525
+ background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.08))",
1526
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
1527
+ borderRadius: "8px",
1528
+ padding: "3px 8px"
1529
+ };
1530
+ function writeLinks(next) {
1531
+ Promise.resolve(scope.set("links", next)).then(function(ok) {
1532
+ if (ok === false) setErrText(wt("linksWriteFailed"));
1533
+ }, function() {
1534
+ setErrText(wt("linksWriteFailed"));
1535
+ });
1536
+ }
1537
+ function limitText() {
1538
+ return wt("linksLimitReached", { n: MAX_LINKS });
1539
+ }
1540
+ function addCdp() {
1541
+ if (!isValidEndpoint(addEndpoint)) {
1542
+ setErrText(wt("linksEndpointInvalid"));
1543
+ return;
1544
+ }
1545
+ var res = addRow(links, buildCdpRow({
1546
+ label: addLabel,
1547
+ endpoint: addEndpoint
1548
+ }));
1549
+ if (res.code) {
1550
+ setErrText(res.code === "link-limit-reached" ? limitText() : wt("linksEndpointInvalid"));
1551
+ return;
1552
+ }
1553
+ writeLinks(res.links);
1554
+ if (activeId === "") scope.set("activeTargetId", res.links[res.links.length - 1].id);
1555
+ setAddLabel("");
1556
+ setAddEndpoint("");
1557
+ setErrText("");
1558
+ }
1559
+ function addCli() {
1560
+ var res = addRow(links, buildCliRow({
1561
+ label: "",
1562
+ cliPath: addCliPath
1563
+ }));
1564
+ if (res.code) {
1565
+ setErrText(res.code === "link-limit-reached" ? limitText() : wt("linksAddCliExists"));
1566
+ return;
1567
+ }
1568
+ writeLinks(res.links);
1569
+ if (activeId === "") scope.set("activeTargetId", res.links[res.links.length - 1].id);
1570
+ setAddCliPath("");
1571
+ setErrText("");
1572
+ }
1573
+ function removeOne(row) {
1574
+ var res = removeRow(links, row.id);
1575
+ writeLinks(res.links);
1576
+ if (res.removed && res.removed.id !== void 0 && res.removed.id === activeId) scope.set("activeTargetId", "");
1577
+ }
1578
+ function probeOne(row) {
1579
+ if (probingId !== "" || !isValidEndpoint(row.endpoint)) return;
1580
+ setProbingId(row.id);
1581
+ setErrText("");
1582
+ postJson("/bcdp/api/cdp-probe", { endpoint: row.endpoint }).then(function(data) {
1583
+ var outcome = data && data.value && data.value.outcome ? data.value.outcome : {
1584
+ ok: false,
1585
+ code: "probe-failed",
1586
+ message: "no outcome"
1587
+ };
1588
+ writeLinks(applyProbe(links, row.id, outcome, Date.now()));
1589
+ }).catch(function(error) {
1590
+ writeLinks(applyProbe(links, row.id, {
1591
+ ok: false,
1592
+ code: "probe-failed",
1593
+ message: String(error && error.message || error)
1594
+ }, Date.now()));
1595
+ }).then(function() {
1596
+ setProbingId("");
1222
1597
  });
1223
- scope.set("links", next);
1224
1598
  }
1599
+ var localActive = cdpMode === "local";
1600
+ var localRow = h("div", {
1601
+ key: "fam-links-local",
1602
+ style: {
1603
+ borderTop: "1px dashed var(--dsw-alias-border-l2, rgba(127,127,127,.18))",
1604
+ padding: "6px 0",
1605
+ display: "grid",
1606
+ gap: "4px"
1607
+ }
1608
+ }, h("div", { style: {
1609
+ display: "flex",
1610
+ alignItems: "center",
1611
+ gap: "8px",
1612
+ flexWrap: "wrap"
1613
+ } }, h("input", {
1614
+ type: "checkbox",
1615
+ checked: value.allowLocalFallback === true,
1616
+ disabled: !writable,
1617
+ title: wt("linksLocalEnableHint"),
1618
+ onChange: function(e) {
1619
+ scope.set("allowLocalFallback", e.target.checked);
1620
+ }
1621
+ }), h("span", { style: badgeStyle }, "LOCAL"), h("span", { style: {
1622
+ fontSize: "13px",
1623
+ color: "var(--dsw-alias-label-primary, inherit)",
1624
+ flex: "1 1 120px",
1625
+ overflow: "hidden",
1626
+ textOverflow: "ellipsis",
1627
+ whiteSpace: "nowrap"
1628
+ } }, wt("linksLocalRow")), localActive ? h("span", { style: {
1629
+ fontSize: "11px",
1630
+ color: "#30d158",
1631
+ flex: "0 0 auto"
1632
+ } }, wt("linksActive")) : h("button", {
1633
+ type: "button",
1634
+ disabled: !writable,
1635
+ style: btnStyle,
1636
+ onClick: function() {
1637
+ scope.set("cdpMode", "local");
1638
+ }
1639
+ }, wt("linksActivate"))));
1225
1640
  return h("div", { style: {
1226
1641
  borderTop: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.25))",
1227
- paddingTop: "6px"
1642
+ paddingTop: "6px",
1643
+ display: "grid",
1644
+ gap: "4px"
1228
1645
  } }, h("div", { style: {
1229
1646
  fontSize: "12px",
1230
1647
  fontWeight: 600,
1231
1648
  color: "var(--dsw-alias-label-secondary, rgba(127,127,127,.9))",
1232
1649
  padding: "2px 0 4px"
1233
- } }, _egoLocale === "zh" ? "连接目标(顺序即优先级)" : "Connection targets (order = priority)"), links.length === 0 ? h("div", { style: {
1650
+ } }, wt("linksTitle")), links.length === 0 ? h("div", { style: {
1234
1651
  fontSize: "12px",
1235
1652
  color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.8))",
1236
- padding: "4px 0"
1237
- } }, _egoLocale === "zh" ? "暂无目标 —— 连接序列在 profile 的 cordis.patch.yml links 中维护" : "No targets — maintain the sequence in the profile cordis.patch.yml links") : links.map(function(row, idx) {
1238
- var label = row.label || row.id || "#" + idx;
1239
- var detail = row.kind === "ego-cli" ? row.cliPath || "" : row.endpoint || "";
1653
+ padding: "2px 0"
1654
+ } }, wt("linksEmpty")) : links.map(function(row, idx) {
1655
+ var isCli = row.kind === "ego-cli";
1240
1656
  var isActive = row.id !== void 0 && row.id === activeId;
1657
+ var probeBadge = null;
1658
+ if (row.probeStatus === "ok" || row.probeStatus === "error") probeBadge = h("span", {
1659
+ title: row.probeError || row.probeCode || "",
1660
+ style: {
1661
+ fontSize: "11px",
1662
+ flex: "0 0 auto",
1663
+ color: row.probeStatus === "ok" ? "#30d158" : "#ff453a"
1664
+ }
1665
+ }, wt(row.probeStatus === "ok" ? "linksProbeOk" : "linksProbeFail") + (row.probeStatus === "ok" && row.probeLatencyMs ? " · " + row.probeLatencyMs + "ms" : ""));
1241
1666
  return h("div", {
1242
1667
  key: row.id || idx,
1243
1668
  style: {
1244
- display: "flex",
1245
- alignItems: "center",
1246
- gap: "8px",
1247
- padding: "5px 0",
1248
- flexWrap: "wrap"
1669
+ borderTop: "1px dashed var(--dsw-alias-border-l2, rgba(127,127,127,.18))",
1670
+ padding: "6px 0",
1671
+ display: "grid",
1672
+ gap: "4px"
1249
1673
  }
1250
- }, h("input", {
1674
+ }, h("div", { style: {
1675
+ display: "flex",
1676
+ alignItems: "center",
1677
+ gap: "8px",
1678
+ flexWrap: "wrap"
1679
+ } }, h("input", {
1251
1680
  type: "checkbox",
1252
1681
  checked: row.enabled === true,
1253
1682
  disabled: !writable,
1254
- title: _egoLocale === "zh" ? "启用" : "Enabled",
1683
+ title: wt("linksEnabled"),
1255
1684
  onChange: function(e) {
1256
- setEnabled(idx, e.target.checked);
1685
+ writeLinks(updateRow(links, row.id, { enabled: e.target.checked }));
1257
1686
  }
1258
- }), h("span", { style: {
1259
- fontSize: "13px",
1260
- color: "var(--dsw-alias-label-primary, inherit)"
1261
- } }, label), h("span", { style: {
1262
- fontSize: "11px",
1263
- color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))",
1264
- minWidth: 0,
1265
- overflow: "hidden",
1266
- textOverflow: "ellipsis",
1267
- whiteSpace: "nowrap",
1268
- flex: "1 1 120px"
1269
- } }, detail), isActive ? h("span", { style: {
1687
+ }), h("span", { style: badgeStyle }, isCli ? "CLI" : "CDP"), h(FamRowInput, {
1688
+ v: row.label || "",
1689
+ writable,
1690
+ placeholder: wt("linksLabel"),
1691
+ onCommit: function(v) {
1692
+ writeLinks(updateRow(links, row.id, { label: v }));
1693
+ }
1694
+ }), probeBadge, isActive ? h("span", { style: {
1270
1695
  fontSize: "11px",
1271
1696
  color: "#30d158",
1272
1697
  flex: "0 0 auto"
1273
- } }, _egoLocale === "zh" ? "已激活" : "active") : h("button", {
1698
+ } }, wt("linksActive")) : h("button", {
1274
1699
  type: "button",
1275
- disabled: !writable,
1276
- style: {
1277
- font: "inherit",
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
- },
1700
+ disabled: !writable || row.enabled === false,
1701
+ title: row.enabled === false ? wt("linksDisabledHint") : void 0,
1702
+ style: btnStyle,
1287
1703
  onClick: function() {
1288
1704
  scope.set("activeTargetId", row.id);
1705
+ if (cdpMode === "local") scope.set("cdpMode", "auto");
1289
1706
  }
1290
- }, _egoLocale === "zh" ? "激活" : "activate"));
1291
- }));
1707
+ }, wt("linksActivate"))), h("div", { style: {
1708
+ display: "flex",
1709
+ alignItems: "center",
1710
+ gap: "8px",
1711
+ flexWrap: "wrap"
1712
+ } }, h(FamRowInput, {
1713
+ v: (isCli ? row.cliPath : row.endpoint) || "",
1714
+ writable,
1715
+ placeholder: isCli ? wt("linksCliPathHint") : wt("linksEndpointHint"),
1716
+ onCommit: function(v) {
1717
+ if (isCli) {
1718
+ writeLinks(updateRow(links, row.id, { cliPath: v }));
1719
+ return;
1720
+ }
1721
+ if (!isValidEndpoint(v)) {
1722
+ setErrText(wt("linksEndpointInvalid"));
1723
+ return;
1724
+ }
1725
+ writeLinks(updateRow(links, row.id, { endpoint: v }));
1726
+ }
1727
+ }), isCli ? h("label", { style: {
1728
+ display: "flex",
1729
+ alignItems: "center",
1730
+ gap: "4px",
1731
+ fontSize: "11px",
1732
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))",
1733
+ flex: "0 0 auto"
1734
+ } }, h("input", {
1735
+ type: "checkbox",
1736
+ checked: row.useSdkPath === true,
1737
+ disabled: !writable,
1738
+ title: wt("linksCliSdk"),
1739
+ onChange: function(e) {
1740
+ writeLinks(updateRow(links, row.id, { useSdkPath: e.target.checked }));
1741
+ }
1742
+ }), wt("linksCliSdk")) : null, !isCli ? h("button", {
1743
+ type: "button",
1744
+ disabled: !writable || probingId === row.id,
1745
+ style: btnStyle,
1746
+ onClick: function() {
1747
+ probeOne(row);
1748
+ }
1749
+ }, probingId === row.id ? wt("linksProbing") : wt("linksProbe")) : null, h("button", {
1750
+ type: "button",
1751
+ disabled: !writable || idx === 0,
1752
+ title: wt("linksMoveUp"),
1753
+ style: btnStyle,
1754
+ onClick: function() {
1755
+ writeLinks(moveRow(links, row.id, -1));
1756
+ }
1757
+ }, "↑"), h("button", {
1758
+ type: "button",
1759
+ disabled: !writable || idx === links.length - 1,
1760
+ title: wt("linksMoveDown"),
1761
+ style: btnStyle,
1762
+ onClick: function() {
1763
+ writeLinks(moveRow(links, row.id, 1));
1764
+ }
1765
+ }, "↓"), h("button", {
1766
+ type: "button",
1767
+ disabled: !writable,
1768
+ title: wt("linksRemove"),
1769
+ style: btnStyle,
1770
+ onClick: function() {
1771
+ removeOne(row);
1772
+ }
1773
+ }, "✕"), isCli && cdpMode === "remote" ? h("span", { style: {
1774
+ fontSize: "11px",
1775
+ color: "#ff9f0a",
1776
+ flex: "1 1 100%"
1777
+ } }, wt("linksCliRemoteWarn")) : null));
1778
+ }), localRow, h("div", { style: {
1779
+ display: "grid",
1780
+ gap: "6px",
1781
+ paddingTop: "4px"
1782
+ } }, h("div", { style: {
1783
+ display: "flex",
1784
+ gap: "8px",
1785
+ alignItems: "center",
1786
+ flexWrap: "wrap"
1787
+ } }, h("input", {
1788
+ type: "text",
1789
+ value: addLabel,
1790
+ disabled: !writable || isFull(links),
1791
+ placeholder: wt("linksLabel"),
1792
+ style: Object.assign({ width: "96px" }, inputStyle),
1793
+ onChange: function(e) {
1794
+ setAddLabel(e.target.value);
1795
+ }
1796
+ }), h("input", {
1797
+ type: "text",
1798
+ value: addEndpoint,
1799
+ disabled: !writable || isFull(links),
1800
+ placeholder: wt("linksEndpointHint"),
1801
+ style: Object.assign({
1802
+ flex: "1 1 160px",
1803
+ minWidth: 0
1804
+ }, inputStyle),
1805
+ onChange: function(e) {
1806
+ setAddEndpoint(e.target.value);
1807
+ },
1808
+ onKeyDown: function(e) {
1809
+ if (e.key === "Enter") addCdp();
1810
+ }
1811
+ }), h("button", {
1812
+ type: "button",
1813
+ disabled: !writable || isFull(links),
1814
+ title: isFull(links) ? limitText() : void 0,
1815
+ style: btnStyle,
1816
+ onClick: addCdp
1817
+ }, wt("linksAddCdp"))), h("div", { style: {
1818
+ display: "flex",
1819
+ gap: "8px",
1820
+ alignItems: "center",
1821
+ flexWrap: "wrap"
1822
+ } }, h("input", {
1823
+ type: "text",
1824
+ value: addCliPath,
1825
+ disabled: !writable || isFull(links) || hasCliLink(links),
1826
+ placeholder: wt("linksCliPathHint"),
1827
+ style: Object.assign({
1828
+ flex: "1 1 160px",
1829
+ minWidth: 0
1830
+ }, inputStyle),
1831
+ onChange: function(e) {
1832
+ setAddCliPath(e.target.value);
1833
+ },
1834
+ onKeyDown: function(e) {
1835
+ if (e.key === "Enter") addCli();
1836
+ }
1837
+ }), h("button", {
1838
+ type: "button",
1839
+ disabled: !writable || isFull(links) || hasCliLink(links),
1840
+ title: hasCliLink(links) ? wt("linksAddCliExists") : isFull(links) ? limitText() : void 0,
1841
+ style: btnStyle,
1842
+ onClick: addCli
1843
+ }, wt("linksAddCli"))), errText ? h("div", { style: {
1844
+ fontSize: "11px",
1845
+ color: "#ff453a"
1846
+ } }, errText) : null));
1292
1847
  }
1293
1848
  function apply(ctx) {
1294
1849
  mountFamilySettingsCard(ctx);
1850
+ mountPluginsPageCard(ctx);
1295
1851
  var betterSidebarService;
1296
1852
  try {
1297
1853
  betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;