agent-browser-stealth 0.14.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 (77) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1219 -0
  3. package/bin/agent-browser-darwin-arm64 +0 -0
  4. package/bin/agent-browser-local +0 -0
  5. package/bin/agent-browser.js +109 -0
  6. package/dist/actions.d.ts +17 -0
  7. package/dist/actions.d.ts.map +1 -0
  8. package/dist/actions.js +1917 -0
  9. package/dist/actions.js.map +1 -0
  10. package/dist/browser.d.ts +598 -0
  11. package/dist/browser.d.ts.map +1 -0
  12. package/dist/browser.js +2287 -0
  13. package/dist/browser.js.map +1 -0
  14. package/dist/daemon.d.ts +66 -0
  15. package/dist/daemon.d.ts.map +1 -0
  16. package/dist/daemon.js +603 -0
  17. package/dist/daemon.js.map +1 -0
  18. package/dist/diff.d.ts +18 -0
  19. package/dist/diff.d.ts.map +1 -0
  20. package/dist/diff.js +271 -0
  21. package/dist/diff.js.map +1 -0
  22. package/dist/encryption.d.ts +50 -0
  23. package/dist/encryption.d.ts.map +1 -0
  24. package/dist/encryption.js +85 -0
  25. package/dist/encryption.js.map +1 -0
  26. package/dist/ios-actions.d.ts +11 -0
  27. package/dist/ios-actions.d.ts.map +1 -0
  28. package/dist/ios-actions.js +228 -0
  29. package/dist/ios-actions.js.map +1 -0
  30. package/dist/ios-manager.d.ts +266 -0
  31. package/dist/ios-manager.d.ts.map +1 -0
  32. package/dist/ios-manager.js +1073 -0
  33. package/dist/ios-manager.js.map +1 -0
  34. package/dist/protocol.d.ts +26 -0
  35. package/dist/protocol.d.ts.map +1 -0
  36. package/dist/protocol.js +935 -0
  37. package/dist/protocol.js.map +1 -0
  38. package/dist/snapshot.d.ts +67 -0
  39. package/dist/snapshot.d.ts.map +1 -0
  40. package/dist/snapshot.js +514 -0
  41. package/dist/snapshot.js.map +1 -0
  42. package/dist/state-utils.d.ts +77 -0
  43. package/dist/state-utils.d.ts.map +1 -0
  44. package/dist/state-utils.js +178 -0
  45. package/dist/state-utils.js.map +1 -0
  46. package/dist/stealth.d.ts +22 -0
  47. package/dist/stealth.d.ts.map +1 -0
  48. package/dist/stealth.js +614 -0
  49. package/dist/stealth.js.map +1 -0
  50. package/dist/stream-server.d.ts +117 -0
  51. package/dist/stream-server.d.ts.map +1 -0
  52. package/dist/stream-server.js +309 -0
  53. package/dist/stream-server.js.map +1 -0
  54. package/dist/types.d.ts +855 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/dist/types.js +2 -0
  57. package/dist/types.js.map +1 -0
  58. package/package.json +85 -0
  59. package/scripts/build-all-platforms.sh +68 -0
  60. package/scripts/check-creepjs-headless.js +137 -0
  61. package/scripts/check-sannysoft-webdriver.js +112 -0
  62. package/scripts/check-version-sync.js +39 -0
  63. package/scripts/copy-native.js +36 -0
  64. package/scripts/postinstall.js +275 -0
  65. package/scripts/sync-upstream.sh +142 -0
  66. package/scripts/sync-version.js +69 -0
  67. package/skills/agent-browser/SKILL.md +464 -0
  68. package/skills/agent-browser/references/authentication.md +202 -0
  69. package/skills/agent-browser/references/commands.md +263 -0
  70. package/skills/agent-browser/references/profiling.md +120 -0
  71. package/skills/agent-browser/references/proxy-support.md +194 -0
  72. package/skills/agent-browser/references/session-management.md +193 -0
  73. package/skills/agent-browser/references/snapshot-refs.md +194 -0
  74. package/skills/agent-browser/references/video-recording.md +173 -0
  75. package/skills/agent-browser/templates/authenticated-session.sh +100 -0
  76. package/skills/agent-browser/templates/capture-workflow.sh +69 -0
  77. package/skills/agent-browser/templates/form-automation.sh +62 -0
@@ -0,0 +1,598 @@
1
+ import { devices, type Browser, type BrowserContext, type Page, type Frame, type Locator, type CDPSession } from 'playwright-core';
2
+ import type { LaunchCommand } from './types.js';
3
+ import { type RefMap, type EnhancedSnapshot } from './snapshot.js';
4
+ /**
5
+ * Returns the default Playwright timeout in milliseconds for standard operations.
6
+ * Can be overridden via the AGENT_BROWSER_DEFAULT_TIMEOUT environment variable.
7
+ * Default is 25s, which is below the CLI's 30s IPC read timeout to ensure
8
+ * Playwright errors are returned before the CLI gives up with EAGAIN.
9
+ * CDP and recording contexts use a shorter fixed timeout (10s) and are not affected.
10
+ */
11
+ export declare function getDefaultTimeout(): number;
12
+ export interface ScreencastFrame {
13
+ data: string;
14
+ metadata: {
15
+ offsetTop: number;
16
+ pageScaleFactor: number;
17
+ deviceWidth: number;
18
+ deviceHeight: number;
19
+ scrollOffsetX: number;
20
+ scrollOffsetY: number;
21
+ timestamp?: number;
22
+ };
23
+ sessionId: number;
24
+ }
25
+ export interface ScreencastOptions {
26
+ format?: 'jpeg' | 'png';
27
+ quality?: number;
28
+ maxWidth?: number;
29
+ maxHeight?: number;
30
+ everyNthFrame?: number;
31
+ }
32
+ interface TrackedRequest {
33
+ url: string;
34
+ method: string;
35
+ headers: Record<string, string>;
36
+ timestamp: number;
37
+ resourceType: string;
38
+ }
39
+ interface ConsoleMessage {
40
+ type: string;
41
+ text: string;
42
+ timestamp: number;
43
+ }
44
+ interface PageError {
45
+ message: string;
46
+ timestamp: number;
47
+ }
48
+ type BrowserType = NonNullable<LaunchCommand['browser']>;
49
+ type StealthConnectionKind = 'local' | 'cdp' | 'provider-browserbase' | 'provider-browseruse' | 'provider-kernel';
50
+ export interface StealthStatus {
51
+ enabled: boolean;
52
+ connectionKind: StealthConnectionKind;
53
+ capabilities: string[];
54
+ providerManaged: boolean;
55
+ }
56
+ /**
57
+ * Manages the Playwright browser lifecycle with multiple tabs/windows
58
+ */
59
+ export declare class BrowserManager {
60
+ private browser;
61
+ private cdpEndpoint;
62
+ private isPersistentContext;
63
+ private browserbaseSessionId;
64
+ private browserbaseApiKey;
65
+ private browserUseSessionId;
66
+ private browserUseApiKey;
67
+ private kernelSessionId;
68
+ private kernelApiKey;
69
+ private contexts;
70
+ private pages;
71
+ private activePageIndex;
72
+ private activeFrame;
73
+ private dialogHandler;
74
+ private trackedRequests;
75
+ private routes;
76
+ private consoleMessages;
77
+ private pageErrors;
78
+ private isRecordingHar;
79
+ private refMap;
80
+ private lastSnapshot;
81
+ private scopedHeaderRoutes;
82
+ private colorScheme;
83
+ private stealthEnabled;
84
+ private stealthConnectionKind;
85
+ private contextLocale;
86
+ private contextTimezoneId;
87
+ private contextHeaders;
88
+ private contextUserAgent;
89
+ /**
90
+ * Set the persistent color scheme preference.
91
+ * Applied automatically to all new pages and contexts.
92
+ */
93
+ setColorScheme(scheme: 'light' | 'dark' | 'no-preference' | null): void;
94
+ /**
95
+ * Centralized stealth policy so launch mode semantics stay consistent.
96
+ * Local Chromium gets args + init scripts; CDP/providers get init scripts only.
97
+ */
98
+ private getStealthPolicy;
99
+ private logStealthPolicy;
100
+ getStealthStatus(browserType?: BrowserType): StealthStatus;
101
+ private normalizeLocaleTag;
102
+ private buildAcceptLanguageHeader;
103
+ private getHeaderValue;
104
+ private resolveStealthLocale;
105
+ private resolveStealthTimezoneId;
106
+ private buildStealthContextDefaults;
107
+ private extractChromiumVersion;
108
+ private buildStealthChromiumUserAgent;
109
+ private getStealthUserAgentVersionHint;
110
+ /**
111
+ * Apply context init-script stealth patches when policy allows.
112
+ */
113
+ private applyStealthIfEnabled;
114
+ private cdpSession;
115
+ private screencastActive;
116
+ private screencastSessionId;
117
+ private frameCallback;
118
+ private screencastFrameHandler;
119
+ private recordingContext;
120
+ private recordingPage;
121
+ private recordingOutputPath;
122
+ private recordingTempDir;
123
+ private launchWarnings;
124
+ /**
125
+ * Get and clear launch warnings (e.g., decryption failures)
126
+ */
127
+ getAndClearWarnings(): string[];
128
+ private static readonly MAX_PROFILE_EVENTS;
129
+ private profilingActive;
130
+ private profileChunks;
131
+ private profileEventsDropped;
132
+ private profileCompleteResolver;
133
+ private profileDataHandler;
134
+ private profileCompleteHandler;
135
+ /**
136
+ * Check if browser is launched
137
+ */
138
+ isLaunched(): boolean;
139
+ /**
140
+ * Get enhanced snapshot with refs and cache the ref map
141
+ */
142
+ getSnapshot(options?: {
143
+ interactive?: boolean;
144
+ cursor?: boolean;
145
+ maxDepth?: number;
146
+ compact?: boolean;
147
+ selector?: string;
148
+ }): Promise<EnhancedSnapshot>;
149
+ /**
150
+ * Get the last snapshot tree text (empty string if no snapshot has been taken)
151
+ */
152
+ getLastSnapshot(): string;
153
+ /**
154
+ * Update the stored snapshot (used by diff to keep the baseline current)
155
+ */
156
+ setLastSnapshot(snapshot: string): void;
157
+ /**
158
+ * Get the cached ref map from last snapshot
159
+ */
160
+ getRefMap(): RefMap;
161
+ /**
162
+ * Get a locator from a ref (e.g., "e1", "@e1", "ref=e1")
163
+ * Returns null if ref doesn't exist or is invalid
164
+ */
165
+ getLocatorFromRef(refArg: string): Locator | null;
166
+ /**
167
+ * Check if a selector looks like a ref
168
+ */
169
+ isRef(selector: string): boolean;
170
+ /**
171
+ * Get locator - supports both refs and regular selectors
172
+ */
173
+ getLocator(selectorOrRef: string): Locator;
174
+ /**
175
+ * Check if the browser has any usable pages
176
+ */
177
+ hasPages(): boolean;
178
+ /**
179
+ * Ensure at least one page exists. If the browser is launched but all pages
180
+ * were closed (stale session), creates a new page on the existing context.
181
+ * No-op if pages already exist.
182
+ */
183
+ ensurePage(): Promise<void>;
184
+ /**
185
+ * Get the current active page, throws if not launched
186
+ */
187
+ getPage(): Page;
188
+ /**
189
+ * Get the current frame (or page's main frame if no frame is selected)
190
+ */
191
+ getFrame(): Frame;
192
+ /**
193
+ * Switch to a frame by selector, name, or URL
194
+ */
195
+ switchToFrame(options: {
196
+ selector?: string;
197
+ name?: string;
198
+ url?: string;
199
+ }): Promise<void>;
200
+ /**
201
+ * Switch back to main frame
202
+ */
203
+ switchToMainFrame(): void;
204
+ /**
205
+ * Set up dialog handler
206
+ */
207
+ setDialogHandler(response: 'accept' | 'dismiss', promptText?: string): void;
208
+ /**
209
+ * Clear dialog handler
210
+ */
211
+ clearDialogHandler(): void;
212
+ /**
213
+ * Start tracking requests
214
+ */
215
+ startRequestTracking(): void;
216
+ /**
217
+ * Get tracked requests
218
+ */
219
+ getRequests(filter?: string): TrackedRequest[];
220
+ /**
221
+ * Clear tracked requests
222
+ */
223
+ clearRequests(): void;
224
+ /**
225
+ * Add a route to intercept requests
226
+ */
227
+ addRoute(url: string, options: {
228
+ response?: {
229
+ status?: number;
230
+ body?: string;
231
+ contentType?: string;
232
+ headers?: Record<string, string>;
233
+ };
234
+ abort?: boolean;
235
+ }): Promise<void>;
236
+ /**
237
+ * Remove a route
238
+ */
239
+ removeRoute(url?: string): Promise<void>;
240
+ /**
241
+ * Set geolocation
242
+ */
243
+ setGeolocation(latitude: number, longitude: number, accuracy?: number): Promise<void>;
244
+ /**
245
+ * Set permissions
246
+ */
247
+ setPermissions(permissions: string[], grant: boolean): Promise<void>;
248
+ /**
249
+ * Set viewport
250
+ */
251
+ setViewport(width: number, height: number): Promise<void>;
252
+ /**
253
+ * Set device scale factor (devicePixelRatio) via CDP
254
+ * This sets window.devicePixelRatio which affects how the page renders and responds to media queries
255
+ *
256
+ * Note: When using CDP to set deviceScaleFactor, screenshots will be at logical pixel dimensions
257
+ * (viewport size), not physical pixel dimensions (viewport × scale). This is a Playwright limitation
258
+ * when using CDP emulation on existing contexts. For true HiDPI screenshots with physical pixels,
259
+ * deviceScaleFactor must be set at context creation time.
260
+ *
261
+ * Must be called after setViewport to work correctly
262
+ */
263
+ setDeviceScaleFactor(deviceScaleFactor: number, width: number, height: number, mobile?: boolean): Promise<void>;
264
+ /**
265
+ * Clear device metrics override to restore default devicePixelRatio
266
+ */
267
+ clearDeviceMetricsOverride(): Promise<void>;
268
+ /**
269
+ * Get device descriptor
270
+ */
271
+ getDevice(deviceName: string): (typeof devices)[keyof typeof devices] | undefined;
272
+ /**
273
+ * List available devices
274
+ */
275
+ listDevices(): string[];
276
+ /**
277
+ * Start console message tracking
278
+ */
279
+ startConsoleTracking(): void;
280
+ /**
281
+ * Get console messages
282
+ */
283
+ getConsoleMessages(): ConsoleMessage[];
284
+ /**
285
+ * Clear console messages
286
+ */
287
+ clearConsoleMessages(): void;
288
+ /**
289
+ * Start error tracking
290
+ */
291
+ startErrorTracking(): void;
292
+ /**
293
+ * Get page errors
294
+ */
295
+ getPageErrors(): PageError[];
296
+ /**
297
+ * Clear page errors
298
+ */
299
+ clearPageErrors(): void;
300
+ /**
301
+ * Start HAR recording
302
+ */
303
+ startHarRecording(): Promise<void>;
304
+ /**
305
+ * Check if HAR recording
306
+ */
307
+ isHarRecording(): boolean;
308
+ /**
309
+ * Set offline mode
310
+ */
311
+ setOffline(offline: boolean): Promise<void>;
312
+ /**
313
+ * Set extra HTTP headers (global - all requests)
314
+ */
315
+ setExtraHeaders(headers: Record<string, string>): Promise<void>;
316
+ /**
317
+ * Set scoped HTTP headers (only for requests matching the origin)
318
+ * Uses route interception to add headers only to matching requests
319
+ */
320
+ setScopedHeaders(origin: string, headers: Record<string, string>): Promise<void>;
321
+ /**
322
+ * Clear scoped headers for an origin (or all if no origin specified)
323
+ */
324
+ clearScopedHeaders(origin?: string): Promise<void>;
325
+ /**
326
+ * Start tracing
327
+ */
328
+ startTracing(options: {
329
+ screenshots?: boolean;
330
+ snapshots?: boolean;
331
+ }): Promise<void>;
332
+ /**
333
+ * Stop tracing and save
334
+ */
335
+ stopTracing(path?: string): Promise<void>;
336
+ /**
337
+ * Get the current browser context (first context)
338
+ */
339
+ getContext(): BrowserContext | null;
340
+ /**
341
+ * Save storage state (cookies, localStorage, etc.)
342
+ */
343
+ saveStorageState(path: string): Promise<void>;
344
+ /**
345
+ * Get all pages
346
+ */
347
+ getPages(): Page[];
348
+ /**
349
+ * Get current page index
350
+ */
351
+ getActiveIndex(): number;
352
+ /**
353
+ * Get the current browser instance
354
+ */
355
+ getBrowser(): Browser | null;
356
+ /**
357
+ * Check if an existing CDP connection is still alive
358
+ * by verifying we can access browser contexts and that at least one has pages
359
+ */
360
+ private isCdpConnectionAlive;
361
+ /**
362
+ * Check if CDP connection needs to be re-established
363
+ */
364
+ private needsCdpReconnect;
365
+ /**
366
+ * Close a Browserbase session via API
367
+ */
368
+ private closeBrowserbaseSession;
369
+ /**
370
+ * Close a Browser Use session via API
371
+ */
372
+ private closeBrowserUseSession;
373
+ /**
374
+ * Close a Kernel session via API
375
+ */
376
+ private closeKernelSession;
377
+ /**
378
+ * Connect to Browserbase remote browser via CDP.
379
+ * Requires BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID environment variables.
380
+ */
381
+ private connectToBrowserbase;
382
+ /**
383
+ * Find or create a Kernel profile by name.
384
+ * Returns the profile object if successful.
385
+ */
386
+ private findOrCreateKernelProfile;
387
+ /**
388
+ * Connect to Kernel remote browser via CDP.
389
+ * Requires KERNEL_API_KEY environment variable.
390
+ */
391
+ private connectToKernel;
392
+ /**
393
+ * Connect to Browser Use remote browser via CDP.
394
+ * Requires BROWSER_USE_API_KEY environment variable.
395
+ */
396
+ private connectToBrowserUse;
397
+ /**
398
+ * Launch the browser with the specified options
399
+ * If already launched, this is a no-op (browser stays open)
400
+ */
401
+ launch(options: LaunchCommand): Promise<void>;
402
+ /**
403
+ * Connect to a running browser via CDP (Chrome DevTools Protocol)
404
+ * @param cdpEndpoint Either a port number (as string) or a full WebSocket URL (ws:// or wss://)
405
+ */
406
+ private connectViaCDP;
407
+ /**
408
+ * Get Chrome's default user data directory paths for the current platform.
409
+ * Returns an array of candidate paths to check (stable, then beta/canary).
410
+ */
411
+ private getChromeUserDataDirs;
412
+ /**
413
+ * Try to read the DevToolsActivePort file from a Chrome user data directory.
414
+ * Returns { port, wsPath } if found, or null if not available.
415
+ */
416
+ private readDevToolsActivePort;
417
+ /**
418
+ * Try to discover a Chrome CDP endpoint by querying an HTTP debug port.
419
+ * Returns the WebSocket debugger URL if available.
420
+ */
421
+ private probeDebugPort;
422
+ /**
423
+ * Auto-discover and connect to a running Chrome/Chromium instance.
424
+ *
425
+ * Discovery strategy:
426
+ * 1. Read DevToolsActivePort from Chrome's default user data directories
427
+ * 2. If found, connect using the port and WebSocket path from that file
428
+ * 3. If not found, probe common debugging ports (9222, 9229)
429
+ * 4. If a port responds, connect via CDP
430
+ */
431
+ private autoConnectViaCDP;
432
+ /**
433
+ * Set up console, error, and close tracking for a page
434
+ */
435
+ private setupPageTracking;
436
+ /**
437
+ * Set up tracking for new pages in a context (for CDP connections and popups/new tabs)
438
+ * This handles pages created externally (e.g., via target="_blank" links, window.open)
439
+ */
440
+ private setupContextTracking;
441
+ /**
442
+ * Create a new tab in the current context
443
+ */
444
+ newTab(): Promise<{
445
+ index: number;
446
+ total: number;
447
+ }>;
448
+ /**
449
+ * Create a new window (new context)
450
+ */
451
+ newWindow(viewport?: {
452
+ width: number;
453
+ height: number;
454
+ } | null): Promise<{
455
+ index: number;
456
+ total: number;
457
+ }>;
458
+ /**
459
+ * Invalidate the current CDP session (must be called before switching pages)
460
+ * This ensures screencast and input injection work correctly after tab switch
461
+ */
462
+ private invalidateCDPSession;
463
+ /**
464
+ * Switch to a specific tab/page by index
465
+ */
466
+ switchTo(index: number): Promise<{
467
+ index: number;
468
+ url: string;
469
+ title: string;
470
+ }>;
471
+ /**
472
+ * Close a specific tab/page
473
+ */
474
+ closeTab(index?: number): Promise<{
475
+ closed: number;
476
+ remaining: number;
477
+ }>;
478
+ /**
479
+ * List all tabs with their info
480
+ */
481
+ listTabs(): Promise<Array<{
482
+ index: number;
483
+ url: string;
484
+ title: string;
485
+ active: boolean;
486
+ }>>;
487
+ /**
488
+ * Get or create a CDP session for the current page
489
+ * Only works with Chromium-based browsers
490
+ */
491
+ getCDPSession(): Promise<CDPSession>;
492
+ /**
493
+ * Check if screencast is currently active
494
+ */
495
+ isScreencasting(): boolean;
496
+ /**
497
+ * Start screencast - streams viewport frames via CDP
498
+ * @param callback Function called for each frame
499
+ * @param options Screencast options
500
+ */
501
+ startScreencast(callback: (frame: ScreencastFrame) => void, options?: ScreencastOptions): Promise<void>;
502
+ /**
503
+ * Stop screencast
504
+ */
505
+ stopScreencast(): Promise<void>;
506
+ /**
507
+ * Check if profiling is currently active
508
+ */
509
+ isProfilingActive(): boolean;
510
+ /**
511
+ * Start CDP profiling (Tracing)
512
+ */
513
+ startProfiling(options?: {
514
+ categories?: string[];
515
+ }): Promise<void>;
516
+ /**
517
+ * Stop CDP profiling and save to file
518
+ */
519
+ stopProfiling(outputPath: string): Promise<{
520
+ path: string;
521
+ eventCount: number;
522
+ }>;
523
+ /**
524
+ * Inject a mouse event via CDP
525
+ */
526
+ injectMouseEvent(params: {
527
+ type: 'mousePressed' | 'mouseReleased' | 'mouseMoved' | 'mouseWheel';
528
+ x: number;
529
+ y: number;
530
+ button?: 'left' | 'right' | 'middle' | 'none';
531
+ clickCount?: number;
532
+ deltaX?: number;
533
+ deltaY?: number;
534
+ modifiers?: number;
535
+ }): Promise<void>;
536
+ /**
537
+ * Inject a keyboard event via CDP
538
+ */
539
+ injectKeyboardEvent(params: {
540
+ type: 'keyDown' | 'keyUp' | 'char';
541
+ key?: string;
542
+ code?: string;
543
+ text?: string;
544
+ modifiers?: number;
545
+ }): Promise<void>;
546
+ /**
547
+ * Inject touch event via CDP (for mobile emulation)
548
+ */
549
+ injectTouchEvent(params: {
550
+ type: 'touchStart' | 'touchEnd' | 'touchMove' | 'touchCancel';
551
+ touchPoints: Array<{
552
+ x: number;
553
+ y: number;
554
+ id?: number;
555
+ }>;
556
+ modifiers?: number;
557
+ }): Promise<void>;
558
+ /**
559
+ * Check if video recording is currently active
560
+ */
561
+ isRecording(): boolean;
562
+ /**
563
+ * Start recording to a video file using Playwright's native video recording.
564
+ * Creates a fresh browser context with video recording enabled.
565
+ * Automatically captures current URL and transfers cookies/storage if no URL provided.
566
+ *
567
+ * @param outputPath - Path to the output video file (will be .webm)
568
+ * @param url - Optional URL to navigate to (defaults to current page URL)
569
+ */
570
+ startRecording(outputPath: string, url?: string): Promise<void>;
571
+ /**
572
+ * Stop recording and save the video file
573
+ * @returns Recording result with path
574
+ */
575
+ stopRecording(): Promise<{
576
+ path: string;
577
+ frames: number;
578
+ error?: string;
579
+ }>;
580
+ /**
581
+ * Restart recording - stops current recording (if any) and starts a new one.
582
+ * Convenience method that combines stopRecording and startRecording.
583
+ *
584
+ * @param outputPath - Path to the output video file (must be .webm)
585
+ * @param url - Optional URL to navigate to (defaults to current page URL)
586
+ * @returns Result from stopping the previous recording (if any)
587
+ */
588
+ restartRecording(outputPath: string, url?: string): Promise<{
589
+ previousPath?: string;
590
+ stopped: boolean;
591
+ }>;
592
+ /**
593
+ * Close the browser and clean up
594
+ */
595
+ close(): Promise<void>;
596
+ }
597
+ export {};
598
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,EACP,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,KAAK,EAIV,KAAK,OAAO,EACZ,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,gBAAgB,EAAiC,MAAM,eAAe,CAAC;AAclG;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAS1C;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB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