diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 788b0fa..97bce11 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.22.0" + ".": "0.23.0" } diff --git a/.stats.yml b/.stats.yml index 7792bb0..135345a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 74 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-003e9afa15f0765009d2c7d34e8eb62268d818e628e3c84361b21138e30cc423.yml -openapi_spec_hash: c1b8309f60385bf2b02d245363ca47c1 -config_hash: a4124701ae0a474e580d7416adbcfb00 +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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f50be4..b5a1736 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## 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) + +### Features + +* [wip] Browser pools polish pass ([7c8a464](https://github.com/onkernel/kernel-node-sdk/commit/7c8a4641cb87a76a3248e2d1df713df929957262)) +* enhance agent authentication API with new endpoints and request… ([0ef28fd](https://github.com/onkernel/kernel-node-sdk/commit/0ef28fddbf7c7d03b24a56d4157d1eb3966c0a7f)) +* Enhance agent authentication with optional login page URL and auth ch… ([7ea4b07](https://github.com/onkernel/kernel-node-sdk/commit/7ea4b076cc5255f76945ae370a8f686349a28a30)) +* Enhance AuthAgent model with last_auth_check_at field ([29d43d1](https://github.com/onkernel/kernel-node-sdk/commit/29d43d10a026f25cf1a1de2579c06f90ca246054)) + + +### Bug Fixes + +* **mcp:** correct code tool API endpoint ([4f60927](https://github.com/onkernel/kernel-node-sdk/commit/4f6092702503c6dafb0d310c8123bf8dccce60e1)) +* **mcp:** return correct lines on typescript errors ([8ccaae1](https://github.com/onkernel/kernel-node-sdk/commit/8ccaae1b63ee9ca371c4f32033486e6e9ba1c351)) + + +### Chores + +* **internal:** codegen related update ([3ffeaa7](https://github.com/onkernel/kernel-node-sdk/commit/3ffeaa72b3cb5c7cd5baea0ddeaf5fad60979235)) +* **internal:** codegen related update ([c9461e7](https://github.com/onkernel/kernel-node-sdk/commit/c9461e7e02592559c3592f8916bf1351d32cce9a)) + + +### Refactors + +* **browser:** remove persistence option UI ([f3fdc89](https://github.com/onkernel/kernel-node-sdk/commit/f3fdc89088feeb32983da39700e47e922f767126)) + ## 0.22.0 (2025-12-05) Full Changelog: [v0.21.0...v0.22.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.21.0...v0.22.0) diff --git a/README.md b/README.md index 0018d91..3007e65 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ const client = new Kernel({ environment: 'development', // defaults to 'production' }); -const browser = await client.browsers.create({ persistence: { id: 'browser-for-user-1234' } }); +const browser = await client.browsers.create({ stealth: true }); console.log(browser.session_id); ``` @@ -45,7 +45,7 @@ const client = new Kernel({ environment: 'development', // defaults to 'production' }); -const params: Kernel.BrowserCreateParams = { persistence: { id: 'browser-for-user-1234' } }; +const params: Kernel.BrowserCreateParams = { stealth: true }; const browser: Kernel.BrowserCreateResponse = await client.browsers.create(params); ``` @@ -88,17 +88,15 @@ a subclass of `APIError` will be thrown: ```ts -const browser = await client.browsers - .create({ persistence: { id: 'browser-for-user-1234' } }) - .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({ stealth: true }).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; + } +}); ``` Error codes are as follows: @@ -130,7 +128,7 @@ const client = new Kernel({ }); // Or, configure per-request: -await client.browsers.create({ persistence: { id: 'browser-for-user-1234' } }, { +await client.browsers.create({ stealth: true }, { maxRetries: 5, }); ``` @@ -147,7 +145,7 @@ const client = new Kernel({ }); // Override per-request: -await client.browsers.create({ persistence: { id: 'browser-for-user-1234' } }, { +await client.browsers.create({ stealth: true }, { timeout: 5 * 1000, }); ``` @@ -201,13 +199,11 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse ```ts const client = new Kernel(); -const response = await client.browsers.create({ persistence: { id: 'browser-for-user-1234' } }).asResponse(); +const response = await client.browsers.create({ stealth: true }).asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object -const { data: browser, response: raw } = await client.browsers - .create({ persistence: { id: 'browser-for-user-1234' } }) - .withResponse(); +const { data: browser, response: raw } = await client.browsers.create({ stealth: true }).withResponse(); console.log(raw.headers.get('X-My-Header')); console.log(browser.session_id); ``` diff --git a/api.md b/api.md index c3c1b6e..2050a8d 100644 --- a/api.md +++ b/api.md @@ -246,3 +246,38 @@ Methods: - client.browserPools.acquire(idOrName, { ...params }) -> BrowserPoolAcquireResponse - client.browserPools.flush(idOrName) -> void - client.browserPools.release(idOrName, { ...params }) -> void + +# Agents + +## Auth + +Types: + +- AgentAuthDiscoverResponse +- AgentAuthInvocationResponse +- AgentAuthSubmitResponse +- AuthAgent +- AuthAgentCreateRequest +- AuthAgentInvocationCreateRequest +- AuthAgentInvocationCreateResponse +- DiscoveredField + +Methods: + +- client.agents.auth.create({ ...params }) -> AuthAgent +- client.agents.auth.retrieve(id) -> AuthAgent +- client.agents.auth.list({ ...params }) -> AuthAgentsOffsetPagination + +### Invocations + +Types: + +- InvocationExchangeResponse + +Methods: + +- client.agents.auth.invocations.create({ ...params }) -> AuthAgentInvocationCreateResponse +- client.agents.auth.invocations.retrieve(invocationID) -> AgentAuthInvocationResponse +- client.agents.auth.invocations.discover(invocationID, { ...params }) -> AgentAuthDiscoverResponse +- client.agents.auth.invocations.exchange(invocationID, { ...params }) -> InvocationExchangeResponse +- client.agents.auth.invocations.submit(invocationID, { ...params }) -> AgentAuthSubmitResponse diff --git a/package.json b/package.json index 76cf5a4..5383c20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/sdk", - "version": "0.22.0", + "version": "0.23.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 a0dffa0..dd80bb3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -76,6 +76,7 @@ import { ProxyListResponse, ProxyRetrieveResponse, } from './resources/proxies'; +import { Agents } from './resources/agents/agents'; import { BrowserCreateParams, BrowserCreateResponse, @@ -859,6 +860,7 @@ export class Kernel { proxies: API.Proxies = new API.Proxies(this); extensions: API.Extensions = new API.Extensions(this); browserPools: API.BrowserPools = new API.BrowserPools(this); + agents: API.Agents = new API.Agents(this); } Kernel.Deployments = Deployments; @@ -869,6 +871,7 @@ Kernel.Profiles = Profiles; Kernel.Proxies = Proxies; Kernel.Extensions = Extensions; Kernel.BrowserPools = BrowserPools; +Kernel.Agents = Agents; export declare namespace Kernel { export type RequestOptions = Opts.RequestOptions; @@ -966,6 +969,8 @@ export declare namespace Kernel { type BrowserPoolReleaseParams as BrowserPoolReleaseParams, }; + export { Agents as Agents }; + export type AppAction = API.AppAction; export type BrowserExtension = API.BrowserExtension; export type BrowserProfile = API.BrowserProfile; diff --git a/src/resources/agents.ts b/src/resources/agents.ts new file mode 100644 index 0000000..0c43db0 --- /dev/null +++ b/src/resources/agents.ts @@ -0,0 +1,3 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export * from './agents/index'; diff --git a/src/resources/agents/agents.ts b/src/resources/agents/agents.ts new file mode 100644 index 0000000..cf10a25 --- /dev/null +++ b/src/resources/agents/agents.ts @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../core/resource'; +import * as AuthAPI from './auth/auth'; +import { + AgentAuthDiscoverResponse, + AgentAuthInvocationResponse, + AgentAuthSubmitResponse, + Auth, + AuthAgent, + AuthAgentCreateRequest, + AuthAgentInvocationCreateRequest, + AuthAgentInvocationCreateResponse, + AuthAgentsOffsetPagination, + AuthCreateParams, + AuthListParams, + DiscoveredField, +} from './auth/auth'; + +export class Agents extends APIResource { + auth: AuthAPI.Auth = new AuthAPI.Auth(this._client); +} + +Agents.Auth = Auth; + +export declare namespace Agents { + export { + Auth as Auth, + type AgentAuthDiscoverResponse as AgentAuthDiscoverResponse, + type AgentAuthInvocationResponse as AgentAuthInvocationResponse, + type AgentAuthSubmitResponse as AgentAuthSubmitResponse, + type AuthAgent as AuthAgent, + type AuthAgentCreateRequest as AuthAgentCreateRequest, + type AuthAgentInvocationCreateRequest as AuthAgentInvocationCreateRequest, + type AuthAgentInvocationCreateResponse as AuthAgentInvocationCreateResponse, + type DiscoveredField as DiscoveredField, + type AuthAgentsOffsetPagination as AuthAgentsOffsetPagination, + type AuthCreateParams as AuthCreateParams, + type AuthListParams as AuthListParams, + }; +} diff --git a/src/resources/agents/auth.ts b/src/resources/agents/auth.ts new file mode 100644 index 0000000..b64faa1 --- /dev/null +++ b/src/resources/agents/auth.ts @@ -0,0 +1,3 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export * from './auth/index'; diff --git a/src/resources/agents/auth/auth.ts b/src/resources/agents/auth/auth.ts new file mode 100644 index 0000000..ca02544 --- /dev/null +++ b/src/resources/agents/auth/auth.ts @@ -0,0 +1,385 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../core/resource'; +import * as InvocationsAPI from './invocations'; +import { + InvocationCreateParams, + InvocationDiscoverParams, + InvocationExchangeParams, + InvocationExchangeResponse, + InvocationSubmitParams, + Invocations, +} from './invocations'; +import { APIPromise } from '../../../core/api-promise'; +import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../../../core/pagination'; +import { RequestOptions } from '../../../internal/request-options'; +import { path } from '../../../internal/utils/path'; + +export class Auth extends APIResource { + invocations: InvocationsAPI.Invocations = new InvocationsAPI.Invocations(this._client); + + /** + * Creates a new auth agent for the specified domain and profile combination, or + * returns an existing one if it already exists. This is idempotent - calling with + * the same domain and profile will return the same agent. Does NOT start an + * invocation - use POST /agents/auth/invocations to start an auth flow. + * + * @example + * ```ts + * const authAgent = await client.agents.auth.create({ + * profile_name: 'user-123', + * target_domain: 'netflix.com', + * }); + * ``` + */ + create(body: AuthCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/agents/auth', { body, ...options }); + } + + /** + * Retrieve an auth agent by its ID. Returns the current authentication status of + * the managed profile. + * + * @example + * ```ts + * const authAgent = await client.agents.auth.retrieve('id'); + * ``` + */ + retrieve(id: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/agents/auth/${id}`, options); + } + + /** + * List auth agents with optional filters for profile_name and target_domain. + * + * @example + * ```ts + * // Automatically fetches more pages as needed. + * for await (const authAgent of client.agents.auth.list()) { + * // ... + * } + * ``` + */ + list( + query: AuthListParams | null | undefined = {}, + options?: RequestOptions, + ): PagePromise { + return this._client.getAPIList('/agents/auth', OffsetPagination, { query, ...options }); + } +} + +export type AuthAgentsOffsetPagination = OffsetPagination; + +/** + * Response from discover endpoint matching AuthBlueprint schema + */ +export interface AgentAuthDiscoverResponse { + /** + * Whether discovery succeeded + */ + success: boolean; + + /** + * Error message if discovery failed + */ + error_message?: string; + + /** + * Discovered form fields (present when success is true) + */ + fields?: Array; + + /** + * Whether user is already logged in + */ + logged_in?: boolean; + + /** + * URL of the discovered login page + */ + login_url?: string; + + /** + * Title of the login page + */ + page_title?: string; +} + +/** + * Response from get invocation endpoint + */ +export interface AgentAuthInvocationResponse { + /** + * App name (org name at time of invocation creation) + */ + app_name: string; + + /** + * When the handoff code expires + */ + expires_at: string; + + /** + * Invocation status + */ + status: 'IN_PROGRESS' | 'SUCCESS' | 'EXPIRED' | 'CANCELED'; + + /** + * Target domain for authentication + */ + target_domain: string; +} + +/** + * Response from submit endpoint matching SubmitResult schema + */ +export interface AgentAuthSubmitResponse { + /** + * Whether submission succeeded + */ + success: boolean; + + /** + * Additional fields needed (e.g., OTP) - present when needs_additional_auth is + * true + */ + additional_fields?: Array; + + /** + * App name (only present when logged_in is true) + */ + app_name?: string; + + /** + * Error message if submission failed + */ + error_message?: string; + + /** + * Whether user is now logged in + */ + logged_in?: boolean; + + /** + * Whether additional authentication fields are needed + */ + needs_additional_auth?: boolean; + + /** + * Target domain (only present when logged_in is true) + */ + target_domain?: string; +} + +/** + * An auth agent that manages authentication for a specific domain and profile + * combination + */ +export interface AuthAgent { + /** + * Unique identifier for the auth agent + */ + id: string; + + /** + * Target domain for authentication + */ + domain: string; + + /** + * Name of the profile associated with this auth agent + */ + profile_name: string; + + /** + * Current authentication status of the managed profile + */ + status: 'AUTHENTICATED' | 'NEEDS_AUTH'; + + /** + * When the last authentication check was performed + */ + last_auth_check_at?: string; +} + +/** + * Request to create or find an auth agent + */ +export interface AuthAgentCreateRequest { + /** + * Name of the profile to use for this auth agent + */ + profile_name: string; + + /** + * Target domain for authentication + */ + target_domain: string; + + /** + * Optional login page URL. If provided, will be stored on the agent and used to + * skip discovery in future invocations. + */ + login_url?: string; + + /** + * Optional proxy configuration + */ + proxy?: AuthAgentCreateRequest.Proxy; +} + +export namespace AuthAgentCreateRequest { + /** + * Optional proxy configuration + */ + export interface Proxy { + /** + * ID of the proxy to use + */ + proxy_id?: string; + } +} + +/** + * Request to create an invocation for an existing auth agent + */ +export interface AuthAgentInvocationCreateRequest { + /** + * ID of the auth agent to create an invocation for + */ + auth_agent_id: string; +} + +/** + * Response from creating an auth agent invocation + */ +export interface AuthAgentInvocationCreateResponse { + /** + * When the handoff code expires + */ + expires_at: 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; +} + +/** + * A discovered form field + */ +export interface DiscoveredField { + /** + * Field label + */ + label: string; + + /** + * Field name + */ + name: string; + + /** + * CSS selector for the field + */ + selector: string; + + /** + * Field type + */ + type: 'text' | 'email' | 'password' | 'tel' | 'number' | 'url' | 'code'; + + /** + * Field placeholder + */ + placeholder?: string; + + /** + * Whether field is required + */ + required?: boolean; +} + +export interface AuthCreateParams { + /** + * Name of the profile to use for this auth agent + */ + profile_name: string; + + /** + * Target domain for authentication + */ + target_domain: string; + + /** + * Optional login page URL. If provided, will be stored on the agent and used to + * skip discovery in future invocations. + */ + login_url?: string; + + /** + * Optional proxy configuration + */ + proxy?: AuthCreateParams.Proxy; +} + +export namespace AuthCreateParams { + /** + * Optional proxy configuration + */ + export interface Proxy { + /** + * ID of the proxy to use + */ + proxy_id?: string; + } +} + +export interface AuthListParams extends OffsetPaginationParams { + /** + * Filter by profile name + */ + profile_name?: string; + + /** + * Filter by target domain + */ + target_domain?: string; +} + +Auth.Invocations = Invocations; + +export declare namespace Auth { + export { + type AgentAuthDiscoverResponse as AgentAuthDiscoverResponse, + type AgentAuthInvocationResponse as AgentAuthInvocationResponse, + type AgentAuthSubmitResponse as AgentAuthSubmitResponse, + type AuthAgent as AuthAgent, + type AuthAgentCreateRequest as AuthAgentCreateRequest, + type AuthAgentInvocationCreateRequest as AuthAgentInvocationCreateRequest, + type AuthAgentInvocationCreateResponse as AuthAgentInvocationCreateResponse, + type DiscoveredField as DiscoveredField, + type AuthAgentsOffsetPagination as AuthAgentsOffsetPagination, + type AuthCreateParams as AuthCreateParams, + type AuthListParams as AuthListParams, + }; + + export { + Invocations as Invocations, + type InvocationExchangeResponse as InvocationExchangeResponse, + type InvocationCreateParams as InvocationCreateParams, + type InvocationDiscoverParams as InvocationDiscoverParams, + type InvocationExchangeParams as InvocationExchangeParams, + type InvocationSubmitParams as InvocationSubmitParams, + }; +} diff --git a/src/resources/agents/auth/index.ts b/src/resources/agents/auth/index.ts new file mode 100644 index 0000000..e0a4170 --- /dev/null +++ b/src/resources/agents/auth/index.ts @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + Auth, + type AgentAuthDiscoverResponse, + type AgentAuthInvocationResponse, + type AgentAuthSubmitResponse, + type AuthAgent, + type AuthAgentCreateRequest, + type AuthAgentInvocationCreateRequest, + type AuthAgentInvocationCreateResponse, + type DiscoveredField, + type AuthCreateParams, + type AuthListParams, + type AuthAgentsOffsetPagination, +} from './auth'; +export { + Invocations, + type InvocationExchangeResponse, + type InvocationCreateParams, + type InvocationDiscoverParams, + type InvocationExchangeParams, + type InvocationSubmitParams, +} from './invocations'; diff --git a/src/resources/agents/auth/invocations.ts b/src/resources/agents/auth/invocations.ts new file mode 100644 index 0000000..47dc460 --- /dev/null +++ b/src/resources/agents/auth/invocations.ts @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../core/resource'; +import * as AuthAPI from './auth'; +import { APIPromise } from '../../../core/api-promise'; +import { RequestOptions } from '../../../internal/request-options'; +import { path } from '../../../internal/utils/path'; + +export class Invocations extends APIResource { + /** + * Creates a new authentication invocation for the specified auth agent. This + * starts the auth flow and returns a hosted URL for the user to complete + * authentication. + * + * @example + * ```ts + * const authAgentInvocationCreateResponse = + * await client.agents.auth.invocations.create({ + * auth_agent_id: 'abc123xyz', + * }); + * ``` + */ + create( + body: InvocationCreateParams, + options?: RequestOptions, + ): APIPromise { + return this._client.post('/agents/auth/invocations', { body, ...options }); + } + + /** + * Returns invocation details including app_name and target_domain. Uses the JWT + * returned by the exchange endpoint, or standard API key or JWT authentication. + * + * @example + * ```ts + * const agentAuthInvocationResponse = + * await client.agents.auth.invocations.retrieve( + * 'invocation_id', + * ); + * ``` + */ + retrieve(invocationID: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/agents/auth/invocations/${invocationID}`, options); + } + + /** + * Inspects the target site to detect logged-in state or discover required fields. + * Returns 200 with success: true when fields are found, or 4xx/5xx for failures. + * Requires the JWT returned by the exchange endpoint. + * + * @example + * ```ts + * const agentAuthDiscoverResponse = + * await client.agents.auth.invocations.discover( + * 'invocation_id', + * ); + * ``` + */ + discover( + invocationID: string, + body: InvocationDiscoverParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + return this._client.post(path`/agents/auth/invocations/${invocationID}/discover`, { body, ...options }); + } + + /** + * Validates the handoff code and returns a JWT token for subsequent requests. No + * authentication required (the handoff code serves as the credential). + * + * @example + * ```ts + * const response = + * await client.agents.auth.invocations.exchange( + * 'invocation_id', + * { code: 'abc123xyz' }, + * ); + * ``` + */ + exchange( + invocationID: string, + body: InvocationExchangeParams, + options?: RequestOptions, + ): APIPromise { + return this._client.post(path`/agents/auth/invocations/${invocationID}/exchange`, { body, ...options }); + } + + /** + * Submits field values for the discovered login form and may return additional + * auth fields or success. Requires the JWT returned by the exchange endpoint. + * + * @example + * ```ts + * const agentAuthSubmitResponse = + * await client.agents.auth.invocations.submit( + * 'invocation_id', + * { + * field_values: { + * email: 'user@example.com', + * password: '********', + * }, + * }, + * ); + * ``` + */ + submit( + invocationID: string, + body: InvocationSubmitParams, + options?: RequestOptions, + ): APIPromise { + return this._client.post(path`/agents/auth/invocations/${invocationID}/submit`, { body, ...options }); + } +} + +/** + * Response from exchange endpoint + */ +export interface InvocationExchangeResponse { + /** + * Invocation ID + */ + invocation_id: string; + + /** + * JWT token with invocation_id claim (30 minute TTL) + */ + jwt: string; +} + +export interface InvocationCreateParams { + /** + * ID of the auth agent to create an invocation for + */ + auth_agent_id: string; +} + +export interface InvocationDiscoverParams { + /** + * Optional login page URL. If provided, will override the stored login URL for + * this discovery invocation and skip Phase 1 discovery. + */ + login_url?: string; +} + +export interface InvocationExchangeParams { + /** + * Handoff code from start endpoint + */ + code: string; +} + +export interface InvocationSubmitParams { + /** + * Values for the discovered login fields + */ + field_values: { [key: string]: string }; +} + +export declare namespace Invocations { + export { + type InvocationExchangeResponse as InvocationExchangeResponse, + type InvocationCreateParams as InvocationCreateParams, + type InvocationDiscoverParams as InvocationDiscoverParams, + type InvocationExchangeParams as InvocationExchangeParams, + type InvocationSubmitParams as InvocationSubmitParams, + }; +} diff --git a/src/resources/agents/index.ts b/src/resources/agents/index.ts new file mode 100644 index 0000000..4d4ea82 --- /dev/null +++ b/src/resources/agents/index.ts @@ -0,0 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { Agents } from './agents'; +export { + Auth, + type AgentAuthDiscoverResponse, + type AgentAuthInvocationResponse, + type AgentAuthSubmitResponse, + type AuthAgent, + type AuthAgentCreateRequest, + type AuthAgentInvocationCreateRequest, + type AuthAgentInvocationCreateResponse, + type DiscoveredField, + type AuthCreateParams, + type AuthListParams, + type AuthAgentsOffsetPagination, +} from './auth/index'; diff --git a/src/resources/browser-pools.ts b/src/resources/browser-pools.ts index be28ad0..6aa09c2 100644 --- a/src/resources/browser-pools.ts +++ b/src/resources/browser-pools.ts @@ -266,11 +266,11 @@ export interface BrowserPoolRequest { /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ @@ -284,7 +284,7 @@ export interface BrowserPoolRequest { export interface BrowserPoolUpdateRequest extends BrowserPoolRequest { /** * Whether to discard all idle browsers and rebuild the pool immediately. Defaults - * to true. + * to false. */ discard_all_idle?: boolean; } @@ -339,7 +339,8 @@ export interface BrowserPoolAcquireResponse { kiosk_mode?: boolean; /** - * Optional persistence configuration for the browser session. + * @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles + * instead. */ persistence?: BrowsersAPI.BrowserPersistence; @@ -355,11 +356,11 @@ export interface BrowserPoolAcquireResponse { /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ @@ -425,11 +426,11 @@ export interface BrowserPoolCreateParams { /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ @@ -444,7 +445,7 @@ export interface BrowserPoolUpdateParams { /** * Whether to discard all idle browsers and rebuild the pool immediately. Defaults - * to true. + * to false. */ discard_all_idle?: boolean; @@ -501,11 +502,11 @@ export interface BrowserPoolUpdateParams { /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ diff --git a/src/resources/browsers/browsers.ts b/src/resources/browsers/browsers.ts index d3f8b3d..b42c383 100644 --- a/src/resources/browsers/browsers.ts +++ b/src/resources/browsers/browsers.ts @@ -127,14 +127,10 @@ export class Browsers extends APIResource { } /** - * Delete a persistent browser session by its persistent_id. + * DEPRECATED: Use DELETE /browsers/{id} instead. Delete a persistent browser + * session by its persistent_id. * - * @example - * ```ts - * await client.browsers.delete({ - * persistent_id: 'persistent_id', - * }); - * ``` + * @deprecated */ delete(params: BrowserDeleteParams, options?: RequestOptions): APIPromise { const { persistent_id } = params; @@ -192,11 +188,12 @@ export class Browsers extends APIResource { export type BrowserListResponsesOffsetPagination = OffsetPagination; /** - * Optional persistence configuration for the browser session. + * @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles + * instead. */ export interface BrowserPersistence { /** - * Unique identifier for the persistent browser session. + * DEPRECATED: Unique identifier for the persistent browser session. */ id: string; } @@ -279,7 +276,8 @@ export interface BrowserCreateResponse { kiosk_mode?: boolean; /** - * Optional persistence configuration for the browser session. + * @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles + * instead. */ persistence?: BrowserPersistence; @@ -295,11 +293,11 @@ export interface BrowserCreateResponse { /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ @@ -354,7 +352,8 @@ export interface BrowserRetrieveResponse { kiosk_mode?: boolean; /** - * Optional persistence configuration for the browser session. + * @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles + * instead. */ persistence?: BrowserPersistence; @@ -370,11 +369,11 @@ export interface BrowserRetrieveResponse { /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ @@ -429,7 +428,8 @@ export interface BrowserListResponse { kiosk_mode?: boolean; /** - * Optional persistence configuration for the browser session. + * @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles + * instead. */ persistence?: BrowserPersistence; @@ -445,11 +445,11 @@ export interface BrowserListResponse { /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ @@ -480,7 +480,8 @@ export interface BrowserCreateParams { kiosk_mode?: boolean; /** - * Optional persistence configuration for the browser session. + * @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles + * instead. */ persistence?: BrowserPersistence; @@ -505,21 +506,20 @@ export interface BrowserCreateParams { /** * The number of seconds of inactivity before the browser session is terminated. - * Only applicable to non-persistent browsers. Activity includes CDP connections - * and live view connections. Defaults to 60 seconds. Minimum allowed is 10 - * seconds. Maximum allowed is 259200 (72 hours). We check for inactivity every 5 - * seconds, so the actual timeout behavior you will see is +/- 5 seconds around the - * specified value. + * Activity includes CDP connections and live view connections. Defaults to 60 + * seconds. Minimum allowed is 10 seconds. Maximum allowed is 259200 (72 hours). We + * check for inactivity every 5 seconds, so the actual timeout behavior you will + * see is +/- 5 seconds around the specified value. */ timeout_seconds?: number; /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ diff --git a/src/resources/index.ts b/src/resources/index.ts index 420e5e2..bab015b 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export * from './shared'; +export { Agents } from './agents/agents'; export { Apps, type AppListResponse, diff --git a/src/resources/shared.ts b/src/resources/shared.ts index 13cbc0b..3a3112b 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -53,11 +53,11 @@ export interface BrowserProfile { /** * Initial browser window size in pixels with optional refresh rate. If omitted, - * image defaults apply (commonly 1024x768@60). 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 + * 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 */ diff --git a/src/version.ts b/src/version.ts index db66d33..d77fad4 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.22.0'; // x-release-please-version +export const VERSION = '0.23.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 new file mode 100644 index 0000000..a51a775 --- /dev/null +++ b/tests/api-resources/agents/auth/auth.test.ts @@ -0,0 +1,70 @@ +// 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 auth', () => { + // Prism tests are disabled + test.skip('create: only required params', async () => { + const responsePromise = client.agents.auth.create({ + profile_name: 'user-123', + target_domain: 'netflix.com', + }); + 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.agents.auth.create({ + profile_name: 'user-123', + target_domain: 'netflix.com', + login_url: 'https://netflix.com/login', + proxy: { proxy_id: 'proxy_id' }, + }); + }); + + // Prism tests are disabled + test.skip('retrieve', async () => { + const responsePromise = client.agents.auth.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('list', async () => { + const responsePromise = client.agents.auth.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.agents.auth.list( + { limit: 100, offset: 0, profile_name: 'profile_name', target_domain: 'target_domain' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Kernel.NotFoundError); + }); +}); diff --git a/tests/api-resources/agents/auth/invocations.test.ts b/tests/api-resources/agents/auth/invocations.test.ts new file mode 100644 index 0000000..8bc769c --- /dev/null +++ b/tests/api-resources/agents/auth/invocations.test.ts @@ -0,0 +1,101 @@ +// 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', () => { + // Prism tests are disabled + test.skip('create: only required params', async () => { + const responsePromise = client.agents.auth.invocations.create({ auth_agent_id: 'abc123xyz' }); + 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.agents.auth.invocations.create({ auth_agent_id: 'abc123xyz' }); + }); + + // Prism tests are disabled + test.skip('retrieve', async () => { + const responsePromise = client.agents.auth.invocations.retrieve('invocation_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('discover', async () => { + const responsePromise = client.agents.auth.invocations.discover('invocation_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('discover: 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.agents.auth.invocations.discover( + 'invocation_id', + { login_url: 'https://doordash.com/account/login' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Kernel.NotFoundError); + }); + + // Prism tests are disabled + test.skip('exchange: only required params', async () => { + const responsePromise = client.agents.auth.invocations.exchange('invocation_id', { code: 'abc123xyz' }); + 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('exchange: required and optional params', async () => { + const response = await client.agents.auth.invocations.exchange('invocation_id', { code: 'abc123xyz' }); + }); + + // Prism tests are disabled + test.skip('submit: only required params', async () => { + const responsePromise = client.agents.auth.invocations.submit('invocation_id', { + field_values: { email: 'user@example.com', password: '********' }, + }); + 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('submit: required and optional params', async () => { + const response = await client.agents.auth.invocations.submit('invocation_id', { + field_values: { email: 'user@example.com', password: '********' }, + }); + }); +});