Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.29.0"
".": "0.30.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 97
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-46c8320dcd9f8fc596f469ef0dd1aafaca591ab36cf2a6f8a7297dc9136bdc71.yml
openapi_spec_hash: 1be1e6589cd94c581b241720e01a65bc
config_hash: b470456b217bb9502f5212311d395a6f
configured_endpoints: 98
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ccbe854895eb34a9562e33979f5f43cd6ad1f529d5924ee56e56f0c94dcf0454.yml
openapi_spec_hash: 2fa4ecbe742fc46fdde481188c1d885e
config_hash: dd218aae3f852dff79e77febc2077b8e
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 0.30.0 (2026-02-03)

Full Changelog: [v0.29.0...v0.30.0](https://github.com/kernel/kernel-node-sdk/compare/v0.29.0...v0.30.0)

### Features

* Neil/kernel 872 templates v3 ([3a73c62](https://github.com/kernel/kernel-node-sdk/commit/3a73c6245590aeb784ab0c840728b486f42e7cd5))


### Bug Fixes

* **client:** avoid memory leak with abort signals ([8523597](https://github.com/kernel/kernel-node-sdk/commit/85235970dd1c13e0b1ce5086d74515439453b929))


### Chores

* **client:** do not parse responses with empty content-length ([ada489d](https://github.com/kernel/kernel-node-sdk/commit/ada489d63f91567c9740623ede272a5f0763484b))

## 0.29.0 (2026-01-29)

Full Changelog: [v0.28.0...v0.29.0](https://github.com/kernel/kernel-node-sdk/compare/v0.28.0...v0.29.0)
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Types:
- <code><a href="./src/resources/invocations.ts">InvocationUpdateResponse</a></code>
- <code><a href="./src/resources/invocations.ts">InvocationListResponse</a></code>
- <code><a href="./src/resources/invocations.ts">InvocationFollowResponse</a></code>
- <code><a href="./src/resources/invocations.ts">InvocationListBrowsersResponse</a></code>

Methods:

Expand All @@ -58,6 +59,7 @@ Methods:
- <code title="get /invocations">client.invocations.<a href="./src/resources/invocations.ts">list</a>({ ...params }) -> InvocationListResponsesOffsetPagination</code>
- <code title="delete /invocations/{id}/browsers">client.invocations.<a href="./src/resources/invocations.ts">deleteBrowsers</a>(id) -> void</code>
- <code title="get /invocations/{id}/events">client.invocations.<a href="./src/resources/invocations.ts">follow</a>(id, { ...params }) -> InvocationFollowResponse</code>
- <code title="get /invocations/{id}/browsers">client.invocations.<a href="./src/resources/invocations.ts">listBrowsers</a>(id) -> InvocationListBrowsersResponse</code>

# Browsers

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onkernel/sdk",
"version": "0.29.0",
"version": "0.30.0",
"description": "The official TypeScript library for the Kernel API",
"author": "Kernel <>",
"types": "dist/index.d.ts",
Expand Down
7 changes: 5 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import {
InvocationCreateResponse,
InvocationFollowParams,
InvocationFollowResponse,
InvocationListBrowsersResponse,
InvocationListParams,
InvocationListResponse,
InvocationListResponsesOffsetPagination,
Expand Down Expand Up @@ -638,9 +639,10 @@ export class Kernel {
controller: AbortController,
): Promise<Response> {
const { signal, method, ...options } = init || {};
if (signal) signal.addEventListener('abort', () => controller.abort());
const abort = controller.abort.bind(controller);
if (signal) signal.addEventListener('abort', abort, { once: true });

const timeout = setTimeout(() => controller.abort(), ms);
const timeout = setTimeout(abort, ms);

const isReadableBody =
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
Expand Down Expand Up @@ -935,6 +937,7 @@ export declare namespace Kernel {
type InvocationUpdateResponse as InvocationUpdateResponse,
type InvocationListResponse as InvocationListResponse,
type InvocationFollowResponse as InvocationFollowResponse,
type InvocationListBrowsersResponse as InvocationListBrowsersResponse,
type InvocationListResponsesOffsetPagination as InvocationListResponsesOffsetPagination,
type InvocationCreateParams as InvocationCreateParams,
type InvocationUpdateParams as InvocationUpdateParams,
Expand Down
6 changes: 6 additions & 0 deletions src/internal/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export async function defaultParseResponse<T>(client: Kernel, props: APIResponse
const mediaType = contentType?.split(';')[0]?.trim();
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
if (isJSON) {
const contentLength = response.headers.get('content-length');
if (contentLength === '0') {
// if there is no content we can't do anything
return undefined as T;
}

const json = await response.json();
return json as T;
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export {
type InvocationUpdateResponse,
type InvocationListResponse,
type InvocationFollowResponse,
type InvocationListBrowsersResponse,
type InvocationCreateParams,
type InvocationUpdateParams,
type InvocationListParams,
Expand Down
98 changes: 98 additions & 0 deletions src/resources/invocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { APIResource } from '../core/resource';
import * as Shared from './shared';
import * as BrowsersAPI from './browsers/browsers';
import { APIPromise } from '../core/api-promise';
import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../core/pagination';
import { Stream } from '../core/streaming';
Expand Down Expand Up @@ -118,6 +119,20 @@ export class Invocations extends APIResource {
stream: true,
}) as APIPromise<Stream<InvocationFollowResponse>>;
}

/**
* Returns all active browser sessions created within the specified invocation.
*
* @example
* ```ts
* const response = await client.invocations.listBrowsers(
* 'id',
* );
* ```
*/
listBrowsers(id: string, options?: RequestOptions): APIPromise<InvocationListBrowsersResponse> {
return this._client.get(path`/invocations/${id}/browsers`, options);
}
}

export type InvocationListResponsesOffsetPagination = OffsetPagination<InvocationListResponse>;
Expand Down Expand Up @@ -394,6 +409,88 @@ export type InvocationFollowResponse =
| Shared.ErrorEvent
| Shared.HeartbeatEvent;

export interface InvocationListBrowsersResponse {
browsers: Array<InvocationListBrowsersResponse.Browser>;
}

export namespace InvocationListBrowsersResponse {
export interface Browser {
/**
* 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;

/**
* @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles
* instead.
*/
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 (1920x1080@25). Only specific viewport configurations are
* supported. The server will reject unsupported combinations. Supported
* resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, 1440x900@25,
* 1280x800@60, 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 InvocationCreateParams {
/**
* Name of the action to invoke
Expand Down Expand Up @@ -488,6 +585,7 @@ export declare namespace Invocations {
type InvocationUpdateResponse as InvocationUpdateResponse,
type InvocationListResponse as InvocationListResponse,
type InvocationFollowResponse as InvocationFollowResponse,
type InvocationListBrowsersResponse as InvocationListBrowsersResponse,
type InvocationListResponsesOffsetPagination as InvocationListResponsesOffsetPagination,
type InvocationCreateParams as InvocationCreateParams,
type InvocationUpdateParams as InvocationUpdateParams,
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.29.0'; // x-release-please-version
export const VERSION = '0.30.0'; // x-release-please-version
12 changes: 12 additions & 0 deletions tests/api-resources/invocations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,16 @@ describe('resource invocations', () => {
),
).rejects.toThrow(Kernel.NotFoundError);
});

// Prism tests are disabled
test.skip('listBrowsers', async () => {
const responsePromise = client.invocations.listBrowsers('id');
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);
});
});