@xbrowser/cli 0.16.0 → 1.0.2

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 (52) hide show
  1. package/README.md +17 -26
  2. package/dist/{browser-R7B255ML.js → browser-GITRHHFO.js} +4 -1
  3. package/dist/{browser-GWBH6OJK.js → browser-R56O3CW6.js} +3 -1
  4. package/dist/{browser-I2HJZ7IP.js → browser-ZJOZB5CR.js} +4 -2
  5. package/dist/cdp-driver-BE3FOMRN.js +2803 -0
  6. package/dist/cdp-driver-TOPYJIFL.js +47 -0
  7. package/dist/chunk-2SVQTI2O.js +2794 -0
  8. package/dist/{chunk-KDYXFLAC.js → chunk-ACFE6PKF.js} +1015 -121
  9. package/dist/chunk-BBMRDUYQ.js +260 -0
  10. package/dist/chunk-CAFNSGYM.js +4834 -0
  11. package/dist/{chunk-DTJRVA76.js → chunk-ETCO4SNK.js} +2 -2
  12. package/dist/{chunk-RS6YYWTK.js → chunk-JPA2ZT2R.js} +140 -72
  13. package/dist/chunk-JPHCY4TC.js +260 -0
  14. package/dist/chunk-KFQGP6VL.js +33 -0
  15. package/dist/{chunk-ITKPSIP7.js → chunk-MDAPTB7C.js} +6 -25
  16. package/dist/chunk-OZKD3W4X.js +417 -0
  17. package/dist/chunk-PPG4D2EW.js +2796 -0
  18. package/dist/{chunk-ATFTAKMN.js → chunk-Q4IGYTKR.js} +39 -7
  19. package/dist/{chunk-F3ZWFCJJ.js → chunk-QIK2I3VQ.js} +141 -72
  20. package/dist/chunk-WJRE55TN.js +83 -0
  21. package/dist/cli.js +2358 -1086
  22. package/dist/{convert-4DUWZIKH.js → convert-LB3GJTLR.js} +4 -2
  23. package/dist/{convert-EKQVHKB4.js → convert-R3XXYKC6.js} +2 -2
  24. package/dist/{daemon-client-GX2UYIW4.js → daemon-client-DRCUMNHK.js} +45 -72
  25. package/dist/{daemon-client-XWSSQBEA.js → daemon-client-UZZEHHIV.js} +8 -1
  26. package/dist/daemon-main.js +3067 -1688
  27. package/dist/{extract-JUOQQX4V.js → extract-2ZFW2MX7.js} +1 -1
  28. package/dist/{extract-EGRXZSSK.js → extract-BSYBM4MR.js} +2 -0
  29. package/dist/{filter-OLAE26HN.js → filter-KCFO4RSV.js} +2 -0
  30. package/dist/{filter-VID2GGZ7.js → filter-T7DSZ2X7.js} +1 -1
  31. package/dist/{human-interaction-W753RVJB.js → human-interaction-UKAS5ZXV.js} +2 -2
  32. package/dist/index.d.ts +745 -148
  33. package/dist/index.js +3488 -1719
  34. package/dist/launcher-QUJ4M2VS.js +19 -0
  35. package/dist/launcher-YARP45UY.js +19 -0
  36. package/dist/{network-store-YAF5OIBH.js → network-store-XGZ25FFC.js} +1 -0
  37. package/dist/{network-store-BN6QEZ7R.js → network-store-YVDNUREI.js} +1 -1
  38. package/dist/{parse-action-dsl-T3DYC33D.js → parse-action-dsl-UM333TL2.js} +1 -1
  39. package/dist/{proxy-WKGUCH2C.js → proxy-LV4BJ5RC.js} +1 -1
  40. package/dist/session-recorder-RTDGURIJ.js +8 -0
  41. package/dist/session-recorder-YI7YYM36.js +7 -0
  42. package/dist/session-replayer-GLTUICSD.js +276 -0
  43. package/dist/site-knowledge-SYC6VCDB.js +23 -0
  44. package/package.json +6 -6
  45. package/dist/chunk-2ONMTDLK.js +0 -2050
  46. package/dist/daemon-client-3IJD6X4B.js +0 -59
  47. package/dist/network-store-2S5HATEV.js +0 -194
  48. package/dist/parse-action-dsl-DRSPBALP.js +0 -72
  49. package/dist/screenshot-CWAWMXVA.js +0 -28
  50. package/dist/screenshot-MB6R7RSS.js +0 -26
  51. package/dist/session-recorder-ILSSV2UC.js +0 -6
  52. package/dist/session-recorder-XET3DNML.js +0 -7
package/dist/index.d.ts CHANGED
@@ -1,13 +1,426 @@
1
+ import { Tip, CommandContext, CommandScope, XCLIAPI, Core, PluginInstance, PluginStatus } from '@dyyz1993/xcli-core';
2
+ export { PluginStatus, parseCommandArgs, readCommandFile, readStdin, registerCommandDefinition, splitCommand } from '@dyyz1993/xcli-core';
1
3
  import { EventEmitter } from 'events';
2
4
  import { Server } from 'http';
3
- import { Page, Browser, BrowserContext } from 'playwright';
4
- import { CommandContext, CommandScope, XCLIAPI, Core, PluginInstance, PluginStatus } from '@dyyz1993/xcli-core';
5
- export { PluginStatus } from '@dyyz1993/xcli-core';
6
5
  import { ZodType, ZodTypeDef, z } from 'zod';
7
- import * as playwright_core from 'playwright-core';
8
6
 
9
7
  declare const version: any;
10
8
 
9
+ /**
10
+ * XBrowser CDP Driver — Abstract Interface Types
11
+ *
12
+ * Playwright-compatible interfaces backed by raw Chrome DevTools Protocol.
13
+ * All commands and plugins depend on these interfaces, NOT on Playwright.
14
+ *
15
+ * Naming convention: XB prefix (XBrowser) to avoid confusion with Playwright types.
16
+ */
17
+ interface XBBrowser {
18
+ readonly disconnected: boolean;
19
+ close(): Promise<void>;
20
+ newContext(opts?: XBContextOptions): Promise<XBContext>;
21
+ contexts(): XBContext[];
22
+ /**
23
+ * Discover existing browser contexts and pages from the CDP browser.
24
+ * Required when connecting via CDP tunnel (cdp-tunnel) where
25
+ * auto-attach events are unreliable. After this call, `contexts()`
26
+ * returns the user's actual browser contexts (with their existing
27
+ * cookies and login state) instead of an empty list.
28
+ */
29
+ discoverContexts(): Promise<void>;
30
+ on(event: string, handler: Function): void;
31
+ off(event: string, handler: Function): void;
32
+ }
33
+ interface XBContextOptions {
34
+ viewport?: {
35
+ width: number;
36
+ height: number;
37
+ };
38
+ userAgent?: string;
39
+ extraHTTPHeaders?: Record<string, string>;
40
+ ignoreHTTPSErrors?: boolean;
41
+ }
42
+ interface XBContext {
43
+ newPage(): Promise<XBPage>;
44
+ pages(): XBPage[];
45
+ close(): Promise<void>;
46
+ browser(): XBBrowser;
47
+ newCDPSession(page?: XBPage): Promise<XBCDPSession>;
48
+ addInitScript(script: string): Promise<void>;
49
+ cookies(urls?: string | string[]): Promise<XBCookie[]>;
50
+ addCookies(cookies: XBCookie[]): Promise<void>;
51
+ clearCookies(): Promise<void>;
52
+ on(event: string, handler: Function): void;
53
+ off(event: string, handler: Function): void;
54
+ }
55
+ interface XBCookie {
56
+ name: string;
57
+ value: string;
58
+ domain?: string;
59
+ path?: string;
60
+ expires?: number;
61
+ httpOnly?: boolean;
62
+ secure?: boolean;
63
+ sameSite?: 'Strict' | 'Lax' | 'None';
64
+ }
65
+ type WaitUntilState = 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
66
+ interface XBPage {
67
+ goto(url: string, opts?: {
68
+ waitUntil?: WaitUntilState;
69
+ timeout?: number;
70
+ referer?: string;
71
+ }): Promise<XBNavigationResponse | null>;
72
+ goBack(opts?: {
73
+ timeout?: number;
74
+ waitUntil?: WaitUntilState;
75
+ }): Promise<void>;
76
+ goForward(opts?: {
77
+ timeout?: number;
78
+ waitUntil?: WaitUntilState;
79
+ }): Promise<void>;
80
+ reload(opts?: {
81
+ timeout?: number;
82
+ waitUntil?: WaitUntilState;
83
+ }): Promise<void>;
84
+ waitForLoadState(state?: WaitUntilState, timeout?: number): Promise<void>;
85
+ waitForTimeout(ms: number): Promise<void>;
86
+ waitForSelector(selector: string, opts?: {
87
+ state?: 'visible' | 'hidden' | 'attached' | 'detached';
88
+ timeout?: number;
89
+ }): Promise<void>;
90
+ waitForFunction<R>(fn: string | Function, opts?: {
91
+ timeout?: number;
92
+ polling?: number | 'raf';
93
+ }, ...args: unknown[]): Promise<R>;
94
+ waitForURL(url: string | RegExp | ((url: string) => boolean), opts?: {
95
+ timeout?: number;
96
+ waitUntil?: WaitUntilState;
97
+ }): Promise<void>;
98
+ waitForResponse(urlOrPredicate: string | RegExp | ((response: XBResponse) => boolean), opts?: {
99
+ timeout?: number;
100
+ }): Promise<XBResponse>;
101
+ waitForRequest(urlOrPredicate: string | RegExp | ((request: XBRequest) => boolean), opts?: {
102
+ timeout?: number;
103
+ }): Promise<XBRequest>;
104
+ url(): string;
105
+ title(): Promise<string>;
106
+ content(): Promise<string>;
107
+ evaluate<R = unknown>(fn: string | Function, ...args: unknown[]): Promise<R>;
108
+ $eval<R = unknown>(selector: string, fn: string | Function, ...args: unknown[]): Promise<R>;
109
+ $$eval<R = unknown>(selector: string, fn: string | Function, ...args: unknown[]): Promise<R>;
110
+ locator(selector: string): XBLocator;
111
+ getByText(text: string, opts?: {
112
+ exact?: boolean;
113
+ }): XBLocator;
114
+ getByRole(role: string, opts?: {
115
+ name?: string;
116
+ exact?: boolean;
117
+ }): XBLocator;
118
+ getByLabel(label: string, opts?: {
119
+ exact?: boolean;
120
+ }): XBLocator;
121
+ getByPlaceholder(text: string, opts?: {
122
+ exact?: boolean;
123
+ }): XBLocator;
124
+ getByTestId(id: string): XBLocator;
125
+ getByAltText(text: string, opts?: {
126
+ exact?: boolean;
127
+ }): XBLocator;
128
+ getByTitle(title: string, opts?: {
129
+ exact?: boolean;
130
+ }): XBLocator;
131
+ click(selector: string, opts?: XBClickOptions): Promise<void>;
132
+ dblclick(selector: string, opts?: XBClickOptions): Promise<void>;
133
+ fill(selector: string, value: string, opts?: XBFillOptions): Promise<void>;
134
+ press(selector: string, key: string, opts?: {
135
+ timeout?: number;
136
+ }): Promise<void>;
137
+ hover(selector: string, opts?: {
138
+ timeout?: number;
139
+ force?: boolean;
140
+ }): Promise<void>;
141
+ type(selector: string, text: string, opts?: {
142
+ delay?: number;
143
+ timeout?: number;
144
+ }): Promise<void>;
145
+ check(selector: string, opts?: {
146
+ timeout?: number;
147
+ }): Promise<void>;
148
+ uncheck(selector: string, opts?: {
149
+ timeout?: number;
150
+ }): Promise<void>;
151
+ selectOption(selector: string, value: string | string[] | {
152
+ label?: string;
153
+ value?: string;
154
+ index?: number;
155
+ }): Promise<string[]>;
156
+ textContent(selector: string): Promise<string | null>;
157
+ innerText(selector: string): Promise<string>;
158
+ innerHTML(selector: string): Promise<string>;
159
+ getAttribute(selector: string, name: string): Promise<string | null>;
160
+ readonly mouse: XBMouse;
161
+ readonly keyboard: XBKeyboard;
162
+ $(selector: string): Promise<XBElementHandle | null>;
163
+ $$(selector: string): Promise<XBElementHandle[]>;
164
+ screenshot(opts?: XBScreenshotOptions): Promise<Buffer>;
165
+ pdf(opts?: XBPdfOptions): Promise<Buffer>;
166
+ viewportSize(): {
167
+ width: number;
168
+ height: number;
169
+ } | null;
170
+ setViewportSize(size: {
171
+ width: number;
172
+ height: number;
173
+ }): Promise<void>;
174
+ addInitScript(script: string): Promise<void>;
175
+ bringToFront(): Promise<void>;
176
+ setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
177
+ setOfflineMode(offline: boolean): Promise<void>;
178
+ route(url: string | RegExp, handler: (route: XBRoute) => Promise<void> | void): Promise<void>;
179
+ unroute(url: string | RegExp, handler?: (route: XBRoute) => Promise<void> | void): Promise<void>;
180
+ setInputFiles(selector: string, files: XBFilePayload | XBFilePayload[]): Promise<void>;
181
+ dragAndDrop(source: string, target: string): Promise<void>;
182
+ on(event: string, handler: Function): void;
183
+ off(event: string, handler: Function): void;
184
+ waitForEvent(event: string, opts?: {
185
+ timeout?: number;
186
+ predicate?: (...args: unknown[]) => boolean;
187
+ }): Promise<unknown>;
188
+ _cdpSend<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
189
+ _subscribe(event: string, handler: (params: unknown) => void): () => void;
190
+ close(): Promise<void>;
191
+ isClosed(): boolean;
192
+ context(): XBContext;
193
+ browser(): XBBrowser;
194
+ mainFrame(): XBFrame;
195
+ frames(): XBFrame[];
196
+ }
197
+ /** Response from navigation (goto). Playwright-compatible subset. */
198
+ interface XBNavigationResponse {
199
+ status(): number;
200
+ ok(): boolean;
201
+ url(): string;
202
+ headers(): Record<string, string>;
203
+ }
204
+ interface XBLocator {
205
+ click(opts?: XBClickOptions): Promise<void>;
206
+ fill(value: string, opts?: XBFillOptions): Promise<void>;
207
+ press(key: string, opts?: {
208
+ timeout?: number;
209
+ }): Promise<void>;
210
+ pressSequentially(text: string, opts?: {
211
+ delay?: number;
212
+ timeout?: number;
213
+ }): Promise<void>;
214
+ hover(opts?: {
215
+ timeout?: number;
216
+ force?: boolean;
217
+ }): Promise<void>;
218
+ type(text: string, opts?: {
219
+ delay?: number;
220
+ timeout?: number;
221
+ }): Promise<void>;
222
+ check(opts?: {
223
+ timeout?: number;
224
+ }): Promise<void>;
225
+ uncheck(opts?: {
226
+ timeout?: number;
227
+ }): Promise<void>;
228
+ selectOption(value: string | string[] | {
229
+ label?: string;
230
+ value?: string;
231
+ index?: number;
232
+ }): Promise<string[]>;
233
+ screenshot(opts?: XBScreenshotOptions): Promise<Buffer>;
234
+ focus(): Promise<void>;
235
+ waitFor(opts?: {
236
+ state?: 'visible' | 'hidden' | 'attached' | 'detached';
237
+ timeout?: number;
238
+ }): Promise<void>;
239
+ count(): Promise<number>;
240
+ isVisible(): Promise<boolean>;
241
+ isHidden(): Promise<boolean>;
242
+ isEnabled(): Promise<boolean>;
243
+ isDisabled(): Promise<boolean>;
244
+ boundingBox(): Promise<{
245
+ x: number;
246
+ y: number;
247
+ width: number;
248
+ height: number;
249
+ } | null>;
250
+ textContent(): Promise<string | null>;
251
+ innerText(): Promise<string>;
252
+ innerHTML(): Promise<string>;
253
+ getAttribute(name: string): Promise<string | null>;
254
+ evaluate<R = unknown>(fn: string | Function, ...args: unknown[]): Promise<R>;
255
+ ariaSnapshot(): Promise<string>;
256
+ first(): XBLocator;
257
+ last(): XBLocator;
258
+ nth(index: number): XBLocator;
259
+ filter(opts: {
260
+ visible?: boolean;
261
+ }): XBLocator;
262
+ all(): Promise<XBLocator[]>;
263
+ }
264
+ interface XBElementHandle {
265
+ click(opts?: XBClickOptions): Promise<void>;
266
+ fill(value: string, opts?: XBFillOptions): Promise<void>;
267
+ hover(): Promise<void>;
268
+ press(key: string): Promise<void>;
269
+ screenshot(opts?: XBScreenshotOptions): Promise<Buffer>;
270
+ boundingBox(): Promise<{
271
+ x: number;
272
+ y: number;
273
+ width: number;
274
+ height: number;
275
+ } | null>;
276
+ isVisible(): Promise<boolean>;
277
+ isEnabled(): Promise<boolean>;
278
+ textContent(): Promise<string | null>;
279
+ innerText(): Promise<string>;
280
+ innerHTML(): Promise<string>;
281
+ getAttribute(name: string): Promise<string | null>;
282
+ scrollIntoViewIfNeeded(): Promise<void>;
283
+ dispose(): void;
284
+ }
285
+ interface XBMouse {
286
+ click(x: number, y: number, opts?: {
287
+ button?: 'left' | 'right' | 'middle';
288
+ clickCount?: number;
289
+ delay?: number;
290
+ }): Promise<void>;
291
+ dblclick(x: number, y: number, opts?: {
292
+ button?: 'left' | 'right' | 'middle';
293
+ }): Promise<void>;
294
+ down(opts?: {
295
+ button?: 'left' | 'right' | 'middle';
296
+ }): Promise<void>;
297
+ up(opts?: {
298
+ button?: 'left' | 'right' | 'middle';
299
+ }): Promise<void>;
300
+ move(x: number, y: number, opts?: {
301
+ steps?: number;
302
+ }): Promise<void>;
303
+ wheel(deltaX: number, deltaY: number): Promise<void>;
304
+ }
305
+ interface XBKeyboard {
306
+ press(key: string, opts?: {
307
+ delay?: number;
308
+ }): Promise<void>;
309
+ down(key: string): Promise<void>;
310
+ up(key: string): Promise<void>;
311
+ type(text: string, opts?: {
312
+ delay?: number;
313
+ }): Promise<void>;
314
+ insertText(text: string): Promise<void>;
315
+ }
316
+ interface XBFrame {
317
+ url(): string;
318
+ name(): string;
319
+ isDetached(): boolean;
320
+ page(): XBPage;
321
+ evaluate<R = unknown>(fn: string | Function, ...args: unknown[]): Promise<R>;
322
+ $(selector: string): Promise<XBElementHandle | null>;
323
+ $$(selector: string): Promise<XBElementHandle[]>;
324
+ }
325
+ interface XBCDPSession {
326
+ send<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
327
+ on(event: string, handler: Function): void;
328
+ off(event: string, handler: Function): void;
329
+ detach(): Promise<void>;
330
+ }
331
+ interface XBClickOptions {
332
+ button?: 'left' | 'right' | 'middle';
333
+ clickCount?: number;
334
+ delay?: number;
335
+ timeout?: number;
336
+ force?: boolean;
337
+ noWaitAfter?: boolean;
338
+ position?: {
339
+ x: number;
340
+ y: number;
341
+ };
342
+ trial?: boolean;
343
+ }
344
+ interface XBFillOptions {
345
+ timeout?: number;
346
+ force?: boolean;
347
+ noWaitAfter?: boolean;
348
+ }
349
+ interface XBScreenshotOptions {
350
+ type?: 'png' | 'jpeg';
351
+ quality?: number;
352
+ fullPage?: boolean;
353
+ clip?: {
354
+ x: number;
355
+ y: number;
356
+ width: number;
357
+ height: number;
358
+ };
359
+ omitBackground?: boolean;
360
+ timeout?: number;
361
+ }
362
+ interface XBPdfOptions {
363
+ format?: string;
364
+ landscape?: boolean;
365
+ printBackground?: boolean;
366
+ scale?: number;
367
+ margin?: {
368
+ top?: string;
369
+ bottom?: string;
370
+ left?: string;
371
+ right?: string;
372
+ };
373
+ preferCSSPageSize?: boolean;
374
+ }
375
+ interface XBResponse {
376
+ status(): number;
377
+ statusText(): string;
378
+ url(): string;
379
+ headers(): Record<string, string>;
380
+ ok(): boolean;
381
+ body(): Promise<Buffer>;
382
+ text(): Promise<string>;
383
+ json(): Promise<unknown>;
384
+ request(): XBRequest;
385
+ }
386
+ interface XBRoute {
387
+ request(): XBRequest;
388
+ abort(errorCode?: string): Promise<void>;
389
+ continue(opts?: {
390
+ url?: string;
391
+ method?: string;
392
+ headers?: Record<string, string>;
393
+ postData?: string;
394
+ }): Promise<void>;
395
+ fulfill(opts: {
396
+ status?: number;
397
+ headers?: Record<string, string>;
398
+ body?: string | Buffer;
399
+ contentType?: string;
400
+ }): Promise<void>;
401
+ }
402
+ interface XBFilePayload {
403
+ name: string;
404
+ mimeType: string;
405
+ buffer: Buffer;
406
+ }
407
+ interface XBRequest {
408
+ url(): string;
409
+ method(): string;
410
+ headers(): Record<string, string>;
411
+ postData(): string | null;
412
+ resourceType(): string;
413
+ response(): Promise<XBResponse | null>;
414
+ }
415
+ interface XBRequest {
416
+ url(): string;
417
+ method(): string;
418
+ headers(): Record<string, string>;
419
+ postData(): string | null;
420
+ resourceType(): string;
421
+ response(): Promise<XBResponse | null>;
422
+ }
423
+
11
424
  /**
12
425
  * Configuration for the WebSocket server.
13
426
  */
@@ -54,6 +467,9 @@ type WSMessage = {
54
467
  success: boolean;
55
468
  fileName: string;
56
469
  error?: string;
470
+ } | {
471
+ type: 'file_input_clicked';
472
+ selector: string;
57
473
  } | {
58
474
  type: 'file_list_result';
59
475
  path: string;
@@ -70,6 +486,9 @@ type WSMessage = {
70
486
  mimeType: string;
71
487
  data: string;
72
488
  error?: string;
489
+ } | {
490
+ type: 'views_update';
491
+ views: ViewInfo[];
73
492
  } | {
74
493
  type: 'error';
75
494
  data: {
@@ -78,6 +497,16 @@ type WSMessage = {
78
497
  availableSessions?: string[];
79
498
  };
80
499
  };
500
+ interface ViewInfo {
501
+ id: string;
502
+ label: string;
503
+ rect: {
504
+ x: number;
505
+ y: number;
506
+ width: number;
507
+ height: number;
508
+ };
509
+ }
81
510
  /**
82
511
  * Inbound WebSocket message types received from clients.
83
512
  */
@@ -136,6 +565,16 @@ type WSInboundMessage = {
136
565
  selector: string;
137
566
  } | {
138
567
  type: 'focus_clear';
568
+ } | {
569
+ type: 'input_blur';
570
+ } | {
571
+ type: 'select_view';
572
+ rect: {
573
+ x: number;
574
+ y: number;
575
+ width: number;
576
+ height: number;
577
+ } | null;
139
578
  };
140
579
  /**
141
580
  * A screencast frame message with binary image data.
@@ -186,71 +625,46 @@ interface StatusMessage {
186
625
  *
187
626
  * **Lazy screencast**: Screencast capture only starts when the first WS client
188
627
  * binds to a session, and stops when the last client for that session disconnects.
628
+ *
629
+ * Responsibilities are delegated to:
630
+ * - **SessionManager**: client/session lifecycle, capturer start/stop, element monitors
631
+ * - **StreamCoordinator**: frame processing, stream state, crop management
632
+ * - **MessageDispatcher**: inbound message routing to typed handlers
189
633
  */
190
634
  declare class WSServer extends EventEmitter {
191
635
  private port;
192
636
  private host;
193
- private clients;
194
- private sessionClients;
195
- private screencasts;
196
637
  private wsServer;
197
638
  private isRunning;
198
- private stateManager;
199
- private frameRateController;
200
- private frameProcessor;
201
- private lastFrameData;
202
- private lastFrameViewport;
203
- private sessionCrops;
639
+ private readonly streamCoordinator;
640
+ private readonly sessionManager;
641
+ private readonly messageDispatcher;
204
642
  constructor(config?: WSServerConfig);
205
- private processAndBroadcast;
206
- /**
207
- * Register a session page for screencast streaming.
208
- * Call this when a session is created. The capturer will only start
209
- * when a WS client binds to this session.
210
- */
211
- registerSession(sessionId: string, page: Page, options?: {
643
+ private setupSessionManagerEvents;
644
+ registerSession(sessionId: string, page: XBPage, options?: {
212
645
  interval?: number;
213
646
  quality?: number;
214
647
  type?: 'jpeg' | 'png';
215
648
  width?: number;
216
649
  height?: number;
217
650
  }): void;
218
- /**
219
- * Unregister a session. Stops screencast if running.
220
- */
221
651
  unregisterSession(sessionId: string): void;
222
- /**
223
- * Start standalone WS server on its own port.
224
- */
652
+ pauseScreencast(sessionId: string): Promise<void>;
653
+ resumeScreencast(sessionId: string): Promise<void>;
654
+ private startScreencastIfNeeded;
655
+ private stopScreencastIfNeeded;
656
+ bindClientToSession(clientId: string, sessionId: string): void;
657
+ private sendBoundStatus;
225
658
  start(): Promise<void>;
226
- /**
227
- * Attach to an existing HTTP server via WS upgrade.
228
- * Shares the same port as the HTTP server (e.g., daemon port 9224).
229
- * The WS path defaults to `/preview`.
230
- */
231
659
  attachToServer(httpServer: Server, path?: string): Promise<void>;
232
- /**
233
- * Set up the connection handler for incoming WS connections.
234
- * When attached to an HTTP server, the third argument carries the sessionId
235
- * extracted from the URL path (e.g., /preview/default).
236
- */
660
+ stop(): Promise<void>;
237
661
  private setupConnectionHandler;
238
- /**
239
- * Lazy screencast: start when first client binds, stop when last unbinds.
240
- */
241
- private startScreencastIfNeeded;
242
- private stopScreencastIfNeeded;
243
- pauseScreencast(sessionId: string): Promise<void>;
244
- resumeScreencast(sessionId: string): Promise<void>;
245
- private sendToClient;
246
- private getClientPage;
247
662
  private handleInboundMessage;
248
- stop(): Promise<void>;
249
- bindClientToSession(clientId: string, sessionId: string): void;
663
+ private handleClientDisconnect;
664
+ private sendToClient;
250
665
  broadcastToSession(sessionId: string, message: WSMessage): void;
251
666
  broadcast(message: WSMessage): void;
252
667
  broadcastBinaryToSession(sessionId: string, payload: Buffer): void;
253
- private handleClientDisconnect;
254
668
  getClientCount(): number;
255
669
  getSessionClientCount(sessionId: string): number;
256
670
  getRunning(): boolean;
@@ -269,7 +683,7 @@ interface ExecutionResult {
269
683
  data: unknown;
270
684
  message?: string;
271
685
  duration: number;
272
- tips?: string[];
686
+ tips?: Tip[];
273
687
  hookOutputs?: HookOutput[];
274
688
  }
275
689
  /**
@@ -282,7 +696,7 @@ interface ChainStepResult {
282
696
  data: unknown;
283
697
  message?: string;
284
698
  duration: number;
285
- tips?: string[];
699
+ tips?: Tip[];
286
700
  hookOutputs?: HookOutput[];
287
701
  }
288
702
  /**
@@ -530,7 +944,7 @@ declare class HumanInteractionManager {
530
944
  private capturer;
531
945
  private webhook;
532
946
  private autoOpen;
533
- constructor(wsServer: WSServer, page: Page);
947
+ constructor(wsServer: WSServer, page: XBPage);
534
948
  private sendWebhook;
535
949
  private tryAutoOpen;
536
950
  /**
@@ -552,9 +966,9 @@ declare class HumanInteractionManager {
552
966
  * along with an optional `waitForHuman` function for CAPTCHA handling.
553
967
  */
554
968
  interface BrowserCommandContext extends CommandContext {
555
- page: Page;
556
- browser: Browser;
557
- browserContext: BrowserContext;
969
+ page: XBPage;
970
+ browser: XBBrowser;
971
+ browserContext: XBContext;
558
972
  sessionId?: string;
559
973
  cdpEndpoint?: string;
560
974
  waitForHuman?: (options?: WaitForHumanOptions) => Promise<WaitForHumanResult>;
@@ -574,7 +988,7 @@ declare function checkBrowserScope(scope: CommandScope, ctx: BrowserCommandConte
574
988
  * @throws If no active page is available in the context.
575
989
  */
576
990
  declare function assertPageScope(ctx: BrowserCommandContext): asserts ctx is BrowserCommandContext & {
577
- page: Page;
991
+ page: XBPage;
578
992
  };
579
993
  /**
580
994
  * Attach a `waitForHuman` function to the browser command context.
@@ -585,21 +999,21 @@ declare function assertPageScope(ctx: BrowserCommandContext): asserts ctx is Bro
585
999
  * @param ctx - The browser command context to augment.
586
1000
  * @param getOrCreateWSServer - Factory that returns a WSServer for the given BrowserContext.
587
1001
  */
588
- declare function attachWaitForHuman(ctx: BrowserCommandContext, getOrCreateWSServer: (browserContext: BrowserContext) => Promise<WSServer>): void;
1002
+ declare function attachWaitForHuman(ctx: BrowserCommandContext, getOrCreateWSServer: (browserContext: XBContext) => Promise<WSServer>): void;
589
1003
  /**
590
1004
  * Retrieve a cached WSServer instance for the given BrowserContext.
591
1005
  *
592
1006
  * @param browserContext - The Playwright BrowserContext.
593
1007
  * @returns The cached WSServer, or `undefined` if none is cached.
594
1008
  */
595
- declare function getWSServerFromCache(browserContext: BrowserContext): WSServer | undefined;
1009
+ declare function getWSServerFromCache(browserContext: XBContext): WSServer | undefined;
596
1010
  /**
597
1011
  * Cache a WSServer instance for the given BrowserContext.
598
1012
  *
599
1013
  * @param browserContext - The Playwright BrowserContext.
600
1014
  * @param server - The WSServer to associate with this context.
601
1015
  */
602
- declare function setWSServerCache(browserContext: BrowserContext, server: WSServer): void;
1016
+ declare function setWSServerCache(browserContext: XBContext, server: WSServer): void;
603
1017
 
604
1018
  /**
605
1019
  * Represents a managed browser session with its Playwright context, page,
@@ -608,9 +1022,9 @@ declare function setWSServerCache(browserContext: BrowserContext, server: WSServ
608
1022
  interface ManagedSession {
609
1023
  id: string;
610
1024
  name: string;
611
- context: BrowserContext;
612
- page: Page;
613
- browser: Browser;
1025
+ context: XBContext;
1026
+ page: XBPage;
1027
+ browser: XBBrowser;
614
1028
  createdAt: string;
615
1029
  lastActivityAt: number;
616
1030
  isCDP?: boolean;
@@ -640,7 +1054,7 @@ interface BrowserLaunchOptions {
640
1054
  * const browser = await getBrowser({ headless: true });
641
1055
  * ```
642
1056
  */
643
- declare function getBrowser(options?: BrowserLaunchOptions): Promise<Browser>;
1057
+ declare function getBrowser(options?: BrowserLaunchOptions): Promise<XBBrowser>;
644
1058
  /**
645
1059
  * Find a managed session by its name.
646
1060
  *
@@ -855,23 +1269,6 @@ interface AISearchResult {
855
1269
  */
856
1270
  declare function routeCommand(argv: string[], stdinCommands?: string[]): Promise<void>;
857
1271
 
858
- /**
859
- * Read non-empty, non-comment lines from stdin.
860
- *
861
- * Returns an empty array when stdin is a TTY. Lines starting with `#` are
862
- * treated as comments and skipped.
863
- *
864
- * @returns Array of trimmed, non-comment lines.
865
- */
866
- declare function readStdin(): Promise<string[]>;
867
- /**
868
- * Read a command file and return non-empty, non-comment lines.
869
- *
870
- * @param filePath - Path to the file to read.
871
- * @returns Array of trimmed, non-comment lines.
872
- */
873
- declare function readCommandFile(filePath: string): string[];
874
-
875
1272
  /**
876
1273
  * Open a new browser session, navigate to the given URL, and persist session metadata.
877
1274
  *
@@ -915,7 +1312,7 @@ declare function listSessions(): Promise<Array<{
915
1312
  * @param name - The session name. Defaults to "default".
916
1313
  * @returns The page instance, or `null` if the session does not exist.
917
1314
  */
918
- declare function getSessionPage(name?: string, cdpEndpoint?: string): Promise<playwright_core.Page | null>;
1315
+ declare function getSessionPage(name?: string, cdpEndpoint?: string): Promise<XBPage | null>;
919
1316
 
920
1317
  /**
921
1318
  * A built-in CLI command with help text and an execute function.
@@ -957,6 +1354,80 @@ declare const allBuiltins: BuiltinCommand[];
957
1354
  */
958
1355
  declare function getBuiltin(name: string): BuiltinCommand | undefined;
959
1356
 
1357
+ interface XBrowserPluginMetadata {
1358
+ id: string;
1359
+ name: string;
1360
+ description: string;
1361
+ version: string;
1362
+ author: string;
1363
+ homepage?: string;
1364
+ commands?: string[];
1365
+ sites?: string[];
1366
+ tags?: string[];
1367
+ screenshot?: string;
1368
+ license?: string;
1369
+ }
1370
+ type PluginFormWidget = 'text' | 'textarea' | 'number' | 'checkbox' | 'select' | 'multi-select' | 'json' | 'file' | 'url' | 'password';
1371
+ type PluginCapability = 'browser.page' | 'browser.context' | 'browser.cdp' | 'network' | 'storage' | 'filesystem' | 'external-api' | 'auth.login' | (string & {});
1372
+ interface PluginFormField {
1373
+ name: string;
1374
+ label: string;
1375
+ type: string;
1376
+ widget: PluginFormWidget;
1377
+ required: boolean;
1378
+ description?: string;
1379
+ default?: unknown;
1380
+ enum?: string[];
1381
+ positional?: boolean;
1382
+ placeholder?: string;
1383
+ secret?: boolean;
1384
+ multiple?: boolean;
1385
+ }
1386
+ interface PluginCommandContractExtension {
1387
+ category?: string;
1388
+ capabilities?: PluginCapability[];
1389
+ positional?: string[];
1390
+ form?: {
1391
+ title?: string;
1392
+ description?: string;
1393
+ submitLabel?: string;
1394
+ fields?: Partial<PluginFormField>[];
1395
+ };
1396
+ output?: {
1397
+ schema?: unknown;
1398
+ examples?: unknown[];
1399
+ };
1400
+ }
1401
+ interface PluginCommandContract {
1402
+ name: string;
1403
+ description: string;
1404
+ scope: string;
1405
+ requiresLogin: boolean;
1406
+ category?: string;
1407
+ capabilities: PluginCapability[];
1408
+ positional: string[];
1409
+ form: {
1410
+ title: string;
1411
+ description?: string;
1412
+ submitLabel: string;
1413
+ fields: PluginFormField[];
1414
+ };
1415
+ output?: PluginCommandContractExtension['output'];
1416
+ }
1417
+ interface PluginContract {
1418
+ version: 2;
1419
+ plugin: {
1420
+ name: string;
1421
+ url?: string;
1422
+ description?: string;
1423
+ requiresLogin?: boolean;
1424
+ };
1425
+ commands: PluginCommandContract[];
1426
+ }
1427
+ interface PluginListOptions {
1428
+ json?: boolean;
1429
+ }
1430
+
960
1431
  /**
961
1432
  * Options for configuring the plugin loader's search directories.
962
1433
  */
@@ -985,6 +1456,7 @@ declare class XBrowserPluginLoader {
985
1456
  getPlugin(id: string): PluginInstance | undefined;
986
1457
  getPluginStatus(id: string): PluginStatus;
987
1458
  getLoadedPlugins(): PluginInstance[];
1459
+ getPluginContract(siteName: string, commandName?: string): PluginContract | PluginCommandContract | undefined;
988
1460
  loadPlugin(pluginPath: string, id?: string): Promise<PluginInstance>;
989
1461
  unloadPlugin(id: string): Promise<void>;
990
1462
  reloadPlugin(id: string): Promise<PluginInstance>;
@@ -993,23 +1465,6 @@ declare class XBrowserPluginLoader {
993
1465
  unload(): Promise<void>;
994
1466
  }
995
1467
 
996
- interface XBrowserPluginMetadata {
997
- id: string;
998
- name: string;
999
- description: string;
1000
- version: string;
1001
- author: string;
1002
- homepage?: string;
1003
- commands?: string[];
1004
- sites?: string[];
1005
- tags?: string[];
1006
- screenshot?: string;
1007
- license?: string;
1008
- }
1009
- interface PluginListOptions {
1010
- json?: boolean;
1011
- }
1012
-
1013
1468
  interface InstalledPlugin {
1014
1469
  id: string;
1015
1470
  name: string;
@@ -1104,7 +1559,7 @@ declare class RecorderController {
1104
1559
  private startTime;
1105
1560
  private startUrl;
1106
1561
  private name;
1107
- constructor(page: Page);
1562
+ constructor(page: XBPage);
1108
1563
  /**
1109
1564
  * Start recording browser interactions.
1110
1565
  *
@@ -1177,7 +1632,7 @@ interface ClickContext {
1177
1632
  }
1178
1633
  interface UserAction {
1179
1634
  id: number;
1180
- type: 'click' | 'input' | 'change' | 'keydown' | 'submit' | 'scroll';
1635
+ type: 'click' | 'input' | 'change' | 'keydown' | 'submit' | 'scroll' | 'navigation' | 'goto' | 'cdp-fill' | 'cdp-click' | 'cdp-eval' | 'filechooser' | 'dblclick' | 'contextmenu' | 'hover' | 'drag' | 'resize' | 'clipboard' | 'touch' | 'focus' | 'visibility';
1181
1636
  timestamp: number;
1182
1637
  url: string;
1183
1638
  pageTitle: string;
@@ -1185,6 +1640,21 @@ interface UserAction {
1185
1640
  tag: string;
1186
1641
  selector?: string;
1187
1642
  text: string;
1643
+ /** Which strategy from generateUniqueSelector produced this selector */
1644
+ strategy?: string;
1645
+ /** Reliability rating from generateUniqueSelector: high / medium / low */
1646
+ confidence?: 'high' | 'medium' | 'low';
1647
+ /** Text-based fallback for low-confidence selectors (e.g. menu items) */
1648
+ textFallback?: {
1649
+ type: 'text';
1650
+ value: string;
1651
+ selector: string;
1652
+ };
1653
+ /** Popup/menu context when element is inside a dropdown */
1654
+ popup?: {
1655
+ containerSelector: string;
1656
+ containerText: string;
1657
+ };
1188
1658
  role?: string;
1189
1659
  type?: string;
1190
1660
  placeholder?: string;
@@ -1199,6 +1669,77 @@ interface UserAction {
1199
1669
  scrollY?: number;
1200
1670
  /** Click context: popover/dropdown/menu items captured 200ms after click */
1201
1671
  clickContext?: ClickContext;
1672
+ /** File upload info (type=filechooser only) */
1673
+ files?: {
1674
+ names: string[];
1675
+ count: number;
1676
+ isMultiple: boolean;
1677
+ fileData?: Array<{
1678
+ name: string;
1679
+ type: string;
1680
+ size: number;
1681
+ dataUrl: string | null;
1682
+ }>;
1683
+ };
1684
+ /** Drag & drop info (type=drag only) */
1685
+ drag?: {
1686
+ fromX: number;
1687
+ fromY: number;
1688
+ toX: number;
1689
+ toY: number;
1690
+ /** Source element description */
1691
+ source?: {
1692
+ tag: string;
1693
+ selector?: string;
1694
+ text: string;
1695
+ };
1696
+ /** Target (drop zone) element description */
1697
+ target?: {
1698
+ tag: string;
1699
+ selector?: string;
1700
+ text: string;
1701
+ };
1702
+ };
1703
+ /** Resize info (type=resize only) */
1704
+ resize?: {
1705
+ width: number;
1706
+ height: number;
1707
+ };
1708
+ /** Clipboard info (type=clipboard only) */
1709
+ clipboard?: {
1710
+ operation: 'copy' | 'paste' | 'cut';
1711
+ textPreview?: string;
1712
+ };
1713
+ /** Touch info (type=touch only) */
1714
+ touch?: {
1715
+ touchType: 'start' | 'move' | 'end';
1716
+ touches: Array<{
1717
+ x: number;
1718
+ y: number;
1719
+ }>;
1720
+ };
1721
+ /** Focus info (type=focus only) */
1722
+ focus?: {
1723
+ focusType: 'focus' | 'blur';
1724
+ };
1725
+ /** Visibility info (type=visibility only) */
1726
+ visibility?: {
1727
+ state: 'visible' | 'hidden';
1728
+ };
1729
+ /** Mouse trajectory from previous action's position to this action's position.
1730
+ * Captured as simplified waypoints with relative timestamps for realistic replay. */
1731
+ trajectory?: {
1732
+ /** Waypoints: [x, y, deltaMs from previous point] */
1733
+ points: Array<{
1734
+ x: number;
1735
+ y: number;
1736
+ dt: number;
1737
+ }>;
1738
+ /** Total distance in pixels (approximate) */
1739
+ distance: number;
1740
+ /** Total duration in ms */
1741
+ duration: number;
1742
+ };
1202
1743
  }
1203
1744
  interface NetworkEntry {
1204
1745
  id: number;
@@ -1299,10 +1840,24 @@ declare class SessionRecorder {
1299
1840
  private flushTimer;
1300
1841
  private lastActionTs;
1301
1842
  private activePages;
1843
+ private lastKnownUrl;
1844
+ /** Dedup window: after a CDP command action, ignore matching action signals within this window */
1845
+ private cdpActionDedup;
1846
+ /** Network dedup: last request key for short-window dedup */
1847
+ private _lastRequestKey;
1848
+ private _lastRequestTs;
1302
1849
  private _isRecording;
1303
- constructor(context: BrowserContext, page: Page, sessionName: string);
1850
+ constructor(context: XBContext, page: XBPage, sessionName: string);
1304
1851
  get isRecording(): boolean;
1305
1852
  get actionCount(): number;
1853
+ /** Record an action triggered by a CDP command (e.g. xbrowser fill/click/goto) */
1854
+ recordCommandAction(action: {
1855
+ type: string;
1856
+ selector?: string;
1857
+ value?: string;
1858
+ url?: string;
1859
+ element?: UserAction['element'];
1860
+ }): void;
1306
1861
  get networkCount(): number;
1307
1862
  getLiveData(): RecordingData;
1308
1863
  addManualCheckpoint(type: string, hint: string, selector?: string): CheckpointEntry;
@@ -1329,6 +1884,7 @@ declare class SessionRecorder {
1329
1884
  private handleNewPage;
1330
1885
  private handleFrameNavigated;
1331
1886
  private handleDialog;
1887
+ private handleFileChooser;
1332
1888
  private pollActions;
1333
1889
  private flushPendingActions;
1334
1890
  /**
@@ -1386,7 +1942,7 @@ declare class PlaybackEngine {
1386
1942
  private page;
1387
1943
  private recording;
1388
1944
  private checkpoints;
1389
- constructor(page: Page, recording: RecordingSession);
1945
+ constructor(page: XBPage, recording: RecordingSession);
1390
1946
  /**
1391
1947
  * Create a PlaybackEngine from a YAML recording file.
1392
1948
  *
@@ -1394,7 +1950,7 @@ declare class PlaybackEngine {
1394
1950
  * @param filePath - Path to the YAML recording file.
1395
1951
  * @returns A new PlaybackEngine instance.
1396
1952
  */
1397
- static fromFile(page: Page, filePath: string): PlaybackEngine;
1953
+ static fromFile(page: XBPage, filePath: string): PlaybackEngine;
1398
1954
  withCheckpoints(checkpoints: CheckpointEntry[]): PlaybackEngine;
1399
1955
  play(options?: PlaybackOptions): Promise<PlaybackResult>;
1400
1956
  private executeEvent;
@@ -1452,7 +2008,7 @@ declare class CaptchaDetector {
1452
2008
  * @param page - The Playwright page to scan.
1453
2009
  * @returns Detection result with type, selector, and confidence level.
1454
2010
  */
1455
- static detect(page: Page): Promise<CaptchaDetectionResult>;
2011
+ static detect(page: XBPage): Promise<CaptchaDetectionResult>;
1456
2012
  /**
1457
2013
  * Check whether a previously detected CAPTCHA has been solved.
1458
2014
  *
@@ -1460,7 +2016,7 @@ declare class CaptchaDetector {
1460
2016
  * @param previousSelector - The selector from a previous detection result.
1461
2017
  * @returns `true` if the CAPTCHA is no longer visible.
1462
2018
  */
1463
- static isSolved(page: Page, previousSelector?: string): Promise<boolean>;
2019
+ static isSolved(page: XBPage, previousSelector?: string): Promise<boolean>;
1464
2020
  }
1465
2021
 
1466
2022
  /**
@@ -1520,7 +2076,7 @@ declare class ScreencastCapturer {
1520
2076
  * If CDP session creation fails (non-Chromium, restricted access),
1521
2077
  * automatically falls back to `page.screenshot()` polling.
1522
2078
  */
1523
- startCapture(page: Page, sessionId: string, onFrame: (frame: ScreencastFrame) => void): Promise<void>;
2079
+ startCapture(page: XBPage, sessionId: string, onFrame: (frame: ScreencastFrame) => void): Promise<void>;
1524
2080
  /**
1525
2081
  * Fallback: periodic page.screenshot() polling when CDP Cast is unavailable.
1526
2082
  */
@@ -1771,52 +2327,92 @@ interface ParseOptions {
1771
2327
  * @param input - The raw command chain string.
1772
2328
  * @param options - Parse options; `fileMode` treats single `|` as a pipeline separator.
1773
2329
  * @returns Array of parsed pipelines, each with commands and a chain type.
1774
- *
1775
- * @example
1776
- * ```ts
1777
- * const pipelines = parseCommandChain('goto https://example.com && click #btn');
1778
- * // [{ pipeline: ['goto https://example.com', 'click #btn'], type: 'and' }]
1779
- * ```
1780
2330
  */
1781
2331
  declare function parseCommandChain(input: string, options?: ParseOptions): ParsedPipeline[];
1782
- /**
1783
- * Split a command string into whitespace-separated tokens, respecting quotes.
1784
- *
1785
- * @param cmdStr - The raw command string (e.g. `"click '#my-btn'"`).
1786
- * @returns Array of string tokens.
1787
- */
1788
- declare function splitCommand(cmdStr: string): string[];
1789
- /**
1790
- * Parse positional and flagged arguments into a parameter object.
1791
- *
1792
- * Supports `--key value`, `-s value` (short flags), and positional arguments
1793
- * mapped via registered command definitions. Values are automatically coerced
1794
- * to boolean, number, or string.
1795
- *
1796
- * @param name - The command name (used to look up positional parameter names).
1797
- * @param args - Array of argument strings.
1798
- * @returns An object with the command name and parsed params.
1799
- *
1800
- * @example
1801
- * ```ts
1802
- * const { params } = parseCommandArgs('fill', ['#email', 'hello']);
1803
- * // { command: 'fill', params: { selector: '#email', value: 'hello' } }
1804
- * ```
1805
- */
1806
- declare function parseCommandArgs(name: string, args: string[]): {
1807
- command: string;
1808
- params: Record<string, unknown>;
1809
- };
1810
- /**
1811
- * Register positional parameter names for a command used by {@link parseCommandArgs}.
1812
- *
1813
- * @param name - The command name.
1814
- * @param positional - Ordered array of positional parameter names.
1815
- */
1816
- declare function registerCommandDefinition(name: string, positional: string[]): void;
1817
2332
 
1818
2333
  declare function normalizeSelector(input: string): string;
1819
2334
 
2335
+ type AgentTargetAction = 'click' | 'fill' | 'type' | 'press' | 'select' | 'check' | 'hover';
2336
+ interface AgentTarget {
2337
+ ref: string;
2338
+ selector: string;
2339
+ role: string;
2340
+ name: string;
2341
+ tag: string;
2342
+ visible: boolean;
2343
+ enabled: boolean;
2344
+ editable: boolean;
2345
+ checked?: boolean;
2346
+ value?: string;
2347
+ box?: {
2348
+ x: number;
2349
+ y: number;
2350
+ width: number;
2351
+ height: number;
2352
+ };
2353
+ actions: AgentTargetAction[];
2354
+ }
2355
+ interface AgentObservation {
2356
+ url: string;
2357
+ title: string;
2358
+ screenHash: string;
2359
+ timestamp: string;
2360
+ targets: AgentTarget[];
2361
+ compact?: string;
2362
+ selectors?: Record<string, string>;
2363
+ }
2364
+ type AgentActionType = 'click' | 'fill' | 'type' | 'press' | 'select' | 'check' | 'hover';
2365
+ interface AgentActionInput {
2366
+ action: AgentActionType;
2367
+ ref?: string;
2368
+ selector?: string;
2369
+ value?: string;
2370
+ key?: string;
2371
+ force?: boolean;
2372
+ timeout?: number;
2373
+ }
2374
+ interface AgentActionResult {
2375
+ action: AgentActionType;
2376
+ selector: string;
2377
+ ref?: string;
2378
+ success: boolean;
2379
+ reason?: string;
2380
+ message?: string;
2381
+ stale?: boolean;
2382
+ screenHash?: string;
2383
+ target?: AgentTarget;
2384
+ }
2385
+ type AgentWaitState = 'attached' | 'detached' | 'visible' | 'hidden';
2386
+ type AgentLoadState = 'load' | 'domcontentloaded' | 'networkidle';
2387
+ interface AgentWaitInput {
2388
+ selector?: string;
2389
+ state?: AgentWaitState;
2390
+ text?: string;
2391
+ url?: string;
2392
+ load?: AgentLoadState;
2393
+ fn?: string;
2394
+ screenHashChanged?: string;
2395
+ timeout?: number;
2396
+ pollInterval?: number;
2397
+ }
2398
+ interface AgentWaitResult {
2399
+ success: boolean;
2400
+ matched: 'selector' | 'text' | 'url' | 'load' | 'fn' | 'screenHashChanged';
2401
+ timeout: number;
2402
+ elapsed: number;
2403
+ screenHash?: string;
2404
+ message?: string;
2405
+ }
2406
+
2407
+ interface ObserveOptions {
2408
+ includeHidden?: boolean;
2409
+ limit?: number;
2410
+ }
2411
+ declare function observePage(page: XBPage, sessionId: string | undefined, options?: ObserveOptions): Promise<AgentObservation>;
2412
+ declare function getPageScreenHash(page: XBPage): Promise<string>;
2413
+ declare function actOnPage(page: XBPage, sessionId: string | undefined, input: AgentActionInput): Promise<AgentActionResult>;
2414
+ declare function waitForPage(page: XBPage, input: AgentWaitInput): Promise<AgentWaitResult>;
2415
+
1820
2416
  /**
1821
2417
  * A single event in a browser recording.
1822
2418
  */
@@ -1859,7 +2455,8 @@ declare function generateJSScript(recording: Recording): string;
1859
2455
  * Generate a Python replay script from a recording.
1860
2456
  *
1861
2457
  * @param recording - The recording session to convert.
1862
- * @returns A self-contained Python script string using Playwright async API.
2458
+ * @returns A self-contained Python script string using Playwright async API
2459
+ * (requires: pip install playwright && playwright install chromium).
1863
2460
  */
1864
2461
  declare function generatePythonScript(recording: Recording): string;
1865
2462
  /**
@@ -2249,4 +2846,4 @@ declare function advise(decision: DecisionResult, originalMethod: string): Advis
2249
2846
  /** Convenience factory: create and start a CDP interceptor proxy with defaults. */
2250
2847
  declare function createCDPInterceptor(config: CDPInterceptorConfig): Promise<CDPInterceptorProxy>;
2251
2848
 
2252
- export { type APIRequest, type APIResponse, type AdvisoryResult, type AnalysisResult, BROWSER_SCOPE, type BatchCollectResult, type BrowserCommandContext, type BrowserCommandDefinition, type BrowserLaunchOptions, type BuiltinCommand, type BuiltinContext, type CDPError, type CDPInterceptorConfig, CDPInterceptorProxy, type CDPInterceptorRule, type CDPInterceptorStats, type CDPLogEntry, type CDPMessage, type CDPRequest, type CDPResponse, type CaptchaDetectionResult, CaptchaDetector, type ChainExecutionResult, type ChainRequest, type ChainStepResult, type CollectResult, type CollectorConfig, type CommandMessage, type CompanyInfo, type ContextChange, type DaemonInfo, DataCollector, DataStorage, type DecisionAction, type DecisionResult, type DomainStat, type ElementRef, type ExecRequest, type ExecutionResult, HTTPServer, type HTTPServerConfig, type HTTPServerError, HumanInteractionManager, type InstallOptions, type InstalledPlugin, type ManagedSession, type MessageDirection, type NetworkEntry, type ParsedPipeline, PlaybackEngine, type PlaybackOptions, type PlaybackResult, PluginInstaller, type PluginLoaderOptions, type RecordedEvent, RecorderController, type RecorderStatus, type Recording, type RecordingControlFile, type RecordingData, type RecordingEvent, type RecordingSession, type RecordingStep, type RecordingSummary, type RegisteredCommand, ResultAnalyzer, type RuleContext, type RuleEngine, type ScopeDefinition, type ScopeLevel, ScreencastCapturer, type ScreencastFrame, type ScreencastMessage, type ScreencastOptions, type SearchResult, type ManagedSession as SessionInfo, SessionRecorder, type StatusMessage, type StorageConfig, type UserAction, type ViolationSeverity, type WSInboundMessage, type WSMessage, WSServer, type WSServerConfig, type WaitForHumanOptions, type WaitForHumanResult, WebhookNotifier, type WebhookPayload, XBrowserPluginLoader, advise, allBuiltins, assertPageScope, attachWaitForHuman, automationSignalsRule, checkBrowserScope, routeCommand as cliRoute, closeAllSessions as closeAllBrowserSessions, closeAllSessions, closeSession, closeSessionByName, createCDPInterceptor, createRuleEngine, createSession, destroyBrowser, destroyBrowser as destroySessionManager, domMutationRule, emulationOverrideRule, eventSimulationRule, executeChain, executeCommand, extractAndSave, extractRecording, filterRecording, findSession, findSession as findSessionInfo, fingerprintingRule, generateBashScript, generateJSScript, generatePythonScript, getAllSessions as getAllBrowserSessions, getAllCommands, getBrowser, getBuiltin, getCaptchaConfig, getCommand, getCommandNames, getCompanyType, getDaemonProcessStatus, getPlatformName, getSessionPage, getWSServerFromCache, inputKeystrokeRule, isChainInput, getAllSessions as listAllBrowserSessions, listSessions, mouseTrajectoryRule, networkAnomalyRule, normalizeSelector, openSession, pageLifecycleRule, parseCommandArgs, parseCommandChain, parseExcludeTypes, printExtractSummary, readCommandFile, readStdin, registerCommand, registerCommandDefinition, resetForTesting, setWSServer, setWSServerCache, splitCommand, startDaemonProcess, stopDaemonProcess, version };
2849
+ export { type APIRequest, type APIResponse, type AdvisoryResult, type AgentActionInput, type AgentActionResult, type AgentObservation, type AgentTarget, type AgentWaitInput, type AgentWaitResult, type AnalysisResult, BROWSER_SCOPE, type BatchCollectResult, type BrowserCommandContext, type BrowserCommandDefinition, type BrowserLaunchOptions, type BuiltinCommand, type BuiltinContext, type CDPError, type CDPInterceptorConfig, CDPInterceptorProxy, type CDPInterceptorRule, type CDPInterceptorStats, type CDPLogEntry, type CDPMessage, type CDPRequest, type CDPResponse, type CaptchaDetectionResult, CaptchaDetector, type ChainExecutionResult, type ChainRequest, type ChainStepResult, type CollectResult, type CollectorConfig, type CommandMessage, type CompanyInfo, type ContextChange, type DaemonInfo, DataCollector, DataStorage, type DecisionAction, type DecisionResult, type DomainStat, type ElementRef, type ExecRequest, type ExecutionResult, HTTPServer, type HTTPServerConfig, type HTTPServerError, HumanInteractionManager, type InstallOptions, type InstalledPlugin, type ManagedSession, type MessageDirection, type NetworkEntry, type ParsedPipeline, PlaybackEngine, type PlaybackOptions, type PlaybackResult, PluginInstaller, type PluginLoaderOptions, type RecordedEvent, RecorderController, type RecorderStatus, type Recording, type RecordingControlFile, type RecordingData, type RecordingEvent, type RecordingSession, type RecordingStep, type RecordingSummary, type RegisteredCommand, ResultAnalyzer, type RuleContext, type RuleEngine, type ScopeDefinition, type ScopeLevel, ScreencastCapturer, type ScreencastFrame, type ScreencastMessage, type ScreencastOptions, type SearchResult, type ManagedSession as SessionInfo, SessionRecorder, type StatusMessage, type StorageConfig, type UserAction, type ViolationSeverity, type WSInboundMessage, type WSMessage, WSServer, type WSServerConfig, type WaitForHumanOptions, type WaitForHumanResult, WebhookNotifier, type WebhookPayload, XBrowserPluginLoader, actOnPage, advise, allBuiltins, assertPageScope, attachWaitForHuman, automationSignalsRule, checkBrowserScope, routeCommand as cliRoute, closeAllSessions as closeAllBrowserSessions, closeAllSessions, closeSession, closeSessionByName, createCDPInterceptor, createRuleEngine, createSession, destroyBrowser, destroyBrowser as destroySessionManager, domMutationRule, emulationOverrideRule, eventSimulationRule, executeChain, executeCommand, extractAndSave, extractRecording, filterRecording, findSession, findSession as findSessionInfo, fingerprintingRule, generateBashScript, generateJSScript, generatePythonScript, getAllSessions as getAllBrowserSessions, getAllCommands, getBrowser, getBuiltin, getCaptchaConfig, getCommand, getCommandNames, getCompanyType, getDaemonProcessStatus, getPageScreenHash, getPlatformName, getSessionPage, getWSServerFromCache, inputKeystrokeRule, isChainInput, getAllSessions as listAllBrowserSessions, listSessions, mouseTrajectoryRule, networkAnomalyRule, normalizeSelector, observePage, openSession, pageLifecycleRule, parseCommandChain, parseExcludeTypes, printExtractSummary, registerCommand, resetForTesting, setWSServer, setWSServerCache, startDaemonProcess, stopDaemonProcess, version, waitForPage };