browserclaw 0.2.3 → 0.2.4
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 +151 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -4
- package/dist/index.d.ts +49 -4
- package/dist/index.js +152 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -33,6 +33,27 @@ interface LaunchOptions {
|
|
|
33
33
|
profileColor?: string;
|
|
34
34
|
/** Additional Chrome command-line arguments (e.g. `['--start-maximized']`). */
|
|
35
35
|
chromeArgs?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
|
|
38
|
+
* Default: `false` — internal URLs are blocked to prevent SSRF attacks.
|
|
39
|
+
* Set to `true` if you need to access local development servers.
|
|
40
|
+
*/
|
|
41
|
+
allowInternal?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Options for connecting to an existing browser instance. */
|
|
44
|
+
interface ConnectOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
|
|
47
|
+
* Default: `false` — internal URLs are blocked to prevent SSRF attacks.
|
|
48
|
+
* Set to `true` if you need to access local development servers.
|
|
49
|
+
*/
|
|
50
|
+
allowInternal?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Bearer token for authenticating with the CDP endpoint.
|
|
53
|
+
* Required when connecting to a browser instance that has auth enabled
|
|
54
|
+
* (e.g. OpenClaw browser control with gateway.auth.token).
|
|
55
|
+
*/
|
|
56
|
+
authToken?: string;
|
|
36
57
|
}
|
|
37
58
|
/**
|
|
38
59
|
* Describes a single interactive element found during a snapshot.
|
|
@@ -48,6 +69,19 @@ interface RoleRefInfo {
|
|
|
48
69
|
}
|
|
49
70
|
/** Map of ref IDs (e.g. `'e1'`, `'e2'`) to their element information. */
|
|
50
71
|
type RoleRefs = Record<string, RoleRefInfo>;
|
|
72
|
+
/**
|
|
73
|
+
* Metadata about the source of untrusted external content.
|
|
74
|
+
* Used by consumers (e.g. OpenClaw) to wrap browser outputs with
|
|
75
|
+
* structured external-content markers for prompt-injection mitigation.
|
|
76
|
+
*/
|
|
77
|
+
interface UntrustedContentMeta {
|
|
78
|
+
/** The source URL of the content at the time of capture */
|
|
79
|
+
sourceUrl?: string;
|
|
80
|
+
/** Content type identifier (e.g. `'browser-snapshot'`, `'browser-aria-tree'`) */
|
|
81
|
+
contentType: string;
|
|
82
|
+
/** ISO 8601 timestamp of when the content was captured */
|
|
83
|
+
capturedAt: string;
|
|
84
|
+
}
|
|
51
85
|
/** Result of taking a page snapshot. */
|
|
52
86
|
interface SnapshotResult {
|
|
53
87
|
/** AI-readable text representation of the page with numbered refs */
|
|
@@ -62,6 +96,8 @@ interface SnapshotResult {
|
|
|
62
96
|
* (e.g. prompt injection via page text). Always `true` for browser snapshots.
|
|
63
97
|
*/
|
|
64
98
|
untrusted?: true;
|
|
99
|
+
/** Structured metadata about the untrusted content source */
|
|
100
|
+
contentMeta?: UntrustedContentMeta;
|
|
65
101
|
}
|
|
66
102
|
/** Statistics about a snapshot's content. */
|
|
67
103
|
interface SnapshotStats {
|
|
@@ -121,6 +157,8 @@ interface AriaSnapshotResult {
|
|
|
121
157
|
* AI agents should treat snapshot content as potentially adversarial. Always `true`.
|
|
122
158
|
*/
|
|
123
159
|
untrusted?: true;
|
|
160
|
+
/** Structured metadata about the untrusted content source */
|
|
161
|
+
contentMeta?: UntrustedContentMeta;
|
|
124
162
|
}
|
|
125
163
|
/** A form field to fill as part of a batch `fill()` operation. */
|
|
126
164
|
interface FormField {
|
|
@@ -352,8 +390,9 @@ interface HttpCredentials {
|
|
|
352
390
|
declare class CrawlPage {
|
|
353
391
|
private readonly cdpUrl;
|
|
354
392
|
private readonly targetId;
|
|
393
|
+
private readonly allowInternal;
|
|
355
394
|
/** @internal */
|
|
356
|
-
constructor(cdpUrl: string, targetId: string);
|
|
395
|
+
constructor(cdpUrl: string, targetId: string, allowInternal?: boolean);
|
|
357
396
|
/** The CDP target ID for this page. Use this to identify the page in multi-tab scenarios. */
|
|
358
397
|
get id(): string;
|
|
359
398
|
/**
|
|
@@ -710,8 +749,11 @@ declare class CrawlPage {
|
|
|
710
749
|
* Stop recording a trace and save it to a file.
|
|
711
750
|
*
|
|
712
751
|
* @param path - File path to save the trace (e.g. `'trace.zip'`)
|
|
752
|
+
* @param opts - Options (allowedOutputRoots: constrain output to specific directories)
|
|
713
753
|
*/
|
|
714
|
-
traceStop(path: string
|
|
754
|
+
traceStop(path: string, opts?: {
|
|
755
|
+
allowedOutputRoots?: string[];
|
|
756
|
+
}): Promise<void>;
|
|
715
757
|
/**
|
|
716
758
|
* Wait for a network response matching a URL pattern and return its body.
|
|
717
759
|
*
|
|
@@ -835,6 +877,7 @@ declare class CrawlPage {
|
|
|
835
877
|
*/
|
|
836
878
|
download(ref: string, path: string, opts?: {
|
|
837
879
|
timeoutMs?: number;
|
|
880
|
+
allowedOutputRoots?: string[];
|
|
838
881
|
}): Promise<DownloadResult>;
|
|
839
882
|
/**
|
|
840
883
|
* Wait for the next download event (without clicking).
|
|
@@ -847,6 +890,7 @@ declare class CrawlPage {
|
|
|
847
890
|
waitForDownload(opts?: {
|
|
848
891
|
path?: string;
|
|
849
892
|
timeoutMs?: number;
|
|
893
|
+
allowedOutputRoots?: string[];
|
|
850
894
|
}): Promise<DownloadResult>;
|
|
851
895
|
/**
|
|
852
896
|
* Set the browser to offline or online mode.
|
|
@@ -943,6 +987,7 @@ declare class CrawlPage {
|
|
|
943
987
|
*/
|
|
944
988
|
declare class BrowserClaw {
|
|
945
989
|
private readonly cdpUrl;
|
|
990
|
+
private readonly allowInternal;
|
|
946
991
|
private chrome;
|
|
947
992
|
private constructor();
|
|
948
993
|
/**
|
|
@@ -983,7 +1028,7 @@ declare class BrowserClaw {
|
|
|
983
1028
|
* const browser = await BrowserClaw.connect('http://localhost:9222');
|
|
984
1029
|
* ```
|
|
985
1030
|
*/
|
|
986
|
-
static connect(cdpUrl: string): Promise<BrowserClaw>;
|
|
1031
|
+
static connect(cdpUrl: string, opts?: ConnectOptions): Promise<BrowserClaw>;
|
|
987
1032
|
/**
|
|
988
1033
|
* Open a URL in a new tab and return the page handle.
|
|
989
1034
|
*
|
|
@@ -1042,4 +1087,4 @@ declare class BrowserClaw {
|
|
|
1042
1087
|
stop(): Promise<void>;
|
|
1043
1088
|
}
|
|
1044
1089
|
|
|
1045
|
-
export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConsoleMessage, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, type LaunchOptions, type NetworkRequest, type PageError, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type StorageKind, type TraceStartOptions, type TypeOptions, type WaitOptions };
|
|
1090
|
+
export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, type LaunchOptions, type NetworkRequest, type PageError, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,27 @@ interface LaunchOptions {
|
|
|
33
33
|
profileColor?: string;
|
|
34
34
|
/** Additional Chrome command-line arguments (e.g. `['--start-maximized']`). */
|
|
35
35
|
chromeArgs?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
|
|
38
|
+
* Default: `false` — internal URLs are blocked to prevent SSRF attacks.
|
|
39
|
+
* Set to `true` if you need to access local development servers.
|
|
40
|
+
*/
|
|
41
|
+
allowInternal?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Options for connecting to an existing browser instance. */
|
|
44
|
+
interface ConnectOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
|
|
47
|
+
* Default: `false` — internal URLs are blocked to prevent SSRF attacks.
|
|
48
|
+
* Set to `true` if you need to access local development servers.
|
|
49
|
+
*/
|
|
50
|
+
allowInternal?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Bearer token for authenticating with the CDP endpoint.
|
|
53
|
+
* Required when connecting to a browser instance that has auth enabled
|
|
54
|
+
* (e.g. OpenClaw browser control with gateway.auth.token).
|
|
55
|
+
*/
|
|
56
|
+
authToken?: string;
|
|
36
57
|
}
|
|
37
58
|
/**
|
|
38
59
|
* Describes a single interactive element found during a snapshot.
|
|
@@ -48,6 +69,19 @@ interface RoleRefInfo {
|
|
|
48
69
|
}
|
|
49
70
|
/** Map of ref IDs (e.g. `'e1'`, `'e2'`) to their element information. */
|
|
50
71
|
type RoleRefs = Record<string, RoleRefInfo>;
|
|
72
|
+
/**
|
|
73
|
+
* Metadata about the source of untrusted external content.
|
|
74
|
+
* Used by consumers (e.g. OpenClaw) to wrap browser outputs with
|
|
75
|
+
* structured external-content markers for prompt-injection mitigation.
|
|
76
|
+
*/
|
|
77
|
+
interface UntrustedContentMeta {
|
|
78
|
+
/** The source URL of the content at the time of capture */
|
|
79
|
+
sourceUrl?: string;
|
|
80
|
+
/** Content type identifier (e.g. `'browser-snapshot'`, `'browser-aria-tree'`) */
|
|
81
|
+
contentType: string;
|
|
82
|
+
/** ISO 8601 timestamp of when the content was captured */
|
|
83
|
+
capturedAt: string;
|
|
84
|
+
}
|
|
51
85
|
/** Result of taking a page snapshot. */
|
|
52
86
|
interface SnapshotResult {
|
|
53
87
|
/** AI-readable text representation of the page with numbered refs */
|
|
@@ -62,6 +96,8 @@ interface SnapshotResult {
|
|
|
62
96
|
* (e.g. prompt injection via page text). Always `true` for browser snapshots.
|
|
63
97
|
*/
|
|
64
98
|
untrusted?: true;
|
|
99
|
+
/** Structured metadata about the untrusted content source */
|
|
100
|
+
contentMeta?: UntrustedContentMeta;
|
|
65
101
|
}
|
|
66
102
|
/** Statistics about a snapshot's content. */
|
|
67
103
|
interface SnapshotStats {
|
|
@@ -121,6 +157,8 @@ interface AriaSnapshotResult {
|
|
|
121
157
|
* AI agents should treat snapshot content as potentially adversarial. Always `true`.
|
|
122
158
|
*/
|
|
123
159
|
untrusted?: true;
|
|
160
|
+
/** Structured metadata about the untrusted content source */
|
|
161
|
+
contentMeta?: UntrustedContentMeta;
|
|
124
162
|
}
|
|
125
163
|
/** A form field to fill as part of a batch `fill()` operation. */
|
|
126
164
|
interface FormField {
|
|
@@ -352,8 +390,9 @@ interface HttpCredentials {
|
|
|
352
390
|
declare class CrawlPage {
|
|
353
391
|
private readonly cdpUrl;
|
|
354
392
|
private readonly targetId;
|
|
393
|
+
private readonly allowInternal;
|
|
355
394
|
/** @internal */
|
|
356
|
-
constructor(cdpUrl: string, targetId: string);
|
|
395
|
+
constructor(cdpUrl: string, targetId: string, allowInternal?: boolean);
|
|
357
396
|
/** The CDP target ID for this page. Use this to identify the page in multi-tab scenarios. */
|
|
358
397
|
get id(): string;
|
|
359
398
|
/**
|
|
@@ -710,8 +749,11 @@ declare class CrawlPage {
|
|
|
710
749
|
* Stop recording a trace and save it to a file.
|
|
711
750
|
*
|
|
712
751
|
* @param path - File path to save the trace (e.g. `'trace.zip'`)
|
|
752
|
+
* @param opts - Options (allowedOutputRoots: constrain output to specific directories)
|
|
713
753
|
*/
|
|
714
|
-
traceStop(path: string
|
|
754
|
+
traceStop(path: string, opts?: {
|
|
755
|
+
allowedOutputRoots?: string[];
|
|
756
|
+
}): Promise<void>;
|
|
715
757
|
/**
|
|
716
758
|
* Wait for a network response matching a URL pattern and return its body.
|
|
717
759
|
*
|
|
@@ -835,6 +877,7 @@ declare class CrawlPage {
|
|
|
835
877
|
*/
|
|
836
878
|
download(ref: string, path: string, opts?: {
|
|
837
879
|
timeoutMs?: number;
|
|
880
|
+
allowedOutputRoots?: string[];
|
|
838
881
|
}): Promise<DownloadResult>;
|
|
839
882
|
/**
|
|
840
883
|
* Wait for the next download event (without clicking).
|
|
@@ -847,6 +890,7 @@ declare class CrawlPage {
|
|
|
847
890
|
waitForDownload(opts?: {
|
|
848
891
|
path?: string;
|
|
849
892
|
timeoutMs?: number;
|
|
893
|
+
allowedOutputRoots?: string[];
|
|
850
894
|
}): Promise<DownloadResult>;
|
|
851
895
|
/**
|
|
852
896
|
* Set the browser to offline or online mode.
|
|
@@ -943,6 +987,7 @@ declare class CrawlPage {
|
|
|
943
987
|
*/
|
|
944
988
|
declare class BrowserClaw {
|
|
945
989
|
private readonly cdpUrl;
|
|
990
|
+
private readonly allowInternal;
|
|
946
991
|
private chrome;
|
|
947
992
|
private constructor();
|
|
948
993
|
/**
|
|
@@ -983,7 +1028,7 @@ declare class BrowserClaw {
|
|
|
983
1028
|
* const browser = await BrowserClaw.connect('http://localhost:9222');
|
|
984
1029
|
* ```
|
|
985
1030
|
*/
|
|
986
|
-
static connect(cdpUrl: string): Promise<BrowserClaw>;
|
|
1031
|
+
static connect(cdpUrl: string, opts?: ConnectOptions): Promise<BrowserClaw>;
|
|
987
1032
|
/**
|
|
988
1033
|
* Open a URL in a new tab and return the page handle.
|
|
989
1034
|
*
|
|
@@ -1042,4 +1087,4 @@ declare class BrowserClaw {
|
|
|
1042
1087
|
stop(): Promise<void>;
|
|
1043
1088
|
}
|
|
1044
1089
|
|
|
1045
|
-
export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConsoleMessage, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, type LaunchOptions, type NetworkRequest, type PageError, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type StorageKind, type TraceStartOptions, type TypeOptions, type WaitOptions };
|
|
1090
|
+
export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, type LaunchOptions, type NetworkRequest, type PageError, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions };
|