@liang-hz/agent-in-chrome 0.55.2 → 0.56.0
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.en.md +6 -5
- package/README.md +6 -5
- package/extension/manifest.json +1 -1
- package/extension/sw.js +794 -76
- package/mcp/agent-identity.mjs +305 -61
- package/mcp/cdp/browser-launch.mjs +160 -48
- package/mcp/secret-shape.mjs +8 -1
- package/mcp/server.mjs +388 -375
- package/mcp/session-id.mjs +25 -3
- package/mcp/tool-tiers.mjs +1 -0
- package/mcp/trace.mjs +7 -4
- package/native-host/host.mjs +28 -0
- package/package.json +1 -1
- package/scripts/borrow-login.mjs +53 -7
- package/scripts/e2e-sweep.mjs +3 -4
- package/scripts/e2e.mjs +164 -40
- package/scripts/fixture-server.mjs +59 -0
- package/scripts/install.mjs +130 -4
- package/scripts/launcher-spawn.mjs +22 -0
- package/scripts/pack-crx.mjs +2 -1
- package/scripts/test-agents.mjs +89 -22
- package/scripts/test-borrow.mjs +6 -0
- package/scripts/test-config.mjs +21 -1
- package/scripts/test-e2e-sweep.mjs +7 -2
- package/scripts/test-identity.mjs +307 -84
- package/scripts/test-install-skill.mjs +37 -2
- package/scripts/test-protocol.mjs +168 -1
- package/scripts/test-security.mjs +274 -18
- package/scripts/test-sw.mjs +423 -20
- package/skills/agent-in-chrome/SKILL.md +4 -4
- package/skills/agent-in-chrome/references/actions-and-waits.md +6 -5
- package/skills/agent-in-chrome/references/network-debugging.md +2 -0
package/README.en.md
CHANGED
|
@@ -42,7 +42,7 @@ Agent in Chrome connects an AI agent (Claude Code, Claude Desktop, Trae, Codex,
|
|
|
42
42
|
| Modal overlay detection (including login walls with no ARIA role) | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
43
43
|
| Element pixel coordinates + top-level coordinates across frames | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
44
44
|
|
|
45
|
-
<sup>1</sup> `--extension` mode only (Chrome/Edge, requires installing their extension); the default mode is an isolated profile. <sup>2</sup> `--autoConnect` only (Chrome 144+, requires manually opening the gate in `chrome://inspect`, which exposes every window in that profile). <sup>3</sup> Either connect over CDP to a Chrome already started with a debug port, or use its bundled browser (isolated profile, no user login state). <sup>4</sup> A separate Chromium fork; login state comes from import rather than live borrowing — `ego-browser import` re-imports from Chrome/Edge/Brave (extensions included). <sup>5</sup> Windows supports extension mode
|
|
45
|
+
<sup>1</sup> `--extension` mode only (Chrome/Edge, requires installing their extension); the default mode is an isolated profile. <sup>2</sup> `--autoConnect` only (Chrome 144+, requires manually opening the gate in `chrome://inspect`, which exposes every window in that profile). <sup>3</sup> Either connect over CDP to a Chrome already started with a debug port, or use its bundled browser (isolated profile, no user login state). <sup>4</sup> A separate Chromium fork; login state comes from import rather than live borrowing — `ego-browser import` re-imports from Chrome/Edge/Brave (extensions included). <sup>5</sup> Windows supports both extension mode and CLI/headless mode; the Linux path is written but unverified. <sup>6</sup> Playwright's `--secrets` and DevTools MCP's `--redactNetworkHeaders` are both opt-in and off by default, and the latter doesn't cover bodies. Measured: Playwright's `browser_network_request` filters Cookie and Set-Cookie out of request headers by default (full raw headers require run_code). <sup>7</sup> Solid placeholder mechanism on the input side; no redaction on network responses. <sup>8</sup> `browser_run_code_unsafe` describes itself as RCE-equivalent and is on by default. <sup>9</sup> ego has no native network helpers, but its `page.cdp()` escape hatch reaches everything (measured on 0.5.0.28): raw headers live in CDP ExtraInfo events and need manual pairing by requestId, WS frames are capturable, mocking/throttling/tracing all doable; cookies stay plaintext throughout, no redaction. <sup>10</sup> ego and browser-use both make code their primary interface (heredoc / Python) — arbitrary code execution is by design. <sup>11</sup> Measured: overlays without ARIA roles don't surface in ego's semantic snapshot (flattened into the same tree, no modality marker; only a click error names the intercepting element); its snapshot carries no element pixel coordinates, and top-level coordinates across frames must be computed by hand. browser-use filters buttons under an overlay out of its element list entirely and its coordinate clicks can falsely report success; its observation output likewise carries no pixel coordinates. <sup>12</sup> Measured: Playwright MCP 0.0.80 ships no mocking/throttling/tracing tools at all (the `browser_route`/tracing tools in its README were not released with this version), and it has no native WS frames, initiator stacks, or curl export either; all of these are reachable through the `browser_run_code_unsafe` escape hatch.
|
|
46
46
|
|
|
47
47
|
**Speed** (same test page containing a cross-origin iframe, equivalent fresh profiles, medians; browser-use is omitted because it requires manual per-run authorization in `chrome://inspect` and can't complete the same flow unattended):
|
|
48
48
|
|
|
@@ -72,10 +72,10 @@ Agent in Chrome connects an AI agent (Claude Code, Claude Desktop, Trae, Codex,
|
|
|
72
72
|
|
|
73
73
|
## Quick start
|
|
74
74
|
|
|
75
|
-
> Requires Node.js 18+ and Chrome 125+ (or Edge / Brave / Vivaldi / any Chromium-based browser). macOS is fully tested; Windows extension mode
|
|
75
|
+
> Requires Node.js 18+ and Chrome 125+ (or Edge / Brave / Vivaldi / any Chromium-based browser). macOS is fully tested; Windows extension mode and CLI/headless mode are both supported (named pipes + registry + `.bat` launcher; CLI-mode process management goes through the PowerShell process table); the Linux path is written but unverified — see [Known limitations](#known-limitations).
|
|
76
76
|
>
|
|
77
77
|
> 18 really is enough, and that's measured: on Node 18.20.8 `check` passes end to end, the MCP server
|
|
78
|
-
> boots and lists all
|
|
78
|
+
> boots and lists all 38 tools. The one exception is CLI mode's `AGENT_IN_CHROME_KEEP=1`, which needs
|
|
79
79
|
> Node's global `WebSocket` — **Node 22+ only**; the default pipe transport works fine on older Node.
|
|
80
80
|
> See [docs/CLI.md](docs/CLI.md).
|
|
81
81
|
|
|
@@ -237,6 +237,7 @@ Terminal agents, cron jobs, CI, and remote SSH boxes don't have "an open Chrome
|
|
|
237
237
|
| Tool | What it does |
|
|
238
238
|
|---|---|
|
|
239
239
|
| `browser_eval` | Evaluate in-page to extract data; results aren't truncated and can go to `outFile` |
|
|
240
|
+
| `browser_fetch` | Same-origin HTTP fetch in the tab context (carries `HttpOnly` cookies, supports `outFile`) |
|
|
240
241
|
| `browser_cdp` | Raw CDP passthrough (escape hatch) |
|
|
241
242
|
| `browser_console` | Console output and page exceptions |
|
|
242
243
|
| `browser_network` | Request list (`type:"api"` filter, `bodyContains` searches response bodies directly) |
|
|
@@ -264,7 +265,7 @@ Terminal agents, cron jobs, CI, and remote SSH boxes don't have "an open Chrome
|
|
|
264
265
|
```
|
|
265
266
|
|
|
266
267
|
- **`profile` has two settings**, controlling which tools appear in the agent's tool list at all. A tool that's off isn't "disabled" — it **doesn't exist**, so the model never sees it and never reaches for it:
|
|
267
|
-
- `observe` — read pages, screenshot, inspect network, open its own tabs and navigate them. No clicking, no typing, no credential access — any **parameter** that crosses into the credential or execution surface is refused outright at this level: `revealSecrets`, and `browser_wait_for`'s `js` (which is arbitrary evaluation in the page's main world). **An honest caveat**: navigation itself issues GET requests as you, and on some sites unsubscribe or deactivate links *are* GETs. The whole `tools/list` is about
|
|
268
|
+
- `observe` — read pages, screenshot, inspect network, open its own tabs and navigate them. No clicking, no typing, no credential access — any **parameter** that crosses into the credential or execution surface is refused outright at this level: `revealSecrets`, and `browser_wait_for`'s `js` (which is arbitrary evaluation in the page's main world). **An honest caveat**: navigation itself issues GET requests as you, and on some sites unsubscribe or deactivate links *are* GETs. The whole `tools/list` is about 15 KB at this level (about 27 KB at `full`), which saves tokens on every single request.
|
|
268
269
|
- `full` (default) — everything: click/type, `eval` / `cdp` (arbitrary code), cookie import/export (your entire login state), `websocket`, `upload_file`.
|
|
269
270
|
- Older configs using `readonly` / `standard` still work, mapping to `observe` / `full` respectively (`standard` migrates toward the permissive side, so we never silently take away capability you already had).
|
|
270
271
|
- **`disable` / `enable`** turn individual tools off or on on top of the profile (full names, `browser_` prefix). If a tool appears in both, `disable` wins.
|
|
@@ -340,7 +341,7 @@ follow the npm package.
|
|
|
340
341
|
- **Cross-origin iframes under a CSS transform** (rotate/scale/skew) can't have their coordinates computed, so elements inside them can't be clicked; `read_page` marks them `coords: "未知"` ("unknown" — the field is emitted in Chinese). Work around it by opening that URL directly with `browser_new_tab`.
|
|
341
342
|
- **No performance / a11y / SEO audit scores** — `npx lighthouse <url> --view` is one command away and carries Chrome's own scoring; in extension mode we drive your everyday Chrome, which has no debugging port, so building our own would only produce a worse Lighthouse. **Division of labour**: scores come from `npx lighthouse`; we cover what it can't reach — pages behind a login, the screen that only appears after you open some panel, and the headers and bodies of one specific request.
|
|
342
343
|
- **There is no dedicated drag tool** — drag sliders, drag-and-drop reordering, and canvas gestures are done with `browser_batch` chaining a series of `browser_cdp` `Input.dispatchMouseEvent` calls (recipe in [skills/agent-in-chrome/references/actions-and-waits.md](skills/agent-in-chrome/references/actions-and-waits.md#拖拽--滑块没有-drag-工具), under "拖拽 / 滑块"). Synthesizing events via `eval` dispatches `isTrusted: false`, which real captchas reject.
|
|
343
|
-
- **Platforms**: macOS is fully tested. **Windows extension mode is supported** (registry + named pipes + a `.bat` launcher; the bridge's first line of defense becomes the token rather than directory permissions — see the `bridgeEndpoint` comment in `mcp/token.mjs`). Windows CLI/headless mode (`AGENT_IN_CHROME_LAUNCH=1`) is
|
|
344
|
+
- **Platforms**: macOS is fully tested. **Windows extension mode is supported** (registry + named pipes + a `.bat` launcher; the bridge's first line of defense becomes the token rather than directory permissions — see the `bridgeEndpoint` comment in `mcp/token.mjs`). Windows CLI/headless mode (`AGENT_IN_CHROME_LAUNCH=1`) is supported — the three process-management data sources were ported (see `mcp/cdp/browser-launch.mjs`); initial real-machine testing passed, long-run feedback welcome. The Linux path is written but unverified. PRs welcome.
|
|
344
345
|
|
|
345
346
|
---
|
|
346
347
|
|
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ Agent in Chrome 把 AI agent(Claude Code、Claude Desktop、Trae、Codex……
|
|
|
42
42
|
| 模态浮层检出(含无 ARIA 角色的登录墙) | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
43
43
|
| 元素像素坐标 + 跨源帧顶层坐标 | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
44
44
|
|
|
45
|
-
<sup>1</sup> 仅 `--extension` 模式(Chrome/Edge,需装其扩展);默认模式是独立 profile。 <sup>2</sup> 仅 `--autoConnect`(Chrome 144+,需在 `chrome://inspect` 手动开闸,该 profile 全部窗口暴露)。 <sup>3</sup> 二选一:CDP 直连已开调试端口的 Chrome,或用自带浏览器(独立 profile,不带用户登录态)。 <sup>4</sup> 独立 Chromium 分叉浏览器;登录态靠导入而非实时借用——`ego-browser import` 可从 Chrome/Edge/Brave 重复导入(扩展一并迁入)。 <sup>5</sup> Windows
|
|
45
|
+
<sup>1</sup> 仅 `--extension` 模式(Chrome/Edge,需装其扩展);默认模式是独立 profile。 <sup>2</sup> 仅 `--autoConnect`(Chrome 144+,需在 `chrome://inspect` 手动开闸,该 profile 全部窗口暴露)。 <sup>3</sup> 二选一:CDP 直连已开调试端口的 Chrome,或用自带浏览器(独立 profile,不带用户登录态)。 <sup>4</sup> 独立 Chromium 分叉浏览器;登录态靠导入而非实时借用——`ego-browser import` 可从 Chrome/Edge/Brave 重复导入(扩展一并迁入)。 <sup>5</sup> Windows 插件模式与 CLI/headless 模式均已支持;Linux 路径已写未验证。 <sup>6</sup> Playwright 的 `--secrets` 与 DevTools 的 `--redactNetworkHeaders` 均为可选开关且默认关闭,后者不覆盖 body。实测 Playwright 的 `browser_network_request` 默认过滤请求头中的 Cookie 与 Set-Cookie(要完整原始头得走 run_code)。 <sup>7</sup> 输入侧占位符机制完备;网络返回值无打码。 <sup>8</sup> `browser_run_code_unsafe` 自述 RCE-equivalent,默认开启。 <sup>9</sup> ego 无网络类原生 helper,但 `page.cdp()` 逃生舱实测可达:原始头在 CDP ExtraInfo 事件里、需按 requestId 自行配对,WS 帧可抓,mock/限速/trace 均可做;全程 Cookie 明文无打码。 <sup>10</sup> ego 与 browser-use 的主接口都是代码(heredoc / Python),任意代码执行是设计使然。 <sup>11</sup> 实测无 ARIA 浮层不进 ego 的语义快照(与正文平铺同树、无模态标记,仅点击报错会点名遮挡元素),快照不含元素像素坐标,跨源帧顶层坐标需自行计算;browser-use 的元素表则会把遮罩下按钮整个过滤掉、坐标点击会误报成功,观察输出同样不含像素坐标。 <sup>12</sup> 实测 Playwright MCP 0.0.80 包内并无 mock/限速/trace 类工具(其 README 文档所载 `browser_route`/tracing 未随该版本发布),WS 帧、发起调用栈、curl 导出也无原生工具;均可用 `browser_run_code_unsafe` 逃生舱补做。
|
|
46
46
|
|
|
47
47
|
**速度**(同一含跨源 iframe 的测试页、对等全新 profile、中位数;browser-use 因需人工在 `chrome://inspect` 逐次授权,无法无人值守完成同一流程,未列入):
|
|
48
48
|
|
|
@@ -72,9 +72,9 @@ Agent in Chrome 把 AI agent(Claude Code、Claude Desktop、Trae、Codex……
|
|
|
72
72
|
|
|
73
73
|
## 快速开始
|
|
74
74
|
|
|
75
|
-
> 需要 Node.js 18+ 和 Chrome 125+(或 Edge / Brave / Vivaldi 等 Chromium 系)。目前 macOS 实测完整;Windows
|
|
75
|
+
> 需要 Node.js 18+ 和 Chrome 125+(或 Edge / Brave / Vivaldi 等 Chromium 系)。目前 macOS 实测完整;Windows 插件模式与 CLI/headless 模式均已支持(命名管道 + 注册表 + .bat 启动器;CLI 模式的进程管理走 PowerShell 进程表);Linux 路径已写待验证(见[已知限制](#已知限制))。
|
|
76
76
|
>
|
|
77
|
-
> 18 够用是实测过的:Node 18.20.8 上 `check` 全过、MCP server 起得来、
|
|
77
|
+
> 18 够用是实测过的:Node 18.20.8 上 `check` 全过、MCP server 起得来、38 个工具都在。唯一的例外在
|
|
78
78
|
> CLI 模式的 `AGENT_IN_CHROME_KEEP=1` 那条路上——它要 Node 的全局 `WebSocket`,**Node 22 才有**;
|
|
79
79
|
> 老 Node 上默认的管道通道照常能跑,见 [docs/CLI.md](docs/CLI.md)。
|
|
80
80
|
|
|
@@ -233,6 +233,7 @@ agent → MCP server → 本机 socket → native host(Chrome 拉起)→ 扩
|
|
|
233
233
|
| 工具 | 作用 |
|
|
234
234
|
|---|---|
|
|
235
235
|
| `browser_eval` | 页面内求值取数据;结果不截断,可 `outFile` 落盘 |
|
|
236
|
+
| `browser_fetch` | 在当前标签页上下文发同源 HTTP 请求(自动带 `HttpOnly` Cookie,可 `outFile` 落盘) |
|
|
236
237
|
| `browser_cdp` | 原始 CDP 直通(逃生舱) |
|
|
237
238
|
| `browser_console` | console 输出与页面异常 |
|
|
238
239
|
| `browser_network` | 请求列表(`type:"api"` 过滤、`bodyContains` 直接搜响应体) |
|
|
@@ -261,7 +262,7 @@ agent → MCP server → 本机 socket → native host(Chrome 拉起)→ 扩
|
|
|
261
262
|
```
|
|
262
263
|
|
|
263
264
|
- **`profile` 两档**,管的是哪些工具出现在 agent 的工具列表里——关掉的工具不是"禁用",是**根本不存在**,模型看不到也不会去调:
|
|
264
|
-
- `observe` —— 读页面、截图、看网络、开自己的标签页并导航过去。不点、不填、不碰凭据(跨进凭据面或执行面的**参数**在这一档一律被拒:`revealSecrets`,以及 `browser_wait_for` 的 `js`——它是页面主世界的任意求值)。**如实说明边界**:导航本身会以你的身份发 GET 请求,个别站点的退订/注销就是 GET。整份 `tools/list` 在这一档约
|
|
265
|
+
- `observe` —— 读页面、截图、看网络、开自己的标签页并导航过去。不点、不填、不碰凭据(跨进凭据面或执行面的**参数**在这一档一律被拒:`revealSecrets`,以及 `browser_wait_for` 的 `js`——它是页面主世界的任意求值)。**如实说明边界**:导航本身会以你的身份发 GET 请求,个别站点的退订/注销就是 GET。整份 `tools/list` 在这一档约 15 KB(完整档约 27 KB),每一次请求都省。
|
|
265
266
|
- `full`(默认)—— 全部工具:点击/输入、`eval` / `cdp`(任意代码)、cookies 导入导出(整份登录态)、`websocket`、`upload_file`。
|
|
266
267
|
- 老配置里的 `readonly` / `standard` 仍然认:分别按 `observe` / `full` 生效(`standard` 往宽松侧迁移,不悄悄削减你已有的能力)。
|
|
267
268
|
- **`disable` / `enable`** 在档位之上单独关 / 开某个工具(全名,`browser_` 开头)。两边都写了同一个工具时,`disable` 赢。
|
|
@@ -333,7 +334,7 @@ npx @liang-hz/agent-in-chrome@latest update
|
|
|
333
334
|
- **跨源 iframe 被 CSS 变换(旋转/缩放/斜切)过时坐标算不出来**,里面的元素点不了,`read_page` 会标 `coords:"未知"`——改用 `browser_new_tab` 直接打开那个地址。
|
|
334
335
|
- **不做性能 / a11y / SEO 审计打分**——那类需求 `npx lighthouse <url> --view` 一条命令就跑完,还带 Chrome 官方的评分口径;插件模式下我们挂的是你自己那个没有调试端口的 Chrome,硬做只会做出一个更差的 Lighthouse。**分工**:跑分交给 `npx lighthouse`,我们负责它进不去的地方——需要登录态的页面、点开某个面板之后才出现的那一屏、以及看具体某个请求的头和响应体。
|
|
335
336
|
- **没有专门的拖拽工具**——拖滑块、拖放排序、画布手势用 `browser_batch` 串一列 `browser_cdp` 的 `Input.dispatchMouseEvent`(配方在 [skills/agent-in-chrome/references/actions-and-waits.md](skills/agent-in-chrome/references/actions-and-waits.md#拖拽--滑块没有-drag-工具));用 `eval` 合成事件派的是 `isTrusted: false`,真验证码不认。
|
|
336
|
-
- **平台**:macOS 完整实测。**Windows
|
|
337
|
+
- **平台**:macOS 完整实测。**Windows 插件模式与 CLI/headless 模式均已支持**(插件模式:注册表 + 命名管道 + `.bat` 启动器,桥接第一道防线由目录权限换成令牌,详见 `mcp/token.mjs` 的 bridgeEndpoint 注释;CLI 模式:进程表/占用者/收场三处数据源走 Windows 对应物,见 `mcp/cdp/browser-launch.mjs`)。CLI 模式在 Windows 上初测通过,长跑反馈欢迎开 issue。Linux 路径已写未验证。欢迎 PR。
|
|
337
338
|
|
|
338
339
|
---
|
|
339
340
|
|
package/extension/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Agent in Chrome",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.56.0",
|
|
5
5
|
"description": "让 AI agent 操作你已经登录的那个 Chrome 标签页,复用你现有的登录态。 · by Liang (liangai.org)",
|
|
6
6
|
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6Jtdbvmd/bUVxIn9YXdLBw9idVVJwXfCHCGYkPZ0Wp8YcIRBPj10a6L4tTF6h78cLjvgowiZmCAdiUZekjBdPrKJT9nhkGIX9yER3DfRpk0NOkTxum95Eb/K6Y4U/3q1TbhFkebBFZAcPG6O5/Nh8qnTiEuN/EFB3PqlODh4UInLxYbGsHV5vp4WXxfGOt1fF3VkekS7T1gPndijbBBeriv61eb7KguMNrEbid+p07kBPDZ6D3mp4JT6eqsfoPgK01QISBMrJgou0ra9Z4t+bhPvsoe2xAkr8X5iojSAVKUs1UKyKueV2WJ1JPqdAFIRckWwZ4sqEpk/LenKFljTiQIDAQAB",
|
|
7
7
|
"minimum_chrome_version": "125",
|