Conversation
Add a built-in browser tool that drives headless Chrome, Chromium, or Edge over the Chrome DevTools Protocol. It opens pages, returns screenshots as image attachments, and supports clicking, typing, pressing keys, scrolling, and reading page text so the agent can verify front-end work end to end. - no new dependencies: raw CDP over a WebSocket connection - cross-platform browser discovery with OPENCODE_BROWSER_PATH override - permission key "browser" with per-action patterns - idle shutdown plus process exit cleanup - unit tests and a Chrome-gated integration test
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: I found one potentially related PR: PR #7302 — "Added in-built browser tools using playwright and a parallel playwright node process using spawn for bun-playwright issues" This PR appears to be an earlier attempt at adding browser automation capabilities to the agent, but uses Playwright instead of Chrome DevTools Protocol. This may have been closed or superseded, but it's worth noting as related work in the same feature area. The current PR (#48505) takes a different implementation approach (CDP-based) and adds more comprehensive features like cross-platform browser discovery and proper screenshot integration. |
Run the browser tool with a visible window when a display is available so the user can watch the agent work. Pass `headless: true` or set `OPENCODE_BROWSER_HEADLESS=1` to hide it, and fall back to headless on Linux hosts without a display.
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Issue for this PR
Closes #48377
Related: #40782
Type of change
What does this PR do?
Adds a built-in
browsertool so the agent can see and interact with web pages.open,screenshot,click(selector or coordinates),type,press,scroll,read,back,forward,reload,close.Bun.spawn— no new dependencies.OPENCODE_BROWSER_PATHoverrides.browserpermission key;docs/tools.mdxanddocs/permissions.mdxupdated.Scoped to the browser; OS-level desktop control is out of scope for this PR. Happy to adjust the tool surface (naming, action granularity, gating) based on maintainer feedback.
How did you verify your code works?
bun typecheckinpackages/opencode— clean.bun test test/tool— 350 pass, including new tests for URL normalization, key parsing, and platform browser discovery.Screenshots / recordings
N/A — no UI changes. The tool returns page screenshots to the model as attachments.
Checklist