browser-pilot 0.0.11 → 0.0.13
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.
- package/README.md +44 -8
- package/dist/actions.cjs +686 -32
- package/dist/actions.d.cts +3 -3
- package/dist/actions.d.ts +3 -3
- package/dist/actions.mjs +2 -1
- package/dist/browser.cjs +3415 -2324
- package/dist/browser.d.cts +9 -3
- package/dist/browser.d.ts +9 -3
- package/dist/browser.mjs +4 -3
- package/dist/cdp.cjs +19 -4
- package/dist/cdp.d.cts +1 -1
- package/dist/cdp.d.ts +1 -1
- package/dist/cdp.mjs +4 -2
- package/dist/chunk-A2ZRAEO3.mjs +1711 -0
- package/dist/{chunk-BCOZUKWS.mjs → chunk-HP6R3W32.mjs} +22 -16
- package/dist/chunk-JXAUPHZM.mjs +15 -0
- package/dist/{chunk-JHAF52FA.mjs → chunk-VDAMDOS6.mjs} +1014 -738
- package/dist/cli.mjs +4998 -3259
- package/dist/{client-7Nqka5MV.d.ts → client-DRqxBdHv.d.cts} +1 -1
- package/dist/{client-7Nqka5MV.d.cts → client-DRqxBdHv.d.ts} +1 -1
- package/dist/index.cjs +4555 -3314
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +6 -4
- package/dist/{types-GWuQJs_e.d.cts → types-BXMGFtnB.d.cts} +96 -9
- package/dist/{types-DtGF3yGl.d.ts → types-CzgQjai9.d.ts} +96 -9
- package/package.json +6 -2
- package/dist/chunk-FAUNIZR7.mjs +0 -751
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { BatchExecutor, ValidationError, ValidationResult, addBatchToPage, validateSteps } from './actions.cjs';
|
|
2
|
-
import { R as RequestPattern, a as RequestHandler, C as CaptureResult } from './types-
|
|
3
|
-
export { k as ActionOptions, l as ActionResult, A as ActionType, d as AudioChunk, e as AudioInput, f as AudioInputState, g as AudioOutput, B as BatchOptions, b as BatchResult, h as CaptureOptions,
|
|
4
|
-
import { C as CDPClient } from './client-
|
|
5
|
-
export { a as CDPClientOptions, c as createCDPClient } from './client-
|
|
2
|
+
import { R as RequestPattern, a as RequestHandler, C as CaptureResult } from './types-BXMGFtnB.cjs';
|
|
3
|
+
export { k as ActionOptions, l as ActionResult, A as ActionType, d as AudioChunk, e as AudioInput, f as AudioInputState, g as AudioOutput, B as BatchOptions, b as BatchResult, h as CaptureOptions, a6 as ClearCookiesOptions, m as ConsoleHandler, n as ConsoleMessage, o as ConsoleMessageType, $ as ContinueRequestOptions, a7 as Cookie, p as CustomSelectConfig, a8 as DeleteCookieOptions, Y as DeviceDescriptor, Z as DeviceName, D as Dialog, q as DialogHandler, r as DialogType, s as Download, E as ElementInfo, t as ElementNotFoundError, u as EmulationState, v as ErrorHandler, a0 as FailRequestOptions, F as FileInput, w as FillOptions, x as FormField, y as FormOption, a1 as FulfillRequestOptions, G as GeolocationOptions, I as InteractiveElement, a2 as InterceptedRequest, N as NavigationError, z as NetworkIdleOptions, H as Page, J as PageError, K as PageSnapshot, P as PlayOptions, a3 as RequestActions, a4 as ResourceType, i as RoundTripOptions, j as RoundTripResult, a5 as RouteOptions, a9 as SetCookieOptions, L as SnapshotNode, M as SnapshotOptions, S as Step, c as StepResult, O as SubmitOptions, T as TimeoutError, Q as TypeOptions, U as UserAgentMetadata, V as UserAgentOptions, W as ViewportOptions, X as WaitForOptions, aa as WaitOptions, ab as WaitResult, ac as WaitState, _ as devices, ad as waitForAnyElement, ae as waitForElement, af as waitForNavigation, ag as waitForNetworkIdle } from './types-BXMGFtnB.cjs';
|
|
4
|
+
import { C as CDPClient } from './client-DRqxBdHv.cjs';
|
|
5
|
+
export { a as CDPClientOptions, c as createCDPClient } from './client-DRqxBdHv.cjs';
|
|
6
6
|
export { Browser, BrowserOptions, PageOptions, connect } from './browser.cjs';
|
|
7
7
|
export { CDPError } from './cdp.cjs';
|
|
8
8
|
export { BrowserBaseProvider, BrowserlessProvider, GenericProvider, createProvider, discoverTargets, getBrowserWebSocketUrl } from './providers.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { BatchExecutor, ValidationError, ValidationResult, addBatchToPage, validateSteps } from './actions.js';
|
|
2
|
-
import { R as RequestPattern, a as RequestHandler, C as CaptureResult } from './types-
|
|
3
|
-
export { k as ActionOptions, l as ActionResult, A as ActionType, d as AudioChunk, e as AudioInput, f as AudioInputState, g as AudioOutput, B as BatchOptions, b as BatchResult, h as CaptureOptions,
|
|
4
|
-
import { C as CDPClient } from './client-
|
|
5
|
-
export { a as CDPClientOptions, c as createCDPClient } from './client-
|
|
2
|
+
import { R as RequestPattern, a as RequestHandler, C as CaptureResult } from './types-CzgQjai9.js';
|
|
3
|
+
export { k as ActionOptions, l as ActionResult, A as ActionType, d as AudioChunk, e as AudioInput, f as AudioInputState, g as AudioOutput, B as BatchOptions, b as BatchResult, h as CaptureOptions, a6 as ClearCookiesOptions, m as ConsoleHandler, n as ConsoleMessage, o as ConsoleMessageType, $ as ContinueRequestOptions, a7 as Cookie, p as CustomSelectConfig, a8 as DeleteCookieOptions, Y as DeviceDescriptor, Z as DeviceName, D as Dialog, q as DialogHandler, r as DialogType, s as Download, E as ElementInfo, t as ElementNotFoundError, u as EmulationState, v as ErrorHandler, a0 as FailRequestOptions, F as FileInput, w as FillOptions, x as FormField, y as FormOption, a1 as FulfillRequestOptions, G as GeolocationOptions, I as InteractiveElement, a2 as InterceptedRequest, N as NavigationError, z as NetworkIdleOptions, H as Page, J as PageError, K as PageSnapshot, P as PlayOptions, a3 as RequestActions, a4 as ResourceType, i as RoundTripOptions, j as RoundTripResult, a5 as RouteOptions, a9 as SetCookieOptions, L as SnapshotNode, M as SnapshotOptions, S as Step, c as StepResult, O as SubmitOptions, T as TimeoutError, Q as TypeOptions, U as UserAgentMetadata, V as UserAgentOptions, W as ViewportOptions, X as WaitForOptions, aa as WaitOptions, ab as WaitResult, ac as WaitState, _ as devices, ad as waitForAnyElement, ae as waitForElement, af as waitForNavigation, ag as waitForNetworkIdle } from './types-CzgQjai9.js';
|
|
4
|
+
import { C as CDPClient } from './client-DRqxBdHv.js';
|
|
5
|
+
export { a as CDPClientOptions, c as createCDPClient } from './client-DRqxBdHv.js';
|
|
6
6
|
export { Browser, BrowserOptions, PageOptions, connect } from './browser.js';
|
|
7
7
|
export { CDPError } from './cdp.js';
|
|
8
8
|
export { BrowserBaseProvider, BrowserlessProvider, GenericProvider, createProvider, discoverTargets, getBrowserWebSocketUrl } from './providers.js';
|
package/dist/index.mjs
CHANGED
|
@@ -16,11 +16,10 @@ import {
|
|
|
16
16
|
waitForElement,
|
|
17
17
|
waitForNavigation,
|
|
18
18
|
waitForNetworkIdle
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-VDAMDOS6.mjs";
|
|
20
20
|
import {
|
|
21
|
-
CDPError,
|
|
22
21
|
createCDPClient
|
|
23
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-HP6R3W32.mjs";
|
|
24
23
|
import {
|
|
25
24
|
BrowserBaseProvider,
|
|
26
25
|
BrowserlessProvider,
|
|
@@ -36,7 +35,10 @@ import {
|
|
|
36
35
|
TimeoutError,
|
|
37
36
|
addBatchToPage,
|
|
38
37
|
validateSteps
|
|
39
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-A2ZRAEO3.mjs";
|
|
39
|
+
import {
|
|
40
|
+
CDPError
|
|
41
|
+
} from "./chunk-JXAUPHZM.mjs";
|
|
40
42
|
|
|
41
43
|
// src/audio/flags.ts
|
|
42
44
|
function getAudioChromeFlags(options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CDPClient } from './client-
|
|
1
|
+
import { C as CDPClient } from './client-DRqxBdHv.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Audio I/O type definitions
|
|
@@ -224,7 +224,9 @@ interface WaitResult {
|
|
|
224
224
|
waitedMs: number;
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
|
-
* Wait for an element to reach a specific state
|
|
227
|
+
* Wait for an element to reach a specific state.
|
|
228
|
+
* Uses fast-fail: if the element is not found on a static page (no DOM mutations),
|
|
229
|
+
* returns early instead of polling for the full timeout.
|
|
228
230
|
*/
|
|
229
231
|
declare function waitForElement(cdp: CDPClient, selector: string, options?: WaitOptions): Promise<WaitResult>;
|
|
230
232
|
/**
|
|
@@ -278,6 +280,8 @@ interface FillOptions extends ActionOptions {
|
|
|
278
280
|
interface TypeOptions extends ActionOptions {
|
|
279
281
|
/** Delay between keystrokes in ms */
|
|
280
282
|
delay?: number;
|
|
283
|
+
/** Blur the element after typing */
|
|
284
|
+
blur?: boolean;
|
|
281
285
|
}
|
|
282
286
|
interface SubmitOptions extends ActionOptions {
|
|
283
287
|
/** How to submit: 'enter' | 'click' | 'enter+click' */
|
|
@@ -363,6 +367,10 @@ interface PageSnapshot {
|
|
|
363
367
|
/** Text representation of the page */
|
|
364
368
|
text: string;
|
|
365
369
|
}
|
|
370
|
+
interface SnapshotOptions {
|
|
371
|
+
/** Restrict the snapshot to these accessibility roles */
|
|
372
|
+
roles?: string[];
|
|
373
|
+
}
|
|
366
374
|
interface SnapshotNode {
|
|
367
375
|
/** Accessibility role */
|
|
368
376
|
role: string;
|
|
@@ -392,6 +400,29 @@ interface InteractiveElement {
|
|
|
392
400
|
selector: string;
|
|
393
401
|
/** Whether the element is disabled */
|
|
394
402
|
disabled?: boolean;
|
|
403
|
+
/** Whether the element is checked */
|
|
404
|
+
checked?: boolean;
|
|
405
|
+
/** Current value where relevant */
|
|
406
|
+
value?: string;
|
|
407
|
+
}
|
|
408
|
+
interface FormOption {
|
|
409
|
+
value: string;
|
|
410
|
+
text: string;
|
|
411
|
+
selected: boolean;
|
|
412
|
+
disabled: boolean;
|
|
413
|
+
}
|
|
414
|
+
interface FormField {
|
|
415
|
+
tag: string;
|
|
416
|
+
type: string;
|
|
417
|
+
id?: string;
|
|
418
|
+
name?: string;
|
|
419
|
+
value?: string | string[] | null;
|
|
420
|
+
checked?: boolean;
|
|
421
|
+
required: boolean;
|
|
422
|
+
disabled: boolean;
|
|
423
|
+
label?: string;
|
|
424
|
+
placeholder?: string;
|
|
425
|
+
options?: FormOption[];
|
|
395
426
|
}
|
|
396
427
|
interface FailureHint {
|
|
397
428
|
/** Suggested selector */
|
|
@@ -705,6 +736,8 @@ declare class Page {
|
|
|
705
736
|
private frameExecutionContexts;
|
|
706
737
|
/** Current frame's execution context ID (null = main frame default) */
|
|
707
738
|
private currentFrameContextId;
|
|
739
|
+
/** Frame selector if context acquisition failed (cross-origin/sandboxed) */
|
|
740
|
+
private brokenFrame;
|
|
708
741
|
/** Last matched selector from findElement (for selectorUsed tracking) */
|
|
709
742
|
private _lastMatchedSelector;
|
|
710
743
|
/** Last snapshot for stale ref recovery */
|
|
@@ -809,9 +842,15 @@ declare class Page {
|
|
|
809
842
|
*/
|
|
810
843
|
submit(selector: string | string[], options?: SubmitOptions): Promise<boolean>;
|
|
811
844
|
/**
|
|
812
|
-
* Press a key
|
|
845
|
+
* Press a key, optionally with modifier keys held down
|
|
813
846
|
*/
|
|
814
|
-
press(key: string
|
|
847
|
+
press(key: string, options?: {
|
|
848
|
+
modifiers?: Array<'Control' | 'Shift' | 'Alt' | 'Meta'>;
|
|
849
|
+
}): Promise<void>;
|
|
850
|
+
/**
|
|
851
|
+
* Execute a keyboard shortcut (e.g. "Control+a", "Meta+Shift+z")
|
|
852
|
+
*/
|
|
853
|
+
shortcut(combo: string): Promise<void>;
|
|
815
854
|
/**
|
|
816
855
|
* Focus an element
|
|
817
856
|
*/
|
|
@@ -870,6 +909,10 @@ declare class Page {
|
|
|
870
909
|
* Get text content from the page or a specific element
|
|
871
910
|
*/
|
|
872
911
|
text(selector?: string): Promise<string>;
|
|
912
|
+
/**
|
|
913
|
+
* Enumerate form controls on the page with labels and current state.
|
|
914
|
+
*/
|
|
915
|
+
forms(): Promise<FormField[]>;
|
|
873
916
|
/**
|
|
874
917
|
* Set files on a file input
|
|
875
918
|
*/
|
|
@@ -892,7 +935,7 @@ declare class Page {
|
|
|
892
935
|
/**
|
|
893
936
|
* Get an accessibility tree snapshot of the page
|
|
894
937
|
*/
|
|
895
|
-
snapshot(): Promise<PageSnapshot>;
|
|
938
|
+
snapshot(options?: SnapshotOptions): Promise<PageSnapshot>;
|
|
896
939
|
/**
|
|
897
940
|
* Export the current ref map for cross-exec reuse (CLI).
|
|
898
941
|
*/
|
|
@@ -1082,9 +1125,17 @@ declare class Page {
|
|
|
1082
1125
|
private withStaleNodeRetry;
|
|
1083
1126
|
/**
|
|
1084
1127
|
* Find an element using single or multiple selectors
|
|
1085
|
-
* Supports ref
|
|
1128
|
+
* Supports ref:, text:, and role: selectors.
|
|
1086
1129
|
*/
|
|
1087
1130
|
private findElement;
|
|
1131
|
+
private formatEvaluationError;
|
|
1132
|
+
private resolveSpecialSelector;
|
|
1133
|
+
private readCheckedState;
|
|
1134
|
+
private readInputType;
|
|
1135
|
+
private getAssociatedLabelNodeId;
|
|
1136
|
+
private objectIdToNode;
|
|
1137
|
+
private tryClickAssociatedLabel;
|
|
1138
|
+
private tryToggleViaLabel;
|
|
1088
1139
|
/**
|
|
1089
1140
|
* Ensure we have a valid root node ID
|
|
1090
1141
|
*/
|
|
@@ -1095,9 +1146,13 @@ declare class Page {
|
|
|
1095
1146
|
*/
|
|
1096
1147
|
private evaluateInFrame;
|
|
1097
1148
|
/**
|
|
1098
|
-
* Scroll an element into view
|
|
1149
|
+
* Scroll an element into view, with fallback to center-scroll if clipped by fixed headers
|
|
1099
1150
|
*/
|
|
1100
1151
|
private scrollIntoView;
|
|
1152
|
+
/**
|
|
1153
|
+
* Check if element is within the visible viewport
|
|
1154
|
+
*/
|
|
1155
|
+
private isInViewport;
|
|
1101
1156
|
/**
|
|
1102
1157
|
* Get element box model (position and dimensions)
|
|
1103
1158
|
*/
|
|
@@ -1115,6 +1170,7 @@ declare class Page {
|
|
|
1115
1170
|
private resolveObjectId;
|
|
1116
1171
|
private dispatchKeyDefinition;
|
|
1117
1172
|
private dispatchKey;
|
|
1173
|
+
private dispatchKeyWithModifiers;
|
|
1118
1174
|
/**
|
|
1119
1175
|
* Audio input controller (fake microphone).
|
|
1120
1176
|
* Lazy-initialized on first access.
|
|
@@ -1150,13 +1206,22 @@ declare class Page {
|
|
|
1150
1206
|
* ```
|
|
1151
1207
|
*/
|
|
1152
1208
|
audioRoundTrip(options: RoundTripOptions): Promise<RoundTripResult>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Wait for a DOM mutation in the current frame (used for detecting client-side form handling)
|
|
1211
|
+
*/
|
|
1212
|
+
private waitForDOMMutation;
|
|
1213
|
+
/**
|
|
1214
|
+
* Wait for a frame execution context via Runtime.executionContextCreated event
|
|
1215
|
+
*/
|
|
1216
|
+
private waitForFrameContext;
|
|
1153
1217
|
}
|
|
1154
1218
|
|
|
1155
1219
|
/**
|
|
1156
1220
|
* Action/Step types for batch execution
|
|
1157
1221
|
*/
|
|
1158
1222
|
|
|
1159
|
-
type
|
|
1223
|
+
type FailureReason = 'missing' | 'hidden' | 'covered' | 'disabled' | 'readonly' | 'detached' | 'replaced' | 'notEditable' | 'timeout' | 'navigation' | 'cdpError' | 'unknown';
|
|
1224
|
+
type ActionType = 'goto' | 'click' | 'fill' | 'type' | 'select' | 'check' | 'uncheck' | 'submit' | 'press' | 'shortcut' | 'focus' | 'hover' | 'scroll' | 'wait' | 'snapshot' | 'forms' | 'screenshot' | 'evaluate' | 'text' | 'newTab' | 'closeTab' | 'switchFrame' | 'switchToMain' | 'assertVisible' | 'assertExists' | 'assertText' | 'assertUrl' | 'assertValue';
|
|
1160
1225
|
interface Step {
|
|
1161
1226
|
/** Action type */
|
|
1162
1227
|
action: ActionType;
|
|
@@ -1166,8 +1231,14 @@ interface Step {
|
|
|
1166
1231
|
url?: string;
|
|
1167
1232
|
/** Value for fill, type, select, evaluate actions */
|
|
1168
1233
|
value?: string | string[];
|
|
1234
|
+
/** Target ID for tab operations */
|
|
1235
|
+
targetId?: string;
|
|
1169
1236
|
/** Key for press action */
|
|
1170
1237
|
key?: string;
|
|
1238
|
+
/** Key combo for shortcut action (e.g. "Control+a", "Meta+Shift+z") */
|
|
1239
|
+
combo?: string;
|
|
1240
|
+
/** Modifier keys for press action */
|
|
1241
|
+
modifiers?: Array<'Control' | 'Shift' | 'Alt' | 'Meta'>;
|
|
1171
1242
|
/** What to wait for (wait action) */
|
|
1172
1243
|
waitFor?: 'visible' | 'hidden' | 'attached' | 'detached' | 'navigation' | 'networkIdle';
|
|
1173
1244
|
/** Step-specific timeout override (ms) */
|
|
@@ -1199,6 +1270,12 @@ interface Step {
|
|
|
1199
1270
|
format?: 'png' | 'jpeg' | 'webp';
|
|
1200
1271
|
quality?: number;
|
|
1201
1272
|
fullPage?: boolean;
|
|
1273
|
+
/** Expected value for assertion steps (substring match for assertText, exact for assertValue/assertUrl) */
|
|
1274
|
+
expect?: string;
|
|
1275
|
+
/** Retry count for assertion or action steps (default: 0 = no retry) */
|
|
1276
|
+
retry?: number;
|
|
1277
|
+
/** Delay between retries in ms (default: 500) */
|
|
1278
|
+
retryDelay?: number;
|
|
1202
1279
|
}
|
|
1203
1280
|
interface BatchOptions {
|
|
1204
1281
|
/** Default timeout for all steps (ms) */
|
|
@@ -1232,6 +1309,16 @@ interface StepResult {
|
|
|
1232
1309
|
text?: string;
|
|
1233
1310
|
/** Failure hints when element not found */
|
|
1234
1311
|
hints?: FailureHint[];
|
|
1312
|
+
/** Structured failure classification */
|
|
1313
|
+
failureReason?: FailureReason;
|
|
1314
|
+
/** Element covering the target (when failureReason is 'covered') */
|
|
1315
|
+
coveringElement?: {
|
|
1316
|
+
tag: string;
|
|
1317
|
+
id?: string;
|
|
1318
|
+
className?: string;
|
|
1319
|
+
};
|
|
1320
|
+
/** AI-friendly suggestion for what to try next */
|
|
1321
|
+
suggestion?: string;
|
|
1235
1322
|
}
|
|
1236
1323
|
interface BatchResult {
|
|
1237
1324
|
/** Whether all steps succeeded */
|
|
@@ -1244,4 +1331,4 @@ interface BatchResult {
|
|
|
1244
1331
|
totalDurationMs: number;
|
|
1245
1332
|
}
|
|
1246
1333
|
|
|
1247
|
-
export { type
|
|
1334
|
+
export { type ContinueRequestOptions as $, type ActionType as A, type BatchOptions as B, type CaptureResult as C, type Dialog as D, type ElementInfo as E, type FileInput as F, type GeolocationOptions as G, Page as H, type InteractiveElement as I, type PageError as J, type PageSnapshot as K, type SnapshotNode as L, type SnapshotOptions as M, NavigationError as N, type SubmitOptions as O, type PlayOptions as P, type TypeOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type UserAgentMetadata as U, type UserAgentOptions as V, type ViewportOptions as W, type WaitForOptions as X, type DeviceDescriptor as Y, type DeviceName as Z, devices as _, type RequestHandler as a, type FailRequestOptions as a0, type FulfillRequestOptions as a1, type InterceptedRequest as a2, type RequestActions as a3, type ResourceType as a4, type RouteOptions as a5, type ClearCookiesOptions as a6, type Cookie as a7, type DeleteCookieOptions as a8, type SetCookieOptions as a9, type WaitOptions as aa, type WaitResult as ab, type WaitState as ac, waitForAnyElement as ad, waitForElement as ae, waitForNavigation as af, waitForNetworkIdle as ag, type FailureHint as ah, type FailureReason as ai, type BatchResult as b, type StepResult as c, type AudioChunk as d, AudioInput as e, type AudioInputState as f, AudioOutput as g, type CaptureOptions as h, type RoundTripOptions as i, type RoundTripResult as j, type ActionOptions as k, type ActionResult as l, type ConsoleHandler as m, type ConsoleMessage as n, type ConsoleMessageType as o, type CustomSelectConfig as p, type DialogHandler as q, type DialogType as r, type Download as s, ElementNotFoundError as t, type EmulationState as u, type ErrorHandler as v, type FillOptions as w, type FormField as x, type FormOption as y, type NetworkIdleOptions as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CDPClient } from './client-
|
|
1
|
+
import { C as CDPClient } from './client-DRqxBdHv.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Audio I/O type definitions
|
|
@@ -224,7 +224,9 @@ interface WaitResult {
|
|
|
224
224
|
waitedMs: number;
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
|
-
* Wait for an element to reach a specific state
|
|
227
|
+
* Wait for an element to reach a specific state.
|
|
228
|
+
* Uses fast-fail: if the element is not found on a static page (no DOM mutations),
|
|
229
|
+
* returns early instead of polling for the full timeout.
|
|
228
230
|
*/
|
|
229
231
|
declare function waitForElement(cdp: CDPClient, selector: string, options?: WaitOptions): Promise<WaitResult>;
|
|
230
232
|
/**
|
|
@@ -278,6 +280,8 @@ interface FillOptions extends ActionOptions {
|
|
|
278
280
|
interface TypeOptions extends ActionOptions {
|
|
279
281
|
/** Delay between keystrokes in ms */
|
|
280
282
|
delay?: number;
|
|
283
|
+
/** Blur the element after typing */
|
|
284
|
+
blur?: boolean;
|
|
281
285
|
}
|
|
282
286
|
interface SubmitOptions extends ActionOptions {
|
|
283
287
|
/** How to submit: 'enter' | 'click' | 'enter+click' */
|
|
@@ -363,6 +367,10 @@ interface PageSnapshot {
|
|
|
363
367
|
/** Text representation of the page */
|
|
364
368
|
text: string;
|
|
365
369
|
}
|
|
370
|
+
interface SnapshotOptions {
|
|
371
|
+
/** Restrict the snapshot to these accessibility roles */
|
|
372
|
+
roles?: string[];
|
|
373
|
+
}
|
|
366
374
|
interface SnapshotNode {
|
|
367
375
|
/** Accessibility role */
|
|
368
376
|
role: string;
|
|
@@ -392,6 +400,29 @@ interface InteractiveElement {
|
|
|
392
400
|
selector: string;
|
|
393
401
|
/** Whether the element is disabled */
|
|
394
402
|
disabled?: boolean;
|
|
403
|
+
/** Whether the element is checked */
|
|
404
|
+
checked?: boolean;
|
|
405
|
+
/** Current value where relevant */
|
|
406
|
+
value?: string;
|
|
407
|
+
}
|
|
408
|
+
interface FormOption {
|
|
409
|
+
value: string;
|
|
410
|
+
text: string;
|
|
411
|
+
selected: boolean;
|
|
412
|
+
disabled: boolean;
|
|
413
|
+
}
|
|
414
|
+
interface FormField {
|
|
415
|
+
tag: string;
|
|
416
|
+
type: string;
|
|
417
|
+
id?: string;
|
|
418
|
+
name?: string;
|
|
419
|
+
value?: string | string[] | null;
|
|
420
|
+
checked?: boolean;
|
|
421
|
+
required: boolean;
|
|
422
|
+
disabled: boolean;
|
|
423
|
+
label?: string;
|
|
424
|
+
placeholder?: string;
|
|
425
|
+
options?: FormOption[];
|
|
395
426
|
}
|
|
396
427
|
interface FailureHint {
|
|
397
428
|
/** Suggested selector */
|
|
@@ -705,6 +736,8 @@ declare class Page {
|
|
|
705
736
|
private frameExecutionContexts;
|
|
706
737
|
/** Current frame's execution context ID (null = main frame default) */
|
|
707
738
|
private currentFrameContextId;
|
|
739
|
+
/** Frame selector if context acquisition failed (cross-origin/sandboxed) */
|
|
740
|
+
private brokenFrame;
|
|
708
741
|
/** Last matched selector from findElement (for selectorUsed tracking) */
|
|
709
742
|
private _lastMatchedSelector;
|
|
710
743
|
/** Last snapshot for stale ref recovery */
|
|
@@ -809,9 +842,15 @@ declare class Page {
|
|
|
809
842
|
*/
|
|
810
843
|
submit(selector: string | string[], options?: SubmitOptions): Promise<boolean>;
|
|
811
844
|
/**
|
|
812
|
-
* Press a key
|
|
845
|
+
* Press a key, optionally with modifier keys held down
|
|
813
846
|
*/
|
|
814
|
-
press(key: string
|
|
847
|
+
press(key: string, options?: {
|
|
848
|
+
modifiers?: Array<'Control' | 'Shift' | 'Alt' | 'Meta'>;
|
|
849
|
+
}): Promise<void>;
|
|
850
|
+
/**
|
|
851
|
+
* Execute a keyboard shortcut (e.g. "Control+a", "Meta+Shift+z")
|
|
852
|
+
*/
|
|
853
|
+
shortcut(combo: string): Promise<void>;
|
|
815
854
|
/**
|
|
816
855
|
* Focus an element
|
|
817
856
|
*/
|
|
@@ -870,6 +909,10 @@ declare class Page {
|
|
|
870
909
|
* Get text content from the page or a specific element
|
|
871
910
|
*/
|
|
872
911
|
text(selector?: string): Promise<string>;
|
|
912
|
+
/**
|
|
913
|
+
* Enumerate form controls on the page with labels and current state.
|
|
914
|
+
*/
|
|
915
|
+
forms(): Promise<FormField[]>;
|
|
873
916
|
/**
|
|
874
917
|
* Set files on a file input
|
|
875
918
|
*/
|
|
@@ -892,7 +935,7 @@ declare class Page {
|
|
|
892
935
|
/**
|
|
893
936
|
* Get an accessibility tree snapshot of the page
|
|
894
937
|
*/
|
|
895
|
-
snapshot(): Promise<PageSnapshot>;
|
|
938
|
+
snapshot(options?: SnapshotOptions): Promise<PageSnapshot>;
|
|
896
939
|
/**
|
|
897
940
|
* Export the current ref map for cross-exec reuse (CLI).
|
|
898
941
|
*/
|
|
@@ -1082,9 +1125,17 @@ declare class Page {
|
|
|
1082
1125
|
private withStaleNodeRetry;
|
|
1083
1126
|
/**
|
|
1084
1127
|
* Find an element using single or multiple selectors
|
|
1085
|
-
* Supports ref
|
|
1128
|
+
* Supports ref:, text:, and role: selectors.
|
|
1086
1129
|
*/
|
|
1087
1130
|
private findElement;
|
|
1131
|
+
private formatEvaluationError;
|
|
1132
|
+
private resolveSpecialSelector;
|
|
1133
|
+
private readCheckedState;
|
|
1134
|
+
private readInputType;
|
|
1135
|
+
private getAssociatedLabelNodeId;
|
|
1136
|
+
private objectIdToNode;
|
|
1137
|
+
private tryClickAssociatedLabel;
|
|
1138
|
+
private tryToggleViaLabel;
|
|
1088
1139
|
/**
|
|
1089
1140
|
* Ensure we have a valid root node ID
|
|
1090
1141
|
*/
|
|
@@ -1095,9 +1146,13 @@ declare class Page {
|
|
|
1095
1146
|
*/
|
|
1096
1147
|
private evaluateInFrame;
|
|
1097
1148
|
/**
|
|
1098
|
-
* Scroll an element into view
|
|
1149
|
+
* Scroll an element into view, with fallback to center-scroll if clipped by fixed headers
|
|
1099
1150
|
*/
|
|
1100
1151
|
private scrollIntoView;
|
|
1152
|
+
/**
|
|
1153
|
+
* Check if element is within the visible viewport
|
|
1154
|
+
*/
|
|
1155
|
+
private isInViewport;
|
|
1101
1156
|
/**
|
|
1102
1157
|
* Get element box model (position and dimensions)
|
|
1103
1158
|
*/
|
|
@@ -1115,6 +1170,7 @@ declare class Page {
|
|
|
1115
1170
|
private resolveObjectId;
|
|
1116
1171
|
private dispatchKeyDefinition;
|
|
1117
1172
|
private dispatchKey;
|
|
1173
|
+
private dispatchKeyWithModifiers;
|
|
1118
1174
|
/**
|
|
1119
1175
|
* Audio input controller (fake microphone).
|
|
1120
1176
|
* Lazy-initialized on first access.
|
|
@@ -1150,13 +1206,22 @@ declare class Page {
|
|
|
1150
1206
|
* ```
|
|
1151
1207
|
*/
|
|
1152
1208
|
audioRoundTrip(options: RoundTripOptions): Promise<RoundTripResult>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Wait for a DOM mutation in the current frame (used for detecting client-side form handling)
|
|
1211
|
+
*/
|
|
1212
|
+
private waitForDOMMutation;
|
|
1213
|
+
/**
|
|
1214
|
+
* Wait for a frame execution context via Runtime.executionContextCreated event
|
|
1215
|
+
*/
|
|
1216
|
+
private waitForFrameContext;
|
|
1153
1217
|
}
|
|
1154
1218
|
|
|
1155
1219
|
/**
|
|
1156
1220
|
* Action/Step types for batch execution
|
|
1157
1221
|
*/
|
|
1158
1222
|
|
|
1159
|
-
type
|
|
1223
|
+
type FailureReason = 'missing' | 'hidden' | 'covered' | 'disabled' | 'readonly' | 'detached' | 'replaced' | 'notEditable' | 'timeout' | 'navigation' | 'cdpError' | 'unknown';
|
|
1224
|
+
type ActionType = 'goto' | 'click' | 'fill' | 'type' | 'select' | 'check' | 'uncheck' | 'submit' | 'press' | 'shortcut' | 'focus' | 'hover' | 'scroll' | 'wait' | 'snapshot' | 'forms' | 'screenshot' | 'evaluate' | 'text' | 'newTab' | 'closeTab' | 'switchFrame' | 'switchToMain' | 'assertVisible' | 'assertExists' | 'assertText' | 'assertUrl' | 'assertValue';
|
|
1160
1225
|
interface Step {
|
|
1161
1226
|
/** Action type */
|
|
1162
1227
|
action: ActionType;
|
|
@@ -1166,8 +1231,14 @@ interface Step {
|
|
|
1166
1231
|
url?: string;
|
|
1167
1232
|
/** Value for fill, type, select, evaluate actions */
|
|
1168
1233
|
value?: string | string[];
|
|
1234
|
+
/** Target ID for tab operations */
|
|
1235
|
+
targetId?: string;
|
|
1169
1236
|
/** Key for press action */
|
|
1170
1237
|
key?: string;
|
|
1238
|
+
/** Key combo for shortcut action (e.g. "Control+a", "Meta+Shift+z") */
|
|
1239
|
+
combo?: string;
|
|
1240
|
+
/** Modifier keys for press action */
|
|
1241
|
+
modifiers?: Array<'Control' | 'Shift' | 'Alt' | 'Meta'>;
|
|
1171
1242
|
/** What to wait for (wait action) */
|
|
1172
1243
|
waitFor?: 'visible' | 'hidden' | 'attached' | 'detached' | 'navigation' | 'networkIdle';
|
|
1173
1244
|
/** Step-specific timeout override (ms) */
|
|
@@ -1199,6 +1270,12 @@ interface Step {
|
|
|
1199
1270
|
format?: 'png' | 'jpeg' | 'webp';
|
|
1200
1271
|
quality?: number;
|
|
1201
1272
|
fullPage?: boolean;
|
|
1273
|
+
/** Expected value for assertion steps (substring match for assertText, exact for assertValue/assertUrl) */
|
|
1274
|
+
expect?: string;
|
|
1275
|
+
/** Retry count for assertion or action steps (default: 0 = no retry) */
|
|
1276
|
+
retry?: number;
|
|
1277
|
+
/** Delay between retries in ms (default: 500) */
|
|
1278
|
+
retryDelay?: number;
|
|
1202
1279
|
}
|
|
1203
1280
|
interface BatchOptions {
|
|
1204
1281
|
/** Default timeout for all steps (ms) */
|
|
@@ -1232,6 +1309,16 @@ interface StepResult {
|
|
|
1232
1309
|
text?: string;
|
|
1233
1310
|
/** Failure hints when element not found */
|
|
1234
1311
|
hints?: FailureHint[];
|
|
1312
|
+
/** Structured failure classification */
|
|
1313
|
+
failureReason?: FailureReason;
|
|
1314
|
+
/** Element covering the target (when failureReason is 'covered') */
|
|
1315
|
+
coveringElement?: {
|
|
1316
|
+
tag: string;
|
|
1317
|
+
id?: string;
|
|
1318
|
+
className?: string;
|
|
1319
|
+
};
|
|
1320
|
+
/** AI-friendly suggestion for what to try next */
|
|
1321
|
+
suggestion?: string;
|
|
1235
1322
|
}
|
|
1236
1323
|
interface BatchResult {
|
|
1237
1324
|
/** Whether all steps succeeded */
|
|
@@ -1244,4 +1331,4 @@ interface BatchResult {
|
|
|
1244
1331
|
totalDurationMs: number;
|
|
1245
1332
|
}
|
|
1246
1333
|
|
|
1247
|
-
export { type
|
|
1334
|
+
export { type ContinueRequestOptions as $, type ActionType as A, type BatchOptions as B, type CaptureResult as C, type Dialog as D, type ElementInfo as E, type FileInput as F, type GeolocationOptions as G, Page as H, type InteractiveElement as I, type PageError as J, type PageSnapshot as K, type SnapshotNode as L, type SnapshotOptions as M, NavigationError as N, type SubmitOptions as O, type PlayOptions as P, type TypeOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type UserAgentMetadata as U, type UserAgentOptions as V, type ViewportOptions as W, type WaitForOptions as X, type DeviceDescriptor as Y, type DeviceName as Z, devices as _, type RequestHandler as a, type FailRequestOptions as a0, type FulfillRequestOptions as a1, type InterceptedRequest as a2, type RequestActions as a3, type ResourceType as a4, type RouteOptions as a5, type ClearCookiesOptions as a6, type Cookie as a7, type DeleteCookieOptions as a8, type SetCookieOptions as a9, type WaitOptions as aa, type WaitResult as ab, type WaitState as ac, waitForAnyElement as ad, waitForElement as ae, waitForNavigation as af, waitForNetworkIdle as ag, type FailureHint as ah, type FailureReason as ai, type BatchResult as b, type StepResult as c, type AudioChunk as d, AudioInput as e, type AudioInputState as f, AudioOutput as g, type CaptureOptions as h, type RoundTripOptions as i, type RoundTripResult as j, type ActionOptions as k, type ActionResult as l, type ConsoleHandler as m, type ConsoleMessage as n, type ConsoleMessageType as o, type CustomSelectConfig as p, type DialogHandler as q, type DialogType as r, type Download as s, ElementNotFoundError as t, type EmulationState as u, type ErrorHandler as v, type FillOptions as w, type FormField as x, type FormOption as y, type NetworkIdleOptions as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-pilot",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Lightweight CDP-based browser automation for Node.js, Bun, and Cloudflare Workers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -57,8 +57,10 @@
|
|
|
57
57
|
"typecheck": "tsc --noEmit",
|
|
58
58
|
"lint": "biome check .",
|
|
59
59
|
"lint:fix": "biome check --write .",
|
|
60
|
+
"lint:type": "oxlint --type-aware --tsconfig ./tsconfig.json src/",
|
|
60
61
|
"format": "biome format --write .",
|
|
61
|
-
"check": "bun run typecheck && bun run lint",
|
|
62
|
+
"check": "bun run typecheck && bun run lint && bun run lint:type",
|
|
63
|
+
"check:quiet": "bash scripts/check.sh",
|
|
62
64
|
"prepublishOnly": "bun run build",
|
|
63
65
|
"bp": "bun ./src/cli/index.ts",
|
|
64
66
|
"dev:bp": "bun ./src/cli/index.ts",
|
|
@@ -69,6 +71,8 @@
|
|
|
69
71
|
"@biomejs/biome": "^2.3.10",
|
|
70
72
|
"@types/bun": "latest",
|
|
71
73
|
"chrome-launcher": "^1.2.1",
|
|
74
|
+
"oxlint": "^1.51.0",
|
|
75
|
+
"oxlint-tsgolint": "^0.16.0",
|
|
72
76
|
"tsup": "^8.0.0"
|
|
73
77
|
},
|
|
74
78
|
"peerDependencies": {
|