@browserbasehq/sdk 2.14.1 → 2.16.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/index.d.mts +3 -0
  3. package/index.d.ts +3 -0
  4. package/index.d.ts.map +1 -1
  5. package/index.js +3 -0
  6. package/index.js.map +1 -1
  7. package/index.mjs +3 -0
  8. package/index.mjs.map +1 -1
  9. package/package.json +2 -1
  10. package/resources/agents/agents.d.ts +240 -0
  11. package/resources/agents/agents.d.ts.map +1 -0
  12. package/resources/agents/agents.js +85 -0
  13. package/resources/agents/agents.js.map +1 -0
  14. package/resources/agents/agents.mjs +48 -0
  15. package/resources/agents/agents.mjs.map +1 -0
  16. package/resources/agents/index.d.ts +3 -0
  17. package/resources/agents/index.d.ts.map +1 -0
  18. package/resources/agents/index.js +9 -0
  19. package/resources/agents/index.js.map +1 -0
  20. package/resources/agents/index.mjs +4 -0
  21. package/resources/agents/index.mjs.map +1 -0
  22. package/resources/agents/runs.d.ts +441 -0
  23. package/resources/agents/runs.d.ts.map +1 -0
  24. package/resources/agents/runs.js +38 -0
  25. package/resources/agents/runs.js.map +1 -0
  26. package/resources/agents/runs.mjs +34 -0
  27. package/resources/agents/runs.mjs.map +1 -0
  28. package/resources/agents.d.ts +2 -0
  29. package/resources/agents.d.ts.map +1 -0
  30. package/resources/agents.js +19 -0
  31. package/resources/agents.js.map +1 -0
  32. package/resources/agents.mjs +3 -0
  33. package/resources/agents.mjs.map +1 -0
  34. package/resources/index.d.ts +1 -0
  35. package/resources/index.d.ts.map +1 -1
  36. package/resources/index.js +3 -1
  37. package/resources/index.js.map +1 -1
  38. package/resources/index.mjs +1 -0
  39. package/resources/index.mjs.map +1 -1
  40. package/resources/sessions/index.d.ts +1 -1
  41. package/resources/sessions/index.d.ts.map +1 -1
  42. package/resources/sessions/index.js +2 -2
  43. package/resources/sessions/index.js.map +1 -1
  44. package/resources/sessions/index.mjs +1 -1
  45. package/resources/sessions/recording/downloads.d.ts +48 -0
  46. package/resources/sessions/recording/downloads.d.ts.map +1 -0
  47. package/resources/sessions/recording/downloads.js +25 -0
  48. package/resources/sessions/recording/downloads.js.map +1 -0
  49. package/resources/sessions/recording/downloads.mjs +21 -0
  50. package/resources/sessions/recording/downloads.mjs.map +1 -0
  51. package/resources/sessions/recording/index.d.ts +3 -0
  52. package/resources/sessions/recording/index.d.ts.map +1 -0
  53. package/resources/sessions/recording/index.js +9 -0
  54. package/resources/sessions/recording/index.js.map +1 -0
  55. package/resources/sessions/recording/index.mjs +4 -0
  56. package/resources/sessions/recording/index.mjs.map +1 -0
  57. package/resources/sessions/recording/recording.d.ts +32 -0
  58. package/resources/sessions/recording/recording.d.ts.map +1 -0
  59. package/resources/sessions/recording/recording.js +55 -0
  60. package/resources/sessions/recording/recording.js.map +1 -0
  61. package/resources/sessions/recording/recording.mjs +18 -0
  62. package/resources/sessions/recording/recording.mjs.map +1 -0
  63. package/resources/sessions/recording.d.ts +1 -27
  64. package/resources/sessions/recording.d.ts.map +1 -1
  65. package/resources/sessions/recording.js +15 -11
  66. package/resources/sessions/recording.js.map +1 -1
  67. package/resources/sessions/recording.mjs +1 -9
  68. package/resources/sessions/recording.mjs.map +1 -1
  69. package/resources/sessions/sessions.d.ts +13 -2
  70. package/resources/sessions/sessions.d.ts.map +1 -1
  71. package/resources/sessions/sessions.js +2 -2
  72. package/resources/sessions/sessions.js.map +1 -1
  73. package/resources/sessions/sessions.mjs +2 -2
  74. package/resources/sessions/sessions.mjs.map +1 -1
  75. package/src/index.ts +23 -0
  76. package/src/resources/agents/agents.ts +335 -0
  77. package/src/resources/agents/index.ts +22 -0
  78. package/src/resources/agents/runs.ts +553 -0
  79. package/src/resources/agents.ts +3 -0
  80. package/src/resources/index.ts +10 -0
  81. package/src/resources/sessions/index.ts +1 -1
  82. package/src/resources/sessions/recording/downloads.ts +66 -0
  83. package/src/resources/sessions/recording/index.ts +9 -0
  84. package/src/resources/sessions/recording/recording.ts +52 -0
  85. package/src/resources/sessions/recording.ts +1 -37
  86. package/src/resources/sessions/sessions.ts +14 -2
  87. package/src/version.ts +1 -1
  88. package/version.d.ts +1 -1
  89. package/version.js +1 -1
  90. package/version.mjs +1 -1
@@ -0,0 +1,553 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../resource';
4
+ import { isRequestOptions } from '../../core';
5
+ import * as Core from '../../core';
6
+
7
+ export class Runs extends APIResource {
8
+ /**
9
+ * Run a browser agent to complete the `task` by using web search and browser
10
+ * tooling. Optionally pass `agentId` to run a
11
+ * [custom agent](/reference/api/create-an-agent) you've created.
12
+ */
13
+ create(body: RunCreateParams, options?: Core.RequestOptions): Core.APIPromise<RunCreateResponse> {
14
+ return this._client.post('/v1/agents/runs', { body, ...options });
15
+ }
16
+
17
+ /**
18
+ * Retrieve the current status and details of a run, including its result and
19
+ * associated session information. To fetch the run's messages, use
20
+ * [List Run Messages](/reference/api/list-run-messages).
21
+ */
22
+ retrieve(runId: string, options?: Core.RequestOptions): Core.APIPromise<RunRetrieveResponse> {
23
+ return this._client.get(`/v1/agents/runs/${runId}`, options);
24
+ }
25
+
26
+ /**
27
+ * List runs across your account. Supports filtering by status, by the agent they
28
+ * reference, and by creation time.
29
+ */
30
+ list(query?: RunListParams, options?: Core.RequestOptions): Core.APIPromise<RunListResponse>;
31
+ list(options?: Core.RequestOptions): Core.APIPromise<RunListResponse>;
32
+ list(
33
+ query: RunListParams | Core.RequestOptions = {},
34
+ options?: Core.RequestOptions,
35
+ ): Core.APIPromise<RunListResponse> {
36
+ if (isRequestOptions(query)) {
37
+ return this.list({}, query);
38
+ }
39
+ return this._client.get('/v1/agents/runs', { query, ...options });
40
+ }
41
+
42
+ /**
43
+ * Returns a paginated list of messages produced by a run, in chronological order,
44
+ * with the oldest messages first.
45
+ *
46
+ * Messages conform to the
47
+ * [AI SDK UIMessage format](https://ai-sdk.dev/docs/reference/ai-sdk-core/ui-message).
48
+ */
49
+ listMessages(
50
+ runId: string,
51
+ query?: RunListMessagesParams,
52
+ options?: Core.RequestOptions,
53
+ ): Core.APIPromise<RunListMessagesResponse>;
54
+ listMessages(runId: string, options?: Core.RequestOptions): Core.APIPromise<RunListMessagesResponse>;
55
+ listMessages(
56
+ runId: string,
57
+ query: RunListMessagesParams | Core.RequestOptions = {},
58
+ options?: Core.RequestOptions,
59
+ ): Core.APIPromise<RunListMessagesResponse> {
60
+ if (isRequestOptions(query)) {
61
+ return this.listMessages(runId, {}, query);
62
+ }
63
+ return this._client.get(`/v1/agents/runs/${runId}/messages`, { query, ...options });
64
+ }
65
+ }
66
+
67
+ /**
68
+ * One execution of an agent against a task. Created in `pending` and transitioned
69
+ * through `running` → `completed`/`failed` by the runner.
70
+ */
71
+ export interface RunCreateResponse {
72
+ createdAt: string;
73
+
74
+ /**
75
+ * Unique identifier for the run.
76
+ */
77
+ runId: string;
78
+
79
+ /**
80
+ * Current status of the run.
81
+ *
82
+ * - `PENDING` - agent will run soon
83
+ * - `RUNNING` - agent is currently running
84
+ * - `COMPLETED` - agent has finished running
85
+ * - `FAILED` - agent has failed the run
86
+ * - `STOPPED` - run was stopped by the user
87
+ * - `TIMED_OUT` - run exceeded maximum time
88
+ */
89
+ status: 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'STOPPED' | 'TIMED_OUT';
90
+
91
+ /**
92
+ * The original task description.
93
+ */
94
+ task: string;
95
+
96
+ updatedAt: string;
97
+
98
+ /**
99
+ * The ID of the agent applied to this run, if any. Omitted for ad-hoc runs.
100
+ */
101
+ agentId?: string;
102
+
103
+ cause?: RunCreateResponse.Cause;
104
+
105
+ endedAt?: string;
106
+
107
+ /**
108
+ * The agent's structured result for the run. Only present when the run has
109
+ * finished and output is available. The result conforms to the provided
110
+ * [JSON Schema](https://json-schema.org/specification) when one is set.
111
+ */
112
+ result?: { [key: string]: unknown };
113
+
114
+ /**
115
+ * Per-run [JSON Schema](https://json-schema.org/specification) override for the
116
+ * result shape. When unset, the agent's default `resultSchema` applies.
117
+ */
118
+ resultSchema?: { [key: string]: unknown };
119
+
120
+ /**
121
+ * External sandbox identifier assigned by the runner. Optional.
122
+ */
123
+ sandboxId?: string;
124
+
125
+ /**
126
+ * The Browserbase session ID powering this run.
127
+ */
128
+ sessionId?: string;
129
+
130
+ startedAt?: string;
131
+ }
132
+
133
+ export namespace RunCreateResponse {
134
+ export interface Cause {
135
+ /**
136
+ * Structured failure code (e.g., RUNNER_HEARTBEAT_LOST).
137
+ */
138
+ code: string;
139
+
140
+ /**
141
+ * Human-readable failure detail.
142
+ */
143
+ message?: string;
144
+ }
145
+ }
146
+
147
+ /**
148
+ * One execution of an agent against a task. Created in `pending` and transitioned
149
+ * through `running` → `completed`/`failed` by the runner.
150
+ */
151
+ export interface RunRetrieveResponse {
152
+ createdAt: string;
153
+
154
+ /**
155
+ * Unique identifier for the run.
156
+ */
157
+ runId: string;
158
+
159
+ /**
160
+ * Current status of the run.
161
+ *
162
+ * - `PENDING` - agent will run soon
163
+ * - `RUNNING` - agent is currently running
164
+ * - `COMPLETED` - agent has finished running
165
+ * - `FAILED` - agent has failed the run
166
+ * - `STOPPED` - run was stopped by the user
167
+ * - `TIMED_OUT` - run exceeded maximum time
168
+ */
169
+ status: 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'STOPPED' | 'TIMED_OUT';
170
+
171
+ /**
172
+ * The original task description.
173
+ */
174
+ task: string;
175
+
176
+ updatedAt: string;
177
+
178
+ /**
179
+ * The ID of the agent applied to this run, if any. Omitted for ad-hoc runs.
180
+ */
181
+ agentId?: string;
182
+
183
+ cause?: RunRetrieveResponse.Cause;
184
+
185
+ endedAt?: string;
186
+
187
+ /**
188
+ * The agent's structured result for the run. Only present when the run has
189
+ * finished and output is available. The result conforms to the provided
190
+ * [JSON Schema](https://json-schema.org/specification) when one is set.
191
+ */
192
+ result?: { [key: string]: unknown };
193
+
194
+ /**
195
+ * Per-run [JSON Schema](https://json-schema.org/specification) override for the
196
+ * result shape. When unset, the agent's default `resultSchema` applies.
197
+ */
198
+ resultSchema?: { [key: string]: unknown };
199
+
200
+ /**
201
+ * External sandbox identifier assigned by the runner. Optional.
202
+ */
203
+ sandboxId?: string;
204
+
205
+ /**
206
+ * The Browserbase session ID powering this run.
207
+ */
208
+ sessionId?: string;
209
+
210
+ startedAt?: string;
211
+ }
212
+
213
+ export namespace RunRetrieveResponse {
214
+ export interface Cause {
215
+ /**
216
+ * Structured failure code (e.g., RUNNER_HEARTBEAT_LOST).
217
+ */
218
+ code: string;
219
+
220
+ /**
221
+ * Human-readable failure detail.
222
+ */
223
+ message?: string;
224
+ }
225
+ }
226
+
227
+ /**
228
+ * A page of agent runs.
229
+ */
230
+ export interface RunListResponse {
231
+ /**
232
+ * The page of matching agent runs.
233
+ */
234
+ data: Array<RunListResponse.Data>;
235
+
236
+ /**
237
+ * The maximum number of results returned in this page.
238
+ */
239
+ limit: number;
240
+
241
+ /**
242
+ * Cursor for the next page. Pass it back as `cursor` on the next request to
243
+ * continue paging. null when there are no more results.
244
+ */
245
+ nextCursor: string | null;
246
+ }
247
+
248
+ export namespace RunListResponse {
249
+ /**
250
+ * One execution of an agent against a task. Created in `pending` and transitioned
251
+ * through `running` → `completed`/`failed` by the runner.
252
+ */
253
+ export interface Data {
254
+ createdAt: string;
255
+
256
+ /**
257
+ * Unique identifier for the run.
258
+ */
259
+ runId: string;
260
+
261
+ /**
262
+ * Current status of the run.
263
+ *
264
+ * - `PENDING` - agent will run soon
265
+ * - `RUNNING` - agent is currently running
266
+ * - `COMPLETED` - agent has finished running
267
+ * - `FAILED` - agent has failed the run
268
+ * - `STOPPED` - run was stopped by the user
269
+ * - `TIMED_OUT` - run exceeded maximum time
270
+ */
271
+ status: 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'STOPPED' | 'TIMED_OUT';
272
+
273
+ /**
274
+ * The original task description.
275
+ */
276
+ task: string;
277
+
278
+ updatedAt: string;
279
+
280
+ /**
281
+ * The ID of the agent applied to this run, if any. Omitted for ad-hoc runs.
282
+ */
283
+ agentId?: string;
284
+
285
+ cause?: Data.Cause;
286
+
287
+ endedAt?: string;
288
+
289
+ /**
290
+ * The agent's structured result for the run. Only present when the run has
291
+ * finished and output is available. The result conforms to the provided
292
+ * [JSON Schema](https://json-schema.org/specification) when one is set.
293
+ */
294
+ result?: { [key: string]: unknown };
295
+
296
+ /**
297
+ * Per-run [JSON Schema](https://json-schema.org/specification) override for the
298
+ * result shape. When unset, the agent's default `resultSchema` applies.
299
+ */
300
+ resultSchema?: { [key: string]: unknown };
301
+
302
+ /**
303
+ * External sandbox identifier assigned by the runner. Optional.
304
+ */
305
+ sandboxId?: string;
306
+
307
+ /**
308
+ * The Browserbase session ID powering this run.
309
+ */
310
+ sessionId?: string;
311
+
312
+ startedAt?: string;
313
+ }
314
+
315
+ export namespace Data {
316
+ export interface Cause {
317
+ /**
318
+ * Structured failure code (e.g., RUNNER_HEARTBEAT_LOST).
319
+ */
320
+ code: string;
321
+
322
+ /**
323
+ * Human-readable failure detail.
324
+ */
325
+ message?: string;
326
+ }
327
+ }
328
+ }
329
+
330
+ export interface RunListMessagesResponse {
331
+ /**
332
+ * The page of messages, in chronological order, with the oldest messages first.
333
+ */
334
+ data: Array<RunListMessagesResponse.Data>;
335
+
336
+ /**
337
+ * The `id` of the last message in `data`. Pass it back as `since` on the next
338
+ * request to continue paging, or to poll for new messages. `null` only when the
339
+ * run has no messages yet; in that case, omit `since` and retry.
340
+ */
341
+ nextSince: string | null;
342
+ }
343
+
344
+ export namespace RunListMessagesResponse {
345
+ export interface Data {
346
+ id: string;
347
+
348
+ createdAt: string;
349
+
350
+ /**
351
+ * An AI SDK response message (assistant or tool).
352
+ */
353
+ message: Data.Message;
354
+ }
355
+
356
+ export namespace Data {
357
+ /**
358
+ * An AI SDK response message (assistant or tool).
359
+ */
360
+ export interface Message {
361
+ /**
362
+ * Plain string (assistant text) or an array of typed parts.
363
+ */
364
+ content: string | Array<Message.UnionMember1>;
365
+
366
+ role: 'assistant' | 'tool';
367
+
368
+ [k: string]: unknown;
369
+ }
370
+
371
+ export namespace Message {
372
+ export interface UnionMember1 {
373
+ /**
374
+ * text | reasoning | file | tool-call | tool-result
375
+ */
376
+ type: string;
377
+
378
+ data?: string;
379
+
380
+ input?: unknown;
381
+
382
+ mediaType?: string;
383
+
384
+ output?: unknown;
385
+
386
+ text?: string;
387
+
388
+ toolCallId?: string;
389
+
390
+ toolName?: string;
391
+
392
+ [k: string]: unknown;
393
+ }
394
+ }
395
+ }
396
+ }
397
+
398
+ export interface RunCreateParams {
399
+ /**
400
+ * A natural language description of the task the agent should accomplish.
401
+ */
402
+ task: string;
403
+
404
+ /**
405
+ * Optionally run a specific [custom agent](/reference/api/create-an-agent) you've
406
+ * created by ID. The run will use the agent's `systemPrompt` and `resultSchema`
407
+ * unless overridden.
408
+ */
409
+ agentId?: string;
410
+
411
+ /**
412
+ * Browser configuration for the agent's session. When omitted, runner defaults
413
+ * apply.
414
+ */
415
+ browserSettings?: RunCreateParams.BrowserSettings;
416
+
417
+ /**
418
+ * An optional [JSON Schema](https://json-schema.org/specification) object. If
419
+ * provided, the agent will aim to return a `result` that conforms to this schema
420
+ * when the run completes. Overrides the referenced agent's default `resultSchema`
421
+ * for this run only.
422
+ */
423
+ resultSchema?: { [key: string]: unknown };
424
+
425
+ /**
426
+ * Optional named variables the agent can reference as placeholders, i.e.
427
+ * `%variable%`. Each entry pairs a `value` the placeholder resolves to with an
428
+ * optional `description` that hints to the agent when it should be used. Values
429
+ * are not persisted.
430
+ */
431
+ variables?: { [key: string]: RunCreateParams.Variables };
432
+ }
433
+
434
+ export namespace RunCreateParams {
435
+ /**
436
+ * Browser configuration for the agent's session. When omitted, runner defaults
437
+ * apply.
438
+ */
439
+ export interface BrowserSettings {
440
+ context?: BrowserSettings.Context;
441
+
442
+ /**
443
+ * Set true to route the agent's browser session through the default proxy.
444
+ */
445
+ proxies?: boolean;
446
+
447
+ /**
448
+ * Set true to enable Browserbase Verified for the session.
449
+ */
450
+ verified?: boolean;
451
+ }
452
+
453
+ export namespace BrowserSettings {
454
+ export interface Context {
455
+ /**
456
+ * The Context ID.
457
+ */
458
+ id: string;
459
+
460
+ /**
461
+ * Whether to persist the context after browsing. Defaults to false.
462
+ */
463
+ persist?: boolean;
464
+ }
465
+ }
466
+
467
+ export interface Variables {
468
+ /**
469
+ * The value the placeholder resolves to when the agent uses it.
470
+ */
471
+ value: string;
472
+
473
+ /**
474
+ * Optional hint to the agent describing what this variable represents and when to
475
+ * use it.
476
+ */
477
+ description?: string;
478
+ }
479
+ }
480
+
481
+ export interface RunListParams {
482
+ /**
483
+ * Only return runs that reference this agent ID.
484
+ */
485
+ agentId?: string;
486
+
487
+ /**
488
+ * Pagination cursor. Pass the nextCursor from the previous response to fetch the
489
+ * next page. Omit to start from the first page.
490
+ */
491
+ cursor?: string;
492
+
493
+ /**
494
+ * Only return runs created on or before this timestamp (inclusive). ISO 8601 / RFC
495
+ * 3339, e.g. 2026-01-20T00:00:00Z.
496
+ */
497
+ endAt?: string;
498
+
499
+ /**
500
+ * Maximum number of results to return.
501
+ */
502
+ limit?: number;
503
+
504
+ /**
505
+ * Only return runs created on or after this timestamp (inclusive). ISO 8601 / RFC
506
+ * 3339, e.g. 2026-01-19T00:00:00Z.
507
+ */
508
+ startAt?: string;
509
+
510
+ /**
511
+ * Current status of the run.
512
+ *
513
+ * - `PENDING` - agent will run soon
514
+ * - `RUNNING` - agent is currently running
515
+ * - `COMPLETED` - agent has finished running
516
+ * - `FAILED` - agent has failed the run
517
+ * - `STOPPED` - run was stopped by the user
518
+ * - `TIMED_OUT` - run exceeded maximum time
519
+ */
520
+ status?: 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'STOPPED' | 'TIMED_OUT';
521
+ }
522
+
523
+ export interface RunListMessagesParams {
524
+ /**
525
+ * Return every message after `since` in one response, ignoring `limit`.
526
+ */
527
+ all?: boolean;
528
+
529
+ /**
530
+ * Maximum number of messages to return.
531
+ */
532
+ limit?: number;
533
+
534
+ /**
535
+ * The `id` of the last message you've already received. The response will contain
536
+ * messages produced after that one, in chronological order. Omit on the first
537
+ * call. Pass the previous response's `nextSince` value to continue paging or to
538
+ * poll for new messages.
539
+ */
540
+ since?: string;
541
+ }
542
+
543
+ export declare namespace Runs {
544
+ export {
545
+ type RunCreateResponse as RunCreateResponse,
546
+ type RunRetrieveResponse as RunRetrieveResponse,
547
+ type RunListResponse as RunListResponse,
548
+ type RunListMessagesResponse as RunListMessagesResponse,
549
+ type RunCreateParams as RunCreateParams,
550
+ type RunListParams as RunListParams,
551
+ type RunListMessagesParams as RunListMessagesParams,
552
+ };
553
+ }
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './agents/index';
@@ -1,5 +1,15 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ export {
4
+ Agents,
5
+ type AgentCreateResponse,
6
+ type AgentRetrieveResponse,
7
+ type AgentUpdateResponse,
8
+ type AgentListResponse,
9
+ type AgentCreateParams,
10
+ type AgentUpdateParams,
11
+ type AgentListParams,
12
+ } from './agents/agents';
3
13
  export {
4
14
  Certificates,
5
15
  type Certificate,
@@ -2,7 +2,7 @@
2
2
 
3
3
  export { Downloads } from './downloads';
4
4
  export { Logs, type SessionLog, type LogListResponse } from './logs';
5
- export { Recording, type SessionRecording, type RecordingRetrieveResponse } from './recording';
5
+ export { Recording, type SessionRecording, type RecordingRetrieveResponse } from './recording/index';
6
6
  export { Replays, type ReplayRetrieveResponse } from './replays';
7
7
  export {
8
8
  Sessions,
@@ -0,0 +1,66 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../resource';
4
+ import * as Core from '../../../core';
5
+
6
+ export class Downloads extends APIResource {
7
+ /**
8
+ * Requests one downloadable MP4 per recorded page of a session. Assembly runs
9
+ * asynchronously and every page returns as `PENDING`. Re-posting re-enqueues all
10
+ * pages and retries any that failed. Poll the GET endpoint for per-page status
11
+ * and, on standard (non-BYOS) projects, download URLs.
12
+ */
13
+ create(id: string, options?: Core.RequestOptions): Core.APIPromise<DownloadCreateResponse> {
14
+ return this._client.post(`/v1/sessions/${id}/recording/downloads`, options);
15
+ }
16
+
17
+ /**
18
+ * Returns the per-page download status for a session, with a short-lived signed
19
+ * URL for each completed page on standard (non-BYOS) projects.
20
+ */
21
+ list(id: string, options?: Core.RequestOptions): Core.APIPromise<DownloadListResponse> {
22
+ return this._client.get(`/v1/sessions/${id}/recording/downloads`, options);
23
+ }
24
+ }
25
+
26
+ export interface RecordingDownload {
27
+ /**
28
+ * Recorded page (tab) within the session, e.g. "0", "1".
29
+ */
30
+ pageId: string;
31
+
32
+ /**
33
+ * Per-page MP4 assembly state. `NOT_REQUESTED`: no download has been requested for
34
+ * the session yet. `PENDING`: assembly is enqueued or in progress. `COMPLETED`:
35
+ * the MP4 is ready. `FAILED`: assembly failed; POST again to retry.
36
+ */
37
+ status: 'NOT_REQUESTED' | 'PENDING' | 'COMPLETED' | 'FAILED';
38
+
39
+ /**
40
+ * When the MP4 was created. Present only when COMPLETED on a standard (non-BYOS)
41
+ * project.
42
+ */
43
+ completedAt?: string;
44
+
45
+ /**
46
+ * Short-lived signed CDN URL, re-minted each GET. Present only when COMPLETED on a
47
+ * standard (non-BYOS) project.
48
+ */
49
+ downloadUrl?: string;
50
+ }
51
+
52
+ export interface DownloadCreateResponse {
53
+ downloads: Array<RecordingDownload>;
54
+ }
55
+
56
+ export interface DownloadListResponse {
57
+ downloads: Array<RecordingDownload>;
58
+ }
59
+
60
+ export declare namespace Downloads {
61
+ export {
62
+ type RecordingDownload as RecordingDownload,
63
+ type DownloadCreateResponse as DownloadCreateResponse,
64
+ type DownloadListResponse as DownloadListResponse,
65
+ };
66
+ }
@@ -0,0 +1,9 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Downloads,
5
+ type RecordingDownload,
6
+ type DownloadCreateResponse,
7
+ type DownloadListResponse,
8
+ } from './downloads';
9
+ export { Recording, type SessionRecording, type RecordingRetrieveResponse } from './recording';
@@ -0,0 +1,52 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../resource';
4
+ import * as Core from '../../../core';
5
+ import * as DownloadsAPI from './downloads';
6
+ import { DownloadCreateResponse, DownloadListResponse, Downloads, RecordingDownload } from './downloads';
7
+
8
+ export class Recording extends APIResource {
9
+ downloads: DownloadsAPI.Downloads = new DownloadsAPI.Downloads(this._client);
10
+
11
+ /**
12
+ * Session Recording
13
+ */
14
+ retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<RecordingRetrieveResponse> {
15
+ return this._client.get(`/v1/sessions/${id}/recording`, options);
16
+ }
17
+ }
18
+
19
+ export interface SessionRecording {
20
+ /**
21
+ * See
22
+ * [rrweb documentation](https://github.com/rrweb-io/rrweb/blob/master/docs/recipes/dive-into-event.md).
23
+ */
24
+ data: { [key: string]: unknown };
25
+
26
+ sessionId: string;
27
+
28
+ /**
29
+ * milliseconds that have elapsed since the UNIX epoch
30
+ */
31
+ timestamp: number;
32
+
33
+ type: number;
34
+ }
35
+
36
+ export type RecordingRetrieveResponse = Array<SessionRecording>;
37
+
38
+ Recording.Downloads = Downloads;
39
+
40
+ export declare namespace Recording {
41
+ export {
42
+ type SessionRecording as SessionRecording,
43
+ type RecordingRetrieveResponse as RecordingRetrieveResponse,
44
+ };
45
+
46
+ export {
47
+ Downloads as Downloads,
48
+ type RecordingDownload as RecordingDownload,
49
+ type DownloadCreateResponse as DownloadCreateResponse,
50
+ type DownloadListResponse as DownloadListResponse,
51
+ };
52
+ }