diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 71e95ba..d353515 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.20.0" + ".": "0.21.0" } diff --git a/.stats.yml b/.stats.yml index 11b820d..25e77f1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 66 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2af1b468584cb44aa9babbbfb82bff4055614fbb5c815084a6b7dacc1cf1a822.yml -openapi_spec_hash: 891affa2849341ea01d62011125f7edc -config_hash: 9421eb86b7f3f4b274f123279da3858e +configured_endpoints: 74 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-3db06d1628149b5ea8303f1c72250664dfd7cb4a14ceb6102f1ae6e85c92c038.yml +openapi_spec_hash: e5b3da2da328eb26d2a70e2521744c62 +config_hash: a4124701ae0a474e580d7416adbcfb00 diff --git a/CHANGELOG.md b/CHANGELOG.md index e8d68b2..6a6c41b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.21.0 (2025-12-02) + +Full Changelog: [v0.20.0...v0.21.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.20.0...v0.21.0) + +### Features + +* Browser pools sdk release ([0fca0c8](https://github.com/onkernel/kernel-node-sdk/commit/0fca0c8145e7a9938a9ebe20eeac19eb9d3e4e82)) +* Mason/agent auth api ([963aaf2](https://github.com/onkernel/kernel-node-sdk/commit/963aaf27f6449d4bcd39f9f3340b5d5a68ae49e8)) + + +### Chores + +* **client:** fix logger property type ([426b7b4](https://github.com/onkernel/kernel-node-sdk/commit/426b7b4d79357fcae88807aad49718c26eb02044)) + ## 0.20.0 (2025-11-19) Full Changelog: [v0.19.2...v0.20.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.19.2...v0.20.0) diff --git a/api.md b/api.md index 982d841..c3c1b6e 100644 --- a/api.md +++ b/api.md @@ -3,6 +3,9 @@ Types: - AppAction +- BrowserExtension +- BrowserProfile +- BrowserViewport - ErrorDetail - ErrorEvent - ErrorModel @@ -220,3 +223,26 @@ Methods: - client.extensions.download(idOrName) -> Response - client.extensions.downloadFromChromeStore({ ...params }) -> Response - client.extensions.upload({ ...params }) -> ExtensionUploadResponse + +# BrowserPools + +Types: + +- BrowserPool +- BrowserPoolAcquireRequest +- BrowserPoolReleaseRequest +- BrowserPoolRequest +- BrowserPoolUpdateRequest +- BrowserPoolListResponse +- BrowserPoolAcquireResponse + +Methods: + +- client.browserPools.create({ ...params }) -> BrowserPool +- client.browserPools.retrieve(idOrName) -> BrowserPool +- client.browserPools.update(idOrName, { ...params }) -> BrowserPool +- client.browserPools.list() -> BrowserPoolListResponse +- client.browserPools.delete(idOrName, { ...params }) -> void +- client.browserPools.acquire(idOrName, { ...params }) -> BrowserPoolAcquireResponse +- client.browserPools.flush(idOrName) -> void +- client.browserPools.release(idOrName, { ...params }) -> void diff --git a/package.json b/package.json index 6fa7c73..9ff823b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/sdk", - "version": "0.20.0", + "version": "0.21.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 a419c27..a0dffa0 100644 --- a/src/client.ts +++ b/src/client.ts @@ -19,6 +19,21 @@ import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; import { AppListParams, AppListResponse, AppListResponsesOffsetPagination, Apps } from './resources/apps'; +import { + BrowserPool, + BrowserPoolAcquireParams, + BrowserPoolAcquireRequest, + BrowserPoolAcquireResponse, + BrowserPoolCreateParams, + BrowserPoolDeleteParams, + BrowserPoolListResponse, + BrowserPoolReleaseParams, + BrowserPoolReleaseRequest, + BrowserPoolRequest, + BrowserPoolUpdateParams, + BrowserPoolUpdateRequest, + BrowserPools, +} from './resources/browser-pools'; import { DeploymentCreateParams, DeploymentCreateResponse, @@ -186,7 +201,7 @@ export class Kernel { baseURL: string; maxRetries: number; timeout: number; - logger: Logger | undefined; + logger: Logger; logLevel: LogLevel | undefined; fetchOptions: MergedRequestInit | undefined; @@ -843,6 +858,7 @@ export class Kernel { profiles: API.Profiles = new API.Profiles(this); proxies: API.Proxies = new API.Proxies(this); extensions: API.Extensions = new API.Extensions(this); + browserPools: API.BrowserPools = new API.BrowserPools(this); } Kernel.Deployments = Deployments; @@ -852,6 +868,7 @@ Kernel.Browsers = Browsers; Kernel.Profiles = Profiles; Kernel.Proxies = Proxies; Kernel.Extensions = Extensions; +Kernel.BrowserPools = BrowserPools; export declare namespace Kernel { export type RequestOptions = Opts.RequestOptions; @@ -933,7 +950,26 @@ export declare namespace Kernel { type ExtensionUploadParams as ExtensionUploadParams, }; + export { + BrowserPools as BrowserPools, + type BrowserPool as BrowserPool, + type BrowserPoolAcquireRequest as BrowserPoolAcquireRequest, + type BrowserPoolReleaseRequest as BrowserPoolReleaseRequest, + type BrowserPoolRequest as BrowserPoolRequest, + type BrowserPoolUpdateRequest as BrowserPoolUpdateRequest, + type BrowserPoolListResponse as BrowserPoolListResponse, + type BrowserPoolAcquireResponse as BrowserPoolAcquireResponse, + type BrowserPoolCreateParams as BrowserPoolCreateParams, + type BrowserPoolUpdateParams as BrowserPoolUpdateParams, + type BrowserPoolDeleteParams as BrowserPoolDeleteParams, + type BrowserPoolAcquireParams as BrowserPoolAcquireParams, + type BrowserPoolReleaseParams as BrowserPoolReleaseParams, + }; + export type AppAction = API.AppAction; + export type BrowserExtension = API.BrowserExtension; + export type BrowserProfile = API.BrowserProfile; + export type BrowserViewport = API.BrowserViewport; export type ErrorDetail = API.ErrorDetail; export type ErrorEvent = API.ErrorEvent; export type ErrorModel = API.ErrorModel; diff --git a/src/resources/browser-pools.ts b/src/resources/browser-pools.ts new file mode 100644 index 0000000..be28ad0 --- /dev/null +++ b/src/resources/browser-pools.ts @@ -0,0 +1,560 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../core/resource'; +import * as Shared from './shared'; +import * as BrowsersAPI from './browsers/browsers'; +import { APIPromise } from '../core/api-promise'; +import { buildHeaders } from '../internal/headers'; +import { RequestOptions } from '../internal/request-options'; +import { path } from '../internal/utils/path'; + +export class BrowserPools extends APIResource { + /** + * Create a new browser pool with the specified configuration and size. + * + * @example + * ```ts + * const browserPool = await client.browserPools.create({ + * size: 10, + * }); + * ``` + */ + create(body: BrowserPoolCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/browser_pools', { body, ...options }); + } + + /** + * Retrieve details for a single browser pool by its ID or name. + * + * @example + * ```ts + * const browserPool = await client.browserPools.retrieve( + * 'id_or_name', + * ); + * ``` + */ + retrieve(idOrName: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/browser_pools/${idOrName}`, options); + } + + /** + * Updates the configuration used to create browsers in the pool. + * + * @example + * ```ts + * const browserPool = await client.browserPools.update( + * 'id_or_name', + * { size: 10 }, + * ); + * ``` + */ + update(idOrName: string, body: BrowserPoolUpdateParams, options?: RequestOptions): APIPromise { + return this._client.patch(path`/browser_pools/${idOrName}`, { body, ...options }); + } + + /** + * List browser pools owned by the caller's organization. + * + * @example + * ```ts + * const browserPools = await client.browserPools.list(); + * ``` + */ + list(options?: RequestOptions): APIPromise { + return this._client.get('/browser_pools', options); + } + + /** + * Delete a browser pool and all browsers in it. By default, deletion is blocked if + * browsers are currently leased. Use force=true to terminate leased browsers. + * + * @example + * ```ts + * await client.browserPools.delete('id_or_name'); + * ``` + */ + delete( + idOrName: string, + body: BrowserPoolDeleteParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + return this._client.delete(path`/browser_pools/${idOrName}`, { + body, + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } + + /** + * Long-polling endpoint to acquire a browser from the pool. Returns immediately + * when a browser is available, or returns 204 No Content when the poll times out. + * The client should retry the request to continue waiting for a browser. The + * acquired browser will use the pool's timeout_seconds for its idle timeout. + * + * @example + * ```ts + * const response = await client.browserPools.acquire( + * 'id_or_name', + * ); + * ``` + */ + acquire( + idOrName: string, + body: BrowserPoolAcquireParams, + options?: RequestOptions, + ): APIPromise { + return this._client.post(path`/browser_pools/${idOrName}/acquire`, { body, ...options }); + } + + /** + * Destroys all idle browsers in the pool; leased browsers are not affected. + * + * @example + * ```ts + * await client.browserPools.flush('id_or_name'); + * ``` + */ + flush(idOrName: string, options?: RequestOptions): APIPromise { + return this._client.post(path`/browser_pools/${idOrName}/flush`, { + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } + + /** + * Release a browser back to the pool, optionally recreating the browser instance. + * + * @example + * ```ts + * await client.browserPools.release('id_or_name', { + * session_id: 'ts8iy3sg25ibheguyni2lg9t', + * }); + * ``` + */ + release(idOrName: string, body: BrowserPoolReleaseParams, options?: RequestOptions): APIPromise { + return this._client.post(path`/browser_pools/${idOrName}/release`, { + body, + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } +} + +/** + * A browser pool containing multiple identically configured browsers. + */ +export interface BrowserPool { + /** + * Unique identifier for the browser pool + */ + id: string; + + /** + * Number of browsers currently acquired from the pool + */ + acquired_count: number; + + /** + * Number of browsers currently available in the pool + */ + available_count: number; + + /** + * Configuration used to create all browsers in this pool + */ + browser_pool_config: BrowserPoolRequest; + + /** + * Timestamp when the browser pool was created + */ + created_at: string; + + /** + * Browser pool name, if set + */ + name?: string; +} + +/** + * Request body for acquiring a browser from the pool. + */ +export interface BrowserPoolAcquireRequest { + /** + * Maximum number of seconds to wait for a browser to be available. Defaults to the + * calculated time it would take to fill the pool at the currently configured fill + * rate. + */ + acquire_timeout_seconds?: number; +} + +/** + * Request body for releasing a browser back to the pool. + */ +export interface BrowserPoolReleaseRequest { + /** + * Browser session ID to release back to the pool + */ + session_id: string; + + /** + * Whether to reuse the browser instance or destroy it and create a new one. + * Defaults to true. + */ + reuse?: boolean; +} + +/** + * Parameters for creating a browser pool. All browsers in the pool will be created + * with the same configuration. + */ +export interface BrowserPoolRequest { + /** + * Number of browsers to create in the pool + */ + size: number; + + /** + * List of browser extensions to load into the session. Provide each by id or name. + */ + extensions?: Array; + + /** + * Percentage of the pool to fill per minute. Defaults to 10%. + */ + fill_rate_per_minute?: number; + + /** + * If true, launches the browser using a headless image. Defaults to false. + */ + headless?: boolean; + + /** + * If true, launches the browser in kiosk mode to hide address bar and tabs in live + * view. + */ + kiosk_mode?: boolean; + + /** + * Optional name for the browser pool. Must be unique within the organization. + */ + name?: string; + + /** + * Profile selection for the browser session. Provide either id or name. If + * specified, the matching profile will be loaded into the browser session. + * Profiles must be created beforehand. + */ + profile?: Shared.BrowserProfile; + + /** + * Optional proxy to associate to the browser session. Must reference a proxy + * belonging to the caller's org. + */ + proxy_id?: string; + + /** + * If true, launches the browser in stealth mode to reduce detection by anti-bot + * mechanisms. + */ + stealth?: boolean; + + /** + * Default idle timeout in seconds for browsers acquired from this pool before they + * are destroyed. Defaults to 600 seconds if not specified + */ + timeout_seconds?: number; + + /** + * Initial browser window size in pixels with optional refresh rate. If omitted, + * image defaults apply (commonly 1024x768@60). Only specific viewport + * configurations are supported. The server will reject unsupported combinations. + * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, + * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will + * be automatically determined from the width and height if they match a supported + * configuration exactly. Note: Higher resolutions may affect the responsiveness of + * live view browser + */ + viewport?: Shared.BrowserViewport; +} + +/** + * Parameters for updating a browser pool. All browsers in the pool will be created + * with the same configuration. + */ +export interface BrowserPoolUpdateRequest extends BrowserPoolRequest { + /** + * Whether to discard all idle browsers and rebuild the pool immediately. Defaults + * to true. + */ + discard_all_idle?: boolean; +} + +export type BrowserPoolListResponse = Array; + +export interface BrowserPoolAcquireResponse { + /** + * Websocket URL for Chrome DevTools Protocol connections to the browser session + */ + cdp_ws_url: string; + + /** + * When the browser session was created. + */ + created_at: string; + + /** + * Whether the browser session is running in headless mode. + */ + headless: boolean; + + /** + * Unique identifier for the browser session + */ + session_id: string; + + /** + * Whether the browser session is running in stealth mode. + */ + stealth: boolean; + + /** + * The number of seconds of inactivity before the browser session is terminated. + */ + timeout_seconds: number; + + /** + * Remote URL for live viewing the browser session. Only available for non-headless + * browsers. + */ + browser_live_view_url?: string; + + /** + * When the browser session was soft-deleted. Only present for deleted sessions. + */ + deleted_at?: string; + + /** + * Whether the browser session is running in kiosk mode. + */ + kiosk_mode?: boolean; + + /** + * Optional persistence configuration for the browser session. + */ + persistence?: BrowsersAPI.BrowserPersistence; + + /** + * Browser profile metadata. + */ + profile?: BrowsersAPI.Profile; + + /** + * ID of the proxy associated with this browser session, if any. + */ + proxy_id?: string; + + /** + * Initial browser window size in pixels with optional refresh rate. If omitted, + * image defaults apply (commonly 1024x768@60). Only specific viewport + * configurations are supported. The server will reject unsupported combinations. + * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, + * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will + * be automatically determined from the width and height if they match a supported + * configuration exactly. Note: Higher resolutions may affect the responsiveness of + * live view browser + */ + viewport?: Shared.BrowserViewport; +} + +export interface BrowserPoolCreateParams { + /** + * Number of browsers to create in the pool + */ + size: number; + + /** + * List of browser extensions to load into the session. Provide each by id or name. + */ + extensions?: Array; + + /** + * Percentage of the pool to fill per minute. Defaults to 10%. + */ + fill_rate_per_minute?: number; + + /** + * If true, launches the browser using a headless image. Defaults to false. + */ + headless?: boolean; + + /** + * If true, launches the browser in kiosk mode to hide address bar and tabs in live + * view. + */ + kiosk_mode?: boolean; + + /** + * Optional name for the browser pool. Must be unique within the organization. + */ + name?: string; + + /** + * Profile selection for the browser session. Provide either id or name. If + * specified, the matching profile will be loaded into the browser session. + * Profiles must be created beforehand. + */ + profile?: Shared.BrowserProfile; + + /** + * Optional proxy to associate to the browser session. Must reference a proxy + * belonging to the caller's org. + */ + proxy_id?: string; + + /** + * If true, launches the browser in stealth mode to reduce detection by anti-bot + * mechanisms. + */ + stealth?: boolean; + + /** + * Default idle timeout in seconds for browsers acquired from this pool before they + * are destroyed. Defaults to 600 seconds if not specified + */ + timeout_seconds?: number; + + /** + * Initial browser window size in pixels with optional refresh rate. If omitted, + * image defaults apply (commonly 1024x768@60). Only specific viewport + * configurations are supported. The server will reject unsupported combinations. + * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, + * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will + * be automatically determined from the width and height if they match a supported + * configuration exactly. Note: Higher resolutions may affect the responsiveness of + * live view browser + */ + viewport?: Shared.BrowserViewport; +} + +export interface BrowserPoolUpdateParams { + /** + * Number of browsers to create in the pool + */ + size: number; + + /** + * Whether to discard all idle browsers and rebuild the pool immediately. Defaults + * to true. + */ + discard_all_idle?: boolean; + + /** + * List of browser extensions to load into the session. Provide each by id or name. + */ + extensions?: Array; + + /** + * Percentage of the pool to fill per minute. Defaults to 10%. + */ + fill_rate_per_minute?: number; + + /** + * If true, launches the browser using a headless image. Defaults to false. + */ + headless?: boolean; + + /** + * If true, launches the browser in kiosk mode to hide address bar and tabs in live + * view. + */ + kiosk_mode?: boolean; + + /** + * Optional name for the browser pool. Must be unique within the organization. + */ + name?: string; + + /** + * Profile selection for the browser session. Provide either id or name. If + * specified, the matching profile will be loaded into the browser session. + * Profiles must be created beforehand. + */ + profile?: Shared.BrowserProfile; + + /** + * Optional proxy to associate to the browser session. Must reference a proxy + * belonging to the caller's org. + */ + proxy_id?: string; + + /** + * If true, launches the browser in stealth mode to reduce detection by anti-bot + * mechanisms. + */ + stealth?: boolean; + + /** + * Default idle timeout in seconds for browsers acquired from this pool before they + * are destroyed. Defaults to 600 seconds if not specified + */ + timeout_seconds?: number; + + /** + * Initial browser window size in pixels with optional refresh rate. If omitted, + * image defaults apply (commonly 1024x768@60). Only specific viewport + * configurations are supported. The server will reject unsupported combinations. + * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, + * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will + * be automatically determined from the width and height if they match a supported + * configuration exactly. Note: Higher resolutions may affect the responsiveness of + * live view browser + */ + viewport?: Shared.BrowserViewport; +} + +export interface BrowserPoolDeleteParams { + /** + * If true, force delete even if browsers are currently leased. Leased browsers + * will be terminated. + */ + force?: boolean; +} + +export interface BrowserPoolAcquireParams { + /** + * Maximum number of seconds to wait for a browser to be available. Defaults to the + * calculated time it would take to fill the pool at the currently configured fill + * rate. + */ + acquire_timeout_seconds?: number; +} + +export interface BrowserPoolReleaseParams { + /** + * Browser session ID to release back to the pool + */ + session_id: string; + + /** + * Whether to reuse the browser instance or destroy it and create a new one. + * Defaults to true. + */ + reuse?: boolean; +} + +export declare namespace BrowserPools { + export { + type BrowserPool as BrowserPool, + type BrowserPoolAcquireRequest as BrowserPoolAcquireRequest, + type BrowserPoolReleaseRequest as BrowserPoolReleaseRequest, + type BrowserPoolRequest as BrowserPoolRequest, + type BrowserPoolUpdateRequest as BrowserPoolUpdateRequest, + type BrowserPoolListResponse as BrowserPoolListResponse, + type BrowserPoolAcquireResponse as BrowserPoolAcquireResponse, + type BrowserPoolCreateParams as BrowserPoolCreateParams, + type BrowserPoolUpdateParams as BrowserPoolUpdateParams, + type BrowserPoolDeleteParams as BrowserPoolDeleteParams, + type BrowserPoolAcquireParams as BrowserPoolAcquireParams, + type BrowserPoolReleaseParams as BrowserPoolReleaseParams, + }; +} diff --git a/src/resources/browsers/browsers.ts b/src/resources/browsers/browsers.ts index 1c0f9bc..d3f8b3d 100644 --- a/src/resources/browsers/browsers.ts +++ b/src/resources/browsers/browsers.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; +import * as Shared from '../shared'; import * as ComputerAPI from './computer'; import { Computer, @@ -302,37 +303,7 @@ export interface BrowserCreateResponse { * configuration exactly. Note: Higher resolutions may affect the responsiveness of * live view browser */ - viewport?: BrowserCreateResponse.Viewport; -} - -export namespace BrowserCreateResponse { - /** - * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). Only specific viewport - * configurations are supported. The server will reject unsupported combinations. - * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, - * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will - * be automatically determined from the width and height if they match a supported - * configuration exactly. Note: Higher resolutions may affect the responsiveness of - * live view browser - */ - export interface Viewport { - /** - * Browser window height in pixels. - */ - height: number; - - /** - * Browser window width in pixels. - */ - width: number; - - /** - * Display refresh rate in Hz. If omitted, automatically determined from width and - * height. - */ - refresh_rate?: number; - } + viewport?: Shared.BrowserViewport; } export interface BrowserRetrieveResponse { @@ -407,37 +378,7 @@ export interface BrowserRetrieveResponse { * configuration exactly. Note: Higher resolutions may affect the responsiveness of * live view browser */ - viewport?: BrowserRetrieveResponse.Viewport; -} - -export namespace BrowserRetrieveResponse { - /** - * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). Only specific viewport - * configurations are supported. The server will reject unsupported combinations. - * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, - * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will - * be automatically determined from the width and height if they match a supported - * configuration exactly. Note: Higher resolutions may affect the responsiveness of - * live view browser - */ - export interface Viewport { - /** - * Browser window height in pixels. - */ - height: number; - - /** - * Browser window width in pixels. - */ - width: number; - - /** - * Display refresh rate in Hz. If omitted, automatically determined from width and - * height. - */ - refresh_rate?: number; - } + viewport?: Shared.BrowserViewport; } export interface BrowserListResponse { @@ -512,44 +453,14 @@ export interface BrowserListResponse { * configuration exactly. Note: Higher resolutions may affect the responsiveness of * live view browser */ - viewport?: BrowserListResponse.Viewport; -} - -export namespace BrowserListResponse { - /** - * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). Only specific viewport - * configurations are supported. The server will reject unsupported combinations. - * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, - * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will - * be automatically determined from the width and height if they match a supported - * configuration exactly. Note: Higher resolutions may affect the responsiveness of - * live view browser - */ - export interface Viewport { - /** - * Browser window height in pixels. - */ - height: number; - - /** - * Browser window width in pixels. - */ - width: number; - - /** - * Display refresh rate in Hz. If omitted, automatically determined from width and - * height. - */ - refresh_rate?: number; - } + viewport?: Shared.BrowserViewport; } export interface BrowserCreateParams { /** * List of browser extensions to load into the session. Provide each by id or name. */ - extensions?: Array; + extensions?: Array; /** * If true, launches the browser using a headless image (no VNC/GUI). Defaults to @@ -578,7 +489,7 @@ export interface BrowserCreateParams { * specified, the matching profile will be loaded into the browser session. * Profiles must be created beforehand. */ - profile?: BrowserCreateParams.Profile; + profile?: Shared.BrowserProfile; /** * Optional proxy to associate to the browser session. Must reference a proxy @@ -612,78 +523,7 @@ export interface BrowserCreateParams { * configuration exactly. Note: Higher resolutions may affect the responsiveness of * live view browser */ - viewport?: BrowserCreateParams.Viewport; -} - -export namespace BrowserCreateParams { - /** - * Extension selection for the browser session. Provide either id or name of an - * extension uploaded to Kernel. - */ - export interface Extension { - /** - * Extension ID to load for this browser session - */ - id?: string; - - /** - * Extension name to load for this browser session (instead of id). Must be 1-255 - * characters, using letters, numbers, dots, underscores, or hyphens. - */ - name?: string; - } - - /** - * Profile selection for the browser session. Provide either id or name. If - * specified, the matching profile will be loaded into the browser session. - * Profiles must be created beforehand. - */ - export interface Profile { - /** - * Profile ID to load for this browser session - */ - id?: string; - - /** - * Profile name to load for this browser session (instead of id). Must be 1-255 - * characters, using letters, numbers, dots, underscores, or hyphens. - */ - name?: string; - - /** - * If true, save changes made during the session back to the profile when the - * session ends. - */ - save_changes?: boolean; - } - - /** - * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). Only specific viewport - * configurations are supported. The server will reject unsupported combinations. - * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, - * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will - * be automatically determined from the width and height if they match a supported - * configuration exactly. Note: Higher resolutions may affect the responsiveness of - * live view browser - */ - export interface Viewport { - /** - * Browser window height in pixels. - */ - height: number; - - /** - * Browser window width in pixels. - */ - width: number; - - /** - * Display refresh rate in Hz. If omitted, automatically determined from width and - * height. - */ - refresh_rate?: number; - } + viewport?: Shared.BrowserViewport; } export interface BrowserListParams extends OffsetPaginationParams { diff --git a/src/resources/index.ts b/src/resources/index.ts index 69c693d..420e5e2 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -7,6 +7,21 @@ export { type AppListParams, type AppListResponsesOffsetPagination, } from './apps'; +export { + BrowserPools, + type BrowserPool, + type BrowserPoolAcquireRequest, + type BrowserPoolReleaseRequest, + type BrowserPoolRequest, + type BrowserPoolUpdateRequest, + type BrowserPoolListResponse, + type BrowserPoolAcquireResponse, + type BrowserPoolCreateParams, + type BrowserPoolUpdateParams, + type BrowserPoolDeleteParams, + type BrowserPoolAcquireParams, + type BrowserPoolReleaseParams, +} from './browser-pools'; export { Browsers, type BrowserPersistence, diff --git a/src/resources/shared.ts b/src/resources/shared.ts index c44734e..13cbc0b 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -10,6 +10,75 @@ export interface AppAction { name: string; } +/** + * Extension selection for the browser session. Provide either id or name of an + * extension uploaded to Kernel. + */ +export interface BrowserExtension { + /** + * Extension ID to load for this browser session + */ + id?: string; + + /** + * Extension name to load for this browser session (instead of id). Must be 1-255 + * characters, using letters, numbers, dots, underscores, or hyphens. + */ + name?: string; +} + +/** + * Profile selection for the browser session. Provide either id or name. If + * specified, the matching profile will be loaded into the browser session. + * Profiles must be created beforehand. + */ +export interface BrowserProfile { + /** + * Profile ID to load for this browser session + */ + id?: string; + + /** + * Profile name to load for this browser session (instead of id). Must be 1-255 + * characters, using letters, numbers, dots, underscores, or hyphens. + */ + name?: string; + + /** + * If true, save changes made during the session back to the profile when the + * session ends. + */ + save_changes?: boolean; +} + +/** + * Initial browser window size in pixels with optional refresh rate. If omitted, + * image defaults apply (commonly 1024x768@60). Only specific viewport + * configurations are supported. The server will reject unsupported combinations. + * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, + * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will + * be automatically determined from the width and height if they match a supported + * configuration exactly. Note: Higher resolutions may affect the responsiveness of + * live view browser + */ +export interface BrowserViewport { + /** + * Browser window height in pixels. + */ + height: number; + + /** + * Browser window width in pixels. + */ + width: number; + + /** + * Display refresh rate in Hz. If omitted, automatically determined from width and + * height. + */ + refresh_rate?: number; +} + export interface ErrorDetail { /** * Lower-level error code providing more specific detail diff --git a/src/version.ts b/src/version.ts index b4e51da..bc95435 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.20.0'; // x-release-please-version +export const VERSION = '0.21.0'; // x-release-please-version diff --git a/tests/api-resources/browser-pools.test.ts b/tests/api-resources/browser-pools.test.ts new file mode 100644 index 0000000..2fdc93e --- /dev/null +++ b/tests/api-resources/browser-pools.test.ts @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Kernel from '@onkernel/sdk'; + +const client = new Kernel({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource browserPools', () => { + // Prism tests are disabled + test.skip('create: only required params', async () => { + const responsePromise = client.browserPools.create({ size: 10 }); + 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); + }); + + // Prism tests are disabled + test.skip('create: required and optional params', async () => { + const response = await client.browserPools.create({ + size: 10, + extensions: [{ id: 'id', name: 'name' }], + fill_rate_per_minute: 0, + headless: false, + kiosk_mode: true, + name: 'my-pool', + profile: { id: 'id', name: 'name', save_changes: true }, + proxy_id: 'proxy_id', + stealth: true, + timeout_seconds: 60, + viewport: { height: 800, width: 1280, refresh_rate: 60 }, + }); + }); + + // Prism tests are disabled + test.skip('retrieve', async () => { + const responsePromise = client.browserPools.retrieve('id_or_name'); + 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); + }); + + // Prism tests are disabled + test.skip('update: only required params', async () => { + const responsePromise = client.browserPools.update('id_or_name', { size: 10 }); + 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); + }); + + // Prism tests are disabled + test.skip('update: required and optional params', async () => { + const response = await client.browserPools.update('id_or_name', { + size: 10, + discard_all_idle: false, + extensions: [{ id: 'id', name: 'name' }], + fill_rate_per_minute: 0, + headless: false, + kiosk_mode: true, + name: 'my-pool', + profile: { id: 'id', name: 'name', save_changes: true }, + proxy_id: 'proxy_id', + stealth: true, + timeout_seconds: 60, + viewport: { height: 800, width: 1280, refresh_rate: 60 }, + }); + }); + + // Prism tests are disabled + test.skip('list', async () => { + const responsePromise = client.browserPools.list(); + 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); + }); + + // Prism tests are disabled + test.skip('delete', async () => { + const responsePromise = client.browserPools.delete('id_or_name'); + 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); + }); + + // Prism tests are disabled + test.skip('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.browserPools.delete('id_or_name', { force: true }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Kernel.NotFoundError); + }); + + // Prism tests are disabled + test.skip('acquire', async () => { + const responsePromise = client.browserPools.acquire('id_or_name', {}); + 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); + }); + + // Prism tests are disabled + test.skip('flush', async () => { + const responsePromise = client.browserPools.flush('id_or_name'); + 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); + }); + + // Prism tests are disabled + test.skip('release: only required params', async () => { + const responsePromise = client.browserPools.release('id_or_name', { + session_id: 'ts8iy3sg25ibheguyni2lg9t', + }); + 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); + }); + + // Prism tests are disabled + test.skip('release: required and optional params', async () => { + const response = await client.browserPools.release('id_or_name', { + session_id: 'ts8iy3sg25ibheguyni2lg9t', + reuse: false, + }); + }); +});