Commit Graph

4189 Commits

Author SHA1 Message Date
reformedot b2b5a260db fix: fixed cubic issues + handle onTabClosed event emission correctly 2025-10-28 18:57:25 -07:00
Aitor 5682f4a993 Merge branch 'main' into feat/improve-session-manager 2025-10-29 02:27:23 +01:00
reformedot 9a0bad39c2 fix: improved session recovery, target type caching & cleaned code 2025-10-28 17:35:04 -07:00
Reagan Hsu 85d1a15dc7 use new create api key link 2025-10-28 11:37:42 -07:00
Reagan Hsu 536600678f added listing functionality if no template is provided 2025-10-28 11:30:57 -07:00
Reagan Hsu 185cce58cf fixed --template generation 2025-10-28 11:30:57 -07:00
Reagan Hsu 47b92ca715 fixed instant selection 2025-10-28 11:30:57 -07:00
Reagan Hsu 7e2d4f5dbd add instant selection with numbers 2025-10-28 11:30:57 -07:00
Reagan Hsu 4de1439f81 change wording; will test now 2025-10-28 11:30:57 -07:00
Reagan Hsu c653d21284 Make init command work without [cli] extras by adding core dependencies
Add click, rich, and InquirerPy to core dependencies to enable
'uvx browser-use init' to work out of the box with beautiful styling
and arrow-key template selection.

Dependencies added to core (all permissive licenses):
- click>=8.1.8 (BSD-3-Clause, 756KB, zero deps)
- rich>=14.0.0 (MIT, 1.8MB, 2 deps: markdown-it-py, pygments)
- InquirerPy>=0.3.4 (MIT, 483KB, 2 deps: prompt-toolkit, pfzy)

Total impact: ~3MB + 4 transitive dependencies
All licenses are compatible with browser-use's MIT license.

Benefits:
- uvx browser-use init works without [cli] extras
- Beautiful terminal output with colors and panels
- Arrow-key navigation for template selection
- Consistent UX across all init methods

[cli] extras now only contain textual for the full TUI application.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 11:30:57 -07:00
Reagan Hsu dd1fca43d7 Make init command work without browser-use[cli] extras
- Add click to core dependencies (moved from [cli] optional deps)
- Create standalone browser_use/init_cmd.py with template generation logic
- Add early check in cli.py to redirect 'init' subcommand to init_cmd.py
- This allows 'uvx browser-use init' to work without installing textual/rich

Users can now run template generation with minimal dependencies:
  uvx browser-use init              # Interactive template selection
  uvx browser-use init -t default   # Generate default template
  uvx browser-use init --list       # List available templates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 11:30:52 -07:00
Reagan Hsu fd655903eb default template naming instead of quickstart 2025-10-28 11:28:52 -07:00
Reagan Hsu a4839215f5 Add template generation command for quick project setup
Adds `uvx browser-use init` command to generate starter template files,
  making it easier for users to get started with browser-use.

  Changes:
  - Add `init` subcommand with three template options:
    - quickstart: Minimal setup using ChatBrowserUse
    - advanced: All configuration options with defaults
    - tools: Custom action examples
  - Templates support both CLI syntax:
    - `uvx browser-use init --template <name>`
    - `uvx browser-use --template <name>` (shorthand)
  - Add interactive mode when no template specified
  - Include template files in package build
  - All templates use async patterns with Browser(use_cloud=False)

  Usage:
    uvx browser-use init --template quickstart
    uvx browser-use --template advanced --output my_script.py
    uvx browser-use init --list
2025-10-28 11:28:46 -07:00
kalil0321 c292e8e3d4 Merge branch 'main' into add-vercel-ai-gateway 2025-10-28 08:32:05 +01:00
Magnus Müller 00b11e1e27 Add method to retrieve target ID from CDP session ID and enhance DownloadsWatchdog with global network response handling
- Introduced `get_target_id_from_session_id` method in `BrowserSession` to facilitate lookup of target IDs from CDP session IDs.
- Updated `DownloadsWatchdog` to register a global network response callback, improving detection of downloadable content.
- Enhanced error handling and logging for network response events to ensure better tracking of downloads and potential issues.

These changes aim to improve the reliability and functionality of session management and download monitoring in the browser automation framework.
2025-10-27 22:30:53 -07:00
Magnus Müller d4f9f9f072 Linter 2025-10-27 22:21:34 -07:00
Magnus Müller 191e0a91ed Message update 2025-10-27 21:48:17 -07:00
Magnus Müller 6098685bca Enhance documentation for file writing action and improve field descriptions
- Updated the `write_file` action to include detailed documentation on supported file formats (.txt, .md, .json, .jsonl, .csv, .pdf) and conversion process for PDF files.
- Refined the `text` field description in `DoneAction` to clarify the expected format for user summaries.
- Improved the `success` field description in `StructuredOutputAction` to specify its meaning more clearly.

These changes aim to enhance clarity and usability for developers interacting with the API.
2025-10-27 21:46:47 -07:00
Magnus Müller 2e6db8a135 Improve auto download for inside iframe 2025-10-27 21:46:34 -07:00
Magnus Müller 367cae2195 Merge branch 'main' into fix/increase-interaction-timeouts 2025-10-27 18:36:23 -07:00
reformedot 1e20610b09 fix: revert evaluate disabled 2025-10-27 18:27:03 -07:00
Magnus Müller 12caa635b9 Increase interaction timeouts to reduce failures on slow pages
Increased timeouts in DefaultActionWatchdog to handle slow-loading
SPAs and dynamic content more reliably:

- Click element fallback: 3.0s → 10.0s (line 126)
- Mouse press event: 1.0s → 3.0s (line 496)
- Mouse release event: 3.0s → 5.0s (line 516)

Analysis of 15,639 benchmark tests showed 1,262 failures (8.1%) due
to input timeouts. This change is expected to resolve ~900 of those
failures, improving overall pass rate from 66.3% to ~72%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 18:21:18 -07:00
Magnus Müller 3ce813ff2c Merge branch 'main' into test-screenshot 2025-10-27 17:34:03 -07:00
Magnus Müller 65da3ddd92 Debug logs 2025-10-27 17:33:42 -07:00
Magnus Müller 9cd948c7db Debug logs 2025-10-27 17:31:52 -07:00
Magnus Müller c3db6cff02 Refactor cross-origin iframe handling in tests and serializer
- Updated the DOMTreeSerializer to remove debug code related to cross-origin iframe detection, enhancing clarity and maintainability.
- Adjusted test cases to replace the cross-origin iframe source with a placeholder (about:blank) for improved test isolation and reliability.
- Updated comments and descriptions in tests to reflect the changes in iframe handling, ensuring accurate documentation of test behavior.

This change aims to streamline the handling of cross-origin iframes in both the serializer and tests, improving overall robustness and maintainability.
2025-10-27 17:19:03 -07:00
Magnus Müller f3c7070506 Refactor cross-origin iframe click test for improved clarity and functionality
- Updated test to verify clicking elements inside iframes in different CDP targets, enhancing the description for better understanding.
- Replaced the previous cross-origin iframe setup with a more controlled iframe content for testing.
- Adjusted assertions to ensure at least one element from the iframe is found, improving test reliability.
- Cleaned up comments and print statements for clarity, ensuring the test accurately reflects its purpose.

This change aims to enhance the robustness and maintainability of tests involving iframe interactions in the browser automation framework.
2025-10-27 17:14:30 -07:00
Alezander9 195f1f1f0f address cubic comments 2025-10-27 12:28:06 -07:00
kalil0321 d1420fe13d Add reasoning models and JSON schema conversion for Gemini compatibility in ChatVercel class 2025-10-27 15:34:56 +01:00
Magnus Müller 16d986a6d9 Remove debug code for cross-origin iframe detection in DOMTreeSerializer
- Eliminated debug logging related to clickable element detection for cross-origin iframes.
- Cleaned up unnecessary comments and code to streamline the function.
- This change aims to enhance code clarity and maintainability while ensuring that the clickable cache functionality remains intact.

Further investigation may be needed to address any remaining issues with detecting interactive elements within cross-origin iframes.
2025-10-27 00:01:46 -07:00
Magnus Müller 8557cffdd7 Remove debug logging from DOM serializer and clickable detector
- Removed all debug print statements for link detection
- Cleaned up empty if blocks left by debug removal
- Fixed indentation issues from automated cleanup
- All linter checks pass

Cross-origin iframe DOM extraction works but clickable elements
within cross-origin iframes are not being detected as interactive.
Further investigation needed to determine if this is a target
switching issue or element detection issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 23:29:35 -07:00
Magnus Müller 04e987df99 Add stacked DOM elements test for complex scenarios
- Introduced a new HTML template for testing stacked DOM elements, including open and closed shadow DOMs, same-origin and cross-origin iframes, and a final button.
- Implemented a test case to validate click functionality through these stacked elements, ensuring that all interactive elements are clickable and that the click counter reflects the expected number of clicks.
- Enhanced the browser session configuration to accommodate a taller window size for better visibility of stacked elements.

This update aims to improve the robustness of DOM interaction tests and ensure comprehensive coverage of complex scenarios in the browser automation framework.
2025-10-26 23:16:06 -07:00
Magnus Müller 4258546098 Add DOM serializer test templates and improve logging
- Introduced new HTML templates for DOM serializer tests, including a main page and an iframe template.
- Enhanced logging in the BrowserSession to provide clearer insights when fetching the CDP client for target nodes, improving traceability during debugging.
- Updated tests to utilize the new HTML templates, ensuring better structure and maintainability.

This update aims to enhance the robustness of the DOM serializer tests and improve error handling in session management.
2025-10-26 22:44:42 -07:00
Magnus Müller 06d0efc289 Improve logging for CDP client retrieval in BrowserSession
- Enhanced error handling when fetching the CDP client for a target node.
- Updated log message to include a warning with the last four characters of the target ID for better traceability.
- Ensured fallback to the main session is clearly indicated in the logs.

This change aims to provide clearer insights during debugging and improve the robustness of the session management.
2025-10-26 22:26:26 -07:00
Magnus Müller 8410a3b9bc Rename action logs to click 2025-10-26 21:50:28 -07:00
kalil0321 d517efa50a Add stop_reason to ChatInvokeCompletion in ChatVercel model 2025-10-26 21:30:00 +01:00
kalil0321 06d2648d95 Add ChatVercel to lazy import 2025-10-26 20:49:14 +01:00
kalil0321 048615e1eb Merge remote-tracking branch 'upstream/main' into add-vercel-ai-gateway 2025-10-26 20:45:56 +01:00
kalil0321 9096011c4d Add Vercel AI Gateway integration with ChatVercel model support 2025-10-26 20:45:01 +01:00
ShawnPana 1ca1307545 Make install command work without CLI dependencies 2025-10-26 12:37:39 -07:00
reformedot 1271c34062 fix: disable evaluate tool 2025-10-26 12:36:11 -07:00
reformedot f0469a8427 fix: fixed "No active exception to reraise" error 2025-10-26 12:15:22 -07:00
reformedot f7bfb15b9c feat: improved system prompt with CAPTCHAs instructions 2025-10-26 07:26:19 -07:00
reformedot 3a21ce805d fix: don't focus when generating DOMTree in _get_viewport_ratio 2025-10-26 06:42:10 -07:00
reformedot 54e4dacbf9 feat: improved session manager 2025-10-26 06:05:49 -07:00
ShawnPana b36524c0ba Apply ruff formatting fixes 2025-10-25 20:37:51 -07:00
ShawnPana 2b3caa3940 init 2025-10-25 19:41:36 -07:00
Magnus Müller 93f1a37ceb Merge branch 'main' into model-tests 2025-10-25 10:46:02 -07:00
Gregor Žunič a3c6fd8025 changed browser use api key creation url everywhere 2025-10-25 10:38:10 -07:00
Magnus Müller 16d8833048 Api key rename 2025-10-25 10:24:40 -07:00