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.
Files changed (147) hide show
  1. browser_use/__init__.py +157 -0
  2. browser_use/actor/__init__.py +11 -0
  3. browser_use/actor/element.py +1175 -0
  4. browser_use/actor/mouse.py +134 -0
  5. browser_use/actor/page.py +561 -0
  6. browser_use/actor/playground/flights.py +41 -0
  7. browser_use/actor/playground/mixed_automation.py +54 -0
  8. browser_use/actor/playground/playground.py +236 -0
  9. browser_use/actor/utils.py +176 -0
  10. browser_use/agent/cloud_events.py +282 -0
  11. browser_use/agent/gif.py +424 -0
  12. browser_use/agent/judge.py +170 -0
  13. browser_use/agent/message_manager/service.py +473 -0
  14. browser_use/agent/message_manager/utils.py +52 -0
  15. browser_use/agent/message_manager/views.py +98 -0
  16. browser_use/agent/prompts.py +413 -0
  17. browser_use/agent/service.py +2316 -0
  18. browser_use/agent/system_prompt.md +185 -0
  19. browser_use/agent/system_prompt_flash.md +10 -0
  20. browser_use/agent/system_prompt_no_thinking.md +183 -0
  21. browser_use/agent/views.py +743 -0
  22. browser_use/browser/__init__.py +41 -0
  23. browser_use/browser/cloud/cloud.py +203 -0
  24. browser_use/browser/cloud/views.py +89 -0
  25. browser_use/browser/events.py +578 -0
  26. browser_use/browser/profile.py +1158 -0
  27. browser_use/browser/python_highlights.py +548 -0
  28. browser_use/browser/session.py +3225 -0
  29. browser_use/browser/session_manager.py +399 -0
  30. browser_use/browser/video_recorder.py +162 -0
  31. browser_use/browser/views.py +200 -0
  32. browser_use/browser/watchdog_base.py +260 -0
  33. browser_use/browser/watchdogs/__init__.py +0 -0
  34. browser_use/browser/watchdogs/aboutblank_watchdog.py +253 -0
  35. browser_use/browser/watchdogs/crash_watchdog.py +335 -0
  36. browser_use/browser/watchdogs/default_action_watchdog.py +2729 -0
  37. browser_use/browser/watchdogs/dom_watchdog.py +817 -0
  38. browser_use/browser/watchdogs/downloads_watchdog.py +1277 -0
  39. browser_use/browser/watchdogs/local_browser_watchdog.py +461 -0
  40. browser_use/browser/watchdogs/permissions_watchdog.py +43 -0
  41. browser_use/browser/watchdogs/popups_watchdog.py +143 -0
  42. browser_use/browser/watchdogs/recording_watchdog.py +126 -0
  43. browser_use/browser/watchdogs/screenshot_watchdog.py +62 -0
  44. browser_use/browser/watchdogs/security_watchdog.py +280 -0
  45. browser_use/browser/watchdogs/storage_state_watchdog.py +335 -0
  46. browser_use/cli.py +2359 -0
  47. browser_use/code_use/__init__.py +16 -0
  48. browser_use/code_use/formatting.py +192 -0
  49. browser_use/code_use/namespace.py +665 -0
  50. browser_use/code_use/notebook_export.py +276 -0
  51. browser_use/code_use/service.py +1340 -0
  52. browser_use/code_use/system_prompt.md +574 -0
  53. browser_use/code_use/utils.py +150 -0
  54. browser_use/code_use/views.py +171 -0
  55. browser_use/config.py +505 -0
  56. browser_use/controller/__init__.py +3 -0
  57. browser_use/dom/enhanced_snapshot.py +161 -0
  58. browser_use/dom/markdown_extractor.py +169 -0
  59. browser_use/dom/playground/extraction.py +312 -0
  60. browser_use/dom/playground/multi_act.py +32 -0
  61. browser_use/dom/serializer/clickable_elements.py +200 -0
  62. browser_use/dom/serializer/code_use_serializer.py +287 -0
  63. browser_use/dom/serializer/eval_serializer.py +478 -0
  64. browser_use/dom/serializer/html_serializer.py +212 -0
  65. browser_use/dom/serializer/paint_order.py +197 -0
  66. browser_use/dom/serializer/serializer.py +1170 -0
  67. browser_use/dom/service.py +825 -0
  68. browser_use/dom/utils.py +129 -0
  69. browser_use/dom/views.py +906 -0
  70. browser_use/exceptions.py +5 -0
  71. browser_use/filesystem/__init__.py +0 -0
  72. browser_use/filesystem/file_system.py +619 -0
  73. browser_use/init_cmd.py +376 -0
  74. browser_use/integrations/gmail/__init__.py +24 -0
  75. browser_use/integrations/gmail/actions.py +115 -0
  76. browser_use/integrations/gmail/service.py +225 -0
  77. browser_use/llm/__init__.py +155 -0
  78. browser_use/llm/anthropic/chat.py +242 -0
  79. browser_use/llm/anthropic/serializer.py +312 -0
  80. browser_use/llm/aws/__init__.py +36 -0
  81. browser_use/llm/aws/chat_anthropic.py +242 -0
  82. browser_use/llm/aws/chat_bedrock.py +289 -0
  83. browser_use/llm/aws/serializer.py +257 -0
  84. browser_use/llm/azure/chat.py +91 -0
  85. browser_use/llm/base.py +57 -0
  86. browser_use/llm/browser_use/__init__.py +3 -0
  87. browser_use/llm/browser_use/chat.py +201 -0
  88. browser_use/llm/cerebras/chat.py +193 -0
  89. browser_use/llm/cerebras/serializer.py +109 -0
  90. browser_use/llm/deepseek/chat.py +212 -0
  91. browser_use/llm/deepseek/serializer.py +109 -0
  92. browser_use/llm/exceptions.py +29 -0
  93. browser_use/llm/google/__init__.py +3 -0
  94. browser_use/llm/google/chat.py +542 -0
  95. browser_use/llm/google/serializer.py +120 -0
  96. browser_use/llm/groq/chat.py +229 -0
  97. browser_use/llm/groq/parser.py +158 -0
  98. browser_use/llm/groq/serializer.py +159 -0
  99. browser_use/llm/messages.py +238 -0
  100. browser_use/llm/models.py +271 -0
  101. browser_use/llm/oci_raw/__init__.py +10 -0
  102. browser_use/llm/oci_raw/chat.py +443 -0
  103. browser_use/llm/oci_raw/serializer.py +229 -0
  104. browser_use/llm/ollama/chat.py +97 -0
  105. browser_use/llm/ollama/serializer.py +143 -0
  106. browser_use/llm/openai/chat.py +264 -0
  107. browser_use/llm/openai/like.py +15 -0
  108. browser_use/llm/openai/serializer.py +165 -0
  109. browser_use/llm/openrouter/chat.py +211 -0
  110. browser_use/llm/openrouter/serializer.py +26 -0
  111. browser_use/llm/schema.py +176 -0
  112. browser_use/llm/views.py +48 -0
  113. browser_use/logging_config.py +330 -0
  114. browser_use/mcp/__init__.py +18 -0
  115. browser_use/mcp/__main__.py +12 -0
  116. browser_use/mcp/client.py +544 -0
  117. browser_use/mcp/controller.py +264 -0
  118. browser_use/mcp/server.py +1114 -0
  119. browser_use/observability.py +204 -0
  120. browser_use/py.typed +0 -0
  121. browser_use/sandbox/__init__.py +41 -0
  122. browser_use/sandbox/sandbox.py +637 -0
  123. browser_use/sandbox/views.py +132 -0
  124. browser_use/screenshots/__init__.py +1 -0
  125. browser_use/screenshots/service.py +52 -0
  126. browser_use/sync/__init__.py +6 -0
  127. browser_use/sync/auth.py +357 -0
  128. browser_use/sync/service.py +161 -0
  129. browser_use/telemetry/__init__.py +51 -0
  130. browser_use/telemetry/service.py +112 -0
  131. browser_use/telemetry/views.py +101 -0
  132. browser_use/tokens/__init__.py +0 -0
  133. browser_use/tokens/custom_pricing.py +24 -0
  134. browser_use/tokens/mappings.py +4 -0
  135. browser_use/tokens/service.py +580 -0
  136. browser_use/tokens/views.py +108 -0
  137. browser_use/tools/registry/service.py +572 -0
  138. browser_use/tools/registry/views.py +174 -0
  139. browser_use/tools/service.py +1675 -0
  140. browser_use/tools/utils.py +82 -0
  141. browser_use/tools/views.py +100 -0
  142. browser_use/utils.py +670 -0
  143. optexity_browser_use-0.9.5.dist-info/METADATA +344 -0
  144. optexity_browser_use-0.9.5.dist-info/RECORD +147 -0
  145. optexity_browser_use-0.9.5.dist-info/WHEEL +4 -0
  146. optexity_browser_use-0.9.5.dist-info/entry_points.txt +3 -0
  147. optexity_browser_use-0.9.5.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,204 @@
1
+ # @file purpose: Observability module for browser-use that handles optional lmnr integration with debug mode support
2
+ """
3
+ Observability module for browser-use
4
+
5
+ This module provides observability decorators that optionally integrate with lmnr (Laminar) for tracing.
6
+ If lmnr is not installed, it provides no-op wrappers that accept the same parameters.
7
+
8
+ Features:
9
+ - Optional lmnr integration - works with or without lmnr installed
10
+ - Debug mode support - observe_debug only traces when in debug mode
11
+ - Full parameter compatibility with lmnr observe decorator
12
+ - No-op fallbacks when lmnr is unavailable
13
+ """
14
+
15
+ import logging
16
+ import os
17
+ from collections.abc import Callable
18
+ from functools import wraps
19
+ from typing import Any, Literal, TypeVar, cast
20
+
21
+ logger = logging.getLogger(__name__)
22
+ from dotenv import load_dotenv
23
+
24
+ load_dotenv()
25
+
26
+ # Type definitions
27
+ F = TypeVar('F', bound=Callable[..., Any])
28
+
29
+
30
+ # Check if we're in debug mode
31
+ def _is_debug_mode() -> bool:
32
+ """Check if we're in debug mode based on environment variables or logging level."""
33
+
34
+ lmnr_debug_mode = os.getenv('LMNR_LOGGING_LEVEL', '').lower()
35
+ if lmnr_debug_mode == 'debug':
36
+ # logger.info('Debug mode is enabled for observability')
37
+ return True
38
+ # logger.info('Debug mode is disabled for observability')
39
+ return False
40
+
41
+
42
+ # Try to import lmnr observe
43
+ _LMNR_AVAILABLE = False
44
+ _lmnr_observe = None
45
+
46
+ try:
47
+ from lmnr import observe as _lmnr_observe # type: ignore
48
+
49
+ if os.environ.get('BROWSER_USE_VERBOSE_OBSERVABILITY', 'false').lower() == 'true':
50
+ logger.debug('Lmnr is available for observability')
51
+ _LMNR_AVAILABLE = True
52
+ except ImportError:
53
+ if os.environ.get('BROWSER_USE_VERBOSE_OBSERVABILITY', 'false').lower() == 'true':
54
+ logger.debug('Lmnr is not available for observability')
55
+ _LMNR_AVAILABLE = False
56
+
57
+
58
+ def _create_no_op_decorator(
59
+ name: str | None = None,
60
+ ignore_input: bool = False,
61
+ ignore_output: bool = False,
62
+ metadata: dict[str, Any] | None = None,
63
+ **kwargs: Any,
64
+ ) -> Callable[[F], F]:
65
+ """Create a no-op decorator that accepts all lmnr observe parameters but does nothing."""
66
+ import asyncio
67
+
68
+ def decorator(func: F) -> F:
69
+ if asyncio.iscoroutinefunction(func):
70
+
71
+ @wraps(func)
72
+ async def async_wrapper(*args, **kwargs):
73
+ return await func(*args, **kwargs)
74
+
75
+ return cast(F, async_wrapper)
76
+ else:
77
+
78
+ @wraps(func)
79
+ def sync_wrapper(*args, **kwargs):
80
+ return func(*args, **kwargs)
81
+
82
+ return cast(F, sync_wrapper)
83
+
84
+ return decorator
85
+
86
+
87
+ def observe(
88
+ name: str | None = None,
89
+ ignore_input: bool = False,
90
+ ignore_output: bool = False,
91
+ metadata: dict[str, Any] | None = None,
92
+ span_type: Literal['DEFAULT', 'LLM', 'TOOL'] = 'DEFAULT',
93
+ **kwargs: Any,
94
+ ) -> Callable[[F], F]:
95
+ """
96
+ Observability decorator that traces function execution when lmnr is available.
97
+
98
+ This decorator will use lmnr's observe decorator if lmnr is installed,
99
+ otherwise it will be a no-op that accepts the same parameters.
100
+
101
+ Args:
102
+ name: Name of the span/trace
103
+ ignore_input: Whether to ignore function input parameters in tracing
104
+ ignore_output: Whether to ignore function output in tracing
105
+ metadata: Additional metadata to attach to the span
106
+ **kwargs: Additional parameters passed to lmnr observe
107
+
108
+ Returns:
109
+ Decorated function that may be traced depending on lmnr availability
110
+
111
+ Example:
112
+ @observe(name="my_function", metadata={"version": "1.0"})
113
+ def my_function(param1, param2):
114
+ return param1 + param2
115
+ """
116
+ kwargs = {
117
+ 'name': name,
118
+ 'ignore_input': ignore_input,
119
+ 'ignore_output': ignore_output,
120
+ 'metadata': metadata,
121
+ 'span_type': span_type,
122
+ 'tags': ['observe', 'observe_debug'], # important: tags need to be created on laminar first
123
+ **kwargs,
124
+ }
125
+
126
+ if _LMNR_AVAILABLE and _lmnr_observe:
127
+ # Use the real lmnr observe decorator
128
+ return cast(Callable[[F], F], _lmnr_observe(**kwargs))
129
+ else:
130
+ # Use no-op decorator
131
+ return _create_no_op_decorator(**kwargs)
132
+
133
+
134
+ def observe_debug(
135
+ name: str | None = None,
136
+ ignore_input: bool = False,
137
+ ignore_output: bool = False,
138
+ metadata: dict[str, Any] | None = None,
139
+ span_type: Literal['DEFAULT', 'LLM', 'TOOL'] = 'DEFAULT',
140
+ **kwargs: Any,
141
+ ) -> Callable[[F], F]:
142
+ """
143
+ Debug-only observability decorator that only traces when in debug mode.
144
+
145
+ This decorator will use lmnr's observe decorator if both lmnr is installed
146
+ AND we're in debug mode, otherwise it will be a no-op.
147
+
148
+ Debug mode is determined by:
149
+ - DEBUG environment variable set to 1/true/yes/on
150
+ - BROWSER_USE_DEBUG environment variable set to 1/true/yes/on
151
+ - Root logging level set to DEBUG or lower
152
+
153
+ Args:
154
+ name: Name of the span/trace
155
+ ignore_input: Whether to ignore function input parameters in tracing
156
+ ignore_output: Whether to ignore function output in tracing
157
+ metadata: Additional metadata to attach to the span
158
+ **kwargs: Additional parameters passed to lmnr observe
159
+
160
+ Returns:
161
+ Decorated function that may be traced only in debug mode
162
+
163
+ Example:
164
+ @observe_debug(ignore_input=True, ignore_output=True,name="debug_function", metadata={"debug": True})
165
+ def debug_function(param1, param2):
166
+ return param1 + param2
167
+ """
168
+ kwargs = {
169
+ 'name': name,
170
+ 'ignore_input': ignore_input,
171
+ 'ignore_output': ignore_output,
172
+ 'metadata': metadata,
173
+ 'span_type': span_type,
174
+ 'tags': ['observe_debug'], # important: tags need to be created on laminar first
175
+ **kwargs,
176
+ }
177
+
178
+ if _LMNR_AVAILABLE and _lmnr_observe and _is_debug_mode():
179
+ # Use the real lmnr observe decorator only in debug mode
180
+ return cast(Callable[[F], F], _lmnr_observe(**kwargs))
181
+ else:
182
+ # Use no-op decorator (either not in debug mode or lmnr not available)
183
+ return _create_no_op_decorator(**kwargs)
184
+
185
+
186
+ # Convenience functions for checking availability and debug status
187
+ def is_lmnr_available() -> bool:
188
+ """Check if lmnr is available for tracing."""
189
+ return _LMNR_AVAILABLE
190
+
191
+
192
+ def is_debug_mode() -> bool:
193
+ """Check if we're currently in debug mode."""
194
+ return _is_debug_mode()
195
+
196
+
197
+ def get_observability_status() -> dict[str, bool]:
198
+ """Get the current status of observability features."""
199
+ return {
200
+ 'lmnr_available': _LMNR_AVAILABLE,
201
+ 'debug_mode': _is_debug_mode(),
202
+ 'observe_active': _LMNR_AVAILABLE,
203
+ 'observe_debug_active': _LMNR_AVAILABLE and _is_debug_mode(),
204
+ }
browser_use/py.typed ADDED
File without changes
@@ -0,0 +1,41 @@
1
+ """Sandbox execution package for browser-use
2
+
3
+ This package provides type-safe sandbox code execution with SSE streaming.
4
+
5
+ Example:
6
+ from browser_use.sandbox import sandbox, SSEEvent, SSEEventType
7
+
8
+ @sandbox(log_level="INFO")
9
+ async def my_task(browser: Browser) -> str:
10
+ page = await browser.get_current_page()
11
+ await page.goto("https://example.com")
12
+ return await page.title()
13
+
14
+ result = await my_task()
15
+ """
16
+
17
+ from browser_use.sandbox.sandbox import SandboxError, sandbox
18
+ from browser_use.sandbox.views import (
19
+ BrowserCreatedData,
20
+ ErrorData,
21
+ ExecutionResponse,
22
+ LogData,
23
+ ResultData,
24
+ SSEEvent,
25
+ SSEEventType,
26
+ )
27
+
28
+ __all__ = [
29
+ # Main decorator
30
+ 'sandbox',
31
+ 'SandboxError',
32
+ # Event types
33
+ 'SSEEvent',
34
+ 'SSEEventType',
35
+ # Event data models
36
+ 'BrowserCreatedData',
37
+ 'LogData',
38
+ 'ResultData',
39
+ 'ErrorData',
40
+ 'ExecutionResponse',
41
+ ]