feat(browser): support direct WebSocket CDP URLs for Browserbase

Browserbase uses direct WebSocket connections (wss://) rather than the
standard HTTP-based /json/version CDP discovery flow used by Browserless.
This change teaches the browser tool to accept ws:// and wss:// URLs as
cdpUrl values: when a WebSocket URL is detected, OpenClaw connects
directly instead of attempting HTTP discovery.

Changes:
- config.ts: accept ws:// and wss:// in cdpUrl validation
- cdp.helpers.ts: add isWebSocketUrl() helper
- cdp.ts: skip /json/version when cdpUrl is already a WebSocket URL
- chrome.ts: probe WSS endpoints via WebSocket handshake instead of HTTP
- cdp.test.ts: add test for direct WebSocket target creation
- docs/tools/browser.md: update Browserbase section with correct URL
  format and notes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shrey150
2026-03-02 00:49:55 -08:00
committed by Peter Steinberger
parent 3cf75f760c
commit 75602014db
6 changed files with 106 additions and 17 deletions

View File

@@ -200,9 +200,10 @@ Notes:
[Browserbase](https://www.browserbase.com) is a cloud platform for running
headless browsers. It provides remote CDP endpoints with built-in CAPTCHA
solving, stealth mode, and residential proxies. You can point an
OpenClaw browser profile at Browserbase's connect endpoint and authenticate
with your API key.
solving, stealth mode, and residential proxies. Unlike Browserless (which
exposes a standard HTTP-based CDP discovery endpoint), Browserbase uses a
direct WebSocket connection — OpenClaw connects to `wss://connect.browserbase.com`
and authenticates via your API key in the query string.
Example:
@@ -228,6 +229,8 @@ Notes:
- [Sign up](https://www.browserbase.com/sign-up) and copy your **API Key**
from the [Overview dashboard](https://www.browserbase.com/overview).
- Replace `<BROWSERBASE_API_KEY>` with your real Browserbase API key.
- Browserbase auto-creates a browser session on WebSocket connect, so no
manual session creation step is needed.
- The free tier allows one concurrent session and one browser hour per month.
See [pricing](https://www.browserbase.com/pricing) for paid plan limits.
- See the [Browserbase docs](https://docs.browserbase.com) for full API