optexity-browser-use 0.9.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- browser_use/__init__.py +157 -0
- browser_use/actor/__init__.py +11 -0
- browser_use/actor/element.py +1175 -0
- browser_use/actor/mouse.py +134 -0
- browser_use/actor/page.py +561 -0
- browser_use/actor/playground/flights.py +41 -0
- browser_use/actor/playground/mixed_automation.py +54 -0
- browser_use/actor/playground/playground.py +236 -0
- browser_use/actor/utils.py +176 -0
- browser_use/agent/cloud_events.py +282 -0
- browser_use/agent/gif.py +424 -0
- browser_use/agent/judge.py +170 -0
- browser_use/agent/message_manager/service.py +473 -0
- browser_use/agent/message_manager/utils.py +52 -0
- browser_use/agent/message_manager/views.py +98 -0
- browser_use/agent/prompts.py +413 -0
- browser_use/agent/service.py +2316 -0
- browser_use/agent/system_prompt.md +185 -0
- browser_use/agent/system_prompt_flash.md +10 -0
- browser_use/agent/system_prompt_no_thinking.md +183 -0
- browser_use/agent/views.py +743 -0
- browser_use/browser/__init__.py +41 -0
- browser_use/browser/cloud/cloud.py +203 -0
- browser_use/browser/cloud/views.py +89 -0
- browser_use/browser/events.py +578 -0
- browser_use/browser/profile.py +1158 -0
- browser_use/browser/python_highlights.py +548 -0
- browser_use/browser/session.py +3225 -0
- browser_use/browser/session_manager.py +399 -0
- browser_use/browser/video_recorder.py +162 -0
- browser_use/browser/views.py +200 -0
- browser_use/browser/watchdog_base.py +260 -0
- browser_use/browser/watchdogs/__init__.py +0 -0
- browser_use/browser/watchdogs/aboutblank_watchdog.py +253 -0
- browser_use/browser/watchdogs/crash_watchdog.py +335 -0
- browser_use/browser/watchdogs/default_action_watchdog.py +2729 -0
- browser_use/browser/watchdogs/dom_watchdog.py +817 -0
- browser_use/browser/watchdogs/downloads_watchdog.py +1277 -0
- browser_use/browser/watchdogs/local_browser_watchdog.py +461 -0
- browser_use/browser/watchdogs/permissions_watchdog.py +43 -0
- browser_use/browser/watchdogs/popups_watchdog.py +143 -0
- browser_use/browser/watchdogs/recording_watchdog.py +126 -0
- browser_use/browser/watchdogs/screenshot_watchdog.py +62 -0
- browser_use/browser/watchdogs/security_watchdog.py +280 -0
- browser_use/browser/watchdogs/storage_state_watchdog.py +335 -0
- browser_use/cli.py +2359 -0
- browser_use/code_use/__init__.py +16 -0
- browser_use/code_use/formatting.py +192 -0
- browser_use/code_use/namespace.py +665 -0
- browser_use/code_use/notebook_export.py +276 -0
- browser_use/code_use/service.py +1340 -0
- browser_use/code_use/system_prompt.md +574 -0
- browser_use/code_use/utils.py +150 -0
- browser_use/code_use/views.py +171 -0
- browser_use/config.py +505 -0
- browser_use/controller/__init__.py +3 -0
- browser_use/dom/enhanced_snapshot.py +161 -0
- browser_use/dom/markdown_extractor.py +169 -0
- browser_use/dom/playground/extraction.py +312 -0
- browser_use/dom/playground/multi_act.py +32 -0
- browser_use/dom/serializer/clickable_elements.py +200 -0
- browser_use/dom/serializer/code_use_serializer.py +287 -0
- browser_use/dom/serializer/eval_serializer.py +478 -0
- browser_use/dom/serializer/html_serializer.py +212 -0
- browser_use/dom/serializer/paint_order.py +197 -0
- browser_use/dom/serializer/serializer.py +1170 -0
- browser_use/dom/service.py +825 -0
- browser_use/dom/utils.py +129 -0
- browser_use/dom/views.py +906 -0
- browser_use/exceptions.py +5 -0
- browser_use/filesystem/__init__.py +0 -0
- browser_use/filesystem/file_system.py +619 -0
- browser_use/init_cmd.py +376 -0
- browser_use/integrations/gmail/__init__.py +24 -0
- browser_use/integrations/gmail/actions.py +115 -0
- browser_use/integrations/gmail/service.py +225 -0
- browser_use/llm/__init__.py +155 -0
- browser_use/llm/anthropic/chat.py +242 -0
- browser_use/llm/anthropic/serializer.py +312 -0
- browser_use/llm/aws/__init__.py +36 -0
- browser_use/llm/aws/chat_anthropic.py +242 -0
- browser_use/llm/aws/chat_bedrock.py +289 -0
- browser_use/llm/aws/serializer.py +257 -0
- browser_use/llm/azure/chat.py +91 -0
- browser_use/llm/base.py +57 -0
- browser_use/llm/browser_use/__init__.py +3 -0
- browser_use/llm/browser_use/chat.py +201 -0
- browser_use/llm/cerebras/chat.py +193 -0
- browser_use/llm/cerebras/serializer.py +109 -0
- browser_use/llm/deepseek/chat.py +212 -0
- browser_use/llm/deepseek/serializer.py +109 -0
- browser_use/llm/exceptions.py +29 -0
- browser_use/llm/google/__init__.py +3 -0
- browser_use/llm/google/chat.py +542 -0
- browser_use/llm/google/serializer.py +120 -0
- browser_use/llm/groq/chat.py +229 -0
- browser_use/llm/groq/parser.py +158 -0
- browser_use/llm/groq/serializer.py +159 -0
- browser_use/llm/messages.py +238 -0
- browser_use/llm/models.py +271 -0
- browser_use/llm/oci_raw/__init__.py +10 -0
- browser_use/llm/oci_raw/chat.py +443 -0
- browser_use/llm/oci_raw/serializer.py +229 -0
- browser_use/llm/ollama/chat.py +97 -0
- browser_use/llm/ollama/serializer.py +143 -0
- browser_use/llm/openai/chat.py +264 -0
- browser_use/llm/openai/like.py +15 -0
- browser_use/llm/openai/serializer.py +165 -0
- browser_use/llm/openrouter/chat.py +211 -0
- browser_use/llm/openrouter/serializer.py +26 -0
- browser_use/llm/schema.py +176 -0
- browser_use/llm/views.py +48 -0
- browser_use/logging_config.py +330 -0
- browser_use/mcp/__init__.py +18 -0
- browser_use/mcp/__main__.py +12 -0
- browser_use/mcp/client.py +544 -0
- browser_use/mcp/controller.py +264 -0
- browser_use/mcp/server.py +1114 -0
- browser_use/observability.py +204 -0
- browser_use/py.typed +0 -0
- browser_use/sandbox/__init__.py +41 -0
- browser_use/sandbox/sandbox.py +637 -0
- browser_use/sandbox/views.py +132 -0
- browser_use/screenshots/__init__.py +1 -0
- browser_use/screenshots/service.py +52 -0
- browser_use/sync/__init__.py +6 -0
- browser_use/sync/auth.py +357 -0
- browser_use/sync/service.py +161 -0
- browser_use/telemetry/__init__.py +51 -0
- browser_use/telemetry/service.py +112 -0
- browser_use/telemetry/views.py +101 -0
- browser_use/tokens/__init__.py +0 -0
- browser_use/tokens/custom_pricing.py +24 -0
- browser_use/tokens/mappings.py +4 -0
- browser_use/tokens/service.py +580 -0
- browser_use/tokens/views.py +108 -0
- browser_use/tools/registry/service.py +572 -0
- browser_use/tools/registry/views.py +174 -0
- browser_use/tools/service.py +1675 -0
- browser_use/tools/utils.py +82 -0
- browser_use/tools/views.py +100 -0
- browser_use/utils.py +670 -0
- optexity_browser_use-0.9.5.dist-info/METADATA +344 -0
- optexity_browser_use-0.9.5.dist-info/RECORD +147 -0
- optexity_browser_use-0.9.5.dist-info/WHEEL +4 -0
- optexity_browser_use-0.9.5.dist-info/entry_points.txt +3 -0
- optexity_browser_use-0.9.5.dist-info/licenses/LICENSE +21 -0
browser_use/__init__.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
from browser_use.logging_config import setup_logging
|
|
5
|
+
|
|
6
|
+
# Only set up logging if not in MCP mode or if explicitly requested
|
|
7
|
+
if os.environ.get('BROWSER_USE_SETUP_LOGGING', 'true').lower() != 'false':
|
|
8
|
+
from browser_use.config import CONFIG
|
|
9
|
+
|
|
10
|
+
# Get log file paths from config/environment
|
|
11
|
+
debug_log_file = getattr(CONFIG, 'BROWSER_USE_DEBUG_LOG_FILE', None)
|
|
12
|
+
info_log_file = getattr(CONFIG, 'BROWSER_USE_INFO_LOG_FILE', None)
|
|
13
|
+
|
|
14
|
+
# Set up logging with file handlers if specified
|
|
15
|
+
logger = setup_logging(debug_log_file=debug_log_file, info_log_file=info_log_file)
|
|
16
|
+
else:
|
|
17
|
+
import logging
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger('browser_use')
|
|
20
|
+
|
|
21
|
+
# Monkeypatch BaseSubprocessTransport.__del__ to handle closed event loops gracefully
|
|
22
|
+
from asyncio import base_subprocess
|
|
23
|
+
|
|
24
|
+
_original_del = base_subprocess.BaseSubprocessTransport.__del__
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _patched_del(self):
|
|
28
|
+
"""Patched __del__ that handles closed event loops without throwing noisy red-herring errors like RuntimeError: Event loop is closed"""
|
|
29
|
+
try:
|
|
30
|
+
# Check if the event loop is closed before calling the original
|
|
31
|
+
if hasattr(self, '_loop') and self._loop and self._loop.is_closed():
|
|
32
|
+
# Event loop is closed, skip cleanup that requires the loop
|
|
33
|
+
return
|
|
34
|
+
_original_del(self)
|
|
35
|
+
except RuntimeError as e:
|
|
36
|
+
if 'Event loop is closed' in str(e):
|
|
37
|
+
# Silently ignore this specific error
|
|
38
|
+
pass
|
|
39
|
+
else:
|
|
40
|
+
raise
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
base_subprocess.BaseSubprocessTransport.__del__ = _patched_del
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Type stubs for lazy imports - fixes linter warnings
|
|
47
|
+
if TYPE_CHECKING:
|
|
48
|
+
from browser_use.agent.prompts import SystemPrompt
|
|
49
|
+
from browser_use.agent.service import Agent
|
|
50
|
+
|
|
51
|
+
# from browser_use.agent.service import Agent
|
|
52
|
+
from browser_use.agent.views import ActionModel, ActionResult, AgentHistoryList
|
|
53
|
+
from browser_use.browser import BrowserProfile, BrowserSession
|
|
54
|
+
from browser_use.browser import BrowserSession as Browser
|
|
55
|
+
from browser_use.code_use.service import CodeAgent
|
|
56
|
+
from browser_use.dom.service import DomService
|
|
57
|
+
from browser_use.llm import models
|
|
58
|
+
from browser_use.llm.anthropic.chat import ChatAnthropic
|
|
59
|
+
from browser_use.llm.azure.chat import ChatAzureOpenAI
|
|
60
|
+
from browser_use.llm.browser_use.chat import ChatBrowserUse
|
|
61
|
+
from browser_use.llm.google.chat import ChatGoogle
|
|
62
|
+
from browser_use.llm.groq.chat import ChatGroq
|
|
63
|
+
from browser_use.llm.oci_raw.chat import ChatOCIRaw
|
|
64
|
+
from browser_use.llm.ollama.chat import ChatOllama
|
|
65
|
+
from browser_use.llm.openai.chat import ChatOpenAI
|
|
66
|
+
from browser_use.sandbox import sandbox
|
|
67
|
+
from browser_use.tools.service import Controller, Tools
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# Lazy imports mapping - only import when actually accessed
|
|
71
|
+
_LAZY_IMPORTS = {
|
|
72
|
+
# Agent service (heavy due to dependencies)
|
|
73
|
+
# 'Agent': ('browser_use.agent.service', 'Agent'),
|
|
74
|
+
# Code-use agent (Jupyter notebook-like execution)
|
|
75
|
+
'CodeAgent': ('browser_use.code_use.service', 'CodeAgent'),
|
|
76
|
+
'Agent': ('browser_use.agent.service', 'Agent'),
|
|
77
|
+
# System prompt (moderate weight due to agent.views imports)
|
|
78
|
+
'SystemPrompt': ('browser_use.agent.prompts', 'SystemPrompt'),
|
|
79
|
+
# Agent views (very heavy - over 1 second!)
|
|
80
|
+
'ActionModel': ('browser_use.agent.views', 'ActionModel'),
|
|
81
|
+
'ActionResult': ('browser_use.agent.views', 'ActionResult'),
|
|
82
|
+
'AgentHistoryList': ('browser_use.agent.views', 'AgentHistoryList'),
|
|
83
|
+
'BrowserSession': ('browser_use.browser', 'BrowserSession'),
|
|
84
|
+
'Browser': ('browser_use.browser', 'BrowserSession'), # Alias for BrowserSession
|
|
85
|
+
'BrowserProfile': ('browser_use.browser', 'BrowserProfile'),
|
|
86
|
+
# Tools (moderate weight)
|
|
87
|
+
'Tools': ('browser_use.tools.service', 'Tools'),
|
|
88
|
+
'Controller': ('browser_use.tools.service', 'Controller'), # alias
|
|
89
|
+
# DOM service (moderate weight)
|
|
90
|
+
'DomService': ('browser_use.dom.service', 'DomService'),
|
|
91
|
+
# Chat models (very heavy imports)
|
|
92
|
+
'ChatOpenAI': ('browser_use.llm.openai.chat', 'ChatOpenAI'),
|
|
93
|
+
'ChatGoogle': ('browser_use.llm.google.chat', 'ChatGoogle'),
|
|
94
|
+
'ChatAnthropic': ('browser_use.llm.anthropic.chat', 'ChatAnthropic'),
|
|
95
|
+
'ChatBrowserUse': ('browser_use.llm.browser_use.chat', 'ChatBrowserUse'),
|
|
96
|
+
'ChatGroq': ('browser_use.llm.groq.chat', 'ChatGroq'),
|
|
97
|
+
'ChatAzureOpenAI': ('browser_use.llm.azure.chat', 'ChatAzureOpenAI'),
|
|
98
|
+
'ChatOCIRaw': ('browser_use.llm.oci_raw.chat', 'ChatOCIRaw'),
|
|
99
|
+
'ChatOllama': ('browser_use.llm.ollama.chat', 'ChatOllama'),
|
|
100
|
+
# LLM models module
|
|
101
|
+
'models': ('browser_use.llm.models', None),
|
|
102
|
+
# Sandbox execution
|
|
103
|
+
'sandbox': ('browser_use.sandbox', 'sandbox'),
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def __getattr__(name: str):
|
|
108
|
+
"""Lazy import mechanism - only import modules when they're actually accessed."""
|
|
109
|
+
if name in _LAZY_IMPORTS:
|
|
110
|
+
module_path, attr_name = _LAZY_IMPORTS[name]
|
|
111
|
+
try:
|
|
112
|
+
from importlib import import_module
|
|
113
|
+
|
|
114
|
+
module = import_module(module_path)
|
|
115
|
+
if attr_name is None:
|
|
116
|
+
# For modules like 'models', return the module itself
|
|
117
|
+
attr = module
|
|
118
|
+
else:
|
|
119
|
+
attr = getattr(module, attr_name)
|
|
120
|
+
# Cache the imported attribute in the module's globals
|
|
121
|
+
globals()[name] = attr
|
|
122
|
+
return attr
|
|
123
|
+
except ImportError as e:
|
|
124
|
+
raise ImportError(f'Failed to import {name} from {module_path}: {e}') from e
|
|
125
|
+
|
|
126
|
+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
__all__ = [
|
|
130
|
+
'Agent',
|
|
131
|
+
'CodeAgent',
|
|
132
|
+
# 'CodeAgent',
|
|
133
|
+
'BrowserSession',
|
|
134
|
+
'Browser', # Alias for BrowserSession
|
|
135
|
+
'BrowserProfile',
|
|
136
|
+
'Controller',
|
|
137
|
+
'DomService',
|
|
138
|
+
'SystemPrompt',
|
|
139
|
+
'ActionResult',
|
|
140
|
+
'ActionModel',
|
|
141
|
+
'AgentHistoryList',
|
|
142
|
+
# Chat models
|
|
143
|
+
'ChatOpenAI',
|
|
144
|
+
'ChatGoogle',
|
|
145
|
+
'ChatAnthropic',
|
|
146
|
+
'ChatBrowserUse',
|
|
147
|
+
'ChatGroq',
|
|
148
|
+
'ChatAzureOpenAI',
|
|
149
|
+
'ChatOCIRaw',
|
|
150
|
+
'ChatOllama',
|
|
151
|
+
'Tools',
|
|
152
|
+
'Controller',
|
|
153
|
+
# LLM models module
|
|
154
|
+
'models',
|
|
155
|
+
# Sandbox execution
|
|
156
|
+
'sandbox',
|
|
157
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""CDP-Use High-Level Library
|
|
2
|
+
|
|
3
|
+
A Playwright-like library built on top of CDP (Chrome DevTools Protocol).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .element import Element
|
|
7
|
+
from .mouse import Mouse
|
|
8
|
+
from .page import Page
|
|
9
|
+
from .utils import Utils
|
|
10
|
+
|
|
11
|
+
__all__ = ['Page', 'Element', 'Mouse', 'Utils']
|