browser-use-sdk 0.1.0 → 0.2.0
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/CHANGELOG.md +17 -0
- package/README.md +10 -10
- package/client.d.mts +9 -6
- package/client.d.mts.map +1 -1
- package/client.d.ts +9 -6
- package/client.d.ts.map +1 -1
- package/client.js +3 -0
- package/client.js.map +1 -1
- package/client.mjs +3 -0
- package/client.mjs.map +1 -1
- package/internal/tslib.js +4 -0
- package/lib/parse.d.mts +11 -0
- package/lib/parse.d.mts.map +1 -0
- package/lib/parse.d.ts +11 -0
- package/lib/parse.d.ts.map +1 -0
- package/lib/parse.js +32 -0
- package/lib/parse.js.map +1 -0
- package/lib/parse.mjs +27 -0
- package/lib/parse.mjs.map +1 -0
- package/lib/stream.d.mts +15 -0
- package/lib/stream.d.mts.map +1 -0
- package/lib/stream.d.ts +15 -0
- package/lib/stream.d.ts.map +1 -0
- package/lib/stream.js +44 -0
- package/lib/stream.js.map +1 -0
- package/lib/stream.mjs +41 -0
- package/lib/stream.mjs.map +1 -0
- package/lib/types.d.mts +75 -0
- package/lib/types.d.mts.map +1 -0
- package/lib/types.d.ts +75 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +14 -0
- package/lib/types.js.map +1 -0
- package/lib/types.mjs +10 -0
- package/lib/types.mjs.map +1 -0
- package/package.json +14 -1
- package/resources/agent-profiles.d.mts +94 -14
- package/resources/agent-profiles.d.mts.map +1 -1
- package/resources/agent-profiles.d.ts +94 -14
- package/resources/agent-profiles.d.ts.map +1 -1
- package/resources/agent-profiles.js +91 -6
- package/resources/agent-profiles.js.map +1 -1
- package/resources/agent-profiles.mjs +91 -6
- package/resources/agent-profiles.mjs.map +1 -1
- package/resources/browser-profiles.d.mts +91 -10
- package/resources/browser-profiles.d.mts.map +1 -1
- package/resources/browser-profiles.d.ts +91 -10
- package/resources/browser-profiles.d.ts.map +1 -1
- package/resources/browser-profiles.js +92 -6
- package/resources/browser-profiles.js.map +1 -1
- package/resources/browser-profiles.mjs +92 -6
- package/resources/browser-profiles.mjs.map +1 -1
- package/resources/index.d.mts +4 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +4 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/sessions/index.d.mts +1 -1
- package/resources/sessions/index.d.mts.map +1 -1
- package/resources/sessions/index.d.ts +1 -1
- package/resources/sessions/index.d.ts.map +1 -1
- package/resources/sessions/index.js.map +1 -1
- package/resources/sessions/index.mjs.map +1 -1
- package/resources/sessions/public-share.d.mts +59 -6
- package/resources/sessions/public-share.d.mts.map +1 -1
- package/resources/sessions/public-share.d.ts +59 -6
- package/resources/sessions/public-share.d.ts.map +1 -1
- package/resources/sessions/public-share.js +62 -4
- package/resources/sessions/public-share.js.map +1 -1
- package/resources/sessions/public-share.mjs +62 -4
- package/resources/sessions/public-share.mjs.map +1 -1
- package/resources/sessions/sessions.d.mts +117 -22
- package/resources/sessions/sessions.d.mts.map +1 -1
- package/resources/sessions/sessions.d.ts +117 -22
- package/resources/sessions/sessions.d.ts.map +1 -1
- package/resources/sessions/sessions.js +80 -3
- package/resources/sessions/sessions.js.map +1 -1
- package/resources/sessions/sessions.mjs +80 -3
- package/resources/sessions/sessions.mjs.map +1 -1
- package/resources/tasks.d.mts +333 -105
- package/resources/tasks.d.mts.map +1 -1
- package/resources/tasks.d.ts +333 -105
- package/resources/tasks.d.ts.map +1 -1
- package/resources/tasks.js +210 -15
- package/resources/tasks.js.map +1 -1
- package/resources/tasks.mjs +210 -15
- package/resources/tasks.mjs.map +1 -1
- package/resources/users/index.d.mts +3 -0
- package/resources/users/index.d.mts.map +1 -0
- package/resources/users/index.d.ts +3 -0
- package/resources/users/index.d.ts.map +1 -0
- package/resources/users/index.js +9 -0
- package/resources/users/index.js.map +1 -0
- package/resources/users/index.mjs +4 -0
- package/resources/users/index.mjs.map +1 -0
- package/resources/users/me/files.d.mts +64 -0
- package/resources/users/me/files.d.mts.map +1 -0
- package/resources/users/me/files.d.ts +64 -0
- package/resources/users/me/files.d.ts.map +1 -0
- package/resources/users/me/files.js +43 -0
- package/resources/users/me/files.js.map +1 -0
- package/resources/users/me/files.mjs +39 -0
- package/resources/users/me/files.mjs.map +1 -0
- package/resources/users/me/index.d.mts +3 -0
- package/resources/users/me/index.d.mts.map +1 -0
- package/resources/users/me/index.d.ts +3 -0
- package/resources/users/me/index.d.ts.map +1 -0
- package/resources/users/me/index.js +9 -0
- package/resources/users/me/index.js.map +1 -0
- package/resources/users/me/index.mjs +4 -0
- package/resources/users/me/index.mjs.map +1 -0
- package/resources/users/me/me.d.mts +50 -0
- package/resources/users/me/me.d.mts.map +1 -0
- package/resources/users/me/me.d.ts +50 -0
- package/resources/users/me/me.d.ts.map +1 -0
- package/resources/users/me/me.js +41 -0
- package/resources/users/me/me.js.map +1 -0
- package/resources/users/me/me.mjs +36 -0
- package/resources/users/me/me.mjs.map +1 -0
- package/resources/users/me.d.mts +2 -0
- package/resources/users/me.d.mts.map +1 -0
- package/resources/users/me.d.ts +2 -0
- package/resources/users/me.d.ts.map +1 -0
- package/resources/users/me.js +6 -0
- package/resources/users/me.js.map +1 -0
- package/resources/users/me.mjs +3 -0
- package/resources/users/me.mjs.map +1 -0
- package/resources/users/users.d.mts +10 -0
- package/resources/users/users.d.mts.map +1 -0
- package/resources/users/users.d.ts +10 -0
- package/resources/users/users.d.ts.map +1 -0
- package/resources/users/users.js +17 -0
- package/resources/users/users.js.map +1 -0
- package/resources/users/users.mjs +12 -0
- package/resources/users/users.mjs.map +1 -0
- package/resources/users.d.mts +2 -0
- package/resources/users.d.mts.map +1 -0
- package/resources/users.d.ts +2 -0
- package/resources/users.d.ts.map +1 -0
- package/resources/users.js +6 -0
- package/resources/users.js.map +1 -0
- package/resources/users.mjs +3 -0
- package/resources/users.mjs.map +1 -0
- package/src/client.ts +21 -14
- package/src/lib/parse.ts +46 -0
- package/src/lib/stream.ts +70 -0
- package/src/lib/types.ts +73 -0
- package/src/resources/agent-profiles.ts +101 -19
- package/src/resources/browser-profiles.ts +95 -12
- package/src/resources/index.ts +9 -7
- package/src/resources/sessions/index.ts +1 -1
- package/src/resources/sessions/public-share.ts +64 -8
- package/src/resources/sessions/sessions.ts +130 -26
- package/src/resources/tasks.ts +488 -123
- package/src/resources/users/index.ts +4 -0
- package/src/resources/users/me/files.ts +95 -0
- package/src/resources/users/me/index.ts +4 -0
- package/src/resources/users/me/me.ts +68 -0
- package/src/resources/users/me.ts +3 -0
- package/src/resources/users/users.ts +15 -0
- package/src/resources/users.ts +3 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/resources/tasks.ts
CHANGED
|
@@ -1,39 +1,267 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import type { ZodType } from 'zod';
|
|
4
|
+
|
|
5
5
|
import { APIPromise } from '../core/api-promise';
|
|
6
|
+
import { APIResource } from '../core/resource';
|
|
6
7
|
import { RequestOptions } from '../internal/request-options';
|
|
7
8
|
import { path } from '../internal/utils/path';
|
|
9
|
+
import {
|
|
10
|
+
parseStructuredTaskOutput,
|
|
11
|
+
stringifyStructuredOutput,
|
|
12
|
+
type TaskCreateParamsWithSchema,
|
|
13
|
+
type TaskViewWithSchema,
|
|
14
|
+
} from '../lib/parse';
|
|
15
|
+
import { BrowserState, reducer } from '../lib/stream';
|
|
16
|
+
import * as TasksAPI from './tasks';
|
|
8
17
|
|
|
9
18
|
export class Tasks extends APIResource {
|
|
10
19
|
/**
|
|
11
|
-
* Create
|
|
20
|
+
* Create and start a new AI agent task.
|
|
21
|
+
*
|
|
22
|
+
* This is the main endpoint for running AI agents. You can either:
|
|
23
|
+
*
|
|
24
|
+
* 1. Start a new session with a new task
|
|
25
|
+
* 2. Add a follow-up task to an existing session
|
|
26
|
+
*
|
|
27
|
+
* When starting a new session:
|
|
28
|
+
*
|
|
29
|
+
* - A new browser session is created
|
|
30
|
+
* - Credits are deducted from your account
|
|
31
|
+
* - The agent begins executing your task immediately
|
|
32
|
+
*
|
|
33
|
+
* When adding to an existing session:
|
|
34
|
+
*
|
|
35
|
+
* - The agent continues in the same browser context
|
|
36
|
+
* - No additional browser start up costs are charged (browser session is already
|
|
37
|
+
* active)
|
|
38
|
+
* - The agent can build on previous work
|
|
39
|
+
*
|
|
40
|
+
* Key features:
|
|
41
|
+
*
|
|
42
|
+
* - Agent profiles: Define agent behavior and capabilities
|
|
43
|
+
* - Browser profiles: Control browser settings and environment (only used for new
|
|
44
|
+
* sessions)
|
|
45
|
+
* - File uploads: Include documents for the agent to work with
|
|
46
|
+
* - Structured output: Define the format you want results in
|
|
47
|
+
* - Task metadata: Add custom data for tracking and organization (useful when
|
|
48
|
+
* using webhooks)
|
|
49
|
+
*
|
|
50
|
+
* Args:
|
|
51
|
+
*
|
|
52
|
+
* - request: Complete task configuration including agent settings, browser
|
|
53
|
+
* settings, and task description
|
|
54
|
+
*
|
|
55
|
+
* Returns:
|
|
56
|
+
*
|
|
57
|
+
* - The created task with its initial details
|
|
58
|
+
*
|
|
59
|
+
* Raises:
|
|
60
|
+
*
|
|
61
|
+
* - 402: If user has insufficient credits for a new session
|
|
62
|
+
* - 404: If referenced agent/browser profiles don't exist
|
|
63
|
+
* - 400: If session is stopped or already has a running task
|
|
12
64
|
*/
|
|
13
|
-
create
|
|
65
|
+
create<T extends ZodType>(
|
|
66
|
+
body: TaskCreateParamsWithSchema<T>,
|
|
67
|
+
options?: RequestOptions,
|
|
68
|
+
): APIPromise<TaskViewWithSchema<T>>;
|
|
69
|
+
create(body: TaskCreateParams, options?: RequestOptions): APIPromise<TaskView>;
|
|
70
|
+
create(
|
|
71
|
+
body: TaskCreateParams | TaskCreateParamsWithSchema<ZodType>,
|
|
72
|
+
options?: RequestOptions,
|
|
73
|
+
): APIPromise<unknown> {
|
|
74
|
+
if (body.structuredOutputJson == null || typeof body.structuredOutputJson === 'string') {
|
|
75
|
+
return this._client.post('/tasks', { body, ...options });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (typeof body.structuredOutputJson === 'object') {
|
|
79
|
+
const schema = body.structuredOutputJson;
|
|
80
|
+
|
|
81
|
+
const _body: TaskCreateParams = {
|
|
82
|
+
...body,
|
|
83
|
+
structuredOutputJson: stringifyStructuredOutput(schema),
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return this._client
|
|
87
|
+
.post('/tasks', { body: _body, ...options })
|
|
88
|
+
._thenUnwrap((rsp) => parseStructuredTaskOutput(rsp as TaskView, schema));
|
|
89
|
+
}
|
|
90
|
+
|
|
14
91
|
return this._client.post('/tasks', { body, ...options });
|
|
15
92
|
}
|
|
16
93
|
|
|
94
|
+
private async *watch(
|
|
95
|
+
data: TaskCreateParams,
|
|
96
|
+
config: { interval: number },
|
|
97
|
+
options?: RequestOptions,
|
|
98
|
+
): AsyncGenerator<{ event: 'status'; data: TaskView }> {
|
|
99
|
+
const tick: { current: number } = { current: 0 };
|
|
100
|
+
const state: { current: BrowserState } = { current: null };
|
|
101
|
+
|
|
102
|
+
poll: do {
|
|
103
|
+
if (options?.signal?.aborted) {
|
|
104
|
+
break poll;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
tick.current++;
|
|
108
|
+
|
|
109
|
+
let status: TaskView;
|
|
110
|
+
|
|
111
|
+
// NOTE: We take action on each tick.
|
|
112
|
+
if (state.current == null) {
|
|
113
|
+
status = await this.create(data, options);
|
|
114
|
+
} else {
|
|
115
|
+
status = await this.retrieve(state.current.taskId);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const [newState, event] = reducer(state.current, { kind: 'status', status });
|
|
119
|
+
|
|
120
|
+
if (event != null) {
|
|
121
|
+
yield { event: 'status', data: event };
|
|
122
|
+
|
|
123
|
+
if (event.status === 'finished') {
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
state.current = newState;
|
|
129
|
+
|
|
130
|
+
await new Promise((resolve) => setTimeout(resolve, config.interval));
|
|
131
|
+
} while (true);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
stream(body: TaskCreateParams, options?: RequestOptions) {
|
|
135
|
+
const self = this;
|
|
136
|
+
|
|
137
|
+
const enc = new TextEncoder();
|
|
138
|
+
|
|
139
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
140
|
+
async start(controller) {
|
|
141
|
+
// open the SSE stream quickly
|
|
142
|
+
controller.enqueue(enc.encode(': connected\n\n'));
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
for await (const msg of self.watch(body, { interval: 500 }, options)) {
|
|
146
|
+
if (options?.signal?.aborted) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const data = JSON.stringify(msg.data);
|
|
151
|
+
|
|
152
|
+
const payload = `event: ${msg.event}\ndata: ${data}\n\n`;
|
|
153
|
+
controller.enqueue(enc.encode(payload));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
controller.enqueue(enc.encode('event: end\ndata: {}\n\n'));
|
|
157
|
+
} catch (e) {
|
|
158
|
+
controller.enqueue(enc.encode(`event: error\ndata: ${JSON.stringify({ message: String(e) })}\n\n`));
|
|
159
|
+
} finally {
|
|
160
|
+
controller.close();
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return stream;
|
|
166
|
+
}
|
|
167
|
+
|
|
17
168
|
/**
|
|
18
|
-
* Get
|
|
169
|
+
* Get detailed information about a specific AI agent task.
|
|
170
|
+
*
|
|
171
|
+
* Retrieves comprehensive information about a task, including its current status,
|
|
172
|
+
* progress, and detailed execution data. You can choose to get just the status
|
|
173
|
+
* (for quick polling) or full details including steps and file information.
|
|
174
|
+
*
|
|
175
|
+
* Use this endpoint to:
|
|
176
|
+
*
|
|
177
|
+
* - Monitor task progress in real-time
|
|
178
|
+
* - Review completed task results
|
|
179
|
+
* - Debug failed tasks by examining steps
|
|
180
|
+
* - Download output files and logs
|
|
181
|
+
*
|
|
182
|
+
* Args:
|
|
183
|
+
*
|
|
184
|
+
* - task_id: The unique identifier of the agent task
|
|
185
|
+
*
|
|
186
|
+
* Returns:
|
|
187
|
+
*
|
|
188
|
+
* - Complete task information
|
|
189
|
+
*
|
|
190
|
+
* Raises:
|
|
191
|
+
*
|
|
192
|
+
* - 404: If the user agent task doesn't exist
|
|
19
193
|
*/
|
|
20
|
-
retrieve(
|
|
21
|
-
|
|
22
|
-
query: TaskRetrieveParams | null | undefined = {},
|
|
194
|
+
retrieve<T extends ZodType>(
|
|
195
|
+
req: { taskId: string; schema: T },
|
|
23
196
|
options?: RequestOptions,
|
|
24
|
-
): APIPromise<
|
|
25
|
-
|
|
197
|
+
): APIPromise<TaskViewWithSchema<T>>;
|
|
198
|
+
retrieve(taskID: string, options?: RequestOptions): APIPromise<TaskView>;
|
|
199
|
+
retrieve(req: string | { taskId: string; schema: ZodType }, options?: RequestOptions): APIPromise<unknown> {
|
|
200
|
+
if (typeof req === 'string') {
|
|
201
|
+
return this._client.get(path`/tasks/${req}`, options);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const { taskId, schema } = req;
|
|
205
|
+
|
|
206
|
+
return this._client
|
|
207
|
+
.get(path`/tasks/${taskId}`, options)
|
|
208
|
+
._thenUnwrap((rsp) => parseStructuredTaskOutput(rsp as TaskView, schema));
|
|
26
209
|
}
|
|
27
210
|
|
|
28
211
|
/**
|
|
29
|
-
*
|
|
212
|
+
* Control the execution of an AI agent task.
|
|
213
|
+
*
|
|
214
|
+
* Allows you to pause, resume, or stop tasks, and optionally stop the entire
|
|
215
|
+
* session. This is useful for:
|
|
216
|
+
*
|
|
217
|
+
* - Pausing long-running tasks to review progress
|
|
218
|
+
* - Stopping tasks that are taking too long
|
|
219
|
+
* - Ending sessions when you're done with all tasks
|
|
220
|
+
*
|
|
221
|
+
* Available actions:
|
|
222
|
+
*
|
|
223
|
+
* - STOP: Stop the current task
|
|
224
|
+
* - PAUSE: Pause the task (can be resumed later)
|
|
225
|
+
* - RESUME: Resume a paused task
|
|
226
|
+
* - STOP_TASK_AND_SESSION: Stop the task and end the entire session
|
|
227
|
+
*
|
|
228
|
+
* Args:
|
|
229
|
+
*
|
|
230
|
+
* - task_id: The unique identifier of the agent task to control
|
|
231
|
+
* - request: The action to perform on the task
|
|
232
|
+
*
|
|
233
|
+
* Returns:
|
|
234
|
+
*
|
|
235
|
+
* - The updated task information
|
|
236
|
+
*
|
|
237
|
+
* Raises:
|
|
238
|
+
*
|
|
239
|
+
* - 404: If the user agent task doesn't exist
|
|
30
240
|
*/
|
|
31
241
|
update(taskID: string, body: TaskUpdateParams, options?: RequestOptions): APIPromise<TaskView> {
|
|
32
242
|
return this._client.patch(path`/tasks/${taskID}`, { body, ...options });
|
|
33
243
|
}
|
|
34
244
|
|
|
35
245
|
/**
|
|
36
|
-
*
|
|
246
|
+
* Get a paginated list of all AI agent tasks for the authenticated user.
|
|
247
|
+
*
|
|
248
|
+
* AI agent tasks are the individual jobs that your agents perform within a
|
|
249
|
+
* session. Each task represents a specific instruction or goal that the agent
|
|
250
|
+
* works on, such as filling out a form, extracting data, or navigating to specific
|
|
251
|
+
* pages.
|
|
252
|
+
*
|
|
253
|
+
* You can control what data is included for each task:
|
|
254
|
+
*
|
|
255
|
+
* - Task steps: Detailed actions the agent took
|
|
256
|
+
* - User uploaded files: Files you provided for the task
|
|
257
|
+
* - Output files: Files generated by the agent during the task
|
|
258
|
+
*
|
|
259
|
+
* Returns:
|
|
260
|
+
*
|
|
261
|
+
* - A paginated list of agent tasks
|
|
262
|
+
* - Total count of tasks
|
|
263
|
+
* - Page information for navigation
|
|
264
|
+
* - Optional detailed data based on your parameters
|
|
37
265
|
*/
|
|
38
266
|
list(
|
|
39
267
|
query: TaskListParams | null | undefined = {},
|
|
@@ -43,25 +271,122 @@ export class Tasks extends APIResource {
|
|
|
43
271
|
}
|
|
44
272
|
|
|
45
273
|
/**
|
|
46
|
-
* Get
|
|
274
|
+
* Get a download URL for the execution logs of an AI agent task.
|
|
275
|
+
*
|
|
276
|
+
* Task logs contain detailed information about how the AI agent executed the task,
|
|
277
|
+
* including:
|
|
278
|
+
*
|
|
279
|
+
* - Step-by-step reasoning and decisions
|
|
280
|
+
* - Actions taken on web pages
|
|
281
|
+
* - Error messages and debugging information
|
|
282
|
+
* - Performance metrics and timing data
|
|
283
|
+
*
|
|
284
|
+
* This is useful for:
|
|
285
|
+
*
|
|
286
|
+
* - Understanding how the agent solved the task
|
|
287
|
+
* - Debugging failed or unexpected results
|
|
288
|
+
* - Optimizing agent behavior and prompts
|
|
289
|
+
* - Auditing agent actions for compliance
|
|
290
|
+
*
|
|
291
|
+
* Args:
|
|
292
|
+
*
|
|
293
|
+
* - task_id: The unique identifier of the agent task
|
|
294
|
+
*
|
|
295
|
+
* Returns:
|
|
296
|
+
*
|
|
297
|
+
* - A presigned download URL for the task log file
|
|
298
|
+
*
|
|
299
|
+
* Raises:
|
|
300
|
+
*
|
|
301
|
+
* - 404: If the user agent task doesn't exist
|
|
302
|
+
* - 500: If the download URL cannot be generated (should not happen)
|
|
47
303
|
*/
|
|
48
|
-
|
|
304
|
+
getLogs(taskID: string, options?: RequestOptions): APIPromise<TaskGetLogsResponse> {
|
|
49
305
|
return this._client.get(path`/tasks/${taskID}/logs`, options);
|
|
50
306
|
}
|
|
51
307
|
|
|
52
308
|
/**
|
|
53
|
-
* Get
|
|
309
|
+
* Get a download URL for a specific output file generated by an AI agent task.
|
|
310
|
+
*
|
|
311
|
+
* AI agents can generate various output files during task execution, such as:
|
|
312
|
+
*
|
|
313
|
+
* - Screenshots of web pages
|
|
314
|
+
* - Extracted data in CSV/JSON format
|
|
315
|
+
* - Generated reports or documents
|
|
316
|
+
* - Downloaded files from websites
|
|
317
|
+
*
|
|
318
|
+
* This endpoint provides a secure, time-limited download URL for accessing these
|
|
319
|
+
* files. The URL expires after a short time for security.
|
|
320
|
+
*
|
|
321
|
+
* Args:
|
|
322
|
+
*
|
|
323
|
+
* - task_id: The unique identifier of the agent task
|
|
324
|
+
* - file_id: The unique identifier of the output file
|
|
325
|
+
*
|
|
326
|
+
* Returns:
|
|
327
|
+
*
|
|
328
|
+
* - A presigned download URL for the requested file
|
|
329
|
+
*
|
|
330
|
+
* Raises:
|
|
331
|
+
*
|
|
332
|
+
* - 404: If the user agent task or output file doesn't exist
|
|
333
|
+
* - 500: If the download URL cannot be generated (should not happen)
|
|
334
|
+
*/
|
|
335
|
+
getOutputFile(
|
|
336
|
+
fileID: string,
|
|
337
|
+
params: TaskGetOutputFileParams,
|
|
338
|
+
options?: RequestOptions,
|
|
339
|
+
): APIPromise<TaskGetOutputFileResponse> {
|
|
340
|
+
const { task_id } = params;
|
|
341
|
+
return this._client.get(path`/tasks/${task_id}/output-files/${fileID}`, options);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Get a download URL for a specific user uploaded file that was used in the task.
|
|
346
|
+
*
|
|
347
|
+
* A user can upload files to their account file bucket and reference the name of
|
|
348
|
+
* the file in a task. These files are then made available for the agent to use
|
|
349
|
+
* during the agent task run.
|
|
350
|
+
*
|
|
351
|
+
* This endpoint provides a secure, time-limited download URL for accessing these
|
|
352
|
+
* files. The URL expires after a short time for security.
|
|
353
|
+
*
|
|
354
|
+
* Args:
|
|
355
|
+
*
|
|
356
|
+
* - task_id: The unique identifier of the agent task
|
|
357
|
+
* - file_id: The unique identifier of the user uploaded file
|
|
358
|
+
*
|
|
359
|
+
* Returns:
|
|
360
|
+
*
|
|
361
|
+
* - A presigned download URL for the requested file
|
|
362
|
+
*
|
|
363
|
+
* Raises:
|
|
364
|
+
*
|
|
365
|
+
* - 404: If the user agent task or user uploaded file doesn't exist
|
|
366
|
+
* - 500: If the download URL cannot be generated (should not happen)
|
|
54
367
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
params:
|
|
368
|
+
getUserUploadedFile(
|
|
369
|
+
fileID: string,
|
|
370
|
+
params: TaskGetUserUploadedFileParams,
|
|
58
371
|
options?: RequestOptions,
|
|
59
|
-
): APIPromise<
|
|
372
|
+
): APIPromise<TaskGetUserUploadedFileResponse> {
|
|
60
373
|
const { task_id } = params;
|
|
61
|
-
return this._client.get(path`/tasks/${task_id}/
|
|
374
|
+
return this._client.get(path`/tasks/${task_id}/user-uploaded-files/${fileID}`, options);
|
|
62
375
|
}
|
|
63
376
|
}
|
|
64
377
|
|
|
378
|
+
/**
|
|
379
|
+
* View model for representing an output file generated by the agent
|
|
380
|
+
*
|
|
381
|
+
* Attributes: id: Unique identifier for the output file file_name: Name of the
|
|
382
|
+
* output file
|
|
383
|
+
*/
|
|
384
|
+
export interface FileView {
|
|
385
|
+
id: string;
|
|
386
|
+
|
|
387
|
+
fileName: string;
|
|
388
|
+
}
|
|
389
|
+
|
|
65
390
|
export type LlmModel =
|
|
66
391
|
| 'gpt-4o'
|
|
67
392
|
| 'gpt-4o-mini'
|
|
@@ -78,37 +403,26 @@ export type LlmModel =
|
|
|
78
403
|
| 'claude-sonnet-4-20250514'
|
|
79
404
|
| 'llama-4-maverick-17b-128e-instruct';
|
|
80
405
|
|
|
81
|
-
/**
|
|
82
|
-
* Enumeration of possible task execution states
|
|
83
|
-
*
|
|
84
|
-
* Attributes: STARTED: Task has been initiated and is currently running PAUSED:
|
|
85
|
-
* Task execution has been temporarily paused STOPPED: Task execution has been
|
|
86
|
-
* stopped (not completed) FINISHED: Task has completed successfully
|
|
87
|
-
*/
|
|
88
|
-
export type TaskStatus = 'started' | 'paused' | 'stopped' | 'finished';
|
|
89
|
-
|
|
90
406
|
/**
|
|
91
407
|
* View model for representing a task with its execution details
|
|
92
408
|
*
|
|
93
409
|
* Attributes: id: Unique identifier for the task session_id: ID of the session
|
|
94
|
-
* this task belongs to session_live_url:
|
|
95
|
-
* model used for this task task: The task prompt/instruction given to the
|
|
96
|
-
* status: Current status of the task execution started_at: Naive UTC
|
|
97
|
-
* when the task was started finished_at: Naive UTC timestamp when the
|
|
98
|
-
* completed (None if still running) metadata:
|
|
99
|
-
* the task
|
|
100
|
-
* created as a scheduled task steps:
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
410
|
+
* this task belongs to session_live_url: Optional live URL of the session llm: The
|
|
411
|
+
* LLM model used for this task task: The task prompt/instruction given to the
|
|
412
|
+
* agent status: Current status of the task execution started_at: Naive UTC
|
|
413
|
+
* timestamp when the task was started finished_at: Naive UTC timestamp when the
|
|
414
|
+
* task completed (None if still running) metadata: Optional additional metadata
|
|
415
|
+
* associated with the task set by the user is_scheduled: Whether this task was
|
|
416
|
+
* created as a scheduled task steps: Optional list of execution steps done_output:
|
|
417
|
+
* Final output/result of the task user_uploaded_files: Optional list of files
|
|
418
|
+
* uploaded by user for this task output_files: Optional list of files generated as
|
|
419
|
+
* output by this task browser_use_version: Version of browser-use used for this
|
|
420
|
+
* task (older tasks may not have this set) is_success: Whether the task was
|
|
421
|
+
* successful (self-reported by the agent)
|
|
106
422
|
*/
|
|
107
|
-
export interface
|
|
423
|
+
export interface TaskItemView {
|
|
108
424
|
id: string;
|
|
109
425
|
|
|
110
|
-
doneOutput: string;
|
|
111
|
-
|
|
112
426
|
isScheduled: boolean;
|
|
113
427
|
|
|
114
428
|
llm: LlmModel;
|
|
@@ -120,9 +434,9 @@ export interface TaskView {
|
|
|
120
434
|
/**
|
|
121
435
|
* Enumeration of possible task execution states
|
|
122
436
|
*
|
|
123
|
-
* Attributes: STARTED: Task has been
|
|
124
|
-
*
|
|
125
|
-
* stopped (
|
|
437
|
+
* Attributes: STARTED: Task has been started and is currently running PAUSED: Task
|
|
438
|
+
* execution has been temporarily paused (can be resumed) STOPPED: Task execution
|
|
439
|
+
* has been stopped (cannot be resumed) FINISHED: Task has completed successfully
|
|
126
440
|
*/
|
|
127
441
|
status: TaskStatus;
|
|
128
442
|
|
|
@@ -130,82 +444,114 @@ export interface TaskView {
|
|
|
130
444
|
|
|
131
445
|
browserUseVersion?: string | null;
|
|
132
446
|
|
|
447
|
+
doneOutput?: string | null;
|
|
448
|
+
|
|
133
449
|
finishedAt?: string | null;
|
|
134
450
|
|
|
451
|
+
isSuccess?: boolean | null;
|
|
452
|
+
|
|
135
453
|
metadata?: { [key: string]: unknown };
|
|
136
454
|
|
|
137
|
-
outputFiles?: Array<
|
|
455
|
+
outputFiles?: Array<FileView> | null;
|
|
138
456
|
|
|
139
457
|
sessionLiveUrl?: string | null;
|
|
140
458
|
|
|
141
|
-
steps?: Array<
|
|
459
|
+
steps?: Array<TaskStepView> | null;
|
|
142
460
|
|
|
143
|
-
userUploadedFiles?: Array<
|
|
461
|
+
userUploadedFiles?: Array<FileView> | null;
|
|
144
462
|
}
|
|
145
463
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
* this step actions: List of stringified json actions performed by the agent in
|
|
155
|
-
* this step
|
|
156
|
-
*/
|
|
157
|
-
export interface Step {
|
|
158
|
-
actions: Array<string>;
|
|
464
|
+
/**
|
|
465
|
+
* Enumeration of possible task execution states
|
|
466
|
+
*
|
|
467
|
+
* Attributes: STARTED: Task has been started and is currently running PAUSED: Task
|
|
468
|
+
* execution has been temporarily paused (can be resumed) STOPPED: Task execution
|
|
469
|
+
* has been stopped (cannot be resumed) FINISHED: Task has completed successfully
|
|
470
|
+
*/
|
|
471
|
+
export type TaskStatus = 'started' | 'paused' | 'stopped' | 'finished';
|
|
159
472
|
|
|
160
|
-
|
|
473
|
+
/**
|
|
474
|
+
* View model for representing a single step in a task's execution
|
|
475
|
+
*
|
|
476
|
+
* Attributes: number: Sequential step number within the task memory: Agent's
|
|
477
|
+
* memory at this step evaluation_previous_goal: Agent's evaluation of the previous
|
|
478
|
+
* goal completion next_goal: The goal for the next step url: Current URL the
|
|
479
|
+
* browser is on for this step screenshot_url: Optional URL to the screenshot taken
|
|
480
|
+
* at this step actions: List of stringified json actions performed by the agent in
|
|
481
|
+
* this step
|
|
482
|
+
*/
|
|
483
|
+
export interface TaskStepView {
|
|
484
|
+
actions: Array<string>;
|
|
161
485
|
|
|
162
|
-
|
|
486
|
+
evaluationPreviousGoal: string;
|
|
163
487
|
|
|
164
|
-
|
|
488
|
+
memory: string;
|
|
165
489
|
|
|
166
|
-
|
|
490
|
+
nextGoal: string;
|
|
167
491
|
|
|
168
|
-
|
|
492
|
+
number: number;
|
|
169
493
|
|
|
170
|
-
|
|
171
|
-
|
|
494
|
+
url: string;
|
|
495
|
+
|
|
496
|
+
screenshotUrl?: string | null;
|
|
172
497
|
}
|
|
173
498
|
|
|
174
499
|
/**
|
|
175
500
|
* View model for representing a task with its execution details
|
|
176
501
|
*
|
|
177
502
|
* Attributes: id: Unique identifier for the task session_id: ID of the session
|
|
178
|
-
* this task belongs to session_live_url:
|
|
179
|
-
* model used for this task task: The task prompt/instruction given to the
|
|
180
|
-
* status: Current status of the task execution started_at: Naive UTC
|
|
181
|
-
* when the task was started finished_at: Naive UTC timestamp when the
|
|
182
|
-
* completed (None if still running) metadata:
|
|
183
|
-
* the task
|
|
184
|
-
* created as a scheduled task steps: List of execution steps
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* this
|
|
189
|
-
*
|
|
503
|
+
* this task belongs to session_live_url: Optional live URL of the session llm: The
|
|
504
|
+
* LLM model used for this task task: The task prompt/instruction given to the
|
|
505
|
+
* agent status: Current status of the task execution started_at: Naive UTC
|
|
506
|
+
* timestamp when the task was started finished_at: Naive UTC timestamp when the
|
|
507
|
+
* task completed (None if still running) metadata: Optional additional metadata
|
|
508
|
+
* associated with the task set by the user is_scheduled: Whether this task was
|
|
509
|
+
* created as a scheduled task steps: List of execution steps done_output: Final
|
|
510
|
+
* output/result of the task user_uploaded_files: List of files uploaded by user
|
|
511
|
+
* for this task output_files: List of files generated as output by this task
|
|
512
|
+
* browser_use_version: Version of browser-use used for this task (older tasks may
|
|
513
|
+
* not have this set) is_success: Whether the task was successful (self-reported by
|
|
514
|
+
* the agent)
|
|
190
515
|
*/
|
|
191
|
-
export
|
|
516
|
+
export interface TaskView {
|
|
517
|
+
id: string;
|
|
518
|
+
|
|
519
|
+
isScheduled: boolean;
|
|
520
|
+
|
|
521
|
+
llm: LlmModel;
|
|
522
|
+
|
|
523
|
+
outputFiles: Array<FileView>;
|
|
524
|
+
|
|
525
|
+
sessionId: string;
|
|
526
|
+
|
|
527
|
+
startedAt: string;
|
|
192
528
|
|
|
193
|
-
export namespace TaskRetrieveResponse {
|
|
194
529
|
/**
|
|
195
|
-
*
|
|
530
|
+
* Enumeration of possible task execution states
|
|
196
531
|
*
|
|
197
|
-
* Attributes:
|
|
532
|
+
* Attributes: STARTED: Task has been started and is currently running PAUSED: Task
|
|
533
|
+
* execution has been temporarily paused (can be resumed) STOPPED: Task execution
|
|
534
|
+
* has been stopped (cannot be resumed) FINISHED: Task has completed successfully
|
|
198
535
|
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
536
|
+
status: TaskStatus;
|
|
537
|
+
|
|
538
|
+
steps: Array<TaskStepView>;
|
|
539
|
+
|
|
540
|
+
task: string;
|
|
541
|
+
|
|
542
|
+
userUploadedFiles: Array<FileView>;
|
|
543
|
+
|
|
544
|
+
browserUseVersion?: string | null;
|
|
545
|
+
|
|
546
|
+
doneOutput?: string | null;
|
|
547
|
+
|
|
548
|
+
finishedAt?: string | null;
|
|
549
|
+
|
|
550
|
+
isSuccess?: boolean | null;
|
|
551
|
+
|
|
552
|
+
metadata?: { [key: string]: unknown };
|
|
553
|
+
|
|
554
|
+
sessionLiveUrl?: string | null;
|
|
209
555
|
}
|
|
210
556
|
|
|
211
557
|
/**
|
|
@@ -214,7 +560,7 @@ export namespace TaskRetrieveResponse {
|
|
|
214
560
|
* Attributes: items: List of task views for the current page
|
|
215
561
|
*/
|
|
216
562
|
export interface TaskListResponse {
|
|
217
|
-
items: Array<
|
|
563
|
+
items: Array<TaskItemView>;
|
|
218
564
|
|
|
219
565
|
pageNumber: number;
|
|
220
566
|
|
|
@@ -228,7 +574,7 @@ export interface TaskListResponse {
|
|
|
228
574
|
*
|
|
229
575
|
* Attributes: download_url: URL to download the log file
|
|
230
576
|
*/
|
|
231
|
-
export interface
|
|
577
|
+
export interface TaskGetLogsResponse {
|
|
232
578
|
downloadUrl: string;
|
|
233
579
|
}
|
|
234
580
|
|
|
@@ -237,7 +583,16 @@ export interface TaskRetrieveLogsResponse {
|
|
|
237
583
|
*
|
|
238
584
|
* Attributes: download_url: URL to download the output file
|
|
239
585
|
*/
|
|
240
|
-
export interface
|
|
586
|
+
export interface TaskGetOutputFileResponse {
|
|
587
|
+
downloadUrl: string;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Response model for user uploaded file requests
|
|
592
|
+
*
|
|
593
|
+
* Attributes: download_url: URL to download the user uploaded file
|
|
594
|
+
*/
|
|
595
|
+
export interface TaskGetUserUploadedFileResponse {
|
|
241
596
|
downloadUrl: string;
|
|
242
597
|
}
|
|
243
598
|
|
|
@@ -247,19 +602,17 @@ export interface TaskCreateParams {
|
|
|
247
602
|
/**
|
|
248
603
|
* Configuration settings for the AI agent
|
|
249
604
|
*
|
|
250
|
-
* Attributes: llm: The LLM model to use for the agent
|
|
251
|
-
*
|
|
252
|
-
* (None for default)
|
|
605
|
+
* Attributes: llm: The LLM model to use for the agent profile_id: Unique
|
|
606
|
+
* identifier of the agent profile to use for the task
|
|
253
607
|
*/
|
|
254
608
|
agentSettings?: TaskCreateParams.AgentSettings;
|
|
255
609
|
|
|
256
610
|
/**
|
|
257
611
|
* Configuration settings for the browser session
|
|
258
612
|
*
|
|
259
|
-
* Attributes: session_id:
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* later
|
|
613
|
+
* Attributes: session_id: Unique identifier of existing session to continue
|
|
614
|
+
* profile_id: Unique identifier of browser profile to use save_browser_data:
|
|
615
|
+
* Whether to save browser state/data for the user to download later
|
|
263
616
|
*/
|
|
264
617
|
browserSettings?: TaskCreateParams.BrowserSettings;
|
|
265
618
|
|
|
@@ -276,9 +629,8 @@ export namespace TaskCreateParams {
|
|
|
276
629
|
/**
|
|
277
630
|
* Configuration settings for the AI agent
|
|
278
631
|
*
|
|
279
|
-
* Attributes: llm: The LLM model to use for the agent
|
|
280
|
-
*
|
|
281
|
-
* (None for default)
|
|
632
|
+
* Attributes: llm: The LLM model to use for the agent profile_id: Unique
|
|
633
|
+
* identifier of the agent profile to use for the task
|
|
282
634
|
*/
|
|
283
635
|
export interface AgentSettings {
|
|
284
636
|
llm?: TasksAPI.LlmModel;
|
|
@@ -289,10 +641,9 @@ export namespace TaskCreateParams {
|
|
|
289
641
|
/**
|
|
290
642
|
* Configuration settings for the browser session
|
|
291
643
|
*
|
|
292
|
-
* Attributes: session_id:
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* later
|
|
644
|
+
* Attributes: session_id: Unique identifier of existing session to continue
|
|
645
|
+
* profile_id: Unique identifier of browser profile to use save_browser_data:
|
|
646
|
+
* Whether to save browser state/data for the user to download later
|
|
296
647
|
*/
|
|
297
648
|
export interface BrowserSettings {
|
|
298
649
|
profileId?: string | null;
|
|
@@ -303,10 +654,6 @@ export namespace TaskCreateParams {
|
|
|
303
654
|
}
|
|
304
655
|
}
|
|
305
656
|
|
|
306
|
-
export interface TaskRetrieveParams {
|
|
307
|
-
statusOnly?: boolean;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
657
|
export interface TaskUpdateParams {
|
|
311
658
|
/**
|
|
312
659
|
* Available actions that can be performed on a task
|
|
@@ -319,6 +666,15 @@ export interface TaskUpdateParams {
|
|
|
319
666
|
}
|
|
320
667
|
|
|
321
668
|
export interface TaskListParams {
|
|
669
|
+
/**
|
|
670
|
+
* Enumeration of possible task filters
|
|
671
|
+
*
|
|
672
|
+
* Attributes: STARTED: All started tasks PAUSED: All paused tasks STOPPED: All
|
|
673
|
+
* stopped tasks FINISHED: All finished tasks SUCCESSFUL: All successful tasks
|
|
674
|
+
* UNSUCCESSFUL: All unsuccessful tasks
|
|
675
|
+
*/
|
|
676
|
+
filterBy?: 'started' | 'paused' | 'stopped' | 'finished' | 'successful' | 'unsuccessful' | null;
|
|
677
|
+
|
|
322
678
|
includeOutputFiles?: boolean;
|
|
323
679
|
|
|
324
680
|
includeSteps?: boolean;
|
|
@@ -328,25 +684,34 @@ export interface TaskListParams {
|
|
|
328
684
|
pageNumber?: number;
|
|
329
685
|
|
|
330
686
|
pageSize?: number;
|
|
687
|
+
|
|
688
|
+
sessionId?: string | null;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export interface TaskGetOutputFileParams {
|
|
692
|
+
task_id: string;
|
|
331
693
|
}
|
|
332
694
|
|
|
333
|
-
export interface
|
|
695
|
+
export interface TaskGetUserUploadedFileParams {
|
|
334
696
|
task_id: string;
|
|
335
697
|
}
|
|
336
698
|
|
|
337
699
|
export declare namespace Tasks {
|
|
338
700
|
export {
|
|
701
|
+
type FileView as FileView,
|
|
339
702
|
type LlmModel as LlmModel,
|
|
703
|
+
type TaskItemView as TaskItemView,
|
|
340
704
|
type TaskStatus as TaskStatus,
|
|
705
|
+
type TaskStepView as TaskStepView,
|
|
341
706
|
type TaskView as TaskView,
|
|
342
|
-
type TaskRetrieveResponse as TaskRetrieveResponse,
|
|
343
707
|
type TaskListResponse as TaskListResponse,
|
|
344
|
-
type
|
|
345
|
-
type
|
|
708
|
+
type TaskGetLogsResponse as TaskGetLogsResponse,
|
|
709
|
+
type TaskGetOutputFileResponse as TaskGetOutputFileResponse,
|
|
710
|
+
type TaskGetUserUploadedFileResponse as TaskGetUserUploadedFileResponse,
|
|
346
711
|
type TaskCreateParams as TaskCreateParams,
|
|
347
|
-
type TaskRetrieveParams as TaskRetrieveParams,
|
|
348
712
|
type TaskUpdateParams as TaskUpdateParams,
|
|
349
713
|
type TaskListParams as TaskListParams,
|
|
350
|
-
type
|
|
714
|
+
type TaskGetOutputFileParams as TaskGetOutputFileParams,
|
|
715
|
+
type TaskGetUserUploadedFileParams as TaskGetUserUploadedFileParams,
|
|
351
716
|
};
|
|
352
717
|
}
|