Reported with Browser Control (CLI 0.8.3, extension 0.0.25), whose relay this
is: the relay crashed on startup with "unhandled RangeError: Max payload size
exceeded (WS_ERR_UNSUPPORTED_MESSAGE_LENGTH)" when the extension sent an
oversized message, and kept crashing until the extension was reloaded.
ws closes a socket that exceeds maxPayload (100 MiB by default) and reports
it as an "error" event on that socket. The relay had no "error" listener on
the extension or CDP client sockets, so Node treated the event as unhandled
and the process died; the extension reconnected, resent, and crashed it again.
- The relay accepts messages up to 256 MiB, as Playwright's own CDP client
does (large screenshots and response bodies come close to 100 MiB).
- The extension and CDP client sockets, and the HTTP server after it starts
listening, log errors to relay.log (extension.error, client.error,
http.error) instead of crashing; ws then closes the offending socket.
- The extension checks the size of what it sends (UTF-8 bytes, measured only
when the text could be over the limit, and tolerating a result too large to
serialize): an oversized command result fails that one command with "Result
too large to send ... request less data" instead of breaking the connection
and every command in flight; an oversized event is dropped and logged.
Verified against a relay and a headless Chrome on an isolated port: a 240 MB
CDP result now passes (it crashed the relay before); a client message over
256 MiB makes the relay log client.error and close that socket with 1009
while it stays up; an earlier 200 MB cap answered 210 MB with the "Result too
large" error. A result over ~256 MB crashes the extension's own process in
Chrome before it reaches this code (the relay stays up); that is a browser
limit.
packages/browser-extension/cli is the npm package `opencode-browser-cli`, with
its own package.json and lockfile so its dependencies stay out of the
monorepo's. It is Browser Control (anomalyco/browser-control 8c80ac2, MIT)
ported into OpenCode Browser: renamed, on its own port (19988), accepting only
OpenCode Browser's extension IDs, with files under
~/.local/share/opencode-browser.
- The relay: a local CDP endpoint backed by the extension's chrome.debugger,
shared by several clients, with named sessions that survive relay restarts
and extension reloads, handoffs, recordings (CDP and tab capture), a flight
recorder, network capture with a redacted HAR, secrets, and a journal.
relay.log records lifecycle, connects (with the extension's build and
origin), every HTTP request with its duration, and faults.
- The `browse` MCP server (stdio) and the `opencode-browser` CLI: execute
(Playwright API through patchright-core, which never enables CDP's Runtime
domain, so pages can't detect the debugger that way; pageConsole.start()
opts one page into console capture), session_* (session_adopt also takes a
Chrome tab id), network_*, recording_*, flight_recorder_*, secrets_*,
tabs_cleanup, status, skill. The agent guide is skills/browse/SKILL.md.
- Human-like input (human-input.ts): curved, eased mouse paths, off-center
clicks with a settle and hold, paced keys, gliding wheel scrolls.
OPENCODE_BROWSER_HUMAN_INPUT=0 turns it off.
- Setup (setup.ts): `install` installs a pinned runtime, adds the `browse` MCP
server to opencode's global config (with a fingerprint so opencode restarts
it on updates), restarts an outdated relay, copies the unpacked extension and
reloads a connected unpacked build only when it is older (checking the
reload took effect), then reports which browsers and profiles have the
extension and opens its Web Store listing when none does (unless headless,
--no-open, or a browser couldn't be read). It removes leftovers of earlier
versions (native messaging host, opencode plugin, `opencode-browser` MCP
entry). `extension` and `uninstall` round it out.
Verified: cli typecheck and build; install on the user's machine (detected
Helium/Ryan as default with the unpacked build, Chrome unreadable under macOS
privacy protection, Arc without it; a second install neither restarts the
relay nor reloads the extension); through the browse MCP tools in Helium:
session_new, execute (goto, title, locators), screenshot, session_list,
a CDP recording, session_delete.