-
Notifications
You must be signed in to change notification settings - Fork 5k
[FEATURE] Added in-built browser tools using playwright and a parallel playwright node process using spawn for bun-playwright issues. #7302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
…ht node process using spawm for bun-playwright issues.
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
There was a problem hiding this comment.
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
| File | Description |
|---|---|
| tsconfig.json | Added esModuleInterop and path aliases for imports |
| packages/opencode/package.json | Added playwright and sharp dependencies |
| packages/opencode/src/flag/flag.ts | Added OPENCODE_ENABLE_BROWSER and OPENCODE_BROWSER_PROFILE_PATH flags |
| packages/opencode/src/tool/tool.ts | Added Tool.attachExecute helper for convenience execute method |
| packages/opencode/src/tool/registry.ts | Integrated BrowserTools into tool registry |
| packages/opencode/src/browser/manager.ts | Core BrowserManager with HTTP-based Playwright bridge |
| packages/opencode/src/browser/tools/*.ts | 28 individual browser automation tools |
| packages/opencode/browser-server.js | Node.js HTTP server managing Playwright browser instance |
| packages/opencode/src/browser/annotate.ts | Screenshot annotation utilities using sharp |
| packages/opencode/src/browser/README.md | Comprehensive documentation |
| bun.lock | Lock file updates for new dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Added browser automation toolkit to the
packages/opencodepackage, just like anthropic's claude in chrome and cursor 2.0. Also, this feature can be turned on by setting the flagOPENCODE_ENABLE_BROWSER=truein the terminal or settingbrowser: trueinopencode.jsonbefore 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:
browser_navigatebrowser_navigate_backbrowser_navigate_forwardbrowser_waitbrowser_initbrowser_closebrowser_close_pagebrowser_clickbrowser_hoverbrowser_typebrowser_searchbrowser_dragbrowser_scrollbrowser_press_keybrowser_fill_formbrowser_select_optionbrowser_checkbrowser_file_uploadbrowser_contentbrowser_screenshotbrowser_snapshotbrowser_evaluatebrowser_run_codebrowser_console_messagesbrowser_network_requestsbrowser_handle_dialogbrowser_tabsbrowser_resizebrowser_get_pagebrowser_get_element_atbrowser_get_element_boundsbrowser_verify_element_visiblebrowser_verify_text_visiblebrowser_generate_locatorI've made sure these tools give expandable web automation capabilities and infinite possibilities with minimal tool call overhead and context bloat.
Fixes:
Known issues:
npx playwright install chromiumbefore getting started.Notes: