@browserbridge/bbx 1.0.1 → 1.2.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 (70) hide show
  1. package/README.md +4 -4
  2. package/package.json +11 -13
  3. package/packages/agent-client/src/cli-helpers.js +33 -0
  4. package/packages/agent-client/src/cli.js +122 -45
  5. package/packages/agent-client/src/client.js +134 -8
  6. package/packages/agent-client/src/command-registry.js +4 -1
  7. package/packages/agent-client/src/detect.js +159 -48
  8. package/packages/agent-client/src/install.js +24 -1
  9. package/packages/agent-client/src/mcp-config.js +29 -10
  10. package/packages/agent-client/src/setup-status.js +12 -4
  11. package/packages/mcp-server/src/bin.js +57 -5
  12. package/packages/mcp-server/src/handlers-capture.js +279 -0
  13. package/packages/mcp-server/src/handlers-dom.js +196 -0
  14. package/packages/mcp-server/src/handlers-navigation.js +79 -0
  15. package/packages/mcp-server/src/handlers-page.js +365 -0
  16. package/packages/mcp-server/src/handlers-utils.js +296 -0
  17. package/packages/mcp-server/src/handlers.js +63 -1159
  18. package/packages/mcp-server/src/server.js +13 -3
  19. package/packages/native-host/bin/bridge-daemon.js +34 -4
  20. package/packages/native-host/bin/install-manifest.js +32 -2
  21. package/packages/native-host/bin/postinstall.js +16 -0
  22. package/packages/native-host/src/config.js +131 -6
  23. package/packages/native-host/src/daemon-logger.js +157 -0
  24. package/packages/native-host/src/daemon-process.js +422 -0
  25. package/packages/native-host/src/daemon.js +322 -77
  26. package/packages/native-host/src/framing.js +131 -11
  27. package/packages/native-host/src/install-manifest.js +121 -7
  28. package/packages/native-host/src/native-host.js +110 -73
  29. package/packages/protocol/src/capabilities.js +4 -0
  30. package/packages/protocol/src/defaults.js +1 -0
  31. package/packages/protocol/src/errors.js +4 -0
  32. package/packages/protocol/src/payload-cost.js +19 -6
  33. package/packages/protocol/src/protocol.js +143 -7
  34. package/packages/protocol/src/registry.js +13 -0
  35. package/packages/protocol/src/summary.js +18 -10
  36. package/packages/protocol/src/types.js +28 -3
  37. package/skills/browser-bridge/SKILL.md +2 -1
  38. package/skills/browser-bridge/references/interaction.md +1 -0
  39. package/skills/browser-bridge/references/protocol.md +2 -1
  40. package/CHANGELOG.md +0 -55
  41. package/assets/banner.jpg +0 -0
  42. package/assets/logo.png +0 -0
  43. package/assets/logo.svg +0 -65
  44. package/docs/api-reference.md +0 -157
  45. package/docs/cli-guide.md +0 -128
  46. package/docs/index.md +0 -25
  47. package/docs/manual-setup.md +0 -140
  48. package/docs/mcp-vs-cli.md +0 -258
  49. package/docs/publishing.md +0 -112
  50. package/docs/quickstart.md +0 -104
  51. package/docs/troubleshooting.md +0 -59
  52. package/docs/unpacked-extension.md +0 -72
  53. package/docs/usage-scenarios.md +0 -136
  54. package/manifest.json +0 -38
  55. package/packages/extension/assets/icon-128.png +0 -0
  56. package/packages/extension/assets/icon-16.png +0 -0
  57. package/packages/extension/assets/icon-32.png +0 -0
  58. package/packages/extension/assets/icon-48.png +0 -0
  59. package/packages/extension/src/background-helpers.js +0 -474
  60. package/packages/extension/src/background-routing.js +0 -89
  61. package/packages/extension/src/background.js +0 -3490
  62. package/packages/extension/src/content-script-helpers.js +0 -282
  63. package/packages/extension/src/content-script.js +0 -2043
  64. package/packages/extension/src/debugger-coordinator.js +0 -188
  65. package/packages/extension/src/sidepanel-helpers.js +0 -104
  66. package/packages/extension/ui/popup.html +0 -35
  67. package/packages/extension/ui/popup.js +0 -298
  68. package/packages/extension/ui/sidepanel.html +0 -102
  69. package/packages/extension/ui/sidepanel.js +0 -1771
  70. package/packages/extension/ui/ui.css +0 -1160
@@ -1,157 +0,0 @@
1
- # BridgeClient API Reference
2
-
3
- `BridgeClient` is the programmatic interface for agents and tools that want to
4
- communicate with the Browser Bridge daemon directly, without going through the
5
- CLI or MCP server.
6
-
7
- If you are setting up Browser Bridge for normal end-user agent usage, start with
8
- [quickstart](./quickstart.md) or [manual setup](./manual-setup.md) instead.
9
-
10
- ## Install
11
-
12
- ```bash
13
- npm install @browserbridge/bbx
14
- ```
15
-
16
- ## Quick start
17
-
18
- ```js
19
- import { BridgeClient } from '@browserbridge/bbx/packages/agent-client/src/client.js';
20
-
21
- const client = new BridgeClient();
22
- await client.connect();
23
-
24
- const response = await client.request({ method: 'health.ping' });
25
- console.log(response.result); // { daemon: 'ok', extensionConnected: true, ... }
26
-
27
- await client.close();
28
- ```
29
-
30
- ## Constructor
31
-
32
- ```js
33
- new BridgeClient(options?)
34
- ```
35
-
36
- | Option | Type | Default | Description |
37
- |--------|------|---------|-------------|
38
- | `socketPath` | `string` | `~/.config/browser-bridge/bridge.sock` | Path to the daemon Unix socket |
39
- | `clientId` | `string` | `agent_<uuid>` | Identifies this client to the daemon |
40
- | `defaultTimeoutMs` | `number` | `8000` | Per-request timeout in ms |
41
- | `autoReconnect` | `boolean` | `false` | Reconnect automatically after daemon restarts and emit `reconnected` when the session is restored |
42
-
43
- ## Methods
44
-
45
- ### `connect()`
46
-
47
- Connect to the daemon and register as an agent. Performs a `health.ping` to
48
- establish protocol compatibility. Throws if the daemon is not running.
49
-
50
- ```js
51
- await client.connect();
52
- ```
53
-
54
- ### `request(options)`
55
-
56
- Send a bridge request and return the response.
57
-
58
- ```js
59
- const response = await client.request({
60
- method: 'dom.query',
61
- params: { selector: 'h1', maxNodes: 5 },
62
- tabId: 123, // optional - required for tab-bound methods
63
- timeoutMs: 10_000, // optional - overrides defaultTimeoutMs
64
- });
65
-
66
- if (response.ok) {
67
- console.log(response.result);
68
- } else {
69
- console.error(response.error.code, response.error.message);
70
- }
71
- ```
72
-
73
- **Returns** a `BridgeResponse`:
74
-
75
- ```ts
76
- { id, ok: true, result: unknown, error: null, meta }
77
- | { id, ok: false, result: null, error: { code, message, details, recovery? }, meta }
78
- ```
79
-
80
- When `ok` is `false`, `error.recovery` (if present) contains machine-readable
81
- retry guidance:
82
-
83
- ```js
84
- if (!response.ok && response.error.recovery?.retry) {
85
- await new Promise((r) => setTimeout(r, response.error.recovery.retryAfterMs ?? 1000));
86
- // retry once
87
- }
88
- ```
89
-
90
- ### `close()`
91
-
92
- Gracefully close the connection (sends TCP FIN, waits for acknowledgement).
93
-
94
- ```js
95
- await client.close();
96
- ```
97
-
98
- ### `reconnected` event
99
-
100
- When `autoReconnect: true` is enabled, `BridgeClient` emits `reconnected` after
101
- the socket is re-established and the agent is registered again.
102
-
103
- ```js
104
- client.on('reconnected', () => {
105
- console.log('Browser Bridge reconnected');
106
- });
107
- ```
108
-
109
- ## Available methods
110
-
111
- See [`packages/protocol/src/registry.js`](../packages/protocol/src/registry.js) for the full list. Common ones:
112
-
113
- | Method | Description |
114
- | ---------------------------- | ---------------------------------------------- |
115
- | `access.request` | Request window access (surfaces Enable prompt) |
116
- | `health.ping` | Check daemon and extension connectivity |
117
- | `tabs.list` | List tabs in the enabled window |
118
- | `page.get_state` | URL, title, readyState of the active tab |
119
- | `dom.query` | Query DOM subtree with CSS selector |
120
- | `dom.find_by_text` | Find elements by visible text |
121
- | `page.evaluate` | Run JavaScript in the page context |
122
- | `page.get_console` | Read buffered console output |
123
- | `page.get_network` | Read intercepted fetch/XHR requests |
124
- | `input.click` | Click an element |
125
- | `input.type` | Type text into an element |
126
- | `navigation.navigate` | Navigate to a URL |
127
- | `screenshot.capture_element` | Capture element as PNG (base64) |
128
- | `patch.apply_styles` | Apply reversible CSS overrides |
129
-
130
- ## Error codes
131
-
132
- | Code | Retryable | Meaning |
133
- | ------------------------- | --------- | ------------------------------------------------- |
134
- | `ACCESS_DENIED` | No | Browser Bridge is disabled for this window |
135
- | `EXTENSION_DISCONNECTED` | Yes (3 s) | Extension not connected to daemon |
136
- | `TIMEOUT` | Yes (1 s) | Extension did not respond in time |
137
- | `RATE_LIMITED` | Yes (2 s) | Too many concurrent requests |
138
- | `ELEMENT_STALE` | No | Element was removed from the DOM |
139
- | `TAB_MISMATCH` | No | Tab closed or not found |
140
- | `INVALID_REQUEST` | No | Malformed method or params |
141
- | `INTERNAL_ERROR` | Yes (1 s) | Unexpected extension-side error |
142
- | `DAEMON_OFFLINE` | No | Daemon not running — start with `bbx-daemon` |
143
- | `CONNECTION_LOST` | Yes | Socket dropped mid-request — retry |
144
- | `BRIDGE_TIMEOUT` | Yes (1 s) | Extension took too long — retry with simpler call |
145
- | `NATIVE_HOST_UNAVAILABLE` | No | Run `bbx doctor` to diagnose |
146
-
147
- ## Using `withBridgeClient`
148
-
149
- For one-off calls, `withBridgeClient` handles connect/close automatically:
150
-
151
- ```js
152
- import { withBridgeClient } from '@browserbridge/bbx/packages/agent-client/src/runtime.js';
153
-
154
- const result = await withBridgeClient(async (client) => {
155
- return client.request({ method: 'page.get_state' });
156
- });
157
- ```
package/docs/cli-guide.md DELETED
@@ -1,128 +0,0 @@
1
- # CLI Guide
2
-
3
- This is the practical day-to-day guide for the `bbx` command. For install and
4
- agent wiring, see [manual-setup.md](./manual-setup.md).
5
-
6
- ## Setup and diagnostics
7
-
8
- ```bash
9
- bbx install
10
- bbx status
11
- bbx doctor
12
- bbx logs
13
- bbx tabs
14
- bbx skill
15
- ```
16
-
17
- Use these first when Browser Bridge is not connected, the wrong tab is routed,
18
- or you want to see the available runtime presets.
19
-
20
- ## Inspect the page
21
-
22
- ```bash
23
- bbx call page.get_state
24
- bbx dom-query main
25
- bbx describe .hero
26
- bbx text .hero-title medium
27
- bbx html .hero
28
- bbx attrs .hero id,class,data-state
29
- bbx a11y-tree 80 4
30
- ```
31
-
32
- These commands are usually enough to understand what rendered without dumping a
33
- large screenshot or the whole DOM.
34
-
35
- `dom.query` responses include `registrySize` and may include `_registryPruned:
36
- true` when older element refs were evicted. If you see that flag, re-query
37
- instead of reusing old refs.
38
-
39
- ## Inspect styles and layout
40
-
41
- ```bash
42
- bbx styles .hero display,gap,padding,margin
43
- bbx matched-rules .hero
44
- bbx box .hero
45
- bbx call layout.hit_test '{"x":640,"y":280}'
46
- ```
47
-
48
- Use `styles`, `matched-rules`, and `box` together when a layout bug is unclear.
49
-
50
- ## Read runtime state
51
-
52
- ```bash
53
- bbx console error
54
- bbx network 20
55
- bbx page-text medium
56
- bbx storage local authToken,featureFlag
57
- bbx perf
58
- bbx eval 'window.location.href'
59
- ```
60
-
61
- Reach for `eval` only when the structured reads are not enough.
62
-
63
- ## Navigate and interact
64
-
65
- ```bash
66
- bbx navigate https://example.com
67
- bbx reload
68
- bbx back
69
- bbx forward
70
- bbx click button[type="submit"]
71
- bbx type input[name="email"] person@example.com
72
- bbx press-key Enter
73
- bbx hover .menu-trigger
74
- bbx call input.scroll_into_view '{"target":{"selector":".menu-trigger"}}'
75
- bbx scroll 800
76
- bbx resize 1440 900
77
- ```
78
-
79
- Use `input.scroll_into_view` before a hover, click, or capture when the target
80
- is off-screen or inside a nested scroller.
81
-
82
- ## Patch the live page
83
-
84
- ```bash
85
- bbx patch-style .hero gap=24px padding=32px
86
- bbx patch-text .hero-title "Preview heading"
87
- bbx patches
88
- bbx rollback <patchId>
89
- ```
90
-
91
- Patches are session-scoped and reversible. Use them to prove a fix visually
92
- before you edit source.
93
-
94
- ## Use the raw RPC path
95
-
96
- Shortcuts cover the common cases. For exact methods or advanced parameters:
97
-
98
- ```bash
99
- bbx call dom.query '{"selector":".card","maxNodes":5}'
100
- bbx call --tab 123 page.get_state
101
- bbx call input.scroll_into_view '{"target":{"selector":"[data-testid=\"checkout-summary\"]"}}'
102
- bbx call screenshot.capture_full_page '{}'
103
- bbx page.get_state
104
- bbx batch '[{"method":"page.get_state"},{"method":"page.get_console","params":{"level":"warn"}}]'
105
- ```
106
-
107
- Use `bbx call` when you need the full protocol surface. Use `bbx batch` when
108
- you want parallel reads with one CLI round trip.
109
-
110
- `page.get_console` and `page.get_network` also return `dropped` when hot pages
111
- overflow their 200-entry buffers.
112
-
113
- ## Investigate efficiently
114
-
115
- When the task is open-ended, treat CLI inspection as a structured-first
116
- investigation loop:
117
-
118
- ```bash
119
- bbx batch '[
120
- {"method":"page.get_state"},
121
- {"method":"dom.query","params":{"selector":"main","maxNodes":20,"maxDepth":4,"textBudget":600}},
122
- {"method":"page.get_text","params":{"textBudget":4000}}
123
- ]'
124
- ```
125
-
126
- Add `styles.get_computed`, `layout.get_box_model`, `page.get_console`, or
127
- `page.get_network` only when they directly help answer the question. Escalate
128
- to screenshots after that, not before.
package/docs/index.md DELETED
@@ -1,25 +0,0 @@
1
- # Documentation
2
-
3
- Browser Bridge has a few different audiences: end users wiring it into an agent,
4
- people using the `bbx` CLI directly, and maintainers publishing the project.
5
- This index keeps those paths separate.
6
-
7
- ## Start here
8
-
9
- - [Quickstart](./quickstart.md): fastest path from install to first working tab
10
- - [MCP vs CLI](./mcp-vs-cli.md): which integration path to choose
11
- - [Manual setup](./manual-setup.md): exact config locations, project-local installs, and custom-agent setup
12
-
13
- ## End-user guides
14
-
15
- - [Usage scenarios](./usage-scenarios.md): concrete workflows for debugging, verification, and live patching
16
- - [CLI guide](./cli-guide.md): day-to-day `bbx` commands with practical examples
17
- - [Troubleshooting](./troubleshooting.md): what to check when install, access, or routing fails
18
-
19
- ## Reference
20
-
21
- - [BridgeClient API](./api-reference.md): programmatic client usage without MCP or CLI shortcuts
22
-
23
- ## Maintainers
24
-
25
- - [Publishing](./publishing.md): npm and Chrome Web Store release flow
@@ -1,140 +0,0 @@
1
- # Manual Setup
2
-
3
- Use this guide when the side panel setup flow is not enough, when you want
4
- project-local config instead of global config, or when you are wiring Browser
5
- Bridge into a custom agent.
6
-
7
- ## Prerequisites
8
-
9
- - Google Chrome on the same machine as the agent
10
- - Node.js 18 or newer
11
- - The Browser Bridge extension installed in Chrome
12
-
13
- ## 1. Install the CLI and native host
14
-
15
- ```bash
16
- npm install -g @browserbridge/bbx
17
- bbx install
18
- ```
19
-
20
- `bbx install` writes the native messaging manifest so the extension can talk to
21
- the local host. If you are connecting a packaged store build before the
22
- installer embeds a default extension ID, use `bbx install <extension-id>`.
23
-
24
- ## 2. Verify the local bridge first
25
-
26
- Run these before involving an agent:
27
-
28
- ```bash
29
- bbx status
30
- bbx doctor
31
- ```
32
-
33
- Then open Chrome, enable Browser Bridge for the current window, and verify tab
34
- routing:
35
-
36
- ```bash
37
- bbx tabs
38
- bbx call page.get_state
39
- ```
40
-
41
- If these commands do not work locally, the agent setup will not work either.
42
-
43
- ## 3. Managed setup for supported clients
44
-
45
- Supported managed targets are kept in this order across the project:
46
- `codex`, `claude`, `cursor`, `copilot`, `opencode`, `antigravity`,
47
- `windsurf`, `agents`.
48
-
49
- ### MCP setup
50
-
51
- Use MCP when your agent supports it:
52
-
53
- ```bash
54
- bbx install-mcp
55
- bbx install-mcp codex
56
- bbx install-mcp copilot --local
57
- ```
58
-
59
- Managed MCP config paths:
60
-
61
- - `codex`: `~/.codex/config.toml` or `./.codex/config.toml`
62
- - `claude`: `~/.claude.json` or `./.mcp.json`
63
- - `cursor`: `~/.cursor/mcp.json` or `./.cursor/mcp.json`
64
- - `copilot`: `~/.copilot/mcp-config.json` or `./.vscode/mcp.json`
65
- - `opencode`: `~/.config/opencode/opencode.json` or `./opencode.json`
66
- - `antigravity`: `~/.gemini/antigravity/mcp_config.json` or `./.agents/mcp_config.json`
67
- - `windsurf`: `~/.codeium/windsurf/mcp_config.json` or `./.windsurf/mcp_config.json`
68
- - `agents`: `~/.agents/mcp.json` or `./.agents/mcp.json`
69
-
70
- ### CLI skill setup
71
-
72
- Use the CLI skill when you want the agent to invoke `bbx` directly:
73
-
74
- ```bash
75
- bbx install-skill
76
- bbx install-skill codex
77
- bbx install-skill agents --project .
78
- ```
79
-
80
- Managed skill paths:
81
-
82
- - `codex`: `~/.codex/skills/browser-bridge` or `./.codex/skills/browser-bridge`
83
- - `claude`: `~/.claude/skills/browser-bridge` or `./.claude/skills/browser-bridge`
84
- - `cursor`: `~/.cursor/skills/browser-bridge` or `./.cursor/skills/browser-bridge`
85
- - `copilot`: `~/.copilot/skills/browser-bridge` or `./.github/skills/browser-bridge`
86
- - `opencode`: `~/.opencode/skills/browser-bridge` or `./.opencode/skills/browser-bridge`
87
- - `antigravity`: `~/.gemini/antigravity/skills/browser-bridge` or `./.agents/skills/browser-bridge`
88
- - `windsurf`: `~/.codeium/windsurf/skills/browser-bridge` or `./.windsurf/skills/browser-bridge`
89
- - `agents`: `~/.agents/skills/browser-bridge` or `./.agents/skills/browser-bridge`
90
-
91
- ## 4. Custom-agent MCP wiring
92
-
93
- If your client supports MCP but is not one of the managed targets above, it
94
- must be able to launch:
95
-
96
- ```bash
97
- bbx mcp serve
98
- ```
99
-
100
- Most JSON-based MCP clients use a config block like this:
101
-
102
- ```json
103
- {
104
- "mcpServers": {
105
- "browser-bridge": {
106
- "type": "stdio",
107
- "command": "bbx",
108
- "args": ["mcp", "serve"],
109
- "env": {}
110
- }
111
- }
112
- }
113
- ```
114
-
115
- Two common exceptions:
116
-
117
- - Codex uses TOML with `[mcp_servers."browser-bridge"]`
118
- - OpenCode uses an `"mcp"` block with `"type": "local"` and a command array
119
-
120
- ## 5. Custom-agent CLI skill wiring
121
-
122
- For generic agent runners that load skills from a project directory:
123
-
124
- ```bash
125
- bbx install-skill agents --project .
126
- ```
127
-
128
- That writes the Browser Bridge skill into `./.agents/skills/browser-bridge`.
129
- Your agent still needs shell access to run `bbx`.
130
-
131
- ## 6. Recommended validation flow
132
-
133
- After wiring the agent, validate the smallest useful path:
134
-
135
- 1. Ask the agent to check Browser Bridge status.
136
- 2. Ask it to read page state from the current tab.
137
- 3. Ask it to query one visible element.
138
- 4. Ask it to read one computed style or console entry.
139
-
140
- If that works, the rest of the bridge surface is usually available too.