diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 94e69931..e5452f67 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.133.0" + ".": "0.134.0" } diff --git a/.stats.yml b/.stats.yml index caa7c062..ea0d5273 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 175 +configured_endpoints: 176 diff --git a/CHANGELOG.md b/CHANGELOG.md index db2f0b32..8428797a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.134.0](https://github.com/kernel/kernel-node-sdk/compare/v0.133.0...v0.134.0) (2026-10-28) + + +### Features + +* Add mid-session browser profile saves ([2aef0a4](https://github.com/kernel/kernel-node-sdk/commit/2aef0a43a0e013b09b31f4527a6af3f3c84ac4c9)) + ## [0.133.0](https://github.com/kernel/kernel-node-sdk/compare/v0.132.0...v0.133.0) (2026-10-28) diff --git a/api.md b/api.md index ea5699e2..e8fb7919 100644 --- a/api.md +++ b/api.md @@ -120,6 +120,7 @@ Types: - BrowserUsage - BrowserVideoMemory - Profile +- SaveProfileRequest - Tags - VaultReference - BrowserCreateResponse @@ -138,6 +139,7 @@ Methods: - client.browsers.deleteByID(idOrName) -> void - client.browsers.loadExtensions(idOrName, { ...params }) -> void - client.browsers.repl(idOrName, { ...params }) -> BrowserReplResult +- client.browsers.saveProfile(idOrName, { ...params }) -> Profile ## Telemetry diff --git a/package.json b/package.json index f3f49712..24f2e575 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/sdk", - "version": "0.133.0", + "version": "0.134.0", "description": "The official TypeScript library for the Kernel API", "author": "Kernel <>", "types": "dist/index.d.ts", diff --git a/src/client.ts b/src/client.ts index 56af4ee9..645e4fb7 100644 --- a/src/client.ts +++ b/src/client.ts @@ -182,12 +182,14 @@ import { BrowserReplTextContent, BrowserRetrieveParams, BrowserRetrieveResponse, + BrowserSaveProfileParams, BrowserUpdateParams, BrowserUpdateResponse, BrowserUsage, BrowserVideoMemory, Browsers, Profile, + SaveProfileRequest, Tags, VaultReference, } from './resources/browsers/browsers'; @@ -1248,6 +1250,7 @@ export declare namespace Kernel { type BrowserUsage as BrowserUsage, type BrowserVideoMemory as BrowserVideoMemory, type Profile as Profile, + type SaveProfileRequest as SaveProfileRequest, type Tags as Tags, type VaultReference as VaultReference, type BrowserCreateResponse as BrowserCreateResponse, @@ -1263,6 +1266,7 @@ export declare namespace Kernel { type BrowserCurlParams as BrowserCurlParams, type BrowserLoadExtensionsParams as BrowserLoadExtensionsParams, type BrowserReplParams as BrowserReplParams, + type BrowserSaveProfileParams as BrowserSaveProfileParams, }; export { diff --git a/src/resources/browsers/browsers.ts b/src/resources/browsers/browsers.ts index b501f9b2..8a446879 100644 --- a/src/resources/browsers/browsers.ts +++ b/src/resources/browsers/browsers.ts @@ -340,6 +340,51 @@ export class Browsers extends APIResource { repl(idOrName: string, body: BrowserReplParams, options?: RequestOptions): APIPromise { return this._client.post(path`/browsers/${idOrName}/repl`, { body, ...options }); } + + /** + * Saves the running browser's current user-data state to an existing or new + * profile without ending the browser session. + * + * Saving restarts the browser. Active CDP and WebDriver connections are closed and + * must reconnect, and WebDriver clients must create a new session. Open tabs are + * restored, but pages reload and in-memory page state is lost. The browser is + * stopped only while its user data is copied; this request returns once the + * restarted browser accepts CDP connections again and the profile has been + * uploaded. Caches, Service Worker storage and Google Drive IndexedDB data are + * left out of the saved profile but kept in the running browser. + * + * This does not attach the destination profile to the browser or change its + * save_changes setting. Active browsers that already loaded the destination + * profile keep their in-memory state. Pools with refresh_on_profile_update enabled + * flush idle sessions and replenish them from the new snapshot; other browsers + * receive it the next time they load the profile. When saves made with this + * endpoint to the same profile overlap, the save that started most recently wins, + * even if an earlier one finishes later. The automatic save at the end of a + * session whose profile has save_changes enabled is ordered against these saves by + * when each finishes. + * + * A successful save restarts the browser's inactivity timeout (timeout_seconds). A + * failed save leaves it unchanged. + * + * Returns 409 when the browser is no longer active, when a pooled browser was + * released or reacquired after the request was made (browser_lease_changed), or + * when the browser is briefly unable to accept a save (browser_busy), in which + * case the request can be retried. + * + * @example + * ```ts + * const profile = await client.browsers.saveProfile( + * 'htzv5orfit78e1m2biiifpbv', + * ); + * ``` + */ + saveProfile( + idOrName: string, + body: BrowserSaveProfileParams, + options?: RequestOptions, + ): APIPromise { + return this._client.post(path`/browsers/${idOrName}/profiles`, { body, ...options }); + } } export type BrowserListResponsesOffsetPagination = OffsetPagination; @@ -818,6 +863,23 @@ export interface Profile { updated_at?: string; } +/** + * Destination profile for a snapshot of the running browser. Provide either id or + * name. An id must identify an existing profile. A name overwrites the matching + * profile in the browser's project, or creates it when no matching profile exists. + */ +export interface SaveProfileRequest { + /** + * Existing profile ID to overwrite. + */ + id?: string; + + /** + * Profile name to overwrite or create. + */ + name?: string; +} + /** * User-defined key-value tags. */ @@ -2174,6 +2236,18 @@ export interface BrowserReplParams { timeout_sec?: number; } +export interface BrowserSaveProfileParams { + /** + * Existing profile ID to overwrite. + */ + id?: string; + + /** + * Profile name to overwrite or create. + */ + name?: string; +} + Browsers.Telemetry = TelemetryAPITelemetry; Browsers.Replays = Replays; Browsers.Fs = Fs; @@ -2206,6 +2280,7 @@ export declare namespace Browsers { type BrowserUsage as BrowserUsage, type BrowserVideoMemory as BrowserVideoMemory, type Profile as Profile, + type SaveProfileRequest as SaveProfileRequest, type Tags as Tags, type VaultReference as VaultReference, type BrowserCreateResponse as BrowserCreateResponse, @@ -2221,6 +2296,7 @@ export declare namespace Browsers { type BrowserCurlParams as BrowserCurlParams, type BrowserLoadExtensionsParams as BrowserLoadExtensionsParams, type BrowserReplParams as BrowserReplParams, + type BrowserSaveProfileParams as BrowserSaveProfileParams, }; export { diff --git a/src/resources/browsers/index.ts b/src/resources/browsers/index.ts index 86903fcf..6d8e8bf8 100644 --- a/src/resources/browsers/index.ts +++ b/src/resources/browsers/index.ts @@ -23,6 +23,7 @@ export { type BrowserUsage, type BrowserVideoMemory, type Profile, + type SaveProfileRequest, type Tags, type VaultReference, type BrowserCreateResponse, @@ -37,6 +38,7 @@ export { type BrowserCurlParams, type BrowserLoadExtensionsParams, type BrowserReplParams, + type BrowserSaveProfileParams, type ProfilesOffsetPagination, type BrowserListResponsesOffsetPagination, } from './browsers'; diff --git a/src/resources/index.ts b/src/resources/index.ts index 07ba54ef..4e440460 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -61,6 +61,7 @@ export { type BrowserUsage, type BrowserVideoMemory, type Profile, + type SaveProfileRequest, type Tags, type VaultReference, type BrowserCreateResponse, @@ -75,6 +76,7 @@ export { type BrowserCurlParams, type BrowserLoadExtensionsParams, type BrowserReplParams, + type BrowserSaveProfileParams, type ProfilesOffsetPagination, type BrowserListResponsesOffsetPagination, } from './browsers/browsers'; diff --git a/src/version.ts b/src/version.ts index daf15132..9cd2d099 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.133.0'; // x-release-please-version +export const VERSION = '0.134.0'; // x-release-please-version diff --git a/tests/api-resources/browsers/browsers.test.ts b/tests/api-resources/browsers/browsers.test.ts index 3e1e28e8..56dce347 100644 --- a/tests/api-resources/browsers/browsers.test.ts +++ b/tests/api-resources/browsers/browsers.test.ts @@ -243,4 +243,16 @@ describe('resource browsers', () => { timeout_sec: 1, }); }); + + // Mock server tests are disabled + test.skip('saveProfile', async () => { + const responsePromise = client.browsers.saveProfile('htzv5orfit78e1m2biiifpbv', {}); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); });