Skip to content
19 changes: 19 additions & 0 deletions docs/advanced/cdp.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,22 @@ opencli bilibili hot --limit 5 # Test a command
> *Tip: If you provide a standard HTTP/HTTPS CDP endpoint, OpenCLI requests the `/json` target list and picks the most likely inspectable app/page target automatically. If multiple app targets exist, you can further narrow selection with `OPENCLI_CDP_TARGET` (for example `antigravity` or `codex`).*

If you plan to use this setup frequently, you can persist the environment variable by adding the `export` line to your `~/.bashrc` or `~/.zshrc` on the server.

## Local Shortcut: `--browser-cdp`

For local browser-backed commands, you can bypass the daemon/extension path explicitly with `--browser-cdp`.

```bash
opencli cascade https://news.ycombinator.com --browser-cdp
opencli explore https://linux.do --browser-cdp
```

When this flag is present, OpenCLI forces the browser command through Chrome CDP directly. If `OPENCLI_CDP_ENDPOINT` is not already set, OpenCLI will try to auto-discover a local Chrome/Edge debugging session from `DevToolsActivePort`.

If you want this behavior globally, set:

```bash
export OPENCLI_BROWSER_CDP=1
```

With that environment variable enabled, browser-backed commands use the same direct-CDP path by default. You can still disable it for one command with `--no-browser-cdp`.
2 changes: 2 additions & 0 deletions docs/guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Ensure the opencli Browser Bridge extension is installed and **enabled** in `chrome://extensions`.
- Run `opencli doctor` to diagnose connectivity.
- If Chrome is already running with `--remote-debugging-port`, browser-backed commands can bypass the daemon path explicitly with `--browser-cdp`.
- If you want browser-backed commands to use that path by default, set `OPENCLI_BROWSER_CDP=1`.

### Empty data or 'Unauthorized' error

Expand Down
27 changes: 27 additions & 0 deletions docs/images/pr-408-browser-cdp-mode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading