pi-chrome 0.15.49 → 0.15.53
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/CHANGELOG.md +26 -0
- package/README.md +63 -109
- package/SECURITY.md +1 -0
- package/docs/FAQ.md +3 -1
- package/extensions/chrome-profile-bridge/browser-extension/manifest.json +1 -1
- package/extensions/chrome-profile-bridge/browser-extension/service_worker.js +385 -35
- package/extensions/chrome-profile-bridge/index.ts +183 -34
- package/package.json +2 -2
- package/test-suite/unit/background-policy.test.mjs +3 -1
- package/test-suite/unit/bridge-resilience.test.mjs +138 -0
- package/test-suite/unit/cdp-passthrough.test.mjs +183 -0
- package/test-suite/unit/chrome-command.test.mjs +163 -0
- package/test-suite/unit/type-evidence.test.mjs +208 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable user-facing changes to `pi-chrome`.
|
|
4
4
|
|
|
5
|
+
## 0.15.53 — 2026-09-26
|
|
6
|
+
|
|
7
|
+
Changes adapted from community forks (ardhiqii, kkunkunya, nihar-oracle, steimerbyte).
|
|
8
|
+
|
|
9
|
+
- **Connector recovers from stalled connections.** The extension's `/next` long poll now gives up after 45s (the bridge holds it for up to 25s). Before this, a half-open socket (Pi process died, machine slept, network changed) could leave the extension waiting forever until someone reloaded it by hand. Result posts time out, retry on network/5xx failures, and are never posted twice for the same command.
|
|
10
|
+
- **Page actions work on a fresh automation tab.** Chrome refuses `chrome.scripting` on a top-level `about:blank`, which is where the dedicated automation tab starts. As a result, `chrome_snapshot`, `chrome_inspect`, console/network listing, uid click targeting, and the `/chrome doctor` page probe failed on that tab with `Cannot access contents of url "about:blank"`. When Chrome refuses scripting for a permission reason, these calls now fall back to CDP `Runtime.evaluate`. Ordinary pages still use `chrome.scripting` first.
|
|
11
|
+
- **Chrome tools in subagent sessions.** A second load of the same pi-chrome install in one process (for example, pi-subagents) was skipped as a duplicate, so subagents had no `chrome_*` tools. It now loads as a client of the shared bridge. Subagents share the parent's authorization and get their own automation tab and tab group. Two different install roots are still treated as duplicates. `chrome_launch` in a client session now reports the shared connection state instead of always saying "waiting for extension".
|
|
12
|
+
- **New `chrome_cdp` and `chrome_cdp_targets` tools.** `chrome_cdp` runs one raw Chrome DevTools Protocol method on a tab and validates the method/params first. `timeoutMs` can extend the deadline up to 120s, and screenshot/binary or oversized results are summarized instead of returned in full. Background mode blocks `Page.bringToFront` and `Target.activateTarget`. `chrome_cdp_targets` lists CDP targets on a tab, such as password-manager overlays or DevTools, to help diagnose `Detached while handling command`. It never attaches the debugger or creates a tab.
|
|
13
|
+
- **`chrome_type` shows what it typed.** Results include the field value before and after, and `insertedAt` (`empty`, `caret-end`, `caret-middle`, `replaced-selection`, `replaced-all`). The text warns when input was spliced into existing content, when Enter may have submitted the spliced value, and when the field did not change at all (keystrokes did not reach it). Password/OTP/card-like fields report only lengths. New `replace: true` selects all with Chrome's platform-neutral `selectAll` editing command and deletes before typing. Tool descriptions now state that `chrome_type` inserts at the caret and `chrome_fill` replaces.
|
|
14
|
+
- **`includeSnapshot` waits for navigations.** If a click/type/fill/key action starts a navigation, the included snapshot waits up to 5s for the new page and reports `navigation {from, to, settled, waitedMs}`. Before, it could describe the page being replaced. Actions without navigation do not wait. A page that was already loading is reported but not waited on.
|
|
15
|
+
- **CDP timeouts report as timeouts.** A timed-out CDP command now fails with `CDP <method> timed out after Nms`. Before, the cleanup detach surfaced as `Detached while handling command`, and the command was re-sent once, so a slow command could run twice.
|
|
16
|
+
- **`chrome_tab new` reports the loaded tab.** It waits up to 5s for the URL to load and returns `loadStatus` instead of Chrome's initial empty `loading` tab.
|
|
17
|
+
- **Tool activation.** `chrome_find`, `chrome_inspect`, and the new CDP tools are now activated by `/chrome authorize` and removed from the active tool set by `/chrome revoke` or grant expiry, like the other `chrome_*` tools.
|
|
18
|
+
- **Validation.** New unit suites: `bridge-resilience`, `cdp-passthrough`, `type-evidence`.
|
|
19
|
+
|
|
20
|
+
## 0.15.51 — 2026-09-10
|
|
21
|
+
|
|
22
|
+
- **Fewer Chrome commands.** Removed `/chrome status`; use bare `/chrome` for the quick connection, authorization, and background dashboard plus controls. The dashboard remains lightweight and does not run page probes.
|
|
23
|
+
- **Complete Doctor report.** `/chrome doctor` now includes authorization and background state alongside connection, version, page checks, and troubleshooting hints, even when Chrome is offline or outdated.
|
|
24
|
+
- **Command regressions.** Added tests for command dispatch/completion, lightweight dashboard behavior, Doctor state reporting, and failure paths. `/chrome background status` remains available.
|
|
25
|
+
|
|
26
|
+
## 0.15.50 — 2026-09-10
|
|
27
|
+
|
|
28
|
+
- **README clarity.** Lead with workflow examples, correct setup ordering and platform-specific onboarding instructions, and clarify privacy guidance. Describe background behavior and the on/off/status controls directly.
|
|
29
|
+
- **Documentation-only release.** Browser behavior and permissions are unchanged. The companion version matches the npm package version.
|
|
30
|
+
|
|
5
31
|
## 0.15.49 — 2026-09-10
|
|
6
32
|
|
|
7
33
|
- **Validation scope.** Node regression suites passed. Live browser validation remains incomplete: an input attempt encountered `Input.dispatchMouseEvent: Detached while handling command.`; a subsequent retest was blocked by a disconnected companion. No live-browser pass is claimed for these changes.
|
package/README.md
CHANGED
|
@@ -1,157 +1,111 @@
|
|
|
1
1
|
# pi-chrome
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Give Pi the Chrome you're already signed into.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Debug your app, inspect signed-in dashboards, and capture screenshots using your existing Chrome profile—without setting up a separate automation browser.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
You: "Find my open GitHub PR tab, summarize review state, and screenshot failing CI."
|
|
9
|
-
Agent: chrome_tab(list) → chrome_snapshot(uid:…) → chrome_screenshot(...)
|
|
10
|
-
✓ 3 reviewers, 1 change requested, CI red on iOS. Saved → .pi/chrome-screenshots/ci.png
|
|
11
|
-
You: [keeps coding — agent never asked you to log in]
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
`pi-chrome` runs through a small Chrome extension inside the Chrome profile **you already use** — including sites where you're already signed in. Agents can inspect or control Chrome only after you run `/chrome authorize` in current Pi session.
|
|
7
|
+
Built for the [Pi coding agent](https://pi.dev).
|
|
15
8
|
|
|
16
|
-
|
|
9
|
+
## What you can do
|
|
17
10
|
|
|
18
|
-
|
|
11
|
+
Try prompts like these after setup:
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
| Use case | Ask Pi |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| **Debug a signed-in app** | “Reproduce the filter bug in my staging app. Inspect captured console and network errors, then save a screenshot.” |
|
|
16
|
+
| **Understand an existing page** | “Find my open dashboard tab and summarize what's on the page. Don't change anything.” |
|
|
17
|
+
| **Create evidence for a PR** | “On my local app, capture the empty, loading, and populated states of this feature for my PR.” |
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
Pi gets tools to inspect pages, click, type, fill forms, scroll, upload files, capture screenshots, and inspect captured console logs and `fetch`/`XMLHttpRequest` responses. A raw Chrome DevTools Protocol tool (`chrome_cdp`) covers anything else, such as device emulation, cookies, PDFs, or the accessibility tree. You describe the task; Pi handles the agent loop.
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
/chrome onboard
|
|
28
|
-
```
|
|
21
|
+
**Best fit:** interactive workflows in the Chrome profile you already use. For deterministic CI tests, consider a test framework such as Playwright; for fleets of isolated browsers, consider a hosted browser service. See [more workflows](./docs/EXAMPLES.md) and [browser-tool comparisons](./docs/COMPARISON.md).
|
|
29
22
|
|
|
30
|
-
|
|
23
|
+
## Quick start
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
2. Click **Load unpacked**.
|
|
34
|
-
3. Open path field with **Cmd+Shift+G** on macOS or **Ctrl+L** on Windows/Linux.
|
|
35
|
-
4. Paste copied path.
|
|
36
|
-
5. Press Enter.
|
|
25
|
+
**Requirements:** [Pi](https://pi.dev) and Google Chrome. Setup includes a one-time manual installation of the bundled Chrome companion extension.
|
|
37
26
|
|
|
38
|
-
|
|
27
|
+
> **Trust and privacy:** The companion has broad browser permissions and runs in your real Chrome profile. Review [its source](./extensions/chrome-profile-bridge/browser-extension/) before loading it, and authorize only tasks you trust. The browser bridge is local, but page content returned to Pi may be sent to your configured model provider.
|
|
39
28
|
|
|
40
|
-
|
|
41
|
-
/reload
|
|
42
|
-
```
|
|
29
|
+
### 1. Install and load the Pi package
|
|
43
30
|
|
|
44
|
-
|
|
31
|
+
In your terminal:
|
|
45
32
|
|
|
46
|
-
```
|
|
47
|
-
|
|
33
|
+
```bash
|
|
34
|
+
pi install npm:pi-chrome
|
|
48
35
|
```
|
|
49
36
|
|
|
50
|
-
|
|
37
|
+
Start Pi with `pi`. If Pi is already running, run `/reload` in that session **before** using the `/chrome` commands.
|
|
51
38
|
|
|
52
|
-
|
|
53
|
-
✓ Chrome is connected (...)
|
|
54
|
-
```
|
|
39
|
+
### 2. Connect Chrome
|
|
55
40
|
|
|
56
|
-
|
|
41
|
+
In Pi:
|
|
57
42
|
|
|
58
43
|
```text
|
|
59
|
-
/chrome
|
|
60
|
-
/chrome doctor
|
|
44
|
+
/chrome onboard
|
|
61
45
|
```
|
|
62
46
|
|
|
63
|
-
|
|
47
|
+
The setup dialog shows the companion extension's folder path.
|
|
64
48
|
|
|
65
|
-
|
|
49
|
+
- **macOS:** after confirmation, Pi opens `chrome://extensions`, reveals the companion folder in Finder, and copies its path to your clipboard.
|
|
50
|
+
- **Windows/Linux:** copy the folder path shown in the dialog and open `chrome://extensions` manually. Automatic desktop opening and clipboard setup are currently macOS-only.
|
|
66
51
|
|
|
67
|
-
|
|
52
|
+
In Chrome:
|
|
68
53
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
- Inspect console logs and captured `fetch`/`XMLHttpRequest` responses.
|
|
73
|
-
- Manage tabs without taking over your active window.
|
|
74
|
-
|
|
75
|
-
Tool parameters and gotchas are documented inline in Pi.
|
|
76
|
-
|
|
77
|
-
### Typing into rich editors
|
|
78
|
-
|
|
79
|
-
`chrome_type` and `chrome_fill` use one native CDP `Input.insertText` operation for focused contenteditables. This avoids per-character delays for long text and preserves Unicode/newlines. Ordinary inputs and textareas retain individual key events.
|
|
80
|
-
|
|
81
|
-
For an editor that needs a `keydown` for every character, pass `perCharacter:true`. Bulk insertion still uses Chrome's input system, but does not emit per-character key events or a clipboard `paste` event. Use `includeSnapshot:true` to verify the result; `chrome_fill` still honors `domFallback:false` when synthetic fallback is unwanted.
|
|
82
|
-
|
|
83
|
-
---
|
|
54
|
+
1. Turn on **Developer mode**.
|
|
55
|
+
2. Click **Load unpacked**.
|
|
56
|
+
3. Select the companion folder shown by `/chrome onboard`. On macOS, press **Cmd+Shift+G** in the folder picker and paste the copied path.
|
|
84
57
|
|
|
85
|
-
|
|
58
|
+
### 3. Authorize and verify
|
|
86
59
|
|
|
87
|
-
|
|
60
|
+
In Pi:
|
|
88
61
|
|
|
89
62
|
```text
|
|
90
|
-
/chrome authorize
|
|
91
|
-
/chrome
|
|
92
|
-
/chrome authorize indefinite
|
|
93
|
-
/chrome revoke # lock again
|
|
94
|
-
/chrome status
|
|
63
|
+
/chrome authorize
|
|
64
|
+
/chrome doctor
|
|
95
65
|
```
|
|
96
66
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
- Extension runs in your real Chrome profile and has broad tab/scripting permissions. Install only from trusted package source.
|
|
100
|
-
- Pi side binds to `127.0.0.1:17318` only; no default network exposure.
|
|
101
|
-
- Bridge rejects browser-origin command requests, so ordinary web pages cannot drive it through CORS.
|
|
102
|
-
- Each Pi session gets its own automation target; user tabs/windows are not closed by cleanup.
|
|
103
|
-
- `/chrome revoke` closes only calling session's automation target.
|
|
104
|
-
|
|
105
|
-
Security details: [`SECURITY.md`](./SECURITY.md). Architecture details: [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md).
|
|
67
|
+
Approve the authorization prompt for a task you trust. The default authorization lasts **15 minutes**. Doctor should report `✓ Chrome is connected (...)`; follow its instructions if any checks fail.
|
|
106
68
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
## Commands
|
|
69
|
+
Then try a read-only first task:
|
|
110
70
|
|
|
111
71
|
```text
|
|
112
|
-
|
|
113
|
-
/chrome doctor # connectivity + version + eval checks
|
|
114
|
-
/chrome status # connection + auth + background state
|
|
115
|
-
/chrome authorize [duration]
|
|
116
|
-
/chrome revoke
|
|
117
|
-
/chrome background on # default: hard background policy
|
|
118
|
-
/chrome background off # foreground/watch mode
|
|
119
|
-
/chrome background status
|
|
72
|
+
List my open Chrome tabs without navigating, clicking, or changing anything.
|
|
120
73
|
```
|
|
121
74
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
### Background policy
|
|
125
|
-
|
|
126
|
-
`/chrome background on` is enforced, not an overridable default. Per-call `background:false` cannot bring Chrome forward, new tabs stay inactive, and `chrome_tab activate` is blocked. Use the existing `/chrome background off` for foreground/watch mode; per-call `background:true` still works when that mode is off.
|
|
127
|
-
|
|
128
|
-
Screenshots use CDP without activating background tabs. Debugger/capture failures return errors, never an activation fallback. Reload both Pi and the Chrome companion after upgrading; old companions reject background tab creation/screenshots rather than silently switching tabs.
|
|
75
|
+
Run `/chrome revoke` when finished. Use `/chrome authorize` again whenever you want to grant access for another task or session.
|
|
129
76
|
|
|
130
|
-
|
|
77
|
+
## Safety
|
|
131
78
|
|
|
132
|
-
|
|
79
|
+
- **Per-session approval.** Pi's Chrome tools require `/chrome authorize`. `/chrome revoke` locks them and requests cleanup of that session's owned automation tabs. Cleanup preserves existing user tabs.
|
|
80
|
+
- **Separate targets by default.** Page actions without an explicit target use a session-owned automation window or tab. The agent can deliberately target an existing tab when your task calls for it.
|
|
81
|
+
- **Local transport, not a sandbox.** The bridge binds to `127.0.0.1:17318` and rejects browser-origin command requests. It does not authenticate arbitrary non-browser local callers; it is not protection against hostile processes on your machine.
|
|
82
|
+
- **Background mode:** `/chrome background on` (default) blocks pi-chrome tools from directly bringing Chrome to the front or switching your selected tab. Use `/chrome background off` to allow those actions, and `/chrome background status` to check the setting.
|
|
133
83
|
|
|
134
|
-
|
|
84
|
+
### Limits
|
|
135
85
|
|
|
136
|
-
|
|
86
|
+
This is browser automation, not full OS control. Native Chrome/OS dialogs, password-manager prompts, passkeys/security keys/biometrics, CAPTCHA challenges, cross-origin iframe DOM access, rich multitouch/stylus gestures, and arbitrary desktop apps are outside its reliable tool surface. Some workflows need human assistance.
|
|
137
87
|
|
|
138
|
-
|
|
88
|
+
If page inspection or evaluation is blocked, use screenshots and coordinate input where possible. Background pages can throttle rendering or reject focus-gated actions. See the [FAQ](./docs/FAQ.md) for details.
|
|
139
89
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
---
|
|
90
|
+
## Commands
|
|
143
91
|
|
|
144
|
-
|
|
92
|
+
```text
|
|
93
|
+
/chrome # quick connection/auth/background dashboard and controls
|
|
94
|
+
/chrome onboard # one-time companion setup
|
|
95
|
+
/chrome authorize # authorize this Pi session for 15 minutes
|
|
96
|
+
/chrome authorize 30m # choose a duration
|
|
97
|
+
/chrome authorize indefinite # no time limit; revoke when finished
|
|
98
|
+
/chrome revoke # lock tools and request session cleanup
|
|
99
|
+
/chrome doctor # full diagnostics, including authorization/background state
|
|
100
|
+
/chrome background on # default: block explicit focus/tab activation
|
|
101
|
+
/chrome background off # allow foreground/watch mode
|
|
102
|
+
/chrome background status
|
|
103
|
+
```
|
|
145
104
|
|
|
146
|
-
|
|
147
|
-
- FAQ: [`docs/FAQ.md`](./docs/FAQ.md)
|
|
148
|
-
- Comparison: [`docs/COMPARISON.md`](./docs/COMPARISON.md)
|
|
149
|
-
- Security: [`SECURITY.md`](./SECURITY.md)
|
|
150
|
-
- Benchmark suite: [`test-suite/README.md`](./test-suite/README.md)
|
|
151
|
-
- Architecture: [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md)
|
|
105
|
+
Bare `/chrome` checks the connection without running page probes. Use `/chrome doctor` for version and page checks, troubleshooting hints, and authorization/background state.
|
|
152
106
|
|
|
153
|
-
|
|
107
|
+
Tool parameters are documented inline in Pi. See [architecture](./docs/ARCHITECTURE.md) for target ownership, screenshot behavior, and background-policy details.
|
|
154
108
|
|
|
155
|
-
|
|
109
|
+
### Updating and troubleshooting
|
|
156
110
|
|
|
157
|
-
|
|
111
|
+
After `pi update npm:pi-chrome`, run `/reload` in Pi and reload **Pi Chrome Connector** in `chrome://extensions`. Run `/chrome doctor` to check the connection and companion version.
|
package/SECURITY.md
CHANGED
|
@@ -27,6 +27,7 @@ The Chrome extension under `extensions/chrome-profile-bridge/browser-extension/`
|
|
|
27
27
|
- Loopback bridge only. No remote port. No telemetry.
|
|
28
28
|
- Chrome real input layer for interactive controls.
|
|
29
29
|
- Chrome control locked by default; `/chrome authorize` unlocks current Pi session after terminal confirmation, `/chrome revoke` locks it again.
|
|
30
|
+
- `chrome_cdp` sends raw Chrome DevTools Protocol commands to a tab. It is locked behind `/chrome authorize` like every other tool, but it is not filtered against a safe list. Background mode blocks only its explicit focus methods (`Page.bringToFront`, `Target.activateTarget`).
|
|
30
31
|
- Hard background mode is on by default: tools cannot override it to explicitly focus windows or activate tabs. `/chrome background off` allows foreground/watch mode. This is not a security sandbox: trusted input, page scripts, native prompts, and Chrome/OS behavior can still affect focus.
|
|
31
32
|
|
|
32
33
|
## Custom ports
|
package/docs/FAQ.md
CHANGED
|
@@ -32,6 +32,8 @@ Chrome control is also locked per Pi session until you run `/chrome authorize`;
|
|
|
32
32
|
|
|
33
33
|
Yes. The first session opens the local bridge; later sessions detect it and pipe their commands through the same bridge. Each Pi session must be authorized with `/chrome authorize` before its chrome_* tools work. Each session also owns its **own** dedicated automation window (ownership is keyed by session id inside the one extension), so concurrent sessions never navigate into or close each other's tabs.
|
|
34
34
|
|
|
35
|
+
Subagent sessions that run inside an authorized Pi process (for example with pi-subagents) also get the chrome_* tools. They share the parent's `/chrome authorize` grant and bridge, but each subagent gets its own automation tab and tab group, which are cleaned up when the subagent session ends.
|
|
36
|
+
|
|
35
37
|
## Does pi-chrome navigate my current tab?
|
|
36
38
|
|
|
37
39
|
No. The first chrome_* action that has no explicit target opens a **dedicated automation window** that pi-chrome owns (falling back to a dedicated tab only if a separate window can't be created), and reuses it for the rest of the session. Your existing tabs and windows are never reused or overwritten. Pass `targetId`/`urlIncludes`/`titleIncludes` to deliberately act on a tab you already have open.
|
|
@@ -50,7 +52,7 @@ pi-chrome ships as an unpacked extension so the source and broad browser permiss
|
|
|
50
52
|
|
|
51
53
|
## What's the install footprint?
|
|
52
54
|
|
|
53
|
-
- Pi side: one extension that registers
|
|
55
|
+
- Pi side: one extension that registers 23 tools and a few slash commands.
|
|
54
56
|
- Chrome side: one unpacked extension, ~2000 LOC of plain JavaScript, no dependencies.
|
|
55
57
|
|
|
56
58
|
## Can I script it without Pi?
|