From d37ed4a2df3d7067893dae8bd18d9f60a2797670 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 17:37:32 +0000 Subject: [PATCH] SDK regeneration --- README.md | 4 +- package.json | 18 ++-- reference.md | 82 ++++++++-------- src/Client.ts | 14 +-- .../{account => accounts}/client/Client.ts | 23 ++--- .../{account => accounts}/client/index.ts | 0 .../resources/{account => accounts}/index.ts | 0 src/api/resources/files/client/Client.ts | 94 +------------------ src/api/resources/index.ts | 2 +- src/api/resources/profiles/client/Client.ts | 80 +++++++++++++++- src/api/resources/sessions/client/Client.ts | 9 +- src/api/resources/tasks/client/Client.ts | 3 +- .../client/requests/CreateTaskRequest.ts | 24 ++++- .../client/requests/UpdateTaskRequest.ts | 1 + src/api/types/AgentSettings.ts | 28 ------ src/api/types/FileView.ts | 6 +- src/api/types/SessionItemView.ts | 2 +- src/api/types/TaskCreatedResponse.ts | 4 +- src/api/types/TaskItemView.ts | 27 +++--- src/api/types/TaskLogFileResponse.ts | 4 +- src/api/types/TaskStepView.ts | 16 ++-- src/api/types/TaskUploadedFileResponse.ts | 17 ---- src/api/types/TaskView.ts | 27 +++--- .../types/UserUploadedFileNotFoundError.ts | 10 -- src/api/types/index.ts | 3 - src/environments.ts | 9 ++ src/index.ts | 5 +- src/version.ts | 3 +- .../{account.test.ts => accounts.test.ts} | 6 +- tests/wire/files.test.ts | 21 ----- tests/wire/profiles.test.ts | 10 ++ tests/wire/sessions.test.ts | 36 ------- 32 files changed, 240 insertions(+), 348 deletions(-) rename src/api/resources/{account => accounts}/client/Client.ts (85%) rename src/api/resources/{account => accounts}/client/index.ts (100%) rename src/api/resources/{account => accounts}/index.ts (100%) delete mode 100644 src/api/types/AgentSettings.ts delete mode 100644 src/api/types/TaskUploadedFileResponse.ts delete mode 100644 src/api/types/UserUploadedFileNotFoundError.ts create mode 100644 src/environments.ts rename tests/wire/{account.test.ts => accounts.test.ts} (80%) diff --git a/README.md b/README.md index dc4094c..ddfd2d9 100644 --- a/README.md +++ b/README.md @@ -363,9 +363,9 @@ A full reference for this library is available [here](https://github.com/browser Instantiate and use the client with the following: ```typescript -import { BrowserUseClient } from ""; +import { BrowserUseEnvironment, BrowserUseClient } from ""; -const client = new BrowserUseClient({ environment: "YOUR_BASE_URL", apiKey: "YOUR_API_KEY" }); +const client = new BrowserUseClient({ environment: BrowserUseEnvironment.Production, apiKey: "YOUR_API_KEY" }); await client.tasks.createTask({ task: "task", }); diff --git a/package.json b/package.json index dc9b7aa..ed77d5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "", - "version": "0.0.32", + "version": "0.0.34", "private": false, "repository": "github:browser-use/browser-use-node", "type": "commonjs", @@ -47,22 +47,22 @@ "zod": "^4" }, "devDependencies": { - "@dotenvx/dotenvx": "^1.49.0", + "webpack": "^5.97.1", + "ts-loader": "^9.5.1", + "jest": "^29.7.0", "@jest/globals": "^29.7.0", "@types/jest": "^29.5.14", - "@types/node": "^18.19.70", - "jest": "^29.7.0", + "ts-jest": "^29.3.4", "jest-environment-jsdom": "^29.7.0", "msw": "^2.8.4", + "@types/node": "^18.19.70", "prettier": "^3.4.2", + "typescript": "~5.7.2", + "@dotenvx/dotenvx": "^1.49.0", "react": "^19.1.1", "react-dom": "^19.1.1", - "ts-jest": "^29.3.4", - "ts-loader": "^9.5.1", - "ts-node": "^10.5.0", "tsconfig-paths": "^4.2.0", - "typescript": "~5.7.2", - "webpack": "^5.97.1", + "ts-node": "^10.5.0", "zod": "^4" }, "browser": { diff --git a/reference.md b/reference.md index b0c7454..fa35229 100644 --- a/reference.md +++ b/reference.md @@ -1,8 +1,8 @@ # Reference -## Account +## Accounts -
client.account.getAccountMe() -> BrowserUse.AccountView +
client.accounts.getAccountMe() -> BrowserUse.AccountView
@@ -30,7 +30,7 @@ Get authenticated account information including credit balances and account deta
```typescript -await client.account.getAccountMe(); +await client.accounts.getAccountMe(); ```
@@ -46,7 +46,7 @@ await client.account.getAccountMe();
-**requestOptions:** `Account.RequestOptions` +**requestOptions:** `Accounts.RequestOptions`
@@ -453,7 +453,7 @@ await client.sessions.listSessions();
-
client.sessions.createSession({ ...params }) -> BrowserUse.SessionView +
client.sessions.createSession({ ...params }) -> BrowserUse.SessionItemView
@@ -979,7 +979,7 @@ await client.files.userUploadFilePresignedUrl("session_id", {
-
client.files.getTaskUserUploadedFilePresignedUrl(taskId, fileId) -> BrowserUse.TaskUploadedFileResponse +
client.files.getTaskOutputFilePresignedUrl(taskId, fileId) -> BrowserUse.TaskOutputFileResponse
@@ -991,7 +991,7 @@ await client.files.userUploadFilePresignedUrl("session_id", {
-Get secure download URL for a user uploaded file used in the task. +Get secure download URL for an output file generated by the AI agent.
@@ -1007,7 +1007,7 @@ Get secure download URL for a user uploaded file used in the task.
```typescript -await client.files.getTaskUserUploadedFilePresignedUrl("task_id", "file_id"); +await client.files.getTaskOutputFilePresignedUrl("task_id", "file_id"); ```
@@ -1050,7 +1050,9 @@ await client.files.getTaskUserUploadedFilePresignedUrl("task_id", "file_id");
-
client.files.getTaskOutputFilePresignedUrl(taskId, fileId) -> BrowserUse.TaskOutputFileResponse +## Profiles + +
client.profiles.listProfiles({ ...params }) -> BrowserUse.ProfileListResponse
@@ -1062,7 +1064,7 @@ await client.files.getTaskUserUploadedFilePresignedUrl("task_id", "file_id");
-Get secure download URL for an output file generated by the AI agent. +Get paginated list of profiles.
@@ -1078,7 +1080,7 @@ Get secure download URL for an output file generated by the AI agent.
```typescript -await client.files.getTaskOutputFilePresignedUrl("task_id", "file_id"); +await client.profiles.listProfiles(); ```
@@ -1094,15 +1096,7 @@ await client.files.getTaskOutputFilePresignedUrl("task_id", "file_id");
-**taskId:** `string` - -
-
- -
-
- -**fileId:** `string` +**request:** `BrowserUse.ListProfilesProfilesGetRequest`
@@ -1110,7 +1104,7 @@ await client.files.getTaskOutputFilePresignedUrl("task_id", "file_id");
-**requestOptions:** `Files.RequestOptions` +**requestOptions:** `Profiles.RequestOptions`
@@ -1121,9 +1115,7 @@ await client.files.getTaskOutputFilePresignedUrl("task_id", "file_id");
-## Profiles - -
client.profiles.listProfiles({ ...params }) -> BrowserUse.ProfileListResponse +
client.profiles.createProfile() -> BrowserUse.ProfileView
@@ -1135,7 +1127,12 @@ await client.files.getTaskOutputFilePresignedUrl("task_id", "file_id");
-Get paginated list of profiles. +Profiles allow you to preserve the state of the browser between tasks. + +They are most commonly used to allow users to preserve the log-in state in the agent between tasks. +You'd normally create one profile per user and then use it for all their tasks. + +You can create a new profile by calling this endpoint.
@@ -1151,7 +1148,7 @@ Get paginated list of profiles.
```typescript -await client.profiles.listProfiles(); +await client.profiles.createProfile(); ```
@@ -1167,14 +1164,6 @@ await client.profiles.listProfiles();
-**request:** `BrowserUse.ListProfilesProfilesGetRequest` - -
-
- -
-
- **requestOptions:** `Profiles.RequestOptions`
@@ -1186,7 +1175,7 @@ await client.profiles.listProfiles();
-
client.profiles.createProfile() -> BrowserUse.ProfileView +
client.profiles.getProfile(profileId) -> BrowserUse.ProfileView
@@ -1198,12 +1187,7 @@ await client.profiles.listProfiles();
-Profiles allow you to preserve the state of the browser between tasks. - -They are most commonly used to allow users to preserve the log-in state in the agent between tasks. -You'd normally create one profile per user and then use it for all their tasks. - -You can create a new profile by calling this endpoint. +Get profile details.
@@ -1219,7 +1203,7 @@ You can create a new profile by calling this endpoint.
```typescript -await client.profiles.createProfile(); +await client.profiles.getProfile("profile_id"); ```
@@ -1235,6 +1219,14 @@ await client.profiles.createProfile();
+**profileId:** `string` + +
+
+ +
+
+ **requestOptions:** `Profiles.RequestOptions`
@@ -1246,7 +1238,7 @@ await client.profiles.createProfile();
-
client.profiles.getProfile(profileId) -> BrowserUse.ProfileView +
client.profiles.deleteBrowserProfile(profileId) -> void
@@ -1258,7 +1250,7 @@ await client.profiles.createProfile();
-Get profile details. +Permanently delete a browser profile and its configuration.
@@ -1274,7 +1266,7 @@ Get profile details.
```typescript -await client.profiles.getProfile("profile_id"); +await client.profiles.deleteBrowserProfile("profile_id"); ```
diff --git a/src/Client.ts b/src/Client.ts index 4fa82a4..cc13cc4 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -2,9 +2,10 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as environments from "./environments.js"; import * as core from "./core/index.js"; import { mergeHeaders } from "./core/headers.js"; -import { Account } from "./api/resources/account/client/Client.js"; +import { Accounts } from "./api/resources/accounts/client/Client.js"; import { Tasks } from "./api/resources/tasks/client/Client.js"; import { Sessions } from "./api/resources/sessions/client/Client.js"; import { Files } from "./api/resources/files/client/Client.js"; @@ -12,7 +13,7 @@ import { Profiles } from "./api/resources/profiles/client/Client.js"; export declare namespace BrowserUseClient { export interface Options { - environment: core.Supplier; + environment: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; apiKey: core.Supplier; @@ -36,7 +37,7 @@ export declare namespace BrowserUseClient { export class BrowserUseClient { protected readonly _options: BrowserUseClient.Options; - protected _account: Account | undefined; + protected _accounts: Accounts | undefined; protected _tasks: Tasks | undefined; protected _sessions: Sessions | undefined; protected _files: Files | undefined; @@ -49,8 +50,7 @@ export class BrowserUseClient { { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "", - "X-Fern-SDK-Version": "0.0.32", - + "X-Fern-SDK-Version": "0.0.34", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, }, @@ -59,8 +59,8 @@ export class BrowserUseClient { }; } - public get account(): Account { - return (this._account ??= new Account(this._options)); + public get accounts(): Accounts { + return (this._accounts ??= new Accounts(this._options)); } public get tasks(): Tasks { diff --git a/src/api/resources/account/client/Client.ts b/src/api/resources/accounts/client/Client.ts similarity index 85% rename from src/api/resources/account/client/Client.ts rename to src/api/resources/accounts/client/Client.ts index 46541cd..fb95d04 100644 --- a/src/api/resources/account/client/Client.ts +++ b/src/api/resources/accounts/client/Client.ts @@ -2,14 +2,15 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as environments from "../../../../environments.js"; import * as core from "../../../../core/index.js"; import * as BrowserUse from "../../../index.js"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; import * as errors from "../../../../errors/index.js"; -export declare namespace Account { +export declare namespace Accounts { export interface Options { - environment: core.Supplier; + environment: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; apiKey: core.Supplier; @@ -31,29 +32,29 @@ export declare namespace Account { } } -export class Account { - protected readonly _options: Account.Options; +export class Accounts { + protected readonly _options: Accounts.Options; - constructor(_options: Account.Options) { + constructor(_options: Accounts.Options) { this._options = _options; } /** * Get authenticated account information including credit balances and account details. * - * @param {Account.RequestOptions} requestOptions - Request-specific configuration. + * @param {Accounts.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link BrowserUse.NotFoundError} * * @example - * await client.account.getAccountMe() + * await client.accounts.getAccountMe() */ - public getAccountMe(requestOptions?: Account.RequestOptions): core.HttpResponsePromise { + public getAccountMe(requestOptions?: Accounts.RequestOptions): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__getAccountMe(requestOptions)); } private async __getAccountMe( - requestOptions?: Account.RequestOptions, + requestOptions?: Accounts.RequestOptions, ): Promise> { let _headers: core.Fetcher.Args["headers"] = mergeHeaders( this._options?.headers, @@ -64,7 +65,7 @@ export class Account { url: core.url.join( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)), - "account/me", + "accounts/me", ), method: "GET", headers: _headers, @@ -98,7 +99,7 @@ export class Account { rawResponse: _response.rawResponse, }); case "timeout": - throw new errors.BrowserUseTimeoutError("Timeout exceeded when calling GET /account/me."); + throw new errors.BrowserUseTimeoutError("Timeout exceeded when calling GET /accounts/me."); case "unknown": throw new errors.BrowserUseError({ message: _response.error.errorMessage, diff --git a/src/api/resources/account/client/index.ts b/src/api/resources/accounts/client/index.ts similarity index 100% rename from src/api/resources/account/client/index.ts rename to src/api/resources/accounts/client/index.ts diff --git a/src/api/resources/account/index.ts b/src/api/resources/accounts/index.ts similarity index 100% rename from src/api/resources/account/index.ts rename to src/api/resources/accounts/index.ts diff --git a/src/api/resources/files/client/Client.ts b/src/api/resources/files/client/Client.ts index 685dfc1..84f80be 100644 --- a/src/api/resources/files/client/Client.ts +++ b/src/api/resources/files/client/Client.ts @@ -2,6 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as environments from "../../../../environments.js"; import * as core from "../../../../core/index.js"; import * as BrowserUse from "../../../index.js"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; @@ -9,7 +10,7 @@ import * as errors from "../../../../errors/index.js"; export declare namespace Files { export interface Options { - environment: core.Supplier; + environment: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; apiKey: core.Supplier; @@ -46,6 +47,7 @@ export class Files { * @param {Files.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link BrowserUse.BadRequestError} + * @throws {@link BrowserUse.NotFoundError} * @throws {@link BrowserUse.UnprocessableEntityError} * @throws {@link BrowserUse.InternalServerError} * @@ -103,94 +105,6 @@ export class Files { switch (_response.error.statusCode) { case 400: throw new BrowserUse.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 422: - throw new BrowserUse.UnprocessableEntityError( - _response.error.body as unknown, - _response.rawResponse, - ); - case 500: - throw new BrowserUse.InternalServerError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.BrowserUseError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - switch (_response.error.reason) { - case "non-json": - throw new errors.BrowserUseError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - rawResponse: _response.rawResponse, - }); - case "timeout": - throw new errors.BrowserUseTimeoutError( - "Timeout exceeded when calling POST /files/sessions/{session_id}/presigned-url.", - ); - case "unknown": - throw new errors.BrowserUseError({ - message: _response.error.errorMessage, - rawResponse: _response.rawResponse, - }); - } - } - - /** - * Get secure download URL for a user uploaded file used in the task. - * - * @param {string} taskId - * @param {string} fileId - * @param {Files.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link BrowserUse.NotFoundError} - * @throws {@link BrowserUse.UnprocessableEntityError} - * @throws {@link BrowserUse.InternalServerError} - * - * @example - * await client.files.getTaskUserUploadedFilePresignedUrl("task_id", "file_id") - */ - public getTaskUserUploadedFilePresignedUrl( - taskId: string, - fileId: string, - requestOptions?: Files.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise( - this.__getTaskUserUploadedFilePresignedUrl(taskId, fileId, requestOptions), - ); - } - - private async __getTaskUserUploadedFilePresignedUrl( - taskId: string, - fileId: string, - requestOptions?: Files.RequestOptions, - ): Promise> { - let _headers: core.Fetcher.Args["headers"] = mergeHeaders( - this._options?.headers, - mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }), - requestOptions?.headers, - ); - const _response = await core.fetcher({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)), - `files/tasks/${encodeURIComponent(taskId)}/uploaded-files/${encodeURIComponent(fileId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return { data: _response.body as BrowserUse.TaskUploadedFileResponse, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { case 404: throw new BrowserUse.NotFoundError(_response.error.body as unknown, _response.rawResponse); case 422: @@ -218,7 +132,7 @@ export class Files { }); case "timeout": throw new errors.BrowserUseTimeoutError( - "Timeout exceeded when calling GET /files/tasks/{task_id}/uploaded-files/{file_id}.", + "Timeout exceeded when calling POST /files/sessions/{session_id}/presigned-url.", ); case "unknown": throw new errors.BrowserUseError({ diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 0840550..0a3507c 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -1,4 +1,4 @@ -export * as account from "./account/index.js"; +export * as accounts from "./accounts/index.js"; export * as tasks from "./tasks/index.js"; export * as sessions from "./sessions/index.js"; export * as files from "./files/index.js"; diff --git a/src/api/resources/profiles/client/Client.ts b/src/api/resources/profiles/client/Client.ts index 97fbebe..d7613c3 100644 --- a/src/api/resources/profiles/client/Client.ts +++ b/src/api/resources/profiles/client/Client.ts @@ -2,6 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as environments from "../../../../environments.js"; import * as core from "../../../../core/index.js"; import * as BrowserUse from "../../../index.js"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; @@ -9,7 +10,7 @@ import * as errors from "../../../../errors/index.js"; export declare namespace Profiles { export interface Options { - environment: core.Supplier; + environment: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; apiKey: core.Supplier; @@ -288,6 +289,83 @@ export class Profiles { } } + /** + * Permanently delete a browser profile and its configuration. + * + * @param {string} profileId + * @param {Profiles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link BrowserUse.UnprocessableEntityError} + * + * @example + * await client.profiles.deleteBrowserProfile("profile_id") + */ + public deleteBrowserProfile( + profileId: string, + requestOptions?: Profiles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteBrowserProfile(profileId, requestOptions)); + } + + private async __deleteBrowserProfile( + profileId: string, + requestOptions?: Profiles.RequestOptions, + ): Promise> { + let _headers: core.Fetcher.Args["headers"] = mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)), + `profiles/${encodeURIComponent(profileId)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 422: + throw new BrowserUse.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.BrowserUseError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.BrowserUseError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.BrowserUseTimeoutError("Timeout exceeded when calling DELETE /profiles/{profile_id}."); + case "unknown": + throw new errors.BrowserUseError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + protected async _getCustomAuthorizationHeaders() { const apiKeyValue = await core.Supplier.get(this._options.apiKey); return { "X-Browser-Use-API-Key": apiKeyValue }; diff --git a/src/api/resources/sessions/client/Client.ts b/src/api/resources/sessions/client/Client.ts index cc6c1f7..53461e3 100644 --- a/src/api/resources/sessions/client/Client.ts +++ b/src/api/resources/sessions/client/Client.ts @@ -2,6 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as environments from "../../../../environments.js"; import * as core from "../../../../core/index.js"; import * as BrowserUse from "../../../index.js"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; @@ -9,7 +10,7 @@ import * as errors from "../../../../errors/index.js"; export declare namespace Sessions { export interface Options { - environment: core.Supplier; + environment: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; apiKey: core.Supplier; @@ -144,14 +145,14 @@ export class Sessions { public createSession( request: BrowserUse.CreateSessionRequest = {}, requestOptions?: Sessions.RequestOptions, - ): core.HttpResponsePromise { + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__createSession(request, requestOptions)); } private async __createSession( request: BrowserUse.CreateSessionRequest = {}, requestOptions?: Sessions.RequestOptions, - ): Promise> { + ): Promise> { let _headers: core.Fetcher.Args["headers"] = mergeHeaders( this._options?.headers, mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }), @@ -174,7 +175,7 @@ export class Sessions { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return { data: _response.body as BrowserUse.SessionView, rawResponse: _response.rawResponse }; + return { data: _response.body as BrowserUse.SessionItemView, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { diff --git a/src/api/resources/tasks/client/Client.ts b/src/api/resources/tasks/client/Client.ts index c7d98ec..77cc8b3 100644 --- a/src/api/resources/tasks/client/Client.ts +++ b/src/api/resources/tasks/client/Client.ts @@ -2,6 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as environments from "../../../../environments.js"; import * as core from "../../../../core/index.js"; import * as BrowserUse from "../../../index.js"; import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; @@ -9,7 +10,7 @@ import * as errors from "../../../../errors/index.js"; export declare namespace Tasks { export interface Options { - environment: core.Supplier; + environment: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; apiKey: core.Supplier; diff --git a/src/api/resources/tasks/client/requests/CreateTaskRequest.ts b/src/api/resources/tasks/client/requests/CreateTaskRequest.ts index a56186b..94d42c3 100644 --- a/src/api/resources/tasks/client/requests/CreateTaskRequest.ts +++ b/src/api/resources/tasks/client/requests/CreateTaskRequest.ts @@ -11,12 +11,32 @@ import * as BrowserUse from "../../../../index.js"; * } */ export interface CreateTaskRequest { + /** The task prompt/instruction for the agent. */ task: string; - sessionId?: string; + /** The LLM model to use for the agent. */ + llm?: BrowserUse.SupportedLlMs; + /** The URL to start the task from. */ startUrl?: string; + /** Maximum number of steps the agent can take before stopping. */ + maxSteps?: number; + /** The stringified JSON schema for the structured output. */ structuredOutput?: string; + /** The ID of the session where the task will run. */ + sessionId?: string; + /** The metadata for the task. */ metadata?: Record; + /** The secrets for the task. */ secrets?: Record; + /** The allowed domains for the task. */ allowedDomains?: string[]; - agent?: BrowserUse.AgentSettings; + /** Tells the agent to highlight interactive elements on the page. */ + highlightElements?: boolean; + /** Whether agent flash mode is enabled. */ + flashMode?: boolean; + /** Whether agent thinking mode is enabled. */ + thinking?: boolean; + /** Whether agent vision capabilities are enabled. */ + vision?: boolean; + /** Optional extension to the agent system prompt. */ + systemPromptExtension?: string; } diff --git a/src/api/resources/tasks/client/requests/UpdateTaskRequest.ts b/src/api/resources/tasks/client/requests/UpdateTaskRequest.ts index 77e8085..88c6299 100644 --- a/src/api/resources/tasks/client/requests/UpdateTaskRequest.ts +++ b/src/api/resources/tasks/client/requests/UpdateTaskRequest.ts @@ -11,5 +11,6 @@ import * as BrowserUse from "../../../../index.js"; * } */ export interface UpdateTaskRequest { + /** The action to perform on the task */ action: BrowserUse.TaskUpdateAction; } diff --git a/src/api/types/AgentSettings.ts b/src/api/types/AgentSettings.ts deleted file mode 100644 index 10be668..0000000 --- a/src/api/types/AgentSettings.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as BrowserUse from "../index.js"; - -/** - * Agent settings - * - * Attributes: - * llm: The LLM model to use for the agent - * highlight_elements: Whether to highlight elements during agent interaction with the browser - * max_agent_steps: Maximum number of steps the agent can take before stopping - * - * flash_mode: Whether flash mode is enabled - * thinking: Whether thinking mode is enabled - * vision: Whether vision capabilities are enabled - * custom_system_prompt_extension: Optional custom system prompt for the agent - */ -export interface AgentSettings { - llm?: BrowserUse.SupportedLlMs; - highlightElements?: boolean; - flashMode?: boolean; - thinking?: boolean; - vision?: boolean; - maxSteps?: number; - systemPromptExtension?: string; -} diff --git a/src/api/types/FileView.ts b/src/api/types/FileView.ts index 712f9e0..f67db75 100644 --- a/src/api/types/FileView.ts +++ b/src/api/types/FileView.ts @@ -4,12 +4,10 @@ /** * View model for representing an output file generated by the agent - * - * Attributes: - * id: Unique identifier for the output file - * file_name: Name of the output file */ export interface FileView { + /** Unique identifier for the output file */ id: string; + /** Name of the output file */ fileName: string; } diff --git a/src/api/types/SessionItemView.ts b/src/api/types/SessionItemView.ts index 16710be..11c786c 100644 --- a/src/api/types/SessionItemView.ts +++ b/src/api/types/SessionItemView.ts @@ -5,7 +5,7 @@ import * as BrowserUse from "../index.js"; /** - * View model for representing a (browser) session with its associated tasks. + * View model for representing a (browser) session. * * Attributes: * id: Unique identifier for the session. diff --git a/src/api/types/TaskCreatedResponse.ts b/src/api/types/TaskCreatedResponse.ts index 0d2f150..9236cca 100644 --- a/src/api/types/TaskCreatedResponse.ts +++ b/src/api/types/TaskCreatedResponse.ts @@ -4,10 +4,8 @@ /** * Response model for creating a task - * - * Attributes: - * id: Unique identifier for the created task */ export interface TaskCreatedResponse { + /** Unique identifier for the created task */ id: string; } diff --git a/src/api/types/TaskItemView.ts b/src/api/types/TaskItemView.ts index 9e8efed..2082244 100644 --- a/src/api/types/TaskItemView.ts +++ b/src/api/types/TaskItemView.ts @@ -6,34 +6,29 @@ import * as BrowserUse from "../index.js"; /** * View model for representing a task with its execution details - * - * Attributes: - * id: Unique identifier for the task - * session_id: ID of the session this task belongs to - * llm: The LLM model used for this task represented as a string - * task: The task prompt/instruction given to the agent - * status: Current status of the task execution - * started_at: Naive UTC timestamp when the task was started - * finished_at: Naive UTC timestamp when the task completed (None if still running) - * metadata: Optional additional metadata associated with the task set by the user - * is_scheduled: Whether this task was created as a scheduled task - * steps: Optional list of execution steps - * output: Final output/result of the task - * output_files: Optional list of files generated as output by this task - * browser_use_version: Version of browser-use used for this task (older tasks may not have this set) - * is_success: Whether the task was successful (self-reported by the agent) */ export interface TaskItemView { + /** Unique identifier for the task */ id: string; + /** ID of the session this task belongs to */ sessionId: string; + /** The LLM model used for this task represented as a string */ llm: string; + /** The task prompt/instruction given to the agent */ task: string; status: BrowserUse.TaskStatus; + /** Naive UTC timestamp when the task was started */ startedAt: string; + /** Naive UTC timestamp when the task completed (None if still running) */ finishedAt?: string; + /** Optional additional metadata associated with the task set by the user */ metadata?: Record; + /** Whether this task was created as a scheduled task */ isScheduled: boolean; + /** Final output/result of the task */ output?: string; + /** Version of browser-use used for this task (older tasks may not have this set) */ browserUseVersion?: string; + /** Whether the task was successful (self-reported by the agent) */ isSuccess?: boolean; } diff --git a/src/api/types/TaskLogFileResponse.ts b/src/api/types/TaskLogFileResponse.ts index 8ace8cd..13a3cf6 100644 --- a/src/api/types/TaskLogFileResponse.ts +++ b/src/api/types/TaskLogFileResponse.ts @@ -4,10 +4,8 @@ /** * Response model for log file requests - * - * Attributes: - * download_url: URL to download the log file */ export interface TaskLogFileResponse { + /** URL to download the log file */ downloadUrl: string; } diff --git a/src/api/types/TaskStepView.ts b/src/api/types/TaskStepView.ts index ede904e..2eb78bf 100644 --- a/src/api/types/TaskStepView.ts +++ b/src/api/types/TaskStepView.ts @@ -4,22 +4,20 @@ /** * View model for representing a single step in a task's execution - * - * Attributes: - * number: Sequential step number within the task - * memory: Agent's memory at this step - * evaluation_previous_goal: Agent's evaluation of the previous goal completion - * next_goal: The goal for the next step - * url: Current URL the browser is on for this step - * screenshot_url: Optional URL to the screenshot taken at this step - * actions: List of stringified json actions performed by the agent in this step */ export interface TaskStepView { + /** Sequential step number within the task */ number: number; + /** Agent's memory at this step */ memory: string; + /** Agent's evaluation of the previous goal completion */ evaluationPreviousGoal: string; + /** The goal for the next step */ nextGoal: string; + /** Current URL the browser is on for this step */ url: string; + /** Optional URL to the screenshot taken at this step */ screenshotUrl?: string; + /** List of stringified json actions performed by the agent in this step */ actions: string[]; } diff --git a/src/api/types/TaskUploadedFileResponse.ts b/src/api/types/TaskUploadedFileResponse.ts deleted file mode 100644 index 49a84f3..0000000 --- a/src/api/types/TaskUploadedFileResponse.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * Response model for user uploaded file requests - * - * Attributes: - * id: Unique identifier for the user uploaded file - * file_name: Name of the user uploaded file - * download_url: URL to download the user uploaded file - */ -export interface TaskUploadedFileResponse { - id: string; - fileName: string; - downloadUrl: string; -} diff --git a/src/api/types/TaskView.ts b/src/api/types/TaskView.ts index 1520ddd..b87f53e 100644 --- a/src/api/types/TaskView.ts +++ b/src/api/types/TaskView.ts @@ -6,36 +6,31 @@ import * as BrowserUse from "../index.js"; /** * View model for representing a task with its execution details - * - * Attributes: - * id: Unique identifier for the task - * session_id: ID of the session this task belongs to - * llm: The LLM model used for this task represented as a string - * task: The task prompt/instruction given to the agent - * status: Current status of the task execution - * started_at: Naive UTC timestamp when the task was started - * finished_at: Naive UTC timestamp when the task completed (None if still running) - * metadata: Optional additional metadata associated with the task set by the user - * is_scheduled: Whether this task was created as a scheduled task - * steps: List of execution steps - * output: Final output/result of the task - * output_files: List of files generated as output by this task - * browser_use_version: Version of browser-use used for this task (older tasks may not have this set) - * is_success: Whether the task was successful (self-reported by the agent) */ export interface TaskView { + /** Unique identifier for the task */ id: string; sessionId: string; + /** The LLM model used for this task represented as a string */ llm: string; + /** The task prompt/instruction given to the agent */ task: string; + /** Current status of the task execution */ status: BrowserUse.TaskStatus; + /** Naive UTC timestamp when the task was started */ startedAt: string; + /** Naive UTC timestamp when the task completed (None if still running) */ finishedAt?: string; + /** Optional additional metadata associated with the task set by the user */ metadata?: Record; + /** Whether this task was created as a scheduled task */ isScheduled: boolean; steps: BrowserUse.TaskStepView[]; + /** Final output/result of the task */ output?: string; outputFiles: BrowserUse.FileView[]; + /** Version of browser-use used for this task (older tasks may not have this set) */ browserUseVersion?: string; + /** Whether the task was successful (self-reported by the agent) */ isSuccess?: boolean; } diff --git a/src/api/types/UserUploadedFileNotFoundError.ts b/src/api/types/UserUploadedFileNotFoundError.ts deleted file mode 100644 index eaf9b13..0000000 --- a/src/api/types/UserUploadedFileNotFoundError.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * Error response when a file is not found - */ -export interface UserUploadedFileNotFoundError { - detail?: string; -} diff --git a/src/api/types/index.ts b/src/api/types/index.ts index bd7d3f6..2ed2249 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -2,7 +2,6 @@ export * from "./BadRequestErrorBody.js"; export * from "./NotFoundErrorBody.js"; export * from "./AccountNotFoundError.js"; export * from "./AccountView.js"; -export * from "./AgentSettings.js"; export * from "./CreditsDeductionError.js"; export * from "./DownloadUrlGenerationError.js"; export * from "./FileView.js"; @@ -35,9 +34,7 @@ export * from "./TaskOutputFileResponse.js"; export * from "./TaskStatus.js"; export * from "./TaskStepView.js"; export * from "./TaskUpdateAction.js"; -export * from "./TaskUploadedFileResponse.js"; export * from "./TaskView.js"; export * from "./UnsupportedContentTypeError.js"; export * from "./UploadFilePresignedUrlResponse.js"; -export * from "./UserUploadedFileNotFoundError.js"; export * from "./ValidationError.js"; diff --git a/src/environments.ts b/src/environments.ts new file mode 100644 index 0000000..6f299a4 --- /dev/null +++ b/src/environments.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export const BrowserUseEnvironment = { + Production: "https://api.browser-use.com/api/v2", +} as const; + +export type BrowserUseEnvironment = typeof BrowserUseEnvironment.Production; diff --git a/src/index.ts b/src/index.ts index acc4581..72f356a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ export * as BrowserUse from "./api/index.js"; export { BrowserUseError, BrowserUseTimeoutError } from "./errors/index.js"; -export { BrowserUseClient } from "./wrapper/BrowserUseClient.js"; -export type { WrappedTaskFnsWithoutSchema } from "./wrapper/lib/parse.js"; -export type { WrappedTaskFnsWithSchema } from "./wrapper/lib/parse.js"; +export { BrowserUseClient } from "./Client.js"; +export { BrowserUseEnvironment } from "./environments.js"; diff --git a/src/version.ts b/src/version.ts index 528d21e..19e8a0b 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1 @@ -export const SDK_VERSION = "0.0.32"; - +export const SDK_VERSION = "0.0.34"; diff --git a/tests/wire/account.test.ts b/tests/wire/accounts.test.ts similarity index 80% rename from tests/wire/account.test.ts rename to tests/wire/accounts.test.ts index 71ab9fe..54715d8 100644 --- a/tests/wire/account.test.ts +++ b/tests/wire/accounts.test.ts @@ -5,7 +5,7 @@ import { mockServerPool } from "../mock-server/MockServerPool"; import { BrowserUseClient } from "../../src/Client"; -describe("Account", () => { +describe("Accounts", () => { test("getAccountMe", async () => { const server = mockServerPool.createServer(); const client = new BrowserUseClient({ apiKey: "test", environment: server.baseUrl }); @@ -17,9 +17,9 @@ describe("Account", () => { name: "name", signedUpAt: "2024-01-15T09:30:00Z", }; - server.mockEndpoint().get("/account/me").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + server.mockEndpoint().get("/accounts/me").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - const response = await client.account.getAccountMe(); + const response = await client.accounts.getAccountMe(); expect(response).toEqual({ monthlyCreditsBalanceUsd: 1.1, additionalCreditsBalanceUsd: 1.1, diff --git a/tests/wire/files.test.ts b/tests/wire/files.test.ts index 620008b..881723c 100644 --- a/tests/wire/files.test.ts +++ b/tests/wire/files.test.ts @@ -42,27 +42,6 @@ describe("Files", () => { }); }); - test("getTaskUserUploadedFilePresignedUrl", async () => { - const server = mockServerPool.createServer(); - const client = new BrowserUseClient({ apiKey: "test", environment: server.baseUrl }); - - const rawResponseBody = { id: "id", fileName: "fileName", downloadUrl: "downloadUrl" }; - server - .mockEndpoint() - .get("/files/tasks/task_id/uploaded-files/file_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.files.getTaskUserUploadedFilePresignedUrl("task_id", "file_id"); - expect(response).toEqual({ - id: "id", - fileName: "fileName", - downloadUrl: "downloadUrl", - }); - }); - test("getTaskOutputFilePresignedUrl", async () => { const server = mockServerPool.createServer(); const client = new BrowserUseClient({ apiKey: "test", environment: server.baseUrl }); diff --git a/tests/wire/profiles.test.ts b/tests/wire/profiles.test.ts index 446bdcd..32334c9 100644 --- a/tests/wire/profiles.test.ts +++ b/tests/wire/profiles.test.ts @@ -88,4 +88,14 @@ describe("Profiles", () => { updatedAt: "2024-01-15T09:30:00Z", }); }); + + test("deleteBrowserProfile", async () => { + const server = mockServerPool.createServer(); + const client = new BrowserUseClient({ apiKey: "test", environment: server.baseUrl }); + + server.mockEndpoint().delete("/profiles/profile_id").respondWith().statusCode(200).build(); + + const response = await client.profiles.deleteBrowserProfile("profile_id"); + expect(response).toEqual(undefined); + }); }); diff --git a/tests/wire/sessions.test.ts b/tests/wire/sessions.test.ts index 39e8d94..89618a7 100644 --- a/tests/wire/sessions.test.ts +++ b/tests/wire/sessions.test.ts @@ -53,23 +53,6 @@ describe("Sessions", () => { liveUrl: "liveUrl", startedAt: "2024-01-15T09:30:00Z", finishedAt: "2024-01-15T09:30:00Z", - tasks: [ - { - id: "id", - sessionId: "sessionId", - llm: "llm", - task: "task", - status: "started", - startedAt: "2024-01-15T09:30:00Z", - finishedAt: "2024-01-15T09:30:00Z", - metadata: { key: "value" }, - isScheduled: true, - output: "output", - browserUseVersion: "browserUseVersion", - isSuccess: true, - }, - ], - publicShareUrl: "publicShareUrl", }; server .mockEndpoint() @@ -87,25 +70,6 @@ describe("Sessions", () => { liveUrl: "liveUrl", startedAt: "2024-01-15T09:30:00Z", finishedAt: "2024-01-15T09:30:00Z", - tasks: [ - { - id: "id", - sessionId: "sessionId", - llm: "llm", - task: "task", - status: "started", - startedAt: "2024-01-15T09:30:00Z", - finishedAt: "2024-01-15T09:30:00Z", - metadata: { - key: "value", - }, - isScheduled: true, - output: "output", - browserUseVersion: "browserUseVersion", - isSuccess: true, - }, - ], - publicShareUrl: "publicShareUrl", }); });