diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 931fce1..acba45e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.10" + ".": "0.1.0-alpha.11" } diff --git a/.stats.yml b/.stats.yml index d6d797a..6f21bcb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 4 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-07d481d1498bf9677437b555e9ec2d843d50107faa7501e4c430a32b1f3c3343.yml -openapi_spec_hash: 296f78d82afbac95fad12c5eabd71f18 -config_hash: 2c8351ba6611ce4a352e248405783846 +configured_endpoints: 5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-f40e779e2a48f5e37361f2f4a9879e5c40f2851b8033c23db69ec7b91242bf69.yml +openapi_spec_hash: 2dfa146149e61363f1ec40bf9251eb7c +config_hash: 2ddaa85513b6670889b1a56c905423c7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fef3b2..e6df836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.11 (2025-05-19) + +Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.11](https://github.com/onkernel/kernel-node-sdk/compare/v0.1.0-alpha.10...v0.1.0-alpha.11) + +### Features + +* **api:** update via SDK Studio ([ca8d138](https://github.com/onkernel/kernel-node-sdk/commit/ca8d138bd9242266ddd5a5180cefb4baf85f583d)) + ## 0.1.0-alpha.10 (2025-05-14) Full Changelog: [v0.1.0-alpha.9...v0.1.0-alpha.10](https://github.com/onkernel/kernel-node-sdk/compare/v0.1.0-alpha.9...v0.1.0-alpha.10) diff --git a/README.md b/README.md index e9bb7a3..86b1426 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,13 @@ const client = new Kernel({ }); async function main() { - const response = await client.apps.deploy({ - entrypointRelPath: 'app.py', + const deployment = await client.apps.deployments.create({ + entrypoint_rel_path: 'main.ts', file: fs.createReadStream('path/to/file'), - version: 'REPLACE_ME', + version: '1.0.0', }); - console.log(response.apps); + console.log(deployment.apps); } main(); @@ -54,12 +54,8 @@ const client = new Kernel({ }); async function main() { - const params: Kernel.AppDeployParams = { - entrypointRelPath: 'app.py', - file: fs.createReadStream('path/to/file'), - version: 'REPLACE_ME', - }; - const response: Kernel.AppDeployResponse = await client.apps.deploy(params); + const params: Kernel.BrowserCreateParams = { invocation_id: 'REPLACE_ME' }; + const browser: Kernel.BrowserCreateResponse = await client.browsers.create(params); } main(); @@ -83,21 +79,30 @@ 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({ entrypointRelPath: 'app.py', file: fs.createReadStream('/path/to/file') }); +await client.apps.deployments.create({ + entrypoint_rel_path: 'src/app.py', + file: fs.createReadStream('/path/to/file'), +}); // Or if you have the web `File` API you can pass a `File` instance: -await client.apps.deploy({ entrypointRelPath: 'app.py', file: new File(['my bytes'], 'file') }); +await client.apps.deployments.create({ + entrypoint_rel_path: 'src/app.py', + file: new File(['my bytes'], 'file'), +}); // You can also pass a `fetch` `Response`: -await client.apps.deploy({ entrypointRelPath: 'app.py', file: await fetch('https://somesite/file') }); +await client.apps.deployments.create({ + entrypoint_rel_path: 'src/app.py', + file: await fetch('https://somesite/file'), +}); // Finally, if none of the above are convenient, you can use our `toFile` helper: -await client.apps.deploy({ - entrypointRelPath: 'app.py', +await client.apps.deployments.create({ + entrypoint_rel_path: 'src/app.py', file: await toFile(Buffer.from('my bytes'), 'file'), }); -await client.apps.deploy({ - entrypointRelPath: 'app.py', +await client.apps.deployments.create({ + entrypoint_rel_path: 'src/app.py', file: await toFile(new Uint8Array([0, 1, 2]), 'file'), }); ``` @@ -111,17 +116,15 @@ a subclass of `APIError` will be thrown: ```ts async function main() { - const response = await client.apps - .deploy({ entrypointRelPath: 'app.py', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }) - .catch(async (err) => { - if (err instanceof Kernel.APIError) { - console.log(err.status); // 400 - console.log(err.name); // BadRequestError - console.log(err.headers); // {server: 'nginx', ...} - } else { - throw err; - } - }); + const browser = await client.browsers.create({ invocation_id: 'REPLACE_ME' }).catch(async (err) => { + if (err instanceof Kernel.APIError) { + console.log(err.status); // 400 + console.log(err.name); // BadRequestError + console.log(err.headers); // {server: 'nginx', ...} + } else { + throw err; + } + }); } main(); @@ -156,7 +159,7 @@ const client = new Kernel({ }); // Or, configure per-request: -await client.apps.deploy({ entrypointRelPath: 'app.py', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }, { +await client.browsers.create({ invocation_id: 'REPLACE_ME' }, { maxRetries: 5, }); ``` @@ -173,7 +176,7 @@ const client = new Kernel({ }); // Override per-request: -await client.apps.deploy({ entrypointRelPath: 'app.py', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }, { +await client.browsers.create({ invocation_id: 'REPLACE_ME' }, { timeout: 5 * 1000, }); ``` @@ -196,17 +199,15 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse ```ts const client = new Kernel(); -const response = await client.apps - .deploy({ entrypointRelPath: 'app.py', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }) - .asResponse(); +const response = await client.browsers.create({ invocation_id: '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({ entrypointRelPath: 'app.py', file: fs.createReadStream('path/to/file'), version: 'REPLACE_ME' }) +const { data: browser, response: raw } = await client.browsers + .create({ invocation_id: 'REPLACE_ME' }) .withResponse(); console.log(raw.headers.get('X-My-Header')); -console.log(response.apps); +console.log(browser.session_id); ``` ### Logging diff --git a/api.md b/api.md index 88e3798..1fc97fd 100644 --- a/api.md +++ b/api.md @@ -1,23 +1,35 @@ # Apps +## Deployments + +Types: + +- DeploymentCreateResponse + +Methods: + +- client.apps.deployments.create({ ...params }) -> DeploymentCreateResponse + +## Invocations + Types: -- AppDeployResponse -- AppInvokeResponse -- AppRetrieveInvocationResponse +- InvocationCreateResponse +- InvocationRetrieveResponse Methods: -- client.apps.deploy({ ...params }) -> AppDeployResponse -- client.apps.invoke({ ...params }) -> AppInvokeResponse -- client.apps.retrieveInvocation(id) -> AppRetrieveInvocationResponse +- client.apps.invocations.create({ ...params }) -> InvocationCreateResponse +- client.apps.invocations.retrieve(id) -> InvocationRetrieveResponse -# Browser +# Browsers Types: -- BrowserCreateSessionResponse +- BrowserCreateResponse +- BrowserRetrieveResponse Methods: -- client.browser.createSession({ ...params }) -> BrowserCreateSessionResponse +- client.browsers.create({ ...params }) -> BrowserCreateResponse +- client.browsers.retrieve(id) -> BrowserRetrieveResponse diff --git a/package.json b/package.json index dacc7be..fc5f0a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/sdk", - "version": "0.1.0-alpha.10", + "version": "0.1.0-alpha.11", "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 d1dfe16..6c25324 100644 --- a/src/client.ts +++ b/src/client.ts @@ -21,18 +21,16 @@ import { type Fetch } from './internal/builtin-types'; import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; import { FinalRequestOptions, RequestOptions } from './internal/request-options'; import { - AppDeployParams, - AppDeployResponse, - AppInvokeParams, - AppInvokeResponse, - AppRetrieveInvocationResponse, - Apps, -} from './resources/apps'; -import { Browser, BrowserCreateSessionParams, BrowserCreateSessionResponse } from './resources/browser'; + BrowserCreateParams, + BrowserCreateResponse, + BrowserRetrieveResponse, + Browsers, +} from './resources/browsers'; import { readEnv } from './internal/utils/env'; import { formatRequestDetails, loggerFor } from './internal/utils/log'; import { isEmptyObj } from './internal/utils/values'; import { KernelApp } from './core/app-framework'; +import { Apps } from './resources/apps/apps'; const environments = { production: 'https://api.onkernel.com/', @@ -735,25 +733,19 @@ export class Kernel { static toFile = Uploads.toFile; apps: API.Apps = new API.Apps(this); - browser: API.Browser = new API.Browser(this); + browsers: API.Browsers = new API.Browsers(this); } Kernel.Apps = Apps; -Kernel.Browser = Browser; +Kernel.Browsers = Browsers; export declare namespace Kernel { export type RequestOptions = Opts.RequestOptions; - export { - Apps as Apps, - type AppDeployResponse as AppDeployResponse, - type AppInvokeResponse as AppInvokeResponse, - type AppRetrieveInvocationResponse as AppRetrieveInvocationResponse, - type AppDeployParams as AppDeployParams, - type AppInvokeParams as AppInvokeParams, - }; + export { Apps as Apps }; export { - Browser as Browser, - type BrowserCreateSessionResponse as BrowserCreateSessionResponse, - type BrowserCreateSessionParams as BrowserCreateSessionParams, + Browsers as Browsers, + type BrowserCreateResponse as BrowserCreateResponse, + type BrowserRetrieveResponse as BrowserRetrieveResponse, + type BrowserCreateParams as BrowserCreateParams, }; } diff --git a/src/resources/apps.ts b/src/resources/apps.ts index ddf6f55..c368b82 100644 --- a/src/resources/apps.ts +++ b/src/resources/apps.ts @@ -1,187 +1,3 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { APIResource } from '../core/resource'; -import { APIPromise } from '../core/api-promise'; -import { type Uploadable } from '../core/uploads'; -import { RequestOptions } from '../internal/request-options'; -import { multipartFormRequestOptions } from '../internal/uploads'; -import { path } from '../internal/utils/path'; - -export class Apps extends APIResource { - /** - * Deploy a new application - * - * @example - * ```ts - * const response = await client.apps.deploy({ - * entrypointRelPath: 'app.py', - * file: fs.createReadStream('path/to/file'), - * }); - * ``` - */ - deploy(body: AppDeployParams, options?: RequestOptions): APIPromise { - return this._client.post('/apps/deploy', multipartFormRequestOptions({ body, ...options }, this._client)); - } - - /** - * Invoke an application - * - * @example - * ```ts - * const response = await client.apps.invoke({ - * actionName: 'analyze', - * appName: 'my-awesome-app', - * payload: { data: 'example input' }, - * version: '1.0.0', - * }); - * ``` - */ - invoke(body: AppInvokeParams, options?: RequestOptions): APIPromise { - return this._client.post('/apps/invoke', { body, ...options }); - } - - /** - * Get an app invocation by id - * - * @example - * ```ts - * const response = await client.apps.retrieveInvocation( - * 'ckqwer3o20000jb9s7abcdef', - * ); - * ``` - */ - retrieveInvocation(id: string, options?: RequestOptions): APIPromise { - return this._client.get(path`/apps/invocations/${id}`, options); - } -} - -export interface AppDeployResponse { - apps: Array; - - /** - * Success message - */ - message: string; - - /** - * Status of the deployment - */ - success: boolean; -} - -export namespace AppDeployResponse { - export interface App { - /** - * ID for the app version deployed - */ - id: string; - - actions: Array; - - /** - * 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 - */ - id: string; - - /** - * Status of the invocation - */ - status: 'QUEUED' | 'RUNNING' | 'SUCCEEDED' | 'FAILED'; - - /** - * Output from the invocation (if available) - */ - output?: string; -} - -export interface AppRetrieveInvocationResponse { - id: string; - - appName: string; - - finishedAt: string | null; - - input: string; - - output: string; - - startedAt: string; - - status: string; -} - -export interface AppDeployParams { - /** - * Relative path to the entrypoint of the application - */ - entrypointRelPath: string; - - /** - * ZIP file containing the application source directory - */ - file: Uploadable; - - /** - * Allow overwriting an existing app version - */ - force?: 'true' | 'false'; - - /** - * Region for deployment. Currently we only support "aws.us-east-1a" - */ - region?: 'aws.us-east-1a'; - - /** - * Version of the application. Can be any string. - */ - version?: string; -} - -export interface AppInvokeParams { - /** - * Name of the action to invoke - */ - actionName: string; - - /** - * Name of the application - */ - appName: string; - - /** - * Input data for the application - */ - payload: unknown; - - /** - * Version of the application - */ - version: string; -} - -export declare namespace Apps { - export { - type AppDeployResponse as AppDeployResponse, - type AppInvokeResponse as AppInvokeResponse, - type AppRetrieveInvocationResponse as AppRetrieveInvocationResponse, - type AppDeployParams as AppDeployParams, - type AppInvokeParams as AppInvokeParams, - }; -} +export * from './apps/index'; diff --git a/src/resources/apps/apps.ts b/src/resources/apps/apps.ts new file mode 100644 index 0000000..fe32c1e --- /dev/null +++ b/src/resources/apps/apps.ts @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../core/resource'; +import * as DeploymentsAPI from './deployments'; +import { DeploymentCreateParams, DeploymentCreateResponse, Deployments } from './deployments'; +import * as InvocationsAPI from './invocations'; +import { + InvocationCreateParams, + InvocationCreateResponse, + InvocationRetrieveResponse, + Invocations, +} from './invocations'; + +export class Apps extends APIResource { + deployments: DeploymentsAPI.Deployments = new DeploymentsAPI.Deployments(this._client); + invocations: InvocationsAPI.Invocations = new InvocationsAPI.Invocations(this._client); +} + +Apps.Deployments = Deployments; +Apps.Invocations = Invocations; + +export declare namespace Apps { + export { + Deployments as Deployments, + type DeploymentCreateResponse as DeploymentCreateResponse, + type DeploymentCreateParams as DeploymentCreateParams, + }; + + export { + Invocations as Invocations, + type InvocationCreateResponse as InvocationCreateResponse, + type InvocationRetrieveResponse as InvocationRetrieveResponse, + type InvocationCreateParams as InvocationCreateParams, + }; +} diff --git a/src/resources/apps/deployments.ts b/src/resources/apps/deployments.ts new file mode 100644 index 0000000..abd9655 --- /dev/null +++ b/src/resources/apps/deployments.ts @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../core/resource'; +import { APIPromise } from '../../core/api-promise'; +import { type Uploadable } from '../../core/uploads'; +import { RequestOptions } from '../../internal/request-options'; +import { multipartFormRequestOptions } from '../../internal/uploads'; + +export class Deployments extends APIResource { + /** + * Deploy a new application + * + * @example + * ```ts + * const deployment = await client.apps.deployments.create({ + * entrypoint_rel_path: 'src/app.py', + * file: fs.createReadStream('path/to/file'), + * }); + * ``` + */ + create(body: DeploymentCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/deploy', multipartFormRequestOptions({ body, ...options }, this._client)); + } +} + +export interface DeploymentCreateResponse { + /** + * List of apps deployed + */ + apps: Array; + + /** + * Current status of the deployment + */ + status: 'queued' | 'deploying' | 'succeeded' | 'failed'; + + /** + * Status reason + */ + status_reason?: string; +} + +export namespace DeploymentCreateResponse { + export interface App { + /** + * ID for the app version deployed + */ + id: string; + + /** + * List of actions available on the app + */ + actions: Array; + + /** + * Name of the app + */ + name: string; + } + + export namespace App { + export interface Action { + /** + * Name of the action + */ + name: string; + } + } +} + +export interface DeploymentCreateParams { + /** + * Relative path to the entrypoint of the application + */ + entrypoint_rel_path: string; + + /** + * ZIP file containing the application source directory + */ + file: Uploadable; + + /** + * Allow overwriting an existing app version + */ + force?: boolean; + + /** + * Region for deployment. Currently we only support "aws.us-east-1a" + */ + region?: 'aws.us-east-1a'; + + /** + * Version of the application. Can be any string. + */ + version?: string; +} + +export declare namespace Deployments { + export { + type DeploymentCreateResponse as DeploymentCreateResponse, + type DeploymentCreateParams as DeploymentCreateParams, + }; +} diff --git a/src/resources/apps/index.ts b/src/resources/apps/index.ts new file mode 100644 index 0000000..1703ae2 --- /dev/null +++ b/src/resources/apps/index.ts @@ -0,0 +1,10 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { Apps } from './apps'; +export { Deployments, type DeploymentCreateResponse, type DeploymentCreateParams } from './deployments'; +export { + Invocations, + type InvocationCreateResponse, + type InvocationRetrieveResponse, + type InvocationCreateParams, +} from './invocations'; diff --git a/src/resources/apps/invocations.ts b/src/resources/apps/invocations.ts new file mode 100644 index 0000000..fee4db3 --- /dev/null +++ b/src/resources/apps/invocations.ts @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../core/resource'; +import { APIPromise } from '../../core/api-promise'; +import { RequestOptions } from '../../internal/request-options'; +import { path } from '../../internal/utils/path'; + +export class Invocations extends APIResource { + /** + * Invoke an application + * + * @example + * ```ts + * const invocation = await client.apps.invocations.create({ + * action_name: 'analyze', + * app_name: 'my-app', + * version: '1.0.0', + * }); + * ``` + */ + create(body: InvocationCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/invocations', { body, ...options }); + } + + /** + * Get an app invocation by id + * + * @example + * ```ts + * const invocation = await client.apps.invocations.retrieve( + * 'ckqwer3o20000jb9s7abcdef', + * ); + * ``` + */ + retrieve(id: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/invocations/${id}`, options); + } +} + +export interface InvocationCreateResponse { + /** + * ID of the invocation + */ + id: string; + + /** + * Status of the invocation + */ + status: 'queued' | 'running' | 'succeeded' | 'failed'; + + /** + * The return value of the action that was invoked, rendered as a JSON string. This + * could be: string, number, boolean, array, object, or null. + */ + output?: string; + + /** + * Status reason + */ + status_reason?: string; +} + +export interface InvocationRetrieveResponse { + /** + * 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 + */ + action_name: string; + + /** + * Name of the application + */ + app_name: string; + + /** + * Version of the application + */ + version: string; + + /** + * Input data for the action, sent as a JSON string. + */ + payload?: string; +} + +export declare namespace Invocations { + export { + type InvocationCreateResponse as InvocationCreateResponse, + type InvocationRetrieveResponse as InvocationRetrieveResponse, + type InvocationCreateParams as InvocationCreateParams, + }; +} diff --git a/src/resources/browser.ts b/src/resources/browser.ts deleted file mode 100644 index 2b434f5..0000000 --- a/src/resources/browser.ts +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { APIResource } from '../core/resource'; -import { APIPromise } from '../core/api-promise'; -import { RequestOptions } from '../internal/request-options'; - -export class Browser extends APIResource { - /** - * Create Browser Session - */ - createSession( - body: BrowserCreateSessionParams, - options?: RequestOptions, - ): APIPromise { - return this._client.post('/browser', { body, ...options }); - } -} - -export interface BrowserCreateSessionResponse { - /** - * Websocket URL for Chrome DevTools Protocol connections to the browser session - */ - cdp_ws_url: string; - - /** - * Remote URL for live viewing the browser session - */ - remote_url: string; - - /** - * Unique identifier for the browser session - */ - sessionId: string; -} - -export interface BrowserCreateSessionParams { - /** - * Kernel App invocation ID - */ - invocationId: string; -} - -export declare namespace Browser { - export { - type BrowserCreateSessionResponse as BrowserCreateSessionResponse, - type BrowserCreateSessionParams as BrowserCreateSessionParams, - }; -} diff --git a/src/resources/browsers.ts b/src/resources/browsers.ts new file mode 100644 index 0000000..febb6d1 --- /dev/null +++ b/src/resources/browsers.ts @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../core/resource'; +import { APIPromise } from '../core/api-promise'; +import { RequestOptions } from '../internal/request-options'; +import { path } from '../internal/utils/path'; + +export class Browsers extends APIResource { + /** + * Create Browser Session + * + * @example + * ```ts + * const browser = await client.browsers.create({ + * invocation_id: 'ckqwer3o20000jb9s7abcdef', + * }); + * ``` + */ + create(body: BrowserCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/browsers', { body, ...options }); + } + + /** + * Get Browser Session by ID + * + * @example + * ```ts + * const browser = await client.browsers.retrieve( + * 'e5bf36fe-9247-4e2b-8b5a-2f594cc1c073', + * ); + * ``` + */ + retrieve(id: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/browsers/${id}`, options); + } +} + +export interface BrowserCreateResponse { + /** + * Remote URL for live viewing the browser session + */ + browser_live_view_url: string; + + /** + * Websocket URL for Chrome DevTools Protocol connections to the browser session + */ + cdp_ws_url: string; + + /** + * Unique identifier for the browser session + */ + session_id: string; +} + +export interface BrowserRetrieveResponse { + /** + * Remote URL for live viewing the browser session + */ + browser_live_view_url: string; + + /** + * Websocket URL for Chrome DevTools Protocol connections to the browser session + */ + cdp_ws_url: string; + + /** + * Unique identifier for the browser session + */ + session_id: string; +} + +export interface BrowserCreateParams { + /** + * action invocation ID + */ + invocation_id: string; +} + +export declare namespace Browsers { + export { + type BrowserCreateResponse as BrowserCreateResponse, + type BrowserRetrieveResponse as BrowserRetrieveResponse, + type BrowserCreateParams as BrowserCreateParams, + }; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index bf366e6..d8d49ae 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,11 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +export { Apps } from './apps/apps'; export { - Apps, - type AppDeployResponse, - type AppInvokeResponse, - type AppRetrieveInvocationResponse, - type AppDeployParams, - type AppInvokeParams, -} from './apps'; -export { Browser, type BrowserCreateSessionResponse, type BrowserCreateSessionParams } from './browser'; + Browsers, + type BrowserCreateResponse, + type BrowserRetrieveResponse, + type BrowserCreateParams, +} from './browsers'; diff --git a/src/version.ts b/src/version.ts index 5ed52cd..51a202a 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.0-alpha.10'; // x-release-please-version +export const VERSION = '0.1.0-alpha.11'; // x-release-please-version diff --git a/tests/api-resources/apps.test.ts b/tests/api-resources/apps.test.ts deleted file mode 100644 index 974e97b..0000000 --- a/tests/api-resources/apps.test.ts +++ /dev/null @@ -1,75 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Kernel, { toFile } 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 apps', () => { - // skipped: tests are disabled for the time being - test.skip('deploy: only required params', async () => { - const responsePromise = client.apps.deploy({ - entrypointRelPath: 'app.py', - file: await toFile(Buffer.from('# my file contents'), 'README.md'), - }); - 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('deploy: required and optional params', async () => { - const response = await client.apps.deploy({ - entrypointRelPath: 'app.py', - file: await toFile(Buffer.from('# my file contents'), 'README.md'), - force: 'false', - region: 'aws.us-east-1a', - version: '1.0.0', - }); - }); - - // skipped: tests are disabled for the time being - test.skip('invoke: only required params', async () => { - const responsePromise = client.apps.invoke({ - actionName: 'analyze', - appName: 'my-awesome-app', - payload: { data: 'example input' }, - version: '1.0.0', - }); - 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('invoke: required and optional params', async () => { - const response = await client.apps.invoke({ - actionName: 'analyze', - appName: 'my-awesome-app', - payload: { data: 'example input' }, - version: '1.0.0', - }); - }); - - // skipped: tests are disabled for the time being - test.skip('retrieveInvocation', async () => { - const responsePromise = client.apps.retrieveInvocation('ckqwer3o20000jb9s7abcdef'); - 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); - }); -}); diff --git a/tests/api-resources/browser.test.ts b/tests/api-resources/apps/deployments.test.ts similarity index 52% rename from tests/api-resources/browser.test.ts rename to tests/api-resources/apps/deployments.test.ts index 012e207..5e6c43c 100644 --- a/tests/api-resources/browser.test.ts +++ b/tests/api-resources/apps/deployments.test.ts @@ -1,16 +1,19 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import Kernel from '@onkernel/sdk'; +import Kernel, { toFile } 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 browser', () => { +describe('resource deployments', () => { // skipped: tests are disabled for the time being - test.skip('createSession: only required params', async () => { - const responsePromise = client.browser.createSession({ invocationId: 'invocationId' }); + test.skip('create: only required params', async () => { + const responsePromise = client.apps.deployments.create({ + entrypoint_rel_path: 'src/app.py', + file: await toFile(Buffer.from('# my file contents'), 'README.md'), + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +24,13 @@ describe('resource browser', () => { }); // skipped: tests are disabled for the time being - test.skip('createSession: required and optional params', async () => { - const response = await client.browser.createSession({ invocationId: 'invocationId' }); + test.skip('create: required and optional params', async () => { + const response = await client.apps.deployments.create({ + entrypoint_rel_path: 'src/app.py', + file: await toFile(Buffer.from('# my file contents'), 'README.md'), + force: false, + region: 'aws.us-east-1a', + version: '1.0.0', + }); }); }); diff --git a/tests/api-resources/apps/invocations.test.ts b/tests/api-resources/apps/invocations.test.ts new file mode 100644 index 0000000..3bafc76 --- /dev/null +++ b/tests/api-resources/apps/invocations.test.ts @@ -0,0 +1,48 @@ +// 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 invocations', () => { + // skipped: tests are disabled for the time being + test.skip('create: only required params', async () => { + const responsePromise = client.apps.invocations.create({ + action_name: 'analyze', + app_name: 'my-app', + version: '1.0.0', + }); + 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('create: required and optional params', async () => { + const response = await client.apps.invocations.create({ + action_name: 'analyze', + app_name: 'my-app', + version: '1.0.0', + payload: '{"data":"example input"}', + }); + }); + + // skipped: tests are disabled for the time being + test.skip('retrieve', async () => { + const responsePromise = client.apps.invocations.retrieve('ckqwer3o20000jb9s7abcdef'); + 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); + }); +}); diff --git a/tests/api-resources/browsers.test.ts b/tests/api-resources/browsers.test.ts new file mode 100644 index 0000000..7234977 --- /dev/null +++ b/tests/api-resources/browsers.test.ts @@ -0,0 +1,39 @@ +// 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 browsers', () => { + // skipped: tests are disabled for the time being + test.skip('create: only required params', async () => { + const responsePromise = client.browsers.create({ invocation_id: 'ckqwer3o20000jb9s7abcdef' }); + 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('create: required and optional params', async () => { + const response = await client.browsers.create({ invocation_id: 'ckqwer3o20000jb9s7abcdef' }); + }); + + // skipped: tests are disabled for the time being + test.skip('retrieve', async () => { + const responsePromise = client.browsers.retrieve('e5bf36fe-9247-4e2b-8b5a-2f594cc1c073'); + 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); + }); +});