Skip to content

Commit 16f3e7f

Browse files
feat: Fix Stainless GitHub Action
1 parent db1e1a1 commit 16f3e7f

File tree

8 files changed

+91
-91
lines changed

8 files changed

+91
-91
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 26
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-9ff5409663c58ae9e3ecc9ac764956189e3a70600f5ba1b961bb1dedf0208271.yml
3-
openapi_spec_hash: 9865acb75430d9b799502acbae860df0
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-d20f308ac3a63b1ea5749dac763fd846481c9723156a5653c1d03669e73d5b5e.yml
3+
openapi_spec_hash: ccf5babfe92a776213a3e5097a7cd546
44
config_hash: 9d52be5177b2ede4cb0633c04f4cc4ef

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ Types:
3030
- <code><a href="./src/resources/tasks.ts">TaskStatus</a></code>
3131
- <code><a href="./src/resources/tasks.ts">TaskStepView</a></code>
3232
- <code><a href="./src/resources/tasks.ts">TaskView</a></code>
33+
- <code><a href="./src/resources/tasks.ts">TaskCreateResponse</a></code>
3334
- <code><a href="./src/resources/tasks.ts">TaskListResponse</a></code>
3435
- <code><a href="./src/resources/tasks.ts">TaskGetLogsResponse</a></code>
3536
- <code><a href="./src/resources/tasks.ts">TaskGetOutputFileResponse</a></code>
3637
- <code><a href="./src/resources/tasks.ts">TaskGetUserUploadedFileResponse</a></code>
3738

3839
Methods:
3940

40-
- <code title="post /tasks">client.tasks.<a href="./src/resources/tasks.ts">create</a>({ ...params }) -> TaskView</code>
41+
- <code title="post /tasks">client.tasks.<a href="./src/resources/tasks.ts">create</a>({ ...params }) -> TaskCreateResponse</code>
4142
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/resources/tasks.ts">retrieve</a>(taskID) -> TaskView</code>
4243
- <code title="patch /tasks/{task_id}">client.tasks.<a href="./src/resources/tasks.ts">update</a>(taskID, { ...params }) -> TaskView</code>
4344
- <code title="get /tasks">client.tasks.<a href="./src/resources/tasks.ts">list</a>({ ...params }) -> TaskListResponse</code>

examples/stream-zod.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ async function main() {
2020
console.log('Creating task and starting stream...\n');
2121

2222
// Create a task and get the stream
23-
const stream = browseruse.tasks.stream({
23+
const task = await browseruse.tasks.create({
2424
task: 'Extract top 10 Hacker News posts and return the title, url, and score',
2525
structuredOutputJson: TaskOutput,
2626
});
2727

28+
const stream = browseruse.tasks.stream({
29+
taskId: task.id,
30+
schema: TaskOutput,
31+
});
32+
2833
for await (const msg of stream) {
2934
// Regular
3035
process.stdout.write(`${msg.data.status}`);

examples/stream.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ async function main() {
99
console.log('Creating task and starting stream...');
1010

1111
// Create a task and get the stream
12-
const gen = browseruse.tasks.stream({
12+
const task = await browseruse.tasks.create({
1313
task: 'What is the weather in San Francisco?',
1414
});
1515

16+
const gen = browseruse.tasks.stream(task.id);
17+
1618
for await (const msg of gen) {
1719
console.log(msg);
1820
}

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
FileView,
3838
LlmModel,
3939
TaskCreateParams,
40+
TaskCreateResponse,
4041
TaskGetLogsResponse,
4142
TaskGetOutputFileParams,
4243
TaskGetOutputFileResponse,
@@ -782,6 +783,7 @@ export declare namespace BrowserUse {
782783
type TaskStatus as TaskStatus,
783784
type TaskStepView as TaskStepView,
784785
type TaskView as TaskView,
786+
type TaskCreateResponse as TaskCreateResponse,
785787
type TaskListResponse as TaskListResponse,
786788
type TaskGetLogsResponse as TaskGetLogsResponse,
787789
type TaskGetOutputFileResponse as TaskGetOutputFileResponse,

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export {
3434
type TaskStatus,
3535
type TaskStepView,
3636
type TaskView,
37+
type TaskCreateResponse,
3738
type TaskListResponse,
3839
type TaskGetLogsResponse,
3940
type TaskGetOutputFileResponse,

src/resources/tasks.ts

Lines changed: 74 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Tasks extends APIResource {
5454
*
5555
* Returns:
5656
*
57-
* - The created task with its initial details
57+
* - The created task ID together with the task's session ID
5858
*
5959
* Raises:
6060
*
@@ -65,34 +65,71 @@ export class Tasks extends APIResource {
6565
create<T extends ZodType>(
6666
body: TaskCreateParamsWithSchema<T>,
6767
options?: RequestOptions,
68-
): APIPromise<TaskViewWithSchema<T>>;
69-
create(body: TaskCreateParams, options?: RequestOptions): APIPromise<TaskView>;
68+
): APIPromise<TaskCreateResponse>;
69+
create(body: TaskCreateParams, options?: RequestOptions): APIPromise<TaskCreateResponse>;
7070
create(
7171
body: TaskCreateParams | TaskCreateParamsWithSchema<ZodType>,
7272
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') {
73+
): APIPromise<TaskCreateResponse> {
74+
if (body.structuredOutputJson != null && typeof body.structuredOutputJson === 'object') {
7975
const schema = body.structuredOutputJson;
8076

8177
const _body: TaskCreateParams = {
8278
...body,
8379
structuredOutputJson: stringifyStructuredOutput(schema),
8480
};
8581

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 });
8983
}
9084

9185
return this._client.post('/tasks', { body, ...options });
9286
}
9387

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+
94131
private async *watch(
95-
data: TaskCreateParams,
132+
taskId: string,
96133
config: { interval: number },
97134
options?: RequestOptions,
98135
): AsyncGenerator<{ event: 'status'; data: TaskView }> {
@@ -106,14 +143,7 @@ export class Tasks extends APIResource {
106143

107144
tick.current++;
108145

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-
}
146+
const status = await this.retrieve(taskId);
117147

118148
const [newState, event] = reducer(state.current, { kind: 'status', status });
119149

@@ -132,89 +162,35 @@ export class Tasks extends APIResource {
132162
}
133163

134164
stream<T extends ZodType>(
135-
body: TaskCreateParamsWithSchema<T>,
165+
body: {
166+
taskId: string;
167+
schema: T;
168+
},
136169
options?: RequestOptions,
137170
): 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 }>;
142172
async *stream(
143-
body: TaskCreateParams | TaskCreateParamsWithSchema<ZodType>,
173+
body: string | { taskId: string; schema: ZodType },
144174
options?: RequestOptions,
145175
): AsyncGenerator<unknown> {
146176
let req: TaskCreateParams;
147177

148-
if (
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;
160179

161-
for await (const msg of this.watch(req, { interval: 500 }, options)) {
180+
for await (const msg of this.watch(taskId, { interval: 500 }, options)) {
162181
if (options?.signal?.aborted) {
163182
break;
164183
}
165184

166-
if (body.structuredOutputJson != null && typeof body.structuredOutputJson === 'object') {
167-
const parsed = parseStructuredTaskOutput<ZodType>(msg.data, body.structuredOutputJson);
185+
if (typeof body === 'object') {
186+
const parsed = parseStructuredTaskOutput<ZodType>(msg.data, body.schema);
168187
yield { event: 'status', data: parsed };
169188
} else {
170189
yield { event: 'status', data: msg.data };
171190
}
172191
}
173192
}
174193

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-
218194
/**
219195
* Control the execution of an AI agent task.
220196
*
@@ -561,6 +537,18 @@ export interface TaskView {
561537
sessionLiveUrl?: string | null;
562538
}
563539

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+
564552
/**
565553
* Response model for paginated task list requests
566554
*
@@ -711,6 +699,7 @@ export declare namespace Tasks {
711699
type TaskStatus as TaskStatus,
712700
type TaskStepView as TaskStepView,
713701
type TaskView as TaskView,
702+
type TaskCreateResponse as TaskCreateResponse,
714703
type TaskListResponse as TaskListResponse,
715704
type TaskGetLogsResponse as TaskGetLogsResponse,
716705
type TaskGetOutputFileResponse as TaskGetOutputFileResponse,

src/resources/users/me/files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class Files extends APIResource {
4545
}
4646

4747
/**
48-
* Response model for presigned upload URL
48+
* Response model for a presigned upload URL
4949
*
5050
* Attributes: url: The URL to upload the file to method: The HTTP method to use
5151
* for the upload fields: The form fields to include in the upload request

0 commit comments

Comments
 (0)