browserclaw 0.5.7 → 0.5.8
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/dist/index.cjs +532 -171
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +211 -2
- package/dist/index.d.ts +211 -2
- package/dist/index.js +520 -173
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,131 @@
|
|
|
1
1
|
import * as playwright_core from 'playwright-core';
|
|
2
|
-
import { BrowserContext } from 'playwright-core';
|
|
2
|
+
import { BrowserContext, Page, CDPSession } from 'playwright-core';
|
|
3
3
|
import * as node_dns from 'node:dns';
|
|
4
4
|
import { lookup as lookup$1 } from 'node:dns';
|
|
5
5
|
import { lookup } from 'node:dns/promises';
|
|
6
6
|
|
|
7
|
+
/** A single action within a batch. */
|
|
8
|
+
type BatchAction = {
|
|
9
|
+
kind: 'click';
|
|
10
|
+
ref?: string;
|
|
11
|
+
selector?: string;
|
|
12
|
+
targetId?: string;
|
|
13
|
+
doubleClick?: boolean;
|
|
14
|
+
button?: string;
|
|
15
|
+
modifiers?: string[];
|
|
16
|
+
delayMs?: number;
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'type';
|
|
20
|
+
ref?: string;
|
|
21
|
+
selector?: string;
|
|
22
|
+
text: string;
|
|
23
|
+
targetId?: string;
|
|
24
|
+
submit?: boolean;
|
|
25
|
+
slowly?: boolean;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'press';
|
|
29
|
+
key: string;
|
|
30
|
+
targetId?: string;
|
|
31
|
+
delayMs?: number;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'hover';
|
|
34
|
+
ref?: string;
|
|
35
|
+
selector?: string;
|
|
36
|
+
targetId?: string;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'scrollIntoView';
|
|
40
|
+
ref?: string;
|
|
41
|
+
selector?: string;
|
|
42
|
+
targetId?: string;
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'drag';
|
|
46
|
+
startRef?: string;
|
|
47
|
+
startSelector?: string;
|
|
48
|
+
endRef?: string;
|
|
49
|
+
endSelector?: string;
|
|
50
|
+
targetId?: string;
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'select';
|
|
54
|
+
ref?: string;
|
|
55
|
+
selector?: string;
|
|
56
|
+
values: string[];
|
|
57
|
+
targetId?: string;
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'fill';
|
|
61
|
+
fields: Array<{
|
|
62
|
+
ref: string;
|
|
63
|
+
type?: string;
|
|
64
|
+
value?: string | number | boolean;
|
|
65
|
+
}>;
|
|
66
|
+
targetId?: string;
|
|
67
|
+
timeoutMs?: number;
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'resize';
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
targetId?: string;
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'wait';
|
|
75
|
+
timeMs?: number;
|
|
76
|
+
text?: string;
|
|
77
|
+
textGone?: string;
|
|
78
|
+
selector?: string;
|
|
79
|
+
url?: string;
|
|
80
|
+
loadState?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
81
|
+
fn?: string;
|
|
82
|
+
targetId?: string;
|
|
83
|
+
timeoutMs?: number;
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'evaluate';
|
|
86
|
+
fn: string;
|
|
87
|
+
ref?: string;
|
|
88
|
+
targetId?: string;
|
|
89
|
+
timeoutMs?: number;
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'close';
|
|
92
|
+
targetId?: string;
|
|
93
|
+
} | {
|
|
94
|
+
kind: 'batch';
|
|
95
|
+
actions: BatchAction[];
|
|
96
|
+
targetId?: string;
|
|
97
|
+
stopOnError?: boolean;
|
|
98
|
+
};
|
|
99
|
+
/** Result of a single action within a batch. */
|
|
100
|
+
type BatchActionResult = {
|
|
101
|
+
ok: true;
|
|
102
|
+
} | {
|
|
103
|
+
ok: false;
|
|
104
|
+
error: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Execute a single batch action.
|
|
108
|
+
*/
|
|
109
|
+
declare function executeSingleAction(action: BatchAction, cdpUrl: string, targetId: string | undefined, evaluateEnabled: boolean, depth?: number): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Execute multiple browser actions in sequence.
|
|
112
|
+
*
|
|
113
|
+
* @param opts.actions - Array of actions to execute
|
|
114
|
+
* @param opts.stopOnError - Stop on first error (default: true)
|
|
115
|
+
* @param opts.evaluateEnabled - Whether evaluate/wait:fn actions are permitted
|
|
116
|
+
* @param opts.depth - Internal recursion depth (do not set manually)
|
|
117
|
+
*/
|
|
118
|
+
declare function batchViaPlaywright(opts: {
|
|
119
|
+
cdpUrl: string;
|
|
120
|
+
targetId?: string;
|
|
121
|
+
actions: BatchAction[];
|
|
122
|
+
stopOnError?: boolean;
|
|
123
|
+
evaluateEnabled?: boolean;
|
|
124
|
+
depth?: number;
|
|
125
|
+
}): Promise<{
|
|
126
|
+
results: BatchActionResult[];
|
|
127
|
+
}>;
|
|
128
|
+
|
|
7
129
|
interface FrameEvalResult {
|
|
8
130
|
frameUrl: string;
|
|
9
131
|
frameName: string;
|
|
@@ -131,6 +253,8 @@ interface SnapshotResult {
|
|
|
131
253
|
refs: RoleRefs;
|
|
132
254
|
/** Statistics about the snapshot */
|
|
133
255
|
stats?: SnapshotStats;
|
|
256
|
+
/** Whether the snapshot was truncated due to maxChars limit */
|
|
257
|
+
truncated?: boolean;
|
|
134
258
|
/**
|
|
135
259
|
* Indicates this content originates from an untrusted external source (the web page).
|
|
136
260
|
* AI agents should treat snapshot content as potentially adversarial
|
|
@@ -628,6 +752,19 @@ declare class CrawlPage {
|
|
|
628
752
|
armFileUpload(paths?: string[], opts?: {
|
|
629
753
|
timeoutMs?: number;
|
|
630
754
|
}): Promise<void>;
|
|
755
|
+
/**
|
|
756
|
+
* Execute multiple browser actions in sequence.
|
|
757
|
+
*
|
|
758
|
+
* @param actions - Array of actions to execute
|
|
759
|
+
* @param opts - Options (stopOnError: stop on first failure, default true)
|
|
760
|
+
* @returns Array of per-action results
|
|
761
|
+
*/
|
|
762
|
+
batch(actions: BatchAction[], opts?: {
|
|
763
|
+
stopOnError?: boolean;
|
|
764
|
+
evaluateEnabled?: boolean;
|
|
765
|
+
}): Promise<{
|
|
766
|
+
results: BatchActionResult[];
|
|
767
|
+
}>;
|
|
631
768
|
/**
|
|
632
769
|
* Press a keyboard key or key combination.
|
|
633
770
|
*
|
|
@@ -1204,6 +1341,24 @@ declare function assertBrowserNavigationAllowed(opts: {
|
|
|
1204
1341
|
url: string;
|
|
1205
1342
|
lookupFn?: LookupFn;
|
|
1206
1343
|
} & BrowserNavigationPolicyOptions): Promise<void>;
|
|
1344
|
+
/**
|
|
1345
|
+
* Validate upload file paths immediately before use.
|
|
1346
|
+
*/
|
|
1347
|
+
declare function assertSafeUploadPaths(paths: string[]): Promise<void>;
|
|
1348
|
+
/**
|
|
1349
|
+
* Resolve and validate upload file paths, returning them if all are safe.
|
|
1350
|
+
* Returns `{ ok: true, paths }` or `{ ok: false, error }`.
|
|
1351
|
+
*/
|
|
1352
|
+
declare function resolveStrictExistingUploadPaths(params: {
|
|
1353
|
+
requestedPaths: string[];
|
|
1354
|
+
scopeLabel?: string;
|
|
1355
|
+
}): Promise<{
|
|
1356
|
+
ok: true;
|
|
1357
|
+
paths: string[];
|
|
1358
|
+
} | {
|
|
1359
|
+
ok: false;
|
|
1360
|
+
error: string;
|
|
1361
|
+
}>;
|
|
1207
1362
|
/**
|
|
1208
1363
|
* Sanitize an untrusted file name (e.g. from a download) to prevent path traversal.
|
|
1209
1364
|
*/
|
|
@@ -1237,6 +1392,24 @@ declare function assertBrowserNavigationRedirectChainAllowed(opts: {
|
|
|
1237
1392
|
*/
|
|
1238
1393
|
declare function requiresInspectableBrowserNavigationRedirects(ssrfPolicy?: SsrfPolicy): boolean;
|
|
1239
1394
|
|
|
1395
|
+
declare class BrowserTabNotFoundError extends Error {
|
|
1396
|
+
constructor(message?: string);
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Run a function with a scoped Playwright CDP session, detaching when done.
|
|
1400
|
+
*/
|
|
1401
|
+
declare function withPlaywrightPageCdpSession<T>(page: Page, fn: (session: CDPSession) => Promise<T>): Promise<T>;
|
|
1402
|
+
/**
|
|
1403
|
+
* Run a function with a page-scoped CDP client.
|
|
1404
|
+
* For extension relay endpoints, routes through the raw CDP websocket.
|
|
1405
|
+
* Otherwise, uses a Playwright CDP session.
|
|
1406
|
+
*/
|
|
1407
|
+
declare function withPageScopedCdpClient<T>(opts: {
|
|
1408
|
+
cdpUrl: string;
|
|
1409
|
+
page: Page;
|
|
1410
|
+
targetId?: string;
|
|
1411
|
+
fn: (send: (method: string, params?: Record<string, unknown>) => Promise<any>) => Promise<T>;
|
|
1412
|
+
}): Promise<T>;
|
|
1240
1413
|
declare function ensureContextState(context: BrowserContext): ContextState;
|
|
1241
1414
|
/**
|
|
1242
1415
|
* Force-disconnect a Playwright browser connection for a given CDP target.
|
|
@@ -1248,5 +1421,41 @@ declare function forceDisconnectPlaywrightForTarget(opts: {
|
|
|
1248
1421
|
targetId?: string;
|
|
1249
1422
|
reason?: string;
|
|
1250
1423
|
}): Promise<void>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Resolve a page by targetId or throw BrowserTabNotFoundError.
|
|
1426
|
+
*/
|
|
1427
|
+
declare function resolvePageByTargetIdOrThrow(opts: {
|
|
1428
|
+
cdpUrl: string;
|
|
1429
|
+
targetId: string;
|
|
1430
|
+
}): Promise<Page>;
|
|
1431
|
+
/**
|
|
1432
|
+
* Parse a role ref string (e.g. "e1", "@e1", "ref=e1") to a normalized ref ID.
|
|
1433
|
+
* Returns null if the string is not a valid role ref.
|
|
1434
|
+
*/
|
|
1435
|
+
declare function parseRoleRef(raw: string): string | null;
|
|
1436
|
+
/**
|
|
1437
|
+
* Require a ref string, normalizing and validating it.
|
|
1438
|
+
* Throws if the ref is empty.
|
|
1439
|
+
*/
|
|
1440
|
+
declare function requireRef(value: string | undefined): string;
|
|
1441
|
+
/**
|
|
1442
|
+
* Require either a ref or selector, returning whichever is provided.
|
|
1443
|
+
* Throws if neither is provided.
|
|
1444
|
+
*/
|
|
1445
|
+
declare function requireRefOrSelector(ref?: string, selector?: string): {
|
|
1446
|
+
ref?: string;
|
|
1447
|
+
selector?: string;
|
|
1448
|
+
};
|
|
1449
|
+
/** Clamp interaction timeout to [500, 60000]ms range, defaulting to 8000ms. */
|
|
1450
|
+
declare function resolveInteractionTimeoutMs(timeoutMs?: number): number;
|
|
1451
|
+
/** Bounded delay validator for animation/interaction delays. */
|
|
1452
|
+
declare function resolveBoundedDelayMs(value: number | undefined, label: string, maxMs: number): number;
|
|
1453
|
+
/**
|
|
1454
|
+
* Get a page for a target, ensuring page state is initialized and role refs are restored.
|
|
1455
|
+
*/
|
|
1456
|
+
declare function getRestoredPageForTarget(opts: {
|
|
1457
|
+
cdpUrl: string;
|
|
1458
|
+
targetId?: string;
|
|
1459
|
+
}): Promise<Page>;
|
|
1251
1460
|
|
|
1252
|
-
export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, createPinnedLookup, ensureContextState, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, requiresInspectableBrowserNavigationRedirects, resolvePinnedHostnameWithPolicy, sanitizeUntrustedFileName, withBrowserNavigationPolicy, writeViaSiblingTempPath };
|
|
1461
|
+
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,131 @@
|
|
|
1
1
|
import * as playwright_core from 'playwright-core';
|
|
2
|
-
import { BrowserContext } from 'playwright-core';
|
|
2
|
+
import { BrowserContext, Page, CDPSession } from 'playwright-core';
|
|
3
3
|
import * as node_dns from 'node:dns';
|
|
4
4
|
import { lookup as lookup$1 } from 'node:dns';
|
|
5
5
|
import { lookup } from 'node:dns/promises';
|
|
6
6
|
|
|
7
|
+
/** A single action within a batch. */
|
|
8
|
+
type BatchAction = {
|
|
9
|
+
kind: 'click';
|
|
10
|
+
ref?: string;
|
|
11
|
+
selector?: string;
|
|
12
|
+
targetId?: string;
|
|
13
|
+
doubleClick?: boolean;
|
|
14
|
+
button?: string;
|
|
15
|
+
modifiers?: string[];
|
|
16
|
+
delayMs?: number;
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'type';
|
|
20
|
+
ref?: string;
|
|
21
|
+
selector?: string;
|
|
22
|
+
text: string;
|
|
23
|
+
targetId?: string;
|
|
24
|
+
submit?: boolean;
|
|
25
|
+
slowly?: boolean;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'press';
|
|
29
|
+
key: string;
|
|
30
|
+
targetId?: string;
|
|
31
|
+
delayMs?: number;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'hover';
|
|
34
|
+
ref?: string;
|
|
35
|
+
selector?: string;
|
|
36
|
+
targetId?: string;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'scrollIntoView';
|
|
40
|
+
ref?: string;
|
|
41
|
+
selector?: string;
|
|
42
|
+
targetId?: string;
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'drag';
|
|
46
|
+
startRef?: string;
|
|
47
|
+
startSelector?: string;
|
|
48
|
+
endRef?: string;
|
|
49
|
+
endSelector?: string;
|
|
50
|
+
targetId?: string;
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'select';
|
|
54
|
+
ref?: string;
|
|
55
|
+
selector?: string;
|
|
56
|
+
values: string[];
|
|
57
|
+
targetId?: string;
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'fill';
|
|
61
|
+
fields: Array<{
|
|
62
|
+
ref: string;
|
|
63
|
+
type?: string;
|
|
64
|
+
value?: string | number | boolean;
|
|
65
|
+
}>;
|
|
66
|
+
targetId?: string;
|
|
67
|
+
timeoutMs?: number;
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'resize';
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
targetId?: string;
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'wait';
|
|
75
|
+
timeMs?: number;
|
|
76
|
+
text?: string;
|
|
77
|
+
textGone?: string;
|
|
78
|
+
selector?: string;
|
|
79
|
+
url?: string;
|
|
80
|
+
loadState?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
81
|
+
fn?: string;
|
|
82
|
+
targetId?: string;
|
|
83
|
+
timeoutMs?: number;
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'evaluate';
|
|
86
|
+
fn: string;
|
|
87
|
+
ref?: string;
|
|
88
|
+
targetId?: string;
|
|
89
|
+
timeoutMs?: number;
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'close';
|
|
92
|
+
targetId?: string;
|
|
93
|
+
} | {
|
|
94
|
+
kind: 'batch';
|
|
95
|
+
actions: BatchAction[];
|
|
96
|
+
targetId?: string;
|
|
97
|
+
stopOnError?: boolean;
|
|
98
|
+
};
|
|
99
|
+
/** Result of a single action within a batch. */
|
|
100
|
+
type BatchActionResult = {
|
|
101
|
+
ok: true;
|
|
102
|
+
} | {
|
|
103
|
+
ok: false;
|
|
104
|
+
error: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Execute a single batch action.
|
|
108
|
+
*/
|
|
109
|
+
declare function executeSingleAction(action: BatchAction, cdpUrl: string, targetId: string | undefined, evaluateEnabled: boolean, depth?: number): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Execute multiple browser actions in sequence.
|
|
112
|
+
*
|
|
113
|
+
* @param opts.actions - Array of actions to execute
|
|
114
|
+
* @param opts.stopOnError - Stop on first error (default: true)
|
|
115
|
+
* @param opts.evaluateEnabled - Whether evaluate/wait:fn actions are permitted
|
|
116
|
+
* @param opts.depth - Internal recursion depth (do not set manually)
|
|
117
|
+
*/
|
|
118
|
+
declare function batchViaPlaywright(opts: {
|
|
119
|
+
cdpUrl: string;
|
|
120
|
+
targetId?: string;
|
|
121
|
+
actions: BatchAction[];
|
|
122
|
+
stopOnError?: boolean;
|
|
123
|
+
evaluateEnabled?: boolean;
|
|
124
|
+
depth?: number;
|
|
125
|
+
}): Promise<{
|
|
126
|
+
results: BatchActionResult[];
|
|
127
|
+
}>;
|
|
128
|
+
|
|
7
129
|
interface FrameEvalResult {
|
|
8
130
|
frameUrl: string;
|
|
9
131
|
frameName: string;
|
|
@@ -131,6 +253,8 @@ interface SnapshotResult {
|
|
|
131
253
|
refs: RoleRefs;
|
|
132
254
|
/** Statistics about the snapshot */
|
|
133
255
|
stats?: SnapshotStats;
|
|
256
|
+
/** Whether the snapshot was truncated due to maxChars limit */
|
|
257
|
+
truncated?: boolean;
|
|
134
258
|
/**
|
|
135
259
|
* Indicates this content originates from an untrusted external source (the web page).
|
|
136
260
|
* AI agents should treat snapshot content as potentially adversarial
|
|
@@ -628,6 +752,19 @@ declare class CrawlPage {
|
|
|
628
752
|
armFileUpload(paths?: string[], opts?: {
|
|
629
753
|
timeoutMs?: number;
|
|
630
754
|
}): Promise<void>;
|
|
755
|
+
/**
|
|
756
|
+
* Execute multiple browser actions in sequence.
|
|
757
|
+
*
|
|
758
|
+
* @param actions - Array of actions to execute
|
|
759
|
+
* @param opts - Options (stopOnError: stop on first failure, default true)
|
|
760
|
+
* @returns Array of per-action results
|
|
761
|
+
*/
|
|
762
|
+
batch(actions: BatchAction[], opts?: {
|
|
763
|
+
stopOnError?: boolean;
|
|
764
|
+
evaluateEnabled?: boolean;
|
|
765
|
+
}): Promise<{
|
|
766
|
+
results: BatchActionResult[];
|
|
767
|
+
}>;
|
|
631
768
|
/**
|
|
632
769
|
* Press a keyboard key or key combination.
|
|
633
770
|
*
|
|
@@ -1204,6 +1341,24 @@ declare function assertBrowserNavigationAllowed(opts: {
|
|
|
1204
1341
|
url: string;
|
|
1205
1342
|
lookupFn?: LookupFn;
|
|
1206
1343
|
} & BrowserNavigationPolicyOptions): Promise<void>;
|
|
1344
|
+
/**
|
|
1345
|
+
* Validate upload file paths immediately before use.
|
|
1346
|
+
*/
|
|
1347
|
+
declare function assertSafeUploadPaths(paths: string[]): Promise<void>;
|
|
1348
|
+
/**
|
|
1349
|
+
* Resolve and validate upload file paths, returning them if all are safe.
|
|
1350
|
+
* Returns `{ ok: true, paths }` or `{ ok: false, error }`.
|
|
1351
|
+
*/
|
|
1352
|
+
declare function resolveStrictExistingUploadPaths(params: {
|
|
1353
|
+
requestedPaths: string[];
|
|
1354
|
+
scopeLabel?: string;
|
|
1355
|
+
}): Promise<{
|
|
1356
|
+
ok: true;
|
|
1357
|
+
paths: string[];
|
|
1358
|
+
} | {
|
|
1359
|
+
ok: false;
|
|
1360
|
+
error: string;
|
|
1361
|
+
}>;
|
|
1207
1362
|
/**
|
|
1208
1363
|
* Sanitize an untrusted file name (e.g. from a download) to prevent path traversal.
|
|
1209
1364
|
*/
|
|
@@ -1237,6 +1392,24 @@ declare function assertBrowserNavigationRedirectChainAllowed(opts: {
|
|
|
1237
1392
|
*/
|
|
1238
1393
|
declare function requiresInspectableBrowserNavigationRedirects(ssrfPolicy?: SsrfPolicy): boolean;
|
|
1239
1394
|
|
|
1395
|
+
declare class BrowserTabNotFoundError extends Error {
|
|
1396
|
+
constructor(message?: string);
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Run a function with a scoped Playwright CDP session, detaching when done.
|
|
1400
|
+
*/
|
|
1401
|
+
declare function withPlaywrightPageCdpSession<T>(page: Page, fn: (session: CDPSession) => Promise<T>): Promise<T>;
|
|
1402
|
+
/**
|
|
1403
|
+
* Run a function with a page-scoped CDP client.
|
|
1404
|
+
* For extension relay endpoints, routes through the raw CDP websocket.
|
|
1405
|
+
* Otherwise, uses a Playwright CDP session.
|
|
1406
|
+
*/
|
|
1407
|
+
declare function withPageScopedCdpClient<T>(opts: {
|
|
1408
|
+
cdpUrl: string;
|
|
1409
|
+
page: Page;
|
|
1410
|
+
targetId?: string;
|
|
1411
|
+
fn: (send: (method: string, params?: Record<string, unknown>) => Promise<any>) => Promise<T>;
|
|
1412
|
+
}): Promise<T>;
|
|
1240
1413
|
declare function ensureContextState(context: BrowserContext): ContextState;
|
|
1241
1414
|
/**
|
|
1242
1415
|
* Force-disconnect a Playwright browser connection for a given CDP target.
|
|
@@ -1248,5 +1421,41 @@ declare function forceDisconnectPlaywrightForTarget(opts: {
|
|
|
1248
1421
|
targetId?: string;
|
|
1249
1422
|
reason?: string;
|
|
1250
1423
|
}): Promise<void>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Resolve a page by targetId or throw BrowserTabNotFoundError.
|
|
1426
|
+
*/
|
|
1427
|
+
declare function resolvePageByTargetIdOrThrow(opts: {
|
|
1428
|
+
cdpUrl: string;
|
|
1429
|
+
targetId: string;
|
|
1430
|
+
}): Promise<Page>;
|
|
1431
|
+
/**
|
|
1432
|
+
* Parse a role ref string (e.g. "e1", "@e1", "ref=e1") to a normalized ref ID.
|
|
1433
|
+
* Returns null if the string is not a valid role ref.
|
|
1434
|
+
*/
|
|
1435
|
+
declare function parseRoleRef(raw: string): string | null;
|
|
1436
|
+
/**
|
|
1437
|
+
* Require a ref string, normalizing and validating it.
|
|
1438
|
+
* Throws if the ref is empty.
|
|
1439
|
+
*/
|
|
1440
|
+
declare function requireRef(value: string | undefined): string;
|
|
1441
|
+
/**
|
|
1442
|
+
* Require either a ref or selector, returning whichever is provided.
|
|
1443
|
+
* Throws if neither is provided.
|
|
1444
|
+
*/
|
|
1445
|
+
declare function requireRefOrSelector(ref?: string, selector?: string): {
|
|
1446
|
+
ref?: string;
|
|
1447
|
+
selector?: string;
|
|
1448
|
+
};
|
|
1449
|
+
/** Clamp interaction timeout to [500, 60000]ms range, defaulting to 8000ms. */
|
|
1450
|
+
declare function resolveInteractionTimeoutMs(timeoutMs?: number): number;
|
|
1451
|
+
/** Bounded delay validator for animation/interaction delays. */
|
|
1452
|
+
declare function resolveBoundedDelayMs(value: number | undefined, label: string, maxMs: number): number;
|
|
1453
|
+
/**
|
|
1454
|
+
* Get a page for a target, ensuring page state is initialized and role refs are restored.
|
|
1455
|
+
*/
|
|
1456
|
+
declare function getRestoredPageForTarget(opts: {
|
|
1457
|
+
cdpUrl: string;
|
|
1458
|
+
targetId?: string;
|
|
1459
|
+
}): Promise<Page>;
|
|
1251
1460
|
|
|
1252
|
-
export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, createPinnedLookup, ensureContextState, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, requiresInspectableBrowserNavigationRedirects, resolvePinnedHostnameWithPolicy, sanitizeUntrustedFileName, withBrowserNavigationPolicy, writeViaSiblingTempPath };
|
|
1461
|
+
export { type AriaNode, type AriaSnapshotResult, type BatchAction, type BatchActionResult, BrowserClaw, type BrowserNavigationPolicyOptions, type BrowserNavigationRequestLike, type BrowserTab, BrowserTabNotFoundError, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type ContextState, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, InvalidBrowserNavigationUrlError, type LaunchOptions, type LookupFn, type NetworkRequest, type PageError, type PinnedHostname, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type SsrfPolicy, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions, assertBrowserNavigationAllowed, assertBrowserNavigationRedirectChainAllowed, assertBrowserNavigationResultAllowed, assertSafeUploadPaths, batchViaPlaywright, createPinnedLookup, ensureContextState, executeSingleAction, forceDisconnectPlaywrightForTarget, getChromeWebSocketUrl, getRestoredPageForTarget, isChromeCdpReady, isChromeReachable, normalizeCdpHttpBaseForJsonEndpoints, parseRoleRef, requireRef, requireRefOrSelector, requiresInspectableBrowserNavigationRedirects, resolveBoundedDelayMs, resolveInteractionTimeoutMs, resolvePageByTargetIdOrThrow, resolvePinnedHostnameWithPolicy, resolveStrictExistingUploadPaths, sanitizeUntrustedFileName, withBrowserNavigationPolicy, withPageScopedCdpClient, withPlaywrightPageCdpSession, writeViaSiblingTempPath };
|