@liang-hz/agent-in-chrome 0.55.1 → 0.55.5
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 +12 -12
- package/README.md +12 -12
- package/docs/AGENTS.md +19 -1
- package/extension/manifest.json +1 -1
- package/extension/sw.js +91 -25
- package/mcp/agent-identity.mjs +576 -49
- package/mcp/cdp/browser-launch.mjs +160 -48
- package/mcp/config.mjs +51 -7
- package/mcp/server.mjs +17 -26
- package/native-host/host.mjs +28 -0
- package/package.json +1 -1
- package/scripts/agents.mjs +11 -0
- package/scripts/borrow-login.mjs +6 -2
- package/scripts/e2e-sweep.mjs +3 -4
- package/scripts/e2e.mjs +81 -37
- package/scripts/install.mjs +73 -7
- package/scripts/launcher-spawn.mjs +22 -0
- package/scripts/pack-crx.mjs +2 -1
- package/scripts/test-agents.mjs +105 -24
- package/scripts/test-config.mjs +94 -4
- package/scripts/test-e2e-sweep.mjs +7 -2
- package/scripts/test-identity.mjs +914 -66
- package/scripts/test-install-skill.mjs +37 -2
- package/scripts/test-protocol.mjs +195 -3
- package/scripts/test-security.mjs +38 -17
- package/scripts/test-sw.mjs +103 -18
- package/skills/install-agent-in-chrome/SKILL.md +2 -2
package/README.en.md
CHANGED
|
@@ -23,7 +23,7 @@ It inherits the sessions you're already logged into: intranet tools, Gmail, admi
|
|
|
23
23
|
|
|
24
24
|
Agent in Chrome connects an AI agent (Claude Code, Claude Desktop, Trae, Codex, and others) to **the Chrome sitting in front of you**. It exposes a browser toolset over [MCP](https://modelcontextprotocol.io) so the agent can read pages, click, fill forms, and capture network traffic — all carrying your existing login state, all in background tabs that never steal your foreground.
|
|
25
25
|
|
|
26
|
-
**How does it compare?** The table below scores only **native, out-of-the-box capability**: ✅ = works without writing code, ❌ = not available. (Most of these tools ship an arbitrary-code-execution escape hatch, so in principle anything can be rebuilt by hand — count that and every cell turns ✅ and the table stops meaning anything.) Based on a source-code read and hands-on measurement on 2026-08-18, against @playwright/mcp 0.0.
|
|
26
|
+
**How does it compare?** The table below scores only **native, out-of-the-box capability**: ✅ = works without writing code, ❌ = not available. (Most of these tools ship an arbitrary-code-execution escape hatch, so in principle anything can be rebuilt by hand — count that and every cell turns ✅ and the table stops meaning anything.) Based on a source-code read and hands-on measurement on 2026-08-18 (the Playwright MCP, browser-use, and ego lite columns re-verified on 2026-09-10 with the same task books plus targeted probes; Playwright MCP and ego lite matched agent-in-chrome / chrome-devtools-mcp on task completion, while browser-use showed real tool-surface gaps — see footnotes), against @playwright/mcp 0.0.80 · chrome-devtools-mcp 1.7.0 · browser-use 0.13.10 · ego lite 0.5.0.28. No recommendation implied — pick by your situation.
|
|
27
27
|
|
|
28
28
|
| | Agent in Chrome | Playwright MCP | Chrome DevTools MCP | browser-use | ego lite |
|
|
29
29
|
|---|:---:|:---:|:---:|:---:|:---:|
|
|
@@ -33,16 +33,16 @@ Agent in Chrome connects an AI agent (Claude Code, Claude Desktop, Trae, Codex,
|
|
|
33
33
|
| Speaks MCP | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
34
34
|
| Windows / Linux | ✅⁵ | ✅ | ✅ | ✅ | ❌ |
|
|
35
35
|
| Firefox / WebKit | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
36
|
-
| Raw network headers + request/response bodies | ✅ | ✅ | ✅ | ❌ |
|
|
37
|
-
| WebSocket frames / initiator stack / export as curl | ✅ |
|
|
38
|
-
| Request mocking / throttling / performance traces | ❌ |
|
|
39
|
-
| Credentials redacted by default (cookies and passwords never enter model context) | ✅ | ❌⁶ | ❌⁶ | ✅⁷ |
|
|
40
|
-
| No server-side arbitrary code execution enabled by default | ✅ | ❌⁸ | ✅ |
|
|
36
|
+
| Raw network headers + request/response bodies | ✅ | ✅ | ✅ | ❌ | ❌⁹ |
|
|
37
|
+
| WebSocket frames / initiator stack / export as curl | ✅ | ❌¹² | ❌ | ❌ | ❌⁹ |
|
|
38
|
+
| Request mocking / throttling / performance traces | ❌ | ❌¹² | ✅ | ❌ | ❌⁹ |
|
|
39
|
+
| Credentials redacted by default (cookies and passwords never enter model context) | ✅ | ❌⁶ | ❌⁶ | ✅⁷ | ❌⁹ |
|
|
40
|
+
| No server-side arbitrary code execution enabled by default | ✅ | ❌⁸ | ✅ | ❌¹⁰ | ❌¹⁰ |
|
|
41
41
|
| Zero runtime third-party dependencies | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
42
|
-
| Modal overlay detection (including login walls with no ARIA role) | ✅ | ❌ | ❌ |
|
|
43
|
-
| Element pixel coordinates + top-level coordinates across frames | ✅ | ❌ | ❌ |
|
|
42
|
+
| Modal overlay detection (including login walls with no ARIA role) | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
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 to a Chrome already started with a debug port, or
|
|
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,7 +72,7 @@ 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
78
|
> boots and lists all 37 tools. The one exception is CLI mode's `AGENT_IN_CHROME_KEEP=1`, which needs
|
|
@@ -111,7 +111,7 @@ schema. Guessing the paths is how this usually fails: a wrong path gets you a ba
|
|
|
111
111
|
The installer will (every step reversible, and every file it's about to touch is listed before it touches it):
|
|
112
112
|
|
|
113
113
|
1. Sync the runtime into `~/.agent-in-chrome/agent-in-chrome/` and write the native host manifest into each Chromium browser's `NativeMessagingHosts/` directory.
|
|
114
|
-
2. Detect the agents on your machine (Claude Code, Claude Desktop, WorkBuddy, ZCode, opencode, Kimi CLI, Gemini CLI, Antigravity, Qoder CLI, Qoder IDE, Trae, Codex CLI, DeepSeek Harness, plus the China builds Qoder CN CLI / Qoder CN IDE / Trae CN —
|
|
114
|
+
2. Detect the agents on your machine (Claude Code, Claude Desktop, WorkBuddy, WorkBuddy AI, ZCode, opencode, Kimi CLI, Gemini CLI, Antigravity, Qoder CLI, Qoder IDE, Trae, Codex CLI, DeepSeek Harness, plus the China builds Qoder CN CLI / Qoder CN IDE / Trae CN — 17 in total), show you the exact file and content it would write for each, and register the MCP server after you confirm (originals backed up automatically; `--yes` skips the per-agent prompts, `--agents=claude-code,trae` narrows the set, `--no-agents` skips this entirely).
|
|
115
115
|
3. Generate a **connection token unique to this machine** (mode `0600`, never committed, never uploaded) — see [Security and transparency](#security-and-transparency).
|
|
116
116
|
4. Install **two skills and two commands**: `skills/agent-in-chrome/` (including the reference handbooks under `references/`, which teach the agent how to use the browser tools) and `skills/install-agent-in-chrome/` (which teaches it how to install this into another client) are copied to `~/.agent-in-chrome/skills/`, and the `/agent-in-chrome` and `/install-agent-in-chrome` commands to `~/.agent-in-chrome/commands/`.
|
|
117
117
|
|
|
@@ -340,7 +340,7 @@ follow the npm package.
|
|
|
340
340
|
- **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
341
|
- **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
342
|
- **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
|
|
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 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
344
|
|
|
345
345
|
---
|
|
346
346
|
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ by Liang · [liangai.org](https://liangai.org)
|
|
|
23
23
|
|
|
24
24
|
Agent in Chrome 把 AI agent(Claude Code、Claude Desktop、Trae、Codex……)接到**你自己正在用的那个 Chrome** 上。它通过 [MCP](https://modelcontextprotocol.io) 暴露一套浏览器工具,让 agent 能读页面、点按钮、填表单、抓网络请求——全部带着你现有的登录态,全部在后台进行,不抢你的前台。
|
|
25
25
|
|
|
26
|
-
**和别的方案怎么选?** 下面只对比**开箱即有的原生能力**:✅ = 不写代码就能用,❌ = 不具备(多数工具带任意代码执行的逃生舱,理论上都能自己补——若把那也算上,所有格子都是 ✅,表格就没有意义了)。基于 2026-08-18
|
|
26
|
+
**和别的方案怎么选?** 下面只对比**开箱即有的原生能力**:✅ = 不写代码就能用,❌ = 不具备(多数工具带任意代码执行的逃生舱,理论上都能自己补——若把那也算上,所有格子都是 ✅,表格就没有意义了)。基于 2026-08-18 的源码通读与本机实测(Playwright MCP、browser-use、ego lite 三列于 2026-09-10 以同一套任务书与专项探针逐格复测:Playwright MCP 与 ego lite 的任务完成度与 agent-in-chrome / chrome-devtools-mcp 同档,browser-use 实测出工具面缺口,见脚注),版本:@playwright/mcp 0.0.80 · chrome-devtools-mcp 1.7.0 · browser-use 0.13.10 · ego lite 0.5.0.28。不做推荐,按你的场景自取。
|
|
27
27
|
|
|
28
28
|
| | Agent in Chrome | Playwright MCP | Chrome DevTools MCP | browser-use | ego lite |
|
|
29
29
|
|---|:---:|:---:|:---:|:---:|:---:|
|
|
@@ -33,16 +33,16 @@ Agent in Chrome 把 AI agent(Claude Code、Claude Desktop、Trae、Codex……
|
|
|
33
33
|
| 走 MCP 协议 | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
34
34
|
| Windows / Linux | ✅⁵ | ✅ | ✅ | ✅ | ❌ |
|
|
35
35
|
| Firefox / WebKit | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
36
|
-
| 网络原始头 + 请求/响应体 | ✅ | ✅ | ✅ | ❌ |
|
|
37
|
-
| WebSocket 帧 / 发起调用栈 / 导出 curl | ✅ |
|
|
38
|
-
| 请求 mock / 限速模拟 / 性能 trace | ❌ |
|
|
39
|
-
| 凭据默认打码(Cookie/密码不进模型上下文) | ✅ | ❌⁶ | ❌⁶ | ✅⁷ |
|
|
40
|
-
| 无「服务端任意代码执行」默认开启 | ✅ | ❌⁸ | ✅ |
|
|
36
|
+
| 网络原始头 + 请求/响应体 | ✅ | ✅ | ✅ | ❌ | ❌⁹ |
|
|
37
|
+
| WebSocket 帧 / 发起调用栈 / 导出 curl | ✅ | ❌¹² | ❌ | ❌ | ❌⁹ |
|
|
38
|
+
| 请求 mock / 限速模拟 / 性能 trace | ❌ | ❌¹² | ✅ | ❌ | ❌⁹ |
|
|
39
|
+
| 凭据默认打码(Cookie/密码不进模型上下文) | ✅ | ❌⁶ | ❌⁶ | ✅⁷ | ❌⁹ |
|
|
40
|
+
| 无「服务端任意代码执行」默认开启 | ✅ | ❌⁸ | ✅ | ❌¹⁰ | ❌¹⁰ |
|
|
41
41
|
| 零运行时第三方依赖 | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
42
|
-
| 模态浮层检出(含无 ARIA 角色的登录墙) | ✅ | ❌ | ❌ |
|
|
43
|
-
| 元素像素坐标 + 跨源帧顶层坐标 | ✅ | ❌ | ❌ |
|
|
42
|
+
| 模态浮层检出(含无 ARIA 角色的登录墙) | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
43
|
+
| 元素像素坐标 + 跨源帧顶层坐标 | ✅ | ❌ | ❌ | ❌¹¹ | ❌¹¹ |
|
|
44
44
|
|
|
45
|
-
<sup>1</sup> 仅 `--extension` 模式(Chrome/Edge,需装其扩展);默认模式是独立 profile。 <sup>2</sup> 仅 `--autoConnect`(Chrome 144+,需在 `chrome://inspect` 手动开闸,该 profile 全部窗口暴露)。 <sup>3</sup>
|
|
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,7 +72,7 @@ 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
77
|
> 18 够用是实测过的:Node 18.20.8 上 `check` 全过、MCP server 起得来、37 个工具都在。唯一的例外在
|
|
78
78
|
> CLI 模式的 `AGENT_IN_CHROME_KEEP=1` 那条路上——它要 Node 的全局 `WebSocket`,**Node 22 才有**;
|
|
@@ -107,7 +107,7 @@ schema 写进去。路径靠猜是这件事最常见的失败方式:猜错了
|
|
|
107
107
|
安装器会(全部可逆、动手前列出将改动的文件):
|
|
108
108
|
|
|
109
109
|
1. 把运行时同步到 `~/.agent-in-chrome/agent-in-chrome/`,并把 native host 清单写进你各个 Chromium 浏览器的 `NativeMessagingHosts/` 目录;
|
|
110
|
-
2. 探测本机的 agent(Claude Code / Claude Desktop / WorkBuddy / ZCode / opencode / Kimi CLI / Gemini CLI / Antigravity / Qoder CLI / Qoder IDE / Trae / Codex CLI / DeepSeek Harness,以及国内版 Qoder CN CLI / Qoder CN IDE / Trae CN,共
|
|
110
|
+
2. 探测本机的 agent(Claude Code / Claude Desktop / WorkBuddy / WorkBuddy AI / ZCode / opencode / Kimi CLI / Gemini CLI / Antigravity / Qoder CLI / Qoder IDE / Trae / Codex CLI / DeepSeek Harness,以及国内版 Qoder CN CLI / Qoder CN IDE / Trae CN,共 17 家),逐个展示将写入的文件和内容、确认后在各自的 MCP 配置里注册(改前自动备份;`--yes` 跳过逐个确认,`--agents=claude-code,trae` 限定范围,`--no-agents` 完全跳过);
|
|
111
111
|
3. 在本机生成一个**每台机器唯一的连接令牌**(`0600`,不写进仓库、不上传)——见[安全与透明度](#安全与透明度);
|
|
112
112
|
4. 把**两份 skill 和两条命令**装好:`skills/agent-in-chrome/`(含 `references/` 下的分册手册,教 agent 怎么用这些浏览器工具)和 `skills/install-agent-in-chrome/`(教 agent 怎么把它装到别的客户端上)拷到 `~/.agent-in-chrome/skills/`,`/agent-in-chrome` 与 `/install-agent-in-chrome` 两条命令拷到 `~/.agent-in-chrome/commands/`。
|
|
113
113
|
|
|
@@ -333,7 +333,7 @@ npx @liang-hz/agent-in-chrome@latest update
|
|
|
333
333
|
- **跨源 iframe 被 CSS 变换(旋转/缩放/斜切)过时坐标算不出来**,里面的元素点不了,`read_page` 会标 `coords:"未知"`——改用 `browser_new_tab` 直接打开那个地址。
|
|
334
334
|
- **不做性能 / a11y / SEO 审计打分**——那类需求 `npx lighthouse <url> --view` 一条命令就跑完,还带 Chrome 官方的评分口径;插件模式下我们挂的是你自己那个没有调试端口的 Chrome,硬做只会做出一个更差的 Lighthouse。**分工**:跑分交给 `npx lighthouse`,我们负责它进不去的地方——需要登录态的页面、点开某个面板之后才出现的那一屏、以及看具体某个请求的头和响应体。
|
|
335
335
|
- **没有专门的拖拽工具**——拖滑块、拖放排序、画布手势用 `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
|
|
336
|
+
- **平台**:macOS 完整实测。**Windows 插件模式与 CLI/headless 模式均已支持**(插件模式:注册表 + 命名管道 + `.bat` 启动器,桥接第一道防线由目录权限换成令牌,详见 `mcp/token.mjs` 的 bridgeEndpoint 注释;CLI 模式:进程表/占用者/收场三处数据源走 Windows 对应物,见 `mcp/cdp/browser-launch.mjs`)。CLI 模式在 Windows 上初测通过,长跑反馈欢迎开 issue。Linux 路径已写未验证。欢迎 PR。
|
|
337
337
|
|
|
338
338
|
---
|
|
339
339
|
|
package/docs/AGENTS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 安装器(`npx @liang-hz/agent-in-chrome install`)会自动写好这一切,**正常情况下你不需要读这个文件**。
|
|
4
4
|
> 它存在的用途:核对安装器到底写了什么、或在不能跑安装器的环境里手动登记。
|
|
5
|
-
> 从 [README](../README.md) 挪出来,免得
|
|
5
|
+
> 从 [README](../README.md) 挪出来,免得 17 家客户端的配置路径挡在快速开始的正路上。
|
|
6
6
|
|
|
7
7
|
安装器会自动写好这些;下面是它实际写入的文件和内容,供你核对或手动登记。把 `<RUNTIME>` 换成安装器打印的实际路径(默认 `~/.agent-in-chrome/agent-in-chrome`)。每个文件改前都会留 `.bak-<时间戳>` 备份,且只动 `agent-in-chrome` 这一个键。
|
|
8
8
|
|
|
@@ -41,6 +41,24 @@ claude mcp add --scope user agent-in-chrome -- node <RUNTIME>/server.mjs
|
|
|
41
41
|
> 同目录那个隐藏的 `.mcp.json` 是 WorkBuddy 自己的**输出**文件(每次启动写 connector-proxy 聚合条目),
|
|
42
42
|
> 往里写注册它不读;装的时候会顺带把老版本写错在那里的条目摘掉。
|
|
43
43
|
|
|
44
|
+
**WorkBuddy AI**(国际版,`~/.workbuddy-ai/mcp.json`,**非隐藏**那份):
|
|
45
|
+
```json
|
|
46
|
+
{ "mcpServers": { "agent-in-chrome": {
|
|
47
|
+
"type": "stdio", "command": "<RUNTIME>/mcp-launcher.sh", "args": [], "disabled": false
|
|
48
|
+
} } }
|
|
49
|
+
```
|
|
50
|
+
> 和国内版是**同一份代码、只换数据目录**(`cli/product.json` 的 `dataFolderName`:国内版
|
|
51
|
+
> `.workbuddy`、国际版 `.workbuddy-ai`),所以条目形状、文件名、`readCustomMcpConfig`
|
|
52
|
+
> 的读法全都逐字相同——只是目录不同,**两家各写各的,互不覆盖**。
|
|
53
|
+
> 没有 legacy 要清:历史上写错的隐藏 `.mcp.json` 只落在国内版目录下。
|
|
54
|
+
>
|
|
55
|
+
> **国际版多一道信任闸**:第三方 MCP server 写进 `mcp.json` 后,连接器中心里会显示为
|
|
56
|
+
> 「需要你的授权」(`trustLevel: gray` + `status: disabled`),点一下信任才会连。
|
|
57
|
+
> 信任记录在 `~/.workbuddy-ai/mcp-approvals.json`,键是
|
|
58
|
+
> `sha256(command|args|envKeys)::serverName`——**它是进程启动时一次性加载的**,
|
|
59
|
+
> 所以在应用运行期间手改这个文件无效,只能在 UI 里点(或改完重启应用)。
|
|
60
|
+
> 国内版同一套机制,落点是 `~/.workbuddy/mcp-approvals.json`。
|
|
61
|
+
|
|
44
62
|
**ZCode**(`~/.zcode/cli/config.json`,段落是 `mcp.servers`)、**opencode**(`~/.config/opencode/opencode.json`,段落是 `mcp`,`command` 是数组且要 `enabled: true`)、
|
|
45
63
|
**Kimi CLI**(`~/.kimi/mcp.json`)、**Gemini CLI**(`~/.gemini/settings.json`)——
|
|
46
64
|
后两家都是标准 `mcpServers` 形状。安装器只碰 `agent-in-chrome` 这一个键,其余内容原样保留(改前自动备份)。
|
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.55.
|
|
4
|
+
"version": "0.55.5",
|
|
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",
|
package/extension/sw.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// 所有 browser_* 工具的实现都在这个文件里(工具表见 TOOLS)。
|
|
10
10
|
|
|
11
11
|
const HOST_NAME = "org.liangai.agent_in_chrome";
|
|
12
|
-
const VERSION = "0.55.
|
|
12
|
+
const VERSION = "0.55.5";
|
|
13
13
|
/* 这个 service worker 实例是什么时候起来的(= 磁盘上的代码是什么时候读进来的),见 hello */
|
|
14
14
|
const SW_BOOTED_AT = Date.now();
|
|
15
15
|
/* agent 开的标签页统一收进这一组,跟用户自己的标签页视觉隔离 */
|
|
@@ -2978,26 +2978,44 @@ async function wakeTab(tabId) {
|
|
|
2978
2978
|
* 探针(inPage)走的都是单帧默认注入——不一起防住,卡点只是往后挪了一步。
|
|
2979
2979
|
*/
|
|
2980
2980
|
async function injectStaged(opts) {
|
|
2981
|
-
const
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
2981
|
+
const tabId = opts.target?.tabId;
|
|
2982
|
+
let wakePending = null;
|
|
2983
|
+
const pulseWake = () => {
|
|
2984
|
+
if (tabId == null) return Promise.resolve();
|
|
2985
|
+
if (!wakePending) {
|
|
2986
|
+
wakePending = wakeTab(tabId)
|
|
2987
|
+
.catch(() => {})
|
|
2988
|
+
.finally(() => {
|
|
2989
|
+
wakePending = null;
|
|
2990
|
+
});
|
|
2991
|
+
}
|
|
2992
|
+
return wakePending;
|
|
2993
|
+
};
|
|
2994
|
+
const heartbeat = tabId == null ? null : setInterval(() => void pulseWake(), EVAL_WAKE_MS);
|
|
2995
|
+
try {
|
|
2996
|
+
const idle = chrome.scripting.executeScript(opts);
|
|
2997
|
+
const PENDING = {};
|
|
2998
|
+
let timer;
|
|
2999
|
+
const first = await Promise.race([
|
|
3000
|
+
idle,
|
|
3001
|
+
new Promise((r) => {
|
|
3002
|
+
timer = setTimeout(() => r(PENDING), IDLE_INJECT_MS);
|
|
3003
|
+
}),
|
|
3004
|
+
]).finally(() => clearTimeout(timer));
|
|
3005
|
+
if (first !== PENDING) return { res: first, degraded: false };
|
|
3006
|
+
Promise.resolve(idle).catch(() => {});
|
|
3007
|
+
await pulseWake();
|
|
3008
|
+
const res = await deadline(
|
|
3009
|
+
chrome.scripting.executeScript({ ...opts, injectImmediately: true }),
|
|
3010
|
+
IMMEDIATE_INJECT_MS,
|
|
3011
|
+
`页面注入 ${IDLE_INJECT_MS + IMMEDIATE_INJECT_MS}ms 没有回执(等帧就绪、立即注入两条路都试过了):` +
|
|
3012
|
+
`这张标签页的注入路卡死了,重试大概率还是它。用 browser_new_tab 开一张新的、地址照旧,在新页上重来;` +
|
|
3013
|
+
`这张页也没全废——browser_eval 走 CDP,仍然读得到东西。`
|
|
3014
|
+
);
|
|
3015
|
+
return { res, degraded: true };
|
|
3016
|
+
} finally {
|
|
3017
|
+
if (heartbeat !== null) clearInterval(heartbeat);
|
|
3018
|
+
}
|
|
3001
3019
|
}
|
|
3002
3020
|
|
|
3003
3021
|
/*
|
|
@@ -3162,7 +3180,7 @@ function cursorAgent(op, A) {
|
|
|
3162
3180
|
A = {
|
|
3163
3181
|
x: Math.round((window.innerWidth || 0) / 2),
|
|
3164
3182
|
y: Math.round((window.innerHeight || 0) * 0.4),
|
|
3165
|
-
travelMs:
|
|
3183
|
+
travelMs: 0,
|
|
3166
3184
|
kind: "move",
|
|
3167
3185
|
idle: true,
|
|
3168
3186
|
};
|
|
@@ -3288,7 +3306,8 @@ function cursorAgent(op, A) {
|
|
|
3288
3306
|
|
|
3289
3307
|
const kind = String((A && A.kind) || "move");
|
|
3290
3308
|
const label = A && A.label ? String(A.label).slice(0, 40) : "";
|
|
3291
|
-
const travel =
|
|
3309
|
+
const travel =
|
|
3310
|
+
A && A.travelMs != null ? Math.max(0, Math.min(600, Number(A.travelMs) || 0)) : 0;
|
|
3292
3311
|
|
|
3293
3312
|
w.className = "w";
|
|
3294
3313
|
void w.offsetWidth;
|
|
@@ -3947,10 +3966,21 @@ function pageAgent(op, arg) {
|
|
|
3947
3966
|
let b = box(el);
|
|
3948
3967
|
let scrolled = false;
|
|
3949
3968
|
const offscreen = (r) => r.x + r.w <= 0 || r.y + r.h <= 0 || r.x >= vw || r.y >= vh;
|
|
3969
|
+
const SLIVER_MIN_PX = 6;
|
|
3970
|
+
const sliver = (r) => {
|
|
3971
|
+
if (r.x < 0 && r.x + r.w > 0 && r.x + r.w < SLIVER_MIN_PX) return true;
|
|
3972
|
+
if (r.x < vw && r.x + r.w > vw && vw - r.x < SLIVER_MIN_PX) return true;
|
|
3973
|
+
if (r.y < 0 && r.y + r.h > 0 && r.y + r.h < SLIVER_MIN_PX) return true;
|
|
3974
|
+
if (r.y < vh && r.y + r.h > vh && vh - r.y < SLIVER_MIN_PX) return true;
|
|
3975
|
+
return false;
|
|
3976
|
+
};
|
|
3950
3977
|
if (el.scrollIntoView) {
|
|
3951
3978
|
if (offscreen(b)) {
|
|
3952
3979
|
scrolled = scrollIn(el, "center");
|
|
3953
3980
|
b = box(el);
|
|
3981
|
+
} else if (sliver(b)) {
|
|
3982
|
+
scrolled = scrollIn(el, "center") || scrolled;
|
|
3983
|
+
b = box(el);
|
|
3954
3984
|
} else {
|
|
3955
3985
|
const c0 = clipperOf(el);
|
|
3956
3986
|
if (c0 && c0.canScroll) {
|
|
@@ -6986,6 +7016,13 @@ function markFileInputInPage(ref, selector, token) {
|
|
|
6986
7016
|
fired[token] = { change: false, input: false };
|
|
6987
7017
|
const onChange = () => {
|
|
6988
7018
|
fired[token].change = true;
|
|
7019
|
+
try {
|
|
7020
|
+
fired[token].filesAtChange = [...el.files].map((f) => ({
|
|
7021
|
+
name: f.name,
|
|
7022
|
+
size: f.size,
|
|
7023
|
+
type: f.type || "",
|
|
7024
|
+
}));
|
|
7025
|
+
} catch {}
|
|
6989
7026
|
};
|
|
6990
7027
|
const onInput = () => {
|
|
6991
7028
|
fired[token].input = true;
|
|
@@ -7034,11 +7071,28 @@ function readFileInputInPage(token) {
|
|
|
7034
7071
|
};
|
|
7035
7072
|
el = walk(document);
|
|
7036
7073
|
}
|
|
7037
|
-
if (!el)
|
|
7074
|
+
if (!el) {
|
|
7075
|
+
const caught = fired.filesAtChange;
|
|
7076
|
+
if (caught) {
|
|
7077
|
+
try {
|
|
7078
|
+
delete regs[token];
|
|
7079
|
+
} catch {}
|
|
7080
|
+
try {
|
|
7081
|
+
delete firedAll[token];
|
|
7082
|
+
} catch {}
|
|
7083
|
+
return {
|
|
7084
|
+
files: caught,
|
|
7085
|
+
count: caught.length,
|
|
7086
|
+
changeFired: nativeChange,
|
|
7087
|
+
inputFired: nativeInput,
|
|
7088
|
+
elementReplaced: true,
|
|
7089
|
+
};
|
|
7090
|
+
}
|
|
7038
7091
|
return {
|
|
7039
7092
|
error:
|
|
7040
7093
|
"上传目标在设置过程中从页面上消失了(页面可能重新渲染或导航过)。重新 browser_read_page 后再试一次。",
|
|
7041
7094
|
};
|
|
7095
|
+
}
|
|
7042
7096
|
|
|
7043
7097
|
const files = [];
|
|
7044
7098
|
try {
|
|
@@ -9145,6 +9199,17 @@ const TOOLS = {
|
|
|
9145
9199
|
sid
|
|
9146
9200
|
) {
|
|
9147
9201
|
const tabId = await withTarget(sid, wantTab);
|
|
9202
|
+
try {
|
|
9203
|
+
const tab = await chrome.tabs.get(tabId);
|
|
9204
|
+
const win = await chrome.windows.get(tab.windowId);
|
|
9205
|
+
if (win.state === "minimized") {
|
|
9206
|
+
throw new Error(
|
|
9207
|
+
"Chrome 窗口是最小化的:最小化的窗口不产帧,截图会一直挂到超时。先把窗口恢复(点任务栏图标即可,不必切过去)再试。"
|
|
9208
|
+
);
|
|
9209
|
+
}
|
|
9210
|
+
} catch (e) {
|
|
9211
|
+
if (/最小化的窗口/.test(String(e?.message || e))) throw e;
|
|
9212
|
+
}
|
|
9148
9213
|
const given = [region ? "region" : null, ref ? "ref" : null, selector ? "selector" : null, fullPage ? "fullPage" : null].filter(Boolean);
|
|
9149
9214
|
if (given.length > 1) {
|
|
9150
9215
|
throw new Error(`region / ref / selector / fullPage 只能给一个,收到了 ${given.join(" 和 ")},什么都没截。`);
|
|
@@ -10776,6 +10841,7 @@ const TOOLS = {
|
|
|
10776
10841
|
},
|
|
10777
10842
|
changeFired: back.changeFired,
|
|
10778
10843
|
changeDispatchedManually: back.changeDispatchedManually || undefined,
|
|
10844
|
+
elementReplaced: back.elementReplaced || undefined,
|
|
10779
10845
|
hint: back.changeFired
|
|
10780
10846
|
? undefined
|
|
10781
10847
|
: "页面没有收到 change 事件,说明它可能并不监听这个输入框。检查上传是否真的开始了。",
|
|
@@ -10950,7 +11016,7 @@ async function applyViewport(tabId, vp, warnings) {
|
|
|
10950
11016
|
: `按 ${got.innerWidth} 这个宽度去算坐标和断点,别按你给的那个。`)
|
|
10951
11017
|
);
|
|
10952
11018
|
}
|
|
10953
|
-
if (got.dpr
|
|
11019
|
+
if (Math.abs(Number(got.dpr) - Number(dsf)) > 0.001) warnings.push(`devicePixelRatio 实际是 ${got.dpr},不是你给的 ${dsf}。`);
|
|
10954
11020
|
return out;
|
|
10955
11021
|
}
|
|
10956
11022
|
|