Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
remove old unused playwright types
Nick Sweeting86fb44389591
diff --git a/browser_use/__init__.py b/browser_use/__init__.pyindex 0c079efe7..848e4f8e9 100644--- a/browser_use/__init__.py+++ b/browser_use/__init__.py@@ -41,7 +41,7 @@ if TYPE_CHECKING:from browser_use.agent.prompts import SystemPromptfrom browser_use.agent.service import Agentfrom browser_use.agent.views import ActionModel, ActionResult, AgentHistoryList- from browser_use.browser import Browser, BrowserConfig, BrowserContext, BrowserContextConfig, BrowserProfile, BrowserSession+ from browser_use.browser import BrowserProfile, BrowserSessionfrom browser_use.controller.service import Controllerfrom browser_use.dom.service import DomServicefrom browser_use.llm.anthropic.chat import ChatAnthropic@@ -63,12 +63,8 @@ _LAZY_IMPORTS = {'ActionResult': ('browser_use.agent.views', 'ActionResult'),'AgentHistoryList': ('browser_use.agent.views', 'AgentHistoryList'),# Browser components (heavy due to playwright/patchright)- 'Browser': ('browser_use.browser', 'Browser'),- 'BrowserConfig': ('browser_use.browser', 'BrowserConfig'),'BrowserSession': ('browser_use.browser', 'BrowserSession'),'BrowserProfile': ('browser_use.browser', 'BrowserProfile'),- 'BrowserContext': ('browser_use.browser', 'BrowserContext'),- 'BrowserContextConfig': ('browser_use.browser', 'BrowserContextConfig'),# Controller (moderate weight)'Controller': ('browser_use.controller.service', 'Controller'),# DOM service (moderate weight)@@ -103,8 +99,6 @@ def __getattr__(name: str):__all__ = ['Agent',- 'Browser',- 'BrowserConfig','BrowserSession','BrowserProfile','Controller',@@ -113,8 +107,6 @@ __all__ = ['ActionResult','ActionModel','AgentHistoryList',- 'BrowserContext',- 'BrowserContextConfig',# Chat models'ChatOpenAI','ChatGoogle',diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 23441ecec..27a2d084c 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -55,7 +55,6 @@ from browser_use.agent.views import ()from browser_use.browser import BrowserProfile, BrowserSessionfrom browser_use.browser.session import DEFAULT_BROWSER_PROFILE-from browser_use.browser.types import Browser, BrowserContext, Pagefrom browser_use.browser.views import BrowserStateSummaryfrom browser_use.config import CONFIGfrom browser_use.controller.registry.views import ActionModel@@ -127,9 +126,6 @@ class Agent(Generic[Context, AgentStructuredOutput]):task: str,llm: BaseChatModel,# Optional parameters- page: Page | None = None,- browser: Browser | BrowserSession | None = None,- browser_context: BrowserContext | None = None,browser_profile: BrowserProfile | None = None,browser_session: BrowserSession | None = None,controller: Controller[Context] | None = None,@@ -353,29 +349,12 @@ class Agent(Generic[Context, AgentStructuredOutput]):include_recent_events=self.include_recent_events,)- if isinstance(browser, BrowserSession):- browser_session = browser_session or browser-- browser_context = page.context if page else browser_context- # assert not (browser_session and browser_profile), 'Cannot provide both browser_session and browser_profile'- # assert not (browser_session and browser), 'Cannot provide both browser_session and browser'- # assert not (browser_profile and browser), 'Cannot provide both browser_profile and browser'- # assert not (browser_profile and browser_context), 'Cannot provide both browser_profile and browser_context'- # assert not (browser and browser_context), 'Cannot provide both browser and browser_context'- # assert not (browser_session and browser_context), 'Cannot provide both browser_session and browser_context'browser_profile = browser_profile or DEFAULT_BROWSER_PROFILE- if browser_session:- # Use the browser session directly without copying- # This ensures the CDP client and watchdogs are properly accessible- self.browser_session = browser_session- else:- if browser is not None:- assert isinstance(browser, Browser), 'Browser is not set up'- self.browser_session = BrowserSession(- browser_profile=browser_profile,- id=uuid7str()[:-4] + self.id[-4:], # re-use the same 4-char suffix so they show up together in logs- )+ self.browser_session = browser_session or BrowserSession(+ browser_profile=browser_profile,+ id=uuid7str()[:-4] + self.id[-4:], # re-use the same 4-char suffix so they show up together in logs+ )if self.sensitive_data:# Check if sensitive_data has domain-specific credentials