dsh-browser-cdp 0.17.15 → 0.17.17
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 +132 -133
- package/lib/index.js +45 -0
- package/package.json +1 -1
package/dsh-plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -4311,6 +4311,13 @@ var TAB_CSS = `
|
|
|
4311
4311
|
* {"cdpEndpoint":..., "targetId":..., "pageUrl":..., "elements":[{n,backendNodeId,tag,id,name,focusable,describe}]}
|
|
4312
4312
|
* [/CDP-PICKS]
|
|
4313
4313
|
*/
|
|
4314
|
+
function injectPickCardStyles() {
|
|
4315
|
+
if (document.getElementById("dsh-cdp-picks-styles") !== null) return;
|
|
4316
|
+
var style = document.createElement("style");
|
|
4317
|
+
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 同款限宽:卡宽被限制在内容列(拖动范围)内,两侧留出\n clearance,永不顶满整窗 */\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
|
+
document.head.appendChild(style);
|
|
4320
|
+
}
|
|
4314
4321
|
function CdpPicksDockCard(props) {
|
|
4315
4322
|
var input = props.input;
|
|
4316
4323
|
var h = React.createElement;
|
|
@@ -4325,126 +4332,97 @@ function CdpPicksDockCard(props) {
|
|
|
4325
4332
|
window.clearInterval(timer);
|
|
4326
4333
|
};
|
|
4327
4334
|
}, []);
|
|
4328
|
-
var
|
|
4329
|
-
var
|
|
4330
|
-
var
|
|
4331
|
-
while ((mm =
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
title: mm[1],
|
|
4339
|
-
endpoint: mm[3],
|
|
4340
|
-
elements,
|
|
4341
|
-
block: mm[0]
|
|
4342
|
-
});
|
|
4343
|
-
}
|
|
4335
|
+
var snap = readDraftText(input);
|
|
4336
|
+
var refRe = /\[🌐 CDP-PICKS → ([^\s|]+) \| ([^|]*) \| ([^|]*) \| elements:(\d+)[^\]]*\]/g;
|
|
4337
|
+
var refs = [], mm;
|
|
4338
|
+
while ((mm = refRe.exec(snap)) !== null) refs.push({
|
|
4339
|
+
file: mm[1],
|
|
4340
|
+
endpoint: mm[2],
|
|
4341
|
+
title: mm[3],
|
|
4342
|
+
count: Number(mm[4]),
|
|
4343
|
+
line: mm[0]
|
|
4344
|
+
});
|
|
4344
4345
|
try {
|
|
4345
4346
|
window.__dshBrowserCdpDeco = {
|
|
4346
|
-
stage:
|
|
4347
|
-
|
|
4348
|
-
draftLen:
|
|
4347
|
+
stage: refs.length ? "rendered" : "no-refs",
|
|
4348
|
+
refs: refs.length,
|
|
4349
|
+
draftLen: snap.length
|
|
4349
4350
|
};
|
|
4350
4351
|
} catch (e) {}
|
|
4351
|
-
|
|
4352
|
-
|
|
4352
|
+
var loadedState = React.useState({});
|
|
4353
|
+
var contents = loadedState[0], setContents = loadedState[1];
|
|
4354
|
+
var filesKey = refs.map(function(r) {
|
|
4355
|
+
return r.file;
|
|
4356
|
+
}).join("|");
|
|
4357
|
+
React.useEffect(function() {
|
|
4358
|
+
var cancelled = false;
|
|
4359
|
+
refs.forEach(function(r) {
|
|
4360
|
+
if (contents[r.file] !== void 0) return;
|
|
4361
|
+
postJson("/bcdp/api/picks-load", { file: r.file }).then(function(res) {
|
|
4362
|
+
if (cancelled) return;
|
|
4363
|
+
var content = res && res.ok !== false && res.value ? String(res.value.content || "") : "";
|
|
4364
|
+
setContents(function(prev) {
|
|
4365
|
+
var n = Object.assign({}, prev);
|
|
4366
|
+
n[r.file] = content;
|
|
4367
|
+
return n;
|
|
4368
|
+
});
|
|
4369
|
+
}).catch(function() {});
|
|
4370
|
+
});
|
|
4371
|
+
return function() {
|
|
4372
|
+
cancelled = true;
|
|
4373
|
+
};
|
|
4374
|
+
}, [filesKey]);
|
|
4375
|
+
if (refs.length === 0) return null;
|
|
4376
|
+
function removeRef(line) {
|
|
4353
4377
|
var cur = readDraftText(input);
|
|
4354
|
-
var idx = cur.indexOf(
|
|
4378
|
+
var idx = cur.indexOf(line);
|
|
4355
4379
|
if (idx < 0) return;
|
|
4356
|
-
var next = cur.slice(0, idx) + cur.slice(idx +
|
|
4380
|
+
var next = cur.slice(0, idx) + cur.slice(idx + line.length);
|
|
4357
4381
|
next = next.replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
4358
4382
|
input.setDraft(next);
|
|
4359
4383
|
}
|
|
4360
|
-
var cardStyle = {
|
|
4361
|
-
display: "grid",
|
|
4362
|
-
gap: "4px",
|
|
4363
|
-
padding: "8px 10px",
|
|
4364
|
-
font: "inherit",
|
|
4365
|
-
fontSize: "12px",
|
|
4366
|
-
color: "var(--dsw-alias-label-primary, inherit)",
|
|
4367
|
-
background: "var(--dsw-alias-bg-surface, rgba(127,127,127,.14))",
|
|
4368
|
-
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
|
|
4369
|
-
borderRadius: "12px",
|
|
4370
|
-
boxSizing: "border-box"
|
|
4371
|
-
};
|
|
4372
|
-
var headStyle = {
|
|
4373
|
-
display: "flex",
|
|
4374
|
-
alignItems: "center",
|
|
4375
|
-
gap: "6px",
|
|
4376
|
-
flexWrap: "wrap"
|
|
4377
|
-
};
|
|
4378
|
-
var subStyle = {
|
|
4379
|
-
fontSize: "11px",
|
|
4380
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
|
|
4381
|
-
overflow: "hidden",
|
|
4382
|
-
textOverflow: "ellipsis",
|
|
4383
|
-
whiteSpace: "nowrap",
|
|
4384
|
-
minWidth: 0
|
|
4385
|
-
};
|
|
4386
|
-
var chipStyle = {
|
|
4387
|
-
display: "flex",
|
|
4388
|
-
alignItems: "baseline",
|
|
4389
|
-
gap: "6px",
|
|
4390
|
-
padding: "3px 8px",
|
|
4391
|
-
background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.1))",
|
|
4392
|
-
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))",
|
|
4393
|
-
borderRadius: "8px",
|
|
4394
|
-
minWidth: 0
|
|
4395
|
-
};
|
|
4396
|
-
var numStyle = {
|
|
4397
|
-
fontWeight: 700,
|
|
4398
|
-
flex: "0 0 auto",
|
|
4399
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))"
|
|
4400
|
-
};
|
|
4401
|
-
var tagStyle = {
|
|
4402
|
-
fontWeight: 600,
|
|
4403
|
-
flex: "0 0 auto"
|
|
4404
|
-
};
|
|
4405
|
-
var descStyle = {
|
|
4406
|
-
overflow: "hidden",
|
|
4407
|
-
textOverflow: "ellipsis",
|
|
4408
|
-
whiteSpace: "nowrap",
|
|
4409
|
-
minWidth: 0
|
|
4410
|
-
};
|
|
4411
|
-
var closeStyle = {
|
|
4412
|
-
marginLeft: "auto",
|
|
4413
|
-
flex: "0 0 auto",
|
|
4414
|
-
font: "inherit",
|
|
4415
|
-
fontSize: "12px",
|
|
4416
|
-
cursor: "pointer",
|
|
4417
|
-
border: "none",
|
|
4418
|
-
background: "none",
|
|
4419
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
|
|
4420
|
-
padding: "0 2px"
|
|
4421
|
-
};
|
|
4422
4384
|
return h("div", { style: {
|
|
4423
4385
|
display: "grid",
|
|
4424
4386
|
gap: "6px"
|
|
4425
|
-
} },
|
|
4426
|
-
var
|
|
4387
|
+
} }, refs.map(function(r) {
|
|
4388
|
+
var content = contents[r.file];
|
|
4389
|
+
var elements = [];
|
|
4390
|
+
if (typeof content === "string" && content !== "") try {
|
|
4391
|
+
var obj = JSON.parse(content);
|
|
4392
|
+
elements = obj && obj.elements || [];
|
|
4393
|
+
} 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" }, (r.endpoint || "") + " · " + (r.title || "")), h("span", { className: "dsh-cdp-picks-sub" }, wt("pickCardElements", { n: r.count })), h("button", {
|
|
4427
4395
|
type: "button",
|
|
4428
4396
|
title: wt("pickCardRemove"),
|
|
4429
|
-
|
|
4397
|
+
className: "dsh-cdp-picks-close",
|
|
4430
4398
|
onClick: function() {
|
|
4431
|
-
|
|
4399
|
+
removeRef(r.line);
|
|
4432
4400
|
}
|
|
4433
4401
|
}, "✕"));
|
|
4434
|
-
var chips =
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4402
|
+
var chips = [];
|
|
4403
|
+
if (typeof content !== "string") chips.push(h("div", {
|
|
4404
|
+
key: "loading",
|
|
4405
|
+
className: "dsh-cdp-picks-sub"
|
|
4406
|
+
}, "…"));
|
|
4407
|
+
for (var i = 0; i < elements.length && i < 6; i++) {
|
|
4408
|
+
var el = elements[i] || {};
|
|
4409
|
+
chips.push(h("div", {
|
|
4410
|
+
key: el.n || i,
|
|
4411
|
+
className: "dsh-cdp-picks-chip"
|
|
4412
|
+
}, h("span", { className: "dsh-cdp-picks-num" }, "#" + (el.n || i + 1)), h("span", { className: "dsh-cdp-picks-tag" }, el.tag || "?"), h("span", { className: "dsh-cdp-picks-desc" }, el.describe || el.name || "")));
|
|
4413
|
+
}
|
|
4414
|
+
if (elements.length > 6) chips.push(h("div", {
|
|
4415
|
+
key: "more",
|
|
4416
|
+
className: "dsh-cdp-picks-sub"
|
|
4417
|
+
}, "… +" + (elements.length - 6)));
|
|
4441
4418
|
return h("div", {
|
|
4442
|
-
key:
|
|
4443
|
-
|
|
4419
|
+
key: r.file,
|
|
4420
|
+
"data-dsh-cdp-picks-card": ""
|
|
4444
4421
|
}, head, chips);
|
|
4445
4422
|
}));
|
|
4446
4423
|
}
|
|
4447
4424
|
function mountPicksDockCard(ctx) {
|
|
4425
|
+
injectPickCardStyles();
|
|
4448
4426
|
try {
|
|
4449
4427
|
window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, { stage: "registered" });
|
|
4450
4428
|
} catch (e) {}
|
|
@@ -4461,13 +4439,6 @@ function mountPicksDockCard(ctx) {
|
|
|
4461
4439
|
input = actx.get("conversation").input.for(actx);
|
|
4462
4440
|
} catch (e) {
|
|
4463
4441
|
input = null;
|
|
4464
|
-
try {
|
|
4465
|
-
window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, {
|
|
4466
|
-
stage: "inject-failed",
|
|
4467
|
-
error: String(e && e.message || e),
|
|
4468
|
-
sessionId: String(sessionId)
|
|
4469
|
-
});
|
|
4470
|
-
} catch (e2) {}
|
|
4471
4442
|
}
|
|
4472
4443
|
return { input };
|
|
4473
4444
|
}
|
|
@@ -4536,6 +4507,7 @@ function deliverPickToConversation(ctx, element, action) {
|
|
|
4536
4507
|
pageTitle: ""
|
|
4537
4508
|
};
|
|
4538
4509
|
var entry = {
|
|
4510
|
+
n: 1,
|
|
4539
4511
|
backendNodeId: element.backendNodeId,
|
|
4540
4512
|
tag: element.tag,
|
|
4541
4513
|
id: element.id,
|
|
@@ -4543,40 +4515,67 @@ function deliverPickToConversation(ctx, element, action) {
|
|
|
4543
4515
|
focusable: !!element.keyboardFocusable,
|
|
4544
4516
|
describe
|
|
4545
4517
|
};
|
|
4546
|
-
var
|
|
4547
|
-
while ((mm =
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4518
|
+
var reRef = /\[🌐 CDP-PICKS → ([^\s|]+) \| ([^|]*) \| ([^|]*) \| elements:(\d+)[^\]]*\]/g, file = null, oldLine = null, mm;
|
|
4519
|
+
while ((mm = reRef.exec(draft)) !== null) if (mm[2] === src.endpoint) {
|
|
4520
|
+
file = mm[1];
|
|
4521
|
+
mm[2];
|
|
4522
|
+
oldLine = mm[0];
|
|
4523
|
+
Number(mm[4]);
|
|
4524
|
+
break;
|
|
4525
|
+
}
|
|
4526
|
+
if (file !== null) {
|
|
4527
|
+
postJson("/bcdp/api/picks-load", { file }).then(function(lres) {
|
|
4528
|
+
try {
|
|
4529
|
+
if (!lres || lres.ok === false || !lres.value) return;
|
|
4530
|
+
var obj = JSON.parse(lres.value.content);
|
|
4531
|
+
var list = obj && obj.elements ? obj.elements : [];
|
|
4532
|
+
var maxN = 0;
|
|
4533
|
+
for (var k = 0; k < list.length; k++) if (list[k].n > maxN) maxN = list[k].n;
|
|
4534
|
+
entry.n = maxN + 1;
|
|
4535
|
+
list.push(Object.assign({}, entry));
|
|
4536
|
+
var page = {
|
|
4537
|
+
cdpEndpoint: obj.cdpEndpoint || src.endpoint,
|
|
4538
|
+
targetId: obj.targetId || src.targetId,
|
|
4539
|
+
pageUrl: obj.pageUrl || src.pageUrl,
|
|
4540
|
+
pageTitle: obj.pageTitle || src.pageTitle,
|
|
4541
|
+
elements: list
|
|
4542
|
+
};
|
|
4543
|
+
postJson("/bcdp/api/picks-save", {
|
|
4544
|
+
block: JSON.stringify(page, null, 2),
|
|
4545
|
+
file
|
|
4546
|
+
});
|
|
4547
|
+
var cur = readDraftText(input);
|
|
4548
|
+
var newLine = "[🌐 CDP-PICKS → " + file + " | " + src.endpoint + " | " + (page.pageTitle || "") + " | elements:" + list.length + "]";
|
|
4549
|
+
var idx = cur.indexOf(oldLine);
|
|
4550
|
+
if (idx >= 0) input.setDraft(cur.slice(0, idx) + newLine + cur.slice(idx + oldLine.length));
|
|
4551
|
+
} catch (e) {}
|
|
4552
|
+
}).catch(function() {});
|
|
4553
|
+
return {
|
|
4554
|
+
ok: true,
|
|
4555
|
+
code: "archiving"
|
|
4556
|
+
};
|
|
4557
|
+
}
|
|
4558
|
+
var pageNew = {
|
|
4557
4559
|
cdpEndpoint: src.endpoint,
|
|
4558
4560
|
targetId: src.targetId,
|
|
4559
4561
|
pageUrl: src.pageUrl,
|
|
4560
|
-
pageTitle: src.pageTitle
|
|
4562
|
+
pageTitle: src.pageTitle,
|
|
4563
|
+
elements: [Object.assign({ n: 1 }, entry)]
|
|
4561
4564
|
};
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
var block = "[🌐 CDP-PICKS page=\"" + String(src.pageTitle || src.pageUrl || "").replace(/"/g, "'") + "\" targetId=\"" + src.targetId + "\" endpoint=\"" + src.endpoint + "\"]\n" + JSON.stringify(page, null, 2) + "\n[/CDP-PICKS]";
|
|
4574
|
-
draft = draft ? draft + (draft.charAt(draft.length - 1) === "\n" ? "" : "\n") + block : block;
|
|
4575
|
-
input.setDraft(draft);
|
|
4565
|
+
var newFile = "picks-" + Date.now() + ".json";
|
|
4566
|
+
postJson("/bcdp/api/picks-save", {
|
|
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() {});
|
|
4576
4576
|
return {
|
|
4577
4577
|
ok: true,
|
|
4578
|
-
code: "
|
|
4579
|
-
count: page.elements.length
|
|
4578
|
+
code: "archiving"
|
|
4580
4579
|
};
|
|
4581
4580
|
} catch (err) {
|
|
4582
4581
|
return {
|
package/lib/index.js
CHANGED
|
@@ -2733,6 +2733,19 @@ 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
|
+
/**
|
|
2736
2749
|
* Register the `/bcdp/api` HTTP route on the host's web server.
|
|
2737
2750
|
*
|
|
2738
2751
|
* The route reads/writes the `ego-browser` settings namespace in-process
|
|
@@ -2834,6 +2847,38 @@ function registerEgoBrowserGateway(ctx, bridge, ffmpegManager) {
|
|
|
2834
2847
|
return;
|
|
2835
2848
|
}
|
|
2836
2849
|
writeJson(res, 200, envelopeOk({ outcome: await probeEndpoint(endpoint, { timeoutMs: typeof body.timeoutMs === "number" && Number.isFinite(body.timeoutMs) ? body.timeoutMs : void 0 }) }));
|
|
2850
|
+
} else if (method === "picks-save") {
|
|
2851
|
+
const saveBody = body;
|
|
2852
|
+
const block = typeof saveBody.block === "string" ? saveBody.block : "";
|
|
2853
|
+
if (block === "") {
|
|
2854
|
+
writeJson(res, 400, envelopeError("invalid-block", "block is required"));
|
|
2855
|
+
return;
|
|
2856
|
+
}
|
|
2857
|
+
const file = typeof saveBody.file === "string" && /^[A-Za-z0-9._-]+\.json$/.test(saveBody.file) ? saveBody.file : `picks-${Date.now()}.json`;
|
|
2858
|
+
const dir = picksDir();
|
|
2859
|
+
await mkdir(dir, { recursive: true });
|
|
2860
|
+
const target = resolve(dir, file);
|
|
2861
|
+
if (!target.startsWith(resolve(dir))) {
|
|
2862
|
+
writeJson(res, 400, envelopeError("invalid-path", "path escapes the picks dir"));
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
await writeFile(target, block, "utf8");
|
|
2866
|
+
writeJson(res, 200, envelopeOk({
|
|
2867
|
+
path: target,
|
|
2868
|
+
file
|
|
2869
|
+
}));
|
|
2870
|
+
} else if (method === "picks-load") {
|
|
2871
|
+
const loadBody = body;
|
|
2872
|
+
const file = typeof loadBody.file === "string" && /^[A-Za-z0-9._-]+\.json$/.test(loadBody.file) ? loadBody.file : "";
|
|
2873
|
+
if (file === "") {
|
|
2874
|
+
writeJson(res, 400, envelopeError("invalid-file", "file is required"));
|
|
2875
|
+
return;
|
|
2876
|
+
}
|
|
2877
|
+
try {
|
|
2878
|
+
writeJson(res, 200, envelopeOk({ content: await readFile(resolve(picksDir(), file), "utf8") }));
|
|
2879
|
+
} catch (error) {
|
|
2880
|
+
writeJson(res, 404, envelopeError("not-found", error instanceof Error ? error.message : String(error)));
|
|
2881
|
+
}
|
|
2837
2882
|
} else writeJson(res, 404, envelopeError("not-found", `unknown ego-browser API method "${method}"`));
|
|
2838
2883
|
} catch (error) {
|
|
2839
2884
|
const e = error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.17",
|
|
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",
|