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,197 @@
|
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
from browser_use.dom.views import SimplifiedNode
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Helper class for maintaining a union of rectangles (used for order of elements calculation)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True, slots=True)
|
|
12
|
+
class Rect:
|
|
13
|
+
"""Closed axis-aligned rectangle with (x1,y1) bottom-left, (x2,y2) top-right."""
|
|
14
|
+
|
|
15
|
+
x1: float
|
|
16
|
+
y1: float
|
|
17
|
+
x2: float
|
|
18
|
+
y2: float
|
|
19
|
+
|
|
20
|
+
def __post_init__(self):
|
|
21
|
+
if not (self.x1 <= self.x2 and self.y1 <= self.y2):
|
|
22
|
+
return False
|
|
23
|
+
|
|
24
|
+
# --- fast relations ----------------------------------------------------
|
|
25
|
+
def area(self) -> float:
|
|
26
|
+
return (self.x2 - self.x1) * (self.y2 - self.y1)
|
|
27
|
+
|
|
28
|
+
def intersects(self, other: 'Rect') -> bool:
|
|
29
|
+
return not (self.x2 <= other.x1 or other.x2 <= self.x1 or self.y2 <= other.y1 or other.y2 <= self.y1)
|
|
30
|
+
|
|
31
|
+
def contains(self, other: 'Rect') -> bool:
|
|
32
|
+
return self.x1 <= other.x1 and self.y1 <= other.y1 and self.x2 >= other.x2 and self.y2 >= other.y2
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class RectUnionPure:
|
|
36
|
+
"""
|
|
37
|
+
Maintains a *disjoint* set of rectangles.
|
|
38
|
+
No external dependencies - fine for a few thousand rectangles.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
__slots__ = ('_rects',)
|
|
42
|
+
|
|
43
|
+
def __init__(self):
|
|
44
|
+
self._rects: list[Rect] = []
|
|
45
|
+
|
|
46
|
+
# -----------------------------------------------------------------
|
|
47
|
+
def _split_diff(self, a: Rect, b: Rect) -> list[Rect]:
|
|
48
|
+
r"""
|
|
49
|
+
Return list of up to 4 rectangles = a \ b.
|
|
50
|
+
Assumes a intersects b.
|
|
51
|
+
"""
|
|
52
|
+
parts = []
|
|
53
|
+
|
|
54
|
+
# Bottom slice
|
|
55
|
+
if a.y1 < b.y1:
|
|
56
|
+
parts.append(Rect(a.x1, a.y1, a.x2, b.y1))
|
|
57
|
+
# Top slice
|
|
58
|
+
if b.y2 < a.y2:
|
|
59
|
+
parts.append(Rect(a.x1, b.y2, a.x2, a.y2))
|
|
60
|
+
|
|
61
|
+
# Middle (vertical) strip: y overlap is [max(a.y1,b.y1), min(a.y2,b.y2)]
|
|
62
|
+
y_lo = max(a.y1, b.y1)
|
|
63
|
+
y_hi = min(a.y2, b.y2)
|
|
64
|
+
|
|
65
|
+
# Left slice
|
|
66
|
+
if a.x1 < b.x1:
|
|
67
|
+
parts.append(Rect(a.x1, y_lo, b.x1, y_hi))
|
|
68
|
+
# Right slice
|
|
69
|
+
if b.x2 < a.x2:
|
|
70
|
+
parts.append(Rect(b.x2, y_lo, a.x2, y_hi))
|
|
71
|
+
|
|
72
|
+
return parts
|
|
73
|
+
|
|
74
|
+
# -----------------------------------------------------------------
|
|
75
|
+
def contains(self, r: Rect) -> bool:
|
|
76
|
+
"""
|
|
77
|
+
True iff r is fully covered by the current union.
|
|
78
|
+
"""
|
|
79
|
+
if not self._rects:
|
|
80
|
+
return False
|
|
81
|
+
|
|
82
|
+
stack = [r]
|
|
83
|
+
for s in self._rects:
|
|
84
|
+
new_stack = []
|
|
85
|
+
for piece in stack:
|
|
86
|
+
if s.contains(piece):
|
|
87
|
+
# piece completely gone
|
|
88
|
+
continue
|
|
89
|
+
if piece.intersects(s):
|
|
90
|
+
new_stack.extend(self._split_diff(piece, s))
|
|
91
|
+
else:
|
|
92
|
+
new_stack.append(piece)
|
|
93
|
+
if not new_stack: # everything eaten – covered
|
|
94
|
+
return True
|
|
95
|
+
stack = new_stack
|
|
96
|
+
return False # something survived
|
|
97
|
+
|
|
98
|
+
# -----------------------------------------------------------------
|
|
99
|
+
def add(self, r: Rect) -> bool:
|
|
100
|
+
"""
|
|
101
|
+
Insert r unless it is already covered.
|
|
102
|
+
Returns True if the union grew.
|
|
103
|
+
"""
|
|
104
|
+
if self.contains(r):
|
|
105
|
+
return False
|
|
106
|
+
|
|
107
|
+
pending = [r]
|
|
108
|
+
i = 0
|
|
109
|
+
while i < len(self._rects):
|
|
110
|
+
s = self._rects[i]
|
|
111
|
+
new_pending = []
|
|
112
|
+
changed = False
|
|
113
|
+
for piece in pending:
|
|
114
|
+
if piece.intersects(s):
|
|
115
|
+
new_pending.extend(self._split_diff(piece, s))
|
|
116
|
+
changed = True
|
|
117
|
+
else:
|
|
118
|
+
new_pending.append(piece)
|
|
119
|
+
pending = new_pending
|
|
120
|
+
if changed:
|
|
121
|
+
# s unchanged; proceed with next existing rectangle
|
|
122
|
+
i += 1
|
|
123
|
+
else:
|
|
124
|
+
i += 1
|
|
125
|
+
|
|
126
|
+
# Any left‑over pieces are new, non‑overlapping areas
|
|
127
|
+
self._rects.extend(pending)
|
|
128
|
+
return True
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class PaintOrderRemover:
|
|
132
|
+
"""
|
|
133
|
+
Calculates which elements should be removed based on the paint order parameter.
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
def __init__(self, root: SimplifiedNode):
|
|
137
|
+
self.root = root
|
|
138
|
+
|
|
139
|
+
def calculate_paint_order(self) -> None:
|
|
140
|
+
all_simplified_nodes_with_paint_order: list[SimplifiedNode] = []
|
|
141
|
+
|
|
142
|
+
def collect_paint_order(node: SimplifiedNode) -> None:
|
|
143
|
+
if (
|
|
144
|
+
node.original_node.snapshot_node
|
|
145
|
+
and node.original_node.snapshot_node.paint_order is not None
|
|
146
|
+
and node.original_node.snapshot_node.bounds is not None
|
|
147
|
+
):
|
|
148
|
+
all_simplified_nodes_with_paint_order.append(node)
|
|
149
|
+
|
|
150
|
+
for child in node.children:
|
|
151
|
+
collect_paint_order(child)
|
|
152
|
+
|
|
153
|
+
collect_paint_order(self.root)
|
|
154
|
+
|
|
155
|
+
grouped_by_paint_order: defaultdict[int, list[SimplifiedNode]] = defaultdict(list)
|
|
156
|
+
|
|
157
|
+
for node in all_simplified_nodes_with_paint_order:
|
|
158
|
+
if node.original_node.snapshot_node and node.original_node.snapshot_node.paint_order is not None:
|
|
159
|
+
grouped_by_paint_order[node.original_node.snapshot_node.paint_order].append(node)
|
|
160
|
+
|
|
161
|
+
rect_union = RectUnionPure()
|
|
162
|
+
|
|
163
|
+
for paint_order, nodes in sorted(grouped_by_paint_order.items(), key=lambda x: -x[0]):
|
|
164
|
+
rects_to_add = []
|
|
165
|
+
|
|
166
|
+
for node in nodes:
|
|
167
|
+
if not node.original_node.snapshot_node or not node.original_node.snapshot_node.bounds:
|
|
168
|
+
continue # shouldn't happen by how we filter them out in the first place
|
|
169
|
+
|
|
170
|
+
rect = Rect(
|
|
171
|
+
x1=node.original_node.snapshot_node.bounds.x,
|
|
172
|
+
y1=node.original_node.snapshot_node.bounds.y,
|
|
173
|
+
x2=node.original_node.snapshot_node.bounds.x + node.original_node.snapshot_node.bounds.width,
|
|
174
|
+
y2=node.original_node.snapshot_node.bounds.y + node.original_node.snapshot_node.bounds.height,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
if rect_union.contains(rect):
|
|
178
|
+
node.ignored_by_paint_order = True
|
|
179
|
+
|
|
180
|
+
# don't add to the nodes if opacity is less then 0.95 or background-color is transparent
|
|
181
|
+
if (
|
|
182
|
+
node.original_node.snapshot_node.computed_styles
|
|
183
|
+
and node.original_node.snapshot_node.computed_styles.get('background-color', 'rgba(0, 0, 0, 0)')
|
|
184
|
+
== 'rgba(0, 0, 0, 0)'
|
|
185
|
+
) or (
|
|
186
|
+
node.original_node.snapshot_node.computed_styles
|
|
187
|
+
and float(node.original_node.snapshot_node.computed_styles.get('opacity', '1'))
|
|
188
|
+
< 0.8 # this is highly vibes based number
|
|
189
|
+
):
|
|
190
|
+
continue
|
|
191
|
+
|
|
192
|
+
rects_to_add.append(rect)
|
|
193
|
+
|
|
194
|
+
for rect in rects_to_add:
|
|
195
|
+
rect_union.add(rect)
|
|
196
|
+
|
|
197
|
+
return None
|