nstbrowser-ai-agent 0.0.1

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