Pure logic for single-target CDP bridge, handling commands and responses.
// Source: https://github.com/iOfficeAI/AionUi | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works // Provided via justclaw.it.com; keep this notice with the code. /** * @license * Copyright 2025 AionUi (aionui.com) * SPDX-License-Identifier: Apache-2.0 */ /** * 单目标 CDP 转发层的纯协议逻辑(不含 Electron / socket 依赖,便于单测)。 * * 为什么需要这一层:Chromium 的 remote-debugging-port 是「整个应用级」的,没有 * per-target ACL,开一个口子等于把主窗口(连着 preload 桥)一起暴露给本机任意进程。 * 我们改成只对侧边浏览器那一个 webContents 暴露,但 chrome-devtools-mcp 用的是 * puppeteer 的 browserURL 连接方式,它上来就把对面当成「一整个浏览器」,先发 * Target.setDiscoverTargets / setAutoAttach,再靠 Target.attachToTarget 拿 sessionId。 * Electron 的 webContents.debugger 只能服务单个页面,答不上这些命令。 * * 所以这里把自己伪装成「只有一个标签页的浏览器」:Target.* 由我们本地应答,其余命令 * 透传给 debugger。Electron ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key