Skip to content

fix(browser): remote-CDP profiles over Playwright for Browser Sessions - #270

Merged
insomnius merged 6 commits into
boonfrom
arief/browser-remote-cdp-driver
Oct 8, 2026
Merged

insomnius merged 6 commits into
boonfrom
arief/browser-remote-cdp-driver

Conversation

@insomnius

@insomnius insomnius commented Oct 7, 2026 •

Copy link
Copy Markdown

Summary

OpenClaw fork changes needed by Browser Sessions (anychat-boon-web#158, getboon/boon#15419 / openclaw#15420). The anychat-boon-web plugin now relays CDP to the user's cloud browser (Browser Use) through a loopback proxy and registers it as a remote-CDP profile; these make that path work and fast.

  • perf(browser): drive registered remote-CDP profiles with Playwright, attach-only (89e7b362555) — registerRemoteCdpBrowserProfile hardcoded the existing-session (Chrome DevTools MCP) driver, which re-polls the URL after every interaction; over a remote endpoint that cost ~7-17s per click. Profiles now use the openclaw (Playwright) driver, still attachOnly. Also affects browser-handoff profiles (that path is not live yet).
  • fix(browser): drive attach-only loopback CDP relays over Playwright (d6e12f448b1) — a loopback cdpUrl was always classified local-managed, so an attach-only ws://127.0.0.1:<port>/<path> relay had its tabs listed via /json/list on a derived HTTP base → HTTP 404 on every snapshot. An attach-only ws(s) URL with a non-/devtools/ path is now remote-cdp; bare Chrome debug sockets keep local behavior.
  • fix(browser): resolve act targetId aliases before mismatch check (44eab86a921) — cherry-pick of upstream fix(browser): resolve act targetId aliases before mismatch check openclaw/openclaw#96178 (d405cda95ac); act with a tab label as targetId returned 403 ACT_TARGET_ID_MISMATCH.
  • feat(web-fetch): accept ssrfPolicy.allowedHostnames in web_fetch config (af7d02c2e85) — configs written by upstream (allowedHostnames: [localhost]) failed strict validation; SsrFPolicy already supports it, now passed through and included in the fetch cache key.

Test plan

  • Red-first unit tests for each change (browser-profile-mutations.test.ts, config.test.ts, web-fetch.ssrf.test.ts, schema.test.ts; upstream tests for fix(browser): resolve act targetId aliases before mismatch check openclaw/openclaw#96178: 31/31)
  • extensions/browser suite: 1399 pass; 1 pre-existing failure (cdp.helpers.internal.test.ts "rejects and rethrows when the WebSocket fails to open", also red on base)
  • Live end-to-end locally against a real Browser Use browser through the plugin's loopback proxy: connect ~1.6-1.9s, navigate ~1s, click ~4s; no /json/list 404s

Summary by cubic

Makes remote-CDP browser profiles (used by Browser Sessions' cloud browser relay) run over Playwright instead of the Chrome DevTools MCP bridge, cutting per-action latency from ~7-17s to ~1-4s and fixing /json/list 404s on loopback relays. Also fixes act targetId alias mismatches and lets web_fetch accept hostname allowlists.

  • Remote-CDP profiles now register with the openclaw driver, attach-only, instead of existing-session, which re-polled the URL after every interaction.
  • Attach-only ws(s):// URLs with a non-/devtools/ path, or a root path with a query, are treated as remote CDP relays; bare Chrome debug sockets keep local behavior.
  • act requests resolve tab aliases (tabId, label, suggestedTargetId, id prefix) to the canonical targetId before the mismatch check and before Playwright dispatch, fixing 403 ACT_TARGET_ID_MISMATCH and runtime page-lookup misses.
  • web_fetch config now accepts ssrfPolicy.allowedHostnames; entries must be bare hostnames/IPs, are passed to the SSRF policy, and are JSON-serialized into the fetch cache key.
  • attachOnly is now persisted for allocated-port profiles too.

Written for commit 54790a3. Summary will update on new commits.

View guided diff Turn on auto-fix

insomnius and others added 4 commits October 6, 2026 19:56
Boon fork's strict web_fetch ssrfPolicy schema rejected allowedHostnames,
so configs written by upstream (e.g. allowedHostnames: [localhost]) fail
validation. SsrFPolicy already supports allowedHostnames; pass it through
and include it in the fetch cache key.
…attach-only

registerRemoteCdpBrowserProfile registered every sibling-plugin profile with
the existing-session driver, which routes each command through a Chrome
DevTools MCP process and re-polls the page URL after every interaction. Over a
remote CDP endpoint that cost ~7-17s per click. Register with the openclaw
(Playwright) driver instead, still attach-only so nothing is ever launched.
A loopback cdpUrl was always classified local-managed, so an attach-only
ws relay endpoint (e.g. a local app relaying to a cloud browser) had its tabs
listed via /json/list on a derived HTTP base, which the relay does not serve
(HTTP 404). Treat an attach-only ws(s) URL with a non-devtools path as remote
CDP; bare Chrome debug sockets keep local behavior.
…nclaw#96178)

* fix(browser): resolve act targetId aliases before mismatch check

The /act top-level and batch targetId guards compared the caller-supplied
targetId against the resolved canonical tab.targetId with raw string
equality. Any supported alias form (tabId, label, suggestedTargetId, or a
unique id prefix) resolves to a different canonical id, so act requests that
followed the documented 'prefer suggestedTargetId/tabId/label' guidance were
rejected with 403 ACT_TARGET_ID_MISMATCH even though they named the correct
tab. snapshot/open/close/tabs lack this guard and kept working, matching the
reported symptom matrix.

Resolve the action targetId through the same tab alias resolution the route
used and reject only ids that resolve to a different tab.

* fix(browser): canonicalize act targetId aliases before Playwright dispatch

The /act gate accepted tabId/label/suggested/prefix aliases of the request
tab but left them on action.targetId. The managed executor reads
action.targetId ?? targetId for an exact page lookup (executeSingleAction ->
getPageForTargetId), so an alias missed the lookup and broke the action at
runtime whenever more than one page was open (single-page masked it via the
pages.length===1 fallback). Canonicalize the action targetId (top-level and
nested batch sub-actions) to the resolved tab id before dispatch; reject ids
that resolve to a different tab. Replace the mock-masked contract assertions
with executor-action assertions plus direct canonicalizer unit tests.

* test(browser): brace act-targetId guard clauses for curly lint

* docs(changelog): note browser target alias fix

* docs(changelog): note browser target alias fix

* fix(browser): reject ambiguous batch target aliases

* test(browser): type targetless act fixture

* docs(changelog): move browser alias fix to unreleased

* chore: drop nonessential browser changelog entry

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit d405cda)
@insomnius
insomnius requested a review from a team October 7, 2026 12:48

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 16 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="extensions/browser/src/browser/routes/agent.act.ts">

<violation number="1" location="extensions/browser/src/browser/routes/agent.act.ts:451">
P3: Moving target-ID validation before the `isExistingSession` branch changes the error precedence for existing-session (Chrome MCP) batch actions: a batch with a mismatched nested `targetId` now returns 403 `targetIdMismatch` instead of the previous 501 "batch is not supported for existing-session profiles". Both are errors, but clients keying on the 501 to detect unsupported batch on existing-session profiles no longer see it, and nested target-ID validation now runs for a driver the route otherwise considers fully unsupported for batch. Consider running `getExistingSessionUnsupportedMessage` first or gating nested batch validation to the non-existing-session path.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/agents/tools/web-fetch.ts Resolved
Comment thread src/config/zod-schema.agent-runtime.ts Resolved
…ostnames (cubic)

- web_fetch cache key serializes allowedHostnames with JSON (no comma
  collisions across differently-allowed lists)
- allowedHostnames entries must be bare hostnames/IPs (no blank, wildcard,
  URL or path that would silently never match)
- a root attach-only ws relay URL with a query is remote CDP too
- attachOnly is persisted for allocated-port profiles as well
- profile-mutations test clears mock history before asserting

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: APPROVE

LGTM! Remote-CDP browser profiles driven by Playwright over CDP directly instead of Chrome MCP existing-session bridge, eliminating 7-17s re-polling latency per interaction.

Key Changes

  1. Playwright Driver for Remote CDP (extensions/browser/browser-profile-mutations.ts, config-mutations.ts):
    • registerRemoteCdpBrowserProfile now configures driver: "openclaw" and attachOnly: true (instead of existing-session).
    • Persists attachOnly for allocated-port and custom profiles.
  2. Loopback Relay Detection (extensions/browser/src/browser/profile-capabilities.ts):
    • Attach-only ws(s):// endpoints with a non-/devtools/ path or query are classified as mode: "remote-cdp", driving them via persistent Playwright instead of failing on local /json/list endpoints.
  3. Target ID Alias Canonicalization (extensions/browser/src/browser/routes/agent.act.ts, agent.act.normalize.ts):
    • Resolves tab aliases (unique prefixes, labels, suggestedTargetId, tabId) to the canonical targetId before mismatch checks and Playwright dispatch, preventing 403 ACT_TARGET_ID_MISMATCH and page lookup misses.
    • Recursively normalizes batched sub-actions.
  4. SSRF Allowed Hostnames for Web Fetch (src/agents/tools/web-fetch.ts, config schemas):
    • Adds ssrfPolicy.allowedHostnames support to web_fetch.
    • Strict regex validation enforces bare hostnames or IPs.
    • Includes JSON-serialized allowedHostnames in the cache key to avoid cache collisions.

Verification & Testing

  • Unit tests added across all components (browser-profile-mutations.test.ts, config-mutations.test.ts, config.test.ts, agent.act.normalize.test.ts, server.agent-contract-core.test.ts, web-fetch.ssrf.test.ts, schema.test.ts).
  • Upstream tests passing; CI suites passing.

Verdict: APPROVE

@insomnius
insomnius enabled auto-merge (squash) October 8, 2026 08:39
@insomnius
insomnius merged commit 891c5d1 into boon Oct 8, 2026
147 of 155 checks passed
@insomnius
insomnius deleted the arief/browser-remote-cdp-driver branch October 8, 2026 14:11
orswn added a commit that referenced this pull request Oct 9, 2026
…-> 2026.6.34-boon.4 (#274)

Cut the fork release that ships the three commits on boon since
v2026.6.34-boon.3. /stop now also ends the shell commands of the
session and its sub-agents (#272, ENG-16829). Registered remote-CDP
browser profiles run over Playwright for Browser Sessions (#270,
ENG-21111). @modelcontextprotocol/sdk moves to 1.31.0 (#268).

Bump root package.json and npm-shrinkwrap.json, all 135 plugin
manifests, and the version and openclaw peer floor in every extension
npm-shrinkwrap.json. Add the 2026.6.34-boon.4 CHANGELOG.md section.

#268 changed pnpm-lock.yaml but not the npm shrinkwraps, so the root,
acpx, slack and msteams shrinkwraps still pinned the old
@modelcontextprotocol/sdk tree and the shrinkwrap lock graph test
failed on boon. Move those entries to the pnpm-lock.yaml versions:
@modelcontextprotocol/sdk 1.31.0, express-rate-limit 8.7.1,
eventsource-parser 3.1.1, content-type 2.1.0 and iconv-lite 0.7.3.
The shrinkwraps were generated with a temporary npm-only override for
the @opentelemetry packages under @sentry/node; the override is not
committed. No other dependency changes.
orswn added a commit that referenced this pull request Oct 10, 2026
…ep-extension

boon moved to 2026.6.34-boon.4 (#274), which bumped every plugin
manifest. The new boon-pdf-prep manifest still said boon.3, so the
release preflight would fail on the next version bump:
plugins:sync:check reported "update required: @openclaw/boon-pdf-prep".

Align it with pnpm plugins:sync. Regenerate the plugin inventory, the
plugin reference page and the config baseline, which the new plugin
changes and which plugins:inventory:check and config:docs:check
reported as stale. The baseline also picks up
tools.web.fetch.ssrfPolicy.allowedHostnames from #270, which boon did
not regenerate.

The remaining preflight drift is the npm shrinkwrap check on the
@opentelemetry packages under @sentry/node. It is the same on boon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants