dsh-browser-cdp 0.17.9 → 0.17.11

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/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": "0.17.9",
5
+ "version": "0.17.11",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
package/lib/client.js CHANGED
@@ -166,6 +166,8 @@ const zh = {
166
166
  "linksDisabledHint": "已停用——先勾选启用才能激活",
167
167
  "linksLocalRow": "本机 Chrome(受管启动)",
168
168
  "linksLocalEnableHint": "勾选 = 允许 auto 模式在激活目标不可达时回落本机启动",
169
+ "pickCardTitle": "浏览器点选内容",
170
+ "pickCardElements": "已选 {n} 个元素",
169
171
  "linksActivate": "激活"
170
172
  };
171
173
  /** English dictionary, checked complete against the zh key set. */
@@ -314,6 +316,8 @@ const en = {
314
316
  "linksDisabledHint": "Disabled — enable it before activating",
315
317
  "linksLocalRow": "Local Chrome (managed)",
316
318
  "linksLocalEnableHint": "Checked = auto mode may fall back to the managed local browser when the activated target is unreachable",
319
+ "pickCardTitle": "Browser picks",
320
+ "pickCardElements": "{n} element(s) picked",
317
321
  "linksActivate": "activate"
318
322
  };
319
323
  /** Japanese dictionary, checked complete against the zh key set. */
@@ -462,6 +466,8 @@ const ja = {
462
466
  "linksDisabledHint": "無効 — アクティブ化する前に有効化してください",
463
467
  "linksLocalRow": "ローカル Chrome(管理起動)",
464
468
  "linksLocalEnableHint": "チェック = アクティブなターゲットに到達できない場合、auto モードはローカル起動にフォールバックします",
469
+ "pickCardTitle": "ブラウザ選択内容",
470
+ "pickCardElements": "{n} 個の要素を選択",
465
471
  "linksActivate": "アクティブ化"
466
472
  };
467
473
  /** Korean dictionary, checked complete against the zh key set. */
@@ -610,6 +616,8 @@ const ko = {
610
616
  "linksDisabledHint": "비활성 — 활성화하기 전에 사용으로 설정하세요",
611
617
  "linksLocalRow": "로컬 Chrome(관리 시작)",
612
618
  "linksLocalEnableHint": "체크 = 활성 대상에 도달할 수 없을 때 auto 모드가 로컬 시작으로 대체됩니다",
619
+ "pickCardTitle": "브라우저 선택 내용",
620
+ "pickCardElements": "{n}개 요소 선택됨",
613
621
  "linksActivate": "활성화"
614
622
  };
615
623
  /** French dictionary, checked complete against the zh key set. */
@@ -758,6 +766,8 @@ const fr = {
758
766
  "linksDisabledHint": "Désactivé — activez-le avant de le rendre actif",
759
767
  "linksLocalRow": "Chrome local (gestionné)",
760
768
  "linksLocalEnableHint": "Coché = le mode auto peut basculer vers le navigateur local si la cible activée est injoignable",
769
+ "pickCardTitle": "Sélections du navigateur",
770
+ "pickCardElements": "{n} élément(s) sélectionné(s)",
761
771
  "linksActivate": "activer"
762
772
  };
763
773
  /** German dictionary, checked complete against the zh key set. */
@@ -906,6 +916,8 @@ const de = {
906
916
  "linksDisabledHint": "Deaktiviert — erst aktivieren, dann aktiv schalten",
907
917
  "linksLocalRow": "Lokales Chrome (verwaltet)",
908
918
  "linksLocalEnableHint": "Aktiviert = der Auto-Modus darf auf den verwalteten lokalen Browser ausweichen, wenn das aktivierte Ziel nicht erreichbar ist",
919
+ "pickCardTitle": "Browser-Auswahlen",
920
+ "pickCardElements": "{n} Element(e) ausgewählt",
909
921
  "linksActivate": "aktivieren"
910
922
  };
911
923
  /** Italian dictionary, checked complete against the zh key set. */
@@ -1054,6 +1066,8 @@ const it = {
1054
1066
  "linksDisabledHint": "Disabilitato — abilitalo prima di attivarlo",
1055
1067
  "linksLocalRow": "Chrome locale (gestito)",
1056
1068
  "linksLocalEnableHint": "Selezionato = la modalità auto può ripiegare sul browser locale gestito se la destinazione attiva è irraggiungibile",
1069
+ "pickCardTitle": "Selezioni del browser",
1070
+ "pickCardElements": "{n} elemento/i selezionato/i",
1057
1071
  "linksActivate": "attiva"
1058
1072
  };
1059
1073
  /** Russian dictionary, checked complete against the zh key set. */
@@ -1202,6 +1216,8 @@ const ru = {
1202
1216
  "linksDisabledHint": "Отключено — сначала включите, затем активируйте",
1203
1217
  "linksLocalRow": "Локальный Chrome (управляемый)",
1204
1218
  "linksLocalEnableHint": "Отмечено = режим auto может откатиться на управляемый локальный браузер, если активная цель недоступна",
1219
+ "pickCardTitle": "Выбранное в браузере",
1220
+ "pickCardElements": "Выбрано элементов: {n}",
1205
1221
  "linksActivate": "активировать"
1206
1222
  };
1207
1223
  /** Spanish dictionary, checked complete against the zh key set. */
@@ -1350,6 +1366,8 @@ const es = {
1350
1366
  "linksDisabledHint": "Desactivado — actívalo antes de activarlo",
1351
1367
  "linksLocalRow": "Chrome local (gestionado)",
1352
1368
  "linksLocalEnableHint": "Marcado = el modo auto puede replegarse al navegador local gestionado si el destino activo no responde",
1369
+ "pickCardTitle": "Selecciones del navegador",
1370
+ "pickCardElements": "{n} elemento(s) seleccionado(s)",
1353
1371
  "linksActivate": "activar"
1354
1372
  };
1355
1373
  /** All nine dictionaries, handed to the locale service in ONE register call. */
@@ -1558,7 +1576,9 @@ function bindSnapshotSelector(source) {
1558
1576
  const inject = [
1559
1577
  "slots",
1560
1578
  "locale",
1561
- "connection"
1579
+ "connection",
1580
+ "sessions",
1581
+ "conversation"
1562
1582
  ];
1563
1583
  var _egoLocale = (function() {
1564
1584
  try {
@@ -4285,130 +4305,138 @@ var TAB_CSS = `
4285
4305
  function mountComposerDecoration(ctx) {
4286
4306
  var cards = [];
4287
4307
  var lastSig = "";
4308
+ var diag = {
4309
+ stage: "init",
4310
+ error: "",
4311
+ anchor: false,
4312
+ cards: 0,
4313
+ draftLen: -1
4314
+ };
4315
+ try {
4316
+ window.__dshBrowserCdpDeco = diag;
4317
+ } catch (e) {}
4318
+ var CARD_STYLE = {
4319
+ position: "fixed",
4320
+ zIndex: "9998",
4321
+ display: "grid",
4322
+ gap: "4px",
4323
+ padding: "8px 10px",
4324
+ font: "inherit",
4325
+ fontSize: "12px",
4326
+ color: "var(--dsw-alias-label-primary, inherit)",
4327
+ background: "var(--dsw-alias-bg-surface, rgba(127,127,127,.14))",
4328
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
4329
+ borderRadius: "12px",
4330
+ boxShadow: "0 8px 24px rgba(0,0,0,.18)",
4331
+ boxSizing: "border-box",
4332
+ pointerEvents: "auto"
4333
+ };
4334
+ var HEAD_STYLE = {
4335
+ display: "flex",
4336
+ alignItems: "center",
4337
+ gap: "6px",
4338
+ flexWrap: "wrap"
4339
+ };
4340
+ var SUB_STYLE = {
4341
+ fontSize: "11px",
4342
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
4343
+ overflow: "hidden",
4344
+ textOverflow: "ellipsis",
4345
+ whiteSpace: "nowrap",
4346
+ minWidth: 0
4347
+ };
4348
+ var CHIP_STYLE = {
4349
+ display: "flex",
4350
+ alignItems: "baseline",
4351
+ gap: "6px",
4352
+ padding: "3px 8px",
4353
+ background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.1))",
4354
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))",
4355
+ borderRadius: "8px",
4356
+ minWidth: 0
4357
+ };
4358
+ var NUM_STYLE = {
4359
+ fontWeight: 700,
4360
+ flex: "0 0 auto",
4361
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))"
4362
+ };
4363
+ var TAG_STYLE = {
4364
+ fontWeight: 600,
4365
+ flex: "0 0 auto"
4366
+ };
4367
+ var DESC_STYLE = {
4368
+ overflow: "hidden",
4369
+ textOverflow: "ellipsis",
4370
+ whiteSpace: "nowrap",
4371
+ minWidth: 0
4372
+ };
4288
4373
  function hide() {
4289
4374
  for (var i = 0; i < cards.length; i++) {
4290
4375
  var el = cards[i];
4291
- el && el.parentNode && el.parentNode.removeChild(el);
4376
+ if (el && el.parentNode) el.parentNode.removeChild(el);
4292
4377
  }
4293
4378
  cards = [];
4379
+ diag.cards = 0;
4294
4380
  }
4295
- function ensureAnchor() {
4296
- var input = document.querySelector("[data-composer-input]");
4297
- if (!input || !input.parentNode) return null;
4298
- return input.parentNode;
4299
- }
4300
- function cardStyle() {
4301
- return {
4302
- display: "grid",
4303
- gap: "4px",
4304
- margin: "0 0 6px",
4305
- padding: "8px 10px",
4306
- font: "inherit",
4307
- fontSize: "12px",
4308
- color: "var(--dsw-alias-label-primary, inherit)",
4309
- background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.08))",
4310
- border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.3))",
4311
- borderRadius: "12px",
4312
- boxSizing: "border-box",
4313
- width: "100%"
4314
- };
4381
+ function el2(tag, style, text) {
4382
+ var el = document.createElement(tag);
4383
+ if (style) for (var k in style) el.style[k] = style[k];
4384
+ if (text !== void 0 && text !== null && text !== "") el.textContent = String(text);
4385
+ return el;
4315
4386
  }
4316
- function chipStyle() {
4317
- return {
4318
- display: "flex",
4319
- alignItems: "baseline",
4320
- gap: "6px",
4321
- padding: "3px 8px",
4322
- background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.1))",
4323
- border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))",
4324
- borderRadius: "8px",
4325
- minWidth: 0
4326
- };
4387
+ function composerEl() {
4388
+ var el = document.querySelector("[data-composer-input]");
4389
+ if (!el) el = document.querySelector("[data-composer-input] [contenteditable=\"true\"]");
4390
+ if (!el) el = document.querySelector("[contenteditable=\"true\"]");
4391
+ if (!el) el = document.querySelector("textarea");
4392
+ return el;
4327
4393
  }
4328
- function render(pageTitle, endpoint, pageUrl, elements) {
4329
- var anchor = ensureAnchor();
4330
- if (!anchor) {
4394
+ function render(pageTitle, endpoint, elements) {
4395
+ var comp = composerEl();
4396
+ if (!comp) {
4397
+ diag.stage = "no-composer";
4398
+ diag.anchor = false;
4331
4399
  hide();
4332
4400
  return;
4333
4401
  }
4402
+ diag.anchor = true;
4403
+ var rect = comp.getBoundingClientRect();
4334
4404
  hide();
4335
- var h = React.createElement;
4336
- var head = h("div", { style: {
4337
- display: "flex",
4338
- alignItems: "center",
4339
- gap: "6px",
4340
- flexWrap: "wrap"
4341
- } }, h("span", { style: badgeLike() }, "🌐"), h("span", { style: { fontWeight: 600 } }, wt("pickCardTitle")), h("span", { style: {
4342
- color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
4343
- overflow: "hidden",
4344
- textOverflow: "ellipsis",
4345
- whiteSpace: "nowrap",
4346
- minWidth: 0
4347
- } }, (endpoint || "") + " · " + (pageTitle || pageUrl || "")), h("span", { style: {
4348
- color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
4349
- flex: "0 0 auto"
4350
- } }, wt("pickCardElements", { n: elements.length })));
4351
- var chips = elements.slice(0, 6).map(function(el) {
4352
- return h("div", {
4353
- key: el.n,
4354
- style: chipStyle()
4355
- }, h("span", { style: {
4356
- fontWeight: 700,
4357
- flex: "0 0 auto",
4358
- color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))"
4359
- } }, "#" + el.n), h("span", { style: {
4360
- fontWeight: 600,
4361
- flex: "0 0 auto"
4362
- } }, el.tag || "?"), h("span", { style: {
4363
- overflow: "hidden",
4364
- textOverflow: "ellipsis",
4365
- whiteSpace: "nowrap",
4366
- minWidth: 0
4367
- } }, el.describe || el.name || ""));
4368
- });
4369
- if (elements.length > 6) chips.push(h("div", { style: {
4370
- fontSize: "11px",
4371
- color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))"
4372
- } }, "… +" + (elements.length - 6)));
4373
4405
  var card = document.createElement("div");
4374
4406
  card.setAttribute("data-dsh-cdp-picks-card", "");
4375
- var host = null;
4376
- try {
4377
- host = renderToDom(h("div", { style: cardStyle() }, head, chips));
4378
- } catch (e) {
4379
- host = null;
4407
+ var cs = card.style;
4408
+ for (var k in CARD_STYLE) cs[k] = CARD_STYLE[k];
4409
+ card.style.left = Math.max(8, rect.left) + "px";
4410
+ card.style.width = Math.min(Math.max(rect.width, 240), 620) + "px";
4411
+ card.style.bottom = Math.max(8, window.innerHeight - rect.top + 8) + "px";
4412
+ card.style.maxHeight = "40vh";
4413
+ card.style.overflowY = "auto";
4414
+ var head = el2("div", HEAD_STYLE);
4415
+ head.appendChild(el2("span", { fontWeight: 700 }, "🌐 " + wt("pickCardTitle")));
4416
+ head.appendChild(el2("span", SUB_STYLE, (endpoint || "") + " · " + (pageTitle || "")));
4417
+ head.appendChild(el2("span", SUB_STYLE, wt("pickCardElements", { n: elements.length })));
4418
+ card.appendChild(head);
4419
+ var limit = Math.min(elements.length, 6);
4420
+ for (var i = 0; i < limit; i++) {
4421
+ var el = elements[i] || {};
4422
+ var chip = el2("div", CHIP_STYLE);
4423
+ chip.appendChild(el2("span", NUM_STYLE, "#" + (el.n || i + 1)));
4424
+ chip.appendChild(el2("span", TAG_STYLE, el.tag || "?"));
4425
+ chip.appendChild(el2("span", DESC_STYLE, el.describe || el.name || ""));
4426
+ card.appendChild(chip);
4380
4427
  }
4381
- if (!host) return;
4382
- card.appendChild(host);
4383
- anchor.insertBefore(card, anchor.firstChild);
4428
+ if (elements.length > 6) card.appendChild(el2("div", SUB_STYLE, "… +" + (elements.length - 6)));
4429
+ document.body.appendChild(card);
4384
4430
  cards.push(card);
4385
- }
4386
- function badgeLike() {
4387
- return {
4388
- fontSize: "12px",
4389
- lineHeight: "16px"
4390
- };
4391
- }
4392
- function renderToDom(vdom) {
4393
- if (vdom === null || vdom === void 0 || vdom === false) return document.createTextNode("");
4394
- if (typeof vdom === "string" || typeof vdom === "number") return document.createTextNode(String(vdom));
4395
- if (Array.isArray(vdom)) {
4396
- var frag = document.createDocumentFragment();
4397
- for (var i = 0; i < vdom.length; i++) frag.appendChild(renderToDom(vdom[i]));
4398
- return frag;
4399
- }
4400
- var el = document.createElement(vdom.type || "div");
4401
- var props = vdom.props || {};
4402
- if (props.style) for (var k in props.style) el.style[k] = props.style[k];
4403
- if (props.key) el.setAttribute("data-key", String(props.key));
4404
- var children = props.children;
4405
- el.appendChild(renderToDom(children === void 0 ? null : children));
4406
- return el;
4431
+ diag.cards = cards.length;
4432
+ diag.stage = "rendered";
4407
4433
  }
4408
4434
  function tick() {
4435
+ diag.stage = "tick";
4409
4436
  try {
4410
4437
  var sid = currentSessionId(ctx.sessions.list.getSnapshot());
4411
4438
  if (!sid) {
4439
+ diag.stage = "no-session";
4412
4440
  if (lastSig !== "") {
4413
4441
  lastSig = "";
4414
4442
  hide();
@@ -4416,13 +4444,23 @@ function mountComposerDecoration(ctx) {
4416
4444
  return;
4417
4445
  }
4418
4446
  var conversation = ctx.get("conversation");
4419
- if (!conversation || !conversation.input) return;
4447
+ if (!conversation || !conversation.input) {
4448
+ diag.stage = "no-conversation";
4449
+ return;
4450
+ }
4420
4451
  var actx = ctx.sessions.scope(sid);
4421
- if (!actx) return;
4452
+ if (!actx) {
4453
+ diag.stage = "no-scope";
4454
+ return;
4455
+ }
4422
4456
  var input = conversation.input.for(actx);
4423
4457
  var snap = input && input.state && input.state.getSnapshot ? input.state.getSnapshot() : null;
4424
4458
  var draft = snap && typeof snap.draft === "string" ? snap.draft : "";
4425
- if (draft === lastSig) return;
4459
+ diag.draftLen = draft.length;
4460
+ if (draft === lastSig) {
4461
+ diag.stage = "same-draft";
4462
+ return;
4463
+ }
4426
4464
  lastSig = draft;
4427
4465
  var re = /\[(?:🌐 )?CDP-PICKS page="([^"]*)" targetId="([^"]*)" endpoint="([^"]*)"\]\n([\s\S]*?)\n\[\/CDP-PICKS\]/g;
4428
4466
  var found = [], mm;
@@ -4434,17 +4472,20 @@ function mountComposerDecoration(ctx) {
4434
4472
  } catch (e) {}
4435
4473
  found.push({
4436
4474
  title: mm[1],
4437
- targetId: mm[2],
4438
4475
  endpoint: mm[3],
4439
4476
  elements
4440
4477
  });
4441
4478
  }
4442
4479
  if (found.length === 0) {
4480
+ diag.stage = "no-blocks";
4443
4481
  hide();
4444
4482
  return;
4445
4483
  }
4446
- for (var i = 0; i < found.length; i++) render(found[i].title, found[i].endpoint, found[i].title, found[i].elements);
4447
- } catch (e) {}
4484
+ for (var i = 0; i < found.length; i++) render(found[i].title, found[i].endpoint, found[i].elements);
4485
+ } catch (e) {
4486
+ diag.stage = "error";
4487
+ diag.error = String(e && e.message || e);
4488
+ }
4448
4489
  }
4449
4490
  var timer = window.setInterval(tick, 1e3);
4450
4491
  tick();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "0.17.9",
3
+ "version": "0.17.11",
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+ line: declarative settings via Config .volatile() fields; for DSH 0.1.2-rc.1 ~ 0.1.6 use the 0.16.x line]",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",