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.1.0-alpha.8"
".": "0.1.0-alpha.9"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 4
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-d168b58fcf39dbd0458d132091793d3e2d0930070b7dda2d5f7f1baff20dd31b.yml
openapi_spec_hash: b7e0fd7ee1656d7dbad57209d1584d92
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2af763aab4c314b382e1123edc4ee3d51c0fe7977730ce6776b9fb09b29fe291.yml
openapi_spec_hash: be02256478be81fa3f649076879850bc
config_hash: eab40627b734534462ae3b8ccd8b263b
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.0-alpha.9 (2025-05-12)

Full Changelog: [v0.1.0-alpha.8...v0.1.0-alpha.9](https://github.com/onkernel/kernel-node-sdk/compare/v0.1.0-alpha.8...v0.1.0-alpha.9)

### Features

* **api:** update via SDK Studio ([553e10c](https://github.com/onkernel/kernel-node-sdk/commit/553e10cfd6516146d2d81fb3cce9f3f88b21aa62))

## 0.1.0-alpha.8 (2025-05-11)

Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/onkernel/kernel-node-sdk/compare/v0.1.0-alpha.7...v0.1.0-alpha.8)
Expand Down
51 changes: 13 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ const client = new Kernel({

async function main() {
const response = await client.apps.deploy({
appName: 'REPLACE_ME',
file: fs.createReadStream('path/to/file'),
version: 'REPLACE_ME',
});

console.log(response.id);
console.log(response.apps);
}

main();
Expand All @@ -54,11 +53,7 @@ const client = new Kernel({
});

async function main() {
const params: Kernel.AppDeployParams = {
appName: 'REPLACE_ME',
file: fs.createReadStream('path/to/file'),
version: 'REPLACE_ME',
};
const params: Kernel.AppDeployParams = { file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' };
const response: Kernel.AppDeployResponse = await client.apps.deploy(params);
}

Expand All @@ -83,37 +78,17 @@ import Kernel, { toFile } from '@onkernel/sdk';
const client = new Kernel();

// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
await client.apps.deploy({
appName: 'my-awesome-app',
file: fs.createReadStream('/path/to/file'),
version: '1.0.0',
});
await client.apps.deploy({ file: fs.createReadStream('/path/to/file') });

// Or if you have the web `File` API you can pass a `File` instance:
await client.apps.deploy({
appName: 'my-awesome-app',
file: new File(['my bytes'], 'file'),
version: '1.0.0',
});
await client.apps.deploy({ file: new File(['my bytes'], 'file') });

// You can also pass a `fetch` `Response`:
await client.apps.deploy({
appName: 'my-awesome-app',
file: await fetch('https://somesite/file'),
version: '1.0.0',
});
await client.apps.deploy({ file: await fetch('https://somesite/file') });

// Finally, if none of the above are convenient, you can use our `toFile` helper:
await client.apps.deploy({
appName: 'my-awesome-app',
file: await toFile(Buffer.from('my bytes'), 'file'),
version: '1.0.0',
});
await client.apps.deploy({
appName: 'my-awesome-app',
file: await toFile(new Uint8Array([0, 1, 2]), 'file'),
version: '1.0.0',
});
await client.apps.deploy({ file: await toFile(Buffer.from('my bytes'), 'file') });
await client.apps.deploy({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
```

## Handling errors
Expand All @@ -126,7 +101,7 @@ a subclass of `APIError` will be thrown:
```ts
async function main() {
const response = await client.apps
.deploy({ appName: 'REPLACE_ME', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' })
.deploy({ file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' })
.catch(async (err) => {
if (err instanceof Kernel.APIError) {
console.log(err.status); // 400
Expand Down Expand Up @@ -170,7 +145,7 @@ const client = new Kernel({
});

// Or, configure per-request:
await client.apps.deploy({ appName: 'REPLACE_ME', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }, {
await client.apps.deploy({ file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }, {
maxRetries: 5,
});
```
Expand All @@ -187,7 +162,7 @@ const client = new Kernel({
});

// Override per-request:
await client.apps.deploy({ appName: 'REPLACE_ME', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }, {
await client.apps.deploy({ file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }, {
timeout: 5 * 1000,
});
```
Expand All @@ -211,16 +186,16 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
const client = new Kernel();

const response = await client.apps
.deploy({ appName: 'REPLACE_ME', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' })
.deploy({ file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' })
.asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: response, response: raw } = await client.apps
.deploy({ appName: 'REPLACE_ME', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' })
.deploy({ file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(response.id);
console.log(response.apps);
```

### Logging
Expand Down
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Types:

Methods:

- <code title="post /browser">client.browser.<a href="./src/resources/browser.ts">createSession</a>() -> BrowserCreateSessionResponse</code>
- <code title="post /browser">client.browser.<a href="./src/resources/browser.ts">createSession</a>({ ...params }) -> BrowserCreateSessionResponse</code>
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.1.0-alpha.8",
"version": "0.1.0-alpha.9",
"description": "The official TypeScript library for the Kernel API",
"author": "Kernel <>",
"types": "dist/index.d.ts",
Expand Down
8 changes: 6 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
AppRetrieveInvocationResponse,
Apps,
} from './resources/apps';
import { Browser, BrowserCreateSessionResponse } from './resources/browser';
import { Browser, BrowserCreateSessionParams, BrowserCreateSessionResponse } from './resources/browser';
import { readEnv } from './internal/utils/env';
import { formatRequestDetails, loggerFor } from './internal/utils/log';
import { isEmptyObj } from './internal/utils/values';
Expand Down Expand Up @@ -751,5 +751,9 @@ export declare namespace Kernel {
type AppInvokeParams as AppInvokeParams,
};

export { Browser as Browser, type BrowserCreateSessionResponse as BrowserCreateSessionResponse };
export {
Browser as Browser,
type BrowserCreateSessionResponse as BrowserCreateSessionResponse,
type BrowserCreateSessionParams as BrowserCreateSessionParams,
};
}
55 changes: 40 additions & 15 deletions src/resources/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export class Apps extends APIResource {
* @example
* ```ts
* const response = await client.apps.deploy({
* appName: 'my-awesome-app',
* file: fs.createReadStream('path/to/file'),
* version: '1.0.0',
* });
* ```
*/
Expand All @@ -32,7 +30,7 @@ export class Apps extends APIResource {
* const response = await client.apps.invoke({
* actionName: 'analyze',
* appName: 'my-awesome-app',
* payload: '{ "data": "example input" }',
* payload: { data: 'example input' },
* version: '1.0.0',
* });
* ```
Expand All @@ -57,10 +55,7 @@ export class Apps extends APIResource {
}

export interface AppDeployResponse {
/**
* ID of the deployed app version
*/
id: string;
apps: Array<AppDeployResponse.App>;

/**
* Success message
Expand All @@ -73,6 +68,31 @@ export interface AppDeployResponse {
success: boolean;
}

export namespace AppDeployResponse {
export interface App {
/**
* ID for the app version deployed
*/
id: string;

actions: Array<App.Action>;

/**
* Name of the app
*/
name: string;
}

export namespace App {
export interface Action {
/**
* Name of the action
*/
name: string;
}
}
}

export interface AppInvokeResponse {
/**
* ID of the invocation
Expand Down Expand Up @@ -108,24 +128,29 @@ export interface AppRetrieveInvocationResponse {

export interface AppDeployParams {
/**
* Name of the application
* ZIP file containing the application source directory
*/
appName: string;
file: Uploadable;

/**
* ZIP file containing the application
* Relative path to the entrypoint of the application
*/
file: Uploadable;
entrypointRelPath?: string;

/**
* Version of the application
* Allow overwriting an existing app version
*/
version: string;
force?: 'true' | 'false';

/**
* Region for deployment. Currently we only support "aws.us-east-1a"
*/
region?: 'aws.us-east-1a';

/**
* AWS region for deployment (e.g. "aws.us-east-1a")
* Version of the application. Can be any string.
*/
region?: string;
version?: string;
}

export interface AppInvokeParams {
Expand Down
19 changes: 16 additions & 3 deletions src/resources/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ export class Browser extends APIResource {
/**
* Create Browser Session
*/
createSession(options?: RequestOptions): APIPromise<BrowserCreateSessionResponse> {
return this._client.post('/browser', options);
createSession(
body: BrowserCreateSessionParams,
options?: RequestOptions,
): APIPromise<BrowserCreateSessionResponse> {
return this._client.post('/browser', { body, ...options });
}
}

Expand All @@ -30,6 +33,16 @@ export interface BrowserCreateSessionResponse {
sessionId: string;
}

export interface BrowserCreateSessionParams {
/**
* Kernel App invocation ID
*/
invocationId: string;
}

export declare namespace Browser {
export { type BrowserCreateSessionResponse as BrowserCreateSessionResponse };
export {
type BrowserCreateSessionResponse as BrowserCreateSessionResponse,
type BrowserCreateSessionParams as BrowserCreateSessionParams,
};
}
2 changes: 1 addition & 1 deletion src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export {
type AppDeployParams,
type AppInvokeParams,
} from './apps';
export { Browser, type BrowserCreateSessionResponse } from './browser';
export { Browser, type BrowserCreateSessionResponse, type BrowserCreateSessionParams } from './browser';
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.1.0-alpha.8'; // x-release-please-version
export const VERSION = '0.1.0-alpha.9'; // x-release-please-version
11 changes: 5 additions & 6 deletions tests/api-resources/apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ describe('resource apps', () => {
// skipped: tests are disabled for the time being
test.skip('deploy: only required params', async () => {
const responsePromise = client.apps.deploy({
appName: 'my-awesome-app',
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
version: '1.0.0',
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -27,10 +25,11 @@ describe('resource apps', () => {
// skipped: tests are disabled for the time being
test.skip('deploy: required and optional params', async () => {
const response = await client.apps.deploy({
appName: 'my-awesome-app',
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
version: '1.0.0',
entrypointRelPath: 'app.py',
force: 'false',
region: 'aws.us-east-1a',
version: '1.0.0',
});
});

Expand All @@ -39,7 +38,7 @@ describe('resource apps', () => {
const responsePromise = client.apps.invoke({
actionName: 'analyze',
appName: 'my-awesome-app',
payload: '{ "data": "example input" }',
payload: { data: 'example input' },
version: '1.0.0',
});
const rawResponse = await responsePromise.asResponse();
Expand All @@ -56,7 +55,7 @@ describe('resource apps', () => {
const response = await client.apps.invoke({
actionName: 'analyze',
appName: 'my-awesome-app',
payload: '{ "data": "example input" }',
payload: { data: 'example input' },
version: '1.0.0',
});
});
Expand Down
9 changes: 7 additions & 2 deletions tests/api-resources/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const client = new Kernel({

describe('resource browser', () => {
// skipped: tests are disabled for the time being
test.skip('createSession', async () => {
const responsePromise = client.browser.createSession();
test.skip('createSession: only required params', async () => {
const responsePromise = client.browser.createSession({ invocationId: 'invocationId' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -19,4 +19,9 @@ describe('resource browser', () => {
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

// skipped: tests are disabled for the time being
test.skip('createSession: required and optional params', async () => {
const response = await client.browser.createSession({ invocationId: 'invocationId' });
});
});