diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 97bce11..fc5553b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.23.0" + ".": "0.24.0" } diff --git a/.stats.yml b/.stats.yml index 135345a..99bb6c4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 82 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-dac11bdb857e700a8c39d183e753ddd1ebaaca69fd9fc5ee57d6b56b70b00e6e.yml -openapi_spec_hash: 78fbc50dd0b61cdc87564fbea278ee23 -config_hash: a4b4d14bdf6af723b235a6981977627c +configured_endpoints: 89 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-13214b99e392aab631aa1ca99b6a51a58df81e34156d21b8d639bea779566123.yml +openapi_spec_hash: a88d175fc3980de3097ac1411d8dcbff +config_hash: 179f33af31ece83563163d5b3d751d13 diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a1736..10efd02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.24.0 (2025-12-17) + +Full Changelog: [v0.23.0...v0.24.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.23.0...v0.24.0) + +### Features + +* Enhance AuthAgentInvocationCreateResponse to include already_authenti… ([70cd6d6](https://github.com/onkernel/kernel-node-sdk/commit/70cd6d6c44fa9f90a5bfad3e6268bd6264a9f83b)) +* Fix browser pool sdk types ([e4b773f](https://github.com/onkernel/kernel-node-sdk/commit/e4b773f9923b1bf4fcda5bd2c9832cbb291981bd)) + ## 0.23.0 (2025-12-11) Full Changelog: [v0.22.0...v0.23.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.22.0...v0.23.0) diff --git a/api.md b/api.md index 2050a8d..4086b1a 100644 --- a/api.md +++ b/api.md @@ -229,10 +229,6 @@ Methods: Types: - BrowserPool -- BrowserPoolAcquireRequest -- BrowserPoolReleaseRequest -- BrowserPoolRequest -- BrowserPoolUpdateRequest - BrowserPoolListResponse - BrowserPoolAcquireResponse @@ -261,12 +257,15 @@ Types: - AuthAgentInvocationCreateRequest - AuthAgentInvocationCreateResponse - DiscoveredField +- ReauthResponse Methods: - client.agents.auth.create({ ...params }) -> AuthAgent - client.agents.auth.retrieve(id) -> AuthAgent - client.agents.auth.list({ ...params }) -> AuthAgentsOffsetPagination +- client.agents.auth.delete(id) -> void +- client.agents.auth.reauth(id) -> ReauthResponse ### Invocations @@ -281,3 +280,19 @@ Methods: - client.agents.auth.invocations.discover(invocationID, { ...params }) -> AgentAuthDiscoverResponse - client.agents.auth.invocations.exchange(invocationID, { ...params }) -> InvocationExchangeResponse - client.agents.auth.invocations.submit(invocationID, { ...params }) -> AgentAuthSubmitResponse + +# Credentials + +Types: + +- CreateCredentialRequest +- Credential +- UpdateCredentialRequest + +Methods: + +- client.credentials.create({ ...params }) -> Credential +- client.credentials.retrieve(id) -> Credential +- client.credentials.update(id, { ...params }) -> Credential +- client.credentials.list({ ...params }) -> CredentialsOffsetPagination +- client.credentials.delete(id) -> void diff --git a/package.json b/package.json index 5383c20..ce072cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/sdk", - "version": "0.23.0", + "version": "0.24.0", "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 dd80bb3..1bc8783 100644 --- a/src/client.ts +++ b/src/client.ts @@ -22,18 +22,24 @@ import { AppListParams, AppListResponse, AppListResponsesOffsetPagination, Apps import { BrowserPool, BrowserPoolAcquireParams, - BrowserPoolAcquireRequest, BrowserPoolAcquireResponse, BrowserPoolCreateParams, BrowserPoolDeleteParams, BrowserPoolListResponse, BrowserPoolReleaseParams, - BrowserPoolReleaseRequest, - BrowserPoolRequest, BrowserPoolUpdateParams, - BrowserPoolUpdateRequest, BrowserPools, } from './resources/browser-pools'; +import { + CreateCredentialRequest, + Credential, + CredentialCreateParams, + CredentialListParams, + CredentialUpdateParams, + Credentials, + CredentialsOffsetPagination, + UpdateCredentialRequest, +} from './resources/credentials'; import { DeploymentCreateParams, DeploymentCreateResponse, @@ -861,6 +867,7 @@ export class Kernel { extensions: API.Extensions = new API.Extensions(this); browserPools: API.BrowserPools = new API.BrowserPools(this); agents: API.Agents = new API.Agents(this); + credentials: API.Credentials = new API.Credentials(this); } Kernel.Deployments = Deployments; @@ -872,6 +879,7 @@ Kernel.Proxies = Proxies; Kernel.Extensions = Extensions; Kernel.BrowserPools = BrowserPools; Kernel.Agents = Agents; +Kernel.Credentials = Credentials; export declare namespace Kernel { export type RequestOptions = Opts.RequestOptions; @@ -956,10 +964,6 @@ export declare namespace Kernel { export { BrowserPools as BrowserPools, type BrowserPool as BrowserPool, - type BrowserPoolAcquireRequest as BrowserPoolAcquireRequest, - type BrowserPoolReleaseRequest as BrowserPoolReleaseRequest, - type BrowserPoolRequest as BrowserPoolRequest, - type BrowserPoolUpdateRequest as BrowserPoolUpdateRequest, type BrowserPoolListResponse as BrowserPoolListResponse, type BrowserPoolAcquireResponse as BrowserPoolAcquireResponse, type BrowserPoolCreateParams as BrowserPoolCreateParams, @@ -971,6 +975,17 @@ export declare namespace Kernel { export { Agents as Agents }; + export { + Credentials as Credentials, + type CreateCredentialRequest as CreateCredentialRequest, + type Credential as Credential, + type UpdateCredentialRequest as UpdateCredentialRequest, + type CredentialsOffsetPagination as CredentialsOffsetPagination, + type CredentialCreateParams as CredentialCreateParams, + type CredentialUpdateParams as CredentialUpdateParams, + type CredentialListParams as CredentialListParams, + }; + export type AppAction = API.AppAction; export type BrowserExtension = API.BrowserExtension; export type BrowserProfile = API.BrowserProfile; diff --git a/src/resources/agents/agents.ts b/src/resources/agents/agents.ts index cf10a25..cb21314 100644 --- a/src/resources/agents/agents.ts +++ b/src/resources/agents/agents.ts @@ -15,6 +15,7 @@ import { AuthCreateParams, AuthListParams, DiscoveredField, + ReauthResponse, } from './auth/auth'; export class Agents extends APIResource { @@ -34,6 +35,7 @@ export declare namespace Agents { type AuthAgentInvocationCreateRequest as AuthAgentInvocationCreateRequest, type AuthAgentInvocationCreateResponse as AuthAgentInvocationCreateResponse, type DiscoveredField as DiscoveredField, + type ReauthResponse as ReauthResponse, type AuthAgentsOffsetPagination as AuthAgentsOffsetPagination, type AuthCreateParams as AuthCreateParams, type AuthListParams as AuthListParams, diff --git a/src/resources/agents/auth/auth.ts b/src/resources/agents/auth/auth.ts index ca02544..636daba 100644 --- a/src/resources/agents/auth/auth.ts +++ b/src/resources/agents/auth/auth.ts @@ -12,6 +12,7 @@ import { } from './invocations'; import { APIPromise } from '../../../core/api-promise'; import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../../../core/pagination'; +import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; @@ -66,6 +67,42 @@ export class Auth extends APIResource { ): PagePromise { return this._client.getAPIList('/agents/auth', OffsetPagination, { query, ...options }); } + + /** + * Deletes an auth agent and terminates its workflow. This will: + * + * - Soft delete the auth agent record + * - Gracefully terminate the agent's Temporal workflow + * - Cancel any in-progress invocations + * + * @example + * ```ts + * await client.agents.auth.delete('id'); + * ``` + */ + delete(id: string, options?: RequestOptions): APIPromise { + return this._client.delete(path`/agents/auth/${id}`, { + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } + + /** + * Triggers automatic re-authentication for an auth agent using stored credentials. + * Requires the auth agent to have a linked credential, stored selectors, and + * login_url. Returns immediately with status indicating whether re-auth was + * started. + * + * @example + * ```ts + * const reauthResponse = await client.agents.auth.reauth( + * 'id', + * ); + * ``` + */ + reauth(id: string, options?: RequestOptions): APIPromise { + return this._client.post(path`/agents/auth/${id}/reauth`, options); + } } export type AuthAgentsOffsetPagination = OffsetPagination; @@ -196,6 +233,27 @@ export interface AuthAgent { */ status: 'AUTHENTICATED' | 'NEEDS_AUTH'; + /** + * Whether automatic re-authentication is possible (has credential_id, selectors, + * and login_url) + */ + can_reauth?: boolean; + + /** + * ID of the linked credential for automatic re-authentication + */ + credential_id?: string; + + /** + * Name of the linked credential for automatic re-authentication + */ + credential_name?: string; + + /** + * Whether this auth agent has stored selectors for deterministic re-authentication + */ + has_selectors?: boolean; + /** * When the last authentication check was performed */ @@ -216,6 +274,13 @@ export interface AuthAgentCreateRequest { */ target_domain: string; + /** + * Optional name of an existing credential to use for this auth agent. If provided, + * the credential will be linked to the agent and its values will be used to + * auto-fill the login form on invocation. + */ + credential_name?: string; + /** * Optional login page URL. If provided, will be stored on the agent and used to * skip discovery in future invocations. @@ -248,31 +313,62 @@ export interface AuthAgentInvocationCreateRequest { * ID of the auth agent to create an invocation for */ auth_agent_id: string; + + /** + * If provided, saves the submitted credentials under this name upon successful + * login. The credential will be linked to the auth agent for automatic + * re-authentication. + */ + save_credential_as?: string; } /** - * Response from creating an auth agent invocation + * Response when the agent is already authenticated. */ -export interface AuthAgentInvocationCreateResponse { - /** - * When the handoff code expires - */ - expires_at: string; +export type AuthAgentInvocationCreateResponse = + | AuthAgentInvocationCreateResponse.AuthAgentAlreadyAuthenticated + | AuthAgentInvocationCreateResponse.AuthAgentInvocationCreated; +export namespace AuthAgentInvocationCreateResponse { /** - * One-time code for handoff + * Response when the agent is already authenticated. */ - handoff_code: string; + export interface AuthAgentAlreadyAuthenticated { + /** + * Indicates the agent is already authenticated and no invocation was created. + */ + status: 'already_authenticated'; + } /** - * URL to redirect user to + * Response when a new invocation was created. */ - hosted_url: string; + export interface AuthAgentInvocationCreated { + /** + * When the handoff code expires. + */ + expires_at: string; - /** - * Unique identifier for the invocation - */ - invocation_id: string; + /** + * One-time code for handoff. + */ + handoff_code: string; + + /** + * URL to redirect user to. + */ + hosted_url: string; + + /** + * Unique identifier for the invocation. + */ + invocation_id: string; + + /** + * Indicates an invocation was created. + */ + status: 'invocation_created'; + } } /** @@ -310,6 +406,26 @@ export interface DiscoveredField { required?: boolean; } +/** + * Response from triggering re-authentication + */ +export interface ReauthResponse { + /** + * Result of the re-authentication attempt + */ + status: 'reauth_started' | 'already_authenticated' | 'cannot_reauth'; + + /** + * ID of the re-auth invocation if one was created + */ + invocation_id?: string; + + /** + * Human-readable description of the result + */ + message?: string; +} + export interface AuthCreateParams { /** * Name of the profile to use for this auth agent @@ -321,6 +437,13 @@ export interface AuthCreateParams { */ target_domain: string; + /** + * Optional name of an existing credential to use for this auth agent. If provided, + * the credential will be linked to the agent and its values will be used to + * auto-fill the login form on invocation. + */ + credential_name?: string; + /** * Optional login page URL. If provided, will be stored on the agent and used to * skip discovery in future invocations. @@ -369,6 +492,7 @@ export declare namespace Auth { type AuthAgentInvocationCreateRequest as AuthAgentInvocationCreateRequest, type AuthAgentInvocationCreateResponse as AuthAgentInvocationCreateResponse, type DiscoveredField as DiscoveredField, + type ReauthResponse as ReauthResponse, type AuthAgentsOffsetPagination as AuthAgentsOffsetPagination, type AuthCreateParams as AuthCreateParams, type AuthListParams as AuthListParams, diff --git a/src/resources/agents/auth/index.ts b/src/resources/agents/auth/index.ts index e0a4170..bf85b04 100644 --- a/src/resources/agents/auth/index.ts +++ b/src/resources/agents/auth/index.ts @@ -10,6 +10,7 @@ export { type AuthAgentInvocationCreateRequest, type AuthAgentInvocationCreateResponse, type DiscoveredField, + type ReauthResponse, type AuthCreateParams, type AuthListParams, type AuthAgentsOffsetPagination, diff --git a/src/resources/agents/auth/invocations.ts b/src/resources/agents/auth/invocations.ts index 47dc460..84e9cf7 100644 --- a/src/resources/agents/auth/invocations.ts +++ b/src/resources/agents/auth/invocations.ts @@ -132,6 +132,13 @@ export interface InvocationCreateParams { * ID of the auth agent to create an invocation for */ auth_agent_id: string; + + /** + * If provided, saves the submitted credentials under this name upon successful + * login. The credential will be linked to the auth agent for automatic + * re-authentication. + */ + save_credential_as?: string; } export interface InvocationDiscoverParams { diff --git a/src/resources/agents/index.ts b/src/resources/agents/index.ts index 4d4ea82..fbd9005 100644 --- a/src/resources/agents/index.ts +++ b/src/resources/agents/index.ts @@ -11,6 +11,7 @@ export { type AuthAgentInvocationCreateRequest, type AuthAgentInvocationCreateResponse, type DiscoveredField, + type ReauthResponse, type AuthCreateParams, type AuthListParams, type AuthAgentsOffsetPagination, diff --git a/src/resources/browser-pools.ts b/src/resources/browser-pools.ts index 6aa09c2..9e67f7c 100644 --- a/src/resources/browser-pools.ts +++ b/src/resources/browser-pools.ts @@ -162,7 +162,7 @@ export interface BrowserPool { /** * Configuration used to create all browsers in this pool */ - browser_pool_config: BrowserPoolRequest; + browser_pool_config: BrowserPool.BrowserPoolConfig; /** * Timestamp when the browser pool was created @@ -175,118 +175,79 @@ export interface BrowserPool { name?: string; } -/** - * Request body for acquiring a browser from the pool. - */ -export interface BrowserPoolAcquireRequest { - /** - * Maximum number of seconds to wait for a browser to be available. Defaults to the - * calculated time it would take to fill the pool at the currently configured fill - * rate. - */ - acquire_timeout_seconds?: number; -} - -/** - * Request body for releasing a browser back to the pool. - */ -export interface BrowserPoolReleaseRequest { - /** - * Browser session ID to release back to the pool - */ - session_id: string; - - /** - * Whether to reuse the browser instance or destroy it and create a new one. - * Defaults to true. - */ - reuse?: boolean; -} - -/** - * Parameters for creating a browser pool. All browsers in the pool will be created - * with the same configuration. - */ -export interface BrowserPoolRequest { - /** - * Number of browsers to create in the pool - */ - size: number; - - /** - * List of browser extensions to load into the session. Provide each by id or name. - */ - extensions?: Array; - - /** - * Percentage of the pool to fill per minute. Defaults to 10%. - */ - fill_rate_per_minute?: number; - - /** - * If true, launches the browser using a headless image. Defaults to false. - */ - headless?: boolean; - - /** - * If true, launches the browser in kiosk mode to hide address bar and tabs in live - * view. - */ - kiosk_mode?: boolean; - - /** - * Optional name for the browser pool. Must be unique within the organization. - */ - name?: string; - - /** - * Profile selection for the browser session. Provide either id or name. If - * specified, the matching profile will be loaded into the browser session. - * Profiles must be created beforehand. - */ - profile?: Shared.BrowserProfile; - +export namespace BrowserPool { /** - * Optional proxy to associate to the browser session. Must reference a proxy - * belonging to the caller's org. - */ - proxy_id?: string; - - /** - * If true, launches the browser in stealth mode to reduce detection by anti-bot - * mechanisms. - */ - stealth?: boolean; - - /** - * Default idle timeout in seconds for browsers acquired from this pool before they - * are destroyed. Defaults to 600 seconds if not specified - */ - timeout_seconds?: number; - - /** - * 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, - * 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; -} - -/** - * Parameters for updating a browser pool. All browsers in the pool will be created - * with the same configuration. - */ -export interface BrowserPoolUpdateRequest extends BrowserPoolRequest { - /** - * Whether to discard all idle browsers and rebuild the pool immediately. Defaults - * to false. + * Configuration used to create all browsers in this pool */ - discard_all_idle?: boolean; + export interface BrowserPoolConfig { + /** + * Number of browsers to create in the pool + */ + size: number; + + /** + * List of browser extensions to load into the session. Provide each by id or name. + */ + extensions?: Array; + + /** + * Percentage of the pool to fill per minute. Defaults to 10%. + */ + fill_rate_per_minute?: number; + + /** + * If true, launches the browser using a headless image. Defaults to false. + */ + headless?: boolean; + + /** + * If true, launches the browser in kiosk mode to hide address bar and tabs in live + * view. + */ + kiosk_mode?: boolean; + + /** + * Optional name for the browser pool. Must be unique within the organization. + */ + name?: string; + + /** + * Profile selection for the browser session. Provide either id or name. If + * specified, the matching profile will be loaded into the browser session. + * Profiles must be created beforehand. + */ + profile?: Shared.BrowserProfile; + + /** + * Optional proxy to associate to the browser session. Must reference a proxy + * belonging to the caller's org. + */ + proxy_id?: string; + + /** + * If true, launches the browser in stealth mode to reduce detection by anti-bot + * mechanisms. + */ + stealth?: boolean; + + /** + * Default idle timeout in seconds for browsers acquired from this pool before they + * are destroyed. Defaults to 600 seconds if not specified + */ + timeout_seconds?: number; + + /** + * 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, + * 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 type BrowserPoolListResponse = Array; @@ -546,10 +507,6 @@ export interface BrowserPoolReleaseParams { export declare namespace BrowserPools { export { type BrowserPool as BrowserPool, - type BrowserPoolAcquireRequest as BrowserPoolAcquireRequest, - type BrowserPoolReleaseRequest as BrowserPoolReleaseRequest, - type BrowserPoolRequest as BrowserPoolRequest, - type BrowserPoolUpdateRequest as BrowserPoolUpdateRequest, type BrowserPoolListResponse as BrowserPoolListResponse, type BrowserPoolAcquireResponse as BrowserPoolAcquireResponse, type BrowserPoolCreateParams as BrowserPoolCreateParams, diff --git a/src/resources/credentials.ts b/src/resources/credentials.ts new file mode 100644 index 0000000..a90dea7 --- /dev/null +++ b/src/resources/credentials.ts @@ -0,0 +1,205 @@ +// 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 { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../core/pagination'; +import { buildHeaders } from '../internal/headers'; +import { RequestOptions } from '../internal/request-options'; +import { path } from '../internal/utils/path'; + +export class Credentials extends APIResource { + /** + * Create a new credential for storing login information. Values are encrypted at + * rest. + * + * @example + * ```ts + * const credential = await client.credentials.create({ + * domain: 'netflix.com', + * name: 'my-netflix-login', + * values: { + * username: 'user@example.com', + * password: 'mysecretpassword', + * }, + * }); + * ``` + */ + create(body: CredentialCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/credentials', { body, ...options }); + } + + /** + * Retrieve a credential by its ID. Credential values are not returned. + * + * @example + * ```ts + * const credential = await client.credentials.retrieve('id'); + * ``` + */ + retrieve(id: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/credentials/${id}`, options); + } + + /** + * Update a credential's name or values. Values are encrypted at rest. + * + * @example + * ```ts + * const credential = await client.credentials.update('id'); + * ``` + */ + update(id: string, body: CredentialUpdateParams, options?: RequestOptions): APIPromise { + return this._client.patch(path`/credentials/${id}`, { body, ...options }); + } + + /** + * List credentials owned by the caller's organization. Credential values are not + * returned. + * + * @example + * ```ts + * // Automatically fetches more pages as needed. + * for await (const credential of client.credentials.list()) { + * // ... + * } + * ``` + */ + list( + query: CredentialListParams | null | undefined = {}, + options?: RequestOptions, + ): PagePromise { + return this._client.getAPIList('/credentials', OffsetPagination, { query, ...options }); + } + + /** + * Delete a credential by its ID. + * + * @example + * ```ts + * await client.credentials.delete('id'); + * ``` + */ + delete(id: string, options?: RequestOptions): APIPromise { + return this._client.delete(path`/credentials/${id}`, { + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } +} + +export type CredentialsOffsetPagination = OffsetPagination; + +/** + * Request to create a new credential + */ +export interface CreateCredentialRequest { + /** + * Target domain this credential is for + */ + domain: string; + + /** + * Unique name for the credential within the organization + */ + name: string; + + /** + * Field name to value mapping (e.g., username, password) + */ + values: { [key: string]: string }; +} + +/** + * A stored credential for automatic re-authentication + */ +export interface Credential { + /** + * Unique identifier for the credential + */ + id: string; + + /** + * When the credential was created + */ + created_at: string; + + /** + * Target domain this credential is for + */ + domain: string; + + /** + * Unique name for the credential within the organization + */ + name: string; + + /** + * When the credential was last updated + */ + updated_at: string; +} + +/** + * Request to update an existing credential + */ +export interface UpdateCredentialRequest { + /** + * New name for the credential + */ + name?: string; + + /** + * Field name to value mapping (e.g., username, password). Replaces all existing + * values. + */ + values?: { [key: string]: string }; +} + +export interface CredentialCreateParams { + /** + * Target domain this credential is for + */ + domain: string; + + /** + * Unique name for the credential within the organization + */ + name: string; + + /** + * Field name to value mapping (e.g., username, password) + */ + values: { [key: string]: string }; +} + +export interface CredentialUpdateParams { + /** + * New name for the credential + */ + name?: string; + + /** + * Field name to value mapping (e.g., username, password). Replaces all existing + * values. + */ + values?: { [key: string]: string }; +} + +export interface CredentialListParams extends OffsetPaginationParams { + /** + * Filter by domain + */ + domain?: string; +} + +export declare namespace Credentials { + export { + type CreateCredentialRequest as CreateCredentialRequest, + type Credential as Credential, + type UpdateCredentialRequest as UpdateCredentialRequest, + type CredentialsOffsetPagination as CredentialsOffsetPagination, + type CredentialCreateParams as CredentialCreateParams, + type CredentialUpdateParams as CredentialUpdateParams, + type CredentialListParams as CredentialListParams, + }; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index bab015b..c7a0aa1 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -11,10 +11,6 @@ export { export { BrowserPools, type BrowserPool, - type BrowserPoolAcquireRequest, - type BrowserPoolReleaseRequest, - type BrowserPoolRequest, - type BrowserPoolUpdateRequest, type BrowserPoolListResponse, type BrowserPoolAcquireResponse, type BrowserPoolCreateParams, @@ -36,6 +32,16 @@ export { type BrowserLoadExtensionsParams, type BrowserListResponsesOffsetPagination, } from './browsers/browsers'; +export { + Credentials, + type CreateCredentialRequest, + type Credential, + type UpdateCredentialRequest, + type CredentialCreateParams, + type CredentialUpdateParams, + type CredentialListParams, + type CredentialsOffsetPagination, +} from './credentials'; export { Deployments, type DeploymentStateEvent, diff --git a/src/version.ts b/src/version.ts index d77fad4..7434729 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.23.0'; // x-release-please-version +export const VERSION = '0.24.0'; // x-release-please-version diff --git a/tests/api-resources/agents/auth/auth.test.ts b/tests/api-resources/agents/auth/auth.test.ts index a51a775..1882e82 100644 --- a/tests/api-resources/agents/auth/auth.test.ts +++ b/tests/api-resources/agents/auth/auth.test.ts @@ -28,6 +28,7 @@ describe('resource auth', () => { const response = await client.agents.auth.create({ profile_name: 'user-123', target_domain: 'netflix.com', + credential_name: 'my-netflix-login', login_url: 'https://netflix.com/login', proxy: { proxy_id: 'proxy_id' }, }); @@ -67,4 +68,28 @@ describe('resource auth', () => { ), ).rejects.toThrow(Kernel.NotFoundError); }); + + // Prism tests are disabled + test.skip('delete', async () => { + const responsePromise = client.agents.auth.delete('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); + }); + + // Prism tests are disabled + test.skip('reauth', async () => { + const responsePromise = client.agents.auth.reauth('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); + }); }); diff --git a/tests/api-resources/agents/auth/invocations.test.ts b/tests/api-resources/agents/auth/invocations.test.ts index 8bc769c..fc178bb 100644 --- a/tests/api-resources/agents/auth/invocations.test.ts +++ b/tests/api-resources/agents/auth/invocations.test.ts @@ -22,7 +22,10 @@ describe('resource invocations', () => { // Prism tests are disabled test.skip('create: required and optional params', async () => { - const response = await client.agents.auth.invocations.create({ auth_agent_id: 'abc123xyz' }); + const response = await client.agents.auth.invocations.create({ + auth_agent_id: 'abc123xyz', + save_credential_as: 'my-netflix-login', + }); }); // Prism tests are disabled diff --git a/tests/api-resources/credentials.test.ts b/tests/api-resources/credentials.test.ts new file mode 100644 index 0000000..eaf6c33 --- /dev/null +++ b/tests/api-resources/credentials.test.ts @@ -0,0 +1,94 @@ +// 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 credentials', () => { + // Prism tests are disabled + test.skip('create: only required params', async () => { + const responsePromise = client.credentials.create({ + domain: 'netflix.com', + name: 'my-netflix-login', + values: { username: 'user@example.com', password: 'mysecretpassword' }, + }); + 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('create: required and optional params', async () => { + const response = await client.credentials.create({ + domain: 'netflix.com', + name: 'my-netflix-login', + values: { username: 'user@example.com', password: 'mysecretpassword' }, + }); + }); + + // Prism tests are disabled + test.skip('retrieve', async () => { + const responsePromise = client.credentials.retrieve('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); + }); + + // Prism tests are disabled + test.skip('update', async () => { + const responsePromise = client.credentials.update('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); + }); + + // Prism tests are disabled + test.skip('list', async () => { + const responsePromise = client.credentials.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.credentials.list( + { domain: 'domain', limit: 100, offset: 0 }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Kernel.NotFoundError); + }); + + // Prism tests are disabled + test.skip('delete', async () => { + const responsePromise = client.credentials.delete('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); + }); +});