browser-use-sdk 3.1.0 → 3.2.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/larsencundric/Documents/browser-use/sdk/browser-use-node/dist/chunk-RIRVOEIU.cjs","../src/core/errors.ts","../src/core/http.ts"],"names":[],"mappings":"AAAA;ACAO,IAAM,gBAAA,EAAN,MAAA,QAA8B,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAET,WAAA,CAAY,UAAA,EAAoB,OAAA,EAAiB,MAAA,EAAkB;AACjE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,KAAA,EAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,WAAA,EAAa,UAAA;AAClB,IAAA,IAAA,CAAK,OAAA,EAAS,MAAA;AAAA,EAChB;AACF,CAAA;ADCA;AACA;AEHO,IAAM,WAAA,EAAN,MAAiB;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,WAAA,CAAY,OAAA,EAA4B;AACtC,IAAA,IAAA,CAAK,OAAA,EAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACjD,IAAA,IAAA,CAAK,WAAA,mBAAa,OAAA,CAAQ,UAAA,UAAc,GAAA;AACxC,IAAA,IAAA,CAAK,QAAA,mBAAU,OAAA,CAAQ,OAAA,UAAW,KAAA;AAAA,EACpC;AAAA,EAEA,MAAM,OAAA,CACJ,MAAA,EACA,IAAA,EACA,OAAA,EAKY;AACZ,IAAA,MAAM,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA;AACA,IAAA;AACD,MAAA;AACD,QAAA;AACR,UAAA;AACN,QAAA;AACF,MAAA;AACF,IAAA;AAEwC,IAAA;AACtC,MAAA;AACF,IAAA;AACa,IAAA;AACH,MAAA;AACV,IAAA;AAEmB,IAAA;AACA,MAAA;AACD,QAAA;AACJ,QAAA;AACZ,MAAA;AAEmB,MAAA;AACD,MAAA;AAKH,MAAA;AAEX,MAAA;AACe,QAAA;AACf,UAAA;AACA,UAAA;AACe,UAAA;AACf,UAAA;AACD,QAAA;AAEY,QAAA;AAEI,QAAA;AACF,UAAA;AACJ,YAAA;AACT,UAAA;AACc,UAAA;AAChB,QAAA;AAEM,QAAA;AAIW,QAAA;AACf,UAAA;AACF,QAAA;AAEI,QAAA;AACA,QAAA;AACU,UAAA;AACN,QAAA;AAER,QAAA;AAEE,QAAA;AAEmB,UAAA;AAMP,QAAA;AACJ,QAAA;AACI,MAAA;AACD,QAAA;AACP,QAAA;AACR,MAAA;AACF,IAAA;AAEgB,IAAA;AAClB,EAAA;AAEkE,EAAA;AACzC,IAAA;AACzB,EAAA;AAEsC,EAAA;AACb,IAAA;AACzB,EAAA;AAEuC,EAAA;AACd,IAAA;AACzB,EAAA;AAEqE,EAAA;AAC5C,IAAA;AACzB,EAAA;AACF;AFjCyB;AACA;AACA;AACA;AACA","file":"/Users/larsencundric/Documents/browser-use/sdk/browser-use-node/dist/chunk-RIRVOEIU.cjs","sourcesContent":[null,"export class BrowserUseError extends Error {\n readonly statusCode: number;\n readonly detail: unknown;\n\n constructor(statusCode: number, message: string, detail?: unknown) {\n super(message);\n this.name = \"BrowserUseError\";\n this.statusCode = statusCode;\n this.detail = detail;\n }\n}\n","import { BrowserUseError } from \"./errors.js\";\n\nexport interface HttpClientOptions {\n apiKey: string;\n baseUrl: string;\n maxRetries?: number;\n timeout?: number;\n}\n\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly maxRetries: number;\n private readonly timeout: number;\n\n constructor(options: HttpClientOptions) {\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n this.maxRetries = options.maxRetries ?? 3;\n this.timeout = options.timeout ?? 30_000;\n }\n\n async request<T>(\n method: string,\n path: string,\n options?: {\n body?: unknown;\n query?: Record<string, unknown>;\n signal?: AbortSignal;\n },\n ): Promise<T> {\n const url = new URL(`${this.baseUrl}${path}`);\n if (options?.query) {\n for (const [key, value] of Object.entries(options.query)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const headers: Record<string, string> = {\n \"X-Browser-Use-API-Key\": this.apiKey,\n };\n if (options?.body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const delay = Math.min(1000 * 2 ** (attempt - 1), 10_000);\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n\n const controller = new AbortController();\n const timeoutId = options?.signal\n ? undefined\n : setTimeout(() => controller.abort(), this.timeout);\n\n // Combine user signal with internal timeout when both are present\n const signal = options?.signal ?? controller.signal;\n\n try {\n const response = await fetch(url.toString(), {\n method,\n headers,\n body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal,\n });\n\n clearTimeout(timeoutId);\n\n if (response.ok) {\n if (response.status === 204) {\n return undefined as T;\n }\n return (await response.json()) as T;\n }\n\n const shouldRetry =\n response.status === 429 &&\n attempt < this.maxRetries;\n\n if (shouldRetry) {\n continue;\n }\n\n let errorBody: unknown;\n try {\n errorBody = await response.json();\n } catch {\n /* ignore parse errors */\n }\n const message =\n typeof errorBody === \"object\" && errorBody !== null\n ? String(\n \"message\" in errorBody\n ? (errorBody as Record<string, unknown>).message\n : \"detail\" in errorBody\n ? (errorBody as Record<string, unknown>).detail\n : `HTTP ${response.status}`,\n )\n : `HTTP ${response.status}`;\n throw new BrowserUseError(response.status, message, errorBody);\n } catch (error) {\n clearTimeout(timeoutId);\n throw error;\n }\n }\n\n throw new Error(\"Unreachable: retry loop exhausted\");\n }\n\n get<T>(path: string, query?: Record<string, unknown>): Promise<T> {\n return this.request<T>(\"GET\", path, { query });\n }\n\n post<T>(path: string, body?: unknown, query?: Record<string, unknown>): Promise<T> {\n return this.request<T>(\"POST\", path, { body, query });\n }\n\n patch<T>(path: string, body?: unknown, query?: Record<string, unknown>): Promise<T> {\n return this.request<T>(\"PATCH\", path, { body, query });\n }\n\n delete<T>(path: string, query?: Record<string, unknown>): Promise<T> {\n return this.request<T>(\"DELETE\", path, { query });\n }\n}\n"]}
1
+ {"version":3,"sources":["/Users/greg/Documents/browser-use/core/sdk/browser-use-node/dist/chunk-RIRVOEIU.cjs","../src/core/errors.ts","../src/core/http.ts"],"names":[],"mappings":"AAAA;ACAO,IAAM,gBAAA,EAAN,MAAA,QAA8B,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAET,WAAA,CAAY,UAAA,EAAoB,OAAA,EAAiB,MAAA,EAAkB;AACjE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,KAAA,EAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,WAAA,EAAa,UAAA;AAClB,IAAA,IAAA,CAAK,OAAA,EAAS,MAAA;AAAA,EAChB;AACF,CAAA;ADCA;AACA;AEHO,IAAM,WAAA,EAAN,MAAiB;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,WAAA,CAAY,OAAA,EAA4B;AACtC,IAAA,IAAA,CAAK,OAAA,EAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACjD,IAAA,IAAA,CAAK,WAAA,mBAAa,OAAA,CAAQ,UAAA,UAAc,GAAA;AACxC,IAAA,IAAA,CAAK,QAAA,mBAAU,OAAA,CAAQ,OAAA,UAAW,KAAA;AAAA,EACpC;AAAA,EAEA,MAAM,OAAA,CACJ,MAAA,EACA,IAAA,EACA,OAAA,EAKY;AACZ,IAAA,MAAM,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA;AACA,IAAA;AACD,MAAA;AACD,QAAA;AACR,UAAA;AACN,QAAA;AACF,MAAA;AACF,IAAA;AAEwC,IAAA;AACtC,MAAA;AACF,IAAA;AACa,IAAA;AACH,MAAA;AACV,IAAA;AAEmB,IAAA;AACA,MAAA;AACD,QAAA;AACJ,QAAA;AACZ,MAAA;AAEmB,MAAA;AACD,MAAA;AAKH,MAAA;AAEX,MAAA;AACe,QAAA;AACf,UAAA;AACA,UAAA;AACe,UAAA;AACf,UAAA;AACD,QAAA;AAEY,QAAA;AAEI,QAAA;AACF,UAAA;AACJ,YAAA;AACT,UAAA;AACc,UAAA;AAChB,QAAA;AAEM,QAAA;AAIW,QAAA;AACf,UAAA;AACF,QAAA;AAEI,QAAA;AACA,QAAA;AACU,UAAA;AACN,QAAA;AAER,QAAA;AAEE,QAAA;AAEmB,UAAA;AAMP,QAAA;AACJ,QAAA;AACI,MAAA;AACD,QAAA;AACP,QAAA;AACR,MAAA;AACF,IAAA;AAEgB,IAAA;AAClB,EAAA;AAEkE,EAAA;AACzC,IAAA;AACzB,EAAA;AAEsC,EAAA;AACb,IAAA;AACzB,EAAA;AAEuC,EAAA;AACd,IAAA;AACzB,EAAA;AAEqE,EAAA;AAC5C,IAAA;AACzB,EAAA;AACF;AFjCyB;AACA;AACA;AACA;AACA","file":"/Users/greg/Documents/browser-use/core/sdk/browser-use-node/dist/chunk-RIRVOEIU.cjs","sourcesContent":[null,"export class BrowserUseError extends Error {\n readonly statusCode: number;\n readonly detail: unknown;\n\n constructor(statusCode: number, message: string, detail?: unknown) {\n super(message);\n this.name = \"BrowserUseError\";\n this.statusCode = statusCode;\n this.detail = detail;\n }\n}\n","import { BrowserUseError } from \"./errors.js\";\n\nexport interface HttpClientOptions {\n apiKey: string;\n baseUrl: string;\n maxRetries?: number;\n timeout?: number;\n}\n\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly maxRetries: number;\n private readonly timeout: number;\n\n constructor(options: HttpClientOptions) {\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n this.maxRetries = options.maxRetries ?? 3;\n this.timeout = options.timeout ?? 30_000;\n }\n\n async request<T>(\n method: string,\n path: string,\n options?: {\n body?: unknown;\n query?: Record<string, unknown>;\n signal?: AbortSignal;\n },\n ): Promise<T> {\n const url = new URL(`${this.baseUrl}${path}`);\n if (options?.query) {\n for (const [key, value] of Object.entries(options.query)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const headers: Record<string, string> = {\n \"X-Browser-Use-API-Key\": this.apiKey,\n };\n if (options?.body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const delay = Math.min(1000 * 2 ** (attempt - 1), 10_000);\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n\n const controller = new AbortController();\n const timeoutId = options?.signal\n ? undefined\n : setTimeout(() => controller.abort(), this.timeout);\n\n // Combine user signal with internal timeout when both are present\n const signal = options?.signal ?? controller.signal;\n\n try {\n const response = await fetch(url.toString(), {\n method,\n headers,\n body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,\n signal,\n });\n\n clearTimeout(timeoutId);\n\n if (response.ok) {\n if (response.status === 204) {\n return undefined as T;\n }\n return (await response.json()) as T;\n }\n\n const shouldRetry =\n response.status === 429 &&\n attempt < this.maxRetries;\n\n if (shouldRetry) {\n continue;\n }\n\n let errorBody: unknown;\n try {\n errorBody = await response.json();\n } catch {\n /* ignore parse errors */\n }\n const message =\n typeof errorBody === \"object\" && errorBody !== null\n ? String(\n \"message\" in errorBody\n ? (errorBody as Record<string, unknown>).message\n : \"detail\" in errorBody\n ? (errorBody as Record<string, unknown>).detail\n : `HTTP ${response.status}`,\n )\n : `HTTP ${response.status}`;\n throw new BrowserUseError(response.status, message, errorBody);\n } catch (error) {\n clearTimeout(timeoutId);\n throw error;\n }\n }\n\n throw new Error(\"Unreachable: retry loop exhausted\");\n }\n\n get<T>(path: string, query?: Record<string, unknown>): Promise<T> {\n return this.request<T>(\"GET\", path, { query });\n }\n\n post<T>(path: string, body?: unknown, query?: Record<string, unknown>): Promise<T> {\n return this.request<T>(\"POST\", path, { body, query });\n }\n\n patch<T>(path: string, body?: unknown, query?: Record<string, unknown>): Promise<T> {\n return this.request<T>(\"PATCH\", path, { body, query });\n }\n\n delete<T>(path: string, query?: Record<string, unknown>): Promise<T> {\n return this.request<T>(\"DELETE\", path, { query });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/larsencundric/Documents/browser-use/sdk/browser-use-node/dist/index.cjs","../src/v2/client.ts","../src/v2/resources/billing.ts","../src/v2/resources/browsers.ts","../src/v2/resources/files.ts","../src/v2/resources/marketplace.ts","../src/v2/resources/profiles.ts","../src/v2/resources/sessions.ts","../src/v2/resources/skills.ts","../src/v2/helpers.ts","../src/v2/resources/tasks.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,0BAAkB;ADOlB;AACA;AEHO,IAAM,QAAA,EAAN,MAAc;AAAA,EACnB,WAAA,CAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,KAAA,EAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,OAAA,CAAA,EAAgC;AAC9B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAiB,kBAAkB,CAAA;AAAA,EACtD;AACF,CAAA;AFMA;AACA;AGHO,IAAM,SAAA,EAAN,MAAe;AAAA,EACpB,WAAA,CAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,KAAA,EAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAA,CAAO,KAAA,EAA0B,CAAC,CAAA,EAAoC;AACpE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAA6B,WAAA,EAAa,IAAI,CAAA;AAAA,EACjE;AAAA;AAAA,EAGA,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;AAG8F,EAAA;AAC3D,IAAA;AACE,IAAA;AACL,IAAA;AAEA,IAAA;AACW,MAAA;AACG,MAAA;AAClB,QAAA;AACxB,MAAA;AACsC,MAAA;AAClB,MAAA;AACmB,MAAA;AACzC,IAAA;AAE8B,IAAA;AAChC,EAAA;AACF;AViSgD;AACA;ACxWvB;AAYD;AACb,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAEQ,EAAA;AAE4B,EAAA;AAEf,IAAA;AACf,IAAA;AACD,MAAA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AAC2B,IAAA;AACzB,MAAA;AAC4B,MAAA;AACR,MAAA;AACH,MAAA;AAClB,IAAA;AAEmC,IAAA;AACJ,IAAA;AACM,IAAA;AACN,IAAA;AACM,IAAA;AACA,IAAA;AACJ,IAAA;AACU,IAAA;AAC9C,EAAA;AAoB0D,EAAA;AACb,IAAA;AACE,IAAA;AACjC,IAAA;AAC+B,MAAA;AAC3C,IAAA;AACsC,IAAA;AACE,IAAA;AAC1C,EAAA;AACF;ADwUgD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/larsencundric/Documents/browser-use/sdk/browser-use-node/dist/index.cjs","sourcesContent":[null,"import { z } from \"zod\";\nimport { HttpClient } from \"../core/http.js\";\nimport { Billing } from \"./resources/billing.js\";\nimport { Browsers } from \"./resources/browsers.js\";\nimport { Files } from \"./resources/files.js\";\nimport { Marketplace } from \"./resources/marketplace.js\";\nimport { Profiles } from \"./resources/profiles.js\";\nimport { Sessions } from \"./resources/sessions.js\";\nimport { Skills } from \"./resources/skills.js\";\nimport { Tasks } from \"./resources/tasks.js\";\nimport { TaskRun } from \"./helpers.js\";\nimport type { CreateTaskBody } from \"./resources/tasks.js\";\nimport type { RunOptions } from \"./helpers.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.browser-use.com/api/v2\";\n\nexport interface BrowserUseOptions {\n apiKey?: string;\n baseUrl?: string;\n maxRetries?: number;\n timeout?: number;\n}\n\nexport type RunTaskOptions = Partial<Omit<CreateTaskBody, \"task\">> &\n RunOptions & { schema?: z.ZodType };\n\nexport class BrowserUse {\n readonly billing: Billing;\n readonly tasks: Tasks;\n readonly sessions: Sessions;\n readonly files: Files;\n readonly profiles: Profiles;\n readonly browsers: Browsers;\n readonly skills: Skills;\n readonly marketplace: Marketplace;\n\n private readonly http: HttpClient;\n\n constructor(options: BrowserUseOptions = {}) {\n const apiKey =\n options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? \"\";\n if (!apiKey) {\n throw new Error(\n \"No API key provided. Pass apiKey or set BROWSER_USE_API_KEY.\",\n );\n }\n this.http = new HttpClient({\n apiKey,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n maxRetries: options.maxRetries,\n timeout: options.timeout,\n });\n\n this.billing = new Billing(this.http);\n this.tasks = new Tasks(this.http);\n this.sessions = new Sessions(this.http);\n this.files = new Files(this.http);\n this.profiles = new Profiles(this.http);\n this.browsers = new Browsers(this.http);\n this.skills = new Skills(this.http);\n this.marketplace = new Marketplace(this.http);\n }\n\n /**\n * Run an AI agent task.\n *\n * ```ts\n * // Simple — just get the output\n * const output = await client.run(\"Find the top HN post\");\n *\n * // Structured output (Zod)\n * const data = await client.run(\"Find product info\", { schema: ProductSchema });\n *\n * // Step-by-step progress\n * for await (const step of client.run(\"Go to google.com\")) {\n * console.log(`[${step.number}] ${step.nextGoal}`);\n * }\n * ```\n */\n run(task: string, options?: Omit<RunTaskOptions, \"schema\">): TaskRun<string>;\n run<T extends z.ZodType>(task: string, options: RunTaskOptions & { schema: T }): TaskRun<z.output<T>>;\n run(task: string, options?: RunTaskOptions): TaskRun<any> {\n const { schema, timeout, interval, ...rest } = options ?? {};\n const body: CreateTaskBody = { task, ...rest };\n if (schema) {\n body.structuredOutput = JSON.stringify(z.toJSONSchema(schema));\n }\n const promise = this.tasks.create(body);\n return new TaskRun(promise, this.tasks, schema, { timeout, interval });\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype AccountView = components[\"schemas\"][\"AccountView\"];\n\nexport class Billing {\n constructor(private readonly http: HttpClient) {}\n\n /** Get authenticated account billing information including credit balance. */\n account(): Promise<AccountView> {\n return this.http.get<AccountView>(\"/billing/account\");\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\n/** All fields are optional (server applies defaults); body itself is required by the spec. */\nexport type CreateBrowserBody = Partial<components[\"schemas\"][\"CreateBrowserSessionRequest\"]>;\ntype BrowserSessionItemView = components[\"schemas\"][\"BrowserSessionItemView\"];\ntype BrowserSessionListResponse = components[\"schemas\"][\"BrowserSessionListResponse\"];\ntype BrowserSessionView = components[\"schemas\"][\"BrowserSessionView\"];\ntype UpdateBrowserSessionRequest = components[\"schemas\"][\"UpdateBrowserSessionRequest\"];\n\nexport interface BrowserListParams {\n pageSize?: number;\n pageNumber?: number;\n filterBy?: string;\n}\n\nexport class Browsers {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new browser session. */\n create(body: CreateBrowserBody = {}): Promise<BrowserSessionItemView> {\n return this.http.post<BrowserSessionItemView>(\"/browsers\", body);\n }\n\n /** List browser sessions with optional filtering. */\n list(params?: BrowserListParams): Promise<BrowserSessionListResponse> {\n return this.http.get<BrowserSessionListResponse>(\n \"/browsers\",\n params as Record<string, unknown>,\n );\n }\n\n /** Get detailed browser session information. */\n get(sessionId: string): Promise<BrowserSessionView> {\n return this.http.get<BrowserSessionView>(`/browsers/${sessionId}`);\n }\n\n /** Update a browser session (generic PATCH). */\n update(sessionId: string, body: UpdateBrowserSessionRequest): Promise<BrowserSessionView> {\n return this.http.patch<BrowserSessionView>(`/browsers/${sessionId}`, body);\n }\n\n /** Stop a browser session. */\n stop(sessionId: string): Promise<BrowserSessionView> {\n return this.update(sessionId, { action: \"stop\" });\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype UploadFileRequest = components[\"schemas\"][\"UploadFileRequest\"];\ntype UploadFilePresignedUrlResponse = components[\"schemas\"][\"UploadFilePresignedUrlResponse\"];\ntype TaskOutputFileResponse = components[\"schemas\"][\"TaskOutputFileResponse\"];\n\nexport class Files {\n constructor(private readonly http: HttpClient) {}\n\n /** Generate a presigned URL for uploading files to an agent session. */\n sessionUrl(sessionId: string, body: UploadFileRequest): Promise<UploadFilePresignedUrlResponse> {\n return this.http.post<UploadFilePresignedUrlResponse>(\n `/files/sessions/${sessionId}/presigned-url`,\n body,\n );\n }\n\n /** Generate a presigned URL for uploading files to a browser session. */\n browserUrl(sessionId: string, body: UploadFileRequest): Promise<UploadFilePresignedUrlResponse> {\n return this.http.post<UploadFilePresignedUrlResponse>(\n `/files/browsers/${sessionId}/presigned-url`,\n body,\n );\n }\n\n /** Get secure download URL for a task output file. */\n taskOutput(taskId: string, fileId: string): Promise<TaskOutputFileResponse> {\n return this.http.get<TaskOutputFileResponse>(\n `/files/tasks/${taskId}/output-files/${fileId}`,\n );\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype ExecuteSkillRequest = components[\"schemas\"][\"ExecuteSkillRequest\"];\ntype ExecuteSkillResponse = components[\"schemas\"][\"ExecuteSkillResponse\"];\ntype MarketplaceSkillListResponse = components[\"schemas\"][\"MarketplaceSkillListResponse\"];\ntype MarketplaceSkillResponse = components[\"schemas\"][\"MarketplaceSkillResponse\"];\ntype SkillResponse = components[\"schemas\"][\"SkillResponse\"];\n\nexport interface MarketplaceListParams {\n pageSize?: number;\n pageNumber?: number;\n query?: string;\n category?: string;\n fromDate?: string;\n toDate?: string;\n}\n\nexport class Marketplace {\n constructor(private readonly http: HttpClient) {}\n\n /** List all public skills in the marketplace. */\n list(params?: MarketplaceListParams): Promise<MarketplaceSkillListResponse> {\n return this.http.get<MarketplaceSkillListResponse>(\n \"/marketplace/skills\",\n params as Record<string, unknown>,\n );\n }\n\n /** Get details of a specific marketplace skill by slug. */\n get(skillSlug: string): Promise<MarketplaceSkillResponse> {\n return this.http.get<MarketplaceSkillResponse>(`/marketplace/skills/${skillSlug}`);\n }\n\n /** Clone a public marketplace skill to your project. */\n clone(skillId: string): Promise<SkillResponse> {\n return this.http.post<SkillResponse>(`/marketplace/skills/${skillId}/clone`);\n }\n\n /** Execute a marketplace skill. */\n execute(skillId: string, body: ExecuteSkillRequest): Promise<ExecuteSkillResponse> {\n return this.http.post<ExecuteSkillResponse>(\n `/marketplace/skills/${skillId}/execute`,\n body,\n );\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype ProfileCreateRequest = components[\"schemas\"][\"ProfileCreateRequest\"];\ntype ProfileListResponse = components[\"schemas\"][\"ProfileListResponse\"];\ntype ProfileUpdateRequest = components[\"schemas\"][\"ProfileUpdateRequest\"];\ntype ProfileView = components[\"schemas\"][\"ProfileView\"];\n\nexport interface ProfileListParams {\n pageSize?: number;\n pageNumber?: number;\n}\n\nexport class Profiles {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new browser profile. */\n create(body?: ProfileCreateRequest): Promise<ProfileView> {\n return this.http.post<ProfileView>(\"/profiles\", body);\n }\n\n /** List profiles with pagination. */\n list(params?: ProfileListParams): Promise<ProfileListResponse> {\n return this.http.get<ProfileListResponse>(\"/profiles\", params as Record<string, unknown>);\n }\n\n /** Get profile details. */\n get(profileId: string): Promise<ProfileView> {\n return this.http.get<ProfileView>(`/profiles/${profileId}`);\n }\n\n /** Update a browser profile. */\n update(profileId: string, body: ProfileUpdateRequest): Promise<ProfileView> {\n return this.http.patch<ProfileView>(`/profiles/${profileId}`, body);\n }\n\n /** Delete a browser profile. */\n delete(profileId: string): Promise<void> {\n return this.http.delete<void>(`/profiles/${profileId}`);\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\n/** User-facing body: all fields are optional (API has defaults). */\ntype CreateSessionBody = Partial<components[\"schemas\"][\"CreateSessionRequest\"]>;\ntype SessionItemView = components[\"schemas\"][\"SessionItemView\"];\ntype SessionListResponse = components[\"schemas\"][\"SessionListResponse\"];\ntype SessionView = components[\"schemas\"][\"SessionView\"];\ntype ShareView = components[\"schemas\"][\"ShareView\"];\ntype UpdateSessionRequest = components[\"schemas\"][\"UpdateSessionRequest\"];\n\nexport interface SessionListParams {\n pageSize?: number;\n pageNumber?: number;\n filterBy?: string;\n}\n\nexport class Sessions {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new session. */\n create(body?: CreateSessionBody): Promise<SessionItemView> {\n return this.http.post<SessionItemView>(\"/sessions\", body);\n }\n\n /** List sessions with optional filtering. */\n list(params?: SessionListParams): Promise<SessionListResponse> {\n return this.http.get<SessionListResponse>(\"/sessions\", params as Record<string, unknown>);\n }\n\n /** Get detailed session information. */\n get(sessionId: string): Promise<SessionView> {\n return this.http.get<SessionView>(`/sessions/${sessionId}`);\n }\n\n /** Update a session (generic PATCH). */\n update(sessionId: string, body: UpdateSessionRequest): Promise<SessionView> {\n return this.http.patch<SessionView>(`/sessions/${sessionId}`, body);\n }\n\n /** Stop a session and all its running tasks. */\n stop(sessionId: string): Promise<SessionView> {\n return this.update(sessionId, { action: \"stop\" });\n }\n\n /** Delete a session with all its tasks. */\n delete(sessionId: string): Promise<void> {\n return this.http.delete<void>(`/sessions/${sessionId}`);\n }\n\n /** Get public share information for a session. */\n getShare(sessionId: string): Promise<ShareView> {\n return this.http.get<ShareView>(`/sessions/${sessionId}/public-share`);\n }\n\n /** Create or return existing public share for a session. */\n createShare(sessionId: string): Promise<ShareView> {\n return this.http.post<ShareView>(`/sessions/${sessionId}/public-share`);\n }\n\n /** Remove public share for a session. */\n deleteShare(sessionId: string): Promise<void> {\n return this.http.delete<void>(`/sessions/${sessionId}/public-share`);\n }\n\n /** Purge all session data (ZDR projects only). */\n purge(sessionId: string): Promise<void> {\n return this.http.post<void>(`/sessions/${sessionId}/purge`);\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype CreateSkillRequest = components[\"schemas\"][\"CreateSkillRequest\"];\ntype CreateSkillResponse = components[\"schemas\"][\"CreateSkillResponse\"];\ntype ExecuteSkillRequest = components[\"schemas\"][\"ExecuteSkillRequest\"];\ntype ExecuteSkillResponse = components[\"schemas\"][\"ExecuteSkillResponse\"];\ntype RefineSkillRequest = components[\"schemas\"][\"RefineSkillRequest\"];\ntype RefineSkillResponse = components[\"schemas\"][\"RefineSkillResponse\"];\ntype SkillExecutionListResponse = components[\"schemas\"][\"SkillExecutionListResponse\"];\ntype SkillExecutionOutputResponse = components[\"schemas\"][\"SkillExecutionOutputResponse\"];\ntype SkillListResponse = components[\"schemas\"][\"SkillListResponse\"];\ntype SkillResponse = components[\"schemas\"][\"SkillResponse\"];\ntype UpdateSkillRequest = components[\"schemas\"][\"UpdateSkillRequest\"];\n\nexport interface SkillListParams {\n pageSize?: number;\n pageNumber?: number;\n isPublic?: boolean;\n isEnabled?: boolean;\n category?: string;\n query?: string;\n fromDate?: string;\n toDate?: string;\n}\n\nexport interface SkillExecutionListParams {\n pageSize?: number;\n pageNumber?: number;\n}\n\nexport class Skills {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new skill via automated generation. */\n create(body: CreateSkillRequest): Promise<CreateSkillResponse> {\n return this.http.post<CreateSkillResponse>(\"/skills\", body);\n }\n\n /** List all skills owned by the project. */\n list(params?: SkillListParams): Promise<SkillListResponse> {\n return this.http.get<SkillListResponse>(\"/skills\", params as Record<string, unknown>);\n }\n\n /** Get details of a specific skill. */\n get(skillId: string): Promise<SkillResponse> {\n return this.http.get<SkillResponse>(`/skills/${skillId}`);\n }\n\n /** Delete a skill. */\n delete(skillId: string): Promise<void> {\n return this.http.delete<void>(`/skills/${skillId}`);\n }\n\n /** Update skill metadata. */\n update(skillId: string, body: UpdateSkillRequest): Promise<SkillResponse> {\n return this.http.patch<SkillResponse>(`/skills/${skillId}`, body);\n }\n\n /** Cancel the current in-progress generation for a skill. */\n cancel(skillId: string): Promise<SkillResponse> {\n return this.http.post<SkillResponse>(`/skills/${skillId}/cancel`);\n }\n\n /** Execute a skill with the provided parameters. */\n execute(skillId: string, body: ExecuteSkillRequest): Promise<ExecuteSkillResponse> {\n return this.http.post<ExecuteSkillResponse>(`/skills/${skillId}/execute`, body);\n }\n\n /** Refine a skill based on feedback. */\n refine(skillId: string, body: RefineSkillRequest): Promise<RefineSkillResponse> {\n return this.http.post<RefineSkillResponse>(`/skills/${skillId}/refine`, body);\n }\n\n /** Rollback to the previous version. */\n rollback(skillId: string): Promise<SkillResponse> {\n return this.http.post<SkillResponse>(`/skills/${skillId}/rollback`);\n }\n\n /** List executions for a specific skill. */\n executions(skillId: string, params?: SkillExecutionListParams): Promise<SkillExecutionListResponse> {\n return this.http.get<SkillExecutionListResponse>(\n `/skills/${skillId}/executions`,\n params as Record<string, unknown>,\n );\n }\n\n /** Get presigned URL for downloading skill execution output. */\n executionOutput(skillId: string, executionId: string): Promise<SkillExecutionOutputResponse> {\n return this.http.get<SkillExecutionOutputResponse>(\n `/skills/${skillId}/executions/${executionId}/output`,\n );\n }\n}\n","import type { z } from \"zod\";\nimport type { components } from \"../generated/v2/types.js\";\nimport type { Tasks } from \"./resources/tasks.js\";\n\ntype TaskCreatedResponse = components[\"schemas\"][\"TaskCreatedResponse\"];\ntype TaskStepView = components[\"schemas\"][\"TaskStepView\"];\ntype TaskView = components[\"schemas\"][\"TaskView\"];\n\nexport const TERMINAL_STATUSES = new Set([\"finished\", \"stopped\"]);\n\n/** Task result with typed output. All TaskView fields are directly accessible. */\nexport type TaskResult<T = string | null> = Omit<TaskView, \"output\"> & { output: T };\n\nexport interface RunOptions {\n /** Maximum time to wait in milliseconds. Default: 300_000 (5 min). */\n timeout?: number;\n /** Polling interval in milliseconds. Default: 2_000. */\n interval?: number;\n}\n\n/**\n * Lazy task handle returned by `client.run()`.\n *\n * - `await client.run(...)` polls the lightweight status endpoint, returns a `TaskResult`.\n * - `for await (const step of client.run(...))` polls the full task, yields new steps.\n */\nexport class TaskRun<T = string> implements PromiseLike<TaskResult<T>> {\n private readonly _createPromise: Promise<TaskCreatedResponse>;\n private readonly _tasks: Tasks;\n private readonly _schema?: z.ZodType<T>;\n private readonly _timeout: number;\n private readonly _interval: number;\n\n private _taskId: string | null = null;\n private _result: TaskResult<T> | null = null;\n\n constructor(\n createPromise: Promise<TaskCreatedResponse>,\n tasks: Tasks,\n schema?: z.ZodType<T>,\n options?: RunOptions,\n ) {\n this._createPromise = createPromise;\n this._tasks = tasks;\n this._schema = schema;\n this._timeout = options?.timeout ?? 300_000;\n this._interval = options?.interval ?? 2_000;\n }\n\n /** Task ID (available after creation resolves). */\n get taskId(): string | null {\n return this._taskId;\n }\n\n /** Full task result (available after awaiting or iterating to completion). */\n get result(): TaskResult<T> | null {\n return this._result;\n }\n\n /** Enable `await client.run(...)` — polls status endpoint, returns TaskResult. */\n then<R1 = TaskResult<T>, R2 = never>(\n onFulfilled?: ((value: TaskResult<T>) => R1 | PromiseLike<R1>) | null,\n onRejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,\n ): Promise<R1 | R2> {\n return this._waitForOutput().then(onFulfilled, onRejected);\n }\n\n /** Enable `for await (const step of client.run(...))` — polls full task, yields new steps. */\n async *[Symbol.asyncIterator](): AsyncGenerator<TaskStepView> {\n const taskId = await this._ensureTaskId();\n let seen = 0;\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const task = await this._tasks.get(taskId);\n\n for (let i = seen; i < task.steps.length; i++) {\n yield task.steps[i];\n }\n seen = task.steps.length;\n\n if (TERMINAL_STATUSES.has(task.status)) {\n this._result = this._buildResult(task);\n return;\n }\n\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) => setTimeout(r, Math.min(this._interval, remaining)));\n }\n\n throw new Error(`Task ${taskId} did not complete within ${this._timeout}ms`);\n }\n\n private async _ensureTaskId(): Promise<string> {\n if (this._taskId) return this._taskId;\n const created = await this._createPromise;\n this._taskId = created.id;\n return this._taskId;\n }\n\n /** Poll lightweight status endpoint until terminal, return TaskResult. */\n private async _waitForOutput(): Promise<TaskResult<T>> {\n const taskId = await this._ensureTaskId();\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const status = await this._tasks.status(taskId);\n if (TERMINAL_STATUSES.has(status.status)) {\n const task = await this._tasks.get(taskId);\n this._result = this._buildResult(task);\n return this._result;\n }\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) => setTimeout(r, Math.min(this._interval, remaining)));\n }\n\n throw new Error(`Task ${taskId} did not complete within ${this._timeout}ms`);\n }\n\n private _buildResult(task: TaskView): TaskResult<T> {\n const output = this._parseOutput(task.output);\n return { ...task, output };\n }\n\n private _parseOutput(output: string | null | undefined): T {\n if (output == null) return null as T;\n if (!this._schema) return output as unknown as T;\n return this._schema.parse(JSON.parse(output));\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\nimport { TERMINAL_STATUSES } from \"../helpers.js\";\n\n/** User-facing body: only `task` is required; everything else has API defaults. */\nexport type CreateTaskBody = Pick<components[\"schemas\"][\"CreateTaskRequest\"], \"task\"> &\n Partial<Omit<components[\"schemas\"][\"CreateTaskRequest\"], \"task\">>;\ntype TaskCreatedResponse = components[\"schemas\"][\"TaskCreatedResponse\"];\ntype TaskListResponse = components[\"schemas\"][\"TaskListResponse\"];\ntype TaskLogFileResponse = components[\"schemas\"][\"TaskLogFileResponse\"];\ntype TaskStatusView = components[\"schemas\"][\"TaskStatusView\"];\ntype TaskView = components[\"schemas\"][\"TaskView\"];\ntype UpdateTaskRequest = components[\"schemas\"][\"UpdateTaskRequest\"];\n\nexport interface TaskListParams {\n pageSize?: number;\n pageNumber?: number;\n sessionId?: string;\n filterBy?: string;\n after?: string;\n before?: string;\n}\n\nexport class Tasks {\n constructor(private readonly http: HttpClient) {}\n\n /** Create and start a new AI agent task. */\n create(body: CreateTaskBody): Promise<TaskCreatedResponse> {\n return this.http.post<TaskCreatedResponse>(\"/tasks\", body);\n }\n\n /** List tasks with optional filtering. */\n list(params?: TaskListParams): Promise<TaskListResponse> {\n return this.http.get<TaskListResponse>(\"/tasks\", params as Record<string, unknown>);\n }\n\n /** Get detailed task information. */\n get(taskId: string): Promise<TaskView> {\n return this.http.get<TaskView>(`/tasks/${taskId}`);\n }\n\n /** Update a task (generic PATCH). */\n update(taskId: string, body: UpdateTaskRequest): Promise<TaskView> {\n return this.http.patch<TaskView>(`/tasks/${taskId}`, body);\n }\n\n /** Stop a running task. */\n stop(taskId: string): Promise<TaskView> {\n return this.update(taskId, { action: \"stop\" });\n }\n\n /** Stop a running task and its associated browser session. */\n stopTaskAndSession(taskId: string): Promise<TaskView> {\n return this.update(taskId, { action: \"stop_task_and_session\" });\n }\n\n /** Get lightweight task status (optimized for polling). */\n status(taskId: string): Promise<TaskStatusView> {\n return this.http.get<TaskStatusView>(`/tasks/${taskId}/status`);\n }\n\n /** Get secure download URL for task execution logs. */\n logs(taskId: string): Promise<TaskLogFileResponse> {\n return this.http.get<TaskLogFileResponse>(`/tasks/${taskId}/logs`);\n }\n\n /** Poll until a task reaches a terminal status, then return the full TaskView. */\n async wait(taskId: string, opts?: { timeout?: number; interval?: number }): Promise<TaskView> {\n const timeout = opts?.timeout ?? 300_000;\n const interval = opts?.interval ?? 2_000;\n const deadline = Date.now() + timeout;\n\n while (Date.now() < deadline) {\n const status = await this.status(taskId);\n if (TERMINAL_STATUSES.has(status.status)) {\n return this.get(taskId);\n }\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) => setTimeout(r, Math.min(interval, remaining)));\n }\n\n throw new Error(`Task ${taskId} did not complete within ${timeout}ms`);\n }\n}\n"]}
1
+ {"version":3,"sources":["/Users/greg/Documents/browser-use/core/sdk/browser-use-node/dist/index.cjs","../src/v2/client.ts","../src/v2/resources/billing.ts","../src/v2/resources/browsers.ts","../src/v2/resources/files.ts","../src/v2/resources/marketplace.ts","../src/v2/resources/profiles.ts","../src/v2/resources/sessions.ts","../src/v2/resources/skills.ts","../src/v2/helpers.ts","../src/v2/resources/tasks.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,0BAAkB;ADOlB;AACA;AEHO,IAAM,QAAA,EAAN,MAAc;AAAA,EACnB,WAAA,CAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,KAAA,EAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,OAAA,CAAA,EAAgC;AAC9B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAiB,kBAAkB,CAAA;AAAA,EACtD;AACF,CAAA;AFMA;AACA;AGHO,IAAM,SAAA,EAAN,MAAe;AAAA,EACpB,WAAA,CAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,KAAA,EAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAA,CAAO,KAAA,EAA0B,CAAC,CAAA,EAAoC;AACpE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAA6B,WAAA,EAAa,IAAI,CAAA;AAAA,EACjE;AAAA;AAAA,EAGA,IAAA,CAAK,MAAA,EAAiE;AACpE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA;AAAA,MACf,WAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,EACF;AAAA;AAAA,EAGA,GAAA,CAAI,SAAA,EAAgD;AAClD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAwB,CAAA,UAAA,EAAa,SAAS,CAAA,CAAA;AACjE,EAAA;AAAA;AAG0F,EAAA;AAChC,IAAA;AAC1D,EAAA;AAAA;AAGqD,EAAA;AACX,IAAA;AAC1C,EAAA;AACF;AHEgD;AACA;AI1C7B;AAC8B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2B,IAAA;AACzB,MAAA;AAC4B,MAAA;AACR,MAAA;AACH,MAAA;AAClB,IAAA;AAEmC,IAAA;AACJ,IAAA;AACM,IAAA;AACN,IAAA;AACM,IAAA;AACA,IAAA;AACJ,IAAA;AACU,IAAA;AAC9C,EAAA;AAoB0D,EAAA;AACb,IAAA;AACE,IAAA;AACjC,IAAA;AAC+B,MAAA;AAC3C,IAAA;AACsC,IAAA;AACE,IAAA;AAC1C,EAAA;AACF;ADwUgD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/greg/Documents/browser-use/core/sdk/browser-use-node/dist/index.cjs","sourcesContent":[null,"import { z } from \"zod\";\nimport { HttpClient } from \"../core/http.js\";\nimport { Billing } from \"./resources/billing.js\";\nimport { Browsers } from \"./resources/browsers.js\";\nimport { Files } from \"./resources/files.js\";\nimport { Marketplace } from \"./resources/marketplace.js\";\nimport { Profiles } from \"./resources/profiles.js\";\nimport { Sessions } from \"./resources/sessions.js\";\nimport { Skills } from \"./resources/skills.js\";\nimport { Tasks } from \"./resources/tasks.js\";\nimport { TaskRun } from \"./helpers.js\";\nimport type { CreateTaskBody } from \"./resources/tasks.js\";\nimport type { RunOptions } from \"./helpers.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.browser-use.com/api/v2\";\n\nexport interface BrowserUseOptions {\n apiKey?: string;\n baseUrl?: string;\n maxRetries?: number;\n timeout?: number;\n}\n\nexport type RunTaskOptions = Partial<Omit<CreateTaskBody, \"task\">> &\n RunOptions & { schema?: z.ZodType };\n\nexport class BrowserUse {\n readonly billing: Billing;\n readonly tasks: Tasks;\n readonly sessions: Sessions;\n readonly files: Files;\n readonly profiles: Profiles;\n readonly browsers: Browsers;\n readonly skills: Skills;\n readonly marketplace: Marketplace;\n\n private readonly http: HttpClient;\n\n constructor(options: BrowserUseOptions = {}) {\n const apiKey =\n options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? \"\";\n if (!apiKey) {\n throw new Error(\n \"No API key provided. Pass apiKey or set BROWSER_USE_API_KEY.\",\n );\n }\n this.http = new HttpClient({\n apiKey,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n maxRetries: options.maxRetries,\n timeout: options.timeout,\n });\n\n this.billing = new Billing(this.http);\n this.tasks = new Tasks(this.http);\n this.sessions = new Sessions(this.http);\n this.files = new Files(this.http);\n this.profiles = new Profiles(this.http);\n this.browsers = new Browsers(this.http);\n this.skills = new Skills(this.http);\n this.marketplace = new Marketplace(this.http);\n }\n\n /**\n * Run an AI agent task.\n *\n * ```ts\n * // Simple — just get the output\n * const output = await client.run(\"Find the top HN post\");\n *\n * // Structured output (Zod)\n * const data = await client.run(\"Find product info\", { schema: ProductSchema });\n *\n * // Step-by-step progress\n * for await (const step of client.run(\"Go to google.com\")) {\n * console.log(`[${step.number}] ${step.nextGoal}`);\n * }\n * ```\n */\n run(task: string, options?: Omit<RunTaskOptions, \"schema\">): TaskRun<string>;\n run<T extends z.ZodType>(task: string, options: RunTaskOptions & { schema: T }): TaskRun<z.output<T>>;\n run(task: string, options?: RunTaskOptions): TaskRun<any> {\n const { schema, timeout, interval, ...rest } = options ?? {};\n const body: CreateTaskBody = { task, ...rest };\n if (schema) {\n body.structuredOutput = JSON.stringify(z.toJSONSchema(schema));\n }\n const promise = this.tasks.create(body);\n return new TaskRun(promise, this.tasks, schema, { timeout, interval });\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype AccountView = components[\"schemas\"][\"AccountView\"];\n\nexport class Billing {\n constructor(private readonly http: HttpClient) {}\n\n /** Get authenticated account billing information including credit balance. */\n account(): Promise<AccountView> {\n return this.http.get<AccountView>(\"/billing/account\");\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\n/** All fields are optional (server applies defaults); body itself is required by the spec. */\nexport type CreateBrowserBody = Partial<components[\"schemas\"][\"CreateBrowserSessionRequest\"]>;\ntype BrowserSessionItemView = components[\"schemas\"][\"BrowserSessionItemView\"];\ntype BrowserSessionListResponse = components[\"schemas\"][\"BrowserSessionListResponse\"];\ntype BrowserSessionView = components[\"schemas\"][\"BrowserSessionView\"];\ntype UpdateBrowserSessionRequest = components[\"schemas\"][\"UpdateBrowserSessionRequest\"];\n\nexport interface BrowserListParams {\n pageSize?: number;\n pageNumber?: number;\n filterBy?: string;\n}\n\nexport class Browsers {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new browser session. */\n create(body: CreateBrowserBody = {}): Promise<BrowserSessionItemView> {\n return this.http.post<BrowserSessionItemView>(\"/browsers\", body);\n }\n\n /** List browser sessions with optional filtering. */\n list(params?: BrowserListParams): Promise<BrowserSessionListResponse> {\n return this.http.get<BrowserSessionListResponse>(\n \"/browsers\",\n params as Record<string, unknown>,\n );\n }\n\n /** Get detailed browser session information. */\n get(sessionId: string): Promise<BrowserSessionView> {\n return this.http.get<BrowserSessionView>(`/browsers/${sessionId}`);\n }\n\n /** Update a browser session (generic PATCH). */\n update(sessionId: string, body: UpdateBrowserSessionRequest): Promise<BrowserSessionView> {\n return this.http.patch<BrowserSessionView>(`/browsers/${sessionId}`, body);\n }\n\n /** Stop a browser session. */\n stop(sessionId: string): Promise<BrowserSessionView> {\n return this.update(sessionId, { action: \"stop\" });\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype UploadFileRequest = components[\"schemas\"][\"UploadFileRequest\"];\ntype UploadFilePresignedUrlResponse = components[\"schemas\"][\"UploadFilePresignedUrlResponse\"];\ntype TaskOutputFileResponse = components[\"schemas\"][\"TaskOutputFileResponse\"];\n\nexport class Files {\n constructor(private readonly http: HttpClient) {}\n\n /** Generate a presigned URL for uploading files to an agent session. */\n sessionUrl(sessionId: string, body: UploadFileRequest): Promise<UploadFilePresignedUrlResponse> {\n return this.http.post<UploadFilePresignedUrlResponse>(\n `/files/sessions/${sessionId}/presigned-url`,\n body,\n );\n }\n\n /** Generate a presigned URL for uploading files to a browser session. */\n browserUrl(sessionId: string, body: UploadFileRequest): Promise<UploadFilePresignedUrlResponse> {\n return this.http.post<UploadFilePresignedUrlResponse>(\n `/files/browsers/${sessionId}/presigned-url`,\n body,\n );\n }\n\n /** Get secure download URL for a task output file. */\n taskOutput(taskId: string, fileId: string): Promise<TaskOutputFileResponse> {\n return this.http.get<TaskOutputFileResponse>(\n `/files/tasks/${taskId}/output-files/${fileId}`,\n );\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype ExecuteSkillRequest = components[\"schemas\"][\"ExecuteSkillRequest\"];\ntype ExecuteSkillResponse = components[\"schemas\"][\"ExecuteSkillResponse\"];\ntype MarketplaceSkillListResponse = components[\"schemas\"][\"MarketplaceSkillListResponse\"];\ntype MarketplaceSkillResponse = components[\"schemas\"][\"MarketplaceSkillResponse\"];\ntype SkillResponse = components[\"schemas\"][\"SkillResponse\"];\n\nexport interface MarketplaceListParams {\n pageSize?: number;\n pageNumber?: number;\n query?: string;\n category?: string;\n fromDate?: string;\n toDate?: string;\n}\n\nexport class Marketplace {\n constructor(private readonly http: HttpClient) {}\n\n /** List all public skills in the marketplace. */\n list(params?: MarketplaceListParams): Promise<MarketplaceSkillListResponse> {\n return this.http.get<MarketplaceSkillListResponse>(\n \"/marketplace/skills\",\n params as Record<string, unknown>,\n );\n }\n\n /** Get details of a specific marketplace skill by slug. */\n get(skillSlug: string): Promise<MarketplaceSkillResponse> {\n return this.http.get<MarketplaceSkillResponse>(`/marketplace/skills/${skillSlug}`);\n }\n\n /** Clone a public marketplace skill to your project. */\n clone(skillId: string): Promise<SkillResponse> {\n return this.http.post<SkillResponse>(`/marketplace/skills/${skillId}/clone`);\n }\n\n /** Execute a marketplace skill. */\n execute(skillId: string, body: ExecuteSkillRequest): Promise<ExecuteSkillResponse> {\n return this.http.post<ExecuteSkillResponse>(\n `/marketplace/skills/${skillId}/execute`,\n body,\n );\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype ProfileCreateRequest = components[\"schemas\"][\"ProfileCreateRequest\"];\ntype ProfileListResponse = components[\"schemas\"][\"ProfileListResponse\"];\ntype ProfileUpdateRequest = components[\"schemas\"][\"ProfileUpdateRequest\"];\ntype ProfileView = components[\"schemas\"][\"ProfileView\"];\n\nexport interface ProfileListParams {\n pageSize?: number;\n pageNumber?: number;\n}\n\nexport class Profiles {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new browser profile. */\n create(body?: ProfileCreateRequest): Promise<ProfileView> {\n return this.http.post<ProfileView>(\"/profiles\", body);\n }\n\n /** List profiles with pagination. */\n list(params?: ProfileListParams): Promise<ProfileListResponse> {\n return this.http.get<ProfileListResponse>(\"/profiles\", params as Record<string, unknown>);\n }\n\n /** Get profile details. */\n get(profileId: string): Promise<ProfileView> {\n return this.http.get<ProfileView>(`/profiles/${profileId}`);\n }\n\n /** Update a browser profile. */\n update(profileId: string, body: ProfileUpdateRequest): Promise<ProfileView> {\n return this.http.patch<ProfileView>(`/profiles/${profileId}`, body);\n }\n\n /** Delete a browser profile. */\n delete(profileId: string): Promise<void> {\n return this.http.delete<void>(`/profiles/${profileId}`);\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\n/** User-facing body: all fields are optional (API has defaults). */\ntype CreateSessionBody = Partial<components[\"schemas\"][\"CreateSessionRequest\"]>;\ntype SessionItemView = components[\"schemas\"][\"SessionItemView\"];\ntype SessionListResponse = components[\"schemas\"][\"SessionListResponse\"];\ntype SessionView = components[\"schemas\"][\"SessionView\"];\ntype ShareView = components[\"schemas\"][\"ShareView\"];\ntype UpdateSessionRequest = components[\"schemas\"][\"UpdateSessionRequest\"];\n\nexport interface SessionListParams {\n pageSize?: number;\n pageNumber?: number;\n filterBy?: string;\n}\n\nexport class Sessions {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new session. */\n create(body?: CreateSessionBody): Promise<SessionItemView> {\n return this.http.post<SessionItemView>(\"/sessions\", body);\n }\n\n /** List sessions with optional filtering. */\n list(params?: SessionListParams): Promise<SessionListResponse> {\n return this.http.get<SessionListResponse>(\"/sessions\", params as Record<string, unknown>);\n }\n\n /** Get detailed session information. */\n get(sessionId: string): Promise<SessionView> {\n return this.http.get<SessionView>(`/sessions/${sessionId}`);\n }\n\n /** Update a session (generic PATCH). */\n update(sessionId: string, body: UpdateSessionRequest): Promise<SessionView> {\n return this.http.patch<SessionView>(`/sessions/${sessionId}`, body);\n }\n\n /** Stop a session and all its running tasks. */\n stop(sessionId: string): Promise<SessionView> {\n return this.update(sessionId, { action: \"stop\" });\n }\n\n /** Delete a session with all its tasks. */\n delete(sessionId: string): Promise<void> {\n return this.http.delete<void>(`/sessions/${sessionId}`);\n }\n\n /** Get public share information for a session. */\n getShare(sessionId: string): Promise<ShareView> {\n return this.http.get<ShareView>(`/sessions/${sessionId}/public-share`);\n }\n\n /** Create or return existing public share for a session. */\n createShare(sessionId: string): Promise<ShareView> {\n return this.http.post<ShareView>(`/sessions/${sessionId}/public-share`);\n }\n\n /** Remove public share for a session. */\n deleteShare(sessionId: string): Promise<void> {\n return this.http.delete<void>(`/sessions/${sessionId}/public-share`);\n }\n\n /** Purge all session data (ZDR projects only). */\n purge(sessionId: string): Promise<void> {\n return this.http.post<void>(`/sessions/${sessionId}/purge`);\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\n\ntype CreateSkillRequest = components[\"schemas\"][\"CreateSkillRequest\"];\ntype CreateSkillResponse = components[\"schemas\"][\"CreateSkillResponse\"];\ntype ExecuteSkillRequest = components[\"schemas\"][\"ExecuteSkillRequest\"];\ntype ExecuteSkillResponse = components[\"schemas\"][\"ExecuteSkillResponse\"];\ntype RefineSkillRequest = components[\"schemas\"][\"RefineSkillRequest\"];\ntype RefineSkillResponse = components[\"schemas\"][\"RefineSkillResponse\"];\ntype SkillExecutionListResponse = components[\"schemas\"][\"SkillExecutionListResponse\"];\ntype SkillExecutionOutputResponse = components[\"schemas\"][\"SkillExecutionOutputResponse\"];\ntype SkillListResponse = components[\"schemas\"][\"SkillListResponse\"];\ntype SkillResponse = components[\"schemas\"][\"SkillResponse\"];\ntype UpdateSkillRequest = components[\"schemas\"][\"UpdateSkillRequest\"];\n\nexport interface SkillListParams {\n pageSize?: number;\n pageNumber?: number;\n isPublic?: boolean;\n isEnabled?: boolean;\n category?: string;\n query?: string;\n fromDate?: string;\n toDate?: string;\n}\n\nexport interface SkillExecutionListParams {\n pageSize?: number;\n pageNumber?: number;\n}\n\nexport class Skills {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new skill via automated generation. */\n create(body: CreateSkillRequest): Promise<CreateSkillResponse> {\n return this.http.post<CreateSkillResponse>(\"/skills\", body);\n }\n\n /** List all skills owned by the project. */\n list(params?: SkillListParams): Promise<SkillListResponse> {\n return this.http.get<SkillListResponse>(\"/skills\", params as Record<string, unknown>);\n }\n\n /** Get details of a specific skill. */\n get(skillId: string): Promise<SkillResponse> {\n return this.http.get<SkillResponse>(`/skills/${skillId}`);\n }\n\n /** Delete a skill. */\n delete(skillId: string): Promise<void> {\n return this.http.delete<void>(`/skills/${skillId}`);\n }\n\n /** Update skill metadata. */\n update(skillId: string, body: UpdateSkillRequest): Promise<SkillResponse> {\n return this.http.patch<SkillResponse>(`/skills/${skillId}`, body);\n }\n\n /** Cancel the current in-progress generation for a skill. */\n cancel(skillId: string): Promise<SkillResponse> {\n return this.http.post<SkillResponse>(`/skills/${skillId}/cancel`);\n }\n\n /** Execute a skill with the provided parameters. */\n execute(skillId: string, body: ExecuteSkillRequest): Promise<ExecuteSkillResponse> {\n return this.http.post<ExecuteSkillResponse>(`/skills/${skillId}/execute`, body);\n }\n\n /** Refine a skill based on feedback. */\n refine(skillId: string, body: RefineSkillRequest): Promise<RefineSkillResponse> {\n return this.http.post<RefineSkillResponse>(`/skills/${skillId}/refine`, body);\n }\n\n /** Rollback to the previous version. */\n rollback(skillId: string): Promise<SkillResponse> {\n return this.http.post<SkillResponse>(`/skills/${skillId}/rollback`);\n }\n\n /** List executions for a specific skill. */\n executions(skillId: string, params?: SkillExecutionListParams): Promise<SkillExecutionListResponse> {\n return this.http.get<SkillExecutionListResponse>(\n `/skills/${skillId}/executions`,\n params as Record<string, unknown>,\n );\n }\n\n /** Get presigned URL for downloading skill execution output. */\n executionOutput(skillId: string, executionId: string): Promise<SkillExecutionOutputResponse> {\n return this.http.get<SkillExecutionOutputResponse>(\n `/skills/${skillId}/executions/${executionId}/output`,\n );\n }\n}\n","import type { z } from \"zod\";\nimport type { components } from \"../generated/v2/types.js\";\nimport type { Tasks } from \"./resources/tasks.js\";\n\ntype TaskCreatedResponse = components[\"schemas\"][\"TaskCreatedResponse\"];\ntype TaskStepView = components[\"schemas\"][\"TaskStepView\"];\ntype TaskView = components[\"schemas\"][\"TaskView\"];\n\nexport const TERMINAL_STATUSES = new Set([\"finished\", \"stopped\"]);\n\n/** Task result with typed output. All TaskView fields are directly accessible. */\nexport type TaskResult<T = string | null> = Omit<TaskView, \"output\"> & { output: T };\n\nexport interface RunOptions {\n /** Maximum time to wait in milliseconds. Default: 300_000 (5 min). */\n timeout?: number;\n /** Polling interval in milliseconds. Default: 2_000. */\n interval?: number;\n}\n\n/**\n * Lazy task handle returned by `client.run()`.\n *\n * - `await client.run(...)` polls the lightweight status endpoint, returns a `TaskResult`.\n * - `for await (const step of client.run(...))` polls the full task, yields new steps.\n */\nexport class TaskRun<T = string> implements PromiseLike<TaskResult<T>> {\n private readonly _createPromise: Promise<TaskCreatedResponse>;\n private readonly _tasks: Tasks;\n private readonly _schema?: z.ZodType<T>;\n private readonly _timeout: number;\n private readonly _interval: number;\n\n private _taskId: string | null = null;\n private _result: TaskResult<T> | null = null;\n\n constructor(\n createPromise: Promise<TaskCreatedResponse>,\n tasks: Tasks,\n schema?: z.ZodType<T>,\n options?: RunOptions,\n ) {\n this._createPromise = createPromise;\n this._tasks = tasks;\n this._schema = schema;\n this._timeout = options?.timeout ?? 300_000;\n this._interval = options?.interval ?? 2_000;\n }\n\n /** Task ID (available after creation resolves). */\n get taskId(): string | null {\n return this._taskId;\n }\n\n /** Full task result (available after awaiting or iterating to completion). */\n get result(): TaskResult<T> | null {\n return this._result;\n }\n\n /** Enable `await client.run(...)` — polls status endpoint, returns TaskResult. */\n then<R1 = TaskResult<T>, R2 = never>(\n onFulfilled?: ((value: TaskResult<T>) => R1 | PromiseLike<R1>) | null,\n onRejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,\n ): Promise<R1 | R2> {\n return this._waitForOutput().then(onFulfilled, onRejected);\n }\n\n /** Enable `for await (const step of client.run(...))` — polls full task, yields new steps. */\n async *[Symbol.asyncIterator](): AsyncGenerator<TaskStepView> {\n const taskId = await this._ensureTaskId();\n let seen = 0;\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const task = await this._tasks.get(taskId);\n\n for (let i = seen; i < task.steps.length; i++) {\n yield task.steps[i];\n }\n seen = task.steps.length;\n\n if (TERMINAL_STATUSES.has(task.status)) {\n this._result = this._buildResult(task);\n return;\n }\n\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) => setTimeout(r, Math.min(this._interval, remaining)));\n }\n\n throw new Error(`Task ${taskId} did not complete within ${this._timeout}ms`);\n }\n\n private async _ensureTaskId(): Promise<string> {\n if (this._taskId) return this._taskId;\n const created = await this._createPromise;\n this._taskId = created.id;\n return this._taskId;\n }\n\n /** Poll lightweight status endpoint until terminal, return TaskResult. */\n private async _waitForOutput(): Promise<TaskResult<T>> {\n const taskId = await this._ensureTaskId();\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const status = await this._tasks.status(taskId);\n if (TERMINAL_STATUSES.has(status.status)) {\n const task = await this._tasks.get(taskId);\n this._result = this._buildResult(task);\n return this._result;\n }\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) => setTimeout(r, Math.min(this._interval, remaining)));\n }\n\n throw new Error(`Task ${taskId} did not complete within ${this._timeout}ms`);\n }\n\n private _buildResult(task: TaskView): TaskResult<T> {\n const output = this._parseOutput(task.output);\n return { ...task, output };\n }\n\n private _parseOutput(output: string | null | undefined): T {\n if (output == null) return null as T;\n if (!this._schema) return output as unknown as T;\n return this._schema.parse(JSON.parse(output));\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v2/types.js\";\nimport { TERMINAL_STATUSES } from \"../helpers.js\";\n\n/** User-facing body: only `task` is required; everything else has API defaults. */\nexport type CreateTaskBody = Pick<components[\"schemas\"][\"CreateTaskRequest\"], \"task\"> &\n Partial<Omit<components[\"schemas\"][\"CreateTaskRequest\"], \"task\">>;\ntype TaskCreatedResponse = components[\"schemas\"][\"TaskCreatedResponse\"];\ntype TaskListResponse = components[\"schemas\"][\"TaskListResponse\"];\ntype TaskLogFileResponse = components[\"schemas\"][\"TaskLogFileResponse\"];\ntype TaskStatusView = components[\"schemas\"][\"TaskStatusView\"];\ntype TaskView = components[\"schemas\"][\"TaskView\"];\ntype UpdateTaskRequest = components[\"schemas\"][\"UpdateTaskRequest\"];\n\nexport interface TaskListParams {\n pageSize?: number;\n pageNumber?: number;\n sessionId?: string;\n filterBy?: string;\n after?: string;\n before?: string;\n}\n\nexport class Tasks {\n constructor(private readonly http: HttpClient) {}\n\n /** Create and start a new AI agent task. */\n create(body: CreateTaskBody): Promise<TaskCreatedResponse> {\n return this.http.post<TaskCreatedResponse>(\"/tasks\", body);\n }\n\n /** List tasks with optional filtering. */\n list(params?: TaskListParams): Promise<TaskListResponse> {\n return this.http.get<TaskListResponse>(\"/tasks\", params as Record<string, unknown>);\n }\n\n /** Get detailed task information. */\n get(taskId: string): Promise<TaskView> {\n return this.http.get<TaskView>(`/tasks/${taskId}`);\n }\n\n /** Update a task (generic PATCH). */\n update(taskId: string, body: UpdateTaskRequest): Promise<TaskView> {\n return this.http.patch<TaskView>(`/tasks/${taskId}`, body);\n }\n\n /** Stop a running task. */\n stop(taskId: string): Promise<TaskView> {\n return this.update(taskId, { action: \"stop\" });\n }\n\n /** Stop a running task and its associated browser session. */\n stopTaskAndSession(taskId: string): Promise<TaskView> {\n return this.update(taskId, { action: \"stop_task_and_session\" });\n }\n\n /** Get lightweight task status (optimized for polling). */\n status(taskId: string): Promise<TaskStatusView> {\n return this.http.get<TaskStatusView>(`/tasks/${taskId}/status`);\n }\n\n /** Get secure download URL for task execution logs. */\n logs(taskId: string): Promise<TaskLogFileResponse> {\n return this.http.get<TaskLogFileResponse>(`/tasks/${taskId}/logs`);\n }\n\n /** Poll until a task reaches a terminal status, then return the full TaskView. */\n async wait(taskId: string, opts?: { timeout?: number; interval?: number }): Promise<TaskView> {\n const timeout = opts?.timeout ?? 300_000;\n const interval = opts?.interval ?? 2_000;\n const deadline = Date.now() + timeout;\n\n while (Date.now() < deadline) {\n const status = await this.status(taskId);\n if (TERMINAL_STATUSES.has(status.status)) {\n return this.get(taskId);\n }\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) => setTimeout(r, Math.min(interval, remaining)));\n }\n\n throw new Error(`Task ${taskId} did not complete within ${timeout}ms`);\n }\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -118,6 +118,11 @@ interface components {
118
118
  * @default 0
119
119
  */
120
120
  browserCost: string;
121
+ /**
122
+ * Agent Session ID
123
+ * @description ID of the agent session that created this browser (None for standalone BaaS sessions)
124
+ */
125
+ agentSessionId?: string | null;
121
126
  };
122
127
  /**
123
128
  * BrowserSessionListResponse
@@ -225,6 +230,11 @@ interface components {
225
230
  * @default 0
226
231
  */
227
232
  browserCost: string;
233
+ /**
234
+ * Agent Session ID
235
+ * @description ID of the agent session that created this browser (None for standalone BaaS sessions)
236
+ */
237
+ agentSessionId?: string | null;
228
238
  };
229
239
  /**
230
240
  * CannotDeleteSkillWhileGeneratingError
package/dist/index.d.ts CHANGED
@@ -118,6 +118,11 @@ interface components {
118
118
  * @default 0
119
119
  */
120
120
  browserCost: string;
121
+ /**
122
+ * Agent Session ID
123
+ * @description ID of the agent session that created this browser (None for standalone BaaS sessions)
124
+ */
125
+ agentSessionId?: string | null;
121
126
  };
122
127
  /**
123
128
  * BrowserSessionListResponse
@@ -225,6 +230,11 @@ interface components {
225
230
  * @default 0
226
231
  */
227
232
  browserCost: string;
233
+ /**
234
+ * Agent Session ID
235
+ * @description ID of the agent session that created this browser (None for standalone BaaS sessions)
236
+ */
237
+ agentSessionId?: string | null;
228
238
  };
229
239
  /**
230
240
  * CannotDeleteSkillWhileGeneratingError
package/dist/v3.cjs CHANGED
@@ -42,6 +42,63 @@ var Sessions = class {
42
42
  params
43
43
  );
44
44
  }
45
+ /** List messages for a session with cursor-based pagination. */
46
+ messages(sessionId, params) {
47
+ return this.http.get(
48
+ `/sessions/${sessionId}/messages`,
49
+ params
50
+ );
51
+ }
52
+ };
53
+
54
+ // src/v3/resources/workspaces.ts
55
+ var Workspaces = class {
56
+ constructor(http) {
57
+ this.http = http;
58
+ }
59
+ /** List workspaces for the authenticated project. */
60
+ list(params) {
61
+ return this.http.get("/workspaces", params);
62
+ }
63
+ /** Create a new workspace. */
64
+ create(body) {
65
+ return this.http.post("/workspaces", body);
66
+ }
67
+ /** Get workspace details. */
68
+ get(workspaceId) {
69
+ return this.http.get(`/workspaces/${workspaceId}`);
70
+ }
71
+ /** Update a workspace. */
72
+ update(workspaceId, body) {
73
+ return this.http.patch(`/workspaces/${workspaceId}`, body);
74
+ }
75
+ /** Delete a workspace and its data. */
76
+ delete(workspaceId) {
77
+ return this.http.delete(`/workspaces/${workspaceId}`);
78
+ }
79
+ /** List files in a workspace. */
80
+ files(workspaceId, params) {
81
+ return this.http.get(
82
+ `/workspaces/${workspaceId}/files`,
83
+ params
84
+ );
85
+ }
86
+ /** Get presigned upload URLs for workspace files. */
87
+ uploadFiles(workspaceId, body, query) {
88
+ return this.http.post(
89
+ `/workspaces/${workspaceId}/files/upload`,
90
+ body,
91
+ query
92
+ );
93
+ }
94
+ /** Delete a file from a workspace. */
95
+ deleteFile(workspaceId, path) {
96
+ return this.http.delete(`/workspaces/${workspaceId}/files`, { path });
97
+ }
98
+ /** Get storage usage for a workspace. */
99
+ size(workspaceId) {
100
+ return this.http.get(`/workspaces/${workspaceId}/size`);
101
+ }
45
102
  };
46
103
 
47
104
  // src/v3/helpers.ts
@@ -114,6 +171,7 @@ var DEFAULT_BASE_URL = "https://api.browser-use.com/api/v3";
114
171
  var BrowserUse = class {
115
172
 
116
173
 
174
+
117
175
  constructor(options = {}) {
118
176
  const apiKey = _nullishCoalesce(_nullishCoalesce(options.apiKey, () => ( process.env.BROWSER_USE_API_KEY)), () => ( ""));
119
177
  if (!apiKey) {
@@ -128,6 +186,7 @@ var BrowserUse = class {
128
186
  timeout: options.timeout
129
187
  });
130
188
  this.sessions = new Sessions(this.http);
189
+ this.workspaces = new Workspaces(this.http);
131
190
  }
132
191
  run(task, options) {
133
192
  const { schema, timeout, interval, ...rest } = _nullishCoalesce(options, () => ( {}));
@@ -144,5 +203,6 @@ var BrowserUse = class {
144
203
 
145
204
 
146
205
 
147
- exports.BrowserUse = BrowserUse; exports.BrowserUseError = _chunkRIRVOEIUcjs.BrowserUseError; exports.SessionRun = SessionRun; exports.Sessions = Sessions;
206
+
207
+ exports.BrowserUse = BrowserUse; exports.BrowserUseError = _chunkRIRVOEIUcjs.BrowserUseError; exports.SessionRun = SessionRun; exports.Sessions = Sessions; exports.Workspaces = Workspaces;
148
208
  //# sourceMappingURL=v3.cjs.map
package/dist/v3.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/larsencundric/Documents/browser-use/sdk/browser-use-node/dist/v3.cjs","../src/v3/client.ts","../src/v3/resources/sessions.ts","../src/v3/helpers.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,0BAAkB;ADOlB;AACA;AEiBO,IAAM,SAAA,EAAN,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AA;AACtB,QAAA;AACd,MAAA;AACsC,MAAA;AAClB,MAAA;AACV,MAAA;AACoB,QAAA;AAC9B,MAAA;AACF,IAAA;AAEU,IAAA;AACY,MAAA;AACtB,IAAA;AACF,EAAA;AAEyC,EAAA;AACZ,IAAA;AACD,IAAA;AACe,IAAA;AACZ,IAAA;AAC/B,EAAA;AACF;AHQgD;AACA;ACtGvB;AAYD;AACb,EAAA;AAEQ,EAAA;AAE4B,EAAA;AAEf,IAAA;AACf,IAAA;AACD,MAAA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AAC2B,IAAA;AACzB,MAAA;AAC4B,MAAA;AACR,MAAA;AACH,MAAA;AAClB,IAAA;AAEqC,IAAA;AACxC,EAAA;AAiBgE,EAAA;AACnB,IAAA;AACd,IAAA;AACjB,IAAA;AAC+B,MAAA;AAC3C,IAAA;AACyC,IAAA;AACL,IAAA;AACtC,EAAA;AACF;ADyEgD;AACA;AACA;AACA;AACA;AACA","file":"/Users/larsencundric/Documents/browser-use/sdk/browser-use-node/dist/v3.cjs","sourcesContent":[null,"import { z } from \"zod\";\nimport { HttpClient } from \"../core/http.js\";\nimport { Sessions } from \"./resources/sessions.js\";\nimport { SessionRun } from \"./helpers.js\";\nimport type { components } from \"../generated/v3/types.js\";\nimport type { RunOptions } from \"./helpers.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"RunTaskRequest\"];\n\nconst DEFAULT_BASE_URL = \"https://api.browser-use.com/api/v3\";\n\nexport interface BrowserUseOptions {\n apiKey?: string;\n baseUrl?: string;\n maxRetries?: number;\n timeout?: number;\n}\n\nexport type RunSessionOptions = Partial<Omit<RunTaskRequest, \"task\">> &\n RunOptions & { schema?: z.ZodType };\n\nexport class BrowserUse {\n readonly sessions: Sessions;\n\n private readonly http: HttpClient;\n\n constructor(options: BrowserUseOptions = {}) {\n const apiKey =\n options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? \"\";\n if (!apiKey) {\n throw new Error(\n \"No API key provided. Pass apiKey or set BROWSER_USE_API_KEY.\",\n );\n }\n this.http = new HttpClient({\n apiKey,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n maxRetries: options.maxRetries,\n timeout: options.timeout,\n });\n\n this.sessions = new Sessions(this.http);\n }\n\n /**\n * Create a session and run a task. `await` the result for a typed SessionResult.\n *\n * ```ts\n * // Simple — just get the output\n * const result = await client.run(\"Find the top HN post\");\n * console.log(result.output);\n *\n * // Structured output (Zod)\n * const result = await client.run(\"Find product info\", { schema: ProductSchema });\n * console.log(result.output.name); // fully typed\n * ```\n */\n run(task: string, options?: Omit<RunSessionOptions, \"schema\">): SessionRun<string>;\n run<T extends z.ZodType>(task: string, options: RunSessionOptions & { schema: T }): SessionRun<z.output<T>>;\n run(task: string, options?: RunSessionOptions): SessionRun<any> {\n const { schema, timeout, interval, ...rest } = options ?? {};\n const body = { task, ...rest } as RunTaskRequest;\n if (schema) {\n body.outputSchema = z.toJSONSchema(schema) as Record<string, unknown>;\n }\n const promise = this.sessions.create(body);\n return new SessionRun(promise, this.sessions, schema, { timeout, interval });\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v3/types.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"RunTaskRequest\"];\n/** All fields optional — omit `task` to create an idle session. */\nexport type CreateSessionBody = Partial<RunTaskRequest>;\ntype SessionResponse = components[\"schemas\"][\"SessionResponse\"];\ntype SessionListResponse = components[\"schemas\"][\"SessionListResponse\"];\ntype FileListResponse = components[\"schemas\"][\"FileListResponse\"];\ntype StopSessionRequest = components[\"schemas\"][\"StopSessionRequest\"];\ntype FileUploadRequest = components[\"schemas\"][\"FileUploadRequest\"];\ntype FileUploadResponse = components[\"schemas\"][\"FileUploadResponse\"];\n\nexport interface SessionListParams {\n page?: number;\n page_size?: number;\n}\n\nexport interface SessionFilesParams {\n prefix?: string;\n limit?: number;\n cursor?: string | null;\n includeUrls?: boolean;\n}\n\nexport class Sessions {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a session and optionally dispatch a task. */\n create(body?: CreateSessionBody): Promise<SessionResponse> {\n return this.http.post<SessionResponse>(\"/sessions\", body);\n }\n\n /** List sessions for the authenticated project. */\n list(params?: SessionListParams): Promise<SessionListResponse> {\n return this.http.get<SessionListResponse>(\"/sessions\", params as Record<string, unknown>);\n }\n\n /** Get session details. */\n get(sessionId: string): Promise<SessionResponse> {\n return this.http.get<SessionResponse>(`/sessions/${sessionId}`);\n }\n\n /** Stop a session or the running task. */\n stop(sessionId: string, body?: StopSessionRequest): Promise<SessionResponse> {\n return this.http.post<SessionResponse>(`/sessions/${sessionId}/stop`, body);\n }\n\n /** Soft-delete a session. */\n delete(sessionId: string): Promise<void> {\n return this.http.delete<void>(`/sessions/${sessionId}`);\n }\n\n /** Get presigned upload URLs for session files. */\n uploadFiles(sessionId: string, body: FileUploadRequest): Promise<FileUploadResponse> {\n return this.http.post<FileUploadResponse>(`/sessions/${sessionId}/files/upload`, body);\n }\n\n /** List files in a session's workspace. */\n files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse> {\n return this.http.get<FileListResponse>(\n `/sessions/${sessionId}/files`,\n params as Record<string, unknown>,\n );\n }\n}\n","import type { z } from \"zod\";\nimport type { components } from \"../generated/v3/types.js\";\nimport type { Sessions } from \"./resources/sessions.js\";\n\ntype SessionResponse = components[\"schemas\"][\"SessionResponse\"];\n\nconst TERMINAL_STATUSES = new Set([\"idle\", \"stopped\", \"timed_out\", \"error\"]);\n\nexport interface RunOptions {\n /** Maximum time to wait in milliseconds. Default: 300_000 (5 min). */\n timeout?: number;\n /** Polling interval in milliseconds. Default: 2_000. */\n interval?: number;\n}\n\n/** Session result with typed output. All SessionResponse fields are directly accessible. */\nexport type SessionResult<T = string | null> = Omit<SessionResponse, \"output\"> & { output: T };\n\n/**\n * Dual-purpose session handle: `await` it for a typed SessionResult,\n * or access `.result` for the full SessionResult after resolution.\n */\nexport class SessionRun<T = string> implements PromiseLike<SessionResult<T>> {\n private readonly _createPromise: Promise<SessionResponse>;\n private readonly _sessions: Sessions;\n private readonly _schema?: z.ZodType<T>;\n private readonly _timeout: number;\n private readonly _interval: number;\n private _sessionId: string | null = null;\n private _result: SessionResult<T> | null = null;\n\n constructor(\n createPromise: Promise<SessionResponse>,\n sessions: Sessions,\n schema?: z.ZodType<T>,\n options?: RunOptions,\n ) {\n this._createPromise = createPromise;\n this._sessions = sessions;\n this._schema = schema;\n this._timeout = options?.timeout ?? 300_000;\n this._interval = options?.interval ?? 2_000;\n }\n\n /** The session ID, available after task creation resolves. */\n get sessionId(): string | null {\n return this._sessionId;\n }\n\n /** The full SessionResult, available after polling completes. */\n get result(): SessionResult<T> | null {\n return this._result;\n }\n\n /** Enable `await client.run(...)` — polls until terminal, returns SessionResult. */\n then<R1 = SessionResult<T>, R2 = never>(\n onFulfilled?:\n | ((value: SessionResult<T>) => R1 | PromiseLike<R1>)\n | null,\n onRejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,\n ): Promise<R1 | R2> {\n return this._waitForOutput().then(onFulfilled, onRejected);\n }\n\n private async _ensureSessionId(): Promise<string> {\n if (this._sessionId) return this._sessionId;\n const created = await this._createPromise;\n this._sessionId = created.id;\n return this._sessionId;\n }\n\n /** Poll session until terminal, return SessionResult. */\n private async _waitForOutput(): Promise<SessionResult<T>> {\n const sessionId = await this._ensureSessionId();\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const session = await this._sessions.get(sessionId);\n if (TERMINAL_STATUSES.has(session.status)) {\n const { output, ...rest } = session;\n const parsed = this._parseOutput(output);\n this._result = { ...rest, output: parsed } as SessionResult<T>;\n return this._result;\n }\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) =>\n setTimeout(r, Math.min(this._interval, remaining)),\n );\n }\n\n throw new Error(\n `Session ${sessionId} did not complete within ${this._timeout}ms`,\n );\n }\n\n private _parseOutput(output: unknown): T {\n if (output == null) return null as T;\n if (!this._schema) return output as unknown as T;\n const raw = typeof output === \"string\" ? JSON.parse(output) : output;\n return this._schema.parse(raw);\n }\n}\n"]}
1
+ {"version":3,"sources":["/Users/greg/Documents/browser-use/core/sdk/browser-use-node/dist/v3.cjs","../src/v3/client.ts","../src/v3/resources/sessions.ts","../src/v3/resources/workspaces.ts","../src/v3/helpers.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,0BAAkB;ADOlB;AACA;AEyBO,IAAM,SAAA,EAAN,MAAe;AAAA,EACpB,WAAA,CAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,KAAA,EAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,MAAA,CAAO,IAAA,EAAoD;AACzD,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAsB,WAAA,EAAa,IAAI,CAAA;AAAA,EAC1D;AAAA;AAAA,EAGA,IAAA,CAAK,MAAA,EAA0D;AAC7D,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAyB,WAAA,EAAa,MAAiC,CAAA;AAAA,EAC1F;AAAA;AAAA,EAGA,GAAA,CAAI,SAAA,EAA6C;AAC/C,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAqB,CAAA,UAAA,EAAa,SAAS,CAAA,CAAA;AAC9D,EAAA;AAAA;AAG6E,EAAA;AACd,IAAA;AAC/D,EAAA;AAAA;AAGyC,EAAA;AACI,IAAA;AAC7C,EAAA;AAAA;AAGqF,EAAA;AACnB,IAAA;AAClE,EAAA;AAAA;AAGiF,EAAA;AAC9D,IAAA;AACO,MAAA;AACtB,MAAA;AACF,IAAA;AACF,EAAA;AAAA;AAG0F,EAAA;AACvE,IAAA;AACO,MAAA;AACtB,MAAA;AACF,IAAA;AACF,EAAA;AACF;AF7BgD;AACA;AG7BxB;AACyB,EAAA;AAAlB,IAAA;AAAmB,EAAA;AAAA;AAGmB,EAAA;AAC2B,IAAA;AAC9F,EAAA;AAAA;AAG8D,EAAA;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AA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AAC2B,IAAA;AACzB,MAAA;AAC4B,MAAA;AACR,MAAA;AACH,MAAA;AAClB,IAAA;AAEqC,IAAA;AACI,IAAA;AAC5C,EAAA;AAiBgE,EAAA;AACnB,IAAA;AACd,IAAA;AACjB,IAAA;AAC+B,MAAA;AAC3C,IAAA;AACyC,IAAA;AACL,IAAA;AACtC,EAAA;AACF;ADiIgD;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/greg/Documents/browser-use/core/sdk/browser-use-node/dist/v3.cjs","sourcesContent":[null,"import { z } from \"zod\";\nimport { HttpClient } from \"../core/http.js\";\nimport { Sessions } from \"./resources/sessions.js\";\nimport { Workspaces } from \"./resources/workspaces.js\";\nimport { SessionRun } from \"./helpers.js\";\nimport type { components } from \"../generated/v3/types.js\";\nimport type { RunOptions } from \"./helpers.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"RunTaskRequest\"];\n\nconst DEFAULT_BASE_URL = \"https://api.browser-use.com/api/v3\";\n\nexport interface BrowserUseOptions {\n apiKey?: string;\n baseUrl?: string;\n maxRetries?: number;\n timeout?: number;\n}\n\nexport type RunSessionOptions = Partial<Omit<RunTaskRequest, \"task\">> &\n RunOptions & { schema?: z.ZodType };\n\nexport class BrowserUse {\n readonly sessions: Sessions;\n readonly workspaces: Workspaces;\n\n private readonly http: HttpClient;\n\n constructor(options: BrowserUseOptions = {}) {\n const apiKey =\n options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? \"\";\n if (!apiKey) {\n throw new Error(\n \"No API key provided. Pass apiKey or set BROWSER_USE_API_KEY.\",\n );\n }\n this.http = new HttpClient({\n apiKey,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n maxRetries: options.maxRetries,\n timeout: options.timeout,\n });\n\n this.sessions = new Sessions(this.http);\n this.workspaces = new Workspaces(this.http);\n }\n\n /**\n * Create a session and run a task. `await` the result for a typed SessionResult.\n *\n * ```ts\n * // Simple — just get the output\n * const result = await client.run(\"Find the top HN post\");\n * console.log(result.output);\n *\n * // Structured output (Zod)\n * const result = await client.run(\"Find product info\", { schema: ProductSchema });\n * console.log(result.output.name); // fully typed\n * ```\n */\n run(task: string, options?: Omit<RunSessionOptions, \"schema\">): SessionRun<string>;\n run<T extends z.ZodType>(task: string, options: RunSessionOptions & { schema: T }): SessionRun<z.output<T>>;\n run(task: string, options?: RunSessionOptions): SessionRun<any> {\n const { schema, timeout, interval, ...rest } = options ?? {};\n const body = { task, ...rest } as RunTaskRequest;\n if (schema) {\n body.outputSchema = z.toJSONSchema(schema) as Record<string, unknown>;\n }\n const promise = this.sessions.create(body);\n return new SessionRun(promise, this.sessions, schema, { timeout, interval });\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v3/types.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"RunTaskRequest\"];\n/** All fields optional — omit `task` to create an idle session. */\nexport type CreateSessionBody = Partial<RunTaskRequest>;\ntype SessionResponse = components[\"schemas\"][\"SessionResponse\"];\ntype SessionListResponse = components[\"schemas\"][\"SessionListResponse\"];\ntype FileListResponse = components[\"schemas\"][\"FileListResponse\"];\ntype StopSessionRequest = components[\"schemas\"][\"StopSessionRequest\"];\ntype FileUploadRequest = components[\"schemas\"][\"FileUploadRequest\"];\ntype FileUploadResponse = components[\"schemas\"][\"FileUploadResponse\"];\ntype MessageListResponse = components[\"schemas\"][\"MessageListResponse\"];\n\nexport interface SessionListParams {\n page?: number;\n page_size?: number;\n}\n\nexport interface SessionFilesParams {\n prefix?: string;\n limit?: number;\n cursor?: string | null;\n includeUrls?: boolean;\n shallow?: boolean;\n}\n\nexport interface SessionMessagesParams {\n after?: string | null;\n before?: string | null;\n limit?: number;\n}\n\nexport class Sessions {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a session and optionally dispatch a task. */\n create(body?: CreateSessionBody): Promise<SessionResponse> {\n return this.http.post<SessionResponse>(\"/sessions\", body);\n }\n\n /** List sessions for the authenticated project. */\n list(params?: SessionListParams): Promise<SessionListResponse> {\n return this.http.get<SessionListResponse>(\"/sessions\", params as Record<string, unknown>);\n }\n\n /** Get session details. */\n get(sessionId: string): Promise<SessionResponse> {\n return this.http.get<SessionResponse>(`/sessions/${sessionId}`);\n }\n\n /** Stop a session or the running task. */\n stop(sessionId: string, body?: StopSessionRequest): Promise<SessionResponse> {\n return this.http.post<SessionResponse>(`/sessions/${sessionId}/stop`, body);\n }\n\n /** Soft-delete a session. */\n delete(sessionId: string): Promise<void> {\n return this.http.delete<void>(`/sessions/${sessionId}`);\n }\n\n /** Get presigned upload URLs for session files. */\n uploadFiles(sessionId: string, body: FileUploadRequest): Promise<FileUploadResponse> {\n return this.http.post<FileUploadResponse>(`/sessions/${sessionId}/files/upload`, body);\n }\n\n /** List files in a session's workspace. */\n files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse> {\n return this.http.get<FileListResponse>(\n `/sessions/${sessionId}/files`,\n params as Record<string, unknown>,\n );\n }\n\n /** List messages for a session with cursor-based pagination. */\n messages(sessionId: string, params?: SessionMessagesParams): Promise<MessageListResponse> {\n return this.http.get<MessageListResponse>(\n `/sessions/${sessionId}/messages`,\n params as Record<string, unknown>,\n );\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v3/types.js\";\n\ntype WorkspaceView = components[\"schemas\"][\"WorkspaceView\"];\ntype WorkspaceListResponse = components[\"schemas\"][\"WorkspaceListResponse\"];\ntype WorkspaceCreateRequest = components[\"schemas\"][\"WorkspaceCreateRequest\"];\ntype WorkspaceUpdateRequest = components[\"schemas\"][\"WorkspaceUpdateRequest\"];\ntype FileListResponse = components[\"schemas\"][\"FileListResponse\"];\ntype FileUploadRequest = components[\"schemas\"][\"FileUploadRequest\"];\ntype FileUploadResponse = components[\"schemas\"][\"FileUploadResponse\"];\n\nexport interface WorkspaceListParams {\n pageSize?: number;\n pageNumber?: number;\n}\n\nexport interface WorkspaceFilesParams {\n prefix?: string;\n limit?: number;\n cursor?: string | null;\n includeUrls?: boolean;\n shallow?: boolean;\n}\n\nexport class Workspaces {\n constructor(private readonly http: HttpClient) {}\n\n /** List workspaces for the authenticated project. */\n list(params?: WorkspaceListParams): Promise<WorkspaceListResponse> {\n return this.http.get<WorkspaceListResponse>(\"/workspaces\", params as Record<string, unknown>);\n }\n\n /** Create a new workspace. */\n create(body?: WorkspaceCreateRequest): Promise<WorkspaceView> {\n return this.http.post<WorkspaceView>(\"/workspaces\", body);\n }\n\n /** Get workspace details. */\n get(workspaceId: string): Promise<WorkspaceView> {\n return this.http.get<WorkspaceView>(`/workspaces/${workspaceId}`);\n }\n\n /** Update a workspace. */\n update(workspaceId: string, body: WorkspaceUpdateRequest): Promise<WorkspaceView> {\n return this.http.patch<WorkspaceView>(`/workspaces/${workspaceId}`, body);\n }\n\n /** Delete a workspace and its data. */\n delete(workspaceId: string): Promise<void> {\n return this.http.delete<void>(`/workspaces/${workspaceId}`);\n }\n\n /** List files in a workspace. */\n files(workspaceId: string, params?: WorkspaceFilesParams): Promise<FileListResponse> {\n return this.http.get<FileListResponse>(\n `/workspaces/${workspaceId}/files`,\n params as Record<string, unknown>,\n );\n }\n\n /** Get presigned upload URLs for workspace files. */\n uploadFiles(workspaceId: string, body: FileUploadRequest, query?: { prefix?: string }): Promise<FileUploadResponse> {\n return this.http.post<FileUploadResponse>(\n `/workspaces/${workspaceId}/files/upload`,\n body,\n query as Record<string, unknown>,\n );\n }\n\n /** Delete a file from a workspace. */\n deleteFile(workspaceId: string, path: string): Promise<void> {\n return this.http.delete<void>(`/workspaces/${workspaceId}/files`, { path });\n }\n\n /** Get storage usage for a workspace. */\n size(workspaceId: string): Promise<unknown> {\n return this.http.get<unknown>(`/workspaces/${workspaceId}/size`);\n }\n}\n","import type { z } from \"zod\";\nimport type { components } from \"../generated/v3/types.js\";\nimport type { Sessions } from \"./resources/sessions.js\";\n\ntype SessionResponse = components[\"schemas\"][\"SessionResponse\"];\n\nconst TERMINAL_STATUSES = new Set([\"idle\", \"stopped\", \"timed_out\", \"error\"]);\n\nexport interface RunOptions {\n /** Maximum time to wait in milliseconds. Default: 300_000 (5 min). */\n timeout?: number;\n /** Polling interval in milliseconds. Default: 2_000. */\n interval?: number;\n}\n\n/** Session result with typed output. All SessionResponse fields are directly accessible. */\nexport type SessionResult<T = string | null> = Omit<SessionResponse, \"output\"> & { output: T };\n\n/**\n * Dual-purpose session handle: `await` it for a typed SessionResult,\n * or access `.result` for the full SessionResult after resolution.\n */\nexport class SessionRun<T = string> implements PromiseLike<SessionResult<T>> {\n private readonly _createPromise: Promise<SessionResponse>;\n private readonly _sessions: Sessions;\n private readonly _schema?: z.ZodType<T>;\n private readonly _timeout: number;\n private readonly _interval: number;\n private _sessionId: string | null = null;\n private _result: SessionResult<T> | null = null;\n\n constructor(\n createPromise: Promise<SessionResponse>,\n sessions: Sessions,\n schema?: z.ZodType<T>,\n options?: RunOptions,\n ) {\n this._createPromise = createPromise;\n this._sessions = sessions;\n this._schema = schema;\n this._timeout = options?.timeout ?? 300_000;\n this._interval = options?.interval ?? 2_000;\n }\n\n /** The session ID, available after task creation resolves. */\n get sessionId(): string | null {\n return this._sessionId;\n }\n\n /** The full SessionResult, available after polling completes. */\n get result(): SessionResult<T> | null {\n return this._result;\n }\n\n /** Enable `await client.run(...)` — polls until terminal, returns SessionResult. */\n then<R1 = SessionResult<T>, R2 = never>(\n onFulfilled?:\n | ((value: SessionResult<T>) => R1 | PromiseLike<R1>)\n | null,\n onRejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,\n ): Promise<R1 | R2> {\n return this._waitForOutput().then(onFulfilled, onRejected);\n }\n\n private async _ensureSessionId(): Promise<string> {\n if (this._sessionId) return this._sessionId;\n const created = await this._createPromise;\n this._sessionId = created.id;\n return this._sessionId;\n }\n\n /** Poll session until terminal, return SessionResult. */\n private async _waitForOutput(): Promise<SessionResult<T>> {\n const sessionId = await this._ensureSessionId();\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const session = await this._sessions.get(sessionId);\n if (TERMINAL_STATUSES.has(session.status)) {\n const { output, ...rest } = session;\n const parsed = this._parseOutput(output);\n this._result = { ...rest, output: parsed } as SessionResult<T>;\n return this._result;\n }\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) =>\n setTimeout(r, Math.min(this._interval, remaining)),\n );\n }\n\n throw new Error(\n `Session ${sessionId} did not complete within ${this._timeout}ms`,\n );\n }\n\n private _parseOutput(output: unknown): T {\n if (output == null) return null as T;\n if (!this._schema) return output as unknown as T;\n const raw = typeof output === \"string\" ? JSON.parse(output) : output;\n return this._schema.parse(raw);\n }\n}\n"]}
package/dist/v3.d.cts CHANGED
@@ -38,6 +38,11 @@ interface components {
38
38
  FileListResponse: {
39
39
  /** Files */
40
40
  files: components["schemas"]["FileInfo"][];
41
+ /**
42
+ * Folders
43
+ * @description Immediate sub-folder names at this prefix level
44
+ */
45
+ folders?: string[];
41
46
  /** Nextcursor */
42
47
  nextCursor?: string | null;
43
48
  /**
@@ -62,6 +67,11 @@ interface components {
62
67
  * @default application/octet-stream
63
68
  */
64
69
  contentType: string;
70
+ /**
71
+ * Size
72
+ * @description File size in bytes (required for workspace uploads)
73
+ */
74
+ size?: number | null;
65
75
  };
66
76
  /**
67
77
  * FileUploadRequest
@@ -99,6 +109,37 @@ interface components {
99
109
  /** Detail */
100
110
  detail?: components["schemas"]["ValidationError"][];
101
111
  };
112
+ /** MessageListResponse */
113
+ MessageListResponse: {
114
+ /** Messages */
115
+ messages: components["schemas"]["MessageResponse"][];
116
+ /** Hasmore */
117
+ hasMore: boolean;
118
+ };
119
+ /** MessageResponse */
120
+ MessageResponse: {
121
+ /**
122
+ * Id
123
+ * Format: uuid
124
+ */
125
+ id: string;
126
+ /**
127
+ * Sessionid
128
+ * Format: uuid
129
+ */
130
+ sessionId: string;
131
+ /** Role */
132
+ role: string;
133
+ /** Data */
134
+ data: string;
135
+ /** Hidden */
136
+ hidden: boolean;
137
+ /**
138
+ * Createdat
139
+ * Format: date-time
140
+ */
141
+ createdAt: string;
142
+ };
102
143
  /**
103
144
  * ProxyCountryCode
104
145
  * @enum {string}
@@ -129,6 +170,8 @@ interface components {
129
170
  maxCostUsd?: number | string | null;
130
171
  /** Profileid */
131
172
  profileId?: string | null;
173
+ /** Workspaceid */
174
+ workspaceId?: string | null;
132
175
  proxyCountryCode?: components["schemas"]["ProxyCountryCode"] | null;
133
176
  /** Outputschema */
134
177
  outputSchema?: {
@@ -159,10 +202,16 @@ interface components {
159
202
  title?: string | null;
160
203
  /** Output */
161
204
  output?: unknown | null;
205
+ /** Outputschema */
206
+ outputSchema?: {
207
+ [key: string]: unknown;
208
+ } | null;
162
209
  /** Liveurl */
163
210
  liveUrl?: string | null;
164
211
  /** Profileid */
165
212
  profileId?: string | null;
213
+ /** Workspaceid */
214
+ workspaceId?: string | null;
166
215
  proxyCountryCode?: components["schemas"]["ProxyCountryCode"] | null;
167
216
  /** Maxcostusd */
168
217
  maxCostUsd?: string | null;
@@ -226,6 +275,83 @@ interface components {
226
275
  /** Error Type */
227
276
  type: string;
228
277
  };
278
+ /**
279
+ * WorkspaceCreateRequest
280
+ * @description Request model for creating a new workspace.
281
+ */
282
+ WorkspaceCreateRequest: {
283
+ /**
284
+ * Name
285
+ * @description Optional name for the workspace
286
+ */
287
+ name?: string | null;
288
+ };
289
+ /**
290
+ * WorkspaceListResponse
291
+ * @description Response model for paginated workspace list requests.
292
+ */
293
+ WorkspaceListResponse: {
294
+ /**
295
+ * Items
296
+ * @description List of workspace views for the current page
297
+ */
298
+ items: components["schemas"]["WorkspaceView"][];
299
+ /**
300
+ * Total Items
301
+ * @description Total number of items in the list
302
+ */
303
+ totalItems: number;
304
+ /**
305
+ * Page Number
306
+ * @description Page number
307
+ */
308
+ pageNumber: number;
309
+ /**
310
+ * Page Size
311
+ * @description Number of items per page
312
+ */
313
+ pageSize: number;
314
+ };
315
+ /**
316
+ * WorkspaceUpdateRequest
317
+ * @description Request model for updating a workspace.
318
+ */
319
+ WorkspaceUpdateRequest: {
320
+ /**
321
+ * Name
322
+ * @description Optional name for the workspace
323
+ */
324
+ name?: string | null;
325
+ };
326
+ /**
327
+ * WorkspaceView
328
+ * @description View model for a workspace — persistent shared storage across sessions.
329
+ */
330
+ WorkspaceView: {
331
+ /**
332
+ * ID
333
+ * Format: uuid
334
+ * @description Unique identifier for the workspace
335
+ */
336
+ id: string;
337
+ /**
338
+ * Name
339
+ * @description Optional name for the workspace
340
+ */
341
+ name?: string | null;
342
+ /**
343
+ * Created At
344
+ * Format: date-time
345
+ * @description Timestamp when the workspace was created
346
+ */
347
+ createdAt: string;
348
+ /**
349
+ * Updated At
350
+ * Format: date-time
351
+ * @description Timestamp when the workspace was last updated
352
+ */
353
+ updatedAt: string;
354
+ };
229
355
  };
230
356
  responses: never;
231
357
  parameters: never;
@@ -239,10 +365,11 @@ type RunTaskRequest$2 = components["schemas"]["RunTaskRequest"];
239
365
  type CreateSessionBody = Partial<RunTaskRequest$2>;
240
366
  type SessionResponse$2 = components["schemas"]["SessionResponse"];
241
367
  type SessionListResponse$1 = components["schemas"]["SessionListResponse"];
242
- type FileListResponse$1 = components["schemas"]["FileListResponse"];
368
+ type FileListResponse$2 = components["schemas"]["FileListResponse"];
243
369
  type StopSessionRequest$1 = components["schemas"]["StopSessionRequest"];
244
- type FileUploadRequest$1 = components["schemas"]["FileUploadRequest"];
245
- type FileUploadResponse$1 = components["schemas"]["FileUploadResponse"];
370
+ type FileUploadRequest$2 = components["schemas"]["FileUploadRequest"];
371
+ type FileUploadResponse$2 = components["schemas"]["FileUploadResponse"];
372
+ type MessageListResponse$1 = components["schemas"]["MessageListResponse"];
246
373
  interface SessionListParams {
247
374
  page?: number;
248
375
  page_size?: number;
@@ -252,6 +379,12 @@ interface SessionFilesParams {
252
379
  limit?: number;
253
380
  cursor?: string | null;
254
381
  includeUrls?: boolean;
382
+ shallow?: boolean;
383
+ }
384
+ interface SessionMessagesParams {
385
+ after?: string | null;
386
+ before?: string | null;
387
+ limit?: number;
255
388
  }
256
389
  declare class Sessions {
257
390
  private readonly http;
@@ -267,9 +400,54 @@ declare class Sessions {
267
400
  /** Soft-delete a session. */
268
401
  delete(sessionId: string): Promise<void>;
269
402
  /** Get presigned upload URLs for session files. */
270
- uploadFiles(sessionId: string, body: FileUploadRequest$1): Promise<FileUploadResponse$1>;
403
+ uploadFiles(sessionId: string, body: FileUploadRequest$2): Promise<FileUploadResponse$2>;
271
404
  /** List files in a session's workspace. */
272
- files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse$1>;
405
+ files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse$2>;
406
+ /** List messages for a session with cursor-based pagination. */
407
+ messages(sessionId: string, params?: SessionMessagesParams): Promise<MessageListResponse$1>;
408
+ }
409
+
410
+ type WorkspaceView$1 = components["schemas"]["WorkspaceView"];
411
+ type WorkspaceListResponse$1 = components["schemas"]["WorkspaceListResponse"];
412
+ type WorkspaceCreateRequest$1 = components["schemas"]["WorkspaceCreateRequest"];
413
+ type WorkspaceUpdateRequest$1 = components["schemas"]["WorkspaceUpdateRequest"];
414
+ type FileListResponse$1 = components["schemas"]["FileListResponse"];
415
+ type FileUploadRequest$1 = components["schemas"]["FileUploadRequest"];
416
+ type FileUploadResponse$1 = components["schemas"]["FileUploadResponse"];
417
+ interface WorkspaceListParams {
418
+ pageSize?: number;
419
+ pageNumber?: number;
420
+ }
421
+ interface WorkspaceFilesParams {
422
+ prefix?: string;
423
+ limit?: number;
424
+ cursor?: string | null;
425
+ includeUrls?: boolean;
426
+ shallow?: boolean;
427
+ }
428
+ declare class Workspaces {
429
+ private readonly http;
430
+ constructor(http: HttpClient);
431
+ /** List workspaces for the authenticated project. */
432
+ list(params?: WorkspaceListParams): Promise<WorkspaceListResponse$1>;
433
+ /** Create a new workspace. */
434
+ create(body?: WorkspaceCreateRequest$1): Promise<WorkspaceView$1>;
435
+ /** Get workspace details. */
436
+ get(workspaceId: string): Promise<WorkspaceView$1>;
437
+ /** Update a workspace. */
438
+ update(workspaceId: string, body: WorkspaceUpdateRequest$1): Promise<WorkspaceView$1>;
439
+ /** Delete a workspace and its data. */
440
+ delete(workspaceId: string): Promise<void>;
441
+ /** List files in a workspace. */
442
+ files(workspaceId: string, params?: WorkspaceFilesParams): Promise<FileListResponse$1>;
443
+ /** Get presigned upload URLs for workspace files. */
444
+ uploadFiles(workspaceId: string, body: FileUploadRequest$1, query?: {
445
+ prefix?: string;
446
+ }): Promise<FileUploadResponse$1>;
447
+ /** Delete a file from a workspace. */
448
+ deleteFile(workspaceId: string, path: string): Promise<void>;
449
+ /** Get storage usage for a workspace. */
450
+ size(workspaceId: string): Promise<unknown>;
273
451
  }
274
452
 
275
453
  type SessionResponse$1 = components["schemas"]["SessionResponse"];
@@ -320,6 +498,7 @@ type RunSessionOptions = Partial<Omit<RunTaskRequest$1, "task">> & RunOptions &
320
498
  };
321
499
  declare class BrowserUse {
322
500
  readonly sessions: Sessions;
501
+ readonly workspaces: Workspaces;
323
502
  private readonly http;
324
503
  constructor(options?: BrowserUseOptions);
325
504
  /**
@@ -348,13 +527,19 @@ type FileListResponse = S["FileListResponse"];
348
527
  type FileInfo = S["FileInfo"];
349
528
  type FileUploadResponse = S["FileUploadResponse"];
350
529
  type FileUploadResponseItem = S["FileUploadResponseItem"];
530
+ type MessageListResponse = S["MessageListResponse"];
531
+ type MessageResponse = S["MessageResponse"];
532
+ type WorkspaceView = S["WorkspaceView"];
533
+ type WorkspaceListResponse = S["WorkspaceListResponse"];
351
534
  type RunTaskRequest = S["RunTaskRequest"];
352
535
  type StopSessionRequest = S["StopSessionRequest"];
353
536
  type FileUploadRequest = S["FileUploadRequest"];
354
537
  type FileUploadItem = S["FileUploadItem"];
538
+ type WorkspaceCreateRequest = S["WorkspaceCreateRequest"];
539
+ type WorkspaceUpdateRequest = S["WorkspaceUpdateRequest"];
355
540
  type BuAgentSessionStatus = S["BuAgentSessionStatus"];
356
541
  type BuModel = S["BuModel"];
357
542
  type ProxyCountryCode = S["ProxyCountryCode"];
358
543
  type StopStrategy = S["StopStrategy"];
359
544
 
360
- export { BrowserUse, type BrowserUseOptions, type BuAgentSessionStatus, type BuModel, type CreateSessionBody, type FileInfo, type FileListResponse, type FileUploadItem, type FileUploadRequest, type FileUploadResponse, type FileUploadResponseItem, type ProxyCountryCode, type RunOptions, type RunSessionOptions, type RunTaskRequest, type SessionFilesParams, type SessionListParams, type SessionListResponse, type SessionResponse, type SessionResult, SessionRun, Sessions, type StopSessionRequest, type StopStrategy, type components as V3Types };
545
+ export { BrowserUse, type BrowserUseOptions, type BuAgentSessionStatus, type BuModel, type CreateSessionBody, type FileInfo, type FileListResponse, type FileUploadItem, type FileUploadRequest, type FileUploadResponse, type FileUploadResponseItem, type MessageListResponse, type MessageResponse, type ProxyCountryCode, type RunOptions, type RunSessionOptions, type RunTaskRequest, type SessionFilesParams, type SessionListParams, type SessionListResponse, type SessionMessagesParams, type SessionResponse, type SessionResult, SessionRun, Sessions, type StopSessionRequest, type StopStrategy, type components as V3Types, type WorkspaceCreateRequest, type WorkspaceFilesParams, type WorkspaceListParams, type WorkspaceListResponse, type WorkspaceUpdateRequest, type WorkspaceView, Workspaces };
package/dist/v3.d.ts CHANGED
@@ -38,6 +38,11 @@ interface components {
38
38
  FileListResponse: {
39
39
  /** Files */
40
40
  files: components["schemas"]["FileInfo"][];
41
+ /**
42
+ * Folders
43
+ * @description Immediate sub-folder names at this prefix level
44
+ */
45
+ folders?: string[];
41
46
  /** Nextcursor */
42
47
  nextCursor?: string | null;
43
48
  /**
@@ -62,6 +67,11 @@ interface components {
62
67
  * @default application/octet-stream
63
68
  */
64
69
  contentType: string;
70
+ /**
71
+ * Size
72
+ * @description File size in bytes (required for workspace uploads)
73
+ */
74
+ size?: number | null;
65
75
  };
66
76
  /**
67
77
  * FileUploadRequest
@@ -99,6 +109,37 @@ interface components {
99
109
  /** Detail */
100
110
  detail?: components["schemas"]["ValidationError"][];
101
111
  };
112
+ /** MessageListResponse */
113
+ MessageListResponse: {
114
+ /** Messages */
115
+ messages: components["schemas"]["MessageResponse"][];
116
+ /** Hasmore */
117
+ hasMore: boolean;
118
+ };
119
+ /** MessageResponse */
120
+ MessageResponse: {
121
+ /**
122
+ * Id
123
+ * Format: uuid
124
+ */
125
+ id: string;
126
+ /**
127
+ * Sessionid
128
+ * Format: uuid
129
+ */
130
+ sessionId: string;
131
+ /** Role */
132
+ role: string;
133
+ /** Data */
134
+ data: string;
135
+ /** Hidden */
136
+ hidden: boolean;
137
+ /**
138
+ * Createdat
139
+ * Format: date-time
140
+ */
141
+ createdAt: string;
142
+ };
102
143
  /**
103
144
  * ProxyCountryCode
104
145
  * @enum {string}
@@ -129,6 +170,8 @@ interface components {
129
170
  maxCostUsd?: number | string | null;
130
171
  /** Profileid */
131
172
  profileId?: string | null;
173
+ /** Workspaceid */
174
+ workspaceId?: string | null;
132
175
  proxyCountryCode?: components["schemas"]["ProxyCountryCode"] | null;
133
176
  /** Outputschema */
134
177
  outputSchema?: {
@@ -159,10 +202,16 @@ interface components {
159
202
  title?: string | null;
160
203
  /** Output */
161
204
  output?: unknown | null;
205
+ /** Outputschema */
206
+ outputSchema?: {
207
+ [key: string]: unknown;
208
+ } | null;
162
209
  /** Liveurl */
163
210
  liveUrl?: string | null;
164
211
  /** Profileid */
165
212
  profileId?: string | null;
213
+ /** Workspaceid */
214
+ workspaceId?: string | null;
166
215
  proxyCountryCode?: components["schemas"]["ProxyCountryCode"] | null;
167
216
  /** Maxcostusd */
168
217
  maxCostUsd?: string | null;
@@ -226,6 +275,83 @@ interface components {
226
275
  /** Error Type */
227
276
  type: string;
228
277
  };
278
+ /**
279
+ * WorkspaceCreateRequest
280
+ * @description Request model for creating a new workspace.
281
+ */
282
+ WorkspaceCreateRequest: {
283
+ /**
284
+ * Name
285
+ * @description Optional name for the workspace
286
+ */
287
+ name?: string | null;
288
+ };
289
+ /**
290
+ * WorkspaceListResponse
291
+ * @description Response model for paginated workspace list requests.
292
+ */
293
+ WorkspaceListResponse: {
294
+ /**
295
+ * Items
296
+ * @description List of workspace views for the current page
297
+ */
298
+ items: components["schemas"]["WorkspaceView"][];
299
+ /**
300
+ * Total Items
301
+ * @description Total number of items in the list
302
+ */
303
+ totalItems: number;
304
+ /**
305
+ * Page Number
306
+ * @description Page number
307
+ */
308
+ pageNumber: number;
309
+ /**
310
+ * Page Size
311
+ * @description Number of items per page
312
+ */
313
+ pageSize: number;
314
+ };
315
+ /**
316
+ * WorkspaceUpdateRequest
317
+ * @description Request model for updating a workspace.
318
+ */
319
+ WorkspaceUpdateRequest: {
320
+ /**
321
+ * Name
322
+ * @description Optional name for the workspace
323
+ */
324
+ name?: string | null;
325
+ };
326
+ /**
327
+ * WorkspaceView
328
+ * @description View model for a workspace — persistent shared storage across sessions.
329
+ */
330
+ WorkspaceView: {
331
+ /**
332
+ * ID
333
+ * Format: uuid
334
+ * @description Unique identifier for the workspace
335
+ */
336
+ id: string;
337
+ /**
338
+ * Name
339
+ * @description Optional name for the workspace
340
+ */
341
+ name?: string | null;
342
+ /**
343
+ * Created At
344
+ * Format: date-time
345
+ * @description Timestamp when the workspace was created
346
+ */
347
+ createdAt: string;
348
+ /**
349
+ * Updated At
350
+ * Format: date-time
351
+ * @description Timestamp when the workspace was last updated
352
+ */
353
+ updatedAt: string;
354
+ };
229
355
  };
230
356
  responses: never;
231
357
  parameters: never;
@@ -239,10 +365,11 @@ type RunTaskRequest$2 = components["schemas"]["RunTaskRequest"];
239
365
  type CreateSessionBody = Partial<RunTaskRequest$2>;
240
366
  type SessionResponse$2 = components["schemas"]["SessionResponse"];
241
367
  type SessionListResponse$1 = components["schemas"]["SessionListResponse"];
242
- type FileListResponse$1 = components["schemas"]["FileListResponse"];
368
+ type FileListResponse$2 = components["schemas"]["FileListResponse"];
243
369
  type StopSessionRequest$1 = components["schemas"]["StopSessionRequest"];
244
- type FileUploadRequest$1 = components["schemas"]["FileUploadRequest"];
245
- type FileUploadResponse$1 = components["schemas"]["FileUploadResponse"];
370
+ type FileUploadRequest$2 = components["schemas"]["FileUploadRequest"];
371
+ type FileUploadResponse$2 = components["schemas"]["FileUploadResponse"];
372
+ type MessageListResponse$1 = components["schemas"]["MessageListResponse"];
246
373
  interface SessionListParams {
247
374
  page?: number;
248
375
  page_size?: number;
@@ -252,6 +379,12 @@ interface SessionFilesParams {
252
379
  limit?: number;
253
380
  cursor?: string | null;
254
381
  includeUrls?: boolean;
382
+ shallow?: boolean;
383
+ }
384
+ interface SessionMessagesParams {
385
+ after?: string | null;
386
+ before?: string | null;
387
+ limit?: number;
255
388
  }
256
389
  declare class Sessions {
257
390
  private readonly http;
@@ -267,9 +400,54 @@ declare class Sessions {
267
400
  /** Soft-delete a session. */
268
401
  delete(sessionId: string): Promise<void>;
269
402
  /** Get presigned upload URLs for session files. */
270
- uploadFiles(sessionId: string, body: FileUploadRequest$1): Promise<FileUploadResponse$1>;
403
+ uploadFiles(sessionId: string, body: FileUploadRequest$2): Promise<FileUploadResponse$2>;
271
404
  /** List files in a session's workspace. */
272
- files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse$1>;
405
+ files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse$2>;
406
+ /** List messages for a session with cursor-based pagination. */
407
+ messages(sessionId: string, params?: SessionMessagesParams): Promise<MessageListResponse$1>;
408
+ }
409
+
410
+ type WorkspaceView$1 = components["schemas"]["WorkspaceView"];
411
+ type WorkspaceListResponse$1 = components["schemas"]["WorkspaceListResponse"];
412
+ type WorkspaceCreateRequest$1 = components["schemas"]["WorkspaceCreateRequest"];
413
+ type WorkspaceUpdateRequest$1 = components["schemas"]["WorkspaceUpdateRequest"];
414
+ type FileListResponse$1 = components["schemas"]["FileListResponse"];
415
+ type FileUploadRequest$1 = components["schemas"]["FileUploadRequest"];
416
+ type FileUploadResponse$1 = components["schemas"]["FileUploadResponse"];
417
+ interface WorkspaceListParams {
418
+ pageSize?: number;
419
+ pageNumber?: number;
420
+ }
421
+ interface WorkspaceFilesParams {
422
+ prefix?: string;
423
+ limit?: number;
424
+ cursor?: string | null;
425
+ includeUrls?: boolean;
426
+ shallow?: boolean;
427
+ }
428
+ declare class Workspaces {
429
+ private readonly http;
430
+ constructor(http: HttpClient);
431
+ /** List workspaces for the authenticated project. */
432
+ list(params?: WorkspaceListParams): Promise<WorkspaceListResponse$1>;
433
+ /** Create a new workspace. */
434
+ create(body?: WorkspaceCreateRequest$1): Promise<WorkspaceView$1>;
435
+ /** Get workspace details. */
436
+ get(workspaceId: string): Promise<WorkspaceView$1>;
437
+ /** Update a workspace. */
438
+ update(workspaceId: string, body: WorkspaceUpdateRequest$1): Promise<WorkspaceView$1>;
439
+ /** Delete a workspace and its data. */
440
+ delete(workspaceId: string): Promise<void>;
441
+ /** List files in a workspace. */
442
+ files(workspaceId: string, params?: WorkspaceFilesParams): Promise<FileListResponse$1>;
443
+ /** Get presigned upload URLs for workspace files. */
444
+ uploadFiles(workspaceId: string, body: FileUploadRequest$1, query?: {
445
+ prefix?: string;
446
+ }): Promise<FileUploadResponse$1>;
447
+ /** Delete a file from a workspace. */
448
+ deleteFile(workspaceId: string, path: string): Promise<void>;
449
+ /** Get storage usage for a workspace. */
450
+ size(workspaceId: string): Promise<unknown>;
273
451
  }
274
452
 
275
453
  type SessionResponse$1 = components["schemas"]["SessionResponse"];
@@ -320,6 +498,7 @@ type RunSessionOptions = Partial<Omit<RunTaskRequest$1, "task">> & RunOptions &
320
498
  };
321
499
  declare class BrowserUse {
322
500
  readonly sessions: Sessions;
501
+ readonly workspaces: Workspaces;
323
502
  private readonly http;
324
503
  constructor(options?: BrowserUseOptions);
325
504
  /**
@@ -348,13 +527,19 @@ type FileListResponse = S["FileListResponse"];
348
527
  type FileInfo = S["FileInfo"];
349
528
  type FileUploadResponse = S["FileUploadResponse"];
350
529
  type FileUploadResponseItem = S["FileUploadResponseItem"];
530
+ type MessageListResponse = S["MessageListResponse"];
531
+ type MessageResponse = S["MessageResponse"];
532
+ type WorkspaceView = S["WorkspaceView"];
533
+ type WorkspaceListResponse = S["WorkspaceListResponse"];
351
534
  type RunTaskRequest = S["RunTaskRequest"];
352
535
  type StopSessionRequest = S["StopSessionRequest"];
353
536
  type FileUploadRequest = S["FileUploadRequest"];
354
537
  type FileUploadItem = S["FileUploadItem"];
538
+ type WorkspaceCreateRequest = S["WorkspaceCreateRequest"];
539
+ type WorkspaceUpdateRequest = S["WorkspaceUpdateRequest"];
355
540
  type BuAgentSessionStatus = S["BuAgentSessionStatus"];
356
541
  type BuModel = S["BuModel"];
357
542
  type ProxyCountryCode = S["ProxyCountryCode"];
358
543
  type StopStrategy = S["StopStrategy"];
359
544
 
360
- export { BrowserUse, type BrowserUseOptions, type BuAgentSessionStatus, type BuModel, type CreateSessionBody, type FileInfo, type FileListResponse, type FileUploadItem, type FileUploadRequest, type FileUploadResponse, type FileUploadResponseItem, type ProxyCountryCode, type RunOptions, type RunSessionOptions, type RunTaskRequest, type SessionFilesParams, type SessionListParams, type SessionListResponse, type SessionResponse, type SessionResult, SessionRun, Sessions, type StopSessionRequest, type StopStrategy, type components as V3Types };
545
+ export { BrowserUse, type BrowserUseOptions, type BuAgentSessionStatus, type BuModel, type CreateSessionBody, type FileInfo, type FileListResponse, type FileUploadItem, type FileUploadRequest, type FileUploadResponse, type FileUploadResponseItem, type MessageListResponse, type MessageResponse, type ProxyCountryCode, type RunOptions, type RunSessionOptions, type RunTaskRequest, type SessionFilesParams, type SessionListParams, type SessionListResponse, type SessionMessagesParams, type SessionResponse, type SessionResult, SessionRun, Sessions, type StopSessionRequest, type StopStrategy, type components as V3Types, type WorkspaceCreateRequest, type WorkspaceFilesParams, type WorkspaceListParams, type WorkspaceListResponse, type WorkspaceUpdateRequest, type WorkspaceView, Workspaces };
package/dist/v3.js CHANGED
@@ -42,6 +42,63 @@ var Sessions = class {
42
42
  params
43
43
  );
44
44
  }
45
+ /** List messages for a session with cursor-based pagination. */
46
+ messages(sessionId, params) {
47
+ return this.http.get(
48
+ `/sessions/${sessionId}/messages`,
49
+ params
50
+ );
51
+ }
52
+ };
53
+
54
+ // src/v3/resources/workspaces.ts
55
+ var Workspaces = class {
56
+ constructor(http) {
57
+ this.http = http;
58
+ }
59
+ /** List workspaces for the authenticated project. */
60
+ list(params) {
61
+ return this.http.get("/workspaces", params);
62
+ }
63
+ /** Create a new workspace. */
64
+ create(body) {
65
+ return this.http.post("/workspaces", body);
66
+ }
67
+ /** Get workspace details. */
68
+ get(workspaceId) {
69
+ return this.http.get(`/workspaces/${workspaceId}`);
70
+ }
71
+ /** Update a workspace. */
72
+ update(workspaceId, body) {
73
+ return this.http.patch(`/workspaces/${workspaceId}`, body);
74
+ }
75
+ /** Delete a workspace and its data. */
76
+ delete(workspaceId) {
77
+ return this.http.delete(`/workspaces/${workspaceId}`);
78
+ }
79
+ /** List files in a workspace. */
80
+ files(workspaceId, params) {
81
+ return this.http.get(
82
+ `/workspaces/${workspaceId}/files`,
83
+ params
84
+ );
85
+ }
86
+ /** Get presigned upload URLs for workspace files. */
87
+ uploadFiles(workspaceId, body, query) {
88
+ return this.http.post(
89
+ `/workspaces/${workspaceId}/files/upload`,
90
+ body,
91
+ query
92
+ );
93
+ }
94
+ /** Delete a file from a workspace. */
95
+ deleteFile(workspaceId, path) {
96
+ return this.http.delete(`/workspaces/${workspaceId}/files`, { path });
97
+ }
98
+ /** Get storage usage for a workspace. */
99
+ size(workspaceId) {
100
+ return this.http.get(`/workspaces/${workspaceId}/size`);
101
+ }
45
102
  };
46
103
 
47
104
  // src/v3/helpers.ts
@@ -113,6 +170,7 @@ var SessionRun = class {
113
170
  var DEFAULT_BASE_URL = "https://api.browser-use.com/api/v3";
114
171
  var BrowserUse = class {
115
172
  sessions;
173
+ workspaces;
116
174
  http;
117
175
  constructor(options = {}) {
118
176
  const apiKey = options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? "";
@@ -128,6 +186,7 @@ var BrowserUse = class {
128
186
  timeout: options.timeout
129
187
  });
130
188
  this.sessions = new Sessions(this.http);
189
+ this.workspaces = new Workspaces(this.http);
131
190
  }
132
191
  run(task, options) {
133
192
  const { schema, timeout, interval, ...rest } = options ?? {};
@@ -143,6 +202,7 @@ export {
143
202
  BrowserUse,
144
203
  BrowserUseError,
145
204
  SessionRun,
146
- Sessions
205
+ Sessions,
206
+ Workspaces
147
207
  };
148
208
  //# sourceMappingURL=v3.js.map
package/dist/v3.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/v3/client.ts","../src/v3/resources/sessions.ts","../src/v3/helpers.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { HttpClient } from \"../core/http.js\";\nimport { Sessions } from \"./resources/sessions.js\";\nimport { SessionRun } from \"./helpers.js\";\nimport type { components } from \"../generated/v3/types.js\";\nimport type { RunOptions } from \"./helpers.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"RunTaskRequest\"];\n\nconst DEFAULT_BASE_URL = \"https://api.browser-use.com/api/v3\";\n\nexport interface BrowserUseOptions {\n apiKey?: string;\n baseUrl?: string;\n maxRetries?: number;\n timeout?: number;\n}\n\nexport type RunSessionOptions = Partial<Omit<RunTaskRequest, \"task\">> &\n RunOptions & { schema?: z.ZodType };\n\nexport class BrowserUse {\n readonly sessions: Sessions;\n\n private readonly http: HttpClient;\n\n constructor(options: BrowserUseOptions = {}) {\n const apiKey =\n options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? \"\";\n if (!apiKey) {\n throw new Error(\n \"No API key provided. Pass apiKey or set BROWSER_USE_API_KEY.\",\n );\n }\n this.http = new HttpClient({\n apiKey,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n maxRetries: options.maxRetries,\n timeout: options.timeout,\n });\n\n this.sessions = new Sessions(this.http);\n }\n\n /**\n * Create a session and run a task. `await` the result for a typed SessionResult.\n *\n * ```ts\n * // Simple — just get the output\n * const result = await client.run(\"Find the top HN post\");\n * console.log(result.output);\n *\n * // Structured output (Zod)\n * const result = await client.run(\"Find product info\", { schema: ProductSchema });\n * console.log(result.output.name); // fully typed\n * ```\n */\n run(task: string, options?: Omit<RunSessionOptions, \"schema\">): SessionRun<string>;\n run<T extends z.ZodType>(task: string, options: RunSessionOptions & { schema: T }): SessionRun<z.output<T>>;\n run(task: string, options?: RunSessionOptions): SessionRun<any> {\n const { schema, timeout, interval, ...rest } = options ?? {};\n const body = { task, ...rest } as RunTaskRequest;\n if (schema) {\n body.outputSchema = z.toJSONSchema(schema) as Record<string, unknown>;\n }\n const promise = this.sessions.create(body);\n return new SessionRun(promise, this.sessions, schema, { timeout, interval });\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v3/types.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"RunTaskRequest\"];\n/** All fields optional — omit `task` to create an idle session. */\nexport type CreateSessionBody = Partial<RunTaskRequest>;\ntype SessionResponse = components[\"schemas\"][\"SessionResponse\"];\ntype SessionListResponse = components[\"schemas\"][\"SessionListResponse\"];\ntype FileListResponse = components[\"schemas\"][\"FileListResponse\"];\ntype StopSessionRequest = components[\"schemas\"][\"StopSessionRequest\"];\ntype FileUploadRequest = components[\"schemas\"][\"FileUploadRequest\"];\ntype FileUploadResponse = components[\"schemas\"][\"FileUploadResponse\"];\n\nexport interface SessionListParams {\n page?: number;\n page_size?: number;\n}\n\nexport interface SessionFilesParams {\n prefix?: string;\n limit?: number;\n cursor?: string | null;\n includeUrls?: boolean;\n}\n\nexport class Sessions {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a session and optionally dispatch a task. */\n create(body?: CreateSessionBody): Promise<SessionResponse> {\n return this.http.post<SessionResponse>(\"/sessions\", body);\n }\n\n /** List sessions for the authenticated project. */\n list(params?: SessionListParams): Promise<SessionListResponse> {\n return this.http.get<SessionListResponse>(\"/sessions\", params as Record<string, unknown>);\n }\n\n /** Get session details. */\n get(sessionId: string): Promise<SessionResponse> {\n return this.http.get<SessionResponse>(`/sessions/${sessionId}`);\n }\n\n /** Stop a session or the running task. */\n stop(sessionId: string, body?: StopSessionRequest): Promise<SessionResponse> {\n return this.http.post<SessionResponse>(`/sessions/${sessionId}/stop`, body);\n }\n\n /** Soft-delete a session. */\n delete(sessionId: string): Promise<void> {\n return this.http.delete<void>(`/sessions/${sessionId}`);\n }\n\n /** Get presigned upload URLs for session files. */\n uploadFiles(sessionId: string, body: FileUploadRequest): Promise<FileUploadResponse> {\n return this.http.post<FileUploadResponse>(`/sessions/${sessionId}/files/upload`, body);\n }\n\n /** List files in a session's workspace. */\n files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse> {\n return this.http.get<FileListResponse>(\n `/sessions/${sessionId}/files`,\n params as Record<string, unknown>,\n );\n }\n}\n","import type { z } from \"zod\";\nimport type { components } from \"../generated/v3/types.js\";\nimport type { Sessions } from \"./resources/sessions.js\";\n\ntype SessionResponse = components[\"schemas\"][\"SessionResponse\"];\n\nconst TERMINAL_STATUSES = new Set([\"idle\", \"stopped\", \"timed_out\", \"error\"]);\n\nexport interface RunOptions {\n /** Maximum time to wait in milliseconds. Default: 300_000 (5 min). */\n timeout?: number;\n /** Polling interval in milliseconds. Default: 2_000. */\n interval?: number;\n}\n\n/** Session result with typed output. All SessionResponse fields are directly accessible. */\nexport type SessionResult<T = string | null> = Omit<SessionResponse, \"output\"> & { output: T };\n\n/**\n * Dual-purpose session handle: `await` it for a typed SessionResult,\n * or access `.result` for the full SessionResult after resolution.\n */\nexport class SessionRun<T = string> implements PromiseLike<SessionResult<T>> {\n private readonly _createPromise: Promise<SessionResponse>;\n private readonly _sessions: Sessions;\n private readonly _schema?: z.ZodType<T>;\n private readonly _timeout: number;\n private readonly _interval: number;\n private _sessionId: string | null = null;\n private _result: SessionResult<T> | null = null;\n\n constructor(\n createPromise: Promise<SessionResponse>,\n sessions: Sessions,\n schema?: z.ZodType<T>,\n options?: RunOptions,\n ) {\n this._createPromise = createPromise;\n this._sessions = sessions;\n this._schema = schema;\n this._timeout = options?.timeout ?? 300_000;\n this._interval = options?.interval ?? 2_000;\n }\n\n /** The session ID, available after task creation resolves. */\n get sessionId(): string | null {\n return this._sessionId;\n }\n\n /** The full SessionResult, available after polling completes. */\n get result(): SessionResult<T> | null {\n return this._result;\n }\n\n /** Enable `await client.run(...)` — polls until terminal, returns SessionResult. */\n then<R1 = SessionResult<T>, R2 = never>(\n onFulfilled?:\n | ((value: SessionResult<T>) => R1 | PromiseLike<R1>)\n | null,\n onRejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,\n ): Promise<R1 | R2> {\n return this._waitForOutput().then(onFulfilled, onRejected);\n }\n\n private async _ensureSessionId(): Promise<string> {\n if (this._sessionId) return this._sessionId;\n const created = await this._createPromise;\n this._sessionId = created.id;\n return this._sessionId;\n }\n\n /** Poll session until terminal, return SessionResult. */\n private async _waitForOutput(): Promise<SessionResult<T>> {\n const sessionId = await this._ensureSessionId();\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const session = await this._sessions.get(sessionId);\n if (TERMINAL_STATUSES.has(session.status)) {\n const { output, ...rest } = session;\n const parsed = this._parseOutput(output);\n this._result = { ...rest, output: parsed } as SessionResult<T>;\n return this._result;\n }\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) =>\n setTimeout(r, Math.min(this._interval, remaining)),\n );\n }\n\n throw new Error(\n `Session ${sessionId} did not complete within ${this._timeout}ms`,\n );\n }\n\n private _parseOutput(output: unknown): T {\n if (output == null) return null as T;\n if (!this._schema) return output as unknown as T;\n const raw = typeof output === \"string\" ? JSON.parse(output) : output;\n return this._schema.parse(raw);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAS,SAAS;;;ACyBX,IAAM,WAAN,MAAe;AAAA,EACpB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA;AAAA,EAGhD,OAAO,MAAoD;AACzD,WAAO,KAAK,KAAK,KAAsB,aAAa,IAAI;AAAA,EAC1D;AAAA;AAAA,EAGA,KAAK,QAA0D;AAC7D,WAAO,KAAK,KAAK,IAAyB,aAAa,MAAiC;AAAA,EAC1F;A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AAQ;AAAA,MACpB,SAAS,QAAQ;AAAA,IACnB,CAAC;AAED,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AAAA,EACxC;AAAA,EAiBA,IAAI,MAAc,SAA8C;AAC9D,UAAM,EAAE,QAAQ,SAAS,UAAU,GAAG,KAAK,IAAI,WAAW,CAAC;AAC3D,UAAM,OAAO,EAAE,MAAM,GAAG,KAAK;AAC7B,QAAI,QAAQ;AACV,WAAK,eAAe,EAAE,aAAa,MAAM;AAAA,IAC3C;AACA,UAAM,UAAU,KAAK,SAAS,OAAO,IAAI;AACzC,WAAO,IAAI,WAAW,SAAS,KAAK,UAAU,QAAQ,EAAE,SAAS,SAAS,CAAC;AAAA,EAC7E;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/v3/client.ts","../src/v3/resources/sessions.ts","../src/v3/resources/workspaces.ts","../src/v3/helpers.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { HttpClient } from \"../core/http.js\";\nimport { Sessions } from \"./resources/sessions.js\";\nimport { Workspaces } from \"./resources/workspaces.js\";\nimport { SessionRun } from \"./helpers.js\";\nimport type { components } from \"../generated/v3/types.js\";\nimport type { RunOptions } from \"./helpers.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"RunTaskRequest\"];\n\nconst DEFAULT_BASE_URL = \"https://api.browser-use.com/api/v3\";\n\nexport interface BrowserUseOptions {\n apiKey?: string;\n baseUrl?: string;\n maxRetries?: number;\n timeout?: number;\n}\n\nexport type RunSessionOptions = Partial<Omit<RunTaskRequest, \"task\">> &\n RunOptions & { schema?: z.ZodType };\n\nexport class BrowserUse {\n readonly sessions: Sessions;\n readonly workspaces: Workspaces;\n\n private readonly http: HttpClient;\n\n constructor(options: BrowserUseOptions = {}) {\n const apiKey =\n options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? \"\";\n if (!apiKey) {\n throw new Error(\n \"No API key provided. Pass apiKey or set BROWSER_USE_API_KEY.\",\n );\n }\n this.http = new HttpClient({\n apiKey,\n baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,\n maxRetries: options.maxRetries,\n timeout: options.timeout,\n });\n\n this.sessions = new Sessions(this.http);\n this.workspaces = new Workspaces(this.http);\n }\n\n /**\n * Create a session and run a task. `await` the result for a typed SessionResult.\n *\n * ```ts\n * // Simple — just get the output\n * const result = await client.run(\"Find the top HN post\");\n * console.log(result.output);\n *\n * // Structured output (Zod)\n * const result = await client.run(\"Find product info\", { schema: ProductSchema });\n * console.log(result.output.name); // fully typed\n * ```\n */\n run(task: string, options?: Omit<RunSessionOptions, \"schema\">): SessionRun<string>;\n run<T extends z.ZodType>(task: string, options: RunSessionOptions & { schema: T }): SessionRun<z.output<T>>;\n run(task: string, options?: RunSessionOptions): SessionRun<any> {\n const { schema, timeout, interval, ...rest } = options ?? {};\n const body = { task, ...rest } as RunTaskRequest;\n if (schema) {\n body.outputSchema = z.toJSONSchema(schema) as Record<string, unknown>;\n }\n const promise = this.sessions.create(body);\n return new SessionRun(promise, this.sessions, schema, { timeout, interval });\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v3/types.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"RunTaskRequest\"];\n/** All fields optional — omit `task` to create an idle session. */\nexport type CreateSessionBody = Partial<RunTaskRequest>;\ntype SessionResponse = components[\"schemas\"][\"SessionResponse\"];\ntype SessionListResponse = components[\"schemas\"][\"SessionListResponse\"];\ntype FileListResponse = components[\"schemas\"][\"FileListResponse\"];\ntype StopSessionRequest = components[\"schemas\"][\"StopSessionRequest\"];\ntype FileUploadRequest = components[\"schemas\"][\"FileUploadRequest\"];\ntype FileUploadResponse = components[\"schemas\"][\"FileUploadResponse\"];\ntype MessageListResponse = components[\"schemas\"][\"MessageListResponse\"];\n\nexport interface SessionListParams {\n page?: number;\n page_size?: number;\n}\n\nexport interface SessionFilesParams {\n prefix?: string;\n limit?: number;\n cursor?: string | null;\n includeUrls?: boolean;\n shallow?: boolean;\n}\n\nexport interface SessionMessagesParams {\n after?: string | null;\n before?: string | null;\n limit?: number;\n}\n\nexport class Sessions {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a session and optionally dispatch a task. */\n create(body?: CreateSessionBody): Promise<SessionResponse> {\n return this.http.post<SessionResponse>(\"/sessions\", body);\n }\n\n /** List sessions for the authenticated project. */\n list(params?: SessionListParams): Promise<SessionListResponse> {\n return this.http.get<SessionListResponse>(\"/sessions\", params as Record<string, unknown>);\n }\n\n /** Get session details. */\n get(sessionId: string): Promise<SessionResponse> {\n return this.http.get<SessionResponse>(`/sessions/${sessionId}`);\n }\n\n /** Stop a session or the running task. */\n stop(sessionId: string, body?: StopSessionRequest): Promise<SessionResponse> {\n return this.http.post<SessionResponse>(`/sessions/${sessionId}/stop`, body);\n }\n\n /** Soft-delete a session. */\n delete(sessionId: string): Promise<void> {\n return this.http.delete<void>(`/sessions/${sessionId}`);\n }\n\n /** Get presigned upload URLs for session files. */\n uploadFiles(sessionId: string, body: FileUploadRequest): Promise<FileUploadResponse> {\n return this.http.post<FileUploadResponse>(`/sessions/${sessionId}/files/upload`, body);\n }\n\n /** List files in a session's workspace. */\n files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse> {\n return this.http.get<FileListResponse>(\n `/sessions/${sessionId}/files`,\n params as Record<string, unknown>,\n );\n }\n\n /** List messages for a session with cursor-based pagination. */\n messages(sessionId: string, params?: SessionMessagesParams): Promise<MessageListResponse> {\n return this.http.get<MessageListResponse>(\n `/sessions/${sessionId}/messages`,\n params as Record<string, unknown>,\n );\n }\n}\n","import type { HttpClient } from \"../../core/http.js\";\nimport type { components } from \"../../generated/v3/types.js\";\n\ntype WorkspaceView = components[\"schemas\"][\"WorkspaceView\"];\ntype WorkspaceListResponse = components[\"schemas\"][\"WorkspaceListResponse\"];\ntype WorkspaceCreateRequest = components[\"schemas\"][\"WorkspaceCreateRequest\"];\ntype WorkspaceUpdateRequest = components[\"schemas\"][\"WorkspaceUpdateRequest\"];\ntype FileListResponse = components[\"schemas\"][\"FileListResponse\"];\ntype FileUploadRequest = components[\"schemas\"][\"FileUploadRequest\"];\ntype FileUploadResponse = components[\"schemas\"][\"FileUploadResponse\"];\n\nexport interface WorkspaceListParams {\n pageSize?: number;\n pageNumber?: number;\n}\n\nexport interface WorkspaceFilesParams {\n prefix?: string;\n limit?: number;\n cursor?: string | null;\n includeUrls?: boolean;\n shallow?: boolean;\n}\n\nexport class Workspaces {\n constructor(private readonly http: HttpClient) {}\n\n /** List workspaces for the authenticated project. */\n list(params?: WorkspaceListParams): Promise<WorkspaceListResponse> {\n return this.http.get<WorkspaceListResponse>(\"/workspaces\", params as Record<string, unknown>);\n }\n\n /** Create a new workspace. */\n create(body?: WorkspaceCreateRequest): Promise<WorkspaceView> {\n return this.http.post<WorkspaceView>(\"/workspaces\", body);\n }\n\n /** Get workspace details. */\n get(workspaceId: string): Promise<WorkspaceView> {\n return this.http.get<WorkspaceView>(`/workspaces/${workspaceId}`);\n }\n\n /** Update a workspace. */\n update(workspaceId: string, body: WorkspaceUpdateRequest): Promise<WorkspaceView> {\n return this.http.patch<WorkspaceView>(`/workspaces/${workspaceId}`, body);\n }\n\n /** Delete a workspace and its data. */\n delete(workspaceId: string): Promise<void> {\n return this.http.delete<void>(`/workspaces/${workspaceId}`);\n }\n\n /** List files in a workspace. */\n files(workspaceId: string, params?: WorkspaceFilesParams): Promise<FileListResponse> {\n return this.http.get<FileListResponse>(\n `/workspaces/${workspaceId}/files`,\n params as Record<string, unknown>,\n );\n }\n\n /** Get presigned upload URLs for workspace files. */\n uploadFiles(workspaceId: string, body: FileUploadRequest, query?: { prefix?: string }): Promise<FileUploadResponse> {\n return this.http.post<FileUploadResponse>(\n `/workspaces/${workspaceId}/files/upload`,\n body,\n query as Record<string, unknown>,\n );\n }\n\n /** Delete a file from a workspace. */\n deleteFile(workspaceId: string, path: string): Promise<void> {\n return this.http.delete<void>(`/workspaces/${workspaceId}/files`, { path });\n }\n\n /** Get storage usage for a workspace. */\n size(workspaceId: string): Promise<unknown> {\n return this.http.get<unknown>(`/workspaces/${workspaceId}/size`);\n }\n}\n","import type { z } from \"zod\";\nimport type { components } from \"../generated/v3/types.js\";\nimport type { Sessions } from \"./resources/sessions.js\";\n\ntype SessionResponse = components[\"schemas\"][\"SessionResponse\"];\n\nconst TERMINAL_STATUSES = new Set([\"idle\", \"stopped\", \"timed_out\", \"error\"]);\n\nexport interface RunOptions {\n /** Maximum time to wait in milliseconds. Default: 300_000 (5 min). */\n timeout?: number;\n /** Polling interval in milliseconds. Default: 2_000. */\n interval?: number;\n}\n\n/** Session result with typed output. All SessionResponse fields are directly accessible. */\nexport type SessionResult<T = string | null> = Omit<SessionResponse, \"output\"> & { output: T };\n\n/**\n * Dual-purpose session handle: `await` it for a typed SessionResult,\n * or access `.result` for the full SessionResult after resolution.\n */\nexport class SessionRun<T = string> implements PromiseLike<SessionResult<T>> {\n private readonly _createPromise: Promise<SessionResponse>;\n private readonly _sessions: Sessions;\n private readonly _schema?: z.ZodType<T>;\n private readonly _timeout: number;\n private readonly _interval: number;\n private _sessionId: string | null = null;\n private _result: SessionResult<T> | null = null;\n\n constructor(\n createPromise: Promise<SessionResponse>,\n sessions: Sessions,\n schema?: z.ZodType<T>,\n options?: RunOptions,\n ) {\n this._createPromise = createPromise;\n this._sessions = sessions;\n this._schema = schema;\n this._timeout = options?.timeout ?? 300_000;\n this._interval = options?.interval ?? 2_000;\n }\n\n /** The session ID, available after task creation resolves. */\n get sessionId(): string | null {\n return this._sessionId;\n }\n\n /** The full SessionResult, available after polling completes. */\n get result(): SessionResult<T> | null {\n return this._result;\n }\n\n /** Enable `await client.run(...)` — polls until terminal, returns SessionResult. */\n then<R1 = SessionResult<T>, R2 = never>(\n onFulfilled?:\n | ((value: SessionResult<T>) => R1 | PromiseLike<R1>)\n | null,\n onRejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,\n ): Promise<R1 | R2> {\n return this._waitForOutput().then(onFulfilled, onRejected);\n }\n\n private async _ensureSessionId(): Promise<string> {\n if (this._sessionId) return this._sessionId;\n const created = await this._createPromise;\n this._sessionId = created.id;\n return this._sessionId;\n }\n\n /** Poll session until terminal, return SessionResult. */\n private async _waitForOutput(): Promise<SessionResult<T>> {\n const sessionId = await this._ensureSessionId();\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const session = await this._sessions.get(sessionId);\n if (TERMINAL_STATUSES.has(session.status)) {\n const { output, ...rest } = session;\n const parsed = this._parseOutput(output);\n this._result = { ...rest, output: parsed } as SessionResult<T>;\n return this._result;\n }\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) =>\n setTimeout(r, Math.min(this._interval, remaining)),\n );\n }\n\n throw new Error(\n `Session ${sessionId} did not complete within ${this._timeout}ms`,\n );\n }\n\n private _parseOutput(output: unknown): T {\n if (output == null) return null as T;\n if (!this._schema) return output as unknown as T;\n const raw = typeof output === \"string\" ? JSON.parse(output) : output;\n return this._schema.parse(raw);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAS,SAAS;;;ACiCX,IAAM,WAAN,MAAe;AAAA,EACpB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA;AAAA,EAGhD,OAAO,MAAoD;AACzD,WAAO,KAAK,KAAK,KAAsB,aAAa,IAAI;AAAA,EAC1D;AAAA;AAAA,EAGA,KAAK,QAA0D;AAC7D,WAAO,KAAK,KAAK,IAAyB,aAAa,MAAiC;AAAA,EAC1F;AAAA;AAAA,EAGA,IAAI,WAA6C;AAC/C,WAAO,KAAK,KAAK,IAAqB,aAAa,SAAS,EAAE;AAAA,EAChE;AAAA;AAAA,EAGA,KAAK,WAAmB,MAAqD;AAC3E,WAAO,KAAK,KAAK,KAAsB,aAAa,SAAS,SAAS,IAAI;AAAA,EAC5E;AAAA;AAAA,EAGA,OAAO,WAAkC;AACvC,WAAO,KAAK,KAAK,OAAa,aAAa,SAAS,EAAE;AAAA,EACxD;AAAA;AAAA,EAGA,YAAY,WAAmB,MAAsD;AACnF,WAA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AAW,SAAS,KAAK,UAAU,QAAQ,EAAE,SAAS,SAAS,CAAC;AAAA,EAC7E;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-use-sdk",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Official TypeScript SDK for the Browser Use API",
5
5
  "author": "Browser Use",
6
6
  "license": "MIT",