Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.3.0"
".": "0.4.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 26
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-d20f308ac3a63b1ea5749dac763fd846481c9723156a5653c1d03669e73d5b5e.yml
openapi_spec_hash: ccf5babfe92a776213a3e5097a7cd546
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-758a1c052b93e7e478fa650c1748f4b466653f44cb26f97fef1314c7a96924df.yml
openapi_spec_hash: 9e0e99b613f2b9bf3993ac36aa0c7911
config_hash: 9d52be5177b2ede4cb0633c04f4cc4ef
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.4.0 (2025-08-17)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/browser-use/browser-use-node/compare/v0.3.0...v0.4.0)

### Features

* Update param and response views ([68615f4](https://github.com/browser-use/browser-use-node/commit/68615f4851b05203a78520c34409ad4c8f043cc4))


### Chores

* **deps:** update dependency @types/node to v20.17.58 ([42c532e](https://github.com/browser-use/browser-use-node/commit/42c532ede1ba630159e410ebf3c8cc8a73721242))
* **internal:** formatting change ([e09c835](https://github.com/browser-use/browser-use-node/commit/e09c8357715abca8d1e095316a7f43d171a3a0f9))

## 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)
Expand Down
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Types:

Methods:

- <code title="get /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">retrieve</a>(sessionID, { ...params }) -> SessionView</code>
- <code title="get /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">retrieve</a>(sessionID) -> SessionView</code>
- <code title="patch /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">update</a>(sessionID, { ...params }) -> SessionView</code>
- <code title="get /sessions">client.sessions.<a href="./src/resources/sessions/sessions.ts">list</a>({ ...params }) -> SessionListResponse</code>
- <code title="delete /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">delete</a>(sessionID) -> void</code>
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function main() {
case 'started':
case 'paused':
case 'stopped':
log = `agent ${status.status} - live: ${status.sessionLiveUrl}`;
log = `agent ${status.status} - live: ${status.session.liveUrl}`;

await new Promise((resolve) => setTimeout(resolve, 2000));
break;
Expand Down
4 changes: 2 additions & 2 deletions examples/stream-zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ async function main() {
for await (const msg of stream) {
// Regular
process.stdout.write(`${msg.data.status}`);
if (msg.data.sessionLiveUrl) {
process.stdout.write(` | Live URL: ${msg.data.sessionLiveUrl}`);
if (msg.data.session.liveUrl) {
process.stdout.write(` | Live URL: ${msg.data.session.liveUrl}`);
}

if (msg.data.steps.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion examples/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function main() {
const steps = `${stepsCount} steps`;
const lastGoalDescription = stepsCount > 0 ? status.steps![stepsCount - 1]!.nextGoal : undefined;
const lastGoal = lastGoalDescription ? `, last: ${lastGoalDescription}` : '';
const liveUrl = status.sessionLiveUrl ? `, live: ${status.sessionLiveUrl}` : '';
const liveUrl = status.session.liveUrl ? `, live: ${status.session.liveUrl}` : '';

log = `agent ${status.status} (${steps}${lastGoal}${liveUrl}) `;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browser-use-sdk",
"version": "0.3.0",
"version": "0.4.0",
"description": "The official TypeScript library for the Browser Use API",
"author": "Browser Use <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import {
import {
SessionListParams,
SessionListResponse,
SessionRetrieveParams,
SessionStatus,
SessionUpdateParams,
SessionView,
Expand Down Expand Up @@ -765,11 +764,13 @@ export class BrowserUse {
browserProfiles: API.BrowserProfiles = new API.BrowserProfiles(this);
agentProfiles: API.AgentProfiles = new API.AgentProfiles(this);
}

BrowserUse.Users = Users;
BrowserUse.Tasks = Tasks;
BrowserUse.Sessions = Sessions;
BrowserUse.BrowserProfiles = BrowserProfiles;
BrowserUse.AgentProfiles = AgentProfiles;

export declare namespace BrowserUse {
export type RequestOptions = Opts.RequestOptions;

Expand Down Expand Up @@ -800,7 +801,6 @@ export declare namespace BrowserUse {
type SessionStatus as SessionStatus,
type SessionView as SessionView,
type SessionListResponse as SessionListResponse,
type SessionRetrieveParams as SessionRetrieveParams,
type SessionUpdateParams as SessionUpdateParams,
type SessionListParams as SessionListParams,
};
Expand Down
2 changes: 1 addition & 1 deletion src/internal/detect-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const getPlatformProperties = (): PlatformProperties => {
'X-Stainless-Arch': normalizeArch(Deno.build.arch),
'X-Stainless-Runtime': 'deno',
'X-Stainless-Runtime-Version':
typeof Deno.version === 'string' ? Deno.version : Deno.version?.deno ?? 'unknown',
typeof Deno.version === 'string' ? Deno.version : (Deno.version?.deno ?? 'unknown'),
};
}
if (typeof EdgeRuntime !== 'undefined') {
Expand Down
7 changes: 1 addition & 6 deletions src/lib/bin/commands/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ export const listen = new Command('listen')

const tasks: BrowserUse.Tasks.TaskItemView[] = await client.tasks
.list(
{
includeOutputFiles: false,
includeSteps: false,
includeUserUploadedFiles: false,
pageSize: 10,
},
{ pageSize: 10 },
{
signal: tickRef.abort.signal,
},
Expand Down
9 changes: 6 additions & 3 deletions src/lib/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta
// INIT

if (state == null) {
const liveUrl = action.status.sessionLiveUrl ?? null;
const liveUrl = action.status.session.liveUrl ?? null;
const doneOutput = action.status.doneOutput ?? null;

const state: BrowserState = {
Expand All @@ -39,7 +39,7 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta

// UPDATE

const liveUrl = action.status.sessionLiveUrl ?? state.liveUrl;
const liveUrl = action.status.session.liveUrl ?? state.liveUrl;
const doneOutput = action.status.doneOutput ?? state.doneOutput;

const steps: TaskStepView[] = [...state.steps];
Expand Down Expand Up @@ -68,7 +68,10 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta
const update: ReducerEvent = {
...action.status,
steps: newState.steps,
sessionLiveUrl: newState.liveUrl,
session: {
...action.status.session,
liveUrl: newState.liveUrl,
},
doneOutput: newState.doneOutput,
};

Expand Down
1 change: 0 additions & 1 deletion src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export {
type SessionStatus,
type SessionView,
type SessionListResponse,
type SessionRetrieveParams,
type SessionUpdateParams,
type SessionListParams,
} from './sessions/sessions';
Expand Down
1 change: 0 additions & 1 deletion src/resources/sessions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export {
type SessionStatus,
type SessionView,
type SessionListResponse,
type SessionRetrieveParams,
type SessionUpdateParams,
type SessionListParams,
} from './sessions';
18 changes: 2 additions & 16 deletions src/resources/sessions/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ export class Sessions extends APIResource {
*
* - 404: If the user agent session doesn't exist
*/
retrieve(
sessionID: string,
query: SessionRetrieveParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<SessionView> {
return this._client.get(path`/sessions/${sessionID}`, { query, ...options });
retrieve(sessionID: string, options?: RequestOptions): APIPromise<SessionView> {
return this._client.get(path`/sessions/${sessionID}`, options);
}

/**
Expand Down Expand Up @@ -185,7 +181,6 @@ export namespace SessionListResponse {
* session (active/stopped). live_url: URL where the browser can be viewed live in
* real-time. started_at: Timestamp when the session was created and started.
* finished_at: Timestamp when the session was stopped (None if still active).
* tasks: Optional list of tasks associated with this session.
*/
export interface Item {
id: string;
Expand All @@ -203,15 +198,9 @@ export namespace SessionListResponse {
finishedAt?: string | null;

liveUrl?: string | null;

tasks?: Array<TasksAPI.TaskItemView> | null;
}
}

export interface SessionRetrieveParams {
includeTasks?: boolean;
}

export interface SessionUpdateParams {
/**
* Available actions that can be performed on a session
Expand All @@ -231,8 +220,6 @@ export interface SessionListParams {
*/
filterBy?: SessionStatus | null;

includeTasks?: boolean;

pageNumber?: number;

pageSize?: number;
Expand All @@ -245,7 +232,6 @@ export declare namespace Sessions {
type SessionStatus as SessionStatus,
type SessionView as SessionView,
type SessionListResponse as SessionListResponse,
type SessionRetrieveParams as SessionRetrieveParams,
type SessionUpdateParams as SessionUpdateParams,
type SessionListParams as SessionListParams,
};
Expand Down
100 changes: 66 additions & 34 deletions src/resources/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,18 @@ export type LlmModel =
* 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 session_live_url: Optional live URL of the session llm: The
* LLM model used for this task 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 done_output:
* Final output/result of the task user_uploaded_files: Optional list of files
* uploaded by user for this 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)
* this task belongs to llm: The LLM model used for this task 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 done_output: Final output/result of the task
* user_uploaded_files: Optional list of files uploaded by user for this 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 {
id: string;
Expand Down Expand Up @@ -434,14 +434,6 @@ export interface TaskItemView {
isSuccess?: boolean | null;

metadata?: { [key: string]: unknown };

outputFiles?: Array<FileView> | null;

sessionLiveUrl?: string | null;

steps?: Array<TaskStepView> | null;

userUploadedFiles?: Array<FileView> | null;
}

/**
Expand Down Expand Up @@ -483,11 +475,11 @@ export interface TaskStepView {
* 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 session_live_url: Optional live URL of the session llm: The
* LLM model used for this task 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
* this task belongs to session: The session this task belongs to llm: The LLM
* model used for this task 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 done_output: Final
* output/result of the task user_uploaded_files: List of files uploaded by user
Expand All @@ -505,6 +497,16 @@ export interface TaskView {

outputFiles: Array<FileView>;

/**
* View model for representing a session that a task belongs to
*
* Attributes: id: Unique identifier for the session status: Current status of the
* session live_url: URL where the browser can be viewed live in real-time.
* started_at: Timestamp when the session was created and started. finished_at:
* Timestamp when the session was stopped (None if still active).
*/
session: TaskView.Session;

sessionId: string;

startedAt: string;
Expand Down Expand Up @@ -533,8 +535,34 @@ export interface TaskView {
isSuccess?: boolean | null;

metadata?: { [key: string]: unknown };
}

export namespace TaskView {
/**
* View model for representing a session that a task belongs to
*
* Attributes: id: Unique identifier for the session status: Current status of the
* session live_url: URL where the browser can be viewed live in real-time.
* started_at: Timestamp when the session was created and started. finished_at:
* Timestamp when the session was stopped (None if still active).
*/
export interface Session {
id: string;

sessionLiveUrl?: string | null;
startedAt: string;

/**
* Enumeration of possible (browser) session states
*
* Attributes: ACTIVE: Session is currently active and running (browser is running)
* STOPPED: Session has been stopped and is no longer active (browser is stopped)
*/
status: 'active' | 'stopped';

finishedAt?: string | null;

liveUrl?: string | null;
}
}

/**
Expand Down Expand Up @@ -576,19 +604,29 @@ export interface TaskGetLogsResponse {
/**
* Response model for output file requests
*
* Attributes: download_url: URL to download the output file
* Attributes: id: Unique identifier for the output file file_name: Name of the
* output file download_url: URL to download the output file
*/
export interface TaskGetOutputFileResponse {
id: string;

downloadUrl: string;

fileName: string;
}

/**
* Response model for user uploaded file requests
*
* Attributes: download_url: URL to download the user uploaded file
* 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 TaskGetUserUploadedFileResponse {
id: string;

downloadUrl: string;

fileName: string;
}

export interface TaskCreateParams {
Expand Down Expand Up @@ -670,12 +708,6 @@ export interface TaskListParams {
*/
filterBy?: 'started' | 'paused' | 'stopped' | 'finished' | 'successful' | 'unsuccessful' | null;

includeOutputFiles?: boolean;

includeSteps?: boolean;

includeUserUploadedFiles?: boolean;

pageNumber?: number;

pageSize?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.3.0'; // x-release-please-version
export const VERSION = '0.4.0'; // x-release-please-version
Loading