dsh-browser-cdp 0.17.17 → 0.17.19
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 +1 -1
- package/lib/client.js +123 -65
- package/lib/index.js +30 -17
- package/package.json +1 -1
package/dsh-plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -3065,6 +3065,7 @@ function apply(ctx) {
|
|
|
3065
3065
|
mountFamilySettingsCard(ctx);
|
|
3066
3066
|
mountPluginsPageCard(ctx);
|
|
3067
3067
|
mountPicksDockCard(ctx);
|
|
3068
|
+
mountPicksBadge(ctx);
|
|
3068
3069
|
var betterSidebarService;
|
|
3069
3070
|
try {
|
|
3070
3071
|
betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;
|
|
@@ -4306,22 +4307,24 @@ var TAB_CSS = `
|
|
|
4306
4307
|
* attachments are — the block carries its source CDP connection
|
|
4307
4308
|
* (endpoint + targetId) so the agent can find the element's DOM again
|
|
4308
4309
|
* (backendNodeId is directly addressable via bcdp_cdp DOM.describeNode).
|
|
4309
|
-
* Format inside the draft
|
|
4310
|
-
*
|
|
4311
|
-
*
|
|
4312
|
-
* [
|
|
4310
|
+
* Format inside the draft(@mention 精髓:被替换字段以 @ 开头):
|
|
4311
|
+
* @"picks/<file>.json"
|
|
4312
|
+
* — 显示层把该 token 替换成文件片;归档 JSON
|
|
4313
|
+
* {"cdpEndpoint":..., "targetId":..., "pageUrl":..., "elements":[...]}
|
|
4314
|
+
* 存 <workspace>/picks/<file>.json,dock 卡按引用取回渲染。
|
|
4313
4315
|
*/
|
|
4314
4316
|
function injectPickCardStyles() {
|
|
4315
4317
|
if (document.getElementById("dsh-cdp-picks-styles") !== null) return;
|
|
4316
4318
|
var style = document.createElement("style");
|
|
4317
4319
|
style.id = "dsh-cdp-picks-styles";
|
|
4318
|
-
style.textContent = "[data-dsh-cdp-picks-card] {\n box-sizing: border-box; flex: none;\n display: grid; gap: 4px; padding: 8px 10px;\n font: inherit; font-size: 12px;\n color: #1d1d1f; background: #f7f7f9;\n border: 1px solid rgba(0, 0, 0, 0.16); border-radius: 12px;\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);\n /* input-traffic
|
|
4320
|
+
style.textContent = "[data-dsh-cdp-picks-card] {\n box-sizing: border-box; flex: none;\n display: grid; gap: 4px; padding: 8px 10px;\n font: inherit; font-size: 12px;\n color: #1d1d1f; background: #f7f7f9;\n border: 1px solid rgba(0, 0, 0, 0.16); border-radius: 12px;\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);\n /* input-traffic 同款限宽 + 居中:卡宽限制在内容列(拖动范围)内,两侧留出\n clearance,auto margins 在 dock 带内居中,永不顶满整窗 */\n margin-left: auto;\n margin-right: auto;\n width: min(\n calc(100% - var(--dsh-composer-side-clearance, 16px) - var(--dsh-composer-side-clearance, 16px) - var(--dsh-composer-dock-inset, 8px) - var(--dsh-composer-dock-inset, 8px)),\n calc(var(--dsh-chat-content-width, 100%) - var(--dsh-composer-dock-inset, 8px) - var(--dsh-composer-dock-inset, 8px))\n );\n overflow-y: auto; max-height: 40vh;\n}\n@media (prefers-color-scheme: dark) {\n [data-dsh-cdp-picks-card] { color: #f2f2f7; background: #1c1c1e; border-color: rgba(255, 255, 255, 0.18); }\n}\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-sub { font-size: 11px; color: rgba(60, 60, 67, 0.62); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-chip { display: flex; align-items: baseline; gap: 6px; padding: 3px 8px; background: rgba(120, 120, 128, 0.12); border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; min-width: 0; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-num { font-weight: 700; flex: none; color: rgba(60, 60, 67, 0.62); }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-tag { font-weight: 600; flex: none; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-close { margin-left: auto; flex: none; font: inherit; font-size: 12px; cursor: pointer; border: none; background: none; color: rgba(60, 60, 67, 0.62); padding: 0 2px; border-radius: 6px; }\n[data-dsh-cdp-picks-card] .dsh-cdp-picks-close:hover { background: rgba(120, 120, 128, 0.18); }\n@media (prefers-color-scheme: dark) {\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-sub { color: rgba(235, 235, 245, 0.62); }\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-chip { background: rgba(120, 120, 128, 0.24); border-color: rgba(255, 255, 255, 0.12); }\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-num { color: rgba(235, 235, 245, 0.62); }\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-close { color: rgba(235, 235, 245, 0.62); }\n [data-dsh-cdp-picks-card] .dsh-cdp-picks-close:hover { background: rgba(120, 120, 128, 0.3); }\n}";
|
|
4319
4321
|
document.head.appendChild(style);
|
|
4320
4322
|
}
|
|
4321
4323
|
function CdpPicksDockCard(props) {
|
|
4322
4324
|
var input = props.input;
|
|
4323
4325
|
var h = React.createElement;
|
|
4324
|
-
var
|
|
4326
|
+
var tick = React.useState(0);
|
|
4327
|
+
var setTick = tick[1];
|
|
4325
4328
|
React.useEffect(function() {
|
|
4326
4329
|
var timer = window.setInterval(function() {
|
|
4327
4330
|
setTick(function(n) {
|
|
@@ -4333,13 +4336,10 @@ function CdpPicksDockCard(props) {
|
|
|
4333
4336
|
};
|
|
4334
4337
|
}, []);
|
|
4335
4338
|
var snap = readDraftText(input);
|
|
4336
|
-
var refRe =
|
|
4339
|
+
var refRe = /@"(picks\/[^"\s]+\.json)"/g;
|
|
4337
4340
|
var refs = [], mm;
|
|
4338
4341
|
while ((mm = refRe.exec(snap)) !== null) refs.push({
|
|
4339
4342
|
file: mm[1],
|
|
4340
|
-
endpoint: mm[2],
|
|
4341
|
-
title: mm[3],
|
|
4342
|
-
count: Number(mm[4]),
|
|
4343
4343
|
line: mm[0]
|
|
4344
4344
|
});
|
|
4345
4345
|
try {
|
|
@@ -4357,8 +4357,10 @@ function CdpPicksDockCard(props) {
|
|
|
4357
4357
|
React.useEffect(function() {
|
|
4358
4358
|
var cancelled = false;
|
|
4359
4359
|
refs.forEach(function(r) {
|
|
4360
|
-
|
|
4361
|
-
|
|
4360
|
+
postJson("/bcdp/api/picks-load", {
|
|
4361
|
+
file: r.file.slice(6),
|
|
4362
|
+
session: props.session
|
|
4363
|
+
}).then(function(res) {
|
|
4362
4364
|
if (cancelled) return;
|
|
4363
4365
|
var content = res && res.ok !== false && res.value ? String(res.value.content || "") : "";
|
|
4364
4366
|
setContents(function(prev) {
|
|
@@ -4371,7 +4373,7 @@ function CdpPicksDockCard(props) {
|
|
|
4371
4373
|
return function() {
|
|
4372
4374
|
cancelled = true;
|
|
4373
4375
|
};
|
|
4374
|
-
}, [filesKey]);
|
|
4376
|
+
}, [filesKey, Math.floor(tick[0] / 5)]);
|
|
4375
4377
|
if (refs.length === 0) return null;
|
|
4376
4378
|
function removeRef(line) {
|
|
4377
4379
|
var cur = readDraftText(input);
|
|
@@ -4387,11 +4389,13 @@ function CdpPicksDockCard(props) {
|
|
|
4387
4389
|
} }, refs.map(function(r) {
|
|
4388
4390
|
var content = contents[r.file];
|
|
4389
4391
|
var elements = [];
|
|
4392
|
+
var pageTitle = "";
|
|
4390
4393
|
if (typeof content === "string" && content !== "") try {
|
|
4391
4394
|
var obj = JSON.parse(content);
|
|
4392
4395
|
elements = obj && obj.elements || [];
|
|
4396
|
+
pageTitle = obj && obj.pageTitle || "";
|
|
4393
4397
|
} catch (e) {}
|
|
4394
|
-
var head = h("div", { className: "dsh-cdp-picks-head" }, h("span", { style: { fontWeight: 700 } }, "🌐 " + wt("pickCardTitle")), h("span", { className: "dsh-cdp-picks-sub" },
|
|
4398
|
+
var head = h("div", { className: "dsh-cdp-picks-head" }, h("span", { style: { fontWeight: 700 } }, "🌐 " + wt("pickCardTitle")), h("span", { className: "dsh-cdp-picks-sub" }, "@" + r.file), h("span", { className: "dsh-cdp-picks-sub" }, pageTitle), h("span", { className: "dsh-cdp-picks-sub" }, typeof content === "string" ? wt("pickCardElements", { n: elements.length }) : "…"), h("button", {
|
|
4395
4399
|
type: "button",
|
|
4396
4400
|
title: wt("pickCardRemove"),
|
|
4397
4401
|
className: "dsh-cdp-picks-close",
|
|
@@ -4421,6 +4425,50 @@ function CdpPicksDockCard(props) {
|
|
|
4421
4425
|
}, head, chips);
|
|
4422
4426
|
}));
|
|
4423
4427
|
}
|
|
4428
|
+
function CdpPicksBadge(props) {
|
|
4429
|
+
var h = React.createElement;
|
|
4430
|
+
var setTick = React.useState(0)[1];
|
|
4431
|
+
React.useEffect(function() {
|
|
4432
|
+
var timer = window.setInterval(function() {
|
|
4433
|
+
setTick(function(n) {
|
|
4434
|
+
return n + 1;
|
|
4435
|
+
});
|
|
4436
|
+
}, 1e3);
|
|
4437
|
+
return function() {
|
|
4438
|
+
window.clearInterval(timer);
|
|
4439
|
+
};
|
|
4440
|
+
}, []);
|
|
4441
|
+
var refs = [];
|
|
4442
|
+
try {
|
|
4443
|
+
if (props && props.sessionId !== void 0 && props.sessionId !== null ? String(props.sessionId) : null) {
|
|
4444
|
+
var draft = typeof props.getDraft === "function" ? String(props.getDraft() || "") : "";
|
|
4445
|
+
var refRe = /@"(picks\/[^"\s]+\.json)"/g;
|
|
4446
|
+
var mm;
|
|
4447
|
+
while ((mm = refRe.exec(draft)) !== null) refs.push({ file: mm[1] });
|
|
4448
|
+
}
|
|
4449
|
+
} catch (e) {}
|
|
4450
|
+
try {
|
|
4451
|
+
window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, { badgeRefs: refs.length });
|
|
4452
|
+
} catch (e) {}
|
|
4453
|
+
if (refs.length === 0) return null;
|
|
4454
|
+
return h("div", { className: "dsh-cdp-picks-badges" }, refs.map(function(r, i) {
|
|
4455
|
+
return h("span", {
|
|
4456
|
+
key: r.file,
|
|
4457
|
+
className: "dsh-cdp-picks-badge",
|
|
4458
|
+
title: "🌐 @" + r.file
|
|
4459
|
+
}, "🌐" + (refs.length > 1 ? " " + (i + 1) : ""));
|
|
4460
|
+
}));
|
|
4461
|
+
}
|
|
4462
|
+
function mountPicksBadge(ctx) {
|
|
4463
|
+
ctx.slots.inject("conversation.input.overlay", function() {
|
|
4464
|
+
return ctx.slots.register({
|
|
4465
|
+
name: "conversation.input.overlay",
|
|
4466
|
+
id: "dsh-browser-cdp.picks-badge",
|
|
4467
|
+
order: 110,
|
|
4468
|
+
label: "dsh-browser-cdp picks badge"
|
|
4469
|
+
}, CdpPicksBadge);
|
|
4470
|
+
}, "dsh-browser-cdp: picks badge");
|
|
4471
|
+
}
|
|
4424
4472
|
function mountPicksDockCard(ctx) {
|
|
4425
4473
|
injectPickCardStyles();
|
|
4426
4474
|
try {
|
|
@@ -4433,14 +4481,22 @@ function mountPicksDockCard(ctx) {
|
|
|
4433
4481
|
locale: "dsh-browser-cdp",
|
|
4434
4482
|
order: 0,
|
|
4435
4483
|
inject: function(sessionId) {
|
|
4436
|
-
var input = null;
|
|
4484
|
+
var input = null, session = null;
|
|
4437
4485
|
try {
|
|
4438
4486
|
var actx = ctx.sessions.scope(sessionId);
|
|
4439
4487
|
input = actx.get("conversation").input.for(actx);
|
|
4488
|
+
session = String(sessionId);
|
|
4440
4489
|
} catch (e) {
|
|
4441
4490
|
input = null;
|
|
4491
|
+
session = null;
|
|
4442
4492
|
}
|
|
4443
|
-
return {
|
|
4493
|
+
return {
|
|
4494
|
+
input,
|
|
4495
|
+
session,
|
|
4496
|
+
getDraft: function() {
|
|
4497
|
+
return readDraftText(input);
|
|
4498
|
+
}
|
|
4499
|
+
};
|
|
4444
4500
|
}
|
|
4445
4501
|
}, CdpPicksDockCard);
|
|
4446
4502
|
}, "dsh-browser-cdp: picks dock card");
|
|
@@ -4515,67 +4571,69 @@ function deliverPickToConversation(ctx, element, action) {
|
|
|
4515
4571
|
focusable: !!element.keyboardFocusable,
|
|
4516
4572
|
describe
|
|
4517
4573
|
};
|
|
4518
|
-
var reRef =
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
mm[
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4574
|
+
var reRef = /@"(picks\/([^"\s]+\.json))"/g;
|
|
4575
|
+
var mentions = [], mm;
|
|
4576
|
+
while ((mm = reRef.exec(draft)) !== null) mentions.push({
|
|
4577
|
+
token: mm[0],
|
|
4578
|
+
file: mm[2]
|
|
4579
|
+
});
|
|
4580
|
+
(async function() {
|
|
4581
|
+
try {
|
|
4582
|
+
var found = null, hit = null, obj = null;
|
|
4583
|
+
for (var i = 0; i < mentions.length; i++) {
|
|
4584
|
+
var lres = await postJson("/bcdp/api/picks-load", {
|
|
4585
|
+
file: mentions[i].file,
|
|
4586
|
+
session: sessionId
|
|
4587
|
+
});
|
|
4588
|
+
if (!lres || lres.ok === false || !lres.value) continue;
|
|
4589
|
+
obj = JSON.parse(lres.value.content);
|
|
4590
|
+
if (obj && obj.cdpEndpoint === src.endpoint) {
|
|
4591
|
+
found = mentions[i];
|
|
4592
|
+
hit = obj.elements || [];
|
|
4593
|
+
break;
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
if (found) {
|
|
4532
4597
|
var maxN = 0;
|
|
4533
|
-
for (var k = 0; k <
|
|
4598
|
+
for (var k = 0; k < hit.length; k++) if (hit[k].n > maxN) maxN = hit[k].n;
|
|
4534
4599
|
entry.n = maxN + 1;
|
|
4535
|
-
|
|
4600
|
+
hit.push(Object.assign({}, entry));
|
|
4536
4601
|
var page = {
|
|
4537
4602
|
cdpEndpoint: obj.cdpEndpoint || src.endpoint,
|
|
4538
4603
|
targetId: obj.targetId || src.targetId,
|
|
4539
4604
|
pageUrl: obj.pageUrl || src.pageUrl,
|
|
4540
4605
|
pageTitle: obj.pageTitle || src.pageTitle,
|
|
4541
|
-
elements:
|
|
4606
|
+
elements: hit
|
|
4542
4607
|
};
|
|
4543
|
-
postJson("/bcdp/api/picks-save", {
|
|
4608
|
+
await postJson("/bcdp/api/picks-save", {
|
|
4544
4609
|
block: JSON.stringify(page, null, 2),
|
|
4545
|
-
file
|
|
4610
|
+
file: found.file,
|
|
4611
|
+
session: sessionId
|
|
4546
4612
|
});
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
block: JSON.stringify(pageNew, null, 2),
|
|
4568
|
-
file: newFile
|
|
4569
|
-
}).then(function(res) {
|
|
4570
|
-
if (!res || res.ok === false || !res.value) return;
|
|
4571
|
-
var cur = readDraftText(input);
|
|
4572
|
-
var line = "[🌐 CDP-PICKS → " + res.value.file + " | " + src.endpoint + " | " + (src.pageTitle || src.pageUrl || "") + " | elements:1]";
|
|
4573
|
-
cur = cur ? cur + (cur.charAt(cur.length - 1) === "\n" ? "" : "\n") + line : line;
|
|
4574
|
-
input.setDraft(cur);
|
|
4575
|
-
}).catch(function() {});
|
|
4613
|
+
return;
|
|
4614
|
+
}
|
|
4615
|
+
var pageNew = {
|
|
4616
|
+
cdpEndpoint: src.endpoint,
|
|
4617
|
+
targetId: src.targetId,
|
|
4618
|
+
pageUrl: src.pageUrl,
|
|
4619
|
+
pageTitle: src.pageTitle,
|
|
4620
|
+
elements: [Object.assign({ n: 1 }, entry)]
|
|
4621
|
+
};
|
|
4622
|
+
var sres = await postJson("/bcdp/api/picks-save", {
|
|
4623
|
+
block: JSON.stringify(pageNew, null, 2),
|
|
4624
|
+
session: sessionId
|
|
4625
|
+
});
|
|
4626
|
+
if (!sres || sres.ok === false || !sres.value) return;
|
|
4627
|
+
var token = "@\"picks/" + sres.value.file + "\"";
|
|
4628
|
+
var cur = readDraftText(input);
|
|
4629
|
+
cur = cur ? cur + (cur.charAt(cur.length - 1) === "\n" ? "" : "\n") + token : token;
|
|
4630
|
+
input.setDraft(cur);
|
|
4631
|
+
} catch (e) {}
|
|
4632
|
+
})();
|
|
4576
4633
|
return {
|
|
4577
4634
|
ok: true,
|
|
4578
|
-
code: "archiving"
|
|
4635
|
+
code: "archiving",
|
|
4636
|
+
count: 1
|
|
4579
4637
|
};
|
|
4580
4638
|
} catch (err) {
|
|
4581
4639
|
return {
|
package/lib/index.js
CHANGED
|
@@ -2733,19 +2733,6 @@ function normalizeProbeState(link) {
|
|
|
2733
2733
|
/** HTTP route prefix owning every ego-browser API request. */
|
|
2734
2734
|
const API_PREFIX = "/bcdp/api";
|
|
2735
2735
|
/**
|
|
2736
|
-
* Archive dir for CDP-PICKS blocks: the composer holds a one-line reference
|
|
2737
|
-
* and the raw JSON lives here (the dsh-paste-dock content model — the raw
|
|
2738
|
-
* expanded text must not flood the input). Plugin-namespaced subdir under
|
|
2739
|
-
* the same state root the cast worker uses.
|
|
2740
|
-
*/
|
|
2741
|
-
function picksDir() {
|
|
2742
|
-
const e = process.env;
|
|
2743
|
-
const isWin = process.platform === "win32";
|
|
2744
|
-
const home = e.HOME || e.USERPROFILE || (isWin ? e.LOCALAPPDATA || "" : "/root");
|
|
2745
|
-
const stateHome = e.EGO_LINUX_STATE_DIR || (isWin ? e.LOCALAPPDATA || `${home}\\AppData\\Local` : e.XDG_STATE_HOME || `${home}/.local/state`);
|
|
2746
|
-
return stateHome.endsWith("ego-lite-linux") ? resolve(stateHome, "picks") : resolve(stateHome, "ego-lite-linux", "picks");
|
|
2747
|
-
}
|
|
2748
|
-
/**
|
|
2749
2736
|
* Register the `/bcdp/api` HTTP route on the host's web server.
|
|
2750
2737
|
*
|
|
2751
2738
|
* The route reads/writes the `ego-browser` settings namespace in-process
|
|
@@ -2753,7 +2740,7 @@ function picksDir() {
|
|
|
2753
2740
|
* when absent, `get` degrades to the entry source and `set` returns a
|
|
2754
2741
|
* clear error.
|
|
2755
2742
|
*/
|
|
2756
|
-
function registerEgoBrowserGateway(ctx, bridge, ffmpegManager) {
|
|
2743
|
+
function registerEgoBrowserGateway(ctx, bridge, ffmpegManager, picks) {
|
|
2757
2744
|
ctx.effect?.(() => {
|
|
2758
2745
|
const webServer = ctx.get?.("webServer");
|
|
2759
2746
|
if (!webServer || typeof webServer.register !== "function") return;
|
|
@@ -2848,6 +2835,12 @@ function registerEgoBrowserGateway(ctx, bridge, ffmpegManager) {
|
|
|
2848
2835
|
}
|
|
2849
2836
|
writeJson(res, 200, envelopeOk({ outcome: await probeEndpoint(endpoint, { timeoutMs: typeof body.timeoutMs === "number" && Number.isFinite(body.timeoutMs) ? body.timeoutMs : void 0 }) }));
|
|
2850
2837
|
} else if (method === "picks-save") {
|
|
2838
|
+
const picksSession = typeof body.session === "string" ? body.session : void 0;
|
|
2839
|
+
const picksDir0 = picks ? picks.resolveDir(picksSession) : void 0;
|
|
2840
|
+
if (!picksDir0) {
|
|
2841
|
+
writeJson(res, 409, envelopeError("no-workspace", "no registered workspace resolves for this session"));
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2851
2844
|
const saveBody = body;
|
|
2852
2845
|
const block = typeof saveBody.block === "string" ? saveBody.block : "";
|
|
2853
2846
|
if (block === "") {
|
|
@@ -2855,7 +2848,7 @@ function registerEgoBrowserGateway(ctx, bridge, ffmpegManager) {
|
|
|
2855
2848
|
return;
|
|
2856
2849
|
}
|
|
2857
2850
|
const file = typeof saveBody.file === "string" && /^[A-Za-z0-9._-]+\.json$/.test(saveBody.file) ? saveBody.file : `picks-${Date.now()}.json`;
|
|
2858
|
-
const dir =
|
|
2851
|
+
const dir = picksDir0;
|
|
2859
2852
|
await mkdir(dir, { recursive: true });
|
|
2860
2853
|
const target = resolve(dir, file);
|
|
2861
2854
|
if (!target.startsWith(resolve(dir))) {
|
|
@@ -2868,6 +2861,12 @@ function registerEgoBrowserGateway(ctx, bridge, ffmpegManager) {
|
|
|
2868
2861
|
file
|
|
2869
2862
|
}));
|
|
2870
2863
|
} else if (method === "picks-load") {
|
|
2864
|
+
const loadSession = typeof body.session === "string" ? body.session : void 0;
|
|
2865
|
+
const loadDir0 = picks ? picks.resolveDir(loadSession) : void 0;
|
|
2866
|
+
if (!loadDir0) {
|
|
2867
|
+
writeJson(res, 409, envelopeError("no-workspace", "no registered workspace resolves for this session"));
|
|
2868
|
+
return;
|
|
2869
|
+
}
|
|
2871
2870
|
const loadBody = body;
|
|
2872
2871
|
const file = typeof loadBody.file === "string" && /^[A-Za-z0-9._-]+\.json$/.test(loadBody.file) ? loadBody.file : "";
|
|
2873
2872
|
if (file === "") {
|
|
@@ -2875,7 +2874,7 @@ function registerEgoBrowserGateway(ctx, bridge, ffmpegManager) {
|
|
|
2875
2874
|
return;
|
|
2876
2875
|
}
|
|
2877
2876
|
try {
|
|
2878
|
-
writeJson(res, 200, envelopeOk({ content: await readFile(resolve(
|
|
2877
|
+
writeJson(res, 200, envelopeOk({ content: await readFile(resolve(loadDir0, file), "utf8") }));
|
|
2879
2878
|
} catch (error) {
|
|
2880
2879
|
writeJson(res, 404, envelopeError("not-found", error instanceof Error ? error.message : String(error)));
|
|
2881
2880
|
}
|
|
@@ -7098,7 +7097,21 @@ function apply(ctx, config = {}) {
|
|
|
7098
7097
|
ctx.logger?.warn?.(`dsh-browser-cdp: cast server init failed: ${err?.message ?? err}`);
|
|
7099
7098
|
}
|
|
7100
7099
|
try {
|
|
7101
|
-
registerEgoBrowserGateway(wctx, bridge, ffmpegManager)
|
|
7100
|
+
registerEgoBrowserGateway(wctx, bridge, ffmpegManager, { resolveDir: (sessionId) => {
|
|
7101
|
+
try {
|
|
7102
|
+
const registry = typeof ctx.get === "function" ? ctx.get("workspaceRegistry") : void 0;
|
|
7103
|
+
const workspaces = (registry ? registry.list() : []) ?? [];
|
|
7104
|
+
if (workspaces.length === 0) return void 0;
|
|
7105
|
+
if (sessionId) {
|
|
7106
|
+
const owned = workspaces.find((w) => w.sessionIds.includes(sessionId));
|
|
7107
|
+
if (owned) return owned.path + "/picks";
|
|
7108
|
+
}
|
|
7109
|
+
if (workspaces.length === 1) return workspaces[0].path + "/picks";
|
|
7110
|
+
return;
|
|
7111
|
+
} catch {
|
|
7112
|
+
return;
|
|
7113
|
+
}
|
|
7114
|
+
} });
|
|
7102
7115
|
} catch (err) {
|
|
7103
7116
|
ctx.logger?.warn?.(`dsh-browser-cdp: capability gateway init failed: ${err?.message ?? err}`);
|
|
7104
7117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.19",
|
|
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",
|