Commit Graph

8176 Commits

Author SHA1 Message Date
Larsen Cundrič 174747009e InterruptedError is due to user interrupting, so should be warning (#3585) 2025-11-13 21:48:35 -08:00
LarsenCundric deea28b4bb InterruptedError is due to user interrupting, so should be warning 2025-11-13 21:46:52 -08:00
kalil0321 1c85a8a688 Fix lint 2025-11-13 15:49:43 +01:00
kalil0321 0988199776 Merge branch 'main' into kalil0321/demo-mode 2025-11-13 15:34:49 +01:00
Balázs Thomay dc9dbbeddd Fix upgrade command to use == instead of @ for uv compatibility 2025-11-13 12:17:56 +01:00
Larsen Cundrič 1339007f9f Handle None session_manager in DownloadsWatchdog network handler (#3582)
### Problem:
AttributeError: 'NoneType' object has no attribute
'get_target_id_from_session_id' occurred when the network response
handler ran after browser shutdown or before connection, when
session_manager was None.

### Root Cause:
The global Network.responseReceived callback can fire after
session_manager is cleared during _disconnect_from_browser(), causing a
race condition.

### Solution:
Added a None check before accessing
session_manager.get_target_id_from_session_id() in on_response_received,
returning early if session_manager is None. Added a warning log for
visibility.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Handled None session_manager in DownloadsWatchdog to avoid crashes when
Network.responseReceived fires during browser shutdown or before
connection. We now skip network monitoring and log a warning if
session_manager is missing.

<sup>Written for commit a3e1ed7274.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-11-12 22:29:05 -08:00
LarsenCundric a3e1ed7274 Skip if none 2025-11-12 22:24:56 -08:00
Mert Unsal dc9e0a17fb add the system prompt (#3580) 2025-11-12 21:46:59 -08:00
mertunsall 3ec547135b add the system prompt 2025-11-12 21:46:25 -08:00
Magnus Müller 240cb80c33 Add fuzzy search TUI for template selection (#3578)
- Replace ListPrompt with FuzzyPrompt for real-time search
- Add responsive layout based on terminal width
- Display author names for non-default templates
- Organize templates: defaults, featured, others
- Sort by last modified date within sections
- Remove default pre-selection for cleaner UX

Enhances template discovery with intuitive search and better
organization.







<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds fuzzy search and a responsive TUI for template selection to make
finding templates faster and clearer. Improves discovery with organized
sections and visible metadata.

- **New Features**
  - Real-time fuzzy search replaces the list prompt.
  - Responsive choice formatting based on terminal width.
  - Shows [FEATURED] and author names (non-default templates).
  - Organized into defaults, featured, and others.
  - Sorted by last_modified_date within each section (newest first).
  - Removed default pre-selection.

<sup>Written for commit 3505fe5d5f.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->







<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Introduces a fuzzy-search TUI with responsive choice formatting,
organized sections, and recency sorting for template selection in
`browser_use/init_cmd.py`.
> 
> - **CLI (`browser_use/init_cmd.py`)**:
> - Replace list prompt with fuzzy-search prompt for interactive
template selection.
> - Add responsive choice formatting based on terminal width; include
`[FEATURED]` and author (non-default templates).
> - Organize templates into defaults, featured, and others; sort each by
`author.last_modified_date` (newest first).
> - Remove default pre-selection and numeric keybindings; enable
scrollable list (`max_height='70%'`).
>   - Introduce `_get_terminal_width` and `_format_choice` helpers.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3505fe5d5f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-11-12 21:34:59 -08:00
Magnus Müller 3505fe5d5f Merge branch 'main' into init-tui 2025-11-12 21:34:10 -08:00
Mert Unsal 7bb5f6d42a log too much (#3579)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Added detailed debug and warning logs to DownloadsWatchdog’s
BrowserStateRequestEvent flow to improve traceability and
troubleshooting without changing behavior.

- **New Features**
- Log start and successful completion of BrowserStateRequestEvent
handling.
- Include event_id and target_id (last 4 chars) and truncate URLs to 80
chars in logs.
  - Warn and skip when there’s no valid focus or no URL.

<sup>Written for commit 1f758178da.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-11-12 21:22:16 -08:00
mertunsall 1f758178da log too much 2025-11-12 21:20:49 -08:00
Aitor 9be4b62736 feat: improved navigate to URL event logic and wait mechanism (#3549)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Improved navigation reliability and speed with lifecycle-driven waits
and smarter tab handling. Centralized target/session state in
SessionManager to remove polling and prevent race conditions.

- **New Features**
- Added _navigate_and_wait that waits for networkIdle, falling back to
load (2–4s timeout) with loaderId matching.
- SessionManager now enables Page lifecycle + Network once per session,
discovers targets, updates title/URL via targetInfoChanged, initializes
existing tabs, and stores lifecycle events per session so monitoring is
ready before navigation.

- **Refactors**
- Reuse about:blank tabs using cached target data to avoid extra CDP
calls; fall back to current tab on failures.
- Centralized targets/sessions in SessionManager (Target entity) with
cached tabs/URLs; added get_all_page_sessions and made session retrieval
sync; removed polling; iframe targets included; lazy frame fetch for DOM
builds.
- Only switch tabs when needed; safer target_id handling; removed fixed
post-navigate sleep and tab responsiveness checks; still emit
NavigationCompleteEvent on errors.
- Standardized agent focus to agent_focus_target_id with helpers to get
focused session/target; updated watchdogs/CLI and added safer focus
change handling with an about:blank fallback; added
create_task_with_error_handling for background tasks to avoid unhandled
exceptions.
- Updated cdp-use to 1.4.4 and increased max WebSocket frame size to
200MB to better handle large DOMs.

<sup>Written for commit 315995c092.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-11-13 06:12:50 +01:00
shawn pana e843be71d7 Merge branch 'main' into init-tui 2025-11-12 21:03:05 -08:00
ShawnPana bdb02ddc6a Fix lint: avoid private import usage for InquirerPy.fuzzy
- Use getattr(inquirer, 'fuzzy') to avoid pyright reportPrivateImportUsage error
- Apply ruff format to fix code formatting
2025-11-12 20:51:16 -08:00
reformedot 315995c092 Merge branch 'feat/improve-navigation' of github.com:browser-use/browser-use into feat/improve-navigation 2025-11-12 20:46:15 -08:00
reformedot bc8407ac8d refactor: refine exception propagation in create_task_with_error_handling
- Introduced a variable to hold exceptions for re-raising outside the try-except block, ensuring proper propagation to the event loop.
- Updated comments for clarity on the exception handling process in background tasks.
2025-11-12 20:46:06 -08:00
ShawnPana fe56d27424 Add fuzzy search TUI for template selection
- Replace ListPrompt with FuzzyPrompt for real-time search
- Add responsive layout based on terminal width
- Display author names for non-default templates
- Organize templates: defaults, featured, others
- Sort by last modified date within sections
- Remove default pre-selection for cleaner UX

Enhances template discovery with intuitive search and better organization.
2025-11-12 20:43:36 -08:00
Aitor c662b29b31 Merge branch 'main' into feat/improve-navigation 2025-11-13 05:37:09 +01:00
reformedot e7b8f2987c refactor: improve exception handling in create_task_with_error_handling
- Updated the logging behavior for exceptions in background tasks to log at warning level and re-raise exceptions for better propagation to the event loop's exception handler.
- Enhanced clarity in comments regarding exception retrieval and handling.
2025-11-12 20:36:47 -08:00
reformedot 2bfb3497d9 refactor: improve CDP session handling in cua.py and test_frame_hierarchy.py
- Updated the method of obtaining CDP sessions to utilize the public API, enhancing error handling during session retrieval.
- Added exception handling to ensure graceful failure when sessions cannot be created or retrieved, improving robustness in both the main functionality and tests.
2025-11-12 20:35:15 -08:00
Mert Unsal 9b5c91e75c more logging (#3577)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Add debug logging of the raw version info response in session.connect
and a clearer assert message when the CDP URL is missing. This helps
diagnose failures when connecting to existing Chromium browsers via CDP.

<sup>Written for commit a2e81f17d7.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-11-12 20:31:39 -08:00
mertunsall a2e81f17d7 more logging 2025-11-12 20:28:23 -08:00
reformedot 13868aee9b refactor: update all_frames parameter handling in DomService
- Changed the type of the all_frames parameter to allow for None, enabling lazy fetching of cross-origin iframes only when necessary.
- Updated comments to clarify the behavior of all_frames during DOM tree construction.
2025-11-12 20:05:01 -08:00
reformedot b741c429d7 refactor: streamline event handling in BrowserSession
- Adjusted the structure of event handling for 'networkIdle' and 'load' events to improve readability and maintainability.
- Ensured that logging for page readiness is consistently executed within the event handling logic.
2025-11-12 20:02:38 -08:00
reformedot 935f31fd19 Merge branch 'feat/improve-navigation' of github.com:browser-use/browser-use into feat/improve-navigation 2025-11-12 19:59:48 -08:00
reformedot 78042d56a5 refactor: enhance error handling in DOMWatchdog tasks
- Updated the `create_task_with_error_handling` calls in `DOMWatchdog` to include the `suppress_exceptions` parameter, improving error management during DOM tree building and screenshot capturing.
- This change allows for better handling of exceptions without interrupting the flow of task execution.
2025-11-12 19:59:39 -08:00
Aitor bf55fda8f1 Merge branch 'main' into feat/improve-navigation 2025-11-13 04:42:51 +01:00
reformedot 77d7f161fb refactor: enhance session management and error handling in BrowserSession
- Improved the `create_task_with_error_handling` function to allow for better exception logging and retrieval based on the `suppress_exceptions` parameter.
- Updated `SessionManager` to implement event-driven recovery for stale agent focus, replacing polling with efficient event handling.
- Refactored session retrieval methods to ensure focus validation and recovery are handled automatically.
- Enhanced logging for recovery processes and session management to provide clearer insights into state changes and errors.
- Adjusted various watchdogs to utilize the new session management methods, ensuring they correctly handle focus validation and session retrieval.
2025-11-12 19:42:24 -08:00
Larsen Cundrič d992238836 Bump google-genai and anthropic (#3575) 2025-11-12 19:01:51 -08:00
Larsen Cundrič 8d6376b11a Merge branch 'main' into larsen/update-chat-libs 2025-11-12 19:00:38 -08:00
LarsenCundric fc89e83633 Bump google-genai and anthropic 2025-11-12 18:04:04 -08:00
Aitor 0bc50831a9 Merge branch 'main' into feat/improve-navigation 2025-11-13 03:01:24 +01:00
reformedot 177b6d00dd Merge branch 'feat/improve-navigation' of github.com:browser-use/browser-use into feat/improve-navigation 2025-11-12 18:00:22 -08:00
reformedot 91e82ae85e chore: update cdp-use dependency version and increase max WebSocket frame size in BrowserSession
- Updated cdp-use dependency to version 1.4.4 for improved functionality.
- Increased max WebSocket frame size to 200MB in BrowserSession to accommodate large DOMs.
2025-11-12 18:00:14 -08:00
Larsen Cundrič 89034d6139 Add http_client to Anthropic Chat (#3574) 2025-11-12 17:59:58 -08:00
LarsenCundric d251105e64 Add http_client to Anthropic Chat 2025-11-12 17:58:38 -08:00
Aitor 535781e535 Merge branch 'main' into feat/improve-navigation 2025-11-13 02:08:38 +01:00
Mert Unsal 8c301878cc docs: add AWS Bedrock configuration to .env.example (#3559)
## Description
Adds AWS Bedrock configuration examples to `.env.example` to help new
users configure AWS Bedrock models.

## Motivation
The codebase currently supports AWS Bedrock through `ChatAWSBedrock` and
`ChatAnthropicBedrock` classes, but the `.env.example` file doesn't
include any AWS Bedrock configuration examples. This makes it difficult
for new users to know which environment variables are needed and how to
configure them.

## Changes
- Added AWS Bedrock configuration section with all required environment
variables:
  - `AWS_ACCESS_KEY_ID`
  - `AWS_SECRET_ACCESS_KEY`
  - `AWS_SESSION_TOKEN` (marked as optional for temporary credentials)
  - `AWS_REGION` (with note about `AWS_DEFAULT_REGION` alternative)
- Included helpful comments about:
  - Installation requirements (`pip install browser-use[aws]`)
  - AWS Bedrock access and permissions requirements
  - When session token is needed

## Testing
- Verified the environment variables match those used in
`browser_use/llm/aws/chat_bedrock.py` and
`browser_use/llm/aws/chat_anthropic.py`
- Confirmed consistency with the example in `examples/models/aws.py`

## Related Files
- Implementation: `browser_use/llm/aws/chat_bedrock.py`
- Implementation: `browser_use/llm/aws/chat_anthropic.py`
- Example usage: `examples/models/aws.py`

## Checklist
- [x] Documentation updated
- [x] Changes are consistent with existing code
- [x] Follows project's formatting conventions


<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Add AWS Bedrock configuration examples to .env.example to simplify setup
for Bedrock models. Includes AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
optional AWS_SESSION_TOKEN, AWS_REGION, plus notes on installing
browser-use[aws] and required Bedrock access/permissions.

<sup>Written for commit d9ff851279.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-11-12 16:45:53 -08:00
reformedot 060ab445a9 refactor: streamline target validation in BrowserSession 2025-11-12 16:44:07 -08:00
reformedot 9c1ce544e6 Merge branch 'feat/improve-navigation' of github.com:browser-use/browser-use into feat/improve-navigation 2025-11-12 16:12:39 -08:00
reformedot 74775cab9a refactor: update target discovery to include iframe types in session management 2025-11-12 16:12:22 -08:00
Magnus Müller 36fa8ac2d1 Perform general action (#3571)
Update OpenAI dependency to version 2.7.2 to use the latest features and
improvements.

---
[Slack
Thread](https://browser-use.slack.com/archives/C091NM0S79T/p1762989054071819?thread_ts=1762989054.071819&cid=C091NM0S79T)

<a
href="https://cursor.com/background-agent?bcId=bc-955dac98-01b2-421f-bcb9-25c3bcd7891e"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-955dac98-01b2-421f-bcb9-25c3bcd7891e"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Bumps `openai` from `>=1.99.2,<2.0.0` to `>=2.7.2,<3.0.0` in
`pyproject.toml`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
eab2376701. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-11-12 15:49:51 -08:00
Aitor 585141afd7 Merge branch 'main' into feat/improve-navigation 2025-11-13 00:41:51 +01:00
reformedot bff596f2e7 refactor: remove target type caching and streamline target retrieval in session management
- Eliminated the caching of target types in SessionManager, simplifying the management of target information.
- Updated various components to directly access target types from the Target objects, enhancing clarity and reducing redundancy.
- Adjusted related methods in BrowserSession, CrashWatchdog, and DomService to reflect the changes in target type retrieval.
2025-11-12 15:19:34 -08:00
Cursor Agent eab2376701 Bump openai dependency to version 2.7.2
Co-authored-by: mamagnus00 <mamagnus00@gmail.com>
2025-11-12 23:14:41 +00:00
Alexander Yue 0e3a007609 Update badge link in README.md (#3569)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Updated the README to make the package download badge clickable, linking
to https://cloud.browser-use.com for easier navigation to Browser-Use
Cloud.

<sup>Written for commit b440cfb13e.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2025-11-12 12:00:02 -08:00
Alexander Yue b440cfb13e Update badge link in README.md 2025-11-12 11:58:08 -08:00
Mert Unsal f7dc23b999 Add ground truth to judge (#3567)
## Summary by cubic
Adds optional ground truth to the judge to validate agent results
against known answers or required criteria. When provided, the judge
prioritizes it and returns false if the ground truth isn’t met.

- **New Features**
- Judge now accepts a ground_truth string and embeds it into system and
user prompts.
  - Ground truth is treated as highest-priority validation.
  - AgentSettings includes ground_truth; service passes it to judge.
- Example updated to demonstrate validation when the provided
ground_truth is wrong.

- **Migration**
  - No breaking changes.
- To use: set ground_truth on Agent or in settings with the expected
answer or criteria.
2025-11-12 11:36:34 -08:00