dsh-browser-cdp 0.18.19 → 0.18.21
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/README.md +29 -0
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/bin/cdp-cast-worker.mjs +93 -11
- package/dsh-plugin.json +1 -1
- package/lib/client.js +122 -15
- package/lib/index.js +300 -59
- package/lib/{launcher-DBaxfIsF.js → launcher-BadIUjAx.js} +160 -28
- package/lib/launcher-h0Ca5NV1.js +3 -0
- package/package.json +1 -1
- package/lib/launcher-CQyI8-By.js +0 -3
package/README.md
CHANGED
|
@@ -172,6 +172,35 @@ dshx list # 应显示:[on] dsh-
|
|
|
172
172
|
|
|
173
173
|
`bcdp_doctor` 会报告当前序列类型计数、CLI 实际解析到的路径与形态,以及(若同机装了上游 `dsh-ego-browser`)一条共存提示。
|
|
174
174
|
|
|
175
|
+
## Lightpanda 后端(可选引擎,beta)
|
|
176
|
+
|
|
177
|
+
[Lightpanda](https://lightpanda.io) 是面向 AI 的无头文本渲染浏览器(AGPL-3.0,本插件仅作 CDP 客户端使用)。它对插件来说就是一个**普通 CDP 端点**:设置面板添加并激活后,probe 会从 `/json/version` 的 `Browser: Lightpanda/…` **自动识别引擎**,badge 与 `bcdp_doctor` 显示 engine,能力降级自动生效(无需任何配置)。
|
|
178
|
+
|
|
179
|
+
### 分系统安装
|
|
180
|
+
|
|
181
|
+
| 系统 | 方式 |
|
|
182
|
+
|---|---|
|
|
183
|
+
| **Linux**(建议本机直装测试) | `curl -fsSL https://pkg.lightpanda.io/install.sh \| bash`(装入 `~/.local/bin`,确保 PATH 含它)→ `lightpanda serve --host 127.0.0.1 --port 9222` |
|
|
184
|
+
| **macOS**(建议本机直装测试) | 同上一键脚本(aarch64)→ 同 serve 命令 |
|
|
185
|
+
| **Windows**(内置方案 = WSL2,无原生版) | 管理员 PowerShell `wsl --install` → 重启 → `wsl --install -d Ubuntu` → WSL 内同 Linux 一键脚本 → WSL 内 `lightpanda serve …`;WSL2 自动把端口映射到 Windows localhost(**二进制只存在于 WSL 内,宿主侧没有文件,属预期**) |
|
|
186
|
+
| **Docker(备选)** | `docker run -d --name lightpanda -p 127.0.0.1:9222:9222 lightpanda/browser:nightly` |
|
|
187
|
+
|
|
188
|
+
装好后在本插件设置面板添加 CDP 端点 `http://127.0.0.1:9222` 并激活即可。可选:`export LIGHTPANDA_DISABLE_TELEMETRY=true` 关遥测。
|
|
189
|
+
|
|
190
|
+
### 能力降级矩阵(识别后自动生效)
|
|
191
|
+
|
|
192
|
+
| 能力 | Lightpanda 上的行为 |
|
|
193
|
+
|---|---|
|
|
194
|
+
| 导航 / JS / 点击 / 填表 / 键鼠 / 快照(AX 树)/ HTTP / 登录导入 / 等待族 | **无损可用** |
|
|
195
|
+
| `bcdp_screenshot` | PNG **文本级渲染**(无像素引擎,视觉保真低于 Chrome;runtime 本就发 png,零改动兼容) |
|
|
196
|
+
| jev 视觉链(`bcdp_jev_frame` 等) | 投影自动改发 PNG;输出带 `engine` / `rendering: text` 元数据 |
|
|
197
|
+
| 观察窗实时画面 | **关闭**——无 screencast 且无窗口,worker 不启动采集循环,面板显示降级提示 |
|
|
198
|
+
| 面板点选(inspect 路径) | **关闭**——无 Overlay 域 / bindingCalled 事件,返回 `engine-unsupported`(i18n);坐标回退路径保留 |
|
|
199
|
+
| `bcdp_download` | **关闭**——无 Page 下载事件,调用即返回结构化错误(不会挂起超时) |
|
|
200
|
+
| `bcdp_auth_flush` | 返回 `degraded: true`——引擎无 `Storage.flushCookies`,cookie 仅随引擎进程存活 |
|
|
201
|
+
|
|
202
|
+
识别失败的端点(`engine: unknown`)保持**全能力**——误判只应"少给",不应"错给"。
|
|
203
|
+
|
|
175
204
|
## 工具清单(38 个,前缀 `bcdp_`,完整索引见 `bcdp_help`)
|
|
176
205
|
|
|
177
206
|
| 类别 | 工具 |
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -37,6 +37,19 @@ Additional local modifications on top of upstream (see `runtime/ego-linux/src/ch
|
|
|
37
37
|
launched Chrome, so the agent browser can reach the network through a local proxy
|
|
38
38
|
without hijacking the CLI's own loopback CDP traffic.
|
|
39
39
|
|
|
40
|
+
## Lightpanda notice (optional backend)
|
|
41
|
+
|
|
42
|
+
[Lightpanda](https://lightpanda.io) (https://github.com/lightpanda-io/browser) is an
|
|
43
|
+
**optional** third-party browser engine the user may run themselves (native Linux/macOS
|
|
44
|
+
binary, WSL2, or Docker). This plugin uses it strictly over its CDP network protocol as
|
|
45
|
+
a CLIENT — no Lightpanda code is vendored, linked, aggregated, or distributed with this
|
|
46
|
+
plugin, and the user installs the binary independently. Under AGPL-3.0 this client-over-
|
|
47
|
+
network use does not create a combined work; this plugin remains MIT. Users and
|
|
48
|
+
distributors of Lightpanda itself must comply with its AGPL-3.0 license
|
|
49
|
+
(https://www.gnu.org/licenses/agpl-3.0.html). Telemetry of the Lightpanda binary is
|
|
50
|
+
opt-out via `LIGHTPANDA_DISABLE_TELEMETRY=true` (set automatically for plugin-managed
|
|
51
|
+
launches).
|
|
52
|
+
|
|
40
53
|
MIT License (as provided by the upstream project):
|
|
41
54
|
|
|
42
55
|
MIT License
|
package/bin/cdp-cast-worker.mjs
CHANGED
|
@@ -3832,6 +3832,7 @@ var CdpCaptureBackend = class {
|
|
|
3832
3832
|
getConfig;
|
|
3833
3833
|
onStatus;
|
|
3834
3834
|
onJpegFrame;
|
|
3835
|
+
imageFormat;
|
|
3835
3836
|
now;
|
|
3836
3837
|
setTimer;
|
|
3837
3838
|
clearTimer;
|
|
@@ -3843,12 +3844,13 @@ var CdpCaptureBackend = class {
|
|
|
3843
3844
|
metrics;
|
|
3844
3845
|
offFrame;
|
|
3845
3846
|
offDestroyed;
|
|
3846
|
-
constructor({ cdp, sessions, getConfig, onStatus, onJpegFrame, now = Date.now, setTimer = setTimeout, clearTimer = clearTimeout }) {
|
|
3847
|
+
constructor({ cdp, sessions, getConfig, onStatus, onJpegFrame, imageFormat = "jpeg", now = Date.now, setTimer = setTimeout, clearTimer = clearTimeout }) {
|
|
3847
3848
|
this.cdp = cdp;
|
|
3848
3849
|
this.sessions = sessions;
|
|
3849
3850
|
this.getConfig = getConfig;
|
|
3850
3851
|
this.onStatus = onStatus;
|
|
3851
3852
|
this.onJpegFrame = onJpegFrame;
|
|
3853
|
+
this.imageFormat = imageFormat;
|
|
3852
3854
|
this.now = now;
|
|
3853
3855
|
this.setTimer = setTimer;
|
|
3854
3856
|
this.clearTimer = clearTimer;
|
|
@@ -3892,8 +3894,8 @@ var CdpCaptureBackend = class {
|
|
|
3892
3894
|
});
|
|
3893
3895
|
try {
|
|
3894
3896
|
await this.cdp.call("Page.startScreencast", {
|
|
3895
|
-
format:
|
|
3896
|
-
quality: config.cdpQuality,
|
|
3897
|
+
format: this.imageFormat,
|
|
3898
|
+
...this.imageFormat === "jpeg" ? { quality: config.cdpQuality } : {},
|
|
3897
3899
|
maxWidth: config.cdpMaxWidth,
|
|
3898
3900
|
everyNthFrame: 1
|
|
3899
3901
|
}, session.sessionId);
|
|
@@ -4016,8 +4018,8 @@ var CdpCaptureBackend = class {
|
|
|
4016
4018
|
const session = await this.sessions.updateViewport(current.targetId);
|
|
4017
4019
|
const scale = session.viewportW > this.getConfig().cdpMaxWidth ? this.getConfig().cdpMaxWidth / session.viewportW : 1;
|
|
4018
4020
|
const result = await this.cdp.call("Page.captureScreenshot", {
|
|
4019
|
-
format:
|
|
4020
|
-
quality: this.getConfig().cdpQuality,
|
|
4021
|
+
format: this.imageFormat,
|
|
4022
|
+
...this.imageFormat === "jpeg" ? { quality: this.getConfig().cdpQuality } : {},
|
|
4021
4023
|
captureBeyondViewport: false,
|
|
4022
4024
|
...session.viewportW && session.viewportH ? { clip: {
|
|
4023
4025
|
x: 0,
|
|
@@ -4047,6 +4049,7 @@ var CaptureManager = class {
|
|
|
4047
4049
|
backendFactories;
|
|
4048
4050
|
getConfig;
|
|
4049
4051
|
onStatus;
|
|
4052
|
+
screencastSupported;
|
|
4050
4053
|
now;
|
|
4051
4054
|
setTimer;
|
|
4052
4055
|
clearTimer;
|
|
@@ -4061,10 +4064,11 @@ var CaptureManager = class {
|
|
|
4061
4064
|
transition;
|
|
4062
4065
|
stopTimer;
|
|
4063
4066
|
sweepTimer;
|
|
4064
|
-
constructor({ backendFactories, getConfig, onStatus, now = Date.now, setTimer = setTimeout, clearTimer = clearTimeout, leaseTtlMs = 12e4, idleGraceMs = 1500 }) {
|
|
4067
|
+
constructor({ backendFactories, getConfig, onStatus, screencastSupported = true, now = Date.now, setTimer = setTimeout, clearTimer = clearTimeout, leaseTtlMs = 12e4, idleGraceMs = 1500 }) {
|
|
4065
4068
|
this.backendFactories = backendFactories;
|
|
4066
4069
|
this.getConfig = getConfig;
|
|
4067
4070
|
this.onStatus = onStatus;
|
|
4071
|
+
this.screencastSupported = screencastSupported;
|
|
4068
4072
|
this.now = now;
|
|
4069
4073
|
this.setTimer = setTimer;
|
|
4070
4074
|
this.clearTimer = clearTimer;
|
|
@@ -4084,7 +4088,8 @@ var CaptureManager = class {
|
|
|
4084
4088
|
...fallbackReason ? {
|
|
4085
4089
|
code: "ffmpeg-fallback-cdp",
|
|
4086
4090
|
message: fallbackReason
|
|
4087
|
-
} : {}
|
|
4091
|
+
} : {},
|
|
4092
|
+
...screencastSupported ? {} : { engineUnsupported: true }
|
|
4088
4093
|
};
|
|
4089
4094
|
this.transition = Promise.resolve();
|
|
4090
4095
|
this.stopTimer = null;
|
|
@@ -4169,6 +4174,18 @@ var CaptureManager = class {
|
|
|
4169
4174
|
}
|
|
4170
4175
|
async #activate(backendName, targetId, force = false) {
|
|
4171
4176
|
if (!force && this.backend && this.backendName === backendName && this.targetId === targetId) return;
|
|
4177
|
+
if (!this.screencastSupported) {
|
|
4178
|
+
await this.#stopBackend("engine-unsupported");
|
|
4179
|
+
this.#setStatus({
|
|
4180
|
+
backend: backendName,
|
|
4181
|
+
state: "unsupported",
|
|
4182
|
+
targetId,
|
|
4183
|
+
code: "engine-unsupported",
|
|
4184
|
+
message: "the attached engine cannot capture frames (no screencast, no window)",
|
|
4185
|
+
engineUnsupported: true
|
|
4186
|
+
});
|
|
4187
|
+
return;
|
|
4188
|
+
}
|
|
4172
4189
|
await this.#stopBackend("backend-change");
|
|
4173
4190
|
const factory = this.backendFactories[backendName];
|
|
4174
4191
|
if (!factory) {
|
|
@@ -6257,9 +6274,64 @@ async function captureMarked(call, sessionId, options = {}) {
|
|
|
6257
6274
|
};
|
|
6258
6275
|
}
|
|
6259
6276
|
|
|
6277
|
+
//#endregion
|
|
6278
|
+
//#region src/cdp/capabilities.ts
|
|
6279
|
+
const FULL = {
|
|
6280
|
+
engine: "chrome",
|
|
6281
|
+
screencast: true,
|
|
6282
|
+
overlay: true,
|
|
6283
|
+
bindingCalled: true,
|
|
6284
|
+
imageFormat: "jpeg",
|
|
6285
|
+
loadEvent: true,
|
|
6286
|
+
downloadEvents: true,
|
|
6287
|
+
browserClose: true
|
|
6288
|
+
};
|
|
6289
|
+
/**
|
|
6290
|
+
* The capability projection per engine. `chrome` / `unknown` → full
|
|
6291
|
+
* capabilities (bit-for-bit today's behavior); `lightpanda` → the analysis
|
|
6292
|
+
* (docs/plans/2026-10-04-lightpanda-backend-analysis.md §7) projection.
|
|
6293
|
+
*/
|
|
6294
|
+
function capabilitiesFor(engine) {
|
|
6295
|
+
if (engine === "lightpanda") return {
|
|
6296
|
+
engine: "lightpanda",
|
|
6297
|
+
screencast: false,
|
|
6298
|
+
overlay: false,
|
|
6299
|
+
bindingCalled: false,
|
|
6300
|
+
imageFormat: "png",
|
|
6301
|
+
loadEvent: false,
|
|
6302
|
+
downloadEvents: false,
|
|
6303
|
+
browserClose: false
|
|
6304
|
+
};
|
|
6305
|
+
return {
|
|
6306
|
+
...FULL,
|
|
6307
|
+
engine
|
|
6308
|
+
};
|
|
6309
|
+
}
|
|
6310
|
+
/**
|
|
6311
|
+
* Env key the host half sets when spawning the cast / render workers
|
|
6312
|
+
* (mirrors `EGO_LINUX_CDP_URL`'s injection pattern in cast-server). The child
|
|
6313
|
+
* processes cannot see the host's attach cache, so the projected engine id
|
|
6314
|
+
* travels as data — the host decides once, children only read.
|
|
6315
|
+
*/
|
|
6316
|
+
const BCDP_CDP_ENGINE = "BCDP_CDP_ENGINE";
|
|
6317
|
+
/**
|
|
6318
|
+
* Project capabilities from the spawn-env value. Anything absent or
|
|
6319
|
+
* unrecognized means FULL capabilities — an unknown engine must never
|
|
6320
|
+
* conservatively break a Chrome endpoint.
|
|
6321
|
+
*/
|
|
6322
|
+
function capabilitiesFromEnvValue(value) {
|
|
6323
|
+
return capabilitiesFor(value !== void 0 && value.trim() === "lightpanda" ? "lightpanda" : "unknown");
|
|
6324
|
+
}
|
|
6325
|
+
|
|
6260
6326
|
//#endregion
|
|
6261
6327
|
//#region src/worker/cdp-cast-worker.ts
|
|
6262
6328
|
const SENTINEL = "@@DSH_RESULT@@";
|
|
6329
|
+
/**
|
|
6330
|
+
* Lightpanda backend — capability projection for THIS connection. The host
|
|
6331
|
+
* decides once (probe → attach cache → spawn env); the worker only reads.
|
|
6332
|
+
* Absent env = full capabilities = pre-Lightpanda behavior.
|
|
6333
|
+
*/
|
|
6334
|
+
const CAPS = capabilitiesFromEnvValue(process.env[BCDP_CDP_ENGINE]);
|
|
6263
6335
|
const HOME = homedir() || process.env.HOME || process.env.USERPROFILE || "/root";
|
|
6264
6336
|
const IS_WIN = platform() === "win32";
|
|
6265
6337
|
const STATE_HOME = IS_WIN ? process.env.LOCALAPPDATA || join(HOME, "AppData", "Local") : process.env.XDG_STATE_HOME || join(HOME, ".local", "state");
|
|
@@ -6442,7 +6514,10 @@ function publishJpeg(frame) {
|
|
|
6442
6514
|
viewportH: frame.vh
|
|
6443
6515
|
});
|
|
6444
6516
|
while (frameCache.size > 30) frameCache.delete(frameCache.keys().next().value);
|
|
6445
|
-
broadcast("frame", frame
|
|
6517
|
+
broadcast("frame", frame.data !== void 0 && CAPS.imageFormat === "png" ? {
|
|
6518
|
+
...frame,
|
|
6519
|
+
fmt: "png"
|
|
6520
|
+
} : frame);
|
|
6446
6521
|
}
|
|
6447
6522
|
function publishVideoInit(event) {
|
|
6448
6523
|
videoInit = {
|
|
@@ -6490,6 +6565,7 @@ function endVideo({ generation } = {}) {
|
|
|
6490
6565
|
const manager = new CaptureManager({
|
|
6491
6566
|
getConfig: () => castConfig,
|
|
6492
6567
|
onStatus: publishStatus,
|
|
6568
|
+
screencastSupported: CAPS.screencast,
|
|
6493
6569
|
backendFactories: {
|
|
6494
6570
|
cdp: ({ onStatus }) => {
|
|
6495
6571
|
if (!active) throw new Error("no live browser");
|
|
@@ -6498,7 +6574,8 @@ const manager = new CaptureManager({
|
|
|
6498
6574
|
sessions: active.sessions,
|
|
6499
6575
|
getConfig: () => castConfig,
|
|
6500
6576
|
onStatus,
|
|
6501
|
-
onJpegFrame: publishJpeg
|
|
6577
|
+
onJpegFrame: publishJpeg,
|
|
6578
|
+
imageFormat: CAPS.imageFormat
|
|
6502
6579
|
});
|
|
6503
6580
|
},
|
|
6504
6581
|
ffmpeg: ({ generation, onStatus }) => {
|
|
@@ -6777,6 +6854,11 @@ async function main() {
|
|
|
6777
6854
|
code: "browser-disconnected",
|
|
6778
6855
|
error: "no live browser"
|
|
6779
6856
|
});
|
|
6857
|
+
if (body.enabled === true && (!CAPS.overlay || !CAPS.bindingCalled)) return sendJson(res, 503, {
|
|
6858
|
+
ok: false,
|
|
6859
|
+
code: "engine-unsupported",
|
|
6860
|
+
error: "this engine does not support Overlay-based picking"
|
|
6861
|
+
});
|
|
6780
6862
|
const channel = ensurePickChannel();
|
|
6781
6863
|
if (channel === null) return sendJson(res, 409, {
|
|
6782
6864
|
ok: false,
|
|
@@ -6875,8 +6957,8 @@ async function main() {
|
|
|
6875
6957
|
limit: typeof body.limit === "number" ? body.limit : 20,
|
|
6876
6958
|
highlightIndex: typeof body.highlightIndex === "number" ? body.highlightIndex : void 0,
|
|
6877
6959
|
measureRects: body.measureRects !== false,
|
|
6878
|
-
format: body.format === "jpeg" ? "jpeg" : "png",
|
|
6879
|
-
quality: typeof body.quality === "number" ? body.quality : void 0,
|
|
6960
|
+
format: CAPS.imageFormat === "png" ? "png" : body.format === "jpeg" ? "jpeg" : "png",
|
|
6961
|
+
quality: CAPS.imageFormat === "png" ? void 0 : typeof body.quality === "number" ? body.quality : void 0,
|
|
6880
6962
|
timeoutMs: 15e3
|
|
6881
6963
|
});
|
|
6882
6964
|
return sendJson(res, result.ok ? 200 : 502, result);
|
package/dsh-plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -31,6 +31,8 @@ var module = { exports: {} }; var exports = module.exports;
|
|
|
31
31
|
const MAX_LINKS = 32;
|
|
32
32
|
/** Local ego CLI singleton default label — mirrors host `EGO_CLI_LABEL`. */
|
|
33
33
|
const EGO_CLI_LABEL = "本机 ego CLI";
|
|
34
|
+
/** Lightpanda managed-serve singleton default label — mirrors host `LP_LABEL`. */
|
|
35
|
+
const LP_LABEL = "Lightpanda(受管)";
|
|
34
36
|
/** Fresh id, same shape as the host `newTargetId()` (uuid, `t-` fallback). */
|
|
35
37
|
function newLinkId() {
|
|
36
38
|
const cryptoObj = globalThis.crypto;
|
|
@@ -86,12 +88,35 @@ function buildCliRow(input) {
|
|
|
86
88
|
probeAt: 0
|
|
87
89
|
};
|
|
88
90
|
}
|
|
91
|
+
/** Full-field lightpanda row (`servePath` '' = host auto-resolve chain). */
|
|
92
|
+
function buildLpRow(input) {
|
|
93
|
+
const servePath = trimmed(input.servePath);
|
|
94
|
+
return {
|
|
95
|
+
kind: "lightpanda",
|
|
96
|
+
id: newLinkId(),
|
|
97
|
+
label: trimmed(input.label) || LP_LABEL,
|
|
98
|
+
servePath,
|
|
99
|
+
enabled: true,
|
|
100
|
+
note: "",
|
|
101
|
+
probeStatus: "unknown",
|
|
102
|
+
probeLatencyMs: 0,
|
|
103
|
+
probeError: "",
|
|
104
|
+
probeCode: "",
|
|
105
|
+
probeAt: 0
|
|
106
|
+
};
|
|
107
|
+
}
|
|
89
108
|
/** Second ego-cli anywhere in the array would be silently dropped on read. */
|
|
90
109
|
function hasCliLink(links) {
|
|
91
110
|
return links.some(function(row) {
|
|
92
111
|
return row.kind === "ego-cli";
|
|
93
112
|
});
|
|
94
113
|
}
|
|
114
|
+
/** Second lightpanda anywhere in the array would be silently dropped on read. */
|
|
115
|
+
function hasLpLink(links) {
|
|
116
|
+
return links.some(function(row) {
|
|
117
|
+
return row.kind === "lightpanda";
|
|
118
|
+
});
|
|
119
|
+
}
|
|
95
120
|
function isFull(links) {
|
|
96
121
|
return links.length >= MAX_LINKS;
|
|
97
122
|
}
|
|
@@ -105,6 +130,10 @@ function addRow(links, row) {
|
|
|
105
130
|
links,
|
|
106
131
|
code: "ego-cli-already-exists"
|
|
107
132
|
};
|
|
133
|
+
if (row.kind === "lightpanda" && hasLpLink(links)) return {
|
|
134
|
+
links,
|
|
135
|
+
code: "lightpanda-already-exists"
|
|
136
|
+
};
|
|
108
137
|
if (links.length >= MAX_LINKS) return {
|
|
109
138
|
links,
|
|
110
139
|
code: "link-limit-reached"
|
|
@@ -162,7 +191,8 @@ function applyProbe(links, id, outcome, at) {
|
|
|
162
191
|
probeLatencyMs: typeof outcome.latencyMs === "number" ? outcome.latencyMs : 0,
|
|
163
192
|
probeError: outcome.ok ? "" : outcome.message || "",
|
|
164
193
|
probeCode: outcome.ok ? "" : outcome.code || "",
|
|
165
|
-
probeAt: at
|
|
194
|
+
probeAt: at,
|
|
195
|
+
...outcome.engine === void 0 ? {} : { probeEngine: outcome.engine }
|
|
166
196
|
});
|
|
167
197
|
}
|
|
168
198
|
|
|
@@ -211,6 +241,8 @@ var watchEn = {
|
|
|
211
241
|
pinned: "Pinned",
|
|
212
242
|
realtime: "Live",
|
|
213
243
|
noScreenshot: "(no screenshot — about:blank or browser not rendering)",
|
|
244
|
+
engineUnsupportedBanner: "(live view unsupported on this engine — Lightpanda renders text; use bcdp_snapshot / bcdp_screenshot instead)",
|
|
245
|
+
engineUnsupportedPick: "picking is unsupported on this engine (no Overlay / no live view) — use bcdp_snapshot to locate elements",
|
|
214
246
|
noActivePages: "No active browser pages",
|
|
215
247
|
noActiveHint: "Pages will appear here as the agent browses with bcdp_*",
|
|
216
248
|
openExternal: "Open real page",
|
|
@@ -265,6 +297,11 @@ var watchEn = {
|
|
|
265
297
|
linksActive: "active",
|
|
266
298
|
linksAddCdp: "Add CDP endpoint",
|
|
267
299
|
linksAddCli: "Add local ego CLI",
|
|
300
|
+
linksAddLp: "Add Lightpanda (managed)",
|
|
301
|
+
linksAddLpExists: "The Lightpanda link already exists — local-only, one per machine",
|
|
302
|
+
linksLpPathHint: "Empty = auto (PATH → ~/.local/bin; Windows runs it inside WSL2)",
|
|
303
|
+
linksLpHeadlessHint: "Headless quick-trial engine — no manual fallback (login/captcha). Early in the order = quick trials use it; after the headed kinds (CDP / local Chrome / ego CLI) = backstop first.",
|
|
304
|
+
linksLpRemoteWarn: "Activating a Lightpanda link under cdpMode=remote fails with mode-kind-mismatch",
|
|
268
305
|
linksAddCliExists: "The local ego CLI link already exists — local-only, one per machine",
|
|
269
306
|
linksEndpoint: "Endpoint",
|
|
270
307
|
linksEndpointHint: "http(s)://host:port or ws(s)://…",
|
|
@@ -300,6 +337,8 @@ var watchDict = {
|
|
|
300
337
|
pinned: "已固定查看",
|
|
301
338
|
realtime: "正在实时浏览",
|
|
302
339
|
noScreenshot: "(暂无截图 — about:blank 或浏览器未渲染)",
|
|
340
|
+
engineUnsupportedBanner: "(当前引擎不支持实时画面 — Lightpanda 为文本渲染,可用 bcdp_snapshot / bcdp_screenshot 查看)",
|
|
341
|
+
engineUnsupportedPick: "当前引擎不支持面板点选(无 Overlay/无实时画面)— 请用 bcdp_snapshot 定位元素",
|
|
303
342
|
noActivePages: "暂无活跃浏览器页",
|
|
304
343
|
noActiveHint: "当 agent 开始用 bcdp_* 操作网页时,这里会实时显示",
|
|
305
344
|
openExternal: "⧉ 打开真实页",
|
|
@@ -354,6 +393,11 @@ var watchDict = {
|
|
|
354
393
|
linksActive: "已激活",
|
|
355
394
|
linksAddCdp: "添加 CDP 端点",
|
|
356
395
|
linksAddCli: "添加本机 ego CLI",
|
|
396
|
+
linksAddLp: "添加 Lightpanda(受管)",
|
|
397
|
+
linksAddLpExists: "Lightpanda 连接已存在——仅限本机,一台机器只允许一条",
|
|
398
|
+
linksLpPathHint: "留空 = 自动检测(PATH → ~/.local/bin;Windows 经 WSL2)",
|
|
399
|
+
linksLpHeadlessHint: "无头快速试验引擎:无法人工兜底(登录/验证码)。排前面 = 快速场景优先用它;排在有头类型(CDP/本机 Chrome/ego CLI)后 = 兜底优先。",
|
|
400
|
+
linksLpRemoteWarn: "cdpMode=remote 时激活 Lightpanda 行会报 mode-kind-mismatch",
|
|
357
401
|
linksAddCliExists: "本机 ego CLI 连接已存在——仅限本机,一台机器只允许一条",
|
|
358
402
|
linksEndpoint: "端点",
|
|
359
403
|
linksEndpointHint: "http(s)://主机:端口 或 ws(s)://…",
|
|
@@ -1504,6 +1548,8 @@ function FamLinks(props) {
|
|
|
1504
1548
|
var addEndpoint = addEndpointState[0], setAddEndpoint = addEndpointState[1];
|
|
1505
1549
|
var addCliPathState = React.useState("");
|
|
1506
1550
|
var addCliPath = addCliPathState[0], setAddCliPath = addCliPathState[1];
|
|
1551
|
+
var addLpPathState = React.useState("");
|
|
1552
|
+
var addLpPath = addLpPathState[0], setAddLpPath = addLpPathState[1];
|
|
1507
1553
|
var btnStyle = {
|
|
1508
1554
|
font: "inherit",
|
|
1509
1555
|
fontSize: "12px",
|
|
@@ -1578,6 +1624,20 @@ function FamLinks(props) {
|
|
|
1578
1624
|
setAddCliPath("");
|
|
1579
1625
|
setErrText("");
|
|
1580
1626
|
}
|
|
1627
|
+
function addLp() {
|
|
1628
|
+
var res = addRow(links, buildLpRow({
|
|
1629
|
+
label: "",
|
|
1630
|
+
servePath: addLpPath
|
|
1631
|
+
}));
|
|
1632
|
+
if (res.code) {
|
|
1633
|
+
setErrText(res.code === "link-limit-reached" ? limitText() : wt("linksAddLpExists"));
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
writeLinks(res.links);
|
|
1637
|
+
if (activeId === "") scope.set("activeTargetId", res.links[res.links.length - 1].id);
|
|
1638
|
+
setAddLpPath("");
|
|
1639
|
+
setErrText("");
|
|
1640
|
+
}
|
|
1581
1641
|
function removeOne(row) {
|
|
1582
1642
|
var res = removeRow(links, row.id);
|
|
1583
1643
|
writeLinks(res.links);
|
|
@@ -1593,6 +1653,7 @@ function FamLinks(props) {
|
|
|
1593
1653
|
code: "probe-failed",
|
|
1594
1654
|
message: "no outcome"
|
|
1595
1655
|
};
|
|
1656
|
+
if (outcome && outcome.engine === void 0 && outcome.ok === true) outcome.engine = "chrome";
|
|
1596
1657
|
writeLinks(applyProbe(links, row.id, outcome, Date.now()));
|
|
1597
1658
|
}).catch(function(error) {
|
|
1598
1659
|
writeLinks(applyProbe(links, row.id, {
|
|
@@ -1661,6 +1722,7 @@ function FamLinks(props) {
|
|
|
1661
1722
|
padding: "2px 0"
|
|
1662
1723
|
} }, wt("linksEmpty")) : links.map(function(row, idx) {
|
|
1663
1724
|
var isCli = row.kind === "ego-cli";
|
|
1725
|
+
var isLp = row.kind === "lightpanda";
|
|
1664
1726
|
var isActive = row.id !== void 0 && row.id === activeId;
|
|
1665
1727
|
var probeBadge = null;
|
|
1666
1728
|
if (row.probeStatus === "ok" || row.probeStatus === "error") probeBadge = h("span", {
|
|
@@ -1692,7 +1754,7 @@ function FamLinks(props) {
|
|
|
1692
1754
|
onChange: function(e) {
|
|
1693
1755
|
writeLinks(updateRow(links, row.id, { enabled: e.target.checked }));
|
|
1694
1756
|
}
|
|
1695
|
-
}), h("span", { style: badgeStyle }, isCli ? "CLI" : "CDP"), h(FamRowInput, {
|
|
1757
|
+
}), h("span", { style: badgeStyle }, isCli ? "CLI" : isLp ? "LP·无头" : "CDP"), h(FamRowInput, {
|
|
1696
1758
|
v: row.label || "",
|
|
1697
1759
|
writable,
|
|
1698
1760
|
placeholder: wt("linksLabel"),
|
|
@@ -1718,14 +1780,18 @@ function FamLinks(props) {
|
|
|
1718
1780
|
gap: "8px",
|
|
1719
1781
|
flexWrap: "wrap"
|
|
1720
1782
|
} }, h(FamRowInput, {
|
|
1721
|
-
v: (isCli ? row.cliPath : row.endpoint) || "",
|
|
1783
|
+
v: (isCli ? row.cliPath : isLp ? row.servePath : row.endpoint) || "",
|
|
1722
1784
|
writable,
|
|
1723
|
-
placeholder: isCli ? wt("linksCliPathHint") : wt("linksEndpointHint"),
|
|
1785
|
+
placeholder: isCli ? wt("linksCliPathHint") : isLp ? wt("linksLpPathHint") : wt("linksEndpointHint"),
|
|
1724
1786
|
onCommit: function(v) {
|
|
1725
1787
|
if (isCli) {
|
|
1726
1788
|
writeLinks(updateRow(links, row.id, { cliPath: v }));
|
|
1727
1789
|
return;
|
|
1728
1790
|
}
|
|
1791
|
+
if (isLp) {
|
|
1792
|
+
writeLinks(updateRow(links, row.id, { servePath: v }));
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1729
1795
|
if (!isValidEndpoint(v)) {
|
|
1730
1796
|
setErrText(wt("linksEndpointInvalid"));
|
|
1731
1797
|
return;
|
|
@@ -1747,7 +1813,7 @@ function FamLinks(props) {
|
|
|
1747
1813
|
onChange: function(e) {
|
|
1748
1814
|
writeLinks(updateRow(links, row.id, { useSdkPath: e.target.checked }));
|
|
1749
1815
|
}
|
|
1750
|
-
}), wt("linksCliSdk")) : null, !isCli ? h("button", {
|
|
1816
|
+
}), wt("linksCliSdk")) : null, !isCli && !isLp ? h("button", {
|
|
1751
1817
|
type: "button",
|
|
1752
1818
|
disabled: !writable || probingId === row.id,
|
|
1753
1819
|
style: btnStyle,
|
|
@@ -1778,11 +1844,15 @@ function FamLinks(props) {
|
|
|
1778
1844
|
onClick: function() {
|
|
1779
1845
|
removeOne(row);
|
|
1780
1846
|
}
|
|
1781
|
-
}, "✕"), isCli && cdpMode === "remote" ? h("span", { style: {
|
|
1847
|
+
}, "✕"), (isCli || isLp) && cdpMode === "remote" ? h("span", { style: {
|
|
1782
1848
|
fontSize: "11px",
|
|
1783
1849
|
color: "#ff9f0a",
|
|
1784
1850
|
flex: "1 1 100%"
|
|
1785
|
-
} }, wt("linksCliRemoteWarn")) : null
|
|
1851
|
+
} }, wt(isCli ? "linksCliRemoteWarn" : "linksLpRemoteWarn")) : null, isLp ? h("span", { style: {
|
|
1852
|
+
fontSize: "11px",
|
|
1853
|
+
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,.7))",
|
|
1854
|
+
flex: "1 1 100%"
|
|
1855
|
+
} }, wt("linksLpHeadlessHint")) : null));
|
|
1786
1856
|
}), localRow, h("div", { style: {
|
|
1787
1857
|
display: "grid",
|
|
1788
1858
|
gap: "6px",
|
|
@@ -1848,7 +1918,33 @@ function FamLinks(props) {
|
|
|
1848
1918
|
title: hasCliLink(links) ? wt("linksAddCliExists") : isFull(links) ? limitText() : void 0,
|
|
1849
1919
|
style: btnStyle,
|
|
1850
1920
|
onClick: addCli
|
|
1851
|
-
}, wt("linksAddCli"))),
|
|
1921
|
+
}, wt("linksAddCli"))), h("div", { style: {
|
|
1922
|
+
display: "flex",
|
|
1923
|
+
gap: "8px",
|
|
1924
|
+
alignItems: "center",
|
|
1925
|
+
flexWrap: "wrap"
|
|
1926
|
+
} }, h("input", {
|
|
1927
|
+
type: "text",
|
|
1928
|
+
value: addLpPath,
|
|
1929
|
+
disabled: !writable || isFull(links) || hasLpLink(links),
|
|
1930
|
+
placeholder: wt("linksLpPathHint"),
|
|
1931
|
+
style: Object.assign({
|
|
1932
|
+
flex: "1 1 160px",
|
|
1933
|
+
minWidth: 0
|
|
1934
|
+
}, inputStyle),
|
|
1935
|
+
onChange: function(e) {
|
|
1936
|
+
setAddLpPath(e.target.value);
|
|
1937
|
+
},
|
|
1938
|
+
onKeyDown: function(e) {
|
|
1939
|
+
if (e.key === "Enter") addLp();
|
|
1940
|
+
}
|
|
1941
|
+
}), h("button", {
|
|
1942
|
+
type: "button",
|
|
1943
|
+
disabled: !writable || isFull(links) || hasLpLink(links),
|
|
1944
|
+
title: hasLpLink(links) ? wt("linksAddLpExists") : isFull(links) ? limitText() : void 0,
|
|
1945
|
+
style: btnStyle,
|
|
1946
|
+
onClick: addLp
|
|
1947
|
+
}, wt("linksAddLp"))), errText ? h("div", { style: {
|
|
1852
1948
|
fontSize: "11px",
|
|
1853
1949
|
color: "#ff453a"
|
|
1854
1950
|
} }, errText) : null));
|
|
@@ -2036,6 +2132,7 @@ function mountFloatingWatch(ctx) {
|
|
|
2036
2132
|
const pageMeta = /* @__PURE__ */ new Map();
|
|
2037
2133
|
const watchClientId = "floating-" + Math.random().toString(36).slice(2);
|
|
2038
2134
|
let watchStarted = false, watchTargetId = null, watchRenewTimer = null, watchStopTimer = null, watchRequest = null, captureBackend = "cdp", streamGeneration = 0, streamState = "idle", streamMime = "video/mp4; codecs=\"avc1.42E01E\"", videoCleanup = null;
|
|
2135
|
+
let streamEngineUnsupported = false;
|
|
2039
2136
|
const effectiveVisible = () => !panel.hidden;
|
|
2040
2137
|
const stopVideo = () => {
|
|
2041
2138
|
if (videoCleanup) try {
|
|
@@ -2051,12 +2148,14 @@ function mountFloatingWatch(ctx) {
|
|
|
2051
2148
|
const nextGeneration = status.generation ?? streamGeneration;
|
|
2052
2149
|
const nextState = status.state || streamState;
|
|
2053
2150
|
const nextMime = status.mime || streamMime;
|
|
2054
|
-
const
|
|
2151
|
+
const nextUnsupported = status.engineUnsupported === true;
|
|
2152
|
+
const changed = captureBackend !== nextBackend || streamGeneration !== nextGeneration || streamState !== nextState || streamMime !== nextMime || streamEngineUnsupported !== nextUnsupported;
|
|
2055
2153
|
captureBackend = nextBackend;
|
|
2056
2154
|
streamGeneration = nextGeneration;
|
|
2057
2155
|
streamState = nextState;
|
|
2058
2156
|
status.message || status.code;
|
|
2059
2157
|
streamMime = nextMime;
|
|
2158
|
+
streamEngineUnsupported = nextUnsupported;
|
|
2060
2159
|
if (changed) {
|
|
2061
2160
|
stopVideo();
|
|
2062
2161
|
const current = lastList.find((s) => s.targetId === (selectedTabId || currentActiveId));
|
|
@@ -2449,7 +2548,7 @@ function mountFloatingWatch(ctx) {
|
|
|
2449
2548
|
} else {
|
|
2450
2549
|
const n = document.createElement("div");
|
|
2451
2550
|
n.className = "dsh-ego-liveurl";
|
|
2452
|
-
n.textContent = wt("noScreenshot");
|
|
2551
|
+
n.textContent = streamEngineUnsupported ? wt("engineUnsupportedBanner") : wt("noScreenshot");
|
|
2453
2552
|
view.appendChild(n);
|
|
2454
2553
|
}
|
|
2455
2554
|
view.appendChild(t);
|
|
@@ -2576,7 +2675,7 @@ function mountFloatingWatch(ctx) {
|
|
|
2576
2675
|
} else {
|
|
2577
2676
|
const n = document.createElement("div");
|
|
2578
2677
|
n.className = "dsh-ego-liveurl";
|
|
2579
|
-
n.textContent = wt("noScreenshot");
|
|
2678
|
+
n.textContent = streamEngineUnsupported ? wt("engineUnsupportedBanner") : wt("noScreenshot");
|
|
2580
2679
|
view.appendChild(n);
|
|
2581
2680
|
}
|
|
2582
2681
|
view.appendChild(t);
|
|
@@ -2683,7 +2782,7 @@ function mountFloatingWatch(ctx) {
|
|
|
2683
2782
|
vh: m.vh
|
|
2684
2783
|
});
|
|
2685
2784
|
}
|
|
2686
|
-
applyFrame(m.targetId, `data:image
|
|
2785
|
+
applyFrame(m.targetId, `data:image/${m.fmt === "png" ? "png" : "jpeg"};base64,${m.data}`, m.vw, m.vh);
|
|
2687
2786
|
} catch {}
|
|
2688
2787
|
});
|
|
2689
2788
|
sse.addEventListener("spaces", (ev) => {
|
|
@@ -3627,6 +3726,10 @@ function createPickControl(onState, deliver) {
|
|
|
3627
3726
|
post(true, targetId).then(function(res) {
|
|
3628
3727
|
var state = res && res.ok !== false ? res.state : null;
|
|
3629
3728
|
if (!state || state.enabled !== true) {
|
|
3729
|
+
if (res && res.code === "engine-unsupported") {
|
|
3730
|
+
emit("failed", wt("engineUnsupportedPick"));
|
|
3731
|
+
return;
|
|
3732
|
+
}
|
|
3630
3733
|
emit("failed", state && state.message || res && res.error || wt("pickFailed"));
|
|
3631
3734
|
return;
|
|
3632
3735
|
}
|
|
@@ -3703,6 +3806,7 @@ function LivePreviewController(ctx) {
|
|
|
3703
3806
|
this.streamGeneration = 0;
|
|
3704
3807
|
this.streamState = "idle";
|
|
3705
3808
|
this.streamMessage = "";
|
|
3809
|
+
this.engineUnsupported = false;
|
|
3706
3810
|
this.streamMime = "video/mp4; codecs=\"avc1.42E01E\"";
|
|
3707
3811
|
this.liveVideo = null;
|
|
3708
3812
|
this.videoCleanup = null;
|
|
@@ -3760,6 +3864,7 @@ LivePreviewController.prototype._initialState = function() {
|
|
|
3760
3864
|
streamMessage: "",
|
|
3761
3865
|
streamGeneration: 0,
|
|
3762
3866
|
streamMime: "video/mp4; codecs=\"avc1.42E01E\"",
|
|
3867
|
+
engineUnsupported: false,
|
|
3763
3868
|
pick: "off",
|
|
3764
3869
|
pickMessage: ""
|
|
3765
3870
|
};
|
|
@@ -3840,6 +3945,7 @@ LivePreviewController.prototype._recompute = function() {
|
|
|
3840
3945
|
s.streamMessage = self.streamMessage;
|
|
3841
3946
|
s.streamGeneration = self.streamGeneration;
|
|
3842
3947
|
s.streamMime = self.streamMime;
|
|
3948
|
+
s.engineUnsupported = self.engineUnsupported;
|
|
3843
3949
|
s.pick = self._pick;
|
|
3844
3950
|
s.pickMessage = self._pickMessage;
|
|
3845
3951
|
});
|
|
@@ -3924,6 +4030,7 @@ LivePreviewController.prototype._applyCaptureStatus = function(status) {
|
|
|
3924
4030
|
this.streamMessage = status.message || status.code || "";
|
|
3925
4031
|
this.streamGeneration = nextGeneration;
|
|
3926
4032
|
this.streamMime = status.mime || this.streamMime;
|
|
4033
|
+
this.engineUnsupported = status.engineUnsupported === true;
|
|
3927
4034
|
if (generationChanged || this.backend !== "ffmpeg") this._destroyVideo();
|
|
3928
4035
|
this._recompute();
|
|
3929
4036
|
};
|
|
@@ -4105,7 +4212,7 @@ LivePreviewController.prototype.openStream = function() {
|
|
|
4105
4212
|
vh: m.vh
|
|
4106
4213
|
}));
|
|
4107
4214
|
}
|
|
4108
|
-
self.applyFrame(m.targetId, "data:image/jpeg;base64," + m.data, m.vw, m.vh);
|
|
4215
|
+
self.applyFrame(m.targetId, "data:image/" + (m.fmt === "png" ? "png" : "jpeg") + ";base64," + m.data, m.vw, m.vh);
|
|
4109
4216
|
} catch (e) {}
|
|
4110
4217
|
});
|
|
4111
4218
|
this.sse.addEventListener("spaces", function(ev) {
|
|
@@ -4613,8 +4720,8 @@ function EgoBrowserTab(props) {
|
|
|
4613
4720
|
onDoubleClick: function(e) {
|
|
4614
4721
|
controller.handleDoubleClick(e);
|
|
4615
4722
|
}
|
|
4616
|
-
}) : h("div", { className: "dsh-ego-side-liveurl" }, state.streamMessage || wt("noScreenshot"));
|
|
4617
|
-
body = h("div", { className: "dsh-ego-side-body" }, h("div", { className: "dsh-ego-side-liveview" }, h("div", { className: "dsh-ego-side-livebadge" }, h("span", { className: "dsh-ego-side-state-dot" + (state.pinned ? " pin" : state.busy ? " busy" : "") }), h("span", { style: { flex: 1 } }, (state.backend === "ffmpeg" ? "FFmpeg · H.264" : "CDP") + " · " + (state.streamState === "failed" ? state.streamMessage || wt("failed") : state.streamState) + (state.currentTargetId ? state.wiringStale ? " · " + wt("stale") : " · " + wt("captured") : "")), state.pinned ? h("button", {
|
|
4723
|
+
}) : h("div", { className: "dsh-ego-side-liveurl" }, state.engineUnsupported ? wt("engineUnsupportedBanner") : state.streamMessage || wt("noScreenshot"));
|
|
4724
|
+
body = h("div", { className: "dsh-ego-side-body" }, h("div", { className: "dsh-ego-side-liveview" }, h("div", { className: "dsh-ego-side-livebadge" }, h("span", { className: "dsh-ego-side-state-dot" + (state.pinned ? " pin" : state.busy ? " busy" : "") }), h("span", { style: { flex: 1 } }, (state.backend === "ffmpeg" ? "FFmpeg · H.264" : "CDP") + " · " + (state.streamState === "failed" ? state.streamMessage || wt("failed") : state.streamState === "unsupported" ? wt("engineUnsupportedBanner") : state.streamState) + (state.currentTargetId ? state.wiringStale ? " · " + wt("stale") : " · " + wt("captured") : "")), state.pinned ? h("button", {
|
|
4618
4725
|
className: "dsh-ego-side-back",
|
|
4619
4726
|
type: "button",
|
|
4620
4727
|
onClick: function() {
|