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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Utility functions for browser tools."""
|
|
2
|
+
|
|
3
|
+
from browser_use.dom.service import EnhancedDOMTreeNode
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_click_description(node: EnhancedDOMTreeNode) -> str:
|
|
7
|
+
"""Get a brief description of the clicked element for memory."""
|
|
8
|
+
parts = []
|
|
9
|
+
|
|
10
|
+
# Tag name
|
|
11
|
+
parts.append(node.tag_name)
|
|
12
|
+
|
|
13
|
+
# Add type for inputs
|
|
14
|
+
if node.tag_name == 'input' and node.attributes.get('type'):
|
|
15
|
+
input_type = node.attributes['type']
|
|
16
|
+
parts.append(f'type={input_type}')
|
|
17
|
+
|
|
18
|
+
# For checkboxes, include checked state
|
|
19
|
+
if input_type == 'checkbox':
|
|
20
|
+
is_checked = node.attributes.get('checked', 'false').lower() in ['true', 'checked', '']
|
|
21
|
+
# Also check AX node
|
|
22
|
+
if node.ax_node and node.ax_node.properties:
|
|
23
|
+
for prop in node.ax_node.properties:
|
|
24
|
+
if prop.name == 'checked':
|
|
25
|
+
is_checked = prop.value is True or prop.value == 'true'
|
|
26
|
+
break
|
|
27
|
+
state = 'checked' if is_checked else 'unchecked'
|
|
28
|
+
parts.append(f'checkbox-state={state}')
|
|
29
|
+
|
|
30
|
+
# Add role if present
|
|
31
|
+
if node.attributes.get('role'):
|
|
32
|
+
role = node.attributes['role']
|
|
33
|
+
parts.append(f'role={role}')
|
|
34
|
+
|
|
35
|
+
# For role=checkbox, include state
|
|
36
|
+
if role == 'checkbox':
|
|
37
|
+
aria_checked = node.attributes.get('aria-checked', 'false').lower()
|
|
38
|
+
is_checked = aria_checked in ['true', 'checked']
|
|
39
|
+
if node.ax_node and node.ax_node.properties:
|
|
40
|
+
for prop in node.ax_node.properties:
|
|
41
|
+
if prop.name == 'checked':
|
|
42
|
+
is_checked = prop.value is True or prop.value == 'true'
|
|
43
|
+
break
|
|
44
|
+
state = 'checked' if is_checked else 'unchecked'
|
|
45
|
+
parts.append(f'checkbox-state={state}')
|
|
46
|
+
|
|
47
|
+
# For labels/spans/divs, check if related to a hidden checkbox
|
|
48
|
+
if node.tag_name in ['label', 'span', 'div'] and 'type=' not in ' '.join(parts):
|
|
49
|
+
# Check children for hidden checkbox
|
|
50
|
+
for child in node.children:
|
|
51
|
+
if child.tag_name == 'input' and child.attributes.get('type') == 'checkbox':
|
|
52
|
+
# Check if hidden
|
|
53
|
+
is_hidden = False
|
|
54
|
+
if child.snapshot_node and child.snapshot_node.computed_styles:
|
|
55
|
+
opacity = child.snapshot_node.computed_styles.get('opacity', '1')
|
|
56
|
+
if opacity == '0' or opacity == '0.0':
|
|
57
|
+
is_hidden = True
|
|
58
|
+
|
|
59
|
+
if is_hidden or not child.is_visible:
|
|
60
|
+
# Get checkbox state
|
|
61
|
+
is_checked = child.attributes.get('checked', 'false').lower() in ['true', 'checked', '']
|
|
62
|
+
if child.ax_node and child.ax_node.properties:
|
|
63
|
+
for prop in child.ax_node.properties:
|
|
64
|
+
if prop.name == 'checked':
|
|
65
|
+
is_checked = prop.value is True or prop.value == 'true'
|
|
66
|
+
break
|
|
67
|
+
state = 'checked' if is_checked else 'unchecked'
|
|
68
|
+
parts.append(f'checkbox-state={state}')
|
|
69
|
+
break
|
|
70
|
+
|
|
71
|
+
# Add short text content if available
|
|
72
|
+
text = node.get_all_children_text().strip()
|
|
73
|
+
if text:
|
|
74
|
+
short_text = text[:30] + ('...' if len(text) > 30 else '')
|
|
75
|
+
parts.append(f'"{short_text}"')
|
|
76
|
+
|
|
77
|
+
# Add key attributes like id, name, aria-label
|
|
78
|
+
for attr in ['id', 'name', 'aria-label']:
|
|
79
|
+
if node.attributes.get(attr):
|
|
80
|
+
parts.append(f'{attr}={node.attributes[attr][:20]}')
|
|
81
|
+
|
|
82
|
+
return ' '.join(parts)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from typing import Generic, TypeVar
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# Action Input Models
|
|
7
|
+
class ExtractAction(BaseModel):
|
|
8
|
+
query: str
|
|
9
|
+
extract_links: bool = Field(
|
|
10
|
+
default=False, description='Set True to true if the query requires links, else false to safe tokens'
|
|
11
|
+
)
|
|
12
|
+
start_from_char: int = Field(
|
|
13
|
+
default=0, description='Use this for long markdowns to start from a specific character (not index in browser_state)'
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SearchAction(BaseModel):
|
|
18
|
+
query: str
|
|
19
|
+
engine: str = Field(
|
|
20
|
+
default='duckduckgo', description='duckduckgo, google, bing (use duckduckgo by default because less captchas)'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Backward compatibility alias
|
|
25
|
+
SearchAction = SearchAction
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class NavigateAction(BaseModel):
|
|
29
|
+
url: str
|
|
30
|
+
new_tab: bool = Field(default=False)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# Backward compatibility alias
|
|
34
|
+
GoToUrlAction = NavigateAction
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ClickElementAction(BaseModel):
|
|
38
|
+
index: int = Field(ge=1, description='from browser_state. All interactive elements work except <select> or file inputs.')
|
|
39
|
+
# expect_download: bool = Field(default=False, description='set True if expecting a download, False otherwise') # moved to downloads_watchdog.py
|
|
40
|
+
# click_count: int = 1 # TODO
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class InputTextAction(BaseModel):
|
|
44
|
+
index: int = Field(ge=0, description='from browser_state')
|
|
45
|
+
text: str
|
|
46
|
+
clear: bool = Field(default=True, description='1=clear, 0=append')
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class DoneAction(BaseModel):
|
|
50
|
+
text: str = Field(description='Final user message in the format the user requested')
|
|
51
|
+
success: bool = Field(default=True, description='True if user_request completed successfully')
|
|
52
|
+
files_to_display: list[str] | None = Field(default=[])
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
T = TypeVar('T', bound=BaseModel)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class StructuredOutputAction(BaseModel, Generic[T]):
|
|
59
|
+
success: bool = Field(default=True, description='True if user_request completed successfully')
|
|
60
|
+
data: T = Field(description='The actual output data matching the requested schema')
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class SwitchTabAction(BaseModel):
|
|
64
|
+
tab_id: str = Field(min_length=4, max_length=4, description='4-char id')
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class CloseTabAction(BaseModel):
|
|
68
|
+
tab_id: str = Field(min_length=4, max_length=4, description='4-char id')
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class ScrollAction(BaseModel):
|
|
72
|
+
down: bool = Field(description='down=True=scroll down, down=False scroll up')
|
|
73
|
+
pages: float = Field(default=1.0, description='0.5=half page, 1=full page, 10=to bottom/top')
|
|
74
|
+
index: int | None = Field(default=None, description='Optional element index to scroll within specific container')
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class SendKeysAction(BaseModel):
|
|
78
|
+
keys: str = Field(description='keys (Escape, Enter, PageDown) or shortcuts (Control+o)')
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class UploadFileAction(BaseModel):
|
|
82
|
+
index: int
|
|
83
|
+
path: str
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class ExtractPageContentAction(BaseModel):
|
|
87
|
+
value: str
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class NoParamsAction(BaseModel):
|
|
91
|
+
model_config = ConfigDict(extra='ignore')
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class GetDropdownOptionsAction(BaseModel):
|
|
95
|
+
index: int
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class SelectDropdownOptionAction(BaseModel):
|
|
99
|
+
index: int
|
|
100
|
+
text: str = Field(description='exact text/value')
|