Skip to content

Commit f3fdc89

Browse files
refactor(browser): remove persistence option UI
1 parent c611df9 commit f3fdc89

File tree

4 files changed

+38
-41
lines changed

4 files changed

+38
-41
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 74
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-003e9afa15f0765009d2c7d34e8eb62268d818e628e3c84361b21138e30cc423.yml
3-
openapi_spec_hash: c1b8309f60385bf2b02d245363ca47c1
4-
config_hash: a4124701ae0a474e580d7416adbcfb00
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-cbef7e4fef29ad40af5c767aceb762ee68811c2287f255c05d2ee44a9a9247a2.yml
3+
openapi_spec_hash: 467e61e072773ec9f2d49c7dd3de8c2f
4+
config_hash: 6dbe88d2ba9df1ec46cedbfdb7d00000

README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const client = new Kernel({
2727
environment: 'development', // defaults to 'production'
2828
});
2929

30-
const browser = await client.browsers.create({ persistence: { id: 'browser-for-user-1234' } });
30+
const browser = await client.browsers.create({ stealth: true });
3131

3232
console.log(browser.session_id);
3333
```
@@ -45,7 +45,7 @@ const client = new Kernel({
4545
environment: 'development', // defaults to 'production'
4646
});
4747

48-
const params: Kernel.BrowserCreateParams = { persistence: { id: 'browser-for-user-1234' } };
48+
const params: Kernel.BrowserCreateParams = { stealth: true };
4949
const browser: Kernel.BrowserCreateResponse = await client.browsers.create(params);
5050
```
5151

@@ -88,17 +88,15 @@ a subclass of `APIError` will be thrown:
8888

8989
<!-- prettier-ignore -->
9090
```ts
91-
const browser = await client.browsers
92-
.create({ persistence: { id: 'browser-for-user-1234' } })
93-
.catch(async (err) => {
94-
if (err instanceof Kernel.APIError) {
95-
console.log(err.status); // 400
96-
console.log(err.name); // BadRequestError
97-
console.log(err.headers); // {server: 'nginx', ...}
98-
} else {
99-
throw err;
100-
}
101-
});
91+
const browser = await client.browsers.create({ stealth: true }).catch(async (err) => {
92+
if (err instanceof Kernel.APIError) {
93+
console.log(err.status); // 400
94+
console.log(err.name); // BadRequestError
95+
console.log(err.headers); // {server: 'nginx', ...}
96+
} else {
97+
throw err;
98+
}
99+
});
102100
```
103101

104102
Error codes are as follows:
@@ -130,7 +128,7 @@ const client = new Kernel({
130128
});
131129

132130
// Or, configure per-request:
133-
await client.browsers.create({ persistence: { id: 'browser-for-user-1234' } }, {
131+
await client.browsers.create({ stealth: true }, {
134132
maxRetries: 5,
135133
});
136134
```
@@ -147,7 +145,7 @@ const client = new Kernel({
147145
});
148146

149147
// Override per-request:
150-
await client.browsers.create({ persistence: { id: 'browser-for-user-1234' } }, {
148+
await client.browsers.create({ stealth: true }, {
151149
timeout: 5 * 1000,
152150
});
153151
```
@@ -201,13 +199,11 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
201199
```ts
202200
const client = new Kernel();
203201

204-
const response = await client.browsers.create({ persistence: { id: 'browser-for-user-1234' } }).asResponse();
202+
const response = await client.browsers.create({ stealth: true }).asResponse();
205203
console.log(response.headers.get('X-My-Header'));
206204
console.log(response.statusText); // access the underlying Response object
207205

208-
const { data: browser, response: raw } = await client.browsers
209-
.create({ persistence: { id: 'browser-for-user-1234' } })
210-
.withResponse();
206+
const { data: browser, response: raw } = await client.browsers.create({ stealth: true }).withResponse();
211207
console.log(raw.headers.get('X-My-Header'));
212208
console.log(browser.session_id);
213209
```

src/resources/browser-pools.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ export interface BrowserPoolAcquireResponse {
339339
kiosk_mode?: boolean;
340340

341341
/**
342-
* Optional persistence configuration for the browser session.
342+
* @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles
343+
* instead.
343344
*/
344345
persistence?: BrowsersAPI.BrowserPersistence;
345346

src/resources/browsers/browsers.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,10 @@ export class Browsers extends APIResource {
127127
}
128128

129129
/**
130-
* Delete a persistent browser session by its persistent_id.
130+
* DEPRECATED: Use DELETE /browsers/{id} instead. Delete a persistent browser
131+
* session by its persistent_id.
131132
*
132-
* @example
133-
* ```ts
134-
* await client.browsers.delete({
135-
* persistent_id: 'persistent_id',
136-
* });
137-
* ```
133+
* @deprecated
138134
*/
139135
delete(params: BrowserDeleteParams, options?: RequestOptions): APIPromise<void> {
140136
const { persistent_id } = params;
@@ -192,11 +188,12 @@ export class Browsers extends APIResource {
192188
export type BrowserListResponsesOffsetPagination = OffsetPagination<BrowserListResponse>;
193189

194190
/**
195-
* Optional persistence configuration for the browser session.
191+
* @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles
192+
* instead.
196193
*/
197194
export interface BrowserPersistence {
198195
/**
199-
* Unique identifier for the persistent browser session.
196+
* DEPRECATED: Unique identifier for the persistent browser session.
200197
*/
201198
id: string;
202199
}
@@ -279,7 +276,8 @@ export interface BrowserCreateResponse {
279276
kiosk_mode?: boolean;
280277

281278
/**
282-
* Optional persistence configuration for the browser session.
279+
* @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles
280+
* instead.
283281
*/
284282
persistence?: BrowserPersistence;
285283

@@ -354,7 +352,8 @@ export interface BrowserRetrieveResponse {
354352
kiosk_mode?: boolean;
355353

356354
/**
357-
* Optional persistence configuration for the browser session.
355+
* @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles
356+
* instead.
358357
*/
359358
persistence?: BrowserPersistence;
360359

@@ -429,7 +428,8 @@ export interface BrowserListResponse {
429428
kiosk_mode?: boolean;
430429

431430
/**
432-
* Optional persistence configuration for the browser session.
431+
* @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles
432+
* instead.
433433
*/
434434
persistence?: BrowserPersistence;
435435

@@ -480,7 +480,8 @@ export interface BrowserCreateParams {
480480
kiosk_mode?: boolean;
481481

482482
/**
483-
* Optional persistence configuration for the browser session.
483+
* @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles
484+
* instead.
484485
*/
485486
persistence?: BrowserPersistence;
486487

@@ -505,11 +506,10 @@ export interface BrowserCreateParams {
505506

506507
/**
507508
* The number of seconds of inactivity before the browser session is terminated.
508-
* Only applicable to non-persistent browsers. Activity includes CDP connections
509-
* and live view connections. Defaults to 60 seconds. Minimum allowed is 10
510-
* seconds. Maximum allowed is 259200 (72 hours). We check for inactivity every 5
511-
* seconds, so the actual timeout behavior you will see is +/- 5 seconds around the
512-
* specified value.
509+
* Activity includes CDP connections and live view connections. Defaults to 60
510+
* seconds. Minimum allowed is 10 seconds. Maximum allowed is 259200 (72 hours). We
511+
* check for inactivity every 5 seconds, so the actual timeout behavior you will
512+
* see is +/- 5 seconds around the specified value.
513513
*/
514514
timeout_seconds?: number;
515515

0 commit comments

Comments
 (0)