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.3.0"
".": "0.4.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: 10
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-3edc7a0eef4a0d4495782efbdb0d9b777a55aee058dab119f90de56019441326.yml
openapi_spec_hash: dff0b1efa1c1614cf770ed8327cefab2
config_hash: cb04a4d88ee9f530b303ca57ff7090b3
configured_endpoints: 11
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-64ccdff4ca5d73d79d89e817fe83ccfd3d529696df3e6818c3c75e586ae00801.yml
openapi_spec_hash: 21c7b8757fc0cc9415cda1bc06251de6
config_hash: b3fcacd707da56b21d31ce0baf4fb87d
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.4.0 (2025-05-28)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.3.0...v0.4.0)

### Features

* **api:** update via SDK Studio ([4c5b6b6](https://github.com/onkernel/kernel-node-sdk/commit/4c5b6b6ecf8e34ced647b42dca75c5a2b5deaf87))


### Chores

* improve publish-npm script --latest tag logic ([ac1ab4f](https://github.com/onkernel/kernel-node-sdk/commit/ac1ab4f2c79dc4df0b405007e9d64999ce8ed362))

## 0.3.0 (2025-05-22)

Full Changelog: [v0.2.0...v0.3.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.2.0...v0.3.0)
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ Types:

- <code><a href="./src/resources/apps/invocations.ts">InvocationCreateResponse</a></code>
- <code><a href="./src/resources/apps/invocations.ts">InvocationRetrieveResponse</a></code>
- <code><a href="./src/resources/apps/invocations.ts">InvocationUpdateResponse</a></code>

Methods:

- <code title="post /invocations">client.apps.invocations.<a href="./src/resources/apps/invocations.ts">create</a>({ ...params }) -> InvocationCreateResponse</code>
- <code title="get /invocations/{id}">client.apps.invocations.<a href="./src/resources/apps/invocations.ts">retrieve</a>(id) -> InvocationRetrieveResponse</code>
- <code title="patch /invocations/{id}">client.apps.invocations.<a href="./src/resources/apps/invocations.ts">update</a>(id, { ...params }) -> InvocationUpdateResponse</code>

# Browsers

Expand Down
30 changes: 23 additions & 7 deletions bin/publish-npm
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,35 @@ set -eux

npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"

# Build the project
yarn build

# Navigate to the dist directory
cd dist

# Get the version from package.json
# Get latest version from npm
#
# If the package doesn't exist, yarn will return
# {"type":"error","data":"Received invalid response from npm."}
# where .data.version doesn't exist so LAST_VERSION will be an empty string.
LAST_VERSION="$(yarn info --json 2> /dev/null | jq -r '.data.version')"

# Get current version from package.json
VERSION="$(node -p "require('./package.json').version")"

# Extract the pre-release tag if it exists
# Check if current version is pre-release (e.g. alpha / beta / rc)
CURRENT_IS_PRERELEASE=false
if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then
# Extract the part before any dot in the pre-release identifier
TAG="${BASH_REMATCH[1]}"
CURRENT_IS_PRERELEASE=true
CURRENT_TAG="${BASH_REMATCH[1]}"
fi

# Check if last version is a stable release
LAST_IS_STABLE_RELEASE=true
if [[ -z "$LAST_VERSION" || "$LAST_VERSION" =~ -([a-zA-Z]+) ]]; then
LAST_IS_STABLE_RELEASE=false
fi

# Use a corresponding alpha/beta tag if there already is a stable release and we're publishing a prerelease.
if $CURRENT_IS_PRERELEASE && $LAST_IS_STABLE_RELEASE; then
TAG="$CURRENT_TAG"
else
TAG="latest"
fi
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.3.0",
"version": "0.4.0",
"description": "The official TypeScript library for the Kernel API",
"author": "Kernel <>",
"types": "dist/index.d.ts",
Expand Down
4 changes: 4 additions & 0 deletions src/resources/apps/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
InvocationCreateParams,
InvocationCreateResponse,
InvocationRetrieveResponse,
InvocationUpdateParams,
InvocationUpdateResponse,
Invocations,
} from './invocations';
import { APIPromise } from '../../core/api-promise';
Expand Down Expand Up @@ -99,6 +101,8 @@ export declare namespace Apps {
Invocations as Invocations,
type InvocationCreateResponse as InvocationCreateResponse,
type InvocationRetrieveResponse as InvocationRetrieveResponse,
type InvocationUpdateResponse as InvocationUpdateResponse,
type InvocationCreateParams as InvocationCreateParams,
type InvocationUpdateParams as InvocationUpdateParams,
};
}
2 changes: 2 additions & 0 deletions src/resources/apps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export {
Invocations,
type InvocationCreateResponse,
type InvocationRetrieveResponse,
type InvocationUpdateResponse,
type InvocationCreateParams,
type InvocationUpdateParams,
} from './invocations';
88 changes: 88 additions & 0 deletions src/resources/apps/invocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ export class Invocations extends APIResource {
retrieve(id: string, options?: RequestOptions): APIPromise<InvocationRetrieveResponse> {
return this._client.get(path`/invocations/${id}`, options);
}

/**
* Update invocation status or output
*
* @example
* ```ts
* const invocation = await client.apps.invocations.update(
* 'id',
* { status: 'succeeded' },
* );
* ```
*/
update(
id: string,
body: InvocationUpdateParams,
options?: RequestOptions,
): APIPromise<InvocationUpdateResponse> {
return this._client.patch(path`/invocations/${id}`, { body, ...options });
}
}

export interface InvocationCreateResponse {
Expand Down Expand Up @@ -109,6 +128,55 @@ export interface InvocationRetrieveResponse {
status_reason?: string;
}

export interface InvocationUpdateResponse {
/**
* 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;
}

export interface InvocationCreateParams {
/**
* Name of the action to invoke
Expand All @@ -125,16 +193,36 @@ export interface InvocationCreateParams {
*/
version: string;

/**
* If true, invoke asynchronously. When set, the API responds 202 Accepted with
* status "queued".
*/
async?: boolean;

/**
* Input data for the action, sent as a JSON string.
*/
payload?: string;
}

export interface InvocationUpdateParams {
/**
* New status for the invocation.
*/
status: 'succeeded' | 'failed';

/**
* Updated output of the invocation rendered as JSON string.
*/
output?: string;
}

export declare namespace Invocations {
export {
type InvocationCreateResponse as InvocationCreateResponse,
type InvocationRetrieveResponse as InvocationRetrieveResponse,
type InvocationUpdateResponse as InvocationUpdateResponse,
type InvocationCreateParams as InvocationCreateParams,
type InvocationUpdateParams as InvocationUpdateParams,
};
}
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.3.0'; // x-release-please-version
export const VERSION = '0.4.0'; // x-release-please-version
18 changes: 18 additions & 0 deletions tests/api-resources/apps/invocations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('resource invocations', () => {
action_name: 'analyze',
app_name: 'my-app',
version: '1.0.0',
async: true,
payload: '{"data":"example input"}',
});
});
Expand All @@ -45,4 +46,21 @@ describe('resource invocations', () => {
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

// skipped: tests are disabled for the time being
test.skip('update: only required params', async () => {
const responsePromise = client.apps.invocations.update('id', { status: 'succeeded' });
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);
});

// skipped: tests are disabled for the time being
test.skip('update: required and optional params', async () => {
const response = await client.apps.invocations.update('id', { status: 'succeeded', output: 'output' });
});
});