dsh-browser-cdp 0.18.12 → 0.18.14
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
|
@@ -3103,6 +3103,13 @@ var TAB_CSS = `
|
|
|
3103
3103
|
* {"cdpEndpoint":..., "targetId":..., "pageUrl":..., "elements":[{n,backendNodeId,tag,id,name,focusable,describe}]}
|
|
3104
3104
|
* [/CDP-PICKS]
|
|
3105
3105
|
*/
|
|
3106
|
+
function injectPickCardStyles() {
|
|
3107
|
+
if (document.getElementById("dsh-cdp-picks-styles") !== null) return;
|
|
3108
|
+
var style = document.createElement("style");
|
|
3109
|
+
style.id = "dsh-cdp-picks-styles";
|
|
3110
|
+
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}";
|
|
3111
|
+
document.head.appendChild(style);
|
|
3112
|
+
}
|
|
3106
3113
|
function CdpPicksDockCard(props) {
|
|
3107
3114
|
var input = props.input;
|
|
3108
3115
|
var h = React.createElement;
|
|
@@ -3117,126 +3124,97 @@ function CdpPicksDockCard(props) {
|
|
|
3117
3124
|
window.clearInterval(timer);
|
|
3118
3125
|
};
|
|
3119
3126
|
}, []);
|
|
3120
|
-
var
|
|
3121
|
-
var
|
|
3122
|
-
var
|
|
3123
|
-
while ((mm =
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
title: mm[1],
|
|
3131
|
-
endpoint: mm[3],
|
|
3132
|
-
elements,
|
|
3133
|
-
block: mm[0]
|
|
3134
|
-
});
|
|
3135
|
-
}
|
|
3127
|
+
var snap = readDraftText(input);
|
|
3128
|
+
var refRe = /\[🌐 CDP-PICKS → ([^\s|]+) \| ([^|]*) \| ([^|]*) \| elements:(\d+)[^\]]*\]/g;
|
|
3129
|
+
var refs = [], mm;
|
|
3130
|
+
while ((mm = refRe.exec(snap)) !== null) refs.push({
|
|
3131
|
+
file: mm[1],
|
|
3132
|
+
endpoint: mm[2],
|
|
3133
|
+
title: mm[3],
|
|
3134
|
+
count: Number(mm[4]),
|
|
3135
|
+
line: mm[0]
|
|
3136
|
+
});
|
|
3136
3137
|
try {
|
|
3137
3138
|
window.__dshBrowserCdpDeco = {
|
|
3138
|
-
stage:
|
|
3139
|
-
|
|
3140
|
-
draftLen:
|
|
3139
|
+
stage: refs.length ? "rendered" : "no-refs",
|
|
3140
|
+
refs: refs.length,
|
|
3141
|
+
draftLen: snap.length
|
|
3141
3142
|
};
|
|
3142
3143
|
} catch (e) {}
|
|
3143
|
-
|
|
3144
|
-
|
|
3144
|
+
var loadedState = React.useState({});
|
|
3145
|
+
var contents = loadedState[0], setContents = loadedState[1];
|
|
3146
|
+
var filesKey = refs.map(function(r) {
|
|
3147
|
+
return r.file;
|
|
3148
|
+
}).join("|");
|
|
3149
|
+
React.useEffect(function() {
|
|
3150
|
+
var cancelled = false;
|
|
3151
|
+
refs.forEach(function(r) {
|
|
3152
|
+
if (contents[r.file] !== void 0) return;
|
|
3153
|
+
postJson("/bcdp/api/picks-load", { file: r.file }).then(function(res) {
|
|
3154
|
+
if (cancelled) return;
|
|
3155
|
+
var content = res && res.ok !== false && res.value ? String(res.value.content || "") : "";
|
|
3156
|
+
setContents(function(prev) {
|
|
3157
|
+
var n = Object.assign({}, prev);
|
|
3158
|
+
n[r.file] = content;
|
|
3159
|
+
return n;
|
|
3160
|
+
});
|
|
3161
|
+
}).catch(function() {});
|
|
3162
|
+
});
|
|
3163
|
+
return function() {
|
|
3164
|
+
cancelled = true;
|
|
3165
|
+
};
|
|
3166
|
+
}, [filesKey]);
|
|
3167
|
+
if (refs.length === 0) return null;
|
|
3168
|
+
function removeRef(line) {
|
|
3145
3169
|
var cur = readDraftText(input);
|
|
3146
|
-
var idx = cur.indexOf(
|
|
3170
|
+
var idx = cur.indexOf(line);
|
|
3147
3171
|
if (idx < 0) return;
|
|
3148
|
-
var next = cur.slice(0, idx) + cur.slice(idx +
|
|
3172
|
+
var next = cur.slice(0, idx) + cur.slice(idx + line.length);
|
|
3149
3173
|
next = next.replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
3150
3174
|
input.setDraft(next);
|
|
3151
3175
|
}
|
|
3152
|
-
var cardStyle = {
|
|
3153
|
-
display: "grid",
|
|
3154
|
-
gap: "4px",
|
|
3155
|
-
padding: "8px 10px",
|
|
3156
|
-
font: "inherit",
|
|
3157
|
-
fontSize: "12px",
|
|
3158
|
-
color: "var(--dsw-alias-label-primary, inherit)",
|
|
3159
|
-
background: "var(--dsw-alias-bg-surface, rgba(127,127,127,.14))",
|
|
3160
|
-
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))",
|
|
3161
|
-
borderRadius: "12px",
|
|
3162
|
-
boxSizing: "border-box"
|
|
3163
|
-
};
|
|
3164
|
-
var headStyle = {
|
|
3165
|
-
display: "flex",
|
|
3166
|
-
alignItems: "center",
|
|
3167
|
-
gap: "6px",
|
|
3168
|
-
flexWrap: "wrap"
|
|
3169
|
-
};
|
|
3170
|
-
var subStyle = {
|
|
3171
|
-
fontSize: "11px",
|
|
3172
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
|
|
3173
|
-
overflow: "hidden",
|
|
3174
|
-
textOverflow: "ellipsis",
|
|
3175
|
-
whiteSpace: "nowrap",
|
|
3176
|
-
minWidth: 0
|
|
3177
|
-
};
|
|
3178
|
-
var chipStyle = {
|
|
3179
|
-
display: "flex",
|
|
3180
|
-
alignItems: "baseline",
|
|
3181
|
-
gap: "6px",
|
|
3182
|
-
padding: "3px 8px",
|
|
3183
|
-
background: "var(--dsw-alias-bg-module-platform, rgba(127,127,127,.1))",
|
|
3184
|
-
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.22))",
|
|
3185
|
-
borderRadius: "8px",
|
|
3186
|
-
minWidth: 0
|
|
3187
|
-
};
|
|
3188
|
-
var numStyle = {
|
|
3189
|
-
fontWeight: 700,
|
|
3190
|
-
flex: "0 0 auto",
|
|
3191
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))"
|
|
3192
|
-
};
|
|
3193
|
-
var tagStyle = {
|
|
3194
|
-
fontWeight: 600,
|
|
3195
|
-
flex: "0 0 auto"
|
|
3196
|
-
};
|
|
3197
|
-
var descStyle = {
|
|
3198
|
-
overflow: "hidden",
|
|
3199
|
-
textOverflow: "ellipsis",
|
|
3200
|
-
whiteSpace: "nowrap",
|
|
3201
|
-
minWidth: 0
|
|
3202
|
-
};
|
|
3203
|
-
var closeStyle = {
|
|
3204
|
-
marginLeft: "auto",
|
|
3205
|
-
flex: "0 0 auto",
|
|
3206
|
-
font: "inherit",
|
|
3207
|
-
fontSize: "12px",
|
|
3208
|
-
cursor: "pointer",
|
|
3209
|
-
border: "none",
|
|
3210
|
-
background: "none",
|
|
3211
|
-
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.75))",
|
|
3212
|
-
padding: "0 2px"
|
|
3213
|
-
};
|
|
3214
3176
|
return h("div", { style: {
|
|
3215
3177
|
display: "grid",
|
|
3216
3178
|
gap: "6px"
|
|
3217
|
-
} },
|
|
3218
|
-
var
|
|
3179
|
+
} }, refs.map(function(r) {
|
|
3180
|
+
var content = contents[r.file];
|
|
3181
|
+
var elements = [];
|
|
3182
|
+
if (typeof content === "string" && content !== "") try {
|
|
3183
|
+
var obj = JSON.parse(content);
|
|
3184
|
+
elements = obj && obj.elements || [];
|
|
3185
|
+
} catch (e) {}
|
|
3186
|
+
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", {
|
|
3219
3187
|
type: "button",
|
|
3220
3188
|
title: wt("pickCardRemove"),
|
|
3221
|
-
|
|
3189
|
+
className: "dsh-cdp-picks-close",
|
|
3222
3190
|
onClick: function() {
|
|
3223
|
-
|
|
3191
|
+
removeRef(r.line);
|
|
3224
3192
|
}
|
|
3225
3193
|
}, "✕"));
|
|
3226
|
-
var chips =
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3194
|
+
var chips = [];
|
|
3195
|
+
if (typeof content !== "string") chips.push(h("div", {
|
|
3196
|
+
key: "loading",
|
|
3197
|
+
className: "dsh-cdp-picks-sub"
|
|
3198
|
+
}, "…"));
|
|
3199
|
+
for (var i = 0; i < elements.length && i < 6; i++) {
|
|
3200
|
+
var el = elements[i] || {};
|
|
3201
|
+
chips.push(h("div", {
|
|
3202
|
+
key: el.n || i,
|
|
3203
|
+
className: "dsh-cdp-picks-chip"
|
|
3204
|
+
}, 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 || "")));
|
|
3205
|
+
}
|
|
3206
|
+
if (elements.length > 6) chips.push(h("div", {
|
|
3207
|
+
key: "more",
|
|
3208
|
+
className: "dsh-cdp-picks-sub"
|
|
3209
|
+
}, "… +" + (elements.length - 6)));
|
|
3233
3210
|
return h("div", {
|
|
3234
|
-
key:
|
|
3235
|
-
|
|
3211
|
+
key: r.file,
|
|
3212
|
+
"data-dsh-cdp-picks-card": ""
|
|
3236
3213
|
}, head, chips);
|
|
3237
3214
|
}));
|
|
3238
3215
|
}
|
|
3239
3216
|
function mountPicksDockCard(ctx) {
|
|
3217
|
+
injectPickCardStyles();
|
|
3240
3218
|
try {
|
|
3241
3219
|
window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, { stage: "registered" });
|
|
3242
3220
|
} catch (e) {}
|
|
@@ -3253,13 +3231,6 @@ function mountPicksDockCard(ctx) {
|
|
|
3253
3231
|
input = actx.get("conversation").input.for(actx);
|
|
3254
3232
|
} catch (e) {
|
|
3255
3233
|
input = null;
|
|
3256
|
-
try {
|
|
3257
|
-
window.__dshBrowserCdpDeco = Object.assign({}, window.__dshBrowserCdpDeco, {
|
|
3258
|
-
stage: "inject-failed",
|
|
3259
|
-
error: String(e && e.message || e),
|
|
3260
|
-
sessionId: String(sessionId)
|
|
3261
|
-
});
|
|
3262
|
-
} catch (e2) {}
|
|
3263
3234
|
}
|
|
3264
3235
|
return { input };
|
|
3265
3236
|
}
|
|
@@ -3328,6 +3299,7 @@ function deliverPickToConversation(ctx, element, action) {
|
|
|
3328
3299
|
pageTitle: ""
|
|
3329
3300
|
};
|
|
3330
3301
|
var entry = {
|
|
3302
|
+
n: 1,
|
|
3331
3303
|
backendNodeId: element.backendNodeId,
|
|
3332
3304
|
tag: element.tag,
|
|
3333
3305
|
id: element.id,
|
|
@@ -3335,40 +3307,67 @@ function deliverPickToConversation(ctx, element, action) {
|
|
|
3335
3307
|
focusable: !!element.keyboardFocusable,
|
|
3336
3308
|
describe
|
|
3337
3309
|
};
|
|
3338
|
-
var
|
|
3339
|
-
while ((mm =
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3310
|
+
var reRef = /\[🌐 CDP-PICKS → ([^\s|]+) \| ([^|]*) \| ([^|]*) \| elements:(\d+)[^\]]*\]/g, file = null, oldLine = null, mm;
|
|
3311
|
+
while ((mm = reRef.exec(draft)) !== null) if (mm[2] === src.endpoint) {
|
|
3312
|
+
file = mm[1];
|
|
3313
|
+
mm[2];
|
|
3314
|
+
oldLine = mm[0];
|
|
3315
|
+
Number(mm[4]);
|
|
3316
|
+
break;
|
|
3317
|
+
}
|
|
3318
|
+
if (file !== null) {
|
|
3319
|
+
postJson("/bcdp/api/picks-load", { file }).then(function(lres) {
|
|
3320
|
+
try {
|
|
3321
|
+
if (!lres || lres.ok === false || !lres.value) return;
|
|
3322
|
+
var obj = JSON.parse(lres.value.content);
|
|
3323
|
+
var list = obj && obj.elements ? obj.elements : [];
|
|
3324
|
+
var maxN = 0;
|
|
3325
|
+
for (var k = 0; k < list.length; k++) if (list[k].n > maxN) maxN = list[k].n;
|
|
3326
|
+
entry.n = maxN + 1;
|
|
3327
|
+
list.push(Object.assign({}, entry));
|
|
3328
|
+
var page = {
|
|
3329
|
+
cdpEndpoint: obj.cdpEndpoint || src.endpoint,
|
|
3330
|
+
targetId: obj.targetId || src.targetId,
|
|
3331
|
+
pageUrl: obj.pageUrl || src.pageUrl,
|
|
3332
|
+
pageTitle: obj.pageTitle || src.pageTitle,
|
|
3333
|
+
elements: list
|
|
3334
|
+
};
|
|
3335
|
+
postJson("/bcdp/api/picks-save", {
|
|
3336
|
+
block: JSON.stringify(page, null, 2),
|
|
3337
|
+
file
|
|
3338
|
+
});
|
|
3339
|
+
var cur = readDraftText(input);
|
|
3340
|
+
var newLine = "[🌐 CDP-PICKS → " + file + " | " + src.endpoint + " | " + (page.pageTitle || "") + " | elements:" + list.length + "]";
|
|
3341
|
+
var idx = cur.indexOf(oldLine);
|
|
3342
|
+
if (idx >= 0) input.setDraft(cur.slice(0, idx) + newLine + cur.slice(idx + oldLine.length));
|
|
3343
|
+
} catch (e) {}
|
|
3344
|
+
}).catch(function() {});
|
|
3345
|
+
return {
|
|
3346
|
+
ok: true,
|
|
3347
|
+
code: "archiving"
|
|
3348
|
+
};
|
|
3349
|
+
}
|
|
3350
|
+
var pageNew = {
|
|
3349
3351
|
cdpEndpoint: src.endpoint,
|
|
3350
3352
|
targetId: src.targetId,
|
|
3351
3353
|
pageUrl: src.pageUrl,
|
|
3352
|
-
pageTitle: src.pageTitle
|
|
3354
|
+
pageTitle: src.pageTitle,
|
|
3355
|
+
elements: [Object.assign({ n: 1 }, entry)]
|
|
3353
3356
|
};
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
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]";
|
|
3366
|
-
draft = draft ? draft + (draft.charAt(draft.length - 1) === "\n" ? "" : "\n") + block : block;
|
|
3367
|
-
input.setDraft(draft);
|
|
3357
|
+
var newFile = "picks-" + Date.now() + ".json";
|
|
3358
|
+
postJson("/bcdp/api/picks-save", {
|
|
3359
|
+
block: JSON.stringify(pageNew, null, 2),
|
|
3360
|
+
file: newFile
|
|
3361
|
+
}).then(function(res) {
|
|
3362
|
+
if (!res || res.ok === false || !res.value) return;
|
|
3363
|
+
var cur = readDraftText(input);
|
|
3364
|
+
var line = "[🌐 CDP-PICKS → " + res.value.file + " | " + src.endpoint + " | " + (src.pageTitle || src.pageUrl || "") + " | elements:1]";
|
|
3365
|
+
cur = cur ? cur + (cur.charAt(cur.length - 1) === "\n" ? "" : "\n") + line : line;
|
|
3366
|
+
input.setDraft(cur);
|
|
3367
|
+
}).catch(function() {});
|
|
3368
3368
|
return {
|
|
3369
3369
|
ok: true,
|
|
3370
|
-
code: "
|
|
3371
|
-
count: page.elements.length
|
|
3370
|
+
code: "archiving"
|
|
3372
3371
|
};
|
|
3373
3372
|
} catch (err) {
|
|
3374
3373
|
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.18.
|
|
3
|
+
"version": "0.18.14",
|
|
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",
|