@xnng/browser-relay 1.6.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.
Files changed (79) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +445 -0
  3. package/docs/README.zh-CN.md +421 -0
  4. package/docs/benchmarks/browser-gaps-codex-ax.json +418 -0
  5. package/docs/benchmarks/browser-gaps-relay-after.json +655 -0
  6. package/docs/benchmarks/browser-gaps-relay-baseline.json +679 -0
  7. package/docs/benchmarks/browser-readiness-cost.json +106 -0
  8. package/docs/benchmarks/browser-runtime-balanced-headed.json +412 -0
  9. package/docs/benchmarks/browser-runtime-balanced-rtt50.json +412 -0
  10. package/docs/benchmarks/browser-runtime-balanced.json +412 -0
  11. package/docs/benchmarks/browser-runtime-rtt50.json +194 -0
  12. package/docs/benchmarks/browser-runtime.json +254 -0
  13. package/docs/benchmarks/browser-use-parity.json +54 -0
  14. package/docs/benchmarks/codex-extension-audit.json +131 -0
  15. package/docs/benchmarks/codex-native-protocol.md +69 -0
  16. package/docs/benchmarks/codex-native-replay.js +116 -0
  17. package/docs/benchmarks/codex-native-status.json +81 -0
  18. package/docs/benchmarks/codex-native.json +1003 -0
  19. package/docs/benchmarks/extension-sessions.png +0 -0
  20. package/docs/benchmarks/extension-tasks.png +0 -0
  21. package/docs/benchmarks/iframe-routing-regression.json +37 -0
  22. package/docs/browser-use-comparison.md +331 -0
  23. package/docs/browser-use-gap-audit.md +141 -0
  24. package/docs/browser-use-parity.md +105 -0
  25. package/docs/demo/intranet.html +103 -0
  26. package/docs/releases/v1.5.0.md +59 -0
  27. package/docs/releases/v1.5.1.md +16 -0
  28. package/docs/releases/v1.5.2.md +42 -0
  29. package/docs/releases/v1.5.3.md +33 -0
  30. package/docs/releases/v1.5.4.md +42 -0
  31. package/docs/releases/v1.6.0.md +16 -0
  32. package/docs/remote-control-hub.md +523 -0
  33. package/extension/activity.js +328 -0
  34. package/extension/automation.js +1839 -0
  35. package/extension/background.js +1854 -0
  36. package/extension/i18n.js +149 -0
  37. package/extension/icons/icon128.png +0 -0
  38. package/extension/icons/icon16.png +0 -0
  39. package/extension/icons/icon32.png +0 -0
  40. package/extension/icons/icon48.png +0 -0
  41. package/extension/manifest.json +47 -0
  42. package/extension/observations.js +109 -0
  43. package/extension/options.html +289 -0
  44. package/extension/options.js +269 -0
  45. package/extension/popup.html +74 -0
  46. package/extension/popup.js +105 -0
  47. package/extension/protocol.js +45 -0
  48. package/extension/remote-auth.js +18 -0
  49. package/extension/sessions.js +134 -0
  50. package/extension/snapshot.js +161 -0
  51. package/extension/task-groups.js +108 -0
  52. package/extension/tasks.js +186 -0
  53. package/extension/wait.js +89 -0
  54. package/hub/README.md +42 -0
  55. package/hub/package-lock.json +1544 -0
  56. package/hub/package.json +13 -0
  57. package/hub/src/rpc.js +41 -0
  58. package/hub/src/worker.js +322 -0
  59. package/hub/wrangler.example.toml +19 -0
  60. package/package.json +83 -0
  61. package/server/cdp-bridge.js +200 -0
  62. package/server/cli.js +1798 -0
  63. package/server/hub-server.js +258 -0
  64. package/server/install.js +250 -0
  65. package/server/mcp-server.js +504 -0
  66. package/server/npx-runner.js +96 -0
  67. package/server/relay-server.js +1356 -0
  68. package/server/remote-protocol.js +76 -0
  69. package/server/runtime-worker.js +166 -0
  70. package/server/script-runtime.js +189 -0
  71. package/server/sdk.js +307 -0
  72. package/server/service-state.js +103 -0
  73. package/server/snapshot.js +161 -0
  74. package/server/uninstall.js +61 -0
  75. package/server/windows-service-entry.js +58 -0
  76. package/server/windows-service.js +360 -0
  77. package/skills/browser-relay/SKILL.md +192 -0
  78. package/skills/browser-relay/references/legacy-api.md +163 -0
  79. package/skills/browser-relay/references/runtime.md +240 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Browser Relay contributors
4
+ Copyright (c) 2026 Blake Sabatinelli
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,445 @@
1
+ > This package is the xnng-maintained fork of [reliefeai/browser-relay](https://github.com/reliefeai/browser-relay), distributed as `@xnng/browser-relay`. It adds task tab groups and collapsed-group background operation fixes. The upstream MIT license is preserved.
2
+
3
+ <p align="center">
4
+ <img src="extension/icons/icon128.png" width="96" height="96" alt="Browser Relay logo">
5
+ </p>
6
+
7
+ <h1 align="center">Browser Relay</h1>
8
+
9
+ <p align="center">
10
+ Let AI agents use the same Chrome browser you use every day.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="https://www.npmjs.com/package/@xnng/browser-relay"><img src="https://img.shields.io/npm/v/@xnng/browser-relay.svg" alt="npm version"></a>
15
+ <a href="https://www.npmjs.com/package/@xnng/browser-relay"><img src="https://img.shields.io/npm/dm/@xnng/browser-relay.svg" alt="npm downloads"></a>
16
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT License"></a>
17
+ <img src="https://img.shields.io/badge/agent-Skill%20%2B%20CLI-blue" alt="Agent Skill and CLI">
18
+ <img src="https://img.shields.io/badge/remote-multi--machine-7c3aed" alt="Remote multi-machine control">
19
+ <img src="https://img.shields.io/badge/local--first-127.0.0.1-111827" alt="Local first">
20
+ </p>
21
+
22
+ <p align="center">
23
+ <a href="#quick-start">Quick Start</a>
24
+ ·
25
+ <a href="#agent-friendly-by-default">Agent Skill</a>
26
+ ·
27
+ <a href="#cli">CLI</a>
28
+ ·
29
+ <a href="#remote-control-remote-relay">Remote</a>
30
+ ·
31
+ <a href="https://github.com/reliefeai/browser-relay/blob/main/docs/README.zh-CN.md">中文</a>
32
+ </p>
33
+
34
+ <p align="center">
35
+ <a href="https://github.com/reliefeai/browser-relay/blob/main/docs/assets/browser-relay-mobile-to-office.mp4">
36
+ <img src="https://raw.githubusercontent.com/reliefeai/browser-relay/main/docs/assets/browser-relay-mobile-to-office.gif" width="960" alt="Illustrated Browser Relay workflow: an agent on a phone uses the Skill and CLI to operate a mock internal dashboard in the existing Chrome browser on an office machine">
37
+ </a>
38
+ </p>
39
+
40
+ <p align="center"><sub>Illustrated workflow with mock data and no real credentials. Click the animation for the MP4 version.</sub></p>
41
+
42
+ Browser Relay lets an AI agent join the Chrome browser you already use through an agent-native **Skill + CLI**. It does not launch a blank automation profile, keep pulling another browser window to the foreground, or make you log in again. You and the agent work in the same everyday browser — locally or across multiple machines.
43
+
44
+ Use it when the task lives in a browser that already has the right login, extensions, device trust, or network access: operate your desktop browser from an agent on your phone, reach an internal system through the already-authenticated browser on your work computer, or let one agent work across browsers on several machines.
45
+
46
+ ## Real Chrome, not a throwaway profile
47
+
48
+ Most browser automation spins up a fresh, empty browser profile. That is fine for testing, but useless for agents that need your **authenticated** web apps — SaaS dashboards, admin panels, internal tools, documents, private sessions — where a headless browser or a fresh profile simply is not logged in.
49
+
50
+ Browser Relay is that missing layer:
51
+
52
+ - **Your actual Chrome session** — cookies, localStorage, extensions, and login state, shared as-is.
53
+ - **No pop-up automation browser** — it never spawns a separate window or opens tabs behind your back; navigation reuses an attached tab.
54
+ - **Local or remote** — one agent can drive browsers on this machine or several other machines through an outbound relay connection, with no public browser port exposed.
55
+ - **Agent-first** — install the bundled Skill so Claude Code, Codex, Cursor, Windsurf, and other agents know when and how to use the inspectable CLI.
56
+ - **Local-first boundary** — the relay binds to `127.0.0.1` by default.
57
+
58
+ ## Provenance
59
+
60
+ Based on [chengyixu/openclaw-browser-relay](https://github.com/chengyixu/openclaw-browser-relay), with auto-attach behavior inspired by [blakesabatinelli/openclaw-chrome-relay](https://github.com/blakesabatinelli/openclaw-chrome-relay). Repackaged as a general-purpose local browser bridge for AI agents, without the OpenClaw-specific gateway, token auth, or platform bindings.
61
+
62
+ ## Architecture
63
+
64
+ ```text
65
+ Local
66
+ AI Agent ──Skill + CLI──▶ Relay server (Node, 127.0.0.1)
67
+ │ WebSocket
68
+ ▼
69
+ Chrome extension ──chrome.debugger / CDP──▶ your Chrome tabs
70
+
71
+ Remote (Remote Relay)
72
+ AI Agent ──HTTPS──▶ public relay (relay.linso.ai) ◀──WSS── Chrome extension ──▶ your Chrome tabs
73
+ ```
74
+
75
+ **Local mode** is the default: the agent talks to a relay server on `127.0.0.1`, which forwards Chrome DevTools Protocol commands to the extension.
76
+
77
+ **Remote mode** exposes nothing. When you turn on Remote Relay, the extension connects *out* to a public relay service; a remote CLI reaches that same service, which routes each command down to your browser over the existing connection — no open ports, no local server on the network. Use the default hosted relay, or run your own on Cloudflare in one click (see below).
78
+
79
+ ## Quick Start
80
+
81
+ Use Browser Relay in four steps. You need desktop Chrome plus Node.js/npm. The Chrome extension is loaded manually from its installed directory.
82
+
83
+ ### 1. Install
84
+
85
+ ```bash
86
+ npm install -g @xnng/browser-relay
87
+ ```
88
+
89
+ The package attempts to register a user-level background service. If your environment has no supported service manager, the verification step below gives the exact foreground command instead of failing with a stack trace.
90
+
91
+ ### 2. Load the Chrome extension
92
+
93
+ Print the extension directory:
94
+
95
+ ```bash
96
+ browser-relay path
97
+ ```
98
+
99
+ Then open `chrome://extensions`, enable **Developer mode**, click **Load unpacked**, and select the `extension` directory printed by `browser-relay path`.
100
+
101
+ ### 3. Verify the browser connection
102
+
103
+ Run one complete read-only diagnosis, then list the attached tabs:
104
+
105
+ ```bash
106
+ browser-relay doctor
107
+ browser-relay tabs
108
+ ```
109
+
110
+ `doctor` should report a healthy relay and connected extension. `tabs` should print at least one tab ID, title, and URL:
111
+
112
+ ```text
113
+ t_A7k2Pm9QxL Example Domain https://example.com/
114
+ ```
115
+
116
+ If `doctor` says the service manager is unavailable, start the relay in another terminal and keep it running:
117
+
118
+ ```bash
119
+ browser-relay
120
+ ```
121
+
122
+ Then retry `browser-relay doctor`. If the relay is healthy but no tabs appear, reload the unpacked extension and retry `browser-relay tabs`. `doctor` never installs, restarts, or changes anything; add `--json` for automation.
123
+
124
+ <details>
125
+ <summary>Background service, updates, and platform notes</summary>
126
+
127
+ The global install uses launchd on macOS, systemd-user on Linux, and a current-user Task Scheduler task on Windows. The service starts when you sign in. The Windows task uses your existing interactive login token with least privilege: it does not store a password, elevate itself, or run as SYSTEM. Organization policy can still block standard-user task registration.
128
+
129
+ `browser-relay install` safely refreshes a Browser Relay-owned service definition, starts it, and verifies the HTTP endpoint and installed version. Run it after an nvm upgrade or when `doctor` recommends it. It refuses to overwrite a same-name Windows task without Browser Relay's ownership marker. If a managed environment has no usable service manager, foreground mode (`browser-relay`) remains available.
130
+
131
+ Upgrade with `browser-relay update`. It installs `@xnng/browser-relay@latest` globally, attempts to refresh the service, and prints a status check; the extension reloads itself on its next relay reconnect (within about 30 seconds).
132
+
133
+ </details>
134
+
135
+ ### 4. Install the Agent Skill and run the first task
136
+
137
+ Browser Relay ships with an agent-friendly Skill. Choose the Agent explicitly so installation never opens an interactive selector:
138
+
139
+ ```bash
140
+ browser-relay skill install --agent codex
141
+
142
+ # Claude Code, or both agents at once:
143
+ browser-relay skill install --agent claude-code
144
+ browser-relay skill install --agent codex claude-code
145
+ ```
146
+
147
+ The command uses the standard `skills` CLI non-interactively, then reads every target `SKILL.md` back to verify it. Use `--agent universal` for agents that consume the standard `~/.agents/skills` directory, `browser-relay skill path` to inspect the bundled source, or plain `browser-relay skill` to print an install command for all agents (`--agent "*"`). Printing the command does not install anything. After installation, your agent can operate your own browser without opening a separate automation browser.
148
+
149
+ Give the agent a small read-only task first:
150
+
151
+ ```text
152
+ Use Browser Relay to tell me the title and URL of my current Chrome tab. Do not navigate.
153
+ ```
154
+
155
+ The first successful response proves the full path works: Agent Skill → CLI → relay → extension → your existing Chrome tab.
156
+
157
+ If Browser Relay solves a workflow you actually have, starring the repository helps other agent builders find it.
158
+
159
+ ## Agent Friendly by Default
160
+
161
+ Version **1.5.0** adds complete content reading, managed tab sessions and explicit handoff.
162
+ See the [release notes and upgrade steps](docs/releases/v1.5.0.md) and [implementation and validation](docs/browser-use-parity.md).
163
+ Development pushes do not publish npm packages; publication requires a manual workflow run with an explicit version and channel.
164
+
165
+ Version 1.5 also adds a persistent JavaScript runtime, accessibility references and
166
+ ordered action groups. Inspect with `browser-relay observe --tab <id>`, then
167
+ execute a known sequence with `browser-relay actions --tab <id> --file actions.json`.
168
+ One group runs inside the extension and returns the resulting state. Independent
169
+ tabs may run concurrently; groups on one tab are serialized and cancellable.
170
+
171
+ For scripts, use `browser-relay exec --file workflow.js`, or the MCP
172
+ `browser_exec` tool to retain variables between calls. MCP screenshots are image
173
+ content blocks. Visual click, drag and hover support screenshot coordinate
174
+ mapping; background semantic clicks preserve the user's foreground tab. Visual
175
+ mouse input reports `needs_foreground` when a visible tab is required.
176
+
177
+ See the [runtime and SDK reference](skills/browser-relay/references/runtime.md)
178
+ and [Codex comparison and measured results](docs/browser-use-comparison.md).
179
+ Local scripts are trusted code with the agent's OS permissions; their separate
180
+ process provides timeouts and reset, not a security sandbox. Remote devices only
181
+ receive browser operations, never the agent's local JavaScript source.
182
+
183
+ Browser Relay is designed to be comfortable for agents, not just low-level automation scripts.
184
+
185
+ - The included Skill tells agents when to use Browser Relay and how to interact safely.
186
+ - Page snapshots are annotated with links, buttons, inputs, and other interactive elements so agents can plan before acting.
187
+ - Actions target existing attached tabs, keeping the user's browser context visible and predictable.
188
+ - Stable CSS waits let agents wait for an element to attach or become visible instead of guessing with fixed sleeps.
189
+ - Console and network capture record `console.*`, page exceptions, log entries, and request/response activity for debugging real-page behavior.
190
+
191
+ ## CLI
192
+
193
+ The CLI is the primary interface. For agents that can run shell commands, it is faster and less error-prone than hand-writing `curl` JSON:
194
+
195
+ ```bash
196
+ browser-relay tabs
197
+ browser-relay console --tab t_A7k2Pm9QxL --limit 50
198
+ browser-relay network --tab t_A7k2Pm9QxL --type response --status 500
199
+ browser-relay snapshot --tab t_A7k2Pm9QxL --max-length 20000
200
+ browser-relay wait 'button[type=submit]' --state visible --timeout 10000 --tab t_A7k2Pm9QxL
201
+ browser-relay click 'button[type=submit]' --tab t_A7k2Pm9QxL
202
+ browser-relay type 'hello world' --selector 'input[name=q]' --clear --submit
203
+ browser-relay key Control+L
204
+ browser-relay scroll down --amount 1000
205
+ browser-relay screenshot /tmp/page.png --full-page
206
+ browser-relay eval 'document.title'
207
+ ```
208
+
209
+ For long text or JavaScript, avoid shell escaping by reading from stdin:
210
+
211
+ ```bash
212
+ printf 'hello\nworld' | browser-relay type --selector textarea --stdin
213
+ browser-relay eval --stdin < script.js
214
+ ```
215
+
216
+ All browser commands accept `--json` for the raw API response and `--tab <id>` to target a specific tab. When `--json` is used, a failed command prints the structured error payload and exits non-zero.
217
+
218
+ ### Remote control (Remote Relay)
219
+
220
+ To drive this browser from **another machine** — a CI box, a remote agent, a different network — turn on **Remote Relay** in the extension's Options page. The browser connects out to a public relay service (the hosted `relay.linso.ai` by default); nothing listens on a public port and no local server is exposed.
221
+
222
+ Turning it on mints a secret **Device ID** — treat it like a password. Pass it to the same CLI commands from anywhere:
223
+
224
+ ```bash
225
+ browser-relay tabs --remote-device-id br-xxxx
226
+ browser-relay eval "location.href" --remote-device-id br-xxxx
227
+
228
+ # Save an alias once so you don't retype the id (remote ls / rm to manage):
229
+ browser-relay remote add mymac br-xxxx
230
+ browser-relay tabs --remote mymac
231
+ ```
232
+
233
+ Saved remote IDs are credentials. On POSIX systems Browser Relay stores them in
234
+ `~/.browser-relay/remotes.json` and enforces `0700` on the directory and `0600` on
235
+ the file, including tightening permissions created by older versions.
236
+ `browser-relay remote ls`, including `--json`, returns only `(redacted)` IDs; it never
237
+ prints the stored capability.
238
+
239
+ **Run your own relay** instead of the hosted one — one click deploys the Worker in `hub/` to your own Cloudflare account:
240
+
241
+ [![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/reliefeai/browser-relay/tree/main/hub)
242
+
243
+ The button connects Cloudflare to your GitHub the first time (Workers Builds). Prefer the CLI? `git clone`, then `cd hub && npx wrangler deploy`. Either way, put the resulting `…workers.dev` URL in the Options page's *Public relay* field.
244
+
245
+ The `remote-device-id` is a capability — anyone with it can control this browser while Remote Relay is on. Design notes: `docs/remote-control-hub.md`.
246
+
247
+ ### CLI reference
248
+
249
+ ```bash
250
+ browser-relay # Run the relay server in the foreground
251
+ browser-relay start # Start the background service
252
+ browser-relay stop # Stop the background service
253
+ browser-relay restart # Restart the background service
254
+ browser-relay fix # Restart and clear stale session state (when tabs won't connect)
255
+ browser-relay update # Update the global package and refresh the service
256
+ browser-relay status # Show service state and HTTP health
257
+ browser-relay doctor # Run a complete read-only installation diagnosis
258
+ browser-relay logs # Follow the platform service logs
259
+ browser-relay path # Print the Chrome extension directory
260
+ browser-relay skill install --agent codex # Install/update and verify the Agent Skill
261
+ browser-relay skill path # Print the bundled Skill directory
262
+ browser-relay install # Register the background service
263
+ browser-relay uninstall # Unregister the background service
264
+
265
+ browser-relay tabs # List attached browser tabs
266
+ browser-relay console # Print captured console/page errors
267
+ browser-relay network # Print captured network requests/responses/failures
268
+ browser-relay snapshot # Print annotated page text
269
+ browser-relay wait # Wait for a CSS selector to attach or become visible
270
+ browser-relay click # Click an element by CSS selector
271
+ browser-relay type # Type text into the page
272
+ browser-relay key # Press a key or shortcut
273
+ browser-relay scroll # Scroll the page
274
+ browser-relay screenshot # Save a PNG screenshot
275
+ browser-relay eval # Evaluate JavaScript in the page
276
+ browser-relay download # Print src/href for an element
277
+ browser-relay download-start # Start a Chrome download
278
+ browser-relay downloads # List Chrome downloads and events
279
+ browser-relay remote # Manage remote aliases (add / ls / rm)
280
+ browser-relay api-help # Show browser command examples
281
+ ```
282
+
283
+ ## MCP
284
+
285
+ After installing the npm package, use `browser-relay-mcp` directly:
286
+
287
+ ```json
288
+ {
289
+ "mcpServers": {
290
+ "browser": {
291
+ "command": "browser-relay-mcp",
292
+ "env": {
293
+ "BROWSER_RELAY_URL": "http://127.0.0.1:18795"
294
+ }
295
+ }
296
+ }
297
+ }
298
+ ```
299
+
300
+ The MCP server exposes high-level tools such as `browser_tabs`, `browser_snapshot`, `browser_wait`, `browser_click`, `browser_type`, `browser_key`, and `browser_screenshot`.
301
+
302
+ ## HTTP API
303
+
304
+ The HTTP API is the stable integration surface for code and custom tools. For interactive agent work, prefer the CLI above.
305
+
306
+ Errors use a structured shape across HTTP, CLI `--json`, and MCP tool errors:
307
+
308
+ ```json
309
+ { "ok": false, "code": "invalid_request", "error": "url is required", "message": "url is required", "status": 400, "retryable": false }
310
+ ```
311
+
312
+ ```bash
313
+ # List attached tabs
314
+ curl http://127.0.0.1:18795/api/tabs
315
+
316
+ # Take a text snapshot of a page
317
+ curl "http://127.0.0.1:18795/api/snapshot?tabId=t_A7k2Pm9QxL"
318
+
319
+ # Wait until an element is visible (attached is also supported)
320
+ curl -X POST http://127.0.0.1:18795/api/wait \
321
+ -H "Content-Type: application/json" \
322
+ -d '{"tabId":"t_A7k2Pm9QxL","selector":"button.submit","state":"visible","timeoutMs":10000}'
323
+
324
+ # Read captured console/page errors
325
+ curl "http://127.0.0.1:18795/api/console?tabId=t_A7k2Pm9QxL&limit=50"
326
+
327
+ # Read captured network activity (sensitive headers are redacted)
328
+ curl "http://127.0.0.1:18795/api/network?tabId=t_A7k2Pm9QxL&type=response&status=500"
329
+
330
+ # Click an element
331
+ curl -X POST http://127.0.0.1:18795/api/click \
332
+ -H "Content-Type: application/json" \
333
+ -d '{"tabId":"t_A7k2Pm9QxL","selector":"button.submit"}'
334
+ ```
335
+
336
+ | Endpoint | Method | Description |
337
+ | --- | --- | --- |
338
+ | `/` | GET/HEAD | Health check |
339
+ | `/api/debug` | GET | Server diagnostics |
340
+ | `/api/tabs` | GET | List attached tabs |
341
+ | `/api/console` | GET | Read captured console/page error entries |
342
+ | `/api/console/clear` | POST | Clear captured console entries |
343
+ | `/api/network` | GET | Read captured Network.* request/response/failure entries |
344
+ | `/api/network/clear` | POST | Clear captured network entries |
345
+ | `/api/navigate` | POST | Navigate an attached tab |
346
+ | `/api/snapshot` | GET | Get annotated text or raw HTML |
347
+ | `/api/wait` | POST | Wait for a CSS selector to attach or become visible |
348
+ | `/api/click` | POST | Click an element by CSS selector |
349
+ | `/api/type` | POST | Type into an input |
350
+ | `/api/key` | POST | Press a key or keyboard shortcut |
351
+ | `/api/scroll` | POST | Scroll the page |
352
+ | `/api/screenshot` | GET/POST | Capture a PNG screenshot; full-page mode returns capture strategy/size metadata |
353
+ | `/api/eval` | POST | Evaluate JavaScript in the page |
354
+ | `/api/download` | POST | Extract an element URL |
355
+ | `/api/download/start` | POST | Start a real Chrome download from a URL |
356
+ | `/api/downloads` | GET | List Chrome downloads and recent download events |
357
+ | `/api/downloads/clear` | POST | Clear captured download events |
358
+
359
+ Real Chrome downloads require the extension's `downloads` permission. After upgrading from an older Browser Relay version, reload the unpacked extension in `chrome://extensions`.
360
+
361
+ The same endpoints are reachable remotely: a CLI running with `--remote-device-id` sends them through the public relay to the browser.
362
+
363
+ ## Configuration
364
+
365
+ | Environment variable | Default | Description |
366
+ | --- | --- | --- |
367
+ | `BROWSER_RELAY_URL` | `http://127.0.0.1:18795` | Relay base URL used by CLI browser commands and MCP |
368
+ | `BROWSER_RELAY_HOST` | `127.0.0.1` | HTTP and WebSocket bind address |
369
+ | `BROWSER_RELAY_PORT` | `18795` | HTTP and WebSocket port |
370
+ | `BROWSER_RELAY_REMOTE_DEVICE_ID` | — | Remote Device ID (or alias) used when no `--remote-device-id` flag is passed |
371
+ | `BROWSER_RELAY_REMOTE_HOST` | `https://relay.linso.ai` | Public relay URL for remote commands |
372
+
373
+ The Chrome extension port can be changed from the extension Options page.
374
+
375
+ Service files:
376
+
377
+ ```text
378
+ macOS: ~/Library/LaunchAgents/org.browser-relay.service.plist
379
+ Linux: ~/.config/systemd/user/browser-relay.service
380
+ Windows task: BrowserRelay
381
+ Windows definition: %LOCALAPPDATA%\BrowserRelay\task.xml
382
+ ```
383
+
384
+ Logs:
385
+
386
+ ```text
387
+ macOS: /tmp/browser-relay.log, /tmp/browser-relay.error.log
388
+ Linux: journalctl --user -u browser-relay
389
+ Windows: %LOCALAPPDATA%\BrowserRelay\logs\browser-relay.log
390
+ %LOCALAPPDATA%\BrowserRelay\logs\browser-relay.error.log
391
+ ```
392
+
393
+ On Windows, `uninstall` removes only the Browser Relay scheduled task and its generated XML definition. It preserves logs for diagnosis and never kills an unrelated process that happens to use port `18795`.
394
+
395
+ ### Hiding the "debugging this browser" infobar
396
+
397
+ Whenever the extension has a debugger attached, Chrome shows a mandatory
398
+ `"Browser Relay" started debugging this browser` bar at the top of the page.
399
+ No extension API can remove it — it is Chrome's built-in anti-abuse warning.
400
+
401
+ Two ways to deal with it:
402
+
403
+ - **Automatic (default):** the extension soft-detaches idle tabs after 10 min, so
404
+ the bar disappears on its own while you're not using it and re-attaches on the
405
+ next command. Nothing to configure.
406
+ - **Remove it entirely:** launch Chrome with the `--silent-debugger-extension-api`
407
+ flag, which suppresses the bar for the debugger extension API. You must fully
408
+ quit Chrome first (`open --args` only passes flags to a cold start):
409
+
410
+ ```bash
411
+ # macOS
412
+ osascript -e 'quit app "Google Chrome"'
413
+ open -a "Google Chrome" --args --silent-debugger-extension-api
414
+ ```
415
+
416
+ To make it stick, always launch Chrome this way (e.g. a shell alias or a
417
+ `.command` launcher) — a normal Dock click won't carry the flag.
418
+
419
+ Trade-off: this weakens a security protection — *any* extension with the
420
+ `debugger` permission can then silently attach without warning. Fine for
421
+ personal use as long as you understand what it disables.
422
+
423
+ ## Development
424
+
425
+ Release setup and manual workflow commands: [Publishing with npm OIDC](docs/publishing.md).
426
+
427
+ ```bash
428
+ npm install
429
+ npm start
430
+ npm run mcp
431
+ npm test
432
+ ```
433
+
434
+ Load the local `extension/` directory from `chrome://extensions` in Developer mode.
435
+
436
+ ## Security
437
+
438
+ - The extension uses Chrome's `debugger` permission. Install only versions you trust.
439
+ - The relay binds to `127.0.0.1` by default. Do not expose it to the public internet.
440
+ - Remote Relay never opens a port: the browser connects out to the public relay, which only holds a hash of your Device ID secret in memory. Treat the Device ID like a password; anyone with it can control the browser while Remote Relay is on.
441
+ - Browser Relay gives agents access to the same browser state you have, so treat enabled agents as trusted local software.
442
+
443
+ ## License
444
+
445
+ MIT