agent-browser-stealth 0.14.0-fork.3

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