browser-use-sdk 3.5.0 → 3.8.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.
- package/README.md +12 -0
- package/dist/chunk-ESJIWN3M.js +175 -0
- package/dist/chunk-ESJIWN3M.js.map +1 -0
- package/dist/chunk-QMK4AUMH.cjs +175 -0
- package/dist/chunk-QMK4AUMH.cjs.map +1 -0
- package/dist/errors-DaHgFhIQ.d.cts +69 -0
- package/dist/errors-DaHgFhIQ.d.ts +69 -0
- package/dist/index.cjs +35 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +34 -13
- package/dist/index.js.map +1 -1
- package/dist/v3.cjs +45 -17
- package/dist/v3.cjs.map +1 -1
- package/dist/v3.d.cts +147 -124
- package/dist/v3.d.ts +147 -124
- package/dist/v3.js +45 -17
- package/dist/v3.js.map +1 -1
- package/package.json +17 -1
- package/dist/chunk-6TSB5AIP.js +0 -99
- package/dist/chunk-6TSB5AIP.js.map +0 -1
- package/dist/chunk-JT4IL3IZ.cjs +0 -99
- package/dist/chunk-JT4IL3IZ.cjs.map +0 -1
- package/dist/errors-BtB79l7x.d.cts +0 -30
- package/dist/errors-BtB79l7x.d.ts +0 -30
package/dist/v3.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/sauravpanda/Github/LLMs/Browser-Use/sdk/browser-use-node/dist/v3.cjs","../src/v3/client.ts","../src/v3/resources/billing.ts","../src/v3/resources/browsers.ts","../src/v3/resources/profiles.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;AEHO,IAAM,QAAA,EAAN,MAAc;AAAA,EACnB,WAAA,CAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,KA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;AACE,IAAA;AACA,IAAA;AACA,IAAA;AACI,IAAA;AAC5C,EAAA;AAiBgE,EAAA;AACnB,IAAA;AACd,IAAA;AACF,IAAA;AACI,MAAA;AAC/B,IAAA;AACY,IAAA;AAC0B,MAAA;AACxB,QAAA;AACR,UAAA;AAEF,QAAA;AACF,MAAA;AACyC,MAAA;AAC3C,IAAA;AAEyC,IAAA;AACtB,MAAA;AACnB,IAAA;AAGoB,IAAA;AACD,MAAA;AACK,MAAA;AAClB,MAAA;AAEe,MAAA;AAEiB,QAAA;AACZ,QAAA;AAEW,MAAA;AAGC,MAAA;AAClC,QAAA;AACA,QAAA;AACmB,QAAA;AAAS,UAAA;AAAa,QAAA;AAC1C,MAAA;AACH,IAAA;AACyC,IAAA;AACL,IAAA;AACtC,EAAA;AACF;AD0WgD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/sauravpanda/Github/LLMs/Browser-Use/sdk/browser-use-node/dist/v3.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 { Profiles } from \"./resources/profiles.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 billing: Billing;\n readonly browsers: Browsers;\n readonly profiles: Profiles;\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.billing = new Billing(this.http);\n this.browsers = new Browsers(this.http);\n this.profiles = new Profiles(this.http);\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 (body.proxyCountryCode) {\n body.proxyCountryCode = body.proxyCountryCode.toLowerCase() as any;\n }\n if (schema) {\n if (typeof schema !== \"object\" || !(\"_zod\" in schema || \"_def\" in schema)) {\n throw new Error(\n \"schema must be a Zod schema (e.g. z.object({...})). \" +\n \"Make sure you are using Zod v4: npm install zod@4\"\n );\n }\n body.outputSchema = z.toJSONSchema(schema) as Record<string, unknown>;\n }\n // Auto keep_alive when dispatching to an existing session\n if (body.sessionId && body.keepAlive === undefined) {\n body.keepAlive = true;\n }\n // For follow-up runs on an existing session, snapshot the latest message\n // cursor before creating the new task so the iterator skips old messages.\n if (body.sessionId) {\n const sid = body.sessionId;\n const sessions = this.sessions;\n let startCursor: string | undefined;\n const promise = sessions\n .messages(sid, { limit: 1 })\n .then((resp) => {\n const last = resp.messages[resp.messages.length - 1];\n startCursor = last?.id;\n })\n .then(() => sessions.create(body));\n // startCursor is set before createPromise resolves, so the iterator\n // (which awaits _ensureSessionId first) will see the correct value.\n return new SessionRun(promise, this.sessions, schema, {\n timeout,\n interval,\n get _startCursor() { return startCursor; },\n });\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 AccountView = components[\"schemas\"][\"AccountView\"];\n\nexport class Billing {\n constructor(private readonly http: HttpClient) {}\n\n /** Get account billing information. */\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/v3/types.js\";\n\ntype CreateBrowserSessionRequest = components[\"schemas\"][\"CreateBrowserSessionRequest\"];\ntype BrowserSessionItemView = components[\"schemas\"][\"BrowserSessionItemView\"];\ntype BrowserSessionView = components[\"schemas\"][\"BrowserSessionView\"];\ntype BrowserSessionListResponse = components[\"schemas\"][\"BrowserSessionListResponse\"];\ntype UpdateBrowserSessionRequest = components[\"schemas\"][\"UpdateBrowserSessionRequest\"];\ntype BrowserDownloadListResponse = components[\"schemas\"][\"BrowserDownloadListResponse\"];\n\nexport interface BrowserListParams {\n page?: number;\n page_size?: number;\n}\n\nexport interface BrowserDownloadsParams {\n limit?: number;\n cursor?: string;\n includeUrls?: boolean;\n}\n\nexport class Browsers {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a standalone browser session. */\n create(body: Partial<CreateBrowserSessionRequest> = {}): Promise<BrowserSessionItemView> {\n return this.http.post<BrowserSessionItemView>(\"/browsers\", body);\n }\n\n /** List browser sessions for the authenticated project. */\n list(params?: BrowserListParams): Promise<BrowserSessionListResponse> {\n return this.http.get<BrowserSessionListResponse>(\"/browsers\", params as Record<string, unknown>);\n }\n\n /** Get browser session details. */\n get(sessionId: string): Promise<BrowserSessionView> {\n return this.http.get<BrowserSessionView>(`/browsers/${sessionId}`);\n }\n\n /** Update a browser session (e.g. stop it). */\n update(sessionId: string, body: UpdateBrowserSessionRequest): Promise<BrowserSessionView> {\n return this.http.patch<BrowserSessionView>(`/browsers/${sessionId}`, body);\n }\n\n /** Stop a browser session. Convenience wrapper around update. */\n stop(sessionId: string): Promise<BrowserSessionView> {\n return this.update(sessionId, { action: \"stop\" });\n }\n\n /** List files the browser downloaded to S3 during the session. */\n downloads(sessionId: string, params?: BrowserDownloadsParams): Promise<BrowserDownloadListResponse> {\n return this.http.get<BrowserDownloadListResponse>(\n `/browsers/${sessionId}/downloads`,\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 ProfileView = components[\"schemas\"][\"ProfileView\"];\ntype ProfileListResponse = components[\"schemas\"][\"ProfileListResponse\"];\ntype ProfileCreateRequest = components[\"schemas\"][\"ProfileCreateRequest\"];\ntype ProfileUpdateRequest = components[\"schemas\"][\"ProfileUpdateRequest\"];\n\nexport interface ProfileListParams {\n query?: string;\n page?: number;\n page_size?: number;\n}\n\nexport class Profiles {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a browser profile. */\n create(body?: ProfileCreateRequest): Promise<ProfileView> {\n return this.http.post<ProfileView>(\"/profiles\", body);\n }\n\n /** List profiles for the authenticated project. */\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 profile. */\n update(profileId: string, body: ProfileUpdateRequest): Promise<ProfileView> {\n return this.http.patch<ProfileView>(`/profiles/${profileId}`, body);\n }\n\n /** Delete a 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/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 StopSessionRequest = components[\"schemas\"][\"StopSessionRequest\"];\ntype MessageListResponse = components[\"schemas\"][\"MessageListResponse\"];\n\nexport interface SessionListParams {\n page?: number;\n page_size?: number;\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 /** 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 /**\n * Poll until recording URLs are available. Returns presigned MP4 URLs.\n *\n * Returns an empty array if no recording was produced (e.g. the agent\n * answered without opening a browser, or recording was not enabled).\n */\n async waitForRecording(\n sessionId: string,\n options?: { timeout?: number; interval?: number },\n ): Promise<string[]> {\n const timeout = options?.timeout ?? 15_000;\n const interval = options?.interval ?? 2_000;\n const deadline = Date.now() + timeout;\n while (Date.now() < deadline) {\n const session = await this.get(sessionId);\n if (session.recordingUrls?.length) return session.recordingUrls;\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) => setTimeout(r, Math.min(interval, remaining)));\n }\n return [];\n }\n}\n","import { readFileSync, writeFileSync, mkdirSync, statSync } from \"fs\";\nimport { basename, dirname, extname, join, resolve } from \"path\";\nimport type { HttpClient } from \"../../core/http.js\";\n\nfunction safeJoin(base: string, untrusted: string): string {\n const baseResolved = resolve(base) + \"/\";\n const resolved = resolve(base, untrusted);\n if (resolved !== resolve(base) && !resolved.startsWith(baseResolved)) {\n throw new Error(`Path traversal detected: ${untrusted}`);\n }\n return resolved;\n}\n\nconst MIME_TYPES: Record<string, string> = {\n \".csv\": \"text/csv\",\n \".json\": \"application/json\",\n \".txt\": \"text/plain\",\n \".md\": \"text/markdown\",\n \".html\": \"text/html\",\n \".xml\": \"application/xml\",\n \".yaml\": \"application/yaml\",\n \".yml\": \"application/yaml\",\n \".pdf\": \"application/pdf\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".svg\": \"image/svg+xml\",\n \".mp4\": \"video/mp4\",\n \".mp3\": \"audio/mpeg\",\n \".wav\": \"audio/wav\",\n \".zip\": \"application/zip\",\n \".gz\": \"application/gzip\",\n \".tar\": \"application/x-tar\",\n \".xlsx\": \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \".xls\": \"application/vnd.ms-excel\",\n \".docx\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \".doc\": \"application/msword\",\n \".pptx\": \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n};\n\nfunction guessContentType(path: string): string {\n return MIME_TYPES[extname(path).toLowerCase()] ?? \"application/octet-stream\";\n}\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 /**\n * Upload local files to a workspace. Returns the list of remote paths.\n *\n * ```ts\n * await client.workspaces.upload(wsId, \"data.csv\", \"config.json\");\n * await client.workspaces.upload(wsId, \"data.csv\", { prefix: \"uploads/\" });\n * ```\n */\n async upload(workspaceId: string, ...args: (string | { prefix?: string })[]): Promise<string[]> {\n let prefix: string | undefined;\n const paths: string[] = [];\n for (const arg of args) {\n if (typeof arg === \"string\") {\n paths.push(arg);\n } else if (typeof arg === \"object\" && arg !== null) {\n prefix = arg.prefix;\n }\n }\n if (paths.length === 0) {\n throw new Error(\"At least one file path is required\");\n }\n const items = paths.map((p) => ({\n name: basename(p),\n contentType: guessContentType(p),\n size: statSync(p).size,\n }));\n const resp = await this.uploadFiles(workspaceId, { files: items }, prefix ? { prefix } : undefined);\n for (let i = 0; i < paths.length; i++) {\n const body = readFileSync(paths[i]);\n const res = await fetch(resp.files[i].uploadUrl, {\n method: \"PUT\",\n headers: { \"Content-Type\": items[i].contentType },\n body,\n });\n if (!res.ok) throw new Error(`Upload failed: ${res.status} ${res.statusText}`);\n }\n return resp.files.map((f) => f.path);\n }\n\n /**\n * Download a single file from a workspace. Returns the local path.\n *\n * ```ts\n * const local = await client.workspaces.download(wsId, \"uploads/data.csv\", { to: \"./data.csv\" });\n * ```\n */\n async download(workspaceId: string, path: string, options?: { to?: string }): Promise<string> {\n const fileList = await this.files(workspaceId, { prefix: path, includeUrls: true });\n const match = fileList.files?.find((f) => f.path === path);\n if (!match) throw new Error(`File not found in workspace: ${path}`);\n const dest = options?.to ?? basename(match.path);\n mkdirSync(dirname(dest), { recursive: true });\n const resp = await fetch(match.url!);\n if (!resp.ok) throw new Error(`Download failed: ${resp.status}`);\n writeFileSync(dest, Buffer.from(await resp.arrayBuffer()));\n return dest;\n }\n\n /**\n * Download all files from a workspace. Returns list of local paths.\n *\n * ```ts\n * const paths = await client.workspaces.downloadAll(wsId, { to: \"./output\" });\n * ```\n */\n async downloadAll(workspaceId: string, options?: { to?: string; prefix?: string }): Promise<string[]> {\n const destDir = options?.to ?? \".\";\n mkdirSync(destDir, { recursive: true });\n const results: string[] = [];\n let cursor: string | undefined;\n do {\n const fileList = await this.files(workspaceId, {\n prefix: options?.prefix,\n includeUrls: true,\n cursor,\n });\n for (const f of fileList.files ?? []) {\n const local = safeJoin(destDir, f.path);\n mkdirSync(dirname(local), { recursive: true });\n const resp = await fetch(f.url!);\n if (!resp.ok) throw new Error(`Download failed for ${f.path}: ${resp.status}`);\n writeFileSync(local, Buffer.from(await resp.arrayBuffer()));\n results.push(local);\n }\n cursor = fileList.hasMore ? (fileList.nextCursor ?? undefined) : undefined;\n } while (cursor);\n return results;\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\"];\ntype MessageResponse = components[\"schemas\"][\"MessageResponse\"];\n\nconst TERMINAL_STATUSES = new Set([\"idle\", \"stopped\", \"timed_out\", \"error\"]);\n\nexport interface RunOptions {\n /** Maximum time to wait in milliseconds. Default: 14_400_000 (4 hours). */\n timeout?: number;\n /** Polling interval in milliseconds. Default: 2_000. */\n interval?: number;\n /** @internal Starting message cursor for follow-up runs on an existing session. */\n _startCursor?: string;\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 readonly _options?: RunOptions;\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 ?? 14_400_000;\n this._interval = options?.interval ?? 2_000;\n this._options = options;\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 /**\n * Enable `for await (const msg of client.run(...))` — yields messages as they appear.\n * After iteration, `.result` contains the final SessionResult.\n */\n async *[Symbol.asyncIterator](): AsyncGenerator<MessageResponse> {\n const sessionId = await this._ensureSessionId();\n let cursor: string | undefined = this._options?._startCursor;\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const resp = await this._sessions.messages(sessionId, { after: cursor, limit: 100 });\n for (const msg of resp.messages) {\n yield msg;\n cursor = msg.id;\n }\n\n const session = await this._sessions.get(sessionId);\n if (TERMINAL_STATUSES.has(session.status)) {\n // Drain all remaining messages (may be multiple pages)\n while (true) {\n const page = await this._sessions.messages(sessionId, { after: cursor, limit: 100 });\n if (!page.messages.length) break;\n for (const msg of page.messages) {\n yield msg;\n cursor = msg.id;\n }\n }\n const { output, ...rest } = session;\n this._result = { ...rest, output: this._parseOutput(output) } as SessionResult<T>;\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(`Session ${sessionId} did not complete within ${this._timeout}ms`);\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/larsencundric/Documents/browser-use/sdk/browser-use-node/dist/v3.cjs","../src/v3/client.ts","../src/v3/resources/billing.ts","../src/v3/resources/browsers.ts","../src/v3/resources/profiles.ts","../src/v3/resources/sessions.ts","../src/v3/resources/workspaces.ts","../src/v3/helpers.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACTA,0BAAkB;ADWlB;AACA;AEPO,IAAM,QAAA,EAAN,MAAc;AAAA,EACnB,WAAA,CAA6B,IAAA,EAAkB;AA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A,QAAA;AACnC,MAAA;AAGsB,MAAA;AAAE,MAAA;AACA,MAAA;AACjB,QAAA;AACoB,QAAA;AACR,QAAA;AACH,QAAA;AACV,QAAA;AACR,MAAA;AACI,IAAA;AAEuB,MAAA;AACf,MAAA;AACD,QAAA;AACR,UAAA;AAGF,QAAA;AACF,MAAA;AAC2B,MAAA;AACzB,QAAA;AAC4B,QAAA;AACR,QAAA;AACH,QAAA;AAClB,MAAA;AACH,IAAA;AAEoC,IAAA;AACE,IAAA;AACA,IAAA;AACI,IAAA;AACA,IAAA;AAC5C,EAAA;AAiBgE,EAAA;AACnB,IAAA;AACd,IAAA;AACF,IAAA;AACI,MAAA;AAC/B,IAAA;AACY,IAAA;AAC0B,MAAA;AACxB,QAAA;AACR,UAAA;AAEF,QAAA;AACF,MAAA;AACyC,MAAA;AAC3C,IAAA;AAEyC,IAAA;AACtB,MAAA;AACnB,IAAA;AAGoB,IAAA;AACD,MAAA;AACK,MAAA;AAClB,MAAA;AAEe,MAAA;AAEiB,QAAA;AACZ,QAAA;AAEW,MAAA;AAGC,MAAA;AAClC,QAAA;AACA,QAAA;AACmB,QAAA;AAAS,UAAA;AAAa,QAAA;AAC1C,MAAA;AACH,IAAA;AACyC,IAAA;AACL,IAAA;AACtC,EAAA;AACF;ADmVgD;AACA;AACA;AACA;AACA;AACA;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 {\n X402_BASE_URL_DEFAULT,\n type X402Client,\n wrapFetchWithX402,\n x402ClientFromPrivateKey,\n} from \"../core/x402.js\";\nimport { Billing } from \"./resources/billing.js\";\nimport { Browsers } from \"./resources/browsers.js\";\nimport { Profiles } from \"./resources/profiles.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\"][\"app__endpoints__api__v3__sessions__views__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 * Use your own LLM API key configured in Browser Use project settings for v3 agent runs.\n */\n useOwnKey?: boolean;\n /**\n * Pre-built x402 client (advanced — for custom signers / multi-network).\n * If set, the SDK uses pay-per-request authentication via USDC instead of\n * an API key. Requires the optional peer deps `@x402/fetch`, `@x402/evm`,\n * and `viem`.\n */\n x402?: X402Client;\n /**\n * EVM wallet private key for x402 mode. Equivalent to building an x402\n * client from this key and passing it as `x402`. Falls back to\n * `BROWSER_USE_X402_PRIVATE_KEY`.\n */\n x402PrivateKey?: string;\n}\n\nexport type RunSessionOptions = Partial<Omit<RunTaskRequest, \"task\">> &\n RunOptions & { schema?: z.ZodType };\n\nexport class BrowserUse {\n readonly billing: Billing;\n readonly browsers: Browsers;\n readonly profiles: Profiles;\n readonly sessions: Sessions;\n readonly workspaces: Workspaces;\n\n private readonly http: HttpClient;\n\n constructor(options: BrowserUseOptions = {}) {\n const x402PrivateKey =\n options.x402PrivateKey ?? process.env.BROWSER_USE_X402_PRIVATE_KEY;\n\n if (options.x402 || x402PrivateKey) {\n // x402 mode — defer x402 client + wrapped fetch resolution to first request.\n // If apiKey is also set, it's forwarded as a header so the backend\n // credits the API key's project (top-up mode) instead of one keyed\n // to the wallet.\n const topupKey = options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? \"\";\n const fetchPromise = (async () => {\n const x402Client = options.x402 ?? (await x402ClientFromPrivateKey(x402PrivateKey!));\n return wrapFetchWithX402(globalThis.fetch, x402Client);\n })();\n // Suppress unhandled-rejection warnings if the user constructs the client\n // but never makes a request\n fetchPromise.catch(() => {});\n this.http = new HttpClient({\n apiKey: topupKey,\n baseUrl: options.baseUrl ?? X402_BASE_URL_DEFAULT,\n maxRetries: options.maxRetries,\n timeout: options.timeout,\n fetch: fetchPromise,\n });\n } else {\n const apiKey =\n options.apiKey ?? process.env.BROWSER_USE_API_KEY ?? \"\";\n if (!apiKey) {\n throw new Error(\n \"No credentials provided. Pass apiKey / set BROWSER_USE_API_KEY, \" +\n \"or pass x402PrivateKey / set BROWSER_USE_X402_PRIVATE_KEY for \" +\n \"pay-per-request access via USDC.\",\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\n this.billing = new Billing(this.http);\n this.browsers = new Browsers(this.http);\n this.profiles = new Profiles(this.http);\n this.sessions = new Sessions(this.http, { useOwnKey: options.useOwnKey });\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 (body.proxyCountryCode) {\n body.proxyCountryCode = body.proxyCountryCode.toLowerCase() as any;\n }\n if (schema) {\n if (typeof schema !== \"object\" || !(\"_zod\" in schema || \"_def\" in schema)) {\n throw new Error(\n \"schema must be a Zod schema (e.g. z.object({...})). \" +\n \"Make sure you are using Zod v4: npm install zod@4\"\n );\n }\n body.outputSchema = z.toJSONSchema(schema) as Record<string, unknown>;\n }\n // Auto keep_alive when dispatching to an existing session\n if (body.sessionId && body.keepAlive === undefined) {\n body.keepAlive = true;\n }\n // For follow-up runs on an existing session, snapshot the latest message\n // cursor before creating the new task so the iterator skips old messages.\n if (body.sessionId) {\n const sid = body.sessionId;\n const sessions = this.sessions;\n let startCursor: string | undefined;\n const promise = sessions\n .messages(sid, { limit: 1 })\n .then((resp) => {\n const last = resp.messages[resp.messages.length - 1];\n startCursor = last?.id;\n })\n .then(() => sessions.create(body));\n // startCursor is set before createPromise resolves, so the iterator\n // (which awaits _ensureSessionId first) will see the correct value.\n return new SessionRun(promise, this.sessions, schema, {\n timeout,\n interval,\n get _startCursor() { return startCursor; },\n });\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 AccountView = components[\"schemas\"][\"AccountView\"];\n\nexport class Billing {\n constructor(private readonly http: HttpClient) {}\n\n /** Get account billing information. */\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/v3/types.js\";\n\ntype CreateBrowserSessionRequest = components[\"schemas\"][\"CreateBrowserSessionRequest\"];\ntype BrowserSessionItemView = components[\"schemas\"][\"BrowserSessionItemView\"];\ntype BrowserSessionView = components[\"schemas\"][\"BrowserSessionView\"];\ntype BrowserSessionListResponse = components[\"schemas\"][\"BrowserSessionListResponse\"];\ntype UpdateBrowserSessionRequest = components[\"schemas\"][\"UpdateBrowserSessionRequest\"];\ntype BrowserDownloadListResponse = components[\"schemas\"][\"BrowserDownloadListResponse\"];\n\nexport interface BrowserListParams {\n page?: number;\n page_size?: number;\n}\n\nexport interface BrowserDownloadsParams {\n limit?: number;\n cursor?: string;\n includeUrls?: boolean;\n}\n\nexport class Browsers {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a standalone browser session. */\n create(body: Partial<CreateBrowserSessionRequest> = {}): Promise<BrowserSessionItemView> {\n return this.http.post<BrowserSessionItemView>(\"/browsers\", body);\n }\n\n /** List browser sessions for the authenticated project. */\n list(params?: BrowserListParams): Promise<BrowserSessionListResponse> {\n return this.http.get<BrowserSessionListResponse>(\"/browsers\", params as Record<string, unknown>);\n }\n\n /** Get browser session details. */\n get(sessionId: string): Promise<BrowserSessionView> {\n return this.http.get<BrowserSessionView>(`/browsers/${sessionId}`);\n }\n\n /** Update a browser session (e.g. stop it). */\n update(sessionId: string, body: UpdateBrowserSessionRequest): Promise<BrowserSessionView> {\n return this.http.patch<BrowserSessionView>(`/browsers/${sessionId}`, body);\n }\n\n /** Stop a browser session. Convenience wrapper around update. */\n stop(sessionId: string): Promise<BrowserSessionView> {\n return this.update(sessionId, { action: \"stop\" });\n }\n\n /** List files the browser downloaded to S3 during the session. */\n downloads(sessionId: string, params?: BrowserDownloadsParams): Promise<BrowserDownloadListResponse> {\n return this.http.get<BrowserDownloadListResponse>(\n `/browsers/${sessionId}/downloads`,\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 ProfileView = components[\"schemas\"][\"ProfileView\"];\ntype ProfileListResponse = components[\"schemas\"][\"ProfileListResponse\"];\ntype ProfileCreateRequest = components[\"schemas\"][\"ProfileCreateRequest\"];\ntype ProfileUpdateRequest = components[\"schemas\"][\"ProfileUpdateRequest\"];\n\nexport interface ProfileListParams {\n query?: string;\n page?: number;\n page_size?: number;\n}\n\nexport class Profiles {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a browser profile. */\n create(body?: ProfileCreateRequest): Promise<ProfileView> {\n return this.http.post<ProfileView>(\"/profiles\", body);\n }\n\n /** List profiles for the authenticated project. */\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 profile. */\n update(profileId: string, body: ProfileUpdateRequest): Promise<ProfileView> {\n return this.http.patch<ProfileView>(`/profiles/${profileId}`, body);\n }\n\n /** Delete a 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/v3/types.js\";\n\ntype RunTaskRequest = components[\"schemas\"][\"app__endpoints__api__v3__sessions__views__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 StopSessionRequest = components[\"schemas\"][\"StopSessionRequest\"];\ntype MessageListResponse = components[\"schemas\"][\"MessageListResponse\"];\n\nexport interface SessionListParams {\n page?: number;\n page_size?: number;\n}\n\nexport interface SessionMessagesParams {\n after?: string | null;\n before?: string | null;\n limit?: number;\n}\n\nexport interface SessionsOptions {\n useOwnKey?: boolean;\n}\n\nexport class Sessions {\n constructor(\n private readonly http: HttpClient,\n private readonly options: SessionsOptions = {},\n ) {}\n\n /** Create a session and optionally dispatch a task. */\n create(body?: CreateSessionBody): Promise<SessionResponse> {\n const requestBody = { ...(body ?? {}) };\n if (\n this.options.useOwnKey !== undefined &&\n requestBody.useOwnKey === undefined\n ) {\n requestBody.useOwnKey = this.options.useOwnKey;\n }\n return this.http.post<SessionResponse>(\"/sessions\", requestBody);\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 /** 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 /**\n * Poll until recording URLs are available. Returns presigned MP4 URLs.\n *\n * Returns an empty array if no recording was produced (e.g. the agent\n * answered without opening a browser, or recording was not enabled).\n */\n async waitForRecording(\n sessionId: string,\n options?: { timeout?: number; interval?: number },\n ): Promise<string[]> {\n const timeout = options?.timeout ?? 15_000;\n const interval = options?.interval ?? 2_000;\n const deadline = Date.now() + timeout;\n while (Date.now() < deadline) {\n const session = await this.get(sessionId);\n if (session.recordingUrls?.length) return session.recordingUrls;\n const remaining = deadline - Date.now();\n if (remaining <= 0) break;\n await new Promise((r) => setTimeout(r, Math.min(interval, remaining)));\n }\n return [];\n }\n}\n","import { readFileSync, writeFileSync, mkdirSync, statSync } from \"fs\";\nimport { basename, dirname, extname, join, resolve } from \"path\";\nimport type { HttpClient } from \"../../core/http.js\";\n\nfunction safeJoin(base: string, untrusted: string): string {\n const baseResolved = resolve(base) + \"/\";\n const resolved = resolve(base, untrusted);\n if (resolved !== resolve(base) && !resolved.startsWith(baseResolved)) {\n throw new Error(`Path traversal detected: ${untrusted}`);\n }\n return resolved;\n}\n\nconst MIME_TYPES: Record<string, string> = {\n \".csv\": \"text/csv\",\n \".json\": \"application/json\",\n \".txt\": \"text/plain\",\n \".md\": \"text/markdown\",\n \".html\": \"text/html\",\n \".xml\": \"application/xml\",\n \".yaml\": \"application/yaml\",\n \".yml\": \"application/yaml\",\n \".pdf\": \"application/pdf\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".svg\": \"image/svg+xml\",\n \".mp4\": \"video/mp4\",\n \".mp3\": \"audio/mpeg\",\n \".wav\": \"audio/wav\",\n \".zip\": \"application/zip\",\n \".gz\": \"application/gzip\",\n \".tar\": \"application/x-tar\",\n \".xlsx\": \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \".xls\": \"application/vnd.ms-excel\",\n \".docx\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \".doc\": \"application/msword\",\n \".pptx\": \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n};\n\nfunction guessContentType(path: string): string {\n return MIME_TYPES[extname(path).toLowerCase()] ?? \"application/octet-stream\";\n}\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 /**\n * Upload local files to a workspace. Returns the list of remote paths.\n *\n * ```ts\n * await client.workspaces.upload(wsId, \"data.csv\", \"config.json\");\n * await client.workspaces.upload(wsId, \"data.csv\", { prefix: \"uploads/\" });\n * ```\n */\n async upload(workspaceId: string, ...args: (string | { prefix?: string })[]): Promise<string[]> {\n let prefix: string | undefined;\n const paths: string[] = [];\n for (const arg of args) {\n if (typeof arg === \"string\") {\n paths.push(arg);\n } else if (typeof arg === \"object\" && arg !== null) {\n prefix = arg.prefix;\n }\n }\n if (paths.length === 0) {\n throw new Error(\"At least one file path is required\");\n }\n const items = paths.map((p) => ({\n name: basename(p),\n contentType: guessContentType(p),\n size: statSync(p).size,\n }));\n const resp = await this.uploadFiles(workspaceId, { files: items }, prefix ? { prefix } : undefined);\n for (let i = 0; i < paths.length; i++) {\n const body = readFileSync(paths[i]);\n const res = await fetch(resp.files[i].uploadUrl, {\n method: \"PUT\",\n headers: { \"Content-Type\": items[i].contentType },\n body,\n });\n if (!res.ok) throw new Error(`Upload failed: ${res.status} ${res.statusText}`);\n }\n return resp.files.map((f) => f.path);\n }\n\n /**\n * Download a single file from a workspace. Returns the local path.\n *\n * ```ts\n * const local = await client.workspaces.download(wsId, \"uploads/data.csv\", { to: \"./data.csv\" });\n * ```\n */\n async download(workspaceId: string, path: string, options?: { to?: string }): Promise<string> {\n const fileList = await this.files(workspaceId, { prefix: path, includeUrls: true });\n const match = fileList.files?.find((f) => f.path === path);\n if (!match) throw new Error(`File not found in workspace: ${path}`);\n const dest = options?.to ?? basename(match.path);\n mkdirSync(dirname(dest), { recursive: true });\n const resp = await fetch(match.url!);\n if (!resp.ok) throw new Error(`Download failed: ${resp.status}`);\n writeFileSync(dest, Buffer.from(await resp.arrayBuffer()));\n return dest;\n }\n\n /**\n * Download all files from a workspace. Returns list of local paths.\n *\n * ```ts\n * const paths = await client.workspaces.downloadAll(wsId, { to: \"./output\" });\n * ```\n */\n async downloadAll(workspaceId: string, options?: { to?: string; prefix?: string }): Promise<string[]> {\n const destDir = options?.to ?? \".\";\n mkdirSync(destDir, { recursive: true });\n const results: string[] = [];\n let cursor: string | undefined;\n do {\n const fileList = await this.files(workspaceId, {\n prefix: options?.prefix,\n includeUrls: true,\n cursor,\n });\n for (const f of fileList.files ?? []) {\n const local = safeJoin(destDir, f.path);\n mkdirSync(dirname(local), { recursive: true });\n const resp = await fetch(f.url!);\n if (!resp.ok) throw new Error(`Download failed for ${f.path}: ${resp.status}`);\n writeFileSync(local, Buffer.from(await resp.arrayBuffer()));\n results.push(local);\n }\n cursor = fileList.hasMore ? (fileList.nextCursor ?? undefined) : undefined;\n } while (cursor);\n return results;\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\"];\ntype MessageResponse = components[\"schemas\"][\"MessageResponse\"];\n\nconst TERMINAL_STATUSES = new Set([\"idle\", \"stopped\", \"timed_out\", \"error\"]);\n\nexport interface RunOptions {\n /** Maximum time to wait in milliseconds. Default: 14_400_000 (4 hours). */\n timeout?: number;\n /** Polling interval in milliseconds. Default: 2_000. */\n interval?: number;\n /** @internal Starting message cursor for follow-up runs on an existing session. */\n _startCursor?: string;\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 readonly _options?: RunOptions;\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 ?? 14_400_000;\n this._interval = options?.interval ?? 2_000;\n this._options = options;\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 /**\n * Enable `for await (const msg of client.run(...))` — yields messages as they appear.\n * After iteration, `.result` contains the final SessionResult.\n */\n async *[Symbol.asyncIterator](): AsyncGenerator<MessageResponse> {\n const sessionId = await this._ensureSessionId();\n let cursor: string | undefined = this._options?._startCursor;\n const deadline = Date.now() + this._timeout;\n\n while (Date.now() < deadline) {\n const resp = await this._sessions.messages(sessionId, { after: cursor, limit: 100 });\n for (const msg of resp.messages) {\n yield msg;\n cursor = msg.id;\n }\n\n const session = await this._sessions.get(sessionId);\n if (TERMINAL_STATUSES.has(session.status)) {\n // Drain all remaining messages (may be multiple pages)\n while (true) {\n const page = await this._sessions.messages(sessionId, { after: cursor, limit: 100 });\n if (!page.messages.length) break;\n for (const msg of page.messages) {\n yield msg;\n cursor = msg.id;\n }\n }\n const { output, ...rest } = session;\n this._result = { ...rest, output: this._parseOutput(output) } as SessionResult<T>;\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(`Session ${sessionId} did not complete within ${this._timeout}ms`);\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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { H as HttpClient } from './errors-
|
|
3
|
-
export { B as BrowserUseError } from './errors-
|
|
2
|
+
import { H as HttpClient, X as X402Client } from './errors-DaHgFhIQ.cjs';
|
|
3
|
+
export { B as BrowserUseError, a as X402WalletBalance, g as getWalletBalance } from './errors-DaHgFhIQ.cjs';
|
|
4
4
|
|
|
5
5
|
interface components {
|
|
6
6
|
schemas: {
|
|
@@ -908,118 +908,10 @@ interface components {
|
|
|
908
908
|
* @enum {string}
|
|
909
909
|
*/
|
|
910
910
|
ProxyCountryCode: "ad" | "ae" | "af" | "ag" | "ai" | "al" | "am" | "an" | "ao" | "aq" | "ar" | "as" | "at" | "au" | "aw" | "az" | "ba" | "bb" | "bd" | "be" | "bf" | "bg" | "bh" | "bi" | "bj" | "bl" | "bm" | "bn" | "bo" | "bq" | "br" | "bs" | "bt" | "bv" | "bw" | "by" | "bz" | "ca" | "cc" | "cd" | "cf" | "cg" | "ch" | "ck" | "cl" | "cm" | "co" | "cr" | "cs" | "cu" | "cv" | "cw" | "cx" | "cy" | "cz" | "de" | "dj" | "dk" | "dm" | "do" | "dz" | "ec" | "ee" | "eg" | "eh" | "er" | "es" | "et" | "fi" | "fj" | "fk" | "fm" | "fo" | "fr" | "ga" | "gd" | "ge" | "gf" | "gg" | "gh" | "gi" | "gl" | "gm" | "gn" | "gp" | "gq" | "gr" | "gs" | "gt" | "gu" | "gw" | "gy" | "hk" | "hm" | "hn" | "hr" | "ht" | "hu" | "id" | "ie" | "il" | "im" | "in" | "iq" | "ir" | "is" | "it" | "je" | "jm" | "jo" | "jp" | "ke" | "kg" | "kh" | "ki" | "km" | "kn" | "kp" | "kr" | "kw" | "ky" | "kz" | "la" | "lb" | "lc" | "li" | "lk" | "lr" | "ls" | "lt" | "lu" | "lv" | "ly" | "ma" | "mc" | "md" | "me" | "mf" | "mg" | "mh" | "mk" | "ml" | "mm" | "mn" | "mo" | "mp" | "mq" | "mr" | "ms" | "mt" | "mu" | "mv" | "mw" | "mx" | "my" | "mz" | "na" | "nc" | "ne" | "nf" | "ng" | "ni" | "nl" | "no" | "np" | "nr" | "nu" | "nz" | "om" | "pa" | "pe" | "pf" | "pg" | "ph" | "pk" | "pl" | "pm" | "pn" | "pr" | "ps" | "pt" | "pw" | "py" | "qa" | "re" | "ro" | "rs" | "ru" | "rw" | "sa" | "sb" | "sc" | "sd" | "se" | "sg" | "sh" | "si" | "sj" | "sk" | "sl" | "sm" | "sn" | "so" | "sr" | "ss" | "st" | "sv" | "sx" | "sy" | "sz" | "tc" | "td" | "tf" | "tg" | "th" | "tj" | "tk" | "tl" | "tm" | "tn" | "to" | "tr" | "tt" | "tv" | "tw" | "tz" | "ua" | "ug" | "uk" | "us" | "uy" | "uz" | "va" | "vc" | "ve" | "vg" | "vi" | "vn" | "vu" | "wf" | "ws" | "xk" | "ye" | "yt" | "za" | "zm" | "zw";
|
|
911
|
-
/**
|
|
912
|
-
* RunTaskRequest
|
|
913
|
-
* @description Create a new session, dispatch a task, or both.
|
|
914
|
-
*
|
|
915
|
-
* - **No `sessionId` + no `task`**: creates an idle session (useful for uploading files before running a task).
|
|
916
|
-
* - **No `sessionId` + `task`**: creates a new session and immediately runs the task.
|
|
917
|
-
* - **`sessionId` + `task`**: dispatches the task to an existing idle session.
|
|
918
|
-
* - **`sessionId` + no `task`**: returns 422 — a task is required when targeting an existing session.
|
|
919
|
-
*/
|
|
911
|
+
/** RunTaskRequest */
|
|
920
912
|
RunTaskRequest: {
|
|
921
|
-
/**
|
|
922
|
-
|
|
923
|
-
* @description The natural-language instruction for the agent to execute (e.g. "Go to amazon.com and find the best-rated wireless mouse under $50"). Required when dispatching to an existing session.
|
|
924
|
-
*/
|
|
925
|
-
task?: string | null;
|
|
926
|
-
/**
|
|
927
|
-
* @description The model to use. "gemini-3-flash" is fast and cheap, "claude-sonnet-4.6" is balanced, "claude-opus-4.7" is most capable (default). See BuModel for details.
|
|
928
|
-
* @default claude-opus-4.7
|
|
929
|
-
*/
|
|
930
|
-
model: components["schemas"]["BuModel"];
|
|
931
|
-
/**
|
|
932
|
-
* Sessionid
|
|
933
|
-
* @description ID of an existing idle session to dispatch the task to. If omitted, a new session is created.
|
|
934
|
-
*/
|
|
935
|
-
sessionId?: string | null;
|
|
936
|
-
/**
|
|
937
|
-
* Keepalive
|
|
938
|
-
* @description If true, the session stays alive in idle state after the task completes instead of automatically stopping. This lets you dispatch follow-up tasks to the same session, preserving browser state and files.
|
|
939
|
-
* @default false
|
|
940
|
-
*/
|
|
941
|
-
keepAlive: boolean;
|
|
942
|
-
/**
|
|
943
|
-
* Maxcostusd
|
|
944
|
-
* @description Maximum total cost in USD allowed for this session. The task will be stopped if this limit is reached. If omitted, a default limit applies (capped by your available balance). When dispatching a follow-up task to an existing session (`sessionId` is set), supplying this value overrides the session's budget for the upcoming dispatch; otherwise the budget is automatically refreshed to current spend + default.
|
|
945
|
-
*/
|
|
946
|
-
maxCostUsd?: number | string | null;
|
|
947
|
-
/**
|
|
948
|
-
* Profileid
|
|
949
|
-
* @description ID of a browser profile to load into the session. Profiles persist cookies, local storage, and other browser state across sessions. Create profiles via the Profiles API.
|
|
950
|
-
*/
|
|
951
|
-
profileId?: string | null;
|
|
952
|
-
/**
|
|
953
|
-
* Workspaceid
|
|
954
|
-
* @description ID of a workspace to attach to the session. Workspaces provide persistent file storage that carries across sessions. Create workspaces via the Workspaces API.
|
|
955
|
-
*/
|
|
956
|
-
workspaceId?: string | null;
|
|
957
|
-
/**
|
|
958
|
-
* @description Country code for the browser proxy (e.g. "US", "DE", "JP"). Set to null to disable the proxy. The proxy routes browser traffic through the specified country, useful for accessing geo-restricted content.
|
|
959
|
-
* @default us
|
|
960
|
-
*/
|
|
961
|
-
proxyCountryCode: components["schemas"]["ProxyCountryCode"] | null;
|
|
962
|
-
/**
|
|
963
|
-
* Outputschema
|
|
964
|
-
* @description A JSON Schema that the agent's final output must conform to. When set, the agent will return structured data matching this schema in the `output` field of the response. Example: {"type": "object", "properties": {"price": {"type": "number"}, "title": {"type": "string"}}}.
|
|
965
|
-
*/
|
|
966
|
-
outputSchema?: {
|
|
967
|
-
[key: string]: unknown;
|
|
968
|
-
} | null;
|
|
969
|
-
/**
|
|
970
|
-
* Enablescheduledtasks
|
|
971
|
-
* @description If true, the agent can create scheduled tasks that run on a recurring basis (e.g. "every Monday morning, check my inbox and summarize new emails"). Scheduled tasks are tied to your project and persist beyond the session. Note: all scheduled tasks are visible project-wide, so avoid enabling this in multi-user setups where task isolation is needed.
|
|
972
|
-
* @default false
|
|
973
|
-
*/
|
|
974
|
-
enableScheduledTasks: boolean;
|
|
975
|
-
/**
|
|
976
|
-
* Sensitivedata
|
|
977
|
-
* @description Key-value pairs of sensitive data (e.g. passwords, API keys) that the agent can use via secure placeholders. Keys are exposed to the LLM; values are never shown. The agent uses `<secret>key</secret>` placeholders in browser_type_text to securely enter values.
|
|
978
|
-
*/
|
|
979
|
-
sensitiveData?: {
|
|
980
|
-
[key: string]: string;
|
|
981
|
-
} | null;
|
|
982
|
-
/**
|
|
983
|
-
* Enablerecording
|
|
984
|
-
* @description If true, records a video of the browser session. The recording URLs will be available in the `recordingUrls` field of the session response after the task completes.
|
|
985
|
-
* @default false
|
|
986
|
-
*/
|
|
987
|
-
enableRecording: boolean;
|
|
988
|
-
/**
|
|
989
|
-
* Skills
|
|
990
|
-
* @description If true, enables built-in agent skills like Google Sheets integration and file management. Set to false to restrict the agent to browser-only actions.
|
|
991
|
-
* @default true
|
|
992
|
-
*/
|
|
993
|
-
skills: boolean;
|
|
994
|
-
/**
|
|
995
|
-
* Agentmail
|
|
996
|
-
* @description If true, provisions a temporary email inbox (via AgentMail) for the session. The email address is available in the `agentmailEmail` field of the session response. Useful for tasks that require email verification or sign-ups.
|
|
997
|
-
* @default true
|
|
998
|
-
*/
|
|
999
|
-
agentmail: boolean;
|
|
1000
|
-
/**
|
|
1001
|
-
* Codemode
|
|
1002
|
-
* @description When true, the agent returns structured output with `text` (summary) and `code` (validated Python source) fields instead of free-form text.
|
|
1003
|
-
* @default false
|
|
1004
|
-
*/
|
|
1005
|
-
codeMode: boolean;
|
|
1006
|
-
/**
|
|
1007
|
-
* Cachescript
|
|
1008
|
-
* @description Controls deterministic script caching. `null` (default): auto-detected — enabled when the task contains `@{{value}}` brackets and a workspace is attached. `true`: force-enable script caching even without brackets (caches the exact task). `false`: force-disable, even if brackets are present. When active, the first call runs the full agent and saves a reusable script. Subsequent calls with the same task template execute the cached script with $0 LLM cost. Requires workspace_id when enabled. Example: "Get prices from @{{https://example.com}} for @{{electronics}}".
|
|
1009
|
-
*/
|
|
1010
|
-
cacheScript?: boolean | null;
|
|
1011
|
-
/**
|
|
1012
|
-
* Useownkey
|
|
1013
|
-
* @description If true, uses your own LLM API key (configured in project settings) instead of Browser Use managed keys. You pay your provider directly for inference; Browser Use charges a reduced orchestration fee (0.2× of provider list prices). If no key is configured for the model's provider, the request is rejected.
|
|
1014
|
-
* @default false
|
|
1015
|
-
*/
|
|
1016
|
-
useOwnKey: boolean;
|
|
1017
|
-
/**
|
|
1018
|
-
* Autoheal
|
|
1019
|
-
* @description When cache_script is active, controls whether a lightweight LLM validates the cached script output. If the output looks incorrect (empty, error, wrong structure), the system automatically re-triggers the full agent to generate a new version of the script. Set to false to disable validation and always return the raw script output.
|
|
1020
|
-
* @default true
|
|
1021
|
-
*/
|
|
1022
|
-
autoHeal: boolean;
|
|
913
|
+
/** Prompt */
|
|
914
|
+
prompt: string;
|
|
1023
915
|
};
|
|
1024
916
|
/** SessionListResponse */
|
|
1025
917
|
SessionListResponse: {
|
|
@@ -1319,10 +1211,12 @@ interface components {
|
|
|
1319
1211
|
* TrialEligibilityView
|
|
1320
1212
|
* @description GET /me/trial-eligibility — is this user eligible for a free trial?
|
|
1321
1213
|
*
|
|
1214
|
+
* Account-scoped — paid users see this too (one free trial per user,
|
|
1215
|
+
* regardless of payment tier).
|
|
1216
|
+
*
|
|
1322
1217
|
* `reason` is a stable machine-readable code the FE branches on:
|
|
1323
1218
|
* - 'already_used' — user has already started a trial in their
|
|
1324
1219
|
* lifetime. Render an "upgrade to deploy" CTA.
|
|
1325
|
-
* - 'not_free_tier' — paying customer; FE shows the normal flow.
|
|
1326
1220
|
* - 'no_owner' — couldn't resolve the project's owner profile (rare,
|
|
1327
1221
|
* older projects). FE falls back to generic "add credits" copy.
|
|
1328
1222
|
* - None when eligible=True.
|
|
@@ -1331,7 +1225,7 @@ interface components {
|
|
|
1331
1225
|
/** Eligible */
|
|
1332
1226
|
eligible: boolean;
|
|
1333
1227
|
/** Reason */
|
|
1334
|
-
reason?: ("already_used" | "
|
|
1228
|
+
reason?: ("already_used" | "no_owner") | null;
|
|
1335
1229
|
/** Message */
|
|
1336
1230
|
message?: string | null;
|
|
1337
1231
|
};
|
|
@@ -1476,10 +1370,118 @@ interface components {
|
|
|
1476
1370
|
*/
|
|
1477
1371
|
updatedAt: string;
|
|
1478
1372
|
};
|
|
1479
|
-
/**
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1373
|
+
/**
|
|
1374
|
+
* RunTaskRequest
|
|
1375
|
+
* @description Create a new session, dispatch a task, or both.
|
|
1376
|
+
*
|
|
1377
|
+
* - **No `sessionId` + no `task`**: creates an idle session (useful for uploading files before running a task).
|
|
1378
|
+
* - **No `sessionId` + `task`**: creates a new session and immediately runs the task.
|
|
1379
|
+
* - **`sessionId` + `task`**: dispatches the task to an existing idle session.
|
|
1380
|
+
* - **`sessionId` + no `task`**: returns 422 — a task is required when targeting an existing session.
|
|
1381
|
+
*/
|
|
1382
|
+
app__endpoints__api__v3__sessions__views__RunTaskRequest: {
|
|
1383
|
+
/**
|
|
1384
|
+
* Task
|
|
1385
|
+
* @description The natural-language instruction for the agent to execute (e.g. "Go to amazon.com and find the best-rated wireless mouse under $50"). Required when dispatching to an existing session.
|
|
1386
|
+
*/
|
|
1387
|
+
task?: string | null;
|
|
1388
|
+
/**
|
|
1389
|
+
* @description The model to use. "gemini-3-flash" is fast and cheap, "claude-sonnet-4.6" is balanced, "claude-opus-4.7" is most capable (default). See BuModel for details.
|
|
1390
|
+
* @default claude-opus-4.7
|
|
1391
|
+
*/
|
|
1392
|
+
model: components["schemas"]["BuModel"];
|
|
1393
|
+
/**
|
|
1394
|
+
* Sessionid
|
|
1395
|
+
* @description ID of an existing idle session to dispatch the task to. If omitted, a new session is created.
|
|
1396
|
+
*/
|
|
1397
|
+
sessionId?: string | null;
|
|
1398
|
+
/**
|
|
1399
|
+
* Keepalive
|
|
1400
|
+
* @description If true, the session stays alive in idle state after the task completes instead of automatically stopping. This lets you dispatch follow-up tasks to the same session, preserving browser state and files.
|
|
1401
|
+
* @default false
|
|
1402
|
+
*/
|
|
1403
|
+
keepAlive: boolean;
|
|
1404
|
+
/**
|
|
1405
|
+
* Maxcostusd
|
|
1406
|
+
* @description Maximum total cost in USD allowed for this session. The task will be stopped if this limit is reached. If omitted, a default limit applies (capped by your available balance). When dispatching a follow-up task to an existing session (`sessionId` is set), supplying this value overrides the session's budget for the upcoming dispatch; otherwise the budget is automatically refreshed to current spend + default.
|
|
1407
|
+
*/
|
|
1408
|
+
maxCostUsd?: number | string | null;
|
|
1409
|
+
/**
|
|
1410
|
+
* Profileid
|
|
1411
|
+
* @description ID of a browser profile to load into the session. Profiles persist cookies, local storage, and other browser state across sessions. Create profiles via the Profiles API.
|
|
1412
|
+
*/
|
|
1413
|
+
profileId?: string | null;
|
|
1414
|
+
/**
|
|
1415
|
+
* Workspaceid
|
|
1416
|
+
* @description ID of a workspace to attach to the session. Workspaces provide persistent file storage that carries across sessions. Create workspaces via the Workspaces API.
|
|
1417
|
+
*/
|
|
1418
|
+
workspaceId?: string | null;
|
|
1419
|
+
/**
|
|
1420
|
+
* @description Country code for the browser proxy (e.g. "US", "DE", "JP"). Set to null to disable the proxy. The proxy routes browser traffic through the specified country, useful for accessing geo-restricted content.
|
|
1421
|
+
* @default us
|
|
1422
|
+
*/
|
|
1423
|
+
proxyCountryCode: components["schemas"]["ProxyCountryCode"] | null;
|
|
1424
|
+
/**
|
|
1425
|
+
* Outputschema
|
|
1426
|
+
* @description A JSON Schema that the agent's final output must conform to. When set, the agent will return structured data matching this schema in the `output` field of the response. Example: {"type": "object", "properties": {"price": {"type": "number"}, "title": {"type": "string"}}}.
|
|
1427
|
+
*/
|
|
1428
|
+
outputSchema?: {
|
|
1429
|
+
[key: string]: unknown;
|
|
1430
|
+
} | null;
|
|
1431
|
+
/**
|
|
1432
|
+
* Enablescheduledtasks
|
|
1433
|
+
* @description If true, the agent can create scheduled tasks that run on a recurring basis (e.g. "every Monday morning, check my inbox and summarize new emails"). Scheduled tasks are tied to your project and persist beyond the session. Note: all scheduled tasks are visible project-wide, so avoid enabling this in multi-user setups where task isolation is needed.
|
|
1434
|
+
* @default false
|
|
1435
|
+
*/
|
|
1436
|
+
enableScheduledTasks: boolean;
|
|
1437
|
+
/**
|
|
1438
|
+
* Sensitivedata
|
|
1439
|
+
* @description Key-value pairs of sensitive data (e.g. passwords, API keys) that the agent can use via secure placeholders. Keys are exposed to the LLM; values are never shown. The agent uses `<secret>key</secret>` placeholders in browser_type_text to securely enter values.
|
|
1440
|
+
*/
|
|
1441
|
+
sensitiveData?: {
|
|
1442
|
+
[key: string]: string;
|
|
1443
|
+
} | null;
|
|
1444
|
+
/**
|
|
1445
|
+
* Enablerecording
|
|
1446
|
+
* @description If true, records a video of the browser session. The recording URLs will be available in the `recordingUrls` field of the session response after the task completes.
|
|
1447
|
+
* @default false
|
|
1448
|
+
*/
|
|
1449
|
+
enableRecording: boolean;
|
|
1450
|
+
/**
|
|
1451
|
+
* Skills
|
|
1452
|
+
* @description If true, enables built-in agent skills like Google Sheets integration and file management. Set to false to restrict the agent to browser-only actions.
|
|
1453
|
+
* @default true
|
|
1454
|
+
*/
|
|
1455
|
+
skills: boolean;
|
|
1456
|
+
/**
|
|
1457
|
+
* Agentmail
|
|
1458
|
+
* @description If true, provisions a temporary email inbox (via AgentMail) for the session. The email address is available in the `agentmailEmail` field of the session response. Useful for tasks that require email verification or sign-ups.
|
|
1459
|
+
* @default true
|
|
1460
|
+
*/
|
|
1461
|
+
agentmail: boolean;
|
|
1462
|
+
/**
|
|
1463
|
+
* Codemode
|
|
1464
|
+
* @description When true, the agent returns structured output with `text` (summary) and `code` (validated Python source) fields instead of free-form text.
|
|
1465
|
+
* @default false
|
|
1466
|
+
*/
|
|
1467
|
+
codeMode: boolean;
|
|
1468
|
+
/**
|
|
1469
|
+
* Cachescript
|
|
1470
|
+
* @description Controls deterministic script caching. `null` (default): auto-detected — enabled when the task contains `@{{value}}` brackets and a workspace is attached. `true`: force-enable script caching even without brackets (caches the exact task). `false`: force-disable, even if brackets are present. When active, the first call runs the full agent and saves a reusable script. Subsequent calls with the same task template execute the cached script with $0 LLM cost. Requires workspace_id when enabled. Example: "Get prices from @{{https://example.com}} for @{{electronics}}".
|
|
1471
|
+
*/
|
|
1472
|
+
cacheScript?: boolean | null;
|
|
1473
|
+
/**
|
|
1474
|
+
* Useownkey
|
|
1475
|
+
* @description If true, uses your own LLM API key (configured in project settings) instead of Browser Use managed keys. You pay your provider directly for inference; Browser Use charges a reduced orchestration fee (0.2× of provider list prices). If no key is configured for the model's provider, the request is rejected.
|
|
1476
|
+
* @default false
|
|
1477
|
+
*/
|
|
1478
|
+
useOwnKey: boolean;
|
|
1479
|
+
/**
|
|
1480
|
+
* Autoheal
|
|
1481
|
+
* @description When cache_script is active, controls whether a lightweight LLM validates the cached script output. If the output looks incorrect (empty, error, wrong structure), the system automatically re-triggers the full agent to generate a new version of the script. Set to false to disable validation and always return the raw script output.
|
|
1482
|
+
* @default true
|
|
1483
|
+
*/
|
|
1484
|
+
autoHeal: boolean;
|
|
1483
1485
|
};
|
|
1484
1486
|
};
|
|
1485
1487
|
responses: never;
|
|
@@ -1553,7 +1555,7 @@ declare class Profiles {
|
|
|
1553
1555
|
delete(profileId: string): Promise<void>;
|
|
1554
1556
|
}
|
|
1555
1557
|
|
|
1556
|
-
type RunTaskRequest$2 = components["schemas"]["
|
|
1558
|
+
type RunTaskRequest$2 = components["schemas"]["app__endpoints__api__v3__sessions__views__RunTaskRequest"];
|
|
1557
1559
|
/** All fields optional — omit `task` to create an idle session. */
|
|
1558
1560
|
type CreateSessionBody = Partial<RunTaskRequest$2>;
|
|
1559
1561
|
type SessionResponse$2 = components["schemas"]["SessionResponse"];
|
|
@@ -1569,9 +1571,13 @@ interface SessionMessagesParams {
|
|
|
1569
1571
|
before?: string | null;
|
|
1570
1572
|
limit?: number;
|
|
1571
1573
|
}
|
|
1574
|
+
interface SessionsOptions {
|
|
1575
|
+
useOwnKey?: boolean;
|
|
1576
|
+
}
|
|
1572
1577
|
declare class Sessions {
|
|
1573
1578
|
private readonly http;
|
|
1574
|
-
|
|
1579
|
+
private readonly options;
|
|
1580
|
+
constructor(http: HttpClient, options?: SessionsOptions);
|
|
1575
1581
|
/** Create a session and optionally dispatch a task. */
|
|
1576
1582
|
create(body?: CreateSessionBody): Promise<SessionResponse$2>;
|
|
1577
1583
|
/** List sessions for the authenticated project. */
|
|
@@ -1716,12 +1722,29 @@ declare class SessionRun<T = string> implements PromiseLike<SessionResult<T>> {
|
|
|
1716
1722
|
private _parseOutput;
|
|
1717
1723
|
}
|
|
1718
1724
|
|
|
1719
|
-
type RunTaskRequest$1 = components["schemas"]["
|
|
1725
|
+
type RunTaskRequest$1 = components["schemas"]["app__endpoints__api__v3__sessions__views__RunTaskRequest"];
|
|
1720
1726
|
interface BrowserUseOptions {
|
|
1721
1727
|
apiKey?: string;
|
|
1722
1728
|
baseUrl?: string;
|
|
1723
1729
|
maxRetries?: number;
|
|
1724
1730
|
timeout?: number;
|
|
1731
|
+
/**
|
|
1732
|
+
* Use your own LLM API key configured in Browser Use project settings for v3 agent runs.
|
|
1733
|
+
*/
|
|
1734
|
+
useOwnKey?: boolean;
|
|
1735
|
+
/**
|
|
1736
|
+
* Pre-built x402 client (advanced — for custom signers / multi-network).
|
|
1737
|
+
* If set, the SDK uses pay-per-request authentication via USDC instead of
|
|
1738
|
+
* an API key. Requires the optional peer deps `@x402/fetch`, `@x402/evm`,
|
|
1739
|
+
* and `viem`.
|
|
1740
|
+
*/
|
|
1741
|
+
x402?: X402Client;
|
|
1742
|
+
/**
|
|
1743
|
+
* EVM wallet private key for x402 mode. Equivalent to building an x402
|
|
1744
|
+
* client from this key and passing it as `x402`. Falls back to
|
|
1745
|
+
* `BROWSER_USE_X402_PRIVATE_KEY`.
|
|
1746
|
+
*/
|
|
1747
|
+
x402PrivateKey?: string;
|
|
1725
1748
|
}
|
|
1726
1749
|
type RunSessionOptions = Partial<Omit<RunTaskRequest$1, "task">> & RunOptions & {
|
|
1727
1750
|
schema?: z.ZodType;
|
|
@@ -1764,7 +1787,7 @@ type MessageListResponse = S["MessageListResponse"];
|
|
|
1764
1787
|
type MessageResponse = S["MessageResponse"];
|
|
1765
1788
|
type WorkspaceView = S["WorkspaceView"];
|
|
1766
1789
|
type WorkspaceListResponse = S["WorkspaceListResponse"];
|
|
1767
|
-
type RunTaskRequest = S["
|
|
1790
|
+
type RunTaskRequest = S["app__endpoints__api__v3__sessions__views__RunTaskRequest"];
|
|
1768
1791
|
type StopSessionRequest = S["StopSessionRequest"];
|
|
1769
1792
|
type FileUploadRequest = S["FileUploadRequest"];
|
|
1770
1793
|
type FileUploadItem = S["FileUploadItem"];
|
|
@@ -1790,4 +1813,4 @@ type BuModel = S["BuModel"];
|
|
|
1790
1813
|
type ProxyCountryCode = S["ProxyCountryCode"];
|
|
1791
1814
|
type StopStrategy = S["StopStrategy"];
|
|
1792
1815
|
|
|
1793
|
-
export { type AccountView, Billing, type BrowserDownloadFile, type BrowserDownloadListResponse, type BrowserDownloadsParams, type BrowserListParams, type BrowserSessionItemView, type BrowserSessionListResponse, type BrowserSessionStatus, type BrowserSessionUpdateAction, type BrowserSessionView, BrowserUse, type BrowserUseOptions, Browsers, type BuAgentSessionStatus, type BuModel, type CreateBrowserSessionRequest, type CreateSessionBody, type FileInfo, type FileListResponse, type FileUploadItem, type FileUploadRequest, type FileUploadResponse, type FileUploadResponseItem, type MessageListResponse, type MessageResponse, type PlanInfo, type ProfileCreateRequest, type ProfileListParams, type ProfileListResponse, type ProfileUpdateRequest, type ProfileView, Profiles, type ProxyCountryCode, type RunOptions, type RunSessionOptions, type RunTaskRequest, type SessionListParams, type SessionListResponse, type SessionMessagesParams, type SessionResponse, type SessionResult, SessionRun, Sessions, type StopSessionRequest, type StopStrategy, type UpdateBrowserSessionRequest, type components as V3Types, type WorkspaceCreateRequest, type WorkspaceFilesParams, type WorkspaceListParams, type WorkspaceListResponse, type WorkspaceUpdateRequest, type WorkspaceView, Workspaces };
|
|
1816
|
+
export { type AccountView, Billing, type BrowserDownloadFile, type BrowserDownloadListResponse, type BrowserDownloadsParams, type BrowserListParams, type BrowserSessionItemView, type BrowserSessionListResponse, type BrowserSessionStatus, type BrowserSessionUpdateAction, type BrowserSessionView, BrowserUse, type BrowserUseOptions, Browsers, type BuAgentSessionStatus, type BuModel, type CreateBrowserSessionRequest, type CreateSessionBody, type FileInfo, type FileListResponse, type FileUploadItem, type FileUploadRequest, type FileUploadResponse, type FileUploadResponseItem, type MessageListResponse, type MessageResponse, type PlanInfo, type ProfileCreateRequest, type ProfileListParams, type ProfileListResponse, type ProfileUpdateRequest, type ProfileView, Profiles, type ProxyCountryCode, type RunOptions, type RunSessionOptions, type RunTaskRequest, type SessionListParams, type SessionListResponse, type SessionMessagesParams, type SessionResponse, type SessionResult, SessionRun, Sessions, type SessionsOptions, type StopSessionRequest, type StopStrategy, type UpdateBrowserSessionRequest, type components as V3Types, type WorkspaceCreateRequest, type WorkspaceFilesParams, type WorkspaceListParams, type WorkspaceListResponse, type WorkspaceUpdateRequest, type WorkspaceView, Workspaces };
|