opendevbrowser 0.0.12 → 0.0.15

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +216 -28
  3. package/dist/chunk-JVBMT2O5.js +7173 -0
  4. package/dist/chunk-JVBMT2O5.js.map +1 -0
  5. package/dist/cli/index.js +2486 -589
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/index.js +1057 -194
  8. package/dist/index.js.map +1 -1
  9. package/dist/opendevbrowser.js +1057 -194
  10. package/dist/opendevbrowser.js.map +1 -1
  11. package/extension/dist/annotate-content.css +237 -0
  12. package/extension/dist/annotate-content.js +934 -0
  13. package/extension/dist/background.js +1194 -32
  14. package/extension/dist/logging.js +50 -0
  15. package/extension/dist/ops/dom-bridge.js +355 -0
  16. package/extension/dist/ops/ops-runtime.js +1249 -0
  17. package/extension/dist/ops/ops-session-store.js +189 -0
  18. package/extension/dist/ops/redaction.js +52 -0
  19. package/extension/dist/ops/snapshot-builder.js +4 -0
  20. package/extension/dist/ops/snapshot-shared.js +220 -0
  21. package/extension/dist/popup.js +370 -25
  22. package/extension/dist/relay-settings.js +1 -0
  23. package/extension/dist/services/CDPRouter.js +501 -103
  24. package/extension/dist/services/ConnectionManager.js +464 -57
  25. package/extension/dist/services/NativePortManager.js +182 -0
  26. package/extension/dist/services/RelayClient.js +227 -26
  27. package/extension/dist/services/TabManager.js +81 -0
  28. package/extension/dist/services/TargetSessionMap.js +146 -0
  29. package/extension/dist/services/cdp-router-commands.js +203 -0
  30. package/extension/dist/services/url-restrictions.js +41 -0
  31. package/extension/dist/types.js +3 -1
  32. package/extension/manifest.json +17 -3
  33. package/extension/popup.html +144 -0
  34. package/package.json +2 -2
  35. package/skills/AGENTS.md +34 -62
  36. package/skills/data-extraction/SKILL.md +95 -103
  37. package/skills/form-testing/SKILL.md +75 -82
  38. package/skills/login-automation/SKILL.md +76 -66
  39. package/skills/opendevbrowser-best-practices/SKILL.md +90 -49
  40. package/skills/opendevbrowser-continuity-ledger/SKILL.md +57 -23
  41. package/dist/chunk-WTFSMBVH.js +0 -2815
  42. package/dist/chunk-WTFSMBVH.js.map +0 -1
  43. package/extension/dist/popup.jsx +0 -150
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OpenDevBrowser contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -4,11 +4,45 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg?style=flat-square)](https://www.typescriptlang.org/)
6
6
  [![OpenCode Plugin](https://img.shields.io/badge/OpenCode-Plugin-green.svg?style=flat-square)](https://opencode.ai)
7
- [![Test Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen.svg?style=flat-square)](https://registry.npmjs.org/opendevbrowser)
7
+ [![CLI](https://img.shields.io/badge/Interface-CLI-orange.svg?style=flat-square)](docs/CLI.md)
8
+ [![Chrome Extension](https://img.shields.io/badge/Chrome-Extension-blue.svg?style=flat-square)](docs/EXTENSION.md)
9
+ [![Test Coverage](https://img.shields.io/badge/coverage-97%25-brightgreen.svg?style=flat-square)](https://registry.npmjs.org/opendevbrowser)
8
10
 
9
11
  > **Script-first browser automation for AI agents.** Snapshot → Refs → Actions.
10
12
 
11
- OpenDevBrowser is an [OpenCode](https://opencode.ai) plugin that gives AI agents direct browser control via Chrome DevTools Protocol. Launch browsers, capture page snapshots, and interact with elements using stable refs.
13
+ OpenDevBrowser is an agent-agnostic browser automation runtime. You can use it as an [OpenCode](https://opencode.ai) plugin, as a standalone CLI, or through the Chrome extension relay for logged-in browser sessions. It supports managed sessions, direct CDP attach, and extension-backed Ops sessions.
14
+
15
+ <p align="center">
16
+ <img src="assets/readme-image-candidates/2026-02-08/04-annotation-automation-scene.jpg" alt="OpenDevBrowser hero image showing AI-assisted annotation and browser automation workflow" width="920" />
17
+ <br />
18
+ <em>AI-assisted annotation and browser automation workflow</em>
19
+ </p>
20
+
21
+ ## Use It Your Way
22
+
23
+ | Interface | OpenCode Required | Best For |
24
+ |-----------|-------------------|----------|
25
+ | **CLI (`npx opendevbrowser ...`)** | No | Any agent/workflow that can run shell commands |
26
+ | **Chrome Extension + Relay** | No | Reusing existing logged-in tabs without launching a new browser |
27
+ | **OpenCode Plugin Tools** | Yes | Native tool-calling inside OpenCode (`opendevbrowser_*`) |
28
+
29
+ All core automation flows are available through the CLI command surface and the plugin tool surface.
30
+
31
+ ## Why OpenDevBrowser?
32
+
33
+ | Feature | Benefit |
34
+ |---------|---------|
35
+ | **Script-first UX** | Snapshot → Refs → Actions workflow optimized for AI agents |
36
+ | **Accessibility-tree snapshots** | Token-efficient page representation (not raw DOM) |
37
+ | **Stable refs** | Elements identified by `backendNodeId`, not fragile selectors |
38
+ | **Security by default** | CDP localhost-only, timing-safe auth, HTML sanitization |
39
+ | **3 browser modes** | Managed, CDP connect, or extension relay for logged-in sessions |
40
+ | **Ops + CDP channels** | High-level multi-client `/ops` plus legacy `/cdp` compatibility |
41
+ | **Relay Hub (FIFO leases)** | Single-owner CDP binding with a FIFO queue for multi-client safety |
42
+ | **Flat-session routing** | Extension relay uses DebuggerSession sessionId routing (Chrome 125+) |
43
+ | **5 bundled skill packs** | Best practices for login, forms, data extraction |
44
+ | **41 tools** | Complete browser automation coverage |
45
+ | **97% test coverage** | Production-ready with strict TypeScript |
12
46
 
13
47
  ---
14
48
 
@@ -28,10 +62,26 @@ npx opendevbrowser --local # ./opencode.json
28
62
  npx opendevbrowser --full
29
63
  ```
30
64
 
31
- Restart OpenCode after installation.
65
+ Use OpenCode only if you want plugin tools. CLI and extension workflows work without OpenCode.
66
+
67
+ On first successful install, the CLI attempts to install daemon auto-start on supported platforms so the relay is available on login.
68
+ You can remove it later with `npx opendevbrowser daemon uninstall`.
32
69
 
33
70
  OpenCode discovers skills in `.opencode/skill` (project) and `~/.config/opencode/skill` (global) first; `.claude/skills` is compatibility-only. The CLI installs bundled skills into the OpenCode-native locations by default.
34
71
 
72
+ ### CLI + Extension (No OpenCode)
73
+
74
+ ```bash
75
+ # Start relay/daemon runtime
76
+ npx opendevbrowser serve
77
+
78
+ # Launch using extension mode (requires extension popup connected)
79
+ npx opendevbrowser launch --extension-only --wait-for-extension
80
+
81
+ # Or force managed mode without extension
82
+ npx opendevbrowser launch --no-extension
83
+ ```
84
+
35
85
  ### Agent Installation (OpenCode)
36
86
 
37
87
  Recommended (CLI, installs plugin + config + bundled skills + extension assets):
@@ -57,12 +107,14 @@ Manual fallback (edit OpenCode config):
57
107
 
58
108
  Config location: `~/.config/opencode/opencode.json`
59
109
 
60
- Restart OpenCode, then run `opendevbrowser_status` to verify the plugin is loaded.
110
+ Restart OpenCode, then run `opendevbrowser_status` to verify the plugin is loaded (daemon status when hub is enabled).
61
111
 
62
112
  ---
63
113
 
64
114
  ## Quick Start
65
115
 
116
+ OpenDevBrowser uses the same automation model across plugin tools and CLI commands:
117
+
66
118
  ```
67
119
  1. Launch a browser session
68
120
  2. Navigate to a URL
@@ -71,15 +123,15 @@ Restart OpenCode, then run `opendevbrowser_status` to verify the plugin is loade
71
123
  5. Re-snapshot after navigation
72
124
  ```
73
125
 
74
- ### Core Workflow
126
+ ### Core Workflow (Plugin Tools)
75
127
 
76
128
  | Step | Tool | Purpose |
77
129
  |------|------|---------|
78
- | 1 | `opendevbrowser_launch` | Start managed Chrome session |
130
+ | 1 | `opendevbrowser_launch` | Launch a session (extension relay first; managed fallback is explicit) |
79
131
  | 2 | `opendevbrowser_goto` | Navigate to URL |
80
132
  | 3 | `opendevbrowser_snapshot` | Get page structure with refs |
81
133
  | 4 | `opendevbrowser_click` / `opendevbrowser_type` | Interact with elements |
82
- | 5 | `opendevbrowser_close` | Clean up session |
134
+ | 5 | `opendevbrowser_disconnect` | Clean up session |
83
135
 
84
136
  ---
85
137
 
@@ -91,6 +143,12 @@ Run a local daemon for persistent sessions, then drive automation via CLI comman
91
143
  # Start daemon
92
144
  npx opendevbrowser serve
93
145
 
146
+ # Install auto-start (recommended for resilience)
147
+ npx opendevbrowser daemon install
148
+
149
+ # Stop/kill the daemon before restarting
150
+ npx opendevbrowser serve --stop
151
+
94
152
  # Launch a session
95
153
  npx opendevbrowser launch --start-url https://example.com
96
154
 
@@ -111,6 +169,24 @@ Use `--output-format json|stream-json` for automation-friendly output.
111
169
 
112
170
  ---
113
171
 
172
+ ## Recent Features
173
+
174
+ ### v0.0.15 (Latest)
175
+
176
+ - **Documentation and release readiness refresh** across README/CLI/extension guidance.
177
+ - **Extension mode stabilization** with stronger native host flow and recovery paths.
178
+ - **Ops/CDP hardening** for disconnect cleanup and extension routing reliability.
179
+ - **Coverage expansion** for browser/target/native workflows while preserving the 97% threshold.
180
+
181
+ ### v0.0.14
182
+
183
+ - **Ops parity delivery** across daemon, relay, and extension runtime paths.
184
+ - **New automation surface**: expanded DOM query + interaction commands/tools.
185
+ - **Multi-client/session improvements** in core tracking and extension router behavior.
186
+ - **Security and reliability hardening** for relay + daemon connection handling.
187
+
188
+ See [CHANGELOG.md](CHANGELOG.md) for complete version history.
189
+
114
190
  ## Features
115
191
 
116
192
  ### Browser Control
@@ -129,8 +205,8 @@ Use `--output-format json|stream-json` for automation-friendly output.
129
205
 
130
206
  ### DevTools Integration
131
207
  - **Console Capture** - Monitor console.log, errors, warnings
132
- - **Network Tracking** - Capture XHR/fetch requests and responses
133
- - **Screenshot** - Full page or element screenshots
208
+ - **Network Tracking** - Request/response metadata (method, url, status)
209
+ - **Screenshot** - Viewport PNG screenshot (file or base64)
134
210
  - **Performance** - Page load metrics
135
211
 
136
212
  ### Export & Clone
@@ -142,15 +218,16 @@ Use `--output-format json|stream-json` for automation-friendly output.
142
218
 
143
219
  ## Tool Reference
144
220
 
145
- OpenDevBrowser provides **30 tools** organized by category:
221
+ OpenDevBrowser provides **41 tools** organized by category:
222
+ Most runtime actions also have CLI command equivalents (see [docs/CLI.md](docs/CLI.md)).
146
223
 
147
224
  ### Session Management
148
225
  | Tool | Description |
149
226
  |------|-------------|
150
- | `opendevbrowser_launch` | Launch managed Chrome session with optional profile |
151
- | `opendevbrowser_connect` | Connect to existing Chrome CDP endpoint |
227
+ | `opendevbrowser_launch` | Launch a session (extension relay first; managed is explicit) |
228
+ | `opendevbrowser_connect` | Connect to existing Chrome CDP endpoint (or relay `/ops`; legacy `/cdp` via `--extension-legacy`) |
152
229
  | `opendevbrowser_disconnect` | Disconnect browser session |
153
- | `opendevbrowser_status` | Get session status and connection info |
230
+ | `opendevbrowser_status` | Get session status and connection info (daemon status in hub mode) |
154
231
 
155
232
  ### Tab/Target Management
156
233
  | Tool | Description |
@@ -174,9 +251,14 @@ OpenDevBrowser provides **30 tools** organized by category:
174
251
  | `opendevbrowser_wait` | Wait for load state or element |
175
252
  | `opendevbrowser_snapshot` | Capture page accessibility tree with refs |
176
253
  | `opendevbrowser_click` | Click element by ref |
254
+ | `opendevbrowser_hover` | Hover element by ref |
255
+ | `opendevbrowser_press` | Press a keyboard key (optionally focusing a ref) |
256
+ | `opendevbrowser_check` | Check checkbox/toggle by ref |
257
+ | `opendevbrowser_uncheck` | Uncheck checkbox/toggle by ref |
177
258
  | `opendevbrowser_type` | Type text into input by ref |
178
259
  | `opendevbrowser_select` | Select dropdown option by ref |
179
260
  | `opendevbrowser_scroll` | Scroll page or element |
261
+ | `opendevbrowser_scroll_into_view` | Scroll element into view by ref |
180
262
  | `opendevbrowser_run` | Execute multiple actions in sequence |
181
263
 
182
264
  ### DOM Inspection
@@ -184,6 +266,11 @@ OpenDevBrowser provides **30 tools** organized by category:
184
266
  |------|-------------|
185
267
  | `opendevbrowser_dom_get_html` | Get outerHTML of element by ref |
186
268
  | `opendevbrowser_dom_get_text` | Get innerText of element by ref |
269
+ | `opendevbrowser_get_attr` | Get attribute value by ref |
270
+ | `opendevbrowser_get_value` | Get input value by ref |
271
+ | `opendevbrowser_is_visible` | Check if element is visible |
272
+ | `opendevbrowser_is_enabled` | Check if element is enabled |
273
+ | `opendevbrowser_is_checked` | Check if element is checked |
187
274
 
188
275
  ### DevTools & Analysis
189
276
  | Tool | Description |
@@ -194,6 +281,11 @@ OpenDevBrowser provides **30 tools** organized by category:
194
281
  | `opendevbrowser_perf` | Get page performance metrics |
195
282
  | `opendevbrowser_prompting_guide` | Get best-practice prompting guidance |
196
283
 
284
+ ### Annotation
285
+ | Tool | Description |
286
+ |------|-------------|
287
+ | `opendevbrowser_annotate` | Capture interactive annotations via extension relay |
288
+
197
289
  ### Export & Cloning
198
290
  | Tool | Description |
199
291
  |------|-------------|
@@ -239,22 +331,47 @@ Load a skill: `opendevbrowser_skill_load` with `name` and optional `topic` filte
239
331
  | **CDP Connect** | `opendevbrowser_connect` | Attach to existing Chrome with `--remote-debugging-port` |
240
332
  | **Extension Relay** | Chrome Extension | Attach to logged-in tabs via relay server |
241
333
 
334
+ Default behavior: `opendevbrowser_launch` prefers **Extension Relay** when available. Use `--no-extension` (and `--headless` if desired) for managed sessions.
335
+
336
+ Extension relay relies on **flat CDP sessions (Chrome 125+)** and uses DebuggerSession `sessionId` routing for multi-tab and child-target support. When hub mode is enabled, the hub daemon is the sole relay owner and there is **no local relay fallback**.
337
+
338
+ Relay ops endpoint: `ws://127.0.0.1:<relayPort>/ops`.
339
+ The connect command also accepts base relay WS URLs (`ws://127.0.0.1:<relayPort>` or `ws://localhost:<relayPort>`) and normalizes them to `/ops`.
340
+ Legacy relay `/cdp` remains available with explicit opt-in (`--extension-legacy`).
341
+ When pairing is enabled, both `/ops` and `/cdp` require a relay token (`?token=<relayToken>`). Tools and the CLI auto-fetch relay config and tokens.
342
+
343
+ ## Ops vs CDP
344
+
345
+ | Channel | What It Does | When to Use It |
346
+ |---------|---------------|----------------|
347
+ | **`/ops` (default)** | High-level automation protocol with session ownership, event streaming, and multi-client handling | Preferred extension relay path for modern workflows |
348
+ | **`/cdp` (legacy)** | Low-level CDP relay path with compatibility-focused behavior | Opt-in compatibility mode (`--extension-legacy`) |
349
+ | **Direct CDP connect** | Attach to Chrome started with `--remote-debugging-port` | Existing debug/browser setups without extension relay |
350
+
242
351
  ---
243
352
 
353
+ ## Breaking Changes (latest)
354
+
355
+ - `opendevbrowser_launch` now prefers the extension relay by default. Use `--no-extension` (and `--headless` if desired) for managed sessions.
356
+ - Relay `/ops` (default) and legacy `/cdp` both require a token when pairing is enabled; tools/CLI handle this automatically.
357
+
244
358
  ## Chrome Extension (Optional)
245
359
 
246
- The extension enables **Mode C** - attach to existing logged-in browser tabs without launching a new browser.
360
+ The extension enables **Extension Relay** mode - attach to existing logged-in browser tabs without launching a new browser.
361
+
362
+ **Requirements:** Chrome 125+ (flat CDP sessions). Older versions will fail fast with a clear error.
247
363
 
248
364
  ### Auto-Connect + Auto-Pair
249
365
 
250
- The plugin and extension can automatically pair:
366
+ The runtime (plugin or CLI daemon) and extension can automatically pair:
251
367
 
252
- 1. **Plugin side**: Starts a local relay server and config discovery endpoint
368
+ 1. **Runtime side**: Starts a local relay server and config discovery endpoint
253
369
  2. **Extension side**: Enable "Auto-Pair" toggle and click Connect
254
370
  3. Extension fetches relay port from discovery, then fetches token from the relay server
255
371
  4. Connection established with color indicator (green = connected)
256
372
 
257
373
  **Auto-connect** and **Auto-pair** are enabled by default for a seamless setup. The extension badge shows status (ON/OFF).
374
+ If the relay is unavailable, the background worker retries `/config` + `/pair` with exponential backoff (using `chrome.alarms`).
258
375
 
259
376
  ### Default Settings (Extension)
260
377
 
@@ -273,15 +390,28 @@ The plugin and extension can automatically pair:
273
390
  3. If pairing is required and Auto-pair is on, it fetches the token from `http://127.0.0.1:<relayPort>/pair`.
274
391
  4. It connects to `ws://127.0.0.1:<relayPort>/extension` using the extension origin.
275
392
 
276
- `/config` and `/pair` are extension-origin only for CSWSH protection.
393
+ `/config` and `/pair` accept loopback requests with no `Origin` (including `Origin: null`) to support MV3 + PNA; non-extension origins are still rejected, and preflights include `Access-Control-Allow-Private-Network: true`.
394
+
395
+ ### Troubleshooting: Extension Won't Connect
396
+
397
+ - Ensure the active tab is a normal `http(s)` page (not `chrome://` or extension pages).
398
+ - Confirm `relayPort` and `relayToken` in `~/.config/opencode/opendevbrowser.jsonc` match the popup (Auto-pair should fetch the token).
399
+ - If `relayPort` is `0`, the relay is off.
400
+ - `relayToken: false` disables relay/hub behavior entirely.
401
+ - `relayToken: ""` (empty string) keeps relay enabled but disables pairing requirements.
402
+ - Install auto-start with `npx opendevbrowser daemon install` so the relay is available on login.
403
+ - Clear extension local data and retry if the token/port seem stuck.
404
+ - If another process owns the port, change `relayPort` or stop it; `opencode` listening is expected.
277
405
 
278
406
  ### Manual Setup
279
407
 
280
- 1. Start OpenCode once so the plugin can extract the extension assets.
408
+ 1. Ensure extension assets exist by running either:
409
+ - `npx opendevbrowser --full` (installer path), or
410
+ - `npm run extension:build` (repo/dev path)
281
411
  2. Load unpacked from `~/.config/opencode/opendevbrowser/extension`
282
412
  (fallback: `~/.cache/opencode/node_modules/opendevbrowser/extension`).
283
413
  3. Open extension popup
284
- 4. Enter the same relay port and token as the plugin config
414
+ 4. Enter the same relay port and token as the runtime config
285
415
  (if `relayToken` is missing, either add one to `opendevbrowser.jsonc` or use Auto-Pair).
286
416
  5. Click Connect
287
417
 
@@ -350,17 +480,27 @@ Optional config file: `~/.config/opencode/opendevbrowser.jsonc`
350
480
  "relayPort": 8787,
351
481
  "relayToken": "auto-generated-on-first-run",
352
482
 
483
+ // Hub daemon (relay ownership + FIFO queue)
484
+ "daemonPort": 8788,
485
+ "daemonToken": "auto-generated-on-first-run",
486
+
353
487
  // Updates
354
488
  "checkForUpdates": false
355
489
  }
356
490
  ```
357
491
 
358
- All fields optional. Plugin works with sensible defaults.
492
+ All fields are optional. OpenDevBrowser works with sensible defaults.
359
493
 
360
494
  ---
361
495
 
362
496
  ## CLI Commands
363
497
 
498
+ The CLI is agent-agnostic and supports the full automation surface (session, navigation, interaction, DOM, targets, pages, export, devtools, and annotate).
499
+ All commands listed in the CLI reference are implemented and available in the current codebase.
500
+ See [docs/CLI.md](docs/CLI.md) for the full command and flag matrix.
501
+
502
+ ### Install/Management
503
+
364
504
  | Command | Description |
365
505
  |---------|-------------|
366
506
  | `npx opendevbrowser` | Interactive install |
@@ -372,16 +512,42 @@ All fields optional. Plugin works with sensible defaults.
372
512
  | `npx opendevbrowser --uninstall` | Remove from config |
373
513
  | `npx opendevbrowser --version` | Show version |
374
514
 
515
+ ### Common Automation Commands (Daemon-backed)
516
+
517
+ Start the daemon with `npx opendevbrowser serve`, then use:
518
+
519
+ | Command | Description |
520
+ |---------|-------------|
521
+ | `npx opendevbrowser launch` | Launch session (defaults to extension mode when available) |
522
+ | `npx opendevbrowser connect` | Connect via relay or direct CDP endpoint |
523
+ | `npx opendevbrowser disconnect` | Disconnect session |
524
+ | `npx opendevbrowser status` | Show session status |
525
+ | `npx opendevbrowser goto` | Navigate to URL |
526
+ | `npx opendevbrowser wait` | Wait for load or element |
527
+ | `npx opendevbrowser snapshot` | Capture snapshot with refs |
528
+ | `npx opendevbrowser click` | Click element by ref |
529
+ | `npx opendevbrowser type` | Type into element by ref |
530
+ | `npx opendevbrowser select` | Select dropdown option by ref |
531
+ | `npx opendevbrowser scroll` | Scroll page or element |
532
+ | `npx opendevbrowser run` | Run a JSON script |
533
+
375
534
  ---
376
535
 
377
536
  ## Security
378
537
 
379
- - **Relay Authentication** - Cryptographically secure tokens, timing-safe comparison
380
- - **Origin Validation** - Only localhost and Chrome extensions can pair
381
- - **CDP Localhost-Only** - Remote CDP endpoints blocked by default
382
- - **Data Redaction** - Console/network output redacts tokens and API keys
383
- - **Export Sanitization** - Scripts and event handlers stripped from exports
384
- - **Atomic Config Writes** - Prevents config corruption on crash
538
+ OpenDevBrowser is **secure by default** with defense-in-depth protections:
539
+
540
+ | Protection | Details |
541
+ |------------|---------|
542
+ | **CDP Localhost-Only** | Remote endpoints blocked; hostname normalized to prevent bypass |
543
+ | **Timing-Safe Auth** | `crypto.timingSafeEqual()` for token comparison |
544
+ | **Origin Validation** | `/extension` requires `chrome-extension://` origin; `/ops`, `/cdp`, `/annotation`, and `/config`/`/status`/`/pair` allow loopback no-Origin requests |
545
+ | **PNA Preflights** | HTTP preflights include `Access-Control-Allow-Private-Network: true` when requested |
546
+ | **Rate Limiting** | 5 handshake attempts/minute per IP, plus HTTP rate limiting for `/config`, `/status`, `/pair` |
547
+ | **Data Redaction** | Tokens, API keys, sensitive paths auto-redacted |
548
+ | **Export Sanitization** | Scripts, event handlers, dangerous CSS stripped |
549
+ | **Atomic Writes** | Config writes are atomic to prevent corruption |
550
+ | **Secure Defaults** | `allowRawCDP`, `allowNonLocalCdp`, `allowUnsafeExport` all `false` |
385
551
 
386
552
  ---
387
553
 
@@ -401,13 +567,35 @@ Release checklist: [docs/DISTRIBUTION_PLAN.md](docs/DISTRIBUTION_PLAN.md)
401
567
 
402
568
  ---
403
569
 
570
+ ## Architecture
571
+
572
+ ```
573
+ src/
574
+ ├── browser/ # BrowserManager, TargetManager, CDP lifecycle
575
+ ├── cli/ # CLI commands and installers
576
+ ├── core/ # Bootstrap, runtime wiring
577
+ ├── devtools/ # Console/network trackers with redaction
578
+ ├── export/ # DOM capture, React emitter, CSS extraction
579
+ ├── relay/ # Extension relay server, protocol types
580
+ ├── skills/ # SkillLoader for skill pack discovery
581
+ ├── snapshot/ # AX-tree snapshots, ref management
582
+ ├── tools/ # 41 opendevbrowser_* tool definitions
583
+ └── utils/ # Shared utilities
584
+ ```
585
+
586
+ Extension relay uses flat CDP sessions (Chrome 125+) with DebuggerSession `sessionId` routing for multi-tab support.
587
+ When hub mode is enabled, the hub daemon is the sole relay owner and enforces a FIFO lease queue for multi-client safety.
588
+ See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for detailed component diagrams.
589
+
590
+ ---
591
+
404
592
  ## Development
405
593
 
406
594
  ```bash
407
595
  npm install
408
596
  npm run build # Compile to dist/
409
- npm run test # Run tests with coverage
410
- npm run lint # ESLint checks
597
+ npm run test # Run tests with coverage (97% threshold)
598
+ npm run lint # ESLint checks (strict TypeScript)
411
599
  npm run extension:build # Compile extension
412
600
  npm run version:check # Verify package/extension version alignment
413
601
  npm run extension:pack # Build extension zip for releases