browser-use-sdk 3.1.0 → 3.3.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/dist/index.d.cts CHANGED
@@ -118,6 +118,16 @@ 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;
126
+ /**
127
+ * Recording URL
128
+ * @description Presigned URL to download the session recording (available after session ends, if recording was enabled)
129
+ */
130
+ recordingUrl?: string | null;
121
131
  };
122
132
  /**
123
133
  * BrowserSessionListResponse
@@ -225,6 +235,16 @@ interface components {
225
235
  * @default 0
226
236
  */
227
237
  browserCost: string;
238
+ /**
239
+ * Agent Session ID
240
+ * @description ID of the agent session that created this browser (None for standalone BaaS sessions)
241
+ */
242
+ agentSessionId?: string | null;
243
+ /**
244
+ * Recording URL
245
+ * @description Presigned URL to download the session recording (available after session ends, if recording was enabled)
246
+ */
247
+ recordingUrl?: string | null;
228
248
  };
229
249
  /**
230
250
  * CannotDeleteSkillWhileGeneratingError
@@ -301,6 +321,12 @@ interface components {
301
321
  * @description Custom proxy settings to use for the session. If not provided, our proxies will be used. Custom proxies are only available for Business and Scaleup subscribers.
302
322
  */
303
323
  customProxy?: components["schemas"]["CustomProxy"] | null;
324
+ /**
325
+ * Enable Recording
326
+ * @description If True, enables session recording. Defaults to False.
327
+ * @default false
328
+ */
329
+ enableRecording: boolean;
304
330
  };
305
331
  /**
306
332
  * CreateSessionRequest
@@ -349,6 +375,12 @@ interface components {
349
375
  * @description Custom proxy settings to use for the session. If not provided, our proxies will be used. Custom proxies are only available for Business and Scaleup subscribers.
350
376
  */
351
377
  customProxy?: components["schemas"]["CustomProxy"] | null;
378
+ /**
379
+ * Enable Recording
380
+ * @description If True, enables session recording. Defaults to False.
381
+ * @default false
382
+ */
383
+ enableRecording: boolean;
352
384
  };
353
385
  /**
354
386
  * CreateSkillRequest
@@ -1015,6 +1047,11 @@ interface components {
1015
1047
  * @description URL where the browser can be viewed live in real-time
1016
1048
  */
1017
1049
  liveUrl?: string | null;
1050
+ /**
1051
+ * Recording URL
1052
+ * @description Presigned URL to download the session recording (available after session ends, if recording was enabled)
1053
+ */
1054
+ recordingUrl?: string | null;
1018
1055
  /**
1019
1056
  * Started At
1020
1057
  * Format: date-time
@@ -1112,6 +1149,12 @@ interface components {
1112
1149
  * @description Custom screen height in pixels for the browser.
1113
1150
  */
1114
1151
  browserScreenHeight?: number | null;
1152
+ /**
1153
+ * Enable Recording
1154
+ * @description If True, enables session recording. Defaults to False.
1155
+ * @default false
1156
+ */
1157
+ enableRecording: boolean;
1115
1158
  };
1116
1159
  /**
1117
1160
  * SessionStatus
@@ -1175,6 +1218,11 @@ interface components {
1175
1218
  * @description URL where the browser can be viewed live in real-time
1176
1219
  */
1177
1220
  liveUrl?: string | null;
1221
+ /**
1222
+ * Recording URL
1223
+ * @description Presigned URL to download the session recording (available after session ends, if recording was enabled)
1224
+ */
1225
+ recordingUrl?: string | null;
1178
1226
  /**
1179
1227
  * Started At
1180
1228
  * Format: date-time
package/dist/index.d.ts CHANGED
@@ -118,6 +118,16 @@ 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;
126
+ /**
127
+ * Recording URL
128
+ * @description Presigned URL to download the session recording (available after session ends, if recording was enabled)
129
+ */
130
+ recordingUrl?: string | null;
121
131
  };
122
132
  /**
123
133
  * BrowserSessionListResponse
@@ -225,6 +235,16 @@ interface components {
225
235
  * @default 0
226
236
  */
227
237
  browserCost: string;
238
+ /**
239
+ * Agent Session ID
240
+ * @description ID of the agent session that created this browser (None for standalone BaaS sessions)
241
+ */
242
+ agentSessionId?: string | null;
243
+ /**
244
+ * Recording URL
245
+ * @description Presigned URL to download the session recording (available after session ends, if recording was enabled)
246
+ */
247
+ recordingUrl?: string | null;
228
248
  };
229
249
  /**
230
250
  * CannotDeleteSkillWhileGeneratingError
@@ -301,6 +321,12 @@ interface components {
301
321
  * @description Custom proxy settings to use for the session. If not provided, our proxies will be used. Custom proxies are only available for Business and Scaleup subscribers.
302
322
  */
303
323
  customProxy?: components["schemas"]["CustomProxy"] | null;
324
+ /**
325
+ * Enable Recording
326
+ * @description If True, enables session recording. Defaults to False.
327
+ * @default false
328
+ */
329
+ enableRecording: boolean;
304
330
  };
305
331
  /**
306
332
  * CreateSessionRequest
@@ -349,6 +375,12 @@ interface components {
349
375
  * @description Custom proxy settings to use for the session. If not provided, our proxies will be used. Custom proxies are only available for Business and Scaleup subscribers.
350
376
  */
351
377
  customProxy?: components["schemas"]["CustomProxy"] | null;
378
+ /**
379
+ * Enable Recording
380
+ * @description If True, enables session recording. Defaults to False.
381
+ * @default false
382
+ */
383
+ enableRecording: boolean;
352
384
  };
353
385
  /**
354
386
  * CreateSkillRequest
@@ -1015,6 +1047,11 @@ interface components {
1015
1047
  * @description URL where the browser can be viewed live in real-time
1016
1048
  */
1017
1049
  liveUrl?: string | null;
1050
+ /**
1051
+ * Recording URL
1052
+ * @description Presigned URL to download the session recording (available after session ends, if recording was enabled)
1053
+ */
1054
+ recordingUrl?: string | null;
1018
1055
  /**
1019
1056
  * Started At
1020
1057
  * Format: date-time
@@ -1112,6 +1149,12 @@ interface components {
1112
1149
  * @description Custom screen height in pixels for the browser.
1113
1150
  */
1114
1151
  browserScreenHeight?: number | null;
1152
+ /**
1153
+ * Enable Recording
1154
+ * @description If True, enables session recording. Defaults to False.
1155
+ * @default false
1156
+ */
1157
+ enableRecording: boolean;
1115
1158
  };
1116
1159
  /**
1117
1160
  * SessionStatus
@@ -1175,6 +1218,11 @@ interface components {
1175
1218
  * @description URL where the browser can be viewed live in real-time
1176
1219
  */
1177
1220
  liveUrl?: string | null;
1221
+ /**
1222
+ * Recording URL
1223
+ * @description Presigned URL to download the session recording (available after session ends, if recording was enabled)
1224
+ */
1225
+ recordingUrl?: string | null;
1178
1226
  /**
1179
1227
  * Started At
1180
1228
  * Format: date-time
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,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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A;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/larsencundric/Documents/browser-use/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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;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 { 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,35 @@ 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
+ /**
136
+ * Createdat
137
+ * Format: date-time
138
+ */
139
+ createdAt: string;
140
+ };
102
141
  /**
103
142
  * ProxyCountryCode
104
143
  * @enum {string}
@@ -129,6 +168,8 @@ interface components {
129
168
  maxCostUsd?: number | string | null;
130
169
  /** Profileid */
131
170
  profileId?: string | null;
171
+ /** Workspaceid */
172
+ workspaceId?: string | null;
132
173
  proxyCountryCode?: components["schemas"]["ProxyCountryCode"] | null;
133
174
  /** Outputschema */
134
175
  outputSchema?: {
@@ -159,10 +200,16 @@ interface components {
159
200
  title?: string | null;
160
201
  /** Output */
161
202
  output?: unknown | null;
203
+ /** Outputschema */
204
+ outputSchema?: {
205
+ [key: string]: unknown;
206
+ } | null;
162
207
  /** Liveurl */
163
208
  liveUrl?: string | null;
164
209
  /** Profileid */
165
210
  profileId?: string | null;
211
+ /** Workspaceid */
212
+ workspaceId?: string | null;
166
213
  proxyCountryCode?: components["schemas"]["ProxyCountryCode"] | null;
167
214
  /** Maxcostusd */
168
215
  maxCostUsd?: string | null;
@@ -226,6 +273,83 @@ interface components {
226
273
  /** Error Type */
227
274
  type: string;
228
275
  };
276
+ /**
277
+ * WorkspaceCreateRequest
278
+ * @description Request model for creating a new workspace.
279
+ */
280
+ WorkspaceCreateRequest: {
281
+ /**
282
+ * Name
283
+ * @description Optional name for the workspace
284
+ */
285
+ name?: string | null;
286
+ };
287
+ /**
288
+ * WorkspaceListResponse
289
+ * @description Response model for paginated workspace list requests.
290
+ */
291
+ WorkspaceListResponse: {
292
+ /**
293
+ * Items
294
+ * @description List of workspace views for the current page
295
+ */
296
+ items: components["schemas"]["WorkspaceView"][];
297
+ /**
298
+ * Total Items
299
+ * @description Total number of items in the list
300
+ */
301
+ totalItems: number;
302
+ /**
303
+ * Page Number
304
+ * @description Page number
305
+ */
306
+ pageNumber: number;
307
+ /**
308
+ * Page Size
309
+ * @description Number of items per page
310
+ */
311
+ pageSize: number;
312
+ };
313
+ /**
314
+ * WorkspaceUpdateRequest
315
+ * @description Request model for updating a workspace.
316
+ */
317
+ WorkspaceUpdateRequest: {
318
+ /**
319
+ * Name
320
+ * @description Optional name for the workspace
321
+ */
322
+ name?: string | null;
323
+ };
324
+ /**
325
+ * WorkspaceView
326
+ * @description View model for a workspace — persistent shared storage across sessions.
327
+ */
328
+ WorkspaceView: {
329
+ /**
330
+ * ID
331
+ * Format: uuid
332
+ * @description Unique identifier for the workspace
333
+ */
334
+ id: string;
335
+ /**
336
+ * Name
337
+ * @description Optional name for the workspace
338
+ */
339
+ name?: string | null;
340
+ /**
341
+ * Created At
342
+ * Format: date-time
343
+ * @description Timestamp when the workspace was created
344
+ */
345
+ createdAt: string;
346
+ /**
347
+ * Updated At
348
+ * Format: date-time
349
+ * @description Timestamp when the workspace was last updated
350
+ */
351
+ updatedAt: string;
352
+ };
229
353
  };
230
354
  responses: never;
231
355
  parameters: never;
@@ -239,10 +363,11 @@ type RunTaskRequest$2 = components["schemas"]["RunTaskRequest"];
239
363
  type CreateSessionBody = Partial<RunTaskRequest$2>;
240
364
  type SessionResponse$2 = components["schemas"]["SessionResponse"];
241
365
  type SessionListResponse$1 = components["schemas"]["SessionListResponse"];
242
- type FileListResponse$1 = components["schemas"]["FileListResponse"];
366
+ type FileListResponse$2 = components["schemas"]["FileListResponse"];
243
367
  type StopSessionRequest$1 = components["schemas"]["StopSessionRequest"];
244
- type FileUploadRequest$1 = components["schemas"]["FileUploadRequest"];
245
- type FileUploadResponse$1 = components["schemas"]["FileUploadResponse"];
368
+ type FileUploadRequest$2 = components["schemas"]["FileUploadRequest"];
369
+ type FileUploadResponse$2 = components["schemas"]["FileUploadResponse"];
370
+ type MessageListResponse$1 = components["schemas"]["MessageListResponse"];
246
371
  interface SessionListParams {
247
372
  page?: number;
248
373
  page_size?: number;
@@ -252,6 +377,12 @@ interface SessionFilesParams {
252
377
  limit?: number;
253
378
  cursor?: string | null;
254
379
  includeUrls?: boolean;
380
+ shallow?: boolean;
381
+ }
382
+ interface SessionMessagesParams {
383
+ after?: string | null;
384
+ before?: string | null;
385
+ limit?: number;
255
386
  }
256
387
  declare class Sessions {
257
388
  private readonly http;
@@ -267,9 +398,54 @@ declare class Sessions {
267
398
  /** Soft-delete a session. */
268
399
  delete(sessionId: string): Promise<void>;
269
400
  /** Get presigned upload URLs for session files. */
270
- uploadFiles(sessionId: string, body: FileUploadRequest$1): Promise<FileUploadResponse$1>;
401
+ uploadFiles(sessionId: string, body: FileUploadRequest$2): Promise<FileUploadResponse$2>;
271
402
  /** List files in a session's workspace. */
272
- files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse$1>;
403
+ files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse$2>;
404
+ /** List messages for a session with cursor-based pagination. */
405
+ messages(sessionId: string, params?: SessionMessagesParams): Promise<MessageListResponse$1>;
406
+ }
407
+
408
+ type WorkspaceView$1 = components["schemas"]["WorkspaceView"];
409
+ type WorkspaceListResponse$1 = components["schemas"]["WorkspaceListResponse"];
410
+ type WorkspaceCreateRequest$1 = components["schemas"]["WorkspaceCreateRequest"];
411
+ type WorkspaceUpdateRequest$1 = components["schemas"]["WorkspaceUpdateRequest"];
412
+ type FileListResponse$1 = components["schemas"]["FileListResponse"];
413
+ type FileUploadRequest$1 = components["schemas"]["FileUploadRequest"];
414
+ type FileUploadResponse$1 = components["schemas"]["FileUploadResponse"];
415
+ interface WorkspaceListParams {
416
+ pageSize?: number;
417
+ pageNumber?: number;
418
+ }
419
+ interface WorkspaceFilesParams {
420
+ prefix?: string;
421
+ limit?: number;
422
+ cursor?: string | null;
423
+ includeUrls?: boolean;
424
+ shallow?: boolean;
425
+ }
426
+ declare class Workspaces {
427
+ private readonly http;
428
+ constructor(http: HttpClient);
429
+ /** List workspaces for the authenticated project. */
430
+ list(params?: WorkspaceListParams): Promise<WorkspaceListResponse$1>;
431
+ /** Create a new workspace. */
432
+ create(body?: WorkspaceCreateRequest$1): Promise<WorkspaceView$1>;
433
+ /** Get workspace details. */
434
+ get(workspaceId: string): Promise<WorkspaceView$1>;
435
+ /** Update a workspace. */
436
+ update(workspaceId: string, body: WorkspaceUpdateRequest$1): Promise<WorkspaceView$1>;
437
+ /** Delete a workspace and its data. */
438
+ delete(workspaceId: string): Promise<void>;
439
+ /** List files in a workspace. */
440
+ files(workspaceId: string, params?: WorkspaceFilesParams): Promise<FileListResponse$1>;
441
+ /** Get presigned upload URLs for workspace files. */
442
+ uploadFiles(workspaceId: string, body: FileUploadRequest$1, query?: {
443
+ prefix?: string;
444
+ }): Promise<FileUploadResponse$1>;
445
+ /** Delete a file from a workspace. */
446
+ deleteFile(workspaceId: string, path: string): Promise<void>;
447
+ /** Get storage usage for a workspace. */
448
+ size(workspaceId: string): Promise<unknown>;
273
449
  }
274
450
 
275
451
  type SessionResponse$1 = components["schemas"]["SessionResponse"];
@@ -320,6 +496,7 @@ type RunSessionOptions = Partial<Omit<RunTaskRequest$1, "task">> & RunOptions &
320
496
  };
321
497
  declare class BrowserUse {
322
498
  readonly sessions: Sessions;
499
+ readonly workspaces: Workspaces;
323
500
  private readonly http;
324
501
  constructor(options?: BrowserUseOptions);
325
502
  /**
@@ -348,13 +525,19 @@ type FileListResponse = S["FileListResponse"];
348
525
  type FileInfo = S["FileInfo"];
349
526
  type FileUploadResponse = S["FileUploadResponse"];
350
527
  type FileUploadResponseItem = S["FileUploadResponseItem"];
528
+ type MessageListResponse = S["MessageListResponse"];
529
+ type MessageResponse = S["MessageResponse"];
530
+ type WorkspaceView = S["WorkspaceView"];
531
+ type WorkspaceListResponse = S["WorkspaceListResponse"];
351
532
  type RunTaskRequest = S["RunTaskRequest"];
352
533
  type StopSessionRequest = S["StopSessionRequest"];
353
534
  type FileUploadRequest = S["FileUploadRequest"];
354
535
  type FileUploadItem = S["FileUploadItem"];
536
+ type WorkspaceCreateRequest = S["WorkspaceCreateRequest"];
537
+ type WorkspaceUpdateRequest = S["WorkspaceUpdateRequest"];
355
538
  type BuAgentSessionStatus = S["BuAgentSessionStatus"];
356
539
  type BuModel = S["BuModel"];
357
540
  type ProxyCountryCode = S["ProxyCountryCode"];
358
541
  type StopStrategy = S["StopStrategy"];
359
542
 
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 };
543
+ 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,35 @@ 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
+ /**
136
+ * Createdat
137
+ * Format: date-time
138
+ */
139
+ createdAt: string;
140
+ };
102
141
  /**
103
142
  * ProxyCountryCode
104
143
  * @enum {string}
@@ -129,6 +168,8 @@ interface components {
129
168
  maxCostUsd?: number | string | null;
130
169
  /** Profileid */
131
170
  profileId?: string | null;
171
+ /** Workspaceid */
172
+ workspaceId?: string | null;
132
173
  proxyCountryCode?: components["schemas"]["ProxyCountryCode"] | null;
133
174
  /** Outputschema */
134
175
  outputSchema?: {
@@ -159,10 +200,16 @@ interface components {
159
200
  title?: string | null;
160
201
  /** Output */
161
202
  output?: unknown | null;
203
+ /** Outputschema */
204
+ outputSchema?: {
205
+ [key: string]: unknown;
206
+ } | null;
162
207
  /** Liveurl */
163
208
  liveUrl?: string | null;
164
209
  /** Profileid */
165
210
  profileId?: string | null;
211
+ /** Workspaceid */
212
+ workspaceId?: string | null;
166
213
  proxyCountryCode?: components["schemas"]["ProxyCountryCode"] | null;
167
214
  /** Maxcostusd */
168
215
  maxCostUsd?: string | null;
@@ -226,6 +273,83 @@ interface components {
226
273
  /** Error Type */
227
274
  type: string;
228
275
  };
276
+ /**
277
+ * WorkspaceCreateRequest
278
+ * @description Request model for creating a new workspace.
279
+ */
280
+ WorkspaceCreateRequest: {
281
+ /**
282
+ * Name
283
+ * @description Optional name for the workspace
284
+ */
285
+ name?: string | null;
286
+ };
287
+ /**
288
+ * WorkspaceListResponse
289
+ * @description Response model for paginated workspace list requests.
290
+ */
291
+ WorkspaceListResponse: {
292
+ /**
293
+ * Items
294
+ * @description List of workspace views for the current page
295
+ */
296
+ items: components["schemas"]["WorkspaceView"][];
297
+ /**
298
+ * Total Items
299
+ * @description Total number of items in the list
300
+ */
301
+ totalItems: number;
302
+ /**
303
+ * Page Number
304
+ * @description Page number
305
+ */
306
+ pageNumber: number;
307
+ /**
308
+ * Page Size
309
+ * @description Number of items per page
310
+ */
311
+ pageSize: number;
312
+ };
313
+ /**
314
+ * WorkspaceUpdateRequest
315
+ * @description Request model for updating a workspace.
316
+ */
317
+ WorkspaceUpdateRequest: {
318
+ /**
319
+ * Name
320
+ * @description Optional name for the workspace
321
+ */
322
+ name?: string | null;
323
+ };
324
+ /**
325
+ * WorkspaceView
326
+ * @description View model for a workspace — persistent shared storage across sessions.
327
+ */
328
+ WorkspaceView: {
329
+ /**
330
+ * ID
331
+ * Format: uuid
332
+ * @description Unique identifier for the workspace
333
+ */
334
+ id: string;
335
+ /**
336
+ * Name
337
+ * @description Optional name for the workspace
338
+ */
339
+ name?: string | null;
340
+ /**
341
+ * Created At
342
+ * Format: date-time
343
+ * @description Timestamp when the workspace was created
344
+ */
345
+ createdAt: string;
346
+ /**
347
+ * Updated At
348
+ * Format: date-time
349
+ * @description Timestamp when the workspace was last updated
350
+ */
351
+ updatedAt: string;
352
+ };
229
353
  };
230
354
  responses: never;
231
355
  parameters: never;
@@ -239,10 +363,11 @@ type RunTaskRequest$2 = components["schemas"]["RunTaskRequest"];
239
363
  type CreateSessionBody = Partial<RunTaskRequest$2>;
240
364
  type SessionResponse$2 = components["schemas"]["SessionResponse"];
241
365
  type SessionListResponse$1 = components["schemas"]["SessionListResponse"];
242
- type FileListResponse$1 = components["schemas"]["FileListResponse"];
366
+ type FileListResponse$2 = components["schemas"]["FileListResponse"];
243
367
  type StopSessionRequest$1 = components["schemas"]["StopSessionRequest"];
244
- type FileUploadRequest$1 = components["schemas"]["FileUploadRequest"];
245
- type FileUploadResponse$1 = components["schemas"]["FileUploadResponse"];
368
+ type FileUploadRequest$2 = components["schemas"]["FileUploadRequest"];
369
+ type FileUploadResponse$2 = components["schemas"]["FileUploadResponse"];
370
+ type MessageListResponse$1 = components["schemas"]["MessageListResponse"];
246
371
  interface SessionListParams {
247
372
  page?: number;
248
373
  page_size?: number;
@@ -252,6 +377,12 @@ interface SessionFilesParams {
252
377
  limit?: number;
253
378
  cursor?: string | null;
254
379
  includeUrls?: boolean;
380
+ shallow?: boolean;
381
+ }
382
+ interface SessionMessagesParams {
383
+ after?: string | null;
384
+ before?: string | null;
385
+ limit?: number;
255
386
  }
256
387
  declare class Sessions {
257
388
  private readonly http;
@@ -267,9 +398,54 @@ declare class Sessions {
267
398
  /** Soft-delete a session. */
268
399
  delete(sessionId: string): Promise<void>;
269
400
  /** Get presigned upload URLs for session files. */
270
- uploadFiles(sessionId: string, body: FileUploadRequest$1): Promise<FileUploadResponse$1>;
401
+ uploadFiles(sessionId: string, body: FileUploadRequest$2): Promise<FileUploadResponse$2>;
271
402
  /** List files in a session's workspace. */
272
- files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse$1>;
403
+ files(sessionId: string, params?: SessionFilesParams): Promise<FileListResponse$2>;
404
+ /** List messages for a session with cursor-based pagination. */
405
+ messages(sessionId: string, params?: SessionMessagesParams): Promise<MessageListResponse$1>;
406
+ }
407
+
408
+ type WorkspaceView$1 = components["schemas"]["WorkspaceView"];
409
+ type WorkspaceListResponse$1 = components["schemas"]["WorkspaceListResponse"];
410
+ type WorkspaceCreateRequest$1 = components["schemas"]["WorkspaceCreateRequest"];
411
+ type WorkspaceUpdateRequest$1 = components["schemas"]["WorkspaceUpdateRequest"];
412
+ type FileListResponse$1 = components["schemas"]["FileListResponse"];
413
+ type FileUploadRequest$1 = components["schemas"]["FileUploadRequest"];
414
+ type FileUploadResponse$1 = components["schemas"]["FileUploadResponse"];
415
+ interface WorkspaceListParams {
416
+ pageSize?: number;
417
+ pageNumber?: number;
418
+ }
419
+ interface WorkspaceFilesParams {
420
+ prefix?: string;
421
+ limit?: number;
422
+ cursor?: string | null;
423
+ includeUrls?: boolean;
424
+ shallow?: boolean;
425
+ }
426
+ declare class Workspaces {
427
+ private readonly http;
428
+ constructor(http: HttpClient);
429
+ /** List workspaces for the authenticated project. */
430
+ list(params?: WorkspaceListParams): Promise<WorkspaceListResponse$1>;
431
+ /** Create a new workspace. */
432
+ create(body?: WorkspaceCreateRequest$1): Promise<WorkspaceView$1>;
433
+ /** Get workspace details. */
434
+ get(workspaceId: string): Promise<WorkspaceView$1>;
435
+ /** Update a workspace. */
436
+ update(workspaceId: string, body: WorkspaceUpdateRequest$1): Promise<WorkspaceView$1>;
437
+ /** Delete a workspace and its data. */
438
+ delete(workspaceId: string): Promise<void>;
439
+ /** List files in a workspace. */
440
+ files(workspaceId: string, params?: WorkspaceFilesParams): Promise<FileListResponse$1>;
441
+ /** Get presigned upload URLs for workspace files. */
442
+ uploadFiles(workspaceId: string, body: FileUploadRequest$1, query?: {
443
+ prefix?: string;
444
+ }): Promise<FileUploadResponse$1>;
445
+ /** Delete a file from a workspace. */
446
+ deleteFile(workspaceId: string, path: string): Promise<void>;
447
+ /** Get storage usage for a workspace. */
448
+ size(workspaceId: string): Promise<unknown>;
273
449
  }
274
450
 
275
451
  type SessionResponse$1 = components["schemas"]["SessionResponse"];
@@ -320,6 +496,7 @@ type RunSessionOptions = Partial<Omit<RunTaskRequest$1, "task">> & RunOptions &
320
496
  };
321
497
  declare class BrowserUse {
322
498
  readonly sessions: Sessions;
499
+ readonly workspaces: Workspaces;
323
500
  private readonly http;
324
501
  constructor(options?: BrowserUseOptions);
325
502
  /**
@@ -348,13 +525,19 @@ type FileListResponse = S["FileListResponse"];
348
525
  type FileInfo = S["FileInfo"];
349
526
  type FileUploadResponse = S["FileUploadResponse"];
350
527
  type FileUploadResponseItem = S["FileUploadResponseItem"];
528
+ type MessageListResponse = S["MessageListResponse"];
529
+ type MessageResponse = S["MessageResponse"];
530
+ type WorkspaceView = S["WorkspaceView"];
531
+ type WorkspaceListResponse = S["WorkspaceListResponse"];
351
532
  type RunTaskRequest = S["RunTaskRequest"];
352
533
  type StopSessionRequest = S["StopSessionRequest"];
353
534
  type FileUploadRequest = S["FileUploadRequest"];
354
535
  type FileUploadItem = S["FileUploadItem"];
536
+ type WorkspaceCreateRequest = S["WorkspaceCreateRequest"];
537
+ type WorkspaceUpdateRequest = S["WorkspaceUpdateRequest"];
355
538
  type BuAgentSessionStatus = S["BuAgentSessionStatus"];
356
539
  type BuModel = S["BuModel"];
357
540
  type ProxyCountryCode = S["ProxyCountryCode"];
358
541
  type StopStrategy = S["StopStrategy"];
359
542
 
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 };
543
+ 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;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,WAAO,KAAK,KA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AAI;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,WAAO,KAAK,KAAK,KAAyB,aAAa,SAAS,iBAAiB,IAAI;AAAA,EACvF;AAAA;AAAA,EAGA,MAAM,WAAmB,QAAwD;AAC/E,WAAO,KAAK,KAAK;AAAA,MACf,aAAa,SAAS;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGA,SAAS,WAAmB,QAA8D;AACxF,WAAO,KAAK,KAAK;AAAA,MACf,aAAa,SAAS;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;;;ACzDO,IAAM,aAAN,MAAiB;AAAA,EACtB,YAA6B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AAC1B,UAAM,MAAM,OAAO,WAAW,WAAW,KAAK,MAAM,MAAM,IAAI;AAC9D,WAAO,KAAK,QAAQ,MAAM,GAAG;AAAA,EAC/B;AACF;;;AH5FA,IAAM,mBAAmB;AAYlB,IAAM,aAAN,MAAiB;AAAA,EACb;AAAA,EACA;AAAA,EAEQ;AAAA,EAEjB,YAAY,UAA6B,CAAC,GAAG;AAC3C,UAAM,SACJ,QAAQ,UAAU,QAAQ,IAAI,uBAAuB;AACvD,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,SAAK,OAAO,IAAI,WAAW;AAAA,MACzB;AAAA,MACA,SAAS,QAAQ,WAAW;AAAA,MAC5B,YAAY,QAAQ;AAAA,MACpB,SAAS,QAAQ;AAAA,IACnB,CAAC;AAED,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AACtC,SAAK,aAAa,IAAI,WAAW,KAAK,IAAI;AAAA,EAC5C;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":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-use-sdk",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Official TypeScript SDK for the Browser Use API",
5
5
  "author": "Browser Use",
6
6
  "license": "MIT",