From 16f3e7f6a43c5f29c81543624ca56cfd72b8e0cf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 19:49:44 +0000 Subject: [PATCH 1/2] feat: Fix Stainless GitHub Action --- .stats.yml | 4 +- api.md | 3 +- examples/stream-zod.ts | 7 +- examples/stream.ts | 4 +- src/client.ts | 2 + src/resources/index.ts | 1 + src/resources/tasks.ts | 159 +++++++++++++++----------------- src/resources/users/me/files.ts | 2 +- 8 files changed, 91 insertions(+), 91 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1c0836f..4189f1a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 26 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-9ff5409663c58ae9e3ecc9ac764956189e3a70600f5ba1b961bb1dedf0208271.yml -openapi_spec_hash: 9865acb75430d9b799502acbae860df0 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-d20f308ac3a63b1ea5749dac763fd846481c9723156a5653c1d03669e73d5b5e.yml +openapi_spec_hash: ccf5babfe92a776213a3e5097a7cd546 config_hash: 9d52be5177b2ede4cb0633c04f4cc4ef diff --git a/api.md b/api.md index 1ee6ece..8f782ff 100644 --- a/api.md +++ b/api.md @@ -30,6 +30,7 @@ Types: - TaskStatus - TaskStepView - TaskView +- TaskCreateResponse - TaskListResponse - TaskGetLogsResponse - TaskGetOutputFileResponse @@ -37,7 +38,7 @@ Types: Methods: -- client.tasks.create({ ...params }) -> TaskView +- client.tasks.create({ ...params }) -> TaskCreateResponse - client.tasks.retrieve(taskID) -> TaskView - client.tasks.update(taskID, { ...params }) -> TaskView - client.tasks.list({ ...params }) -> TaskListResponse diff --git a/examples/stream-zod.ts b/examples/stream-zod.ts index 9867523..6c2ac21 100755 --- a/examples/stream-zod.ts +++ b/examples/stream-zod.ts @@ -20,11 +20,16 @@ async function main() { console.log('Creating task and starting stream...\n'); // Create a task and get the stream - const stream = browseruse.tasks.stream({ + const task = await browseruse.tasks.create({ task: 'Extract top 10 Hacker News posts and return the title, url, and score', structuredOutputJson: TaskOutput, }); + const stream = browseruse.tasks.stream({ + taskId: task.id, + schema: TaskOutput, + }); + for await (const msg of stream) { // Regular process.stdout.write(`${msg.data.status}`); diff --git a/examples/stream.ts b/examples/stream.ts index 6c38fad..05fcf94 100755 --- a/examples/stream.ts +++ b/examples/stream.ts @@ -9,10 +9,12 @@ async function main() { console.log('Creating task and starting stream...'); // Create a task and get the stream - const gen = browseruse.tasks.stream({ + const task = await browseruse.tasks.create({ task: 'What is the weather in San Francisco?', }); + const gen = browseruse.tasks.stream(task.id); + for await (const msg of gen) { console.log(msg); } diff --git a/src/client.ts b/src/client.ts index 46030f1..9e20f56 100644 --- a/src/client.ts +++ b/src/client.ts @@ -37,6 +37,7 @@ import { FileView, LlmModel, TaskCreateParams, + TaskCreateResponse, TaskGetLogsResponse, TaskGetOutputFileParams, TaskGetOutputFileResponse, @@ -782,6 +783,7 @@ export declare namespace BrowserUse { type TaskStatus as TaskStatus, type TaskStepView as TaskStepView, type TaskView as TaskView, + type TaskCreateResponse as TaskCreateResponse, type TaskListResponse as TaskListResponse, type TaskGetLogsResponse as TaskGetLogsResponse, type TaskGetOutputFileResponse as TaskGetOutputFileResponse, diff --git a/src/resources/index.ts b/src/resources/index.ts index d71e576..a43d293 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -34,6 +34,7 @@ export { type TaskStatus, type TaskStepView, type TaskView, + type TaskCreateResponse, type TaskListResponse, type TaskGetLogsResponse, type TaskGetOutputFileResponse, diff --git a/src/resources/tasks.ts b/src/resources/tasks.ts index 9b3e6ea..61983e8 100644 --- a/src/resources/tasks.ts +++ b/src/resources/tasks.ts @@ -54,7 +54,7 @@ export class Tasks extends APIResource { * * Returns: * - * - The created task with its initial details + * - The created task ID together with the task's session ID * * Raises: * @@ -65,17 +65,13 @@ export class Tasks extends APIResource { create( body: TaskCreateParamsWithSchema, options?: RequestOptions, - ): APIPromise>; - create(body: TaskCreateParams, options?: RequestOptions): APIPromise; + ): APIPromise; + create(body: TaskCreateParams, options?: RequestOptions): APIPromise; create( body: TaskCreateParams | TaskCreateParamsWithSchema, options?: RequestOptions, - ): APIPromise { - if (body.structuredOutputJson == null || typeof body.structuredOutputJson === 'string') { - return this._client.post('/tasks', { body, ...options }); - } - - if (typeof body.structuredOutputJson === 'object') { + ): APIPromise { + if (body.structuredOutputJson != null && typeof body.structuredOutputJson === 'object') { const schema = body.structuredOutputJson; const _body: TaskCreateParams = { @@ -83,16 +79,57 @@ export class Tasks extends APIResource { structuredOutputJson: stringifyStructuredOutput(schema), }; - return this._client - .post('/tasks', { body: _body, ...options }) - ._thenUnwrap((rsp) => parseStructuredTaskOutput(rsp as TaskView, schema)); + return this._client.post('/tasks', { body: _body, ...options }); } return this._client.post('/tasks', { body, ...options }); } + /** + * Get detailed information about a specific AI agent task. + * + * Retrieves comprehensive information about a task, including its current status, + * progress, and detailed execution data. You can choose to get just the status + * (for quick polling) or full details including steps and file information. + * + * Use this endpoint to: + * + * - Monitor task progress in real-time + * - Review completed task results + * - Debug failed tasks by examining steps + * - Download output files and logs + * + * Args: + * + * - task_id: The unique identifier of the agent task + * + * Returns: + * + * - Complete task information + * + * Raises: + * + * - 404: If the user agent task doesn't exist + */ + retrieve( + req: { taskId: string; schema: T }, + options?: RequestOptions, + ): APIPromise>; + retrieve(taskID: string, options?: RequestOptions): APIPromise; + retrieve(req: string | { taskId: string; schema: ZodType }, options?: RequestOptions): APIPromise { + if (typeof req === 'string') { + return this._client.get(path`/tasks/${req}`, options); + } + + const { taskId, schema } = req; + + return this._client + .get(path`/tasks/${taskId}`, options) + ._thenUnwrap((rsp) => parseStructuredTaskOutput(rsp as TaskView, schema)); + } + private async *watch( - data: TaskCreateParams, + taskId: string, config: { interval: number }, options?: RequestOptions, ): AsyncGenerator<{ event: 'status'; data: TaskView }> { @@ -106,14 +143,7 @@ export class Tasks extends APIResource { tick.current++; - let status: TaskView; - - // NOTE: We take action on each tick. - if (state.current == null) { - status = await this.create(data, options); - } else { - status = await this.retrieve(state.current.taskId); - } + const status = await this.retrieve(taskId); const [newState, event] = reducer(state.current, { kind: 'status', status }); @@ -132,39 +162,28 @@ export class Tasks extends APIResource { } stream( - body: TaskCreateParamsWithSchema, + body: { + taskId: string; + schema: T; + }, options?: RequestOptions, ): AsyncGenerator<{ event: 'status'; data: TaskViewWithSchema }>; - stream( - body: TaskCreateParams, - options?: RequestOptions, - ): AsyncGenerator<{ event: 'status'; data: TaskView }>; + stream(taskId: string, options?: RequestOptions): AsyncGenerator<{ event: 'status'; data: TaskView }>; async *stream( - body: TaskCreateParams | TaskCreateParamsWithSchema, + body: string | { taskId: string; schema: ZodType }, options?: RequestOptions, ): AsyncGenerator { let req: TaskCreateParams; - if ( - 'structuredOutputJson' in body && - body.structuredOutputJson != null && - typeof body.structuredOutputJson === 'object' - ) { - req = { - ...body, - structuredOutputJson: stringifyStructuredOutput(body.structuredOutputJson), - }; - } else { - req = body as TaskCreateParams; - } + const taskId = typeof body === 'object' ? body.taskId : body; - for await (const msg of this.watch(req, { interval: 500 }, options)) { + for await (const msg of this.watch(taskId, { interval: 500 }, options)) { if (options?.signal?.aborted) { break; } - if (body.structuredOutputJson != null && typeof body.structuredOutputJson === 'object') { - const parsed = parseStructuredTaskOutput(msg.data, body.structuredOutputJson); + if (typeof body === 'object') { + const parsed = parseStructuredTaskOutput(msg.data, body.schema); yield { event: 'status', data: parsed }; } else { yield { event: 'status', data: msg.data }; @@ -172,49 +191,6 @@ export class Tasks extends APIResource { } } - /** - * Get detailed information about a specific AI agent task. - * - * Retrieves comprehensive information about a task, including its current status, - * progress, and detailed execution data. You can choose to get just the status - * (for quick polling) or full details including steps and file information. - * - * Use this endpoint to: - * - * - Monitor task progress in real-time - * - Review completed task results - * - Debug failed tasks by examining steps - * - Download output files and logs - * - * Args: - * - * - task_id: The unique identifier of the agent task - * - * Returns: - * - * - Complete task information - * - * Raises: - * - * - 404: If the user agent task doesn't exist - */ - retrieve( - req: { taskId: string; schema: T }, - options?: RequestOptions, - ): APIPromise>; - retrieve(taskID: string, options?: RequestOptions): APIPromise; - retrieve(req: string | { taskId: string; schema: ZodType }, options?: RequestOptions): APIPromise { - if (typeof req === 'string') { - return this._client.get(path`/tasks/${req}`, options); - } - - const { taskId, schema } = req; - - return this._client - .get(path`/tasks/${taskId}`, options) - ._thenUnwrap((rsp) => parseStructuredTaskOutput(rsp as TaskView, schema)); - } - /** * Control the execution of an AI agent task. * @@ -561,6 +537,18 @@ export interface TaskView { sessionLiveUrl?: string | null; } +/** + * Response model for creating a task + * + * Attributes: task_id: An unique identifier for the created task session_id: The + * ID of the session this task belongs to + */ +export interface TaskCreateResponse { + id: string; + + sessionId: string; +} + /** * Response model for paginated task list requests * @@ -711,6 +699,7 @@ export declare namespace Tasks { type TaskStatus as TaskStatus, type TaskStepView as TaskStepView, type TaskView as TaskView, + type TaskCreateResponse as TaskCreateResponse, type TaskListResponse as TaskListResponse, type TaskGetLogsResponse as TaskGetLogsResponse, type TaskGetOutputFileResponse as TaskGetOutputFileResponse, diff --git a/src/resources/users/me/files.ts b/src/resources/users/me/files.ts index bc7a119..cda7bb2 100644 --- a/src/resources/users/me/files.ts +++ b/src/resources/users/me/files.ts @@ -45,7 +45,7 @@ export class Files extends APIResource { } /** - * Response model for presigned upload URL + * Response model for a presigned upload URL * * Attributes: url: The URL to upload the file to method: The HTTP method to use * for the upload fields: The form fields to include in the upload request From 7ab027365a15d69ace6db234645ce941bfddce3c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 19:50:01 +0000 Subject: [PATCH 2/2] release: 0.3.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 949ce4c..0ee8c01 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.2" + ".": "0.3.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c42cd3..40769e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.3.0 (2025-08-15) + +Full Changelog: [v0.2.2...v0.3.0](https://github.com/browser-use/browser-use-node/compare/v0.2.2...v0.3.0) + +### Features + +* Fix Stainless GitHub Action ([16f3e7f](https://github.com/browser-use/browser-use-node/commit/16f3e7f6a43c5f29c81543624ca56cfd72b8e0cf)) + ## 0.2.2 (2025-08-15) Full Changelog: [v0.2.1...v0.2.2](https://github.com/browser-use/browser-use-node/compare/v0.2.1...v0.2.2) diff --git a/package.json b/package.json index 0ab2c91..d22676e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browser-use-sdk", - "version": "0.2.2", + "version": "0.3.0", "description": "The official TypeScript library for the Browser Use API", "author": "Browser Use ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index bf2543c..88f4d40 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.2.2'; // x-release-please-version +export const VERSION = '0.3.0'; // x-release-please-version