browser-pilot 0.0.13 → 0.0.15
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 +82 -617
- package/dist/actions.cjs +1438 -17
- package/dist/actions.d.cts +21 -3
- package/dist/actions.d.ts +21 -3
- package/dist/actions.mjs +1 -1
- package/dist/browser-MEWT75IB.mjs +11 -0
- package/dist/browser.cjs +1583 -22
- package/dist/browser.d.cts +12 -3
- package/dist/browser.d.ts +12 -3
- package/dist/browser.mjs +3 -3
- package/dist/cdp.cjs +36 -3
- package/dist/cdp.d.cts +1 -1
- package/dist/cdp.d.ts +1 -1
- package/dist/cdp.mjs +3 -1
- package/dist/{chunk-A2ZRAEO3.mjs → chunk-7YVCOL2W.mjs} +1428 -17
- package/dist/chunk-BVZALQT4.mjs +303 -0
- package/dist/chunk-DTVRFXKI.mjs +35 -0
- package/dist/{chunk-HP6R3W32.mjs → chunk-LCNFBXB5.mjs} +33 -6
- package/dist/chunk-LUGLEMVR.mjs +11 -0
- package/dist/chunk-USYSHCI3.mjs +8640 -0
- package/dist/chunk-WPNW23CE.mjs +466 -0
- package/dist/{chunk-VDAMDOS6.mjs → chunk-ZAXQ5OTV.mjs} +151 -7
- package/dist/cli.mjs +3225 -8434
- package/dist/{client-DRqxBdHv.d.ts → client-B5QBRgIy.d.cts} +10 -6
- package/dist/{client-DRqxBdHv.d.cts → client-B5QBRgIy.d.ts} +10 -6
- package/dist/client-JWWZWO6L.mjs +12 -0
- package/dist/index.cjs +1629 -24
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/page-XPS6IC6V.mjs +7 -0
- package/dist/transport-WHEBAZUP.mjs +83 -0
- package/dist/{types-CzgQjai9.d.ts → types-C9ySEdOX.d.cts} +78 -4
- package/dist/{types-BXMGFtnB.d.cts → types-Cvvf0oGu.d.ts} +78 -4
- package/package.json +2 -2
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 {
|
|
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-C9ySEdOX.cjs';
|
|
3
|
+
export { l as ActionOptions, m as ActionResult, A as ActionType, e as AudioChunk, f as AudioInput, g as AudioInputState, h as AudioOutput, B as BatchOptions, b as BatchResult, i as CaptureOptions, a7 as ClearCookiesOptions, n as ConsoleHandler, o as ConsoleMessage, p as ConsoleMessageType, a0 as ContinueRequestOptions, a8 as Cookie, q as CustomSelectConfig, a9 as DeleteCookieOptions, Z as DeviceDescriptor, _ as DeviceName, D as Dialog, r as DialogHandler, s as DialogType, t as Download, E as ElementInfo, u as ElementNotFoundError, v as EmulationState, w as ErrorHandler, a1 as FailRequestOptions, F as FileInput, x as FillOptions, y as FormField, z as FormOption, a2 as FulfillRequestOptions, G as GeolocationOptions, I as InteractiveElement, a3 as InterceptedRequest, N as NavigationError, H as NetworkIdleOptions, J as Page, K as PageError, L as PageSnapshot, P as PlayOptions, c as RecordOptions, a4 as RequestActions, a5 as ResourceType, j as RoundTripOptions, k as RoundTripResult, a6 as RouteOptions, aa as SetCookieOptions, M as SnapshotNode, O as SnapshotOptions, S as Step, d as StepResult, Q as SubmitOptions, T as TimeoutError, U as TypeOptions, V as UserAgentMetadata, W as UserAgentOptions, X as ViewportOptions, Y as WaitForOptions, ab as WaitOptions, ac as WaitResult, ad as WaitState, $ as devices, ae as waitForAnyElement, af as waitForElement, ag as waitForNavigation, ah as waitForNetworkIdle } from './types-C9ySEdOX.cjs';
|
|
4
|
+
import { C as CDPClient } from './client-B5QBRgIy.cjs';
|
|
5
|
+
export { a as CDPClientOptions, c as createCDPClient } from './client-B5QBRgIy.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 {
|
|
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-Cvvf0oGu.js';
|
|
3
|
+
export { l as ActionOptions, m as ActionResult, A as ActionType, e as AudioChunk, f as AudioInput, g as AudioInputState, h as AudioOutput, B as BatchOptions, b as BatchResult, i as CaptureOptions, a7 as ClearCookiesOptions, n as ConsoleHandler, o as ConsoleMessage, p as ConsoleMessageType, a0 as ContinueRequestOptions, a8 as Cookie, q as CustomSelectConfig, a9 as DeleteCookieOptions, Z as DeviceDescriptor, _ as DeviceName, D as Dialog, r as DialogHandler, s as DialogType, t as Download, E as ElementInfo, u as ElementNotFoundError, v as EmulationState, w as ErrorHandler, a1 as FailRequestOptions, F as FileInput, x as FillOptions, y as FormField, z as FormOption, a2 as FulfillRequestOptions, G as GeolocationOptions, I as InteractiveElement, a3 as InterceptedRequest, N as NavigationError, H as NetworkIdleOptions, J as Page, K as PageError, L as PageSnapshot, P as PlayOptions, c as RecordOptions, a4 as RequestActions, a5 as ResourceType, j as RoundTripOptions, k as RoundTripResult, a6 as RouteOptions, aa as SetCookieOptions, M as SnapshotNode, O as SnapshotOptions, S as Step, d as StepResult, Q as SubmitOptions, T as TimeoutError, U as TypeOptions, V as UserAgentMetadata, W as UserAgentOptions, X as ViewportOptions, Y as WaitForOptions, ab as WaitOptions, ac as WaitResult, ad as WaitState, $ as devices, ae as waitForAnyElement, af as waitForElement, ag as waitForNavigation, ah as waitForNetworkIdle } from './types-Cvvf0oGu.js';
|
|
4
|
+
import { C as CDPClient } from './client-B5QBRgIy.js';
|
|
5
|
+
export { a as CDPClientOptions, c as createCDPClient } from './client-B5QBRgIy.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,10 +16,10 @@ import {
|
|
|
16
16
|
waitForElement,
|
|
17
17
|
waitForNavigation,
|
|
18
18
|
waitForNetworkIdle
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-ZAXQ5OTV.mjs";
|
|
20
20
|
import {
|
|
21
21
|
createCDPClient
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-BVZALQT4.mjs";
|
|
23
23
|
import {
|
|
24
24
|
BrowserBaseProvider,
|
|
25
25
|
BrowserlessProvider,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
TimeoutError,
|
|
36
36
|
addBatchToPage,
|
|
37
37
|
validateSteps
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-7YVCOL2W.mjs";
|
|
39
39
|
import {
|
|
40
40
|
CDPError
|
|
41
41
|
} from "./chunk-JXAUPHZM.mjs";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DAEMON_CONNECT_TIMEOUT_MS
|
|
3
|
+
} from "./chunk-LUGLEMVR.mjs";
|
|
4
|
+
|
|
5
|
+
// src/daemon/transport.ts
|
|
6
|
+
import { connect as netConnect } from "net";
|
|
7
|
+
function createDaemonTransport(socketPath, options) {
|
|
8
|
+
const { timeout = DAEMON_CONNECT_TIMEOUT_MS } = options ?? {};
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const timer = setTimeout(() => {
|
|
11
|
+
socket.destroy();
|
|
12
|
+
reject(new Error(`Daemon connection timeout after ${timeout}ms`));
|
|
13
|
+
}, timeout);
|
|
14
|
+
const socket = netConnect(socketPath, () => {
|
|
15
|
+
clearTimeout(timer);
|
|
16
|
+
let buffer = "";
|
|
17
|
+
const messageHandlers = [];
|
|
18
|
+
const closeHandlers = [];
|
|
19
|
+
const errorHandlers = [];
|
|
20
|
+
socket.on("data", (chunk) => {
|
|
21
|
+
buffer += chunk.toString("utf-8");
|
|
22
|
+
let newlineIdx = buffer.indexOf("\n");
|
|
23
|
+
while (newlineIdx !== -1) {
|
|
24
|
+
const line = buffer.slice(0, newlineIdx).trim();
|
|
25
|
+
buffer = buffer.slice(newlineIdx + 1);
|
|
26
|
+
if (line.length > 0) {
|
|
27
|
+
for (const handler of messageHandlers) {
|
|
28
|
+
handler(line);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
newlineIdx = buffer.indexOf("\n");
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
socket.on("close", () => {
|
|
35
|
+
for (const handler of closeHandlers) {
|
|
36
|
+
handler();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
socket.on("error", (err) => {
|
|
40
|
+
for (const handler of errorHandlers) {
|
|
41
|
+
handler(err);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const transport = {
|
|
45
|
+
send(message) {
|
|
46
|
+
if (!socket.writable) {
|
|
47
|
+
throw new Error("Daemon socket is not writable");
|
|
48
|
+
}
|
|
49
|
+
socket.write(`${message}
|
|
50
|
+
`);
|
|
51
|
+
},
|
|
52
|
+
async close() {
|
|
53
|
+
return new Promise((resolveClose) => {
|
|
54
|
+
if (socket.destroyed) {
|
|
55
|
+
resolveClose();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
socket.once("close", () => resolveClose());
|
|
59
|
+
socket.end();
|
|
60
|
+
setTimeout(resolveClose, 200);
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
onMessage(handler) {
|
|
64
|
+
messageHandlers.push(handler);
|
|
65
|
+
},
|
|
66
|
+
onClose(handler) {
|
|
67
|
+
closeHandlers.push(handler);
|
|
68
|
+
},
|
|
69
|
+
onError(handler) {
|
|
70
|
+
errorHandlers.push(handler);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
resolve(transport);
|
|
74
|
+
});
|
|
75
|
+
socket.on("error", (err) => {
|
|
76
|
+
clearTimeout(timer);
|
|
77
|
+
reject(err);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
createDaemonTransport
|
|
83
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CDPClient } from './client-
|
|
1
|
+
import { C as CDPClient } from './client-B5QBRgIy.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Audio I/O type definitions
|
|
@@ -647,6 +647,13 @@ interface RouteOptions {
|
|
|
647
647
|
contentType?: string;
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
+
interface ActionTargetMetadata {
|
|
651
|
+
tagName?: string;
|
|
652
|
+
inputType?: string;
|
|
653
|
+
autocomplete?: string;
|
|
654
|
+
sensitiveValue?: boolean;
|
|
655
|
+
}
|
|
656
|
+
|
|
650
657
|
/**
|
|
651
658
|
* Cookie and storage types
|
|
652
659
|
*/
|
|
@@ -740,6 +747,9 @@ declare class Page {
|
|
|
740
747
|
private brokenFrame;
|
|
741
748
|
/** Last matched selector from findElement (for selectorUsed tracking) */
|
|
742
749
|
private _lastMatchedSelector;
|
|
750
|
+
private _lastActionCoordinates;
|
|
751
|
+
private _lastActionBoundingBox;
|
|
752
|
+
private _lastActionTargetMetadata;
|
|
743
753
|
/** Last snapshot for stale ref recovery */
|
|
744
754
|
private lastSnapshot?;
|
|
745
755
|
/** Audio input controller (lazy-initialized) */
|
|
@@ -761,6 +771,22 @@ declare class Page {
|
|
|
761
771
|
* Returns undefined if no selector has been matched yet.
|
|
762
772
|
*/
|
|
763
773
|
getLastMatchedSelector(): string | undefined;
|
|
774
|
+
private getActionTargetMetadata;
|
|
775
|
+
private getElementPosition;
|
|
776
|
+
private setLastActionPosition;
|
|
777
|
+
getLastActionCoordinates(): {
|
|
778
|
+
x: number;
|
|
779
|
+
y: number;
|
|
780
|
+
} | null;
|
|
781
|
+
getLastActionBoundingBox(): {
|
|
782
|
+
x: number;
|
|
783
|
+
y: number;
|
|
784
|
+
width: number;
|
|
785
|
+
height: number;
|
|
786
|
+
} | null;
|
|
787
|
+
getLastActionTargetMetadata(): ActionTargetMetadata | null;
|
|
788
|
+
/** Reset position tracking (call before each executor step) */
|
|
789
|
+
resetLastActionPosition(): void;
|
|
764
790
|
/**
|
|
765
791
|
* Initialize the page (enable required CDP domains)
|
|
766
792
|
*/
|
|
@@ -1221,7 +1247,7 @@ declare class Page {
|
|
|
1221
1247
|
*/
|
|
1222
1248
|
|
|
1223
1249
|
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';
|
|
1250
|
+
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' | 'waitForWsMessage' | 'assertNoConsoleErrors' | 'assertTextChanged' | 'assertPermission' | 'assertMediaTrackLive';
|
|
1225
1251
|
interface Step {
|
|
1226
1252
|
/** Action type */
|
|
1227
1253
|
action: ActionType;
|
|
@@ -1258,7 +1284,9 @@ interface Step {
|
|
|
1258
1284
|
/** Custom select: option selector */
|
|
1259
1285
|
option?: string | string[];
|
|
1260
1286
|
/** Custom select: match type */
|
|
1261
|
-
match?: 'text' | 'value' | 'contains';
|
|
1287
|
+
match?: 'text' | 'value' | 'contains' | string;
|
|
1288
|
+
/** Structured matcher for trace-backed waits */
|
|
1289
|
+
where?: Record<string, unknown>;
|
|
1262
1290
|
/** Scroll coordinates */
|
|
1263
1291
|
x?: number;
|
|
1264
1292
|
y?: number;
|
|
@@ -1276,12 +1304,40 @@ interface Step {
|
|
|
1276
1304
|
retry?: number;
|
|
1277
1305
|
/** Delay between retries in ms (default: 500) */
|
|
1278
1306
|
retryDelay?: number;
|
|
1307
|
+
/** Previous text expected before a change */
|
|
1308
|
+
from?: string;
|
|
1309
|
+
/** Text expected after a change */
|
|
1310
|
+
to?: string;
|
|
1311
|
+
/** Permission or resource name */
|
|
1312
|
+
name?: string;
|
|
1313
|
+
/** Expected permission state */
|
|
1314
|
+
state?: string;
|
|
1315
|
+
/** Media track kind */
|
|
1316
|
+
kind?: 'audio' | 'video';
|
|
1317
|
+
/** Assertion observation window in milliseconds */
|
|
1318
|
+
windowMs?: number;
|
|
1319
|
+
}
|
|
1320
|
+
interface RecordOptions {
|
|
1321
|
+
/** Base directory for screenshots and recording.json. */
|
|
1322
|
+
outputDir?: string;
|
|
1323
|
+
/** Session identifier stored in the manifest. CLI fills this automatically. */
|
|
1324
|
+
sessionId?: string;
|
|
1325
|
+
/** Image format. Default: 'webp' */
|
|
1326
|
+
format?: 'png' | 'jpeg' | 'webp';
|
|
1327
|
+
/** Image quality 0-100 (webp/jpeg only). Default: 40 */
|
|
1328
|
+
quality?: number;
|
|
1329
|
+
/** Inject visual highlights before capture. Default: true */
|
|
1330
|
+
highlights?: boolean;
|
|
1331
|
+
/** Actions to skip capturing. Default: ['wait', 'snapshot', 'forms', 'text', 'screenshot'] */
|
|
1332
|
+
skipActions?: ActionType[];
|
|
1279
1333
|
}
|
|
1280
1334
|
interface BatchOptions {
|
|
1281
1335
|
/** Default timeout for all steps (ms) */
|
|
1282
1336
|
timeout?: number;
|
|
1283
1337
|
/** How to handle failures */
|
|
1284
1338
|
onFail?: 'stop' | 'continue';
|
|
1339
|
+
/** Enable screenshot recording */
|
|
1340
|
+
record?: RecordOptions;
|
|
1285
1341
|
}
|
|
1286
1342
|
interface StepResult {
|
|
1287
1343
|
/** Step index */
|
|
@@ -1319,6 +1375,22 @@ interface StepResult {
|
|
|
1319
1375
|
};
|
|
1320
1376
|
/** AI-friendly suggestion for what to try next */
|
|
1321
1377
|
suggestion?: string;
|
|
1378
|
+
/** Absolute timestamp (ms since epoch) when this step completed */
|
|
1379
|
+
timestamp?: number;
|
|
1380
|
+
/** Viewport coordinates where the action occurred (center of interacted element) */
|
|
1381
|
+
coordinates?: {
|
|
1382
|
+
x: number;
|
|
1383
|
+
y: number;
|
|
1384
|
+
};
|
|
1385
|
+
/** Element bounding box at time of action (viewport-relative) */
|
|
1386
|
+
boundingBox?: {
|
|
1387
|
+
x: number;
|
|
1388
|
+
y: number;
|
|
1389
|
+
width: number;
|
|
1390
|
+
height: number;
|
|
1391
|
+
};
|
|
1392
|
+
/** Path to screenshot file captured after this step (when recording enabled) */
|
|
1393
|
+
screenshotPath?: string;
|
|
1322
1394
|
}
|
|
1323
1395
|
interface BatchResult {
|
|
1324
1396
|
/** Whether all steps succeeded */
|
|
@@ -1329,6 +1401,8 @@ interface BatchResult {
|
|
|
1329
1401
|
steps: StepResult[];
|
|
1330
1402
|
/** Total execution time in ms */
|
|
1331
1403
|
totalDurationMs: number;
|
|
1404
|
+
/** Path to recording manifest (when recording is enabled) */
|
|
1405
|
+
recordingManifest?: string;
|
|
1332
1406
|
}
|
|
1333
1407
|
|
|
1334
|
-
export {
|
|
1408
|
+
export { devices 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, type NetworkIdleOptions as H, type InteractiveElement as I, Page as J, type PageError as K, type PageSnapshot as L, type SnapshotNode as M, NavigationError as N, type SnapshotOptions as O, type PlayOptions as P, type SubmitOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type TypeOptions as U, type UserAgentMetadata as V, type UserAgentOptions as W, type ViewportOptions as X, type WaitForOptions as Y, type DeviceDescriptor as Z, type DeviceName as _, type RequestHandler as a, type ContinueRequestOptions as a0, type FailRequestOptions as a1, type FulfillRequestOptions as a2, type InterceptedRequest as a3, type RequestActions as a4, type ResourceType as a5, type RouteOptions as a6, type ClearCookiesOptions as a7, type Cookie as a8, type DeleteCookieOptions as a9, type SetCookieOptions as aa, type WaitOptions as ab, type WaitResult as ac, type WaitState as ad, waitForAnyElement as ae, waitForElement as af, waitForNavigation as ag, waitForNetworkIdle as ah, type FailureHint as ai, type FailureReason as aj, type BatchResult as b, type RecordOptions as c, type StepResult as d, type AudioChunk as e, AudioInput as f, type AudioInputState as g, AudioOutput as h, type CaptureOptions as i, type RoundTripOptions as j, type RoundTripResult as k, type ActionOptions as l, type ActionResult as m, type ConsoleHandler as n, type ConsoleMessage as o, type ConsoleMessageType as p, type CustomSelectConfig as q, type DialogHandler as r, type DialogType as s, type Download as t, ElementNotFoundError as u, type EmulationState as v, type ErrorHandler as w, type FillOptions as x, type FormField as y, type FormOption as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CDPClient } from './client-
|
|
1
|
+
import { C as CDPClient } from './client-B5QBRgIy.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Audio I/O type definitions
|
|
@@ -647,6 +647,13 @@ interface RouteOptions {
|
|
|
647
647
|
contentType?: string;
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
+
interface ActionTargetMetadata {
|
|
651
|
+
tagName?: string;
|
|
652
|
+
inputType?: string;
|
|
653
|
+
autocomplete?: string;
|
|
654
|
+
sensitiveValue?: boolean;
|
|
655
|
+
}
|
|
656
|
+
|
|
650
657
|
/**
|
|
651
658
|
* Cookie and storage types
|
|
652
659
|
*/
|
|
@@ -740,6 +747,9 @@ declare class Page {
|
|
|
740
747
|
private brokenFrame;
|
|
741
748
|
/** Last matched selector from findElement (for selectorUsed tracking) */
|
|
742
749
|
private _lastMatchedSelector;
|
|
750
|
+
private _lastActionCoordinates;
|
|
751
|
+
private _lastActionBoundingBox;
|
|
752
|
+
private _lastActionTargetMetadata;
|
|
743
753
|
/** Last snapshot for stale ref recovery */
|
|
744
754
|
private lastSnapshot?;
|
|
745
755
|
/** Audio input controller (lazy-initialized) */
|
|
@@ -761,6 +771,22 @@ declare class Page {
|
|
|
761
771
|
* Returns undefined if no selector has been matched yet.
|
|
762
772
|
*/
|
|
763
773
|
getLastMatchedSelector(): string | undefined;
|
|
774
|
+
private getActionTargetMetadata;
|
|
775
|
+
private getElementPosition;
|
|
776
|
+
private setLastActionPosition;
|
|
777
|
+
getLastActionCoordinates(): {
|
|
778
|
+
x: number;
|
|
779
|
+
y: number;
|
|
780
|
+
} | null;
|
|
781
|
+
getLastActionBoundingBox(): {
|
|
782
|
+
x: number;
|
|
783
|
+
y: number;
|
|
784
|
+
width: number;
|
|
785
|
+
height: number;
|
|
786
|
+
} | null;
|
|
787
|
+
getLastActionTargetMetadata(): ActionTargetMetadata | null;
|
|
788
|
+
/** Reset position tracking (call before each executor step) */
|
|
789
|
+
resetLastActionPosition(): void;
|
|
764
790
|
/**
|
|
765
791
|
* Initialize the page (enable required CDP domains)
|
|
766
792
|
*/
|
|
@@ -1221,7 +1247,7 @@ declare class Page {
|
|
|
1221
1247
|
*/
|
|
1222
1248
|
|
|
1223
1249
|
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';
|
|
1250
|
+
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' | 'waitForWsMessage' | 'assertNoConsoleErrors' | 'assertTextChanged' | 'assertPermission' | 'assertMediaTrackLive';
|
|
1225
1251
|
interface Step {
|
|
1226
1252
|
/** Action type */
|
|
1227
1253
|
action: ActionType;
|
|
@@ -1258,7 +1284,9 @@ interface Step {
|
|
|
1258
1284
|
/** Custom select: option selector */
|
|
1259
1285
|
option?: string | string[];
|
|
1260
1286
|
/** Custom select: match type */
|
|
1261
|
-
match?: 'text' | 'value' | 'contains';
|
|
1287
|
+
match?: 'text' | 'value' | 'contains' | string;
|
|
1288
|
+
/** Structured matcher for trace-backed waits */
|
|
1289
|
+
where?: Record<string, unknown>;
|
|
1262
1290
|
/** Scroll coordinates */
|
|
1263
1291
|
x?: number;
|
|
1264
1292
|
y?: number;
|
|
@@ -1276,12 +1304,40 @@ interface Step {
|
|
|
1276
1304
|
retry?: number;
|
|
1277
1305
|
/** Delay between retries in ms (default: 500) */
|
|
1278
1306
|
retryDelay?: number;
|
|
1307
|
+
/** Previous text expected before a change */
|
|
1308
|
+
from?: string;
|
|
1309
|
+
/** Text expected after a change */
|
|
1310
|
+
to?: string;
|
|
1311
|
+
/** Permission or resource name */
|
|
1312
|
+
name?: string;
|
|
1313
|
+
/** Expected permission state */
|
|
1314
|
+
state?: string;
|
|
1315
|
+
/** Media track kind */
|
|
1316
|
+
kind?: 'audio' | 'video';
|
|
1317
|
+
/** Assertion observation window in milliseconds */
|
|
1318
|
+
windowMs?: number;
|
|
1319
|
+
}
|
|
1320
|
+
interface RecordOptions {
|
|
1321
|
+
/** Base directory for screenshots and recording.json. */
|
|
1322
|
+
outputDir?: string;
|
|
1323
|
+
/** Session identifier stored in the manifest. CLI fills this automatically. */
|
|
1324
|
+
sessionId?: string;
|
|
1325
|
+
/** Image format. Default: 'webp' */
|
|
1326
|
+
format?: 'png' | 'jpeg' | 'webp';
|
|
1327
|
+
/** Image quality 0-100 (webp/jpeg only). Default: 40 */
|
|
1328
|
+
quality?: number;
|
|
1329
|
+
/** Inject visual highlights before capture. Default: true */
|
|
1330
|
+
highlights?: boolean;
|
|
1331
|
+
/** Actions to skip capturing. Default: ['wait', 'snapshot', 'forms', 'text', 'screenshot'] */
|
|
1332
|
+
skipActions?: ActionType[];
|
|
1279
1333
|
}
|
|
1280
1334
|
interface BatchOptions {
|
|
1281
1335
|
/** Default timeout for all steps (ms) */
|
|
1282
1336
|
timeout?: number;
|
|
1283
1337
|
/** How to handle failures */
|
|
1284
1338
|
onFail?: 'stop' | 'continue';
|
|
1339
|
+
/** Enable screenshot recording */
|
|
1340
|
+
record?: RecordOptions;
|
|
1285
1341
|
}
|
|
1286
1342
|
interface StepResult {
|
|
1287
1343
|
/** Step index */
|
|
@@ -1319,6 +1375,22 @@ interface StepResult {
|
|
|
1319
1375
|
};
|
|
1320
1376
|
/** AI-friendly suggestion for what to try next */
|
|
1321
1377
|
suggestion?: string;
|
|
1378
|
+
/** Absolute timestamp (ms since epoch) when this step completed */
|
|
1379
|
+
timestamp?: number;
|
|
1380
|
+
/** Viewport coordinates where the action occurred (center of interacted element) */
|
|
1381
|
+
coordinates?: {
|
|
1382
|
+
x: number;
|
|
1383
|
+
y: number;
|
|
1384
|
+
};
|
|
1385
|
+
/** Element bounding box at time of action (viewport-relative) */
|
|
1386
|
+
boundingBox?: {
|
|
1387
|
+
x: number;
|
|
1388
|
+
y: number;
|
|
1389
|
+
width: number;
|
|
1390
|
+
height: number;
|
|
1391
|
+
};
|
|
1392
|
+
/** Path to screenshot file captured after this step (when recording enabled) */
|
|
1393
|
+
screenshotPath?: string;
|
|
1322
1394
|
}
|
|
1323
1395
|
interface BatchResult {
|
|
1324
1396
|
/** Whether all steps succeeded */
|
|
@@ -1329,6 +1401,8 @@ interface BatchResult {
|
|
|
1329
1401
|
steps: StepResult[];
|
|
1330
1402
|
/** Total execution time in ms */
|
|
1331
1403
|
totalDurationMs: number;
|
|
1404
|
+
/** Path to recording manifest (when recording is enabled) */
|
|
1405
|
+
recordingManifest?: string;
|
|
1332
1406
|
}
|
|
1333
1407
|
|
|
1334
|
-
export {
|
|
1408
|
+
export { devices 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, type NetworkIdleOptions as H, type InteractiveElement as I, Page as J, type PageError as K, type PageSnapshot as L, type SnapshotNode as M, NavigationError as N, type SnapshotOptions as O, type PlayOptions as P, type SubmitOptions as Q, type RequestPattern as R, type Step as S, TimeoutError as T, type TypeOptions as U, type UserAgentMetadata as V, type UserAgentOptions as W, type ViewportOptions as X, type WaitForOptions as Y, type DeviceDescriptor as Z, type DeviceName as _, type RequestHandler as a, type ContinueRequestOptions as a0, type FailRequestOptions as a1, type FulfillRequestOptions as a2, type InterceptedRequest as a3, type RequestActions as a4, type ResourceType as a5, type RouteOptions as a6, type ClearCookiesOptions as a7, type Cookie as a8, type DeleteCookieOptions as a9, type SetCookieOptions as aa, type WaitOptions as ab, type WaitResult as ac, type WaitState as ad, waitForAnyElement as ae, waitForElement as af, waitForNavigation as ag, waitForNetworkIdle as ah, type FailureHint as ai, type FailureReason as aj, type BatchResult as b, type RecordOptions as c, type StepResult as d, type AudioChunk as e, AudioInput as f, type AudioInputState as g, AudioOutput as h, type CaptureOptions as i, type RoundTripOptions as j, type RoundTripResult as k, type ActionOptions as l, type ActionResult as m, type ConsoleHandler as n, type ConsoleMessage as o, type ConsoleMessageType as p, type CustomSelectConfig as q, type DialogHandler as r, type DialogType as s, type Download as t, ElementNotFoundError as u, type EmulationState as v, type ErrorHandler as w, type FillOptions as x, type FormField as y, type FormOption 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.15",
|
|
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",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"fixtures:serve": "bun tests/fixtures/server.ts"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@biomejs/biome": "^2.
|
|
71
|
+
"@biomejs/biome": "^2.4.6",
|
|
72
72
|
"@types/bun": "latest",
|
|
73
73
|
"chrome-launcher": "^1.2.1",
|
|
74
74
|
"oxlint": "^1.51.0",
|