browser-use 0.5.0 → 0.6.1
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 +22 -17
- package/dist/agent/service.js +13 -2
- package/dist/agent/system_prompt.md +269 -0
- package/dist/agent/system_prompt_anthropic_flash.md +240 -0
- package/dist/agent/system_prompt_browser_use.md +18 -0
- package/dist/agent/system_prompt_browser_use_flash.md +15 -0
- package/dist/agent/system_prompt_browser_use_no_thinking.md +17 -0
- package/dist/agent/system_prompt_flash.md +16 -0
- package/dist/agent/system_prompt_flash_anthropic.md +30 -0
- package/dist/agent/system_prompt_no_thinking.md +245 -0
- package/dist/browser/cloud/index.d.ts +1 -0
- package/dist/browser/cloud/index.js +1 -0
- package/dist/browser/cloud/management.d.ts +130 -0
- package/dist/browser/cloud/management.js +140 -0
- package/dist/browser/events.d.ts +61 -3
- package/dist/browser/events.js +66 -0
- package/dist/browser/profile.d.ts +1 -0
- package/dist/browser/profile.js +1 -0
- package/dist/browser/session.d.ts +56 -2
- package/dist/browser/session.js +596 -24
- package/dist/browser/watchdogs/base.js +34 -1
- package/dist/browser/watchdogs/captcha-watchdog.d.ts +26 -0
- package/dist/browser/watchdogs/captcha-watchdog.js +151 -0
- package/dist/browser/watchdogs/index.d.ts +1 -0
- package/dist/browser/watchdogs/index.js +1 -0
- package/dist/browser/watchdogs/screenshot-watchdog.js +4 -3
- package/dist/cli.d.ts +120 -0
- package/dist/cli.js +1817 -5
- package/dist/config.js +1 -1
- package/dist/controller/registry/views.d.ts +2 -0
- package/dist/controller/registry/views.js +44 -17
- package/dist/controller/service.js +106 -362
- package/dist/controller/views.d.ts +9 -6
- package/dist/controller/views.js +8 -5
- package/dist/filesystem/file-system.js +1 -1
- package/dist/llm/litellm/chat.d.ts +11 -0
- package/dist/llm/litellm/chat.js +16 -0
- package/dist/llm/litellm/index.d.ts +1 -0
- package/dist/llm/litellm/index.js +1 -0
- package/dist/llm/models.js +29 -3
- package/dist/llm/oci-raw/chat.d.ts +64 -0
- package/dist/llm/oci-raw/chat.js +350 -0
- package/dist/llm/oci-raw/index.d.ts +2 -0
- package/dist/llm/oci-raw/index.js +2 -0
- package/dist/llm/oci-raw/serializer.d.ts +12 -0
- package/dist/llm/oci-raw/serializer.js +128 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +62 -13
- package/dist/observability.js +1 -1
- package/dist/skill-cli/direct.d.ts +100 -0
- package/dist/skill-cli/direct.js +984 -0
- package/dist/skill-cli/index.d.ts +2 -0
- package/dist/skill-cli/index.js +2 -0
- package/dist/skill-cli/server.d.ts +2 -0
- package/dist/skill-cli/server.js +472 -11
- package/dist/skill-cli/tunnel.d.ts +61 -0
- package/dist/skill-cli/tunnel.js +257 -0
- package/dist/sync/auth.d.ts +8 -0
- package/dist/sync/auth.js +12 -0
- package/dist/utils.js +1 -1
- package/package.json +31 -12
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export interface CloudManagementClientOptions {
|
|
2
|
+
api_base_url?: string;
|
|
3
|
+
api_key?: string | null;
|
|
4
|
+
fetch_impl?: typeof fetch;
|
|
5
|
+
}
|
|
6
|
+
export interface CloudTaskView {
|
|
7
|
+
id: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
llm?: string | null;
|
|
10
|
+
task: string;
|
|
11
|
+
status: string;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
startedAt?: string | null;
|
|
14
|
+
finishedAt?: string | null;
|
|
15
|
+
metadata?: Record<string, unknown> | null;
|
|
16
|
+
output?: string | null;
|
|
17
|
+
browserUseVersion?: string | null;
|
|
18
|
+
isSuccess?: boolean | null;
|
|
19
|
+
judgement?: string | null;
|
|
20
|
+
judgeVerdict?: boolean | null;
|
|
21
|
+
steps?: Array<Record<string, unknown>>;
|
|
22
|
+
outputFiles?: Array<Record<string, unknown>>;
|
|
23
|
+
}
|
|
24
|
+
export interface CloudSessionView {
|
|
25
|
+
id: string;
|
|
26
|
+
status: string;
|
|
27
|
+
startedAt: string;
|
|
28
|
+
liveUrl?: string | null;
|
|
29
|
+
finishedAt?: string | null;
|
|
30
|
+
tasks?: CloudTaskView[];
|
|
31
|
+
publicShareUrl?: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface CloudProfileView {
|
|
34
|
+
id: string;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
updatedAt: string;
|
|
37
|
+
name?: string | null;
|
|
38
|
+
lastUsedAt?: string | null;
|
|
39
|
+
cookieDomains?: string[] | null;
|
|
40
|
+
}
|
|
41
|
+
export interface CloudShareView {
|
|
42
|
+
shareToken: string;
|
|
43
|
+
shareUrl: string;
|
|
44
|
+
viewCount: number;
|
|
45
|
+
lastViewedAt?: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface PaginatedResponse<T> {
|
|
48
|
+
items: T[];
|
|
49
|
+
totalItems: number;
|
|
50
|
+
pageNumber: number;
|
|
51
|
+
pageSize: number;
|
|
52
|
+
}
|
|
53
|
+
export interface CreateTaskRequest {
|
|
54
|
+
task: string;
|
|
55
|
+
llm?: string | null;
|
|
56
|
+
startUrl?: string | null;
|
|
57
|
+
maxSteps?: number | null;
|
|
58
|
+
structuredOutput?: string | null;
|
|
59
|
+
sessionId?: string | null;
|
|
60
|
+
metadata?: Record<string, string> | null;
|
|
61
|
+
secrets?: Record<string, string> | null;
|
|
62
|
+
allowedDomains?: string[] | null;
|
|
63
|
+
opVaultId?: string | null;
|
|
64
|
+
highlightElements?: boolean;
|
|
65
|
+
flashMode?: boolean;
|
|
66
|
+
thinking?: boolean;
|
|
67
|
+
vision?: boolean | 'auto' | null;
|
|
68
|
+
systemPromptExtension?: string | null;
|
|
69
|
+
judge?: boolean;
|
|
70
|
+
judgeGroundTruth?: string | null;
|
|
71
|
+
judgeLlm?: string | null;
|
|
72
|
+
skillIds?: string[] | null;
|
|
73
|
+
}
|
|
74
|
+
export interface CreateSessionRequest {
|
|
75
|
+
profileId?: string | null;
|
|
76
|
+
proxyCountryCode?: string | null;
|
|
77
|
+
startUrl?: string | null;
|
|
78
|
+
browserScreenWidth?: number | null;
|
|
79
|
+
browserScreenHeight?: number | null;
|
|
80
|
+
}
|
|
81
|
+
export declare class CloudManagementClient {
|
|
82
|
+
private readonly api_base_url;
|
|
83
|
+
private readonly explicit_api_key;
|
|
84
|
+
private readonly fetch_impl;
|
|
85
|
+
constructor(options?: CloudManagementClientOptions);
|
|
86
|
+
private resolve_api_key;
|
|
87
|
+
private auth_headers;
|
|
88
|
+
private request_json;
|
|
89
|
+
private build_query;
|
|
90
|
+
list_tasks(options?: {
|
|
91
|
+
pageSize?: number;
|
|
92
|
+
pageNumber?: number;
|
|
93
|
+
sessionId?: string | null;
|
|
94
|
+
filterBy?: string | null;
|
|
95
|
+
after?: string | null;
|
|
96
|
+
before?: string | null;
|
|
97
|
+
}): Promise<PaginatedResponse<CloudTaskView>>;
|
|
98
|
+
create_task(request: CreateTaskRequest): Promise<{
|
|
99
|
+
id: string;
|
|
100
|
+
sessionId: string;
|
|
101
|
+
}>;
|
|
102
|
+
get_task(task_id: string): Promise<CloudTaskView>;
|
|
103
|
+
update_task(task_id: string, action: 'stop' | 'stop_task_and_session'): Promise<CloudTaskView>;
|
|
104
|
+
get_task_logs(task_id: string): Promise<{
|
|
105
|
+
downloadUrl: string;
|
|
106
|
+
}>;
|
|
107
|
+
list_sessions(options?: {
|
|
108
|
+
pageSize?: number;
|
|
109
|
+
pageNumber?: number;
|
|
110
|
+
filterBy?: string | null;
|
|
111
|
+
}): Promise<PaginatedResponse<CloudSessionView>>;
|
|
112
|
+
create_session(request: CreateSessionRequest): Promise<CloudSessionView>;
|
|
113
|
+
get_session(session_id: string): Promise<CloudSessionView>;
|
|
114
|
+
update_session(session_id: string, action: 'stop'): Promise<CloudSessionView>;
|
|
115
|
+
delete_session(session_id: string): Promise<void>;
|
|
116
|
+
create_session_public_share(session_id: string): Promise<CloudShareView>;
|
|
117
|
+
delete_session_public_share(session_id: string): Promise<void>;
|
|
118
|
+
list_profiles(options?: {
|
|
119
|
+
pageSize?: number;
|
|
120
|
+
pageNumber?: number;
|
|
121
|
+
}): Promise<PaginatedResponse<CloudProfileView>>;
|
|
122
|
+
create_profile(request?: {
|
|
123
|
+
name?: string | null;
|
|
124
|
+
}): Promise<CloudProfileView>;
|
|
125
|
+
get_profile(profile_id: string): Promise<CloudProfileView>;
|
|
126
|
+
update_profile(profile_id: string, request?: {
|
|
127
|
+
name?: string | null;
|
|
128
|
+
}): Promise<CloudProfileView>;
|
|
129
|
+
delete_profile(profile_id: string): Promise<void>;
|
|
130
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { CONFIG } from '../../config.js';
|
|
2
|
+
import { DeviceAuthClient } from '../../sync/auth.js';
|
|
3
|
+
import { CloudBrowserAuthError, CloudBrowserError } from './views.js';
|
|
4
|
+
const stripTrailingSlash = (input) => input.replace(/\/+$/, '');
|
|
5
|
+
export class CloudManagementClient {
|
|
6
|
+
api_base_url;
|
|
7
|
+
explicit_api_key;
|
|
8
|
+
fetch_impl;
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
this.api_base_url = stripTrailingSlash(options.api_base_url ?? CONFIG.BROWSER_USE_CLOUD_API_URL);
|
|
11
|
+
this.explicit_api_key = options.api_key ?? null;
|
|
12
|
+
this.fetch_impl = options.fetch_impl ?? fetch;
|
|
13
|
+
}
|
|
14
|
+
resolve_api_key() {
|
|
15
|
+
if (this.explicit_api_key?.trim()) {
|
|
16
|
+
return this.explicit_api_key.trim();
|
|
17
|
+
}
|
|
18
|
+
if (process.env.BROWSER_USE_API_KEY?.trim()) {
|
|
19
|
+
return process.env.BROWSER_USE_API_KEY.trim();
|
|
20
|
+
}
|
|
21
|
+
const savedToken = new DeviceAuthClient(this.api_base_url).api_token?.trim();
|
|
22
|
+
return savedToken || null;
|
|
23
|
+
}
|
|
24
|
+
auth_headers(extra_headers = {}) {
|
|
25
|
+
const api_key = this.resolve_api_key();
|
|
26
|
+
if (!api_key) {
|
|
27
|
+
throw new CloudBrowserAuthError('No authentication token found. Set BROWSER_USE_API_KEY to use cloud APIs.');
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
'X-Browser-Use-API-Key': api_key,
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
...extra_headers,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async request_json(path, init) {
|
|
36
|
+
const response = await this.fetch_impl(`${this.api_base_url}${path}`, {
|
|
37
|
+
...init,
|
|
38
|
+
headers: this.auth_headers(init.headers),
|
|
39
|
+
});
|
|
40
|
+
const text = await response.text();
|
|
41
|
+
let payload = null;
|
|
42
|
+
if (text) {
|
|
43
|
+
try {
|
|
44
|
+
payload = JSON.parse(text);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
payload = text;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
const details = payload && typeof payload === 'object'
|
|
52
|
+
? JSON.stringify(payload)
|
|
53
|
+
: String(payload ?? '');
|
|
54
|
+
if (response.status === 401 || response.status === 403) {
|
|
55
|
+
throw new CloudBrowserAuthError(`Cloud API authentication failed (${response.status})`);
|
|
56
|
+
}
|
|
57
|
+
throw new CloudBrowserError(`Cloud API request failed (${response.status}): ${details}`);
|
|
58
|
+
}
|
|
59
|
+
return payload;
|
|
60
|
+
}
|
|
61
|
+
build_query(params) {
|
|
62
|
+
const query = new URLSearchParams();
|
|
63
|
+
for (const [key, value] of Object.entries(params)) {
|
|
64
|
+
if (value !== undefined && value !== null && String(value).length > 0) {
|
|
65
|
+
query.set(key, String(value));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const rendered = query.toString();
|
|
69
|
+
return rendered ? `?${rendered}` : '';
|
|
70
|
+
}
|
|
71
|
+
async list_tasks(options = {}) {
|
|
72
|
+
return await this.request_json(`/api/v2/tasks${this.build_query(options)}`, { method: 'GET' });
|
|
73
|
+
}
|
|
74
|
+
async create_task(request) {
|
|
75
|
+
return await this.request_json('/api/v2/tasks', {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
body: JSON.stringify(request),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async get_task(task_id) {
|
|
81
|
+
return await this.request_json(`/api/v2/tasks/${encodeURIComponent(task_id)}`, { method: 'GET' });
|
|
82
|
+
}
|
|
83
|
+
async update_task(task_id, action) {
|
|
84
|
+
return await this.request_json(`/api/v2/tasks/${encodeURIComponent(task_id)}`, {
|
|
85
|
+
method: 'PATCH',
|
|
86
|
+
body: JSON.stringify({ action }),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async get_task_logs(task_id) {
|
|
90
|
+
return await this.request_json(`/api/v2/tasks/${encodeURIComponent(task_id)}/logs`, { method: 'GET' });
|
|
91
|
+
}
|
|
92
|
+
async list_sessions(options = {}) {
|
|
93
|
+
return await this.request_json(`/api/v2/sessions${this.build_query(options)}`, { method: 'GET' });
|
|
94
|
+
}
|
|
95
|
+
async create_session(request) {
|
|
96
|
+
return await this.request_json('/api/v2/sessions', {
|
|
97
|
+
method: 'POST',
|
|
98
|
+
body: JSON.stringify(request),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async get_session(session_id) {
|
|
102
|
+
return await this.request_json(`/api/v2/sessions/${encodeURIComponent(session_id)}`, { method: 'GET' });
|
|
103
|
+
}
|
|
104
|
+
async update_session(session_id, action) {
|
|
105
|
+
return await this.request_json(`/api/v2/sessions/${encodeURIComponent(session_id)}`, {
|
|
106
|
+
method: 'PATCH',
|
|
107
|
+
body: JSON.stringify({ action }),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async delete_session(session_id) {
|
|
111
|
+
await this.request_json(`/api/v2/sessions/${encodeURIComponent(session_id)}`, { method: 'DELETE' });
|
|
112
|
+
}
|
|
113
|
+
async create_session_public_share(session_id) {
|
|
114
|
+
return await this.request_json(`/api/v2/sessions/${encodeURIComponent(session_id)}/public-share`, { method: 'POST' });
|
|
115
|
+
}
|
|
116
|
+
async delete_session_public_share(session_id) {
|
|
117
|
+
await this.request_json(`/api/v2/sessions/${encodeURIComponent(session_id)}/public-share`, { method: 'DELETE' });
|
|
118
|
+
}
|
|
119
|
+
async list_profiles(options = {}) {
|
|
120
|
+
return await this.request_json(`/api/v2/profiles${this.build_query(options)}`, { method: 'GET' });
|
|
121
|
+
}
|
|
122
|
+
async create_profile(request = {}) {
|
|
123
|
+
return await this.request_json('/api/v2/profiles', {
|
|
124
|
+
method: 'POST',
|
|
125
|
+
body: JSON.stringify(request),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async get_profile(profile_id) {
|
|
129
|
+
return await this.request_json(`/api/v2/profiles/${encodeURIComponent(profile_id)}`, { method: 'GET' });
|
|
130
|
+
}
|
|
131
|
+
async update_profile(profile_id, request = {}) {
|
|
132
|
+
return await this.request_json(`/api/v2/profiles/${encodeURIComponent(profile_id)}`, {
|
|
133
|
+
method: 'PATCH',
|
|
134
|
+
body: JSON.stringify(request),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async delete_profile(profile_id) {
|
|
138
|
+
await this.request_json(`/api/v2/profiles/${encodeURIComponent(profile_id)}`, { method: 'DELETE' });
|
|
139
|
+
}
|
|
140
|
+
}
|
package/dist/browser/events.d.ts
CHANGED
|
@@ -80,10 +80,20 @@ export declare class CloseTabEvent extends BrowserEvent<void> {
|
|
|
80
80
|
}
|
|
81
81
|
export declare class ScreenshotEvent extends BrowserEvent<string> {
|
|
82
82
|
full_page: boolean;
|
|
83
|
-
clip:
|
|
83
|
+
clip: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
width: number;
|
|
87
|
+
height: number;
|
|
88
|
+
} | null;
|
|
84
89
|
constructor(init?: EventBusEventInit<string> & {
|
|
85
90
|
full_page?: boolean;
|
|
86
|
-
clip?:
|
|
91
|
+
clip?: {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
width: number;
|
|
95
|
+
height: number;
|
|
96
|
+
} | null;
|
|
87
97
|
});
|
|
88
98
|
}
|
|
89
99
|
export declare class BrowserStateRequestEvent extends BrowserEvent<BrowserStateSummary> {
|
|
@@ -175,12 +185,60 @@ export declare class BrowserConnectedEvent extends BrowserEvent<void> {
|
|
|
175
185
|
cdp_url: string;
|
|
176
186
|
});
|
|
177
187
|
}
|
|
188
|
+
export declare class BrowserReconnectingEvent extends BrowserEvent<void> {
|
|
189
|
+
cdp_url: string;
|
|
190
|
+
attempt: number;
|
|
191
|
+
max_attempts: number;
|
|
192
|
+
constructor(init: EventBusEventInit<void> & {
|
|
193
|
+
cdp_url: string;
|
|
194
|
+
attempt: number;
|
|
195
|
+
max_attempts: number;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
export declare class BrowserReconnectedEvent extends BrowserEvent<void> {
|
|
199
|
+
cdp_url: string;
|
|
200
|
+
attempt: number;
|
|
201
|
+
downtime_seconds: number;
|
|
202
|
+
constructor(init: EventBusEventInit<void> & {
|
|
203
|
+
cdp_url: string;
|
|
204
|
+
attempt: number;
|
|
205
|
+
downtime_seconds: number;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
178
208
|
export declare class BrowserStoppedEvent extends BrowserEvent<void> {
|
|
179
209
|
reason: string | null;
|
|
180
210
|
constructor(init?: EventBusEventInit<void> & {
|
|
181
211
|
reason?: string | null;
|
|
182
212
|
});
|
|
183
213
|
}
|
|
214
|
+
export declare class CaptchaSolverStartedEvent extends BrowserEvent<void> {
|
|
215
|
+
target_id: TargetID;
|
|
216
|
+
vendor: string;
|
|
217
|
+
url: string;
|
|
218
|
+
started_at: number;
|
|
219
|
+
constructor(init: EventBusEventInit<void> & {
|
|
220
|
+
target_id: TargetID;
|
|
221
|
+
vendor: string;
|
|
222
|
+
url: string;
|
|
223
|
+
started_at: number;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
export declare class CaptchaSolverFinishedEvent extends BrowserEvent<void> {
|
|
227
|
+
target_id: TargetID;
|
|
228
|
+
vendor: string;
|
|
229
|
+
url: string;
|
|
230
|
+
duration_ms: number;
|
|
231
|
+
finished_at: number;
|
|
232
|
+
success: boolean;
|
|
233
|
+
constructor(init: EventBusEventInit<void> & {
|
|
234
|
+
target_id: TargetID;
|
|
235
|
+
vendor: string;
|
|
236
|
+
url: string;
|
|
237
|
+
duration_ms: number;
|
|
238
|
+
finished_at: number;
|
|
239
|
+
success: boolean;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
184
242
|
export declare class TabCreatedEvent extends BrowserEvent<void> {
|
|
185
243
|
target_id: TargetID;
|
|
186
244
|
url: string;
|
|
@@ -341,5 +399,5 @@ export declare class DialogOpenedEvent extends BrowserEvent<void> {
|
|
|
341
399
|
frame_id?: string | null;
|
|
342
400
|
});
|
|
343
401
|
}
|
|
344
|
-
export declare const BROWSER_EVENT_CLASSES: readonly [typeof ElementSelectedEvent, typeof NavigateToUrlEvent, typeof ClickElementEvent, typeof ClickCoordinateEvent, typeof TypeTextEvent, typeof ScrollEvent, typeof SwitchTabEvent, typeof CloseTabEvent, typeof ScreenshotEvent, typeof BrowserStateRequestEvent, typeof GoBackEvent, typeof GoForwardEvent, typeof RefreshEvent, typeof WaitEvent, typeof SendKeysEvent, typeof UploadFileEvent, typeof GetDropdownOptionsEvent, typeof SelectDropdownOptionEvent, typeof ScrollToTextEvent, typeof BrowserStartEvent, typeof BrowserStopEvent, typeof BrowserLaunchEvent, typeof BrowserKillEvent, typeof BrowserConnectedEvent, typeof BrowserStoppedEvent, typeof TabCreatedEvent, typeof TabClosedEvent, typeof AgentFocusChangedEvent, typeof TargetCrashedEvent, typeof NavigationStartedEvent, typeof NavigationCompleteEvent, typeof BrowserErrorEvent, typeof SaveStorageStateEvent, typeof StorageStateSavedEvent, typeof LoadStorageStateEvent, typeof StorageStateLoadedEvent, typeof DownloadStartedEvent, typeof DownloadProgressEvent, typeof FileDownloadedEvent, typeof AboutBlankDVDScreensaverShownEvent, typeof DialogOpenedEvent];
|
|
402
|
+
export declare const BROWSER_EVENT_CLASSES: readonly [typeof ElementSelectedEvent, typeof NavigateToUrlEvent, typeof ClickElementEvent, typeof ClickCoordinateEvent, typeof TypeTextEvent, typeof ScrollEvent, typeof SwitchTabEvent, typeof CloseTabEvent, typeof ScreenshotEvent, typeof BrowserStateRequestEvent, typeof GoBackEvent, typeof GoForwardEvent, typeof RefreshEvent, typeof WaitEvent, typeof SendKeysEvent, typeof UploadFileEvent, typeof GetDropdownOptionsEvent, typeof SelectDropdownOptionEvent, typeof ScrollToTextEvent, typeof BrowserStartEvent, typeof BrowserStopEvent, typeof BrowserLaunchEvent, typeof BrowserKillEvent, typeof BrowserConnectedEvent, typeof BrowserReconnectingEvent, typeof BrowserReconnectedEvent, typeof BrowserStoppedEvent, typeof TabCreatedEvent, typeof TabClosedEvent, typeof AgentFocusChangedEvent, typeof TargetCrashedEvent, typeof NavigationStartedEvent, typeof NavigationCompleteEvent, typeof BrowserErrorEvent, typeof SaveStorageStateEvent, typeof StorageStateSavedEvent, typeof LoadStorageStateEvent, typeof StorageStateLoadedEvent, typeof DownloadStartedEvent, typeof DownloadProgressEvent, typeof FileDownloadedEvent, typeof AboutBlankDVDScreensaverShownEvent, typeof DialogOpenedEvent];
|
|
345
403
|
export declare const BROWSER_EVENT_NAMES: string[];
|
package/dist/browser/events.js
CHANGED
|
@@ -276,6 +276,34 @@ export class BrowserConnectedEvent extends BrowserEvent {
|
|
|
276
276
|
this.cdp_url = init.cdp_url;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
+
export class BrowserReconnectingEvent extends BrowserEvent {
|
|
280
|
+
cdp_url;
|
|
281
|
+
attempt;
|
|
282
|
+
max_attempts;
|
|
283
|
+
constructor(init) {
|
|
284
|
+
super('BrowserReconnectingEvent', {
|
|
285
|
+
...init,
|
|
286
|
+
event_timeout: resolveEventTimeout('BrowserReconnectingEvent', 30, init.event_timeout),
|
|
287
|
+
});
|
|
288
|
+
this.cdp_url = init.cdp_url;
|
|
289
|
+
this.attempt = init.attempt;
|
|
290
|
+
this.max_attempts = init.max_attempts;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
export class BrowserReconnectedEvent extends BrowserEvent {
|
|
294
|
+
cdp_url;
|
|
295
|
+
attempt;
|
|
296
|
+
downtime_seconds;
|
|
297
|
+
constructor(init) {
|
|
298
|
+
super('BrowserReconnectedEvent', {
|
|
299
|
+
...init,
|
|
300
|
+
event_timeout: resolveEventTimeout('BrowserReconnectedEvent', 30, init.event_timeout),
|
|
301
|
+
});
|
|
302
|
+
this.cdp_url = init.cdp_url;
|
|
303
|
+
this.attempt = init.attempt;
|
|
304
|
+
this.downtime_seconds = init.downtime_seconds;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
279
307
|
export class BrowserStoppedEvent extends BrowserEvent {
|
|
280
308
|
reason;
|
|
281
309
|
constructor(init = {}) {
|
|
@@ -286,6 +314,42 @@ export class BrowserStoppedEvent extends BrowserEvent {
|
|
|
286
314
|
this.reason = init.reason ?? null;
|
|
287
315
|
}
|
|
288
316
|
}
|
|
317
|
+
export class CaptchaSolverStartedEvent extends BrowserEvent {
|
|
318
|
+
target_id;
|
|
319
|
+
vendor;
|
|
320
|
+
url;
|
|
321
|
+
started_at;
|
|
322
|
+
constructor(init) {
|
|
323
|
+
super('CaptchaSolverStartedEvent', {
|
|
324
|
+
...init,
|
|
325
|
+
event_timeout: resolveEventTimeout('CaptchaSolverStartedEvent', 5, init.event_timeout),
|
|
326
|
+
});
|
|
327
|
+
this.target_id = init.target_id;
|
|
328
|
+
this.vendor = init.vendor;
|
|
329
|
+
this.url = init.url;
|
|
330
|
+
this.started_at = init.started_at;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
export class CaptchaSolverFinishedEvent extends BrowserEvent {
|
|
334
|
+
target_id;
|
|
335
|
+
vendor;
|
|
336
|
+
url;
|
|
337
|
+
duration_ms;
|
|
338
|
+
finished_at;
|
|
339
|
+
success;
|
|
340
|
+
constructor(init) {
|
|
341
|
+
super('CaptchaSolverFinishedEvent', {
|
|
342
|
+
...init,
|
|
343
|
+
event_timeout: resolveEventTimeout('CaptchaSolverFinishedEvent', 5, init.event_timeout),
|
|
344
|
+
});
|
|
345
|
+
this.target_id = init.target_id;
|
|
346
|
+
this.vendor = init.vendor;
|
|
347
|
+
this.url = init.url;
|
|
348
|
+
this.duration_ms = init.duration_ms;
|
|
349
|
+
this.finished_at = init.finished_at;
|
|
350
|
+
this.success = init.success;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
289
353
|
export class TabCreatedEvent extends BrowserEvent {
|
|
290
354
|
target_id;
|
|
291
355
|
url;
|
|
@@ -529,6 +593,8 @@ export const BROWSER_EVENT_CLASSES = [
|
|
|
529
593
|
BrowserLaunchEvent,
|
|
530
594
|
BrowserKillEvent,
|
|
531
595
|
BrowserConnectedEvent,
|
|
596
|
+
BrowserReconnectingEvent,
|
|
597
|
+
BrowserReconnectedEvent,
|
|
532
598
|
BrowserStoppedEvent,
|
|
533
599
|
TabCreatedEvent,
|
|
534
600
|
TabClosedEvent,
|
|
@@ -137,6 +137,7 @@ export interface BrowserProfileSpecificOptions {
|
|
|
137
137
|
block_ip_addresses: boolean;
|
|
138
138
|
keep_alive: Nullable<boolean>;
|
|
139
139
|
enable_default_extensions: boolean;
|
|
140
|
+
captcha_solver: boolean;
|
|
140
141
|
window_size: Nullable<ViewportSize>;
|
|
141
142
|
window_height: Nullable<number>;
|
|
142
143
|
window_width: Nullable<number>;
|
package/dist/browser/profile.js
CHANGED
|
@@ -344,6 +344,7 @@ const DEFAULT_BROWSER_PROFILE_OPTIONS = {
|
|
|
344
344
|
block_ip_addresses: false,
|
|
345
345
|
keep_alive: null,
|
|
346
346
|
enable_default_extensions: getEnableDefaultExtensionsDefault(),
|
|
347
|
+
captcha_solver: true,
|
|
347
348
|
window_size: null,
|
|
348
349
|
window_height: null,
|
|
349
350
|
window_width: null,
|
|
@@ -5,6 +5,7 @@ import { BrowserStateSummary, type TabInfo } from './views.js';
|
|
|
5
5
|
import { type WaitUntilState } from './events.js';
|
|
6
6
|
import { DOMElementNode, type SelectorMap } from '../dom/views.js';
|
|
7
7
|
import { SessionManager } from './session-manager.js';
|
|
8
|
+
import { type CaptchaWaitResult } from './watchdogs/captcha-watchdog.js';
|
|
8
9
|
import type { BaseWatchdog } from './watchdogs/base.js';
|
|
9
10
|
export interface BrowserSessionInit {
|
|
10
11
|
id?: string;
|
|
@@ -22,6 +23,21 @@ export interface BrowserSessionInit {
|
|
|
22
23
|
downloaded_files?: string[];
|
|
23
24
|
closed_popup_messages?: string[];
|
|
24
25
|
}
|
|
26
|
+
export interface ChromeProfileInfo {
|
|
27
|
+
directory: string;
|
|
28
|
+
name: string;
|
|
29
|
+
email?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const systemChrome: {
|
|
32
|
+
findExecutable(): string | null;
|
|
33
|
+
getUserDataDir(executablePath?: string | null): string | null;
|
|
34
|
+
listProfiles(userDataDir?: string | null): ChromeProfileInfo[];
|
|
35
|
+
};
|
|
36
|
+
export interface BrowserSessionFromSystemChromeInit extends Omit<BrowserSessionInit, 'browser_profile' | 'profile'> {
|
|
37
|
+
browser_profile?: BrowserProfile;
|
|
38
|
+
profile?: Partial<BrowserProfileOptions>;
|
|
39
|
+
profile_directory?: string | null;
|
|
40
|
+
}
|
|
25
41
|
export interface BrowserStateOptions {
|
|
26
42
|
cache_clickable_elements_hashes?: boolean;
|
|
27
43
|
include_screenshot?: boolean;
|
|
@@ -78,7 +94,18 @@ export declare class BrowserSession {
|
|
|
78
94
|
private readonly _maxRecentEvents;
|
|
79
95
|
private _watchdogs;
|
|
80
96
|
private _defaultWatchdogsAttached;
|
|
97
|
+
private _captchaWatchdog;
|
|
98
|
+
readonly RECONNECT_WAIT_TIMEOUT = 54;
|
|
99
|
+
private _reconnecting;
|
|
100
|
+
private _reconnectTask;
|
|
101
|
+
private _reconnectWaitPromise;
|
|
102
|
+
private _resolveReconnectWait;
|
|
103
|
+
private _intentionalStop;
|
|
104
|
+
private _disconnectAwareBrowser;
|
|
105
|
+
private _browserDisconnectHandler;
|
|
81
106
|
constructor(init?: BrowserSessionInit);
|
|
107
|
+
static from_system_chrome(init?: BrowserSessionFromSystemChromeInit): BrowserSession;
|
|
108
|
+
static list_chrome_profiles(): ChromeProfileInfo[];
|
|
82
109
|
attach_watchdog(watchdog: BaseWatchdog): void;
|
|
83
110
|
attach_watchdogs(watchdogs: BaseWatchdog[]): void;
|
|
84
111
|
detach_watchdog(watchdog: BaseWatchdog): void;
|
|
@@ -89,6 +116,7 @@ export declare class BrowserSession {
|
|
|
89
116
|
cdp_url: string;
|
|
90
117
|
}>;
|
|
91
118
|
attach_default_watchdogs(): void;
|
|
119
|
+
wait_if_captcha_solving(timeoutSeconds?: number): Promise<CaptchaWaitResult | null>;
|
|
92
120
|
private _formatTabId;
|
|
93
121
|
private _createTabInfo;
|
|
94
122
|
private _buildSyntheticTargetId;
|
|
@@ -110,6 +138,10 @@ export declare class BrowserSession {
|
|
|
110
138
|
describe(): string;
|
|
111
139
|
get _owns_browser_resources(): boolean;
|
|
112
140
|
get is_stopping(): boolean;
|
|
141
|
+
get is_reconnecting(): boolean;
|
|
142
|
+
get should_gate_watchdog_events(): boolean;
|
|
143
|
+
get is_cdp_connected(): boolean;
|
|
144
|
+
wait_for_reconnect(timeoutSeconds?: number): Promise<void>;
|
|
113
145
|
claim_agent(agentId: string, mode?: 'exclusive' | 'shared'): boolean;
|
|
114
146
|
claimAgent(agentId: string, mode?: 'exclusive' | 'shared'): boolean;
|
|
115
147
|
release_agent(agentId?: string): boolean;
|
|
@@ -125,6 +157,22 @@ export declare class BrowserSession {
|
|
|
125
157
|
private _waitWithAbort;
|
|
126
158
|
private _withAbort;
|
|
127
159
|
private _toPlaywrightOptions;
|
|
160
|
+
set_extra_headers(headers: Record<string, string>): Promise<void>;
|
|
161
|
+
private _applyConfiguredExtraHttpHeaders;
|
|
162
|
+
private _usesRemoteBrowserConnection;
|
|
163
|
+
private _connectToConfiguredBrowser;
|
|
164
|
+
private _ensureBrowserContextFromBrowser;
|
|
165
|
+
private _beginReconnectWait;
|
|
166
|
+
private _endReconnectWait;
|
|
167
|
+
private _detachRemoteDisconnectHandler;
|
|
168
|
+
private _attachRemoteDisconnectHandler;
|
|
169
|
+
private _handleUnexpectedRemoteDisconnect;
|
|
170
|
+
private _restorePagesAfterReconnect;
|
|
171
|
+
reconnect(options?: {
|
|
172
|
+
preferred_url?: string | null;
|
|
173
|
+
preferred_tab_index?: number;
|
|
174
|
+
}): Promise<void>;
|
|
175
|
+
private _auto_reconnect;
|
|
128
176
|
private _isSandboxLaunchError;
|
|
129
177
|
private _createNoSandboxLaunchOptions;
|
|
130
178
|
private _launchChromiumWithSandboxFallback;
|
|
@@ -255,11 +303,17 @@ export declare class BrowserSession {
|
|
|
255
303
|
*/
|
|
256
304
|
wait_for_element(selector: string, timeout?: number): Promise<void>;
|
|
257
305
|
/**
|
|
258
|
-
* Take a screenshot of the current page
|
|
306
|
+
* Take a screenshot of the current page.
|
|
259
307
|
* @param full_page Whether to capture the full scrollable page
|
|
308
|
+
* @param clip Optional clip region for partial screenshots
|
|
260
309
|
* @returns Base64 encoded PNG screenshot
|
|
261
310
|
*/
|
|
262
|
-
take_screenshot(full_page?: boolean
|
|
311
|
+
take_screenshot(full_page?: boolean, clip?: {
|
|
312
|
+
x: number;
|
|
313
|
+
y: number;
|
|
314
|
+
width: number;
|
|
315
|
+
height: number;
|
|
316
|
+
} | null): Promise<string | null>;
|
|
263
317
|
/**
|
|
264
318
|
* Add a request event listener to the current page
|
|
265
319
|
*/
|