browser-use 0.0.1 → 0.1.0

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 (200) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +761 -0
  3. package/dist/agent/cloud-events.d.ts +264 -0
  4. package/dist/agent/cloud-events.js +318 -0
  5. package/dist/agent/gif.d.ts +15 -0
  6. package/dist/agent/gif.js +215 -0
  7. package/dist/agent/index.d.ts +8 -0
  8. package/dist/agent/index.js +8 -0
  9. package/dist/agent/message-manager/service.d.ts +30 -0
  10. package/dist/agent/message-manager/service.js +208 -0
  11. package/dist/agent/message-manager/utils.d.ts +2 -0
  12. package/dist/agent/message-manager/utils.js +41 -0
  13. package/dist/agent/message-manager/views.d.ts +26 -0
  14. package/dist/agent/message-manager/views.js +73 -0
  15. package/dist/agent/prompts.d.ts +52 -0
  16. package/dist/agent/prompts.js +259 -0
  17. package/dist/agent/service.d.ts +290 -0
  18. package/dist/agent/service.js +2200 -0
  19. package/dist/agent/views.d.ts +741 -0
  20. package/dist/agent/views.js +537 -0
  21. package/dist/browser/browser.d.ts +7 -0
  22. package/dist/browser/browser.js +5 -0
  23. package/dist/browser/context.d.ts +8 -0
  24. package/dist/browser/context.js +4 -0
  25. package/dist/browser/dvd-screensaver.d.ts +101 -0
  26. package/dist/browser/dvd-screensaver.js +270 -0
  27. package/dist/browser/extensions.d.ts +63 -0
  28. package/dist/browser/extensions.js +359 -0
  29. package/dist/browser/index.d.ts +10 -0
  30. package/dist/browser/index.js +9 -0
  31. package/dist/browser/playwright-manager.d.ts +47 -0
  32. package/dist/browser/playwright-manager.js +146 -0
  33. package/dist/browser/profile.d.ts +196 -0
  34. package/dist/browser/profile.js +815 -0
  35. package/dist/browser/session.d.ts +505 -0
  36. package/dist/browser/session.js +3409 -0
  37. package/dist/browser/types.d.ts +1184 -0
  38. package/dist/browser/types.js +1 -0
  39. package/dist/browser/utils.d.ts +1 -0
  40. package/dist/browser/utils.js +19 -0
  41. package/dist/browser/views.d.ts +78 -0
  42. package/dist/browser/views.js +72 -0
  43. package/dist/cli.d.ts +2 -0
  44. package/dist/cli.js +44 -0
  45. package/dist/config.d.ts +108 -0
  46. package/dist/config.js +430 -0
  47. package/dist/controller/index.d.ts +3 -0
  48. package/dist/controller/index.js +3 -0
  49. package/dist/controller/registry/index.d.ts +2 -0
  50. package/dist/controller/registry/index.js +2 -0
  51. package/dist/controller/registry/service.d.ts +45 -0
  52. package/dist/controller/registry/service.js +184 -0
  53. package/dist/controller/registry/views.d.ts +55 -0
  54. package/dist/controller/registry/views.js +174 -0
  55. package/dist/controller/service.d.ts +49 -0
  56. package/dist/controller/service.js +1176 -0
  57. package/dist/controller/views.d.ts +241 -0
  58. package/dist/controller/views.js +88 -0
  59. package/dist/dom/clickable-element-processor/service.d.ts +11 -0
  60. package/dist/dom/clickable-element-processor/service.js +60 -0
  61. package/dist/dom/dom_tree/index.js +1400 -0
  62. package/dist/dom/history-tree-processor/service.d.ts +14 -0
  63. package/dist/dom/history-tree-processor/service.js +75 -0
  64. package/dist/dom/history-tree-processor/view.d.ts +54 -0
  65. package/dist/dom/history-tree-processor/view.js +56 -0
  66. package/dist/dom/playground/extraction.d.ts +19 -0
  67. package/dist/dom/playground/extraction.js +187 -0
  68. package/dist/dom/playground/process-dom.d.ts +1 -0
  69. package/dist/dom/playground/process-dom.js +5 -0
  70. package/dist/dom/playground/test-accessibility.d.ts +44 -0
  71. package/dist/dom/playground/test-accessibility.js +111 -0
  72. package/dist/dom/service.d.ts +19 -0
  73. package/dist/dom/service.js +227 -0
  74. package/dist/dom/utils.d.ts +1 -0
  75. package/dist/dom/utils.js +6 -0
  76. package/dist/dom/views.d.ts +61 -0
  77. package/dist/dom/views.js +247 -0
  78. package/dist/event-bus.d.ts +11 -0
  79. package/dist/event-bus.js +19 -0
  80. package/dist/exceptions.d.ts +10 -0
  81. package/dist/exceptions.js +22 -0
  82. package/dist/filesystem/file-system.d.ts +68 -0
  83. package/dist/filesystem/file-system.js +412 -0
  84. package/dist/filesystem/index.d.ts +1 -0
  85. package/dist/filesystem/index.js +1 -0
  86. package/dist/index.d.ts +31 -0
  87. package/dist/index.js +33 -0
  88. package/dist/integrations/gmail/actions.d.ts +12 -0
  89. package/dist/integrations/gmail/actions.js +113 -0
  90. package/dist/integrations/gmail/index.d.ts +2 -0
  91. package/dist/integrations/gmail/index.js +2 -0
  92. package/dist/integrations/gmail/service.d.ts +61 -0
  93. package/dist/integrations/gmail/service.js +260 -0
  94. package/dist/llm/anthropic/chat.d.ts +28 -0
  95. package/dist/llm/anthropic/chat.js +126 -0
  96. package/dist/llm/anthropic/index.d.ts +2 -0
  97. package/dist/llm/anthropic/index.js +2 -0
  98. package/dist/llm/anthropic/serializer.d.ts +68 -0
  99. package/dist/llm/anthropic/serializer.js +285 -0
  100. package/dist/llm/aws/chat-anthropic.d.ts +61 -0
  101. package/dist/llm/aws/chat-anthropic.js +176 -0
  102. package/dist/llm/aws/chat-bedrock.d.ts +15 -0
  103. package/dist/llm/aws/chat-bedrock.js +80 -0
  104. package/dist/llm/aws/index.d.ts +3 -0
  105. package/dist/llm/aws/index.js +3 -0
  106. package/dist/llm/aws/serializer.d.ts +5 -0
  107. package/dist/llm/aws/serializer.js +68 -0
  108. package/dist/llm/azure/chat.d.ts +15 -0
  109. package/dist/llm/azure/chat.js +83 -0
  110. package/dist/llm/azure/index.d.ts +1 -0
  111. package/dist/llm/azure/index.js +1 -0
  112. package/dist/llm/base.d.ts +16 -0
  113. package/dist/llm/base.js +1 -0
  114. package/dist/llm/deepseek/chat.d.ts +15 -0
  115. package/dist/llm/deepseek/chat.js +51 -0
  116. package/dist/llm/deepseek/index.d.ts +2 -0
  117. package/dist/llm/deepseek/index.js +2 -0
  118. package/dist/llm/deepseek/serializer.d.ts +6 -0
  119. package/dist/llm/deepseek/serializer.js +57 -0
  120. package/dist/llm/exceptions.d.ts +10 -0
  121. package/dist/llm/exceptions.js +18 -0
  122. package/dist/llm/google/chat.d.ts +20 -0
  123. package/dist/llm/google/chat.js +144 -0
  124. package/dist/llm/google/index.d.ts +2 -0
  125. package/dist/llm/google/index.js +2 -0
  126. package/dist/llm/google/serializer.d.ts +6 -0
  127. package/dist/llm/google/serializer.js +64 -0
  128. package/dist/llm/groq/chat.d.ts +15 -0
  129. package/dist/llm/groq/chat.js +52 -0
  130. package/dist/llm/groq/index.d.ts +3 -0
  131. package/dist/llm/groq/index.js +3 -0
  132. package/dist/llm/groq/parser.d.ts +32 -0
  133. package/dist/llm/groq/parser.js +189 -0
  134. package/dist/llm/groq/serializer.d.ts +6 -0
  135. package/dist/llm/groq/serializer.js +56 -0
  136. package/dist/llm/messages.d.ts +77 -0
  137. package/dist/llm/messages.js +157 -0
  138. package/dist/llm/ollama/chat.d.ts +15 -0
  139. package/dist/llm/ollama/chat.js +77 -0
  140. package/dist/llm/ollama/index.d.ts +2 -0
  141. package/dist/llm/ollama/index.js +2 -0
  142. package/dist/llm/ollama/serializer.d.ts +6 -0
  143. package/dist/llm/ollama/serializer.js +53 -0
  144. package/dist/llm/openai/chat.d.ts +38 -0
  145. package/dist/llm/openai/chat.js +174 -0
  146. package/dist/llm/openai/index.d.ts +3 -0
  147. package/dist/llm/openai/index.js +3 -0
  148. package/dist/llm/openai/like.d.ts +17 -0
  149. package/dist/llm/openai/like.js +19 -0
  150. package/dist/llm/openai/serializer.d.ts +6 -0
  151. package/dist/llm/openai/serializer.js +57 -0
  152. package/dist/llm/openrouter/chat.d.ts +15 -0
  153. package/dist/llm/openrouter/chat.js +74 -0
  154. package/dist/llm/openrouter/index.d.ts +2 -0
  155. package/dist/llm/openrouter/index.js +2 -0
  156. package/dist/llm/openrouter/serializer.d.ts +3 -0
  157. package/dist/llm/openrouter/serializer.js +3 -0
  158. package/dist/llm/schema.d.ts +6 -0
  159. package/dist/llm/schema.js +77 -0
  160. package/dist/llm/views.d.ts +15 -0
  161. package/dist/llm/views.js +12 -0
  162. package/dist/logging-config.d.ts +25 -0
  163. package/dist/logging-config.js +89 -0
  164. package/dist/mcp/client.d.ts +142 -0
  165. package/dist/mcp/client.js +638 -0
  166. package/dist/mcp/controller.d.ts +6 -0
  167. package/dist/mcp/controller.js +38 -0
  168. package/dist/mcp/index.d.ts +3 -0
  169. package/dist/mcp/index.js +3 -0
  170. package/dist/mcp/server.d.ts +134 -0
  171. package/dist/mcp/server.js +759 -0
  172. package/dist/observability-decorators.d.ts +158 -0
  173. package/dist/observability-decorators.js +286 -0
  174. package/dist/observability.d.ts +23 -0
  175. package/dist/observability.js +58 -0
  176. package/dist/screenshots/index.d.ts +1 -0
  177. package/dist/screenshots/index.js +1 -0
  178. package/dist/screenshots/service.d.ts +6 -0
  179. package/dist/screenshots/service.js +28 -0
  180. package/dist/sync/auth.d.ts +27 -0
  181. package/dist/sync/auth.js +205 -0
  182. package/dist/sync/index.d.ts +2 -0
  183. package/dist/sync/index.js +2 -0
  184. package/dist/sync/service.d.ts +21 -0
  185. package/dist/sync/service.js +146 -0
  186. package/dist/telemetry/index.d.ts +2 -0
  187. package/dist/telemetry/index.js +2 -0
  188. package/dist/telemetry/service.d.ts +12 -0
  189. package/dist/telemetry/service.js +85 -0
  190. package/dist/telemetry/views.d.ts +112 -0
  191. package/dist/telemetry/views.js +112 -0
  192. package/dist/tokens/index.d.ts +2 -0
  193. package/dist/tokens/index.js +2 -0
  194. package/dist/tokens/service.d.ts +35 -0
  195. package/dist/tokens/service.js +423 -0
  196. package/dist/tokens/views.d.ts +58 -0
  197. package/dist/tokens/views.js +1 -0
  198. package/dist/utils.d.ts +128 -0
  199. package/dist/utils.js +529 -0
  200. package/package.json +94 -5
@@ -0,0 +1,505 @@
1
+ import { type Browser, type BrowserContext, type Page, type Locator } from './types.js';
2
+ import { BrowserProfile, type BrowserProfileOptions, DEFAULT_BROWSER_PROFILE } from './profile.js';
3
+ import { BrowserStateSummary, type TabInfo } from './views.js';
4
+ import { DOMElementNode, type SelectorMap } from '../dom/views.js';
5
+ export interface BrowserSessionInit {
6
+ id?: string;
7
+ browser_profile?: BrowserProfile;
8
+ profile?: Partial<BrowserProfileOptions>;
9
+ browser?: Browser | null;
10
+ browser_context?: BrowserContext | null;
11
+ page?: Page | null;
12
+ title?: string | null;
13
+ url?: string | null;
14
+ wss_url?: string | null;
15
+ cdp_url?: string | null;
16
+ browser_pid?: number | null;
17
+ playwright?: unknown;
18
+ downloaded_files?: string[];
19
+ }
20
+ export interface BrowserStateOptions {
21
+ cache_clickable_elements_hashes?: boolean;
22
+ include_screenshot?: boolean;
23
+ signal?: AbortSignal | null;
24
+ }
25
+ export interface BrowserActionOptions {
26
+ signal?: AbortSignal | null;
27
+ }
28
+ export declare class BrowserSession {
29
+ readonly id: string;
30
+ readonly browser_profile: BrowserProfile;
31
+ browser: Browser | null;
32
+ browser_context: BrowserContext | null;
33
+ agent_current_page: Page | null;
34
+ human_current_page: Page | null;
35
+ initialized: boolean;
36
+ wss_url: string | null;
37
+ cdp_url: string | null;
38
+ browser_pid: number | null;
39
+ playwright: unknown;
40
+ private cachedBrowserState;
41
+ private _cachedClickableElementHashes;
42
+ private currentUrl;
43
+ private currentTitle;
44
+ private _logger;
45
+ private _tabCounter;
46
+ private _tabs;
47
+ private currentTabIndex;
48
+ private historyStack;
49
+ downloaded_files: string[];
50
+ private ownsBrowserResources;
51
+ private _autoDownloadPdfs;
52
+ private tabPages;
53
+ private currentPageLoadingStatus;
54
+ private _subprocess;
55
+ private _childProcesses;
56
+ private attachedAgentId;
57
+ private attachedSharedAgentIds;
58
+ private _stoppingPromise;
59
+ constructor(init?: BrowserSessionInit);
60
+ private _waitForStableNetwork;
61
+ private _setActivePage;
62
+ get tabs(): TabInfo[];
63
+ get active_tab_index(): number;
64
+ get active_tab(): TabInfo;
65
+ describe(): string;
66
+ get _owns_browser_resources(): boolean;
67
+ claim_agent(agentId: string, mode?: 'exclusive' | 'shared'): boolean;
68
+ claimAgent(agentId: string, mode?: 'exclusive' | 'shared'): boolean;
69
+ release_agent(agentId?: string): boolean;
70
+ releaseAgent(agentId?: string): boolean;
71
+ get_attached_agent_id(): string | null;
72
+ getAttachedAgentId(): string | null;
73
+ get_attached_agent_ids(): string[];
74
+ getAttachedAgentIds(): string[];
75
+ private _determineOwnership;
76
+ private _createAbortError;
77
+ private _isAbortError;
78
+ private _throwIfAborted;
79
+ private _waitWithAbort;
80
+ private _withAbort;
81
+ private _toPlaywrightOptions;
82
+ private _isSandboxLaunchError;
83
+ private _createNoSandboxLaunchOptions;
84
+ private _launchChromiumWithSandboxFallback;
85
+ private _connectionDescriptor;
86
+ toString(): string;
87
+ private get logger();
88
+ start(): Promise<this>;
89
+ /**
90
+ * Setup browser session by connecting to an existing browser process via PID
91
+ * Useful for debugging or connecting to manually launched browsers
92
+ * @param browserPid - Process ID of the browser to connect to
93
+ * @param cdpUrl - Optional CDP URL (will be discovered if not provided)
94
+ */
95
+ setupBrowserViaBrowserPid(browserPid: number, cdpUrl?: string): Promise<void>;
96
+ /**
97
+ * Discover CDP URL from browser PID
98
+ * Tries common ports and checks for debugging endpoints
99
+ */
100
+ private _discoverCdpUrl;
101
+ private _shutdown_browser_session;
102
+ close(): Promise<void>;
103
+ get_browser_state_with_recovery(options?: BrowserStateOptions): Promise<BrowserStateSummary>;
104
+ get_current_page(): Promise<import("playwright-core").Page | null>;
105
+ update_current_page(page: Page | null, title?: string | null, url?: string | null): void;
106
+ private _buildTabs;
107
+ navigate_to(url: string, options?: BrowserActionOptions): Promise<import("playwright-core").Page | null>;
108
+ create_new_tab(url: string, options?: BrowserActionOptions): Promise<import("playwright-core").Page | null>;
109
+ private _resolveTabIndex;
110
+ switch_to_tab(identifier: number, options?: BrowserActionOptions): Promise<import("playwright-core").Page | null>;
111
+ close_tab(identifier: number): Promise<void>;
112
+ go_back(options?: BrowserActionOptions): Promise<void>;
113
+ get_dom_element_by_index(_index: number, options?: BrowserActionOptions): Promise<DOMElementNode>;
114
+ set_downloaded_files(files: string[]): void;
115
+ add_downloaded_file(filePath: string): void;
116
+ get_downloaded_files(): string[];
117
+ set_auto_download_pdfs(enabled: boolean): void;
118
+ auto_download_pdfs(): boolean;
119
+ static get_unique_filename(directory: string, filename: string): Promise<string>;
120
+ get_selector_map(options?: BrowserActionOptions): Promise<SelectorMap>;
121
+ static is_file_input(node: DOMElementNode | null): boolean;
122
+ is_file_input(node: DOMElementNode | null): boolean;
123
+ find_file_upload_element_by_index(index: number, maxHeight?: number, maxDescendantDepth?: number, options?: BrowserActionOptions): Promise<DOMElementNode | null>;
124
+ get_locate_element(node: DOMElementNode): Promise<Locator | null>;
125
+ _input_text_element_node(node: DOMElementNode, text: string, options?: BrowserActionOptions): Promise<void>;
126
+ _click_element_node(node: DOMElementNode, options?: BrowserActionOptions): Promise<string | null>;
127
+ private _waitForLoad;
128
+ /**
129
+ * Get all cookies from the current browser context
130
+ */
131
+ get_cookies(): Promise<Array<Record<string, any>>>;
132
+ /**
133
+ * Save cookies to a file (deprecated, use save_storage_state instead)
134
+ * @deprecated Use save_storage_state() instead
135
+ */
136
+ save_cookies(...args: any[]): Promise<void>;
137
+ /**
138
+ * Load cookies from a file (deprecated, use load_storage_state instead)
139
+ * @deprecated Use load_storage_state() instead
140
+ */
141
+ load_cookies_from_file(...args: any[]): Promise<void>;
142
+ /**
143
+ * Save the current storage state (cookies, localStorage, sessionStorage) to a file
144
+ */
145
+ save_storage_state(filePath?: string): Promise<void>;
146
+ /**
147
+ * Load storage state (cookies, localStorage, sessionStorage) from a file
148
+ */
149
+ load_storage_state(filePath?: string): Promise<void>;
150
+ /**
151
+ * Execute JavaScript in the current page context
152
+ */
153
+ execute_javascript(script: string): Promise<any>;
154
+ /**
155
+ * Get comprehensive page information (size, scroll position, etc.)
156
+ */
157
+ get_page_info(page?: Page): Promise<any>;
158
+ /**
159
+ * Get the HTML content of the current page
160
+ */
161
+ get_page_html(): Promise<string>;
162
+ /**
163
+ * Get a debug view of the page structure including iframes
164
+ */
165
+ get_page_structure(): Promise<string>;
166
+ /**
167
+ * Navigate forward in browser history
168
+ */
169
+ go_forward(): Promise<void>;
170
+ /**
171
+ * Refresh the current page
172
+ */
173
+ refresh(): Promise<void>;
174
+ /**
175
+ * Wait for an element to appear on the page
176
+ */
177
+ wait_for_element(selector: string, timeout?: number): Promise<void>;
178
+ /**
179
+ * Take a screenshot of the current page
180
+ * @param full_page Whether to capture the full scrollable page
181
+ * @returns Base64 encoded PNG screenshot
182
+ */
183
+ take_screenshot(full_page?: boolean): Promise<string | null>;
184
+ /**
185
+ * Add a request event listener to the current page
186
+ */
187
+ on_request(callback: (request: any) => void | Promise<void>): Promise<void>;
188
+ /**
189
+ * Add a response event listener to the current page
190
+ */
191
+ on_response(callback: (response: any) => void | Promise<void>): Promise<void>;
192
+ /**
193
+ * Remove a request event listener from the current page
194
+ */
195
+ off_request(callback: (request: any) => void | Promise<void>): Promise<void>;
196
+ /**
197
+ * Remove a response event listener from the current page
198
+ */
199
+ off_response(callback: (response: any) => void | Promise<void>): Promise<void>;
200
+ /**
201
+ * Get information about all open tabs
202
+ * @returns Array of tab information including page_id, url, and title
203
+ */
204
+ get_tabs_info(): Promise<Array<{
205
+ page_id: number;
206
+ url: string;
207
+ title: string;
208
+ }>>;
209
+ /**
210
+ * Check if a page is responsive by trying to evaluate simple JavaScript
211
+ * @param page - The page to check
212
+ * @param timeout - Timeout in seconds (default: 5)
213
+ * @returns True if page is responsive, false otherwise
214
+ */
215
+ _is_page_responsive(page: any, timeout?: number): Promise<boolean>;
216
+ /**
217
+ * Get scroll information for the current page
218
+ * @returns Object with scroll position and page dimensions
219
+ */
220
+ get_scroll_info(): Promise<{
221
+ scroll_x: number;
222
+ scroll_y: number;
223
+ page_width: number;
224
+ page_height: number;
225
+ viewport_width: number;
226
+ viewport_height: number;
227
+ }>;
228
+ /**
229
+ * Get a summary of the current browser state
230
+ * @param cache_clickable_elements_hashes - Cache clickable element hashes to detect new elements
231
+ * @param include_screenshot - Include screenshot in state summary
232
+ * @returns BrowserStateSummary with current page state
233
+ */
234
+ get_state_summary(cache_clickable_elements_hashes?: boolean, include_screenshot?: boolean): Promise<BrowserStateSummary>;
235
+ /**
236
+ * Get minimal state summary without DOM processing, but with screenshot
237
+ * Used when page is in error state or unresponsive
238
+ */
239
+ get_minimal_state_summary(): Promise<BrowserStateSummary>;
240
+ /**
241
+ * Internal method to get updated browser state with DOM processing
242
+ * @param focus_element - Element index to focus on (default: -1)
243
+ * @param include_screenshot - Whether to include screenshot
244
+ */
245
+ private _get_updated_state;
246
+ /**
247
+ * Check if a URL is a new tab page
248
+ */
249
+ private _is_new_tab_page;
250
+ /**
251
+ * Check if page is displaying a PDF
252
+ */
253
+ private _is_pdf_viewer;
254
+ /**
255
+ * Auto-download PDF if detected and auto-download is enabled
256
+ */
257
+ private _auto_download_pdf_if_needed;
258
+ /**
259
+ * Check if an element is visible on the page
260
+ */
261
+ private _is_visible;
262
+ /**
263
+ * Locate an element by XPath
264
+ */
265
+ get_locate_element_by_xpath(xpath: string): Promise<any>;
266
+ /**
267
+ * Locate an element by CSS selector
268
+ */
269
+ get_locate_element_by_css_selector(css_selector: string): Promise<any>;
270
+ /**
271
+ * Locate an element by text content
272
+ * @param text - Text to search for
273
+ * @param nth - Which matching element to return (0-based index)
274
+ * @param element_type - Optional tag name to filter by (e.g., 'button', 'span')
275
+ */
276
+ get_locate_element_by_text(text: string, nth?: number, element_type?: string | null): Promise<any>;
277
+ /**
278
+ * Check if browser session is connected and has valid browser/context objects
279
+ * @param restart - If true, attempt to create a new tab if no pages exist
280
+ */
281
+ is_connected(restart?: boolean): Promise<boolean>;
282
+ /**
283
+ * Check if a URL is allowed based on allowed_domains configuration
284
+ * @param url - URL to check
285
+ */
286
+ private _is_url_allowed;
287
+ /**
288
+ * Navigate helper with URL validation
289
+ */
290
+ navigate(url: string): Promise<void>;
291
+ /**
292
+ * Kill the browser session (force close even if keep_alive=true)
293
+ */
294
+ kill(): Promise<void>;
295
+ /**
296
+ * Alias for close() to match Python API
297
+ */
298
+ stop(): Promise<void>;
299
+ /**
300
+ * Perform a click action with download and navigation handling
301
+ * @param element_node - DOM element to click
302
+ */
303
+ perform_click(element_node: DOMElementNode): Promise<string | null>;
304
+ /**
305
+ * Remove all highlights from the current page
306
+ */
307
+ remove_highlights(): Promise<void>;
308
+ /**
309
+ * Start tracing on browser context if traces_dir is configured
310
+ * Note: Currently optional as it may cause performance issues in some cases
311
+ */
312
+ private _startContextTracing;
313
+ /**
314
+ * Save browser trace recording
315
+ */
316
+ private _saveTraceRecording;
317
+ /**
318
+ * Scroll using CDP Input.synthesizeScrollGesture for universal compatibility
319
+ * @param page - The page to scroll
320
+ * @param pixels - Number of pixels to scroll (positive = up, negative = down)
321
+ * @returns true if successful, false if failed
322
+ */
323
+ private _scrollWithCdpGesture;
324
+ /**
325
+ * Scroll the current page container
326
+ * @param pixels - Number of pixels to scroll (positive = up, negative = down)
327
+ */
328
+ private _scrollContainer;
329
+ /**
330
+ * Compute hashes for all clickable elements in the selector map
331
+ * @param selectorMap - Selector map from DOM state
332
+ * @returns Set of element hashes
333
+ */
334
+ private _computeElementHashes;
335
+ /**
336
+ * Mark elements in the selector map as new if they weren't in the cached hashes
337
+ * @param selectorMap - Selector map to update
338
+ * @param cachedHashes - Previously cached element hashes
339
+ */
340
+ private _markNewElements;
341
+ /**
342
+ * Helper to get a safe method name from the calling context
343
+ * Used for recovery error messages
344
+ */
345
+ private _getCurrentMethodName;
346
+ /**
347
+ * Get current page with fallback logic
348
+ * Alias for compatibility with Python API
349
+ */
350
+ getCurrentPage(): Promise<Page | null>;
351
+ /**
352
+ * Log warning about unsafe glob patterns
353
+ * @param pattern - The glob pattern being used
354
+ */
355
+ private _logGlobWarning;
356
+ /**
357
+ * Create a shallow copy of the browser session
358
+ * Note: This doesn't copy the actual browser instance, just the session metadata
359
+ * @returns A new BrowserSession instance with copied state
360
+ */
361
+ modelCopy(): BrowserSession;
362
+ model_copy(): BrowserSession;
363
+ private _inRecovery;
364
+ /**
365
+ * Check if a page is responsive by trying to evaluate simple JavaScript
366
+ * @param page - The page to check
367
+ * @param timeout - Timeout in seconds (default: 5.0)
368
+ * @returns true if page is responsive, false otherwise
369
+ */
370
+ private _isPageResponsive;
371
+ /**
372
+ * Force close a crashed page using CDP from a clean temporary page
373
+ * @param pageUrl - The URL of the page to force close
374
+ * @returns true if successful, false otherwise
375
+ */
376
+ private _forceClosePageViaCdp;
377
+ /**
378
+ * Try to reopen a URL in a new page and check if it's responsive
379
+ * @param url - The URL to reopen
380
+ * @param timeoutMs - Navigation timeout in milliseconds
381
+ * @returns true if successful and responsive, false otherwise
382
+ */
383
+ private _tryReopenUrl;
384
+ /**
385
+ * Create a new blank page as a fallback when recovery fails
386
+ * @param url - The original URL that failed
387
+ */
388
+ private _createBlankFallbackPage;
389
+ /**
390
+ * Recover from an unresponsive page by closing and reopening it
391
+ * @param callingMethod - The name of the method that detected the unresponsive page
392
+ * @param timeoutMs - Navigation timeout in milliseconds
393
+ */
394
+ private _recoverUnresponsivePage;
395
+ /**
396
+ * Generate enhanced CSS selector for an element
397
+ * Handles special characters and provides fallback strategies
398
+ * @param xpath - XPath of the element
399
+ * @param element - Optional element node for additional context
400
+ * @returns Enhanced CSS selector string
401
+ */
402
+ private _enhancedCssSelectorForElement;
403
+ /**
404
+ * Convert XPath to CSS selector
405
+ * Handles simple XPath expressions
406
+ */
407
+ private _xpathToCss;
408
+ /**
409
+ * Escape special characters in CSS selectors
410
+ * Handles characters that need escaping in CSS
411
+ */
412
+ private _escapeSelector;
413
+ /**
414
+ * Prepare user data directory for browser profile
415
+ * Handles singleton lock conflicts and creates temp profiles if needed
416
+ */
417
+ prepareUserDataDir(userDataDir?: string): Promise<string>;
418
+ /**
419
+ * Check if user data directory has a singleton lock
420
+ * This happens when another Chrome instance is using the profile
421
+ */
422
+ private _checkForSingletonLockConflict;
423
+ /**
424
+ * Fallback to a temporary profile when the primary one is locked
425
+ */
426
+ private _fallbackToTempProfile;
427
+ /**
428
+ * Create a temporary user data directory
429
+ */
430
+ private _createTempUserDataDir;
431
+ /**
432
+ * Setup listeners for page visibility changes
433
+ * Tracks when user switches tabs to update human_current_page
434
+ */
435
+ private _setupCurrentPageChangeListeners;
436
+ /**
437
+ * Callback when tab visibility changes
438
+ * Updates human_current_page to reflect which tab the user is viewing
439
+ */
440
+ private _onTabVisibilityChange;
441
+ /**
442
+ * Kill all child processes spawned by this browser session
443
+ */
444
+ private _killChildProcesses;
445
+ /**
446
+ * Terminate the browser process and all its children
447
+ */
448
+ private _terminateBrowserProcess;
449
+ /**
450
+ * Get child processes of a given PID
451
+ * Cross-platform implementation using ps on Unix-like systems and WMIC on Windows
452
+ */
453
+ private _getChildProcesses;
454
+ /**
455
+ * Track a child process
456
+ */
457
+ private _trackChildProcess;
458
+ /**
459
+ * Untrack a child process
460
+ */
461
+ private _untrackChildProcess;
462
+ /**
463
+ * Show DVD screensaver loading animation
464
+ * Returns a function to stop the animation
465
+ *
466
+ * @param message - Message to display (default: 'Loading...')
467
+ * @param fps - Frames per second (default: 10)
468
+ * @returns Function to stop the animation
469
+ *
470
+ * @example
471
+ * const stopAnimation = this._showDvdScreensaverLoadingAnimation('Loading page...');
472
+ * await someLongOperation();
473
+ * stopAnimation();
474
+ */
475
+ _showDvdScreensaverLoadingAnimation(message?: string, fps?: number): () => void;
476
+ /**
477
+ * Show simple spinner loading animation
478
+ * Returns a function to stop the animation
479
+ *
480
+ * @param message - Message to display (default: 'Loading...')
481
+ * @param fps - Frames per second (default: 10)
482
+ * @returns Function to stop the animation
483
+ *
484
+ * @example
485
+ * const stopSpinner = this._showSpinnerLoadingAnimation('Processing...');
486
+ * await someLongOperation();
487
+ * stopSpinner();
488
+ */
489
+ _showSpinnerLoadingAnimation(message?: string, fps?: number): () => void;
490
+ /**
491
+ * Execute an async operation with DVD screensaver animation
492
+ *
493
+ * @param operation - Async operation to execute
494
+ * @param message - Message to display during operation
495
+ * @returns Result of the operation
496
+ *
497
+ * @example
498
+ * const page = await this._withDvdScreensaver(
499
+ * async () => await this.browser_context!.newPage(),
500
+ * 'Opening new page...'
501
+ * );
502
+ */
503
+ _withDvdScreensaver<T>(operation: () => Promise<T>, message?: string): Promise<T>;
504
+ }
505
+ export { DEFAULT_BROWSER_PROFILE };