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

Open
opened 2026-02-16 18:17:15 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7302

State: open
Merged: No


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:

https://github.com/user-attachments/assets/af7956cb-cf65-4639-b873-b09f5e39c902

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

Tools:

File Tool Name Description
navigate.ts browser_navigate Navigate to URLs with optional content return
navigate-back.ts browser_navigate_back Go back in browser history
navigate-back.ts browser_navigate_forward Go forward in browser history
wait.ts browser_wait Wait for conditions (time, text, elements)
init.ts browser_init Initialize browser instance with optional direct URL navigation
close.ts browser_close Close browser instance
close-page.ts browser_close_page Close current page while keeping browser running
click.ts browser_click Click elements with fuzzy search and auto-scroll
hover.ts browser_hover Hover over elements
type.ts browser_type Type text into inputs with submit option
search.ts browser_search Find elements using fuzzy search
drag.ts browser_drag Drag and drop between elements
scroll.ts browser_scroll Scroll page with content return
press-key.ts browser_press_key Press keyboard keys
fill-form.ts browser_fill_form Fill multiple form fields at once
select-option.ts browser_select_option Select dropdown options
check-element.ts browser_check Check/uncheck checkboxes and radio buttons
file-upload.ts browser_file_upload Upload files to file inputs
content.ts browser_content Get page content (text, links, inputs, structured)
screenshot.ts browser_screenshot Take screenshots (viewport or full page)
snapshot.ts browser_snapshot Get accessibility snapshot for actions
evaluate.ts browser_evaluate Evaluate JavaScript expressions
run-code.ts browser_run_code Run Playwright code snippets
console-messages.ts browser_console_messages Get browser console messages
network-requests.ts browser_network_requests List network requests
handle-dialog.ts browser_handle_dialog Handle browser dialogs (alerts, confirms)
tabs.ts browser_tabs Manage browser tabs (list, create, close, select)
resize.ts browser_resize Resize browser window
get-page.ts browser_get_page Get current page information (URL, title, scroll position)
get-element-at.ts browser_get_element_at Get element at specific coordinates (x, y)
get-element-bounds.ts browser_get_element_bounds Get bounding box of element by selector/ref
verify-element-visible.ts browser_verify_element_visible Verify elements are visible
verify-text-visible.ts browser_verify_text_visible Verify text appears on page
generate-locator.ts browser_generate_locator Generate 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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7302 **State:** open **Merged:** No --- 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: - [playwright](github.com/microsoft/playwright) ### Working video: https://github.com/user-attachments/assets/af7956cb-cf65-4639-b873-b09f5e39c902 (working speed depends on network ping, unfortunately mine is too high) ### Tools: | File | Tool Name | Description | |------|-----------|-------------| | navigate.ts | `browser_navigate` | Navigate to URLs with optional content return | | navigate-back.ts | `browser_navigate_back` | Go back in browser history | | navigate-back.ts | `browser_navigate_forward` | Go forward in browser history | | wait.ts | `browser_wait` | Wait for conditions (time, text, elements) | | init.ts | `browser_init` | Initialize browser instance with optional direct URL navigation | | close.ts | `browser_close` | Close browser instance | | close-page.ts | `browser_close_page` | Close current page while keeping browser running | | click.ts | `browser_click` | Click elements with fuzzy search and auto-scroll | | hover.ts | `browser_hover` | Hover over elements | | type.ts | `browser_type` | Type text into inputs with submit option | | search.ts | `browser_search` | Find elements using fuzzy search | | drag.ts | `browser_drag` | Drag and drop between elements | | scroll.ts | `browser_scroll` | Scroll page with content return | | press-key.ts | `browser_press_key` | Press keyboard keys | | fill-form.ts | `browser_fill_form` | Fill multiple form fields at once | | select-option.ts | `browser_select_option` | Select dropdown options | | check-element.ts | `browser_check` | Check/uncheck checkboxes and radio buttons | | file-upload.ts | `browser_file_upload` | Upload files to file inputs | | content.ts | `browser_content` | Get page content (text, links, inputs, structured) | | screenshot.ts | `browser_screenshot` | Take screenshots (viewport or full page) | | snapshot.ts | `browser_snapshot` | Get accessibility snapshot for actions | | evaluate.ts | `browser_evaluate` | Evaluate JavaScript expressions | | run-code.ts | `browser_run_code` | Run Playwright code snippets | | console-messages.ts | `browser_console_messages` | Get browser console messages | | network-requests.ts | `browser_network_requests` | List network requests | | handle-dialog.ts | `browser_handle_dialog` | Handle browser dialogs (alerts, confirms) | | tabs.ts | `browser_tabs` | Manage browser tabs (list, create, close, select) | | resize.ts | `browser_resize` | Resize browser window | | get-page.ts | `browser_get_page` | Get current page information (URL, title, scroll position) | | get-element-at.ts | `browser_get_element_at` | Get element at specific coordinates (x, y) | | get-element-bounds.ts | `browser_get_element_bounds` | Get bounding box of element by selector/ref | | verify-element-visible.ts | `browser_verify_element_visible` | Verify elements are visible | | verify-text-visible.ts | `browser_verify_text_visible` | Verify text appears on page | | generate-locator.ts | `browser_generate_locator` | Generate 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: - https://github.com/anomalyco/opencode/issues/6992 - https://github.com/anomalyco/opencode/issues/575 ### 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
yindo added the pull-request label 2026-02-16 18:17:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12339