Skip to content

feat: Added in-built browser tools using playwright and a parallel playwright node process using spawn for bun-playwright issues. - #7302

Open
forloopcodes wants to merge 6 commits into
anomalyco:devfrom
forloopcodes:dev
Open

feat: Added in-built browser tools using playwright and a parallel playwright node process using spawn for bun-playwright issues. #7302
forloopcodes wants to merge 6 commits into
anomalyco:devfrom
forloopcodes:dev

Conversation

@forloopcodes

@forloopcodesforloopcodes commented Jan 8, 2026

Copy link
Copy Markdown

Added browser automation toolkit to the packages/opencode package, just like anthropic's claude in chrome and cursor 2.0. Also, this feature can be turned on by setting the flag OPENCODE_ENABLE_BROWSER=true in the terminal or setting browser: true in opencode.json before running it.

This method does not use mcp but direct integration of browser tools into opencode, doing this can further extend opencode's possibilities to open devtools (not yet, but possible), resize windows, and much more than what extension+mcp method does.

Dependencies:

Working video:

opencode.-.added.browser.tools.mp4

(working speed depends on network ping, unfortunately mine is too high)

Tools:

FileTool NameDescription
navigate.tsbrowser_navigateNavigate to URLs with optional content return
navigate-back.tsbrowser_navigate_backGo back in browser history
navigate-back.tsbrowser_navigate_forwardGo forward in browser history
wait.tsbrowser_waitWait for conditions (time, text, elements)
init.tsbrowser_initInitialize browser instance with optional direct URL navigation
close.tsbrowser_closeClose browser instance
close-page.tsbrowser_close_pageClose current page while keeping browser running
click.tsbrowser_clickClick elements with fuzzy search and auto-scroll
hover.tsbrowser_hoverHover over elements
type.tsbrowser_typeType text into inputs with submit option
search.tsbrowser_searchFind elements using fuzzy search
drag.tsbrowser_dragDrag and drop between elements
scroll.tsbrowser_scrollScroll page with content return
press-key.tsbrowser_press_keyPress keyboard keys
fill-form.tsbrowser_fill_formFill multiple form fields at once
select-option.tsbrowser_select_optionSelect dropdown options
check-element.tsbrowser_checkCheck/uncheck checkboxes and radio buttons
file-upload.tsbrowser_file_uploadUpload files to file inputs
content.tsbrowser_contentGet page content (text, links, inputs, structured)
screenshot.tsbrowser_screenshotTake screenshots (viewport or full page)
snapshot.tsbrowser_snapshotGet accessibility snapshot for actions
evaluate.tsbrowser_evaluateEvaluate JavaScript expressions
run-code.tsbrowser_run_codeRun Playwright code snippets
console-messages.tsbrowser_console_messagesGet browser console messages
network-requests.tsbrowser_network_requestsList network requests
handle-dialog.tsbrowser_handle_dialogHandle browser dialogs (alerts, confirms)
tabs.tsbrowser_tabsManage browser tabs (list, create, close, select)
resize.tsbrowser_resizeResize browser window
get-page.tsbrowser_get_pageGet current page information (URL, title, scroll position)
get-element-at.tsbrowser_get_element_atGet element at specific coordinates (x, y)
get-element-bounds.tsbrowser_get_element_boundsGet bounding box of element by selector/ref
verify-element-visible.tsbrowser_verify_element_visibleVerify elements are visible
verify-text-visible.tsbrowser_verify_text_visibleVerify text appears on page
generate-locator.tsbrowser_generate_locatorGenerate robust selectors for tests

I've made sure these tools give expandable web automation capabilities and infinite possibilities with minimal tool call overhead and context bloat.

Fixes:

Known issues:

  • need to do npx playwright install chromium before getting started.

Notes:

  • this is my first PR on the opencode repository, would love to listen from the community
  • developers/reviewers are requested to tell me whatever i could add/fix over this feature (im sorry if something broke) <3

CopilotAI review requested due to automatic review settings January 8, 2026 08:49
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a comprehensive browser automation toolkit to OpenCode using Playwright, providing 28 tools for web automation tasks. The implementation uses a Node.js HTTP server bridge (browser-server.js) to manage Chromium instances, as Playwright doesn't work natively with Bun. The feature is gated behind the OPENCODE_ENABLE_BROWSER environment flag.

Key Changes:

  • Browser automation infrastructure: BrowserManager, HTTP bridge server, and 28 automation tools
  • Dependencies: Added playwright@1.57.0 and sharp@0.34.5
  • Configuration: TypeScript path aliases, new environment flags, and tool registry integration

Reviewed changes

Copilot reviewed 39 out of 41 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
tsconfig.jsonAdded esModuleInterop and path aliases for imports
packages/opencode/package.jsonAdded playwright and sharp dependencies
packages/opencode/src/flag/flag.tsAdded OPENCODE_ENABLE_BROWSER and OPENCODE_BROWSER_PROFILE_PATH flags
packages/opencode/src/tool/tool.tsAdded Tool.attachExecute helper for convenience execute method
packages/opencode/src/tool/registry.tsIntegrated BrowserTools into tool registry
packages/opencode/src/browser/manager.tsCore BrowserManager with HTTP-based Playwright bridge
packages/opencode/src/browser/tools/*.ts28 individual browser automation tools
packages/opencode/browser-server.jsNode.js HTTP server managing Playwright browser instance
packages/opencode/src/browser/annotate.tsScreenshot annotation utilities using sharp
packages/opencode/src/browser/README.mdComprehensive documentation
bun.lockLock file updates for new dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/opencode/src/browser/annotate.ts Outdated
Comment threadpackages/opencode/src/browser/manager.ts Outdated
Comment threadpackages/opencode/src/browser/manager.ts Outdated
Comment threadpackages/opencode/src/browser/manager.ts Outdated
Comment threadpackages/opencode/src/browser/manager.ts Outdated
Comment threadpackages/opencode/src/browser/manager.ts Outdated
@gangjeuk

Copy link
Copy Markdown

How do you think about the Puppeteer and Puppeteer chromium resolver combination?

@forloopcodes

forloopcodes commented Jan 15, 2026

Copy link
Copy Markdown
Author

i didnt think a lot about choosing between them, but one advantage is that playwright can control multi tabs in a single instance (cant confirm, source: gemini)

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title [FEATURE] Added in-built browser tools using playwright and a parallel playwright node process using spawn for bun-playwright issues. doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@forloopcodesforloopcodes changed the title [FEATURE] Added in-built browser tools using playwright and a parallel playwright node process using spawn for bun-playwright issues. feat: Added in-built browser tools using playwright and a parallel playwright node process using spawn for bun-playwright issues. Jan 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@h0jeZvgoxFepBQ2C

Copy link
Copy Markdown

Cant wait for this merge!

@BrutchsamaJeanLouis

Copy link
Copy Markdown

THIS!!! 🎉

@dj0024javia

Copy link
Copy Markdown

bumping this. really helpful! waiting for the merge 🚀

@transportrefer

Copy link
Copy Markdown

Any status on this PR? This would be really nice.

@SpartanJohn117

Copy link
Copy Markdown

Hi @forloopcodes,

Love this. What is the current status 🤔

@skywalker-35

Copy link
Copy Markdown

This is exactly what OpenCode needs. Having built-in browser tools (not MCP, not external CLI) as first-class citizens would be a huge win for the agent workflow.

Currently I'm hopping between agent-browser, playwright-cli, and Playwright MCP — each has friction (MCP token bloat, CLI cold starts, 360 antivirus blocking Chrome on Windows). Native integration via browser: true in opencode.json is the cleanest path forward.

Looking forward to seeing this merged. Happy to help test on Windows if needed.

@kacperpaczos

Copy link
Copy Markdown

I'm waiting for this feature to be available.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@forloopcodes@gangjeuk@h0jeZvgoxFepBQ2C@BrutchsamaJeanLouis@dj0024javia@transportrefer@SpartanJohn117@skywalker-35@kacperpaczos