browser-use-sdk 0.2.1 → 0.3.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 +16 -0
- package/client.d.mts +2 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +2 -2
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/lib/stream.d.mts +1 -0
- package/lib/stream.d.mts.map +1 -1
- package/lib/stream.d.ts +1 -0
- package/lib/stream.d.ts.map +1 -1
- package/lib/stream.js +16 -5
- package/lib/stream.js.map +1 -1
- package/lib/stream.mjs +16 -5
- package/lib/stream.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/tasks.d.mts +26 -13
- package/resources/tasks.d.mts.map +1 -1
- package/resources/tasks.d.ts +26 -13
- package/resources/tasks.d.ts.map +1 -1
- package/resources/tasks.js +17 -39
- package/resources/tasks.js.map +1 -1
- package/resources/tasks.mjs +17 -39
- package/resources/tasks.mjs.map +1 -1
- package/resources/users/me/files.d.mts +1 -1
- package/resources/users/me/files.d.ts +1 -1
- package/src/client.ts +2 -0
- package/src/lib/stream.ts +21 -8
- package/src/resources/index.ts +1 -0
- package/src/resources/tasks.ts +74 -85
- package/src/resources/users/me/files.ts +1 -1
- 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
|
@@ -54,7 +54,7 @@ export class Tasks extends APIResource {
|
|
|
54
54
|
*
|
|
55
55
|
* Returns:
|
|
56
56
|
*
|
|
57
|
-
* - The created task with
|
|
57
|
+
* - The created task ID together with the task's session ID
|
|
58
58
|
*
|
|
59
59
|
* Raises:
|
|
60
60
|
*
|
|
@@ -65,17 +65,13 @@ export class Tasks extends APIResource {
|
|
|
65
65
|
create<T extends ZodType>(
|
|
66
66
|
body: TaskCreateParamsWithSchema<T>,
|
|
67
67
|
options?: RequestOptions,
|
|
68
|
-
): APIPromise<
|
|
69
|
-
create(body: TaskCreateParams, options?: RequestOptions): APIPromise<
|
|
68
|
+
): APIPromise<TaskCreateResponse>;
|
|
69
|
+
create(body: TaskCreateParams, options?: RequestOptions): APIPromise<TaskCreateResponse>;
|
|
70
70
|
create(
|
|
71
71
|
body: TaskCreateParams | TaskCreateParamsWithSchema<ZodType>,
|
|
72
72
|
options?: RequestOptions,
|
|
73
|
-
): APIPromise<
|
|
74
|
-
if (body.structuredOutputJson
|
|
75
|
-
return this._client.post('/tasks', { body, ...options });
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (typeof body.structuredOutputJson === 'object') {
|
|
73
|
+
): APIPromise<TaskCreateResponse> {
|
|
74
|
+
if (body.structuredOutputJson != null && typeof body.structuredOutputJson === 'object') {
|
|
79
75
|
const schema = body.structuredOutputJson;
|
|
80
76
|
|
|
81
77
|
const _body: TaskCreateParams = {
|
|
@@ -83,16 +79,57 @@ export class Tasks extends APIResource {
|
|
|
83
79
|
structuredOutputJson: stringifyStructuredOutput(schema),
|
|
84
80
|
};
|
|
85
81
|
|
|
86
|
-
return this._client
|
|
87
|
-
.post('/tasks', { body: _body, ...options })
|
|
88
|
-
._thenUnwrap((rsp) => parseStructuredTaskOutput(rsp as TaskView, schema));
|
|
82
|
+
return this._client.post('/tasks', { body: _body, ...options });
|
|
89
83
|
}
|
|
90
84
|
|
|
91
85
|
return this._client.post('/tasks', { body, ...options });
|
|
92
86
|
}
|
|
93
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Get detailed information about a specific AI agent task.
|
|
90
|
+
*
|
|
91
|
+
* Retrieves comprehensive information about a task, including its current status,
|
|
92
|
+
* progress, and detailed execution data. You can choose to get just the status
|
|
93
|
+
* (for quick polling) or full details including steps and file information.
|
|
94
|
+
*
|
|
95
|
+
* Use this endpoint to:
|
|
96
|
+
*
|
|
97
|
+
* - Monitor task progress in real-time
|
|
98
|
+
* - Review completed task results
|
|
99
|
+
* - Debug failed tasks by examining steps
|
|
100
|
+
* - Download output files and logs
|
|
101
|
+
*
|
|
102
|
+
* Args:
|
|
103
|
+
*
|
|
104
|
+
* - task_id: The unique identifier of the agent task
|
|
105
|
+
*
|
|
106
|
+
* Returns:
|
|
107
|
+
*
|
|
108
|
+
* - Complete task information
|
|
109
|
+
*
|
|
110
|
+
* Raises:
|
|
111
|
+
*
|
|
112
|
+
* - 404: If the user agent task doesn't exist
|
|
113
|
+
*/
|
|
114
|
+
retrieve<T extends ZodType>(
|
|
115
|
+
req: { taskId: string; schema: T },
|
|
116
|
+
options?: RequestOptions,
|
|
117
|
+
): APIPromise<TaskViewWithSchema<T>>;
|
|
118
|
+
retrieve(taskID: string, options?: RequestOptions): APIPromise<TaskView>;
|
|
119
|
+
retrieve(req: string | { taskId: string; schema: ZodType }, options?: RequestOptions): APIPromise<unknown> {
|
|
120
|
+
if (typeof req === 'string') {
|
|
121
|
+
return this._client.get(path`/tasks/${req}`, options);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const { taskId, schema } = req;
|
|
125
|
+
|
|
126
|
+
return this._client
|
|
127
|
+
.get(path`/tasks/${taskId}`, options)
|
|
128
|
+
._thenUnwrap((rsp) => parseStructuredTaskOutput(rsp as TaskView, schema));
|
|
129
|
+
}
|
|
130
|
+
|
|
94
131
|
private async *watch(
|
|
95
|
-
|
|
132
|
+
taskId: string,
|
|
96
133
|
config: { interval: number },
|
|
97
134
|
options?: RequestOptions,
|
|
98
135
|
): AsyncGenerator<{ event: 'status'; data: TaskView }> {
|
|
@@ -106,14 +143,7 @@ export class Tasks extends APIResource {
|
|
|
106
143
|
|
|
107
144
|
tick.current++;
|
|
108
145
|
|
|
109
|
-
|
|
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
|
-
}
|
|
146
|
+
const status = await this.retrieve(taskId);
|
|
117
147
|
|
|
118
148
|
const [newState, event] = reducer(state.current, { kind: 'status', status });
|
|
119
149
|
|
|
@@ -132,39 +162,28 @@ export class Tasks extends APIResource {
|
|
|
132
162
|
}
|
|
133
163
|
|
|
134
164
|
stream<T extends ZodType>(
|
|
135
|
-
body:
|
|
165
|
+
body: {
|
|
166
|
+
taskId: string;
|
|
167
|
+
schema: T;
|
|
168
|
+
},
|
|
136
169
|
options?: RequestOptions,
|
|
137
170
|
): AsyncGenerator<{ event: 'status'; data: TaskViewWithSchema<T> }>;
|
|
138
|
-
stream(
|
|
139
|
-
body: TaskCreateParams,
|
|
140
|
-
options?: RequestOptions,
|
|
141
|
-
): AsyncGenerator<{ event: 'status'; data: TaskView }>;
|
|
171
|
+
stream(taskId: string, options?: RequestOptions): AsyncGenerator<{ event: 'status'; data: TaskView }>;
|
|
142
172
|
async *stream(
|
|
143
|
-
body:
|
|
173
|
+
body: string | { taskId: string; schema: ZodType },
|
|
144
174
|
options?: RequestOptions,
|
|
145
175
|
): AsyncGenerator<unknown> {
|
|
146
176
|
let req: TaskCreateParams;
|
|
147
177
|
|
|
148
|
-
|
|
149
|
-
'structuredOutputJson' in body &&
|
|
150
|
-
body.structuredOutputJson != null &&
|
|
151
|
-
typeof body.structuredOutputJson === 'object'
|
|
152
|
-
) {
|
|
153
|
-
req = {
|
|
154
|
-
...body,
|
|
155
|
-
structuredOutputJson: stringifyStructuredOutput(body.structuredOutputJson),
|
|
156
|
-
};
|
|
157
|
-
} else {
|
|
158
|
-
req = body as TaskCreateParams;
|
|
159
|
-
}
|
|
178
|
+
const taskId = typeof body === 'object' ? body.taskId : body;
|
|
160
179
|
|
|
161
|
-
for await (const msg of this.watch(
|
|
180
|
+
for await (const msg of this.watch(taskId, { interval: 500 }, options)) {
|
|
162
181
|
if (options?.signal?.aborted) {
|
|
163
182
|
break;
|
|
164
183
|
}
|
|
165
184
|
|
|
166
|
-
if (
|
|
167
|
-
const parsed = parseStructuredTaskOutput<ZodType>(msg.data, body.
|
|
185
|
+
if (typeof body === 'object') {
|
|
186
|
+
const parsed = parseStructuredTaskOutput<ZodType>(msg.data, body.schema);
|
|
168
187
|
yield { event: 'status', data: parsed };
|
|
169
188
|
} else {
|
|
170
189
|
yield { event: 'status', data: msg.data };
|
|
@@ -172,49 +191,6 @@ export class Tasks extends APIResource {
|
|
|
172
191
|
}
|
|
173
192
|
}
|
|
174
193
|
|
|
175
|
-
/**
|
|
176
|
-
* Get detailed information about a specific AI agent task.
|
|
177
|
-
*
|
|
178
|
-
* Retrieves comprehensive information about a task, including its current status,
|
|
179
|
-
* progress, and detailed execution data. You can choose to get just the status
|
|
180
|
-
* (for quick polling) or full details including steps and file information.
|
|
181
|
-
*
|
|
182
|
-
* Use this endpoint to:
|
|
183
|
-
*
|
|
184
|
-
* - Monitor task progress in real-time
|
|
185
|
-
* - Review completed task results
|
|
186
|
-
* - Debug failed tasks by examining steps
|
|
187
|
-
* - Download output files and logs
|
|
188
|
-
*
|
|
189
|
-
* Args:
|
|
190
|
-
*
|
|
191
|
-
* - task_id: The unique identifier of the agent task
|
|
192
|
-
*
|
|
193
|
-
* Returns:
|
|
194
|
-
*
|
|
195
|
-
* - Complete task information
|
|
196
|
-
*
|
|
197
|
-
* Raises:
|
|
198
|
-
*
|
|
199
|
-
* - 404: If the user agent task doesn't exist
|
|
200
|
-
*/
|
|
201
|
-
retrieve<T extends ZodType>(
|
|
202
|
-
req: { taskId: string; schema: T },
|
|
203
|
-
options?: RequestOptions,
|
|
204
|
-
): APIPromise<TaskViewWithSchema<T>>;
|
|
205
|
-
retrieve(taskID: string, options?: RequestOptions): APIPromise<TaskView>;
|
|
206
|
-
retrieve(req: string | { taskId: string; schema: ZodType }, options?: RequestOptions): APIPromise<unknown> {
|
|
207
|
-
if (typeof req === 'string') {
|
|
208
|
-
return this._client.get(path`/tasks/${req}`, options);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const { taskId, schema } = req;
|
|
212
|
-
|
|
213
|
-
return this._client
|
|
214
|
-
.get(path`/tasks/${taskId}`, options)
|
|
215
|
-
._thenUnwrap((rsp) => parseStructuredTaskOutput(rsp as TaskView, schema));
|
|
216
|
-
}
|
|
217
|
-
|
|
218
194
|
/**
|
|
219
195
|
* Control the execution of an AI agent task.
|
|
220
196
|
*
|
|
@@ -561,6 +537,18 @@ export interface TaskView {
|
|
|
561
537
|
sessionLiveUrl?: string | null;
|
|
562
538
|
}
|
|
563
539
|
|
|
540
|
+
/**
|
|
541
|
+
* Response model for creating a task
|
|
542
|
+
*
|
|
543
|
+
* Attributes: task_id: An unique identifier for the created task session_id: The
|
|
544
|
+
* ID of the session this task belongs to
|
|
545
|
+
*/
|
|
546
|
+
export interface TaskCreateResponse {
|
|
547
|
+
id: string;
|
|
548
|
+
|
|
549
|
+
sessionId: string;
|
|
550
|
+
}
|
|
551
|
+
|
|
564
552
|
/**
|
|
565
553
|
* Response model for paginated task list requests
|
|
566
554
|
*
|
|
@@ -711,6 +699,7 @@ export declare namespace Tasks {
|
|
|
711
699
|
type TaskStatus as TaskStatus,
|
|
712
700
|
type TaskStepView as TaskStepView,
|
|
713
701
|
type TaskView as TaskView,
|
|
702
|
+
type TaskCreateResponse as TaskCreateResponse,
|
|
714
703
|
type TaskListResponse as TaskListResponse,
|
|
715
704
|
type TaskGetLogsResponse as TaskGetLogsResponse,
|
|
716
705
|
type TaskGetOutputFileResponse as TaskGetOutputFileResponse,
|
|
@@ -45,7 +45,7 @@ export class Files extends APIResource {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* Response model for presigned upload URL
|
|
48
|
+
* Response model for a presigned upload URL
|
|
49
49
|
*
|
|
50
50
|
* Attributes: url: The URL to upload the file to method: The HTTP method to use
|
|
51
51
|
* for the upload fields: The form fields to include in the upload request
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.3.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.3.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.3.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.3.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|