From 5166b00297fa06e003ce1314910d870ac4c7ae1f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 18:14:04 +0000 Subject: [PATCH 1/2] feat: getInvocations endpoint --- .stats.yml | 8 +- api.md | 2 + src/client.ts | 6 ++ src/resources/index.ts | 3 + src/resources/invocations.ts | 105 ++++++++++++++++++++++++ tests/api-resources/invocations.test.ts | 31 +++++++ 6 files changed, 151 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4039b10..be90d46 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 50 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5ee2116982adf46664acf84b8ba4b56ba65780983506c63d9b005dab49def757.yml -openapi_spec_hash: 42a3a519301d0e2bb2b5a71018915b55 -config_hash: 0d150b61cae2dc57d3648ceae7784966 +configured_endpoints: 51 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-8b5a722e4964d2d1dcdc34afccb6d742e1c927cbbd622264c8734f132e31a0f5.yml +openapi_spec_hash: ed101ff177c2e962653ca65acf939336 +config_hash: 49c2ff978aaa5ccb4ce324a72f116010 diff --git a/api.md b/api.md index cbf98aa..9165c58 100644 --- a/api.md +++ b/api.md @@ -44,6 +44,7 @@ Types: - InvocationCreateResponse - InvocationRetrieveResponse - InvocationUpdateResponse +- InvocationListResponse - InvocationFollowResponse Methods: @@ -51,6 +52,7 @@ Methods: - client.invocations.create({ ...params }) -> InvocationCreateResponse - client.invocations.retrieve(id) -> InvocationRetrieveResponse - client.invocations.update(id, { ...params }) -> InvocationUpdateResponse +- client.invocations.list({ ...params }) -> InvocationListResponsesOffsetPagination - client.invocations.deleteBrowsers(id) -> void - client.invocations.follow(id, { ...params }) -> InvocationFollowResponse diff --git a/src/client.ts b/src/client.ts index 91da4f0..d5dc675 100644 --- a/src/client.ts +++ b/src/client.ts @@ -37,6 +37,9 @@ import { InvocationCreateResponse, InvocationFollowParams, InvocationFollowResponse, + InvocationListParams, + InvocationListResponse, + InvocationListResponsesOffsetPagination, InvocationRetrieveResponse, InvocationStateEvent, InvocationUpdateParams, @@ -868,9 +871,12 @@ export declare namespace Kernel { type InvocationCreateResponse as InvocationCreateResponse, type InvocationRetrieveResponse as InvocationRetrieveResponse, type InvocationUpdateResponse as InvocationUpdateResponse, + type InvocationListResponse as InvocationListResponse, type InvocationFollowResponse as InvocationFollowResponse, + type InvocationListResponsesOffsetPagination as InvocationListResponsesOffsetPagination, type InvocationCreateParams as InvocationCreateParams, type InvocationUpdateParams as InvocationUpdateParams, + type InvocationListParams as InvocationListParams, type InvocationFollowParams as InvocationFollowParams, }; diff --git a/src/resources/index.ts b/src/resources/index.ts index 3d63b75..0288a65 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -30,10 +30,13 @@ export { type InvocationCreateResponse, type InvocationRetrieveResponse, type InvocationUpdateResponse, + type InvocationListResponse, type InvocationFollowResponse, type InvocationCreateParams, type InvocationUpdateParams, + type InvocationListParams, type InvocationFollowParams, + type InvocationListResponsesOffsetPagination, } from './invocations'; export { Profiles, type ProfileListResponse, type ProfileCreateParams } from './profiles'; export { diff --git a/src/resources/invocations.ts b/src/resources/invocations.ts index bc32630..5db5a3e 100644 --- a/src/resources/invocations.ts +++ b/src/resources/invocations.ts @@ -3,6 +3,7 @@ import { APIResource } from '../core/resource'; import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; +import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../core/pagination'; import { Stream } from '../core/streaming'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; @@ -58,6 +59,28 @@ export class Invocations extends APIResource { return this._client.patch(path`/invocations/${id}`, { body, ...options }); } + /** + * List invocations. Optionally filter by application name, action name, status, + * deployment ID, or start time. + * + * @example + * ```ts + * // Automatically fetches more pages as needed. + * for await (const invocationListResponse of client.invocations.list()) { + * // ... + * } + * ``` + */ + list( + query: InvocationListParams | null | undefined = {}, + options?: RequestOptions, + ): PagePromise { + return this._client.getAPIList('/invocations', OffsetPagination, { + query, + ...options, + }); + } + /** * Delete all browser sessions created within the specified invocation. * @@ -97,6 +120,8 @@ export class Invocations extends APIResource { } } +export type InvocationListResponsesOffsetPagination = OffsetPagination; + /** * An event representing the current state of an invocation. */ @@ -291,6 +316,55 @@ export interface InvocationUpdateResponse { status_reason?: string; } +export interface InvocationListResponse { + /** + * ID of the invocation + */ + id: string; + + /** + * Name of the action invoked + */ + action_name: string; + + /** + * Name of the application + */ + app_name: string; + + /** + * RFC 3339 Nanoseconds timestamp when the invocation started + */ + started_at: string; + + /** + * Status of the invocation + */ + status: 'queued' | 'running' | 'succeeded' | 'failed'; + + /** + * RFC 3339 Nanoseconds timestamp when the invocation finished (null if still + * running) + */ + finished_at?: string | null; + + /** + * Output produced by the action, rendered as a JSON string. This could be: string, + * number, boolean, array, object, or null. + */ + output?: string; + + /** + * Payload provided to the invocation. This is a string that can be parsed as JSON. + */ + payload?: string; + + /** + * Status reason + */ + status_reason?: string; +} + /** * Union type representing any invocation event. */ @@ -340,6 +414,34 @@ export interface InvocationUpdateParams { output?: string; } +export interface InvocationListParams extends OffsetPaginationParams { + /** + * Filter results by action name. + */ + action_name?: string; + + /** + * Filter results by application name. + */ + app_name?: string; + + /** + * Filter results by deployment ID. + */ + deployment_id?: string; + + /** + * Show invocations that have started since the given time (RFC timestamps or + * durations like 5m). + */ + since?: string; + + /** + * Filter results by invocation status. + */ + status?: 'queued' | 'running' | 'succeeded' | 'failed'; +} + export interface InvocationFollowParams { /** * Show logs since the given time (RFC timestamps or durations like 5m). @@ -353,9 +455,12 @@ export declare namespace Invocations { type InvocationCreateResponse as InvocationCreateResponse, type InvocationRetrieveResponse as InvocationRetrieveResponse, type InvocationUpdateResponse as InvocationUpdateResponse, + type InvocationListResponse as InvocationListResponse, type InvocationFollowResponse as InvocationFollowResponse, + type InvocationListResponsesOffsetPagination as InvocationListResponsesOffsetPagination, type InvocationCreateParams as InvocationCreateParams, type InvocationUpdateParams as InvocationUpdateParams, + type InvocationListParams as InvocationListParams, type InvocationFollowParams as InvocationFollowParams, }; } diff --git a/tests/api-resources/invocations.test.ts b/tests/api-resources/invocations.test.ts index 309612a..38aa2d2 100644 --- a/tests/api-resources/invocations.test.ts +++ b/tests/api-resources/invocations.test.ts @@ -64,6 +64,37 @@ describe('resource invocations', () => { const response = await client.invocations.update('id', { status: 'succeeded', output: 'output' }); }); + // Prism tests are disabled + test.skip('list', async () => { + const responsePromise = client.invocations.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('list: 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.invocations.list( + { + action_name: 'action_name', + app_name: 'app_name', + deployment_id: 'deployment_id', + limit: 1, + offset: 0, + since: '2025-06-20T12:00:00Z', + status: 'queued', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Kernel.NotFoundError); + }); + // Prism tests are disabled test.skip('deleteBrowsers', async () => { const responsePromise = client.invocations.deleteBrowsers('id'); From a6a9ce9592852a21d3d319bf6a4398e588584e54 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 18:18:07 +0000 Subject: [PATCH 2/2] release: 0.11.4 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 89688e2..d1eff55 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.11.3" + ".": "0.11.4" } diff --git a/CHANGELOG.md b/CHANGELOG.md index dc25e19..16a15c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.11.4 (2025-09-25) + +Full Changelog: [v0.11.3...v0.11.4](https://github.com/onkernel/kernel-node-sdk/compare/v0.11.3...v0.11.4) + +### Features + +* getInvocations endpoint ([5166b00](https://github.com/onkernel/kernel-node-sdk/commit/5166b00297fa06e003ce1314910d870ac4c7ae1f)) + ## 0.11.3 (2025-09-24) Full Changelog: [v0.11.2...v0.11.3](https://github.com/onkernel/kernel-node-sdk/compare/v0.11.2...v0.11.3) diff --git a/package.json b/package.json index 19e5d15..7e71329 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/sdk", - "version": "0.11.3", + "version": "0.11.4", "description": "The official TypeScript library for the Kernel API", "author": "Kernel <>", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index e2bf0d1..667a403 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.11.3'; // x-release-please-version +export const VERSION = '0.11.4'; // x-release-please-version