@onkernel/sdk 0.20.0 → 0.21.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 (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/client.d.mts +7 -1
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +7 -1
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +3 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/browser-pools.d.mts +438 -0
  12. package/resources/browser-pools.d.mts.map +1 -0
  13. package/resources/browser-pools.d.ts +438 -0
  14. package/resources/browser-pools.d.ts.map +1 -0
  15. package/resources/browser-pools.js +125 -0
  16. package/resources/browser-pools.js.map +1 -0
  17. package/resources/browser-pools.mjs +121 -0
  18. package/resources/browser-pools.mjs.map +1 -0
  19. package/resources/browsers/browsers.d.mts +7 -150
  20. package/resources/browsers/browsers.d.mts.map +1 -1
  21. package/resources/browsers/browsers.d.ts +7 -150
  22. package/resources/browsers/browsers.d.ts.map +1 -1
  23. package/resources/browsers/browsers.js.map +1 -1
  24. package/resources/browsers/browsers.mjs.map +1 -1
  25. package/resources/index.d.mts +1 -0
  26. package/resources/index.d.mts.map +1 -1
  27. package/resources/index.d.ts +1 -0
  28. package/resources/index.d.ts.map +1 -1
  29. package/resources/index.js +3 -1
  30. package/resources/index.js.map +1 -1
  31. package/resources/index.mjs +1 -0
  32. package/resources/index.mjs.map +1 -1
  33. package/resources/shared.d.mts +61 -0
  34. package/resources/shared.d.mts.map +1 -1
  35. package/resources/shared.d.ts +61 -0
  36. package/resources/shared.d.ts.map +1 -1
  37. package/src/client.ts +37 -1
  38. package/src/resources/browser-pools.ts +560 -0
  39. package/src/resources/browsers/browsers.ts +7 -167
  40. package/src/resources/index.ts +15 -0
  41. package/src/resources/shared.ts +69 -0
  42. package/src/version.ts +1 -1
  43. package/version.d.mts +1 -1
  44. package/version.d.ts +1 -1
  45. package/version.js +1 -1
  46. package/version.mjs +1 -1
@@ -0,0 +1,560 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as Shared from './shared';
5
+ import * as BrowsersAPI from './browsers/browsers';
6
+ import { APIPromise } from '../core/api-promise';
7
+ import { buildHeaders } from '../internal/headers';
8
+ import { RequestOptions } from '../internal/request-options';
9
+ import { path } from '../internal/utils/path';
10
+
11
+ export class BrowserPools extends APIResource {
12
+ /**
13
+ * Create a new browser pool with the specified configuration and size.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const browserPool = await client.browserPools.create({
18
+ * size: 10,
19
+ * });
20
+ * ```
21
+ */
22
+ create(body: BrowserPoolCreateParams, options?: RequestOptions): APIPromise<BrowserPool> {
23
+ return this._client.post('/browser_pools', { body, ...options });
24
+ }
25
+
26
+ /**
27
+ * Retrieve details for a single browser pool by its ID or name.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const browserPool = await client.browserPools.retrieve(
32
+ * 'id_or_name',
33
+ * );
34
+ * ```
35
+ */
36
+ retrieve(idOrName: string, options?: RequestOptions): APIPromise<BrowserPool> {
37
+ return this._client.get(path`/browser_pools/${idOrName}`, options);
38
+ }
39
+
40
+ /**
41
+ * Updates the configuration used to create browsers in the pool.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const browserPool = await client.browserPools.update(
46
+ * 'id_or_name',
47
+ * { size: 10 },
48
+ * );
49
+ * ```
50
+ */
51
+ update(idOrName: string, body: BrowserPoolUpdateParams, options?: RequestOptions): APIPromise<BrowserPool> {
52
+ return this._client.patch(path`/browser_pools/${idOrName}`, { body, ...options });
53
+ }
54
+
55
+ /**
56
+ * List browser pools owned by the caller's organization.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const browserPools = await client.browserPools.list();
61
+ * ```
62
+ */
63
+ list(options?: RequestOptions): APIPromise<BrowserPoolListResponse> {
64
+ return this._client.get('/browser_pools', options);
65
+ }
66
+
67
+ /**
68
+ * Delete a browser pool and all browsers in it. By default, deletion is blocked if
69
+ * browsers are currently leased. Use force=true to terminate leased browsers.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * await client.browserPools.delete('id_or_name');
74
+ * ```
75
+ */
76
+ delete(
77
+ idOrName: string,
78
+ body: BrowserPoolDeleteParams | null | undefined = {},
79
+ options?: RequestOptions,
80
+ ): APIPromise<void> {
81
+ return this._client.delete(path`/browser_pools/${idOrName}`, {
82
+ body,
83
+ ...options,
84
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
85
+ });
86
+ }
87
+
88
+ /**
89
+ * Long-polling endpoint to acquire a browser from the pool. Returns immediately
90
+ * when a browser is available, or returns 204 No Content when the poll times out.
91
+ * The client should retry the request to continue waiting for a browser. The
92
+ * acquired browser will use the pool's timeout_seconds for its idle timeout.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const response = await client.browserPools.acquire(
97
+ * 'id_or_name',
98
+ * );
99
+ * ```
100
+ */
101
+ acquire(
102
+ idOrName: string,
103
+ body: BrowserPoolAcquireParams,
104
+ options?: RequestOptions,
105
+ ): APIPromise<BrowserPoolAcquireResponse> {
106
+ return this._client.post(path`/browser_pools/${idOrName}/acquire`, { body, ...options });
107
+ }
108
+
109
+ /**
110
+ * Destroys all idle browsers in the pool; leased browsers are not affected.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * await client.browserPools.flush('id_or_name');
115
+ * ```
116
+ */
117
+ flush(idOrName: string, options?: RequestOptions): APIPromise<void> {
118
+ return this._client.post(path`/browser_pools/${idOrName}/flush`, {
119
+ ...options,
120
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
121
+ });
122
+ }
123
+
124
+ /**
125
+ * Release a browser back to the pool, optionally recreating the browser instance.
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * await client.browserPools.release('id_or_name', {
130
+ * session_id: 'ts8iy3sg25ibheguyni2lg9t',
131
+ * });
132
+ * ```
133
+ */
134
+ release(idOrName: string, body: BrowserPoolReleaseParams, options?: RequestOptions): APIPromise<void> {
135
+ return this._client.post(path`/browser_pools/${idOrName}/release`, {
136
+ body,
137
+ ...options,
138
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
139
+ });
140
+ }
141
+ }
142
+
143
+ /**
144
+ * A browser pool containing multiple identically configured browsers.
145
+ */
146
+ export interface BrowserPool {
147
+ /**
148
+ * Unique identifier for the browser pool
149
+ */
150
+ id: string;
151
+
152
+ /**
153
+ * Number of browsers currently acquired from the pool
154
+ */
155
+ acquired_count: number;
156
+
157
+ /**
158
+ * Number of browsers currently available in the pool
159
+ */
160
+ available_count: number;
161
+
162
+ /**
163
+ * Configuration used to create all browsers in this pool
164
+ */
165
+ browser_pool_config: BrowserPoolRequest;
166
+
167
+ /**
168
+ * Timestamp when the browser pool was created
169
+ */
170
+ created_at: string;
171
+
172
+ /**
173
+ * Browser pool name, if set
174
+ */
175
+ name?: string;
176
+ }
177
+
178
+ /**
179
+ * Request body for acquiring a browser from the pool.
180
+ */
181
+ export interface BrowserPoolAcquireRequest {
182
+ /**
183
+ * Maximum number of seconds to wait for a browser to be available. Defaults to the
184
+ * calculated time it would take to fill the pool at the currently configured fill
185
+ * rate.
186
+ */
187
+ acquire_timeout_seconds?: number;
188
+ }
189
+
190
+ /**
191
+ * Request body for releasing a browser back to the pool.
192
+ */
193
+ export interface BrowserPoolReleaseRequest {
194
+ /**
195
+ * Browser session ID to release back to the pool
196
+ */
197
+ session_id: string;
198
+
199
+ /**
200
+ * Whether to reuse the browser instance or destroy it and create a new one.
201
+ * Defaults to true.
202
+ */
203
+ reuse?: boolean;
204
+ }
205
+
206
+ /**
207
+ * Parameters for creating a browser pool. All browsers in the pool will be created
208
+ * with the same configuration.
209
+ */
210
+ export interface BrowserPoolRequest {
211
+ /**
212
+ * Number of browsers to create in the pool
213
+ */
214
+ size: number;
215
+
216
+ /**
217
+ * List of browser extensions to load into the session. Provide each by id or name.
218
+ */
219
+ extensions?: Array<Shared.BrowserExtension>;
220
+
221
+ /**
222
+ * Percentage of the pool to fill per minute. Defaults to 10%.
223
+ */
224
+ fill_rate_per_minute?: number;
225
+
226
+ /**
227
+ * If true, launches the browser using a headless image. Defaults to false.
228
+ */
229
+ headless?: boolean;
230
+
231
+ /**
232
+ * If true, launches the browser in kiosk mode to hide address bar and tabs in live
233
+ * view.
234
+ */
235
+ kiosk_mode?: boolean;
236
+
237
+ /**
238
+ * Optional name for the browser pool. Must be unique within the organization.
239
+ */
240
+ name?: string;
241
+
242
+ /**
243
+ * Profile selection for the browser session. Provide either id or name. If
244
+ * specified, the matching profile will be loaded into the browser session.
245
+ * Profiles must be created beforehand.
246
+ */
247
+ profile?: Shared.BrowserProfile;
248
+
249
+ /**
250
+ * Optional proxy to associate to the browser session. Must reference a proxy
251
+ * belonging to the caller's org.
252
+ */
253
+ proxy_id?: string;
254
+
255
+ /**
256
+ * If true, launches the browser in stealth mode to reduce detection by anti-bot
257
+ * mechanisms.
258
+ */
259
+ stealth?: boolean;
260
+
261
+ /**
262
+ * Default idle timeout in seconds for browsers acquired from this pool before they
263
+ * are destroyed. Defaults to 600 seconds if not specified
264
+ */
265
+ timeout_seconds?: number;
266
+
267
+ /**
268
+ * Initial browser window size in pixels with optional refresh rate. If omitted,
269
+ * image defaults apply (commonly 1024x768@60). Only specific viewport
270
+ * configurations are supported. The server will reject unsupported combinations.
271
+ * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
272
+ * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will
273
+ * be automatically determined from the width and height if they match a supported
274
+ * configuration exactly. Note: Higher resolutions may affect the responsiveness of
275
+ * live view browser
276
+ */
277
+ viewport?: Shared.BrowserViewport;
278
+ }
279
+
280
+ /**
281
+ * Parameters for updating a browser pool. All browsers in the pool will be created
282
+ * with the same configuration.
283
+ */
284
+ export interface BrowserPoolUpdateRequest extends BrowserPoolRequest {
285
+ /**
286
+ * Whether to discard all idle browsers and rebuild the pool immediately. Defaults
287
+ * to true.
288
+ */
289
+ discard_all_idle?: boolean;
290
+ }
291
+
292
+ export type BrowserPoolListResponse = Array<BrowserPool>;
293
+
294
+ export interface BrowserPoolAcquireResponse {
295
+ /**
296
+ * Websocket URL for Chrome DevTools Protocol connections to the browser session
297
+ */
298
+ cdp_ws_url: string;
299
+
300
+ /**
301
+ * When the browser session was created.
302
+ */
303
+ created_at: string;
304
+
305
+ /**
306
+ * Whether the browser session is running in headless mode.
307
+ */
308
+ headless: boolean;
309
+
310
+ /**
311
+ * Unique identifier for the browser session
312
+ */
313
+ session_id: string;
314
+
315
+ /**
316
+ * Whether the browser session is running in stealth mode.
317
+ */
318
+ stealth: boolean;
319
+
320
+ /**
321
+ * The number of seconds of inactivity before the browser session is terminated.
322
+ */
323
+ timeout_seconds: number;
324
+
325
+ /**
326
+ * Remote URL for live viewing the browser session. Only available for non-headless
327
+ * browsers.
328
+ */
329
+ browser_live_view_url?: string;
330
+
331
+ /**
332
+ * When the browser session was soft-deleted. Only present for deleted sessions.
333
+ */
334
+ deleted_at?: string;
335
+
336
+ /**
337
+ * Whether the browser session is running in kiosk mode.
338
+ */
339
+ kiosk_mode?: boolean;
340
+
341
+ /**
342
+ * Optional persistence configuration for the browser session.
343
+ */
344
+ persistence?: BrowsersAPI.BrowserPersistence;
345
+
346
+ /**
347
+ * Browser profile metadata.
348
+ */
349
+ profile?: BrowsersAPI.Profile;
350
+
351
+ /**
352
+ * ID of the proxy associated with this browser session, if any.
353
+ */
354
+ proxy_id?: string;
355
+
356
+ /**
357
+ * Initial browser window size in pixels with optional refresh rate. If omitted,
358
+ * image defaults apply (commonly 1024x768@60). Only specific viewport
359
+ * configurations are supported. The server will reject unsupported combinations.
360
+ * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
361
+ * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will
362
+ * be automatically determined from the width and height if they match a supported
363
+ * configuration exactly. Note: Higher resolutions may affect the responsiveness of
364
+ * live view browser
365
+ */
366
+ viewport?: Shared.BrowserViewport;
367
+ }
368
+
369
+ export interface BrowserPoolCreateParams {
370
+ /**
371
+ * Number of browsers to create in the pool
372
+ */
373
+ size: number;
374
+
375
+ /**
376
+ * List of browser extensions to load into the session. Provide each by id or name.
377
+ */
378
+ extensions?: Array<Shared.BrowserExtension>;
379
+
380
+ /**
381
+ * Percentage of the pool to fill per minute. Defaults to 10%.
382
+ */
383
+ fill_rate_per_minute?: number;
384
+
385
+ /**
386
+ * If true, launches the browser using a headless image. Defaults to false.
387
+ */
388
+ headless?: boolean;
389
+
390
+ /**
391
+ * If true, launches the browser in kiosk mode to hide address bar and tabs in live
392
+ * view.
393
+ */
394
+ kiosk_mode?: boolean;
395
+
396
+ /**
397
+ * Optional name for the browser pool. Must be unique within the organization.
398
+ */
399
+ name?: string;
400
+
401
+ /**
402
+ * Profile selection for the browser session. Provide either id or name. If
403
+ * specified, the matching profile will be loaded into the browser session.
404
+ * Profiles must be created beforehand.
405
+ */
406
+ profile?: Shared.BrowserProfile;
407
+
408
+ /**
409
+ * Optional proxy to associate to the browser session. Must reference a proxy
410
+ * belonging to the caller's org.
411
+ */
412
+ proxy_id?: string;
413
+
414
+ /**
415
+ * If true, launches the browser in stealth mode to reduce detection by anti-bot
416
+ * mechanisms.
417
+ */
418
+ stealth?: boolean;
419
+
420
+ /**
421
+ * Default idle timeout in seconds for browsers acquired from this pool before they
422
+ * are destroyed. Defaults to 600 seconds if not specified
423
+ */
424
+ timeout_seconds?: number;
425
+
426
+ /**
427
+ * Initial browser window size in pixels with optional refresh rate. If omitted,
428
+ * image defaults apply (commonly 1024x768@60). Only specific viewport
429
+ * configurations are supported. The server will reject unsupported combinations.
430
+ * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
431
+ * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will
432
+ * be automatically determined from the width and height if they match a supported
433
+ * configuration exactly. Note: Higher resolutions may affect the responsiveness of
434
+ * live view browser
435
+ */
436
+ viewport?: Shared.BrowserViewport;
437
+ }
438
+
439
+ export interface BrowserPoolUpdateParams {
440
+ /**
441
+ * Number of browsers to create in the pool
442
+ */
443
+ size: number;
444
+
445
+ /**
446
+ * Whether to discard all idle browsers and rebuild the pool immediately. Defaults
447
+ * to true.
448
+ */
449
+ discard_all_idle?: boolean;
450
+
451
+ /**
452
+ * List of browser extensions to load into the session. Provide each by id or name.
453
+ */
454
+ extensions?: Array<Shared.BrowserExtension>;
455
+
456
+ /**
457
+ * Percentage of the pool to fill per minute. Defaults to 10%.
458
+ */
459
+ fill_rate_per_minute?: number;
460
+
461
+ /**
462
+ * If true, launches the browser using a headless image. Defaults to false.
463
+ */
464
+ headless?: boolean;
465
+
466
+ /**
467
+ * If true, launches the browser in kiosk mode to hide address bar and tabs in live
468
+ * view.
469
+ */
470
+ kiosk_mode?: boolean;
471
+
472
+ /**
473
+ * Optional name for the browser pool. Must be unique within the organization.
474
+ */
475
+ name?: string;
476
+
477
+ /**
478
+ * Profile selection for the browser session. Provide either id or name. If
479
+ * specified, the matching profile will be loaded into the browser session.
480
+ * Profiles must be created beforehand.
481
+ */
482
+ profile?: Shared.BrowserProfile;
483
+
484
+ /**
485
+ * Optional proxy to associate to the browser session. Must reference a proxy
486
+ * belonging to the caller's org.
487
+ */
488
+ proxy_id?: string;
489
+
490
+ /**
491
+ * If true, launches the browser in stealth mode to reduce detection by anti-bot
492
+ * mechanisms.
493
+ */
494
+ stealth?: boolean;
495
+
496
+ /**
497
+ * Default idle timeout in seconds for browsers acquired from this pool before they
498
+ * are destroyed. Defaults to 600 seconds if not specified
499
+ */
500
+ timeout_seconds?: number;
501
+
502
+ /**
503
+ * Initial browser window size in pixels with optional refresh rate. If omitted,
504
+ * image defaults apply (commonly 1024x768@60). Only specific viewport
505
+ * configurations are supported. The server will reject unsupported combinations.
506
+ * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
507
+ * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will
508
+ * be automatically determined from the width and height if they match a supported
509
+ * configuration exactly. Note: Higher resolutions may affect the responsiveness of
510
+ * live view browser
511
+ */
512
+ viewport?: Shared.BrowserViewport;
513
+ }
514
+
515
+ export interface BrowserPoolDeleteParams {
516
+ /**
517
+ * If true, force delete even if browsers are currently leased. Leased browsers
518
+ * will be terminated.
519
+ */
520
+ force?: boolean;
521
+ }
522
+
523
+ export interface BrowserPoolAcquireParams {
524
+ /**
525
+ * Maximum number of seconds to wait for a browser to be available. Defaults to the
526
+ * calculated time it would take to fill the pool at the currently configured fill
527
+ * rate.
528
+ */
529
+ acquire_timeout_seconds?: number;
530
+ }
531
+
532
+ export interface BrowserPoolReleaseParams {
533
+ /**
534
+ * Browser session ID to release back to the pool
535
+ */
536
+ session_id: string;
537
+
538
+ /**
539
+ * Whether to reuse the browser instance or destroy it and create a new one.
540
+ * Defaults to true.
541
+ */
542
+ reuse?: boolean;
543
+ }
544
+
545
+ export declare namespace BrowserPools {
546
+ export {
547
+ type BrowserPool as BrowserPool,
548
+ type BrowserPoolAcquireRequest as BrowserPoolAcquireRequest,
549
+ type BrowserPoolReleaseRequest as BrowserPoolReleaseRequest,
550
+ type BrowserPoolRequest as BrowserPoolRequest,
551
+ type BrowserPoolUpdateRequest as BrowserPoolUpdateRequest,
552
+ type BrowserPoolListResponse as BrowserPoolListResponse,
553
+ type BrowserPoolAcquireResponse as BrowserPoolAcquireResponse,
554
+ type BrowserPoolCreateParams as BrowserPoolCreateParams,
555
+ type BrowserPoolUpdateParams as BrowserPoolUpdateParams,
556
+ type BrowserPoolDeleteParams as BrowserPoolDeleteParams,
557
+ type BrowserPoolAcquireParams as BrowserPoolAcquireParams,
558
+ type BrowserPoolReleaseParams as BrowserPoolReleaseParams,
559
+ };
560
+ }