diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ae8398..27be2a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' @@ -17,7 +19,7 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/warp-api-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -41,7 +43,7 @@ jobs: timeout-minutes: 5 name: build runs-on: ${{ github.repository == 'stainless-sdks/warp-api-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') permissions: contents: read id-token: write @@ -65,14 +67,18 @@ jobs: run: ./scripts/build - name: Get GitHub OIDC Token - if: github.repository == 'stainless-sdks/warp-api-typescript' + if: |- + github.repository == 'stainless-sdks/warp-api-typescript' && + !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Upload tarball - if: github.repository == 'stainless-sdks/warp-api-typescript' + if: |- + github.repository == 'stainless-sdks/warp-api-typescript' && + !startsWith(github.ref, 'refs/heads/stl/') env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} diff --git a/.gitignore b/.gitignore index 2412bb7..c85fe68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log node_modules yarn-error.log codegen.log diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b870c5e..e1bea71 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.0.2" + ".": "1.1.0-alpha.0" } diff --git a/.stats.yml b/.stats.yml index 7dd01bc..65c00aa 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/warp-bnavetta%2Fwarp-api-6c175d34cab49d79dbb24289ae516867404c42f3097264bbae171aced72ecc49.yml -openapi_spec_hash: 5abb55a1fc2836207bc88d4815f47f24 -config_hash: a4b1ffc5b2e162efb3d557c7461153c1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/warp-bnavetta%2Fwarp-api-7283a1794d3c59ddc27241892d1b962ee01c1bc5c0d9a456ff716c3d5e2420a7.yml +openapi_spec_hash: b8754eda5e237d0938d6b808fe33bf9b +config_hash: 1888db8b2f33dc16874aea51a90e78f7 diff --git a/CHANGELOG.md b/CHANGELOG.md index ac78b9d..2c54ccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 1.1.0-alpha.0 (2026-04-02) + +Full Changelog: [v1.0.2...v1.1.0-alpha.0](https://github.com/warpdotdev/oz-sdk-typescript/compare/v1.0.2...v1.1.0-alpha.0) + +### Features + +* Add harness enum to openAPI spec ([36fa2f7](https://github.com/warpdotdev/oz-sdk-typescript/commit/36fa2f720d9cab9c7419d4e351dc200de2814cd3)) +* Add VMIdleTimeoutMinutes param to API ([f69cb9f](https://github.com/warpdotdev/oz-sdk-typescript/commit/f69cb9fbd297f5c395eec28208d6ccee42125120)) +* Address Stainless diagnostics ([0a7a253](https://github.com/warpdotdev/oz-sdk-typescript/commit/0a7a2535743f5a95d09b6491388b0faca79b11df)) +* **api:** api update ([36dd429](https://github.com/warpdotdev/oz-sdk-typescript/commit/36dd42978291f15506666a1115ae98a6e3f87af4)) +* **api:** api update ([d9cddd6](https://github.com/warpdotdev/oz-sdk-typescript/commit/d9cddd6e04aa60dcbdbf4fda5edcc7952520fe72)) +* **api:** api update ([e59522b](https://github.com/warpdotdev/oz-sdk-typescript/commit/e59522b2d8335f3c72787a0d60e45017dbafd1b6)) +* Create run for every local conversation and add filter ([64c6a1f](https://github.com/warpdotdev/oz-sdk-typescript/commit/64c6a1f34c49fc659e353ffee66b41d922caabfb)) +* Endpoint to upload third-party harness block snapshots ([de7b4ab](https://github.com/warpdotdev/oz-sdk-typescript/commit/de7b4ab962b47f47554d5ba2c201930c15a595ac)) +* Fix the harness type in the openAPI spec ([8b53e4a](https://github.com/warpdotdev/oz-sdk-typescript/commit/8b53e4ae6fe31f8f74e46297f8dea1edca375114)) +* Orchestrations V2: Public API endpoints ([29a9bf5](https://github.com/warpdotdev/oz-sdk-typescript/commit/29a9bf58392ed3df54b1ec74e154f2e1f1aeeb6b)) +* Use correct branch for Stainless PRs ([f79393c](https://github.com/warpdotdev/oz-sdk-typescript/commit/f79393caa4fbac92137f2b766957dd3b14b07f75)) + + +### Bug Fixes + +* **client:** preserve URL params already embedded in path ([4420fda](https://github.com/warpdotdev/oz-sdk-typescript/commit/4420fdab4fdc8cc948556b74d2370221528e1f47)) + + +### Chores + +* **ci:** skip lint on metadata-only changes ([096e999](https://github.com/warpdotdev/oz-sdk-typescript/commit/096e99986d06140c10c2fb43290b2d1e15501efd)) +* **ci:** skip uploading artifacts on stainless-internal branches ([842b67e](https://github.com/warpdotdev/oz-sdk-typescript/commit/842b67ea7ff38e6032be0af5cdedef6c5f1b67a9)) +* **internal:** tweak CI branches ([e176700](https://github.com/warpdotdev/oz-sdk-typescript/commit/e176700608c5bc5a1f928f07a03929f63bf6853e)) +* **internal:** update dependencies to address dependabot vulnerabilities ([7d17121](https://github.com/warpdotdev/oz-sdk-typescript/commit/7d171218c88c717ddbe930cb6634d1387b685327)) +* **internal:** update gitignore ([71499fd](https://github.com/warpdotdev/oz-sdk-typescript/commit/71499fd606505c058f5a8f41bbe20107181e9ab9)) + ## 1.0.2 (2026-03-06) Full Changelog: [v1.0.1...v1.0.2](https://github.com/warpdotdev/oz-sdk-typescript/compare/v1.0.1...v1.0.2) diff --git a/README.md b/README.md index 5f6b465..e7a06e2 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,37 @@ On timeout, an `APIConnectionTimeoutError` is thrown. Note that requests which time out will be [retried twice by default](#retries). +## Auto-pagination + +List methods in the OzAPI API are paginated. +You can use the `for await … of` syntax to iterate through items across all pages: + +```ts +async function fetchAllRunItems(params) { + const allRunItems = []; + // Automatically fetches more pages as needed. + for await (const runItem of client.agent.runs.list()) { + allRunItems.push(runItem); + } + return allRunItems; +} +``` + +Alternatively, you can request a single page at a time: + +```ts +let page = await client.agent.runs.list(); +for (const runItem of page.runs) { + console.log(runItem); +} + +// Convenience methods are provided for manually paginating: +while (page.hasNextPage()) { + page = await page.getNextPage(); + // ... +} +``` + ## Advanced Usage ### Accessing raw Response data (e.g., headers) diff --git a/api.md b/api.md index 77aa9ca..d292eb7 100644 --- a/api.md +++ b/api.md @@ -4,9 +4,11 @@ Types: - AgentSkill - AmbientAgentConfig +- AwsProviderConfig - CloudEnvironmentConfig - Error - ErrorCode +- GcpProviderConfig - McpServerConfig - Scope - UserProfile @@ -18,7 +20,7 @@ Methods: - client.agent.list({ ...params }) -> AgentListResponse - client.agent.getArtifact(artifactUid) -> AgentGetArtifactResponse -- client.agent.run({ ...params }) -> AgentRunResponse +- client.agent.run({ ...params }) -> AgentRunResponse ## Runs @@ -28,13 +30,12 @@ Types: - RunItem - RunSourceType - RunState -- RunListResponse - RunCancelResponse Methods: - client.agent.runs.retrieve(runID) -> RunItem -- client.agent.runs.list({ ...params }) -> RunListResponse +- client.agent.runs.list({ ...params }) -> RunItemsRunsCursorPage - client.agent.runs.cancel(runID) -> string ## Schedules diff --git a/package.json b/package.json index 988dbb5..605fd85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oz-agent-sdk", - "version": "1.0.2", + "version": "1.1.0-alpha.0", "description": "The official TypeScript library for the Oz API API", "author": "Oz API <>", "types": "dist/index.d.ts", @@ -50,6 +50,17 @@ "typescript": "5.8.3", "typescript-eslint": "8.31.1" }, + "overrides": { + "minimatch": "^9.0.5" + }, + "pnpm": { + "overrides": { + "minimatch": "^9.0.5" + } + }, + "resolutions": { + "minimatch": "^9.0.5" + }, "exports": { ".": { "import": "./dist/index.mjs", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12cca20..c2b6b50 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + minimatch: ^9.0.5 + importers: .: @@ -743,9 +746,6 @@ packages: resolution: {integrity: sha512-B0xUquLkiGLgHhpPBqvl7GWegWBUNuujQ6kXd/r1U38ElPT6Ok8KZ8e+FpUGEc2ZoRQUzq/aUnaKFc/svWUGSg==} hasBin: true - brace-expansion@1.1.12: - resolution: {integrity: sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==} - brace-expansion@2.0.2: resolution: {integrity: sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==} @@ -840,9 +840,6 @@ packages: resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} engines: {node: '>=14'} - concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} @@ -1486,13 +1483,6 @@ packages: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} - minimatch@3.1.2: - resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} - - minimatch@5.1.6: - resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} - engines: {node: '>=10'} - minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} @@ -2274,7 +2264,7 @@ snapshots: dependencies: '@eslint/object-schema': 2.1.7 debug: 4.4.3 - minimatch: 3.1.2 + minimatch: 9.0.5 transitivePeerDependencies: - supports-color @@ -2295,7 +2285,7 @@ snapshots: ignore: 5.3.2 import-fresh: 3.3.1 js-yaml: 4.1.1 - minimatch: 3.1.2 + minimatch: 9.0.5 strip-json-comments: 3.1.1 transitivePeerDependencies: - supports-color @@ -2862,11 +2852,6 @@ snapshots: baseline-browser-mapping@2.9.14: {} - brace-expansion@1.1.12: - dependencies: - balanced-match: 1.0.2 - concat-map: 0.0.1 - brace-expansion@2.0.2: dependencies: balanced-match: 1.0.2 @@ -2955,8 +2940,6 @@ snapshots: commander@10.0.1: {} - concat-map@0.0.1: {} - convert-source-map@2.0.0: {} create-jest@29.7.0(@types/node@20.19.11)(ts-node@10.7.0(@swc/core@1.4.16)(@types/node@20.19.11)(typescript@5.8.3)): @@ -3081,7 +3064,7 @@ snapshots: is-glob: 4.0.3 json-stable-stringify-without-jsonify: 1.0.1 lodash.merge: 4.6.2 - minimatch: 3.1.2 + minimatch: 9.0.5 natural-compare: 1.4.0 optionator: 0.9.4 transitivePeerDependencies: @@ -3210,7 +3193,7 @@ snapshots: fs.realpath: 1.0.0 inflight: 1.0.6 inherits: 2.0.4 - minimatch: 3.1.2 + minimatch: 9.0.5 once: 1.4.0 path-is-absolute: 1.0.1 @@ -3219,7 +3202,7 @@ snapshots: fs.realpath: 1.0.0 inflight: 1.0.6 inherits: 2.0.4 - minimatch: 5.1.6 + minimatch: 9.0.5 once: 1.4.0 globals@14.0.0: {} @@ -3255,7 +3238,7 @@ snapshots: ignore-walk@5.0.1: dependencies: - minimatch: 5.1.6 + minimatch: 9.0.5 ignore@5.3.2: {} @@ -3744,14 +3727,6 @@ snapshots: mimic-fn@2.1.0: {} - minimatch@3.1.2: - dependencies: - brace-expansion: 1.1.12 - - minimatch@5.1.6: - dependencies: - brace-expansion: 2.0.2 - minimatch@9.0.5: dependencies: brace-expansion: 2.0.2 @@ -4046,7 +4021,7 @@ snapshots: dependencies: '@istanbuljs/schema': 0.1.3 glob: 7.2.3 - minimatch: 3.1.2 + minimatch: 9.0.5 thenify-all@1.6.0: dependencies: diff --git a/src/client.ts b/src/client.ts index ac39f9c..f653a4f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -14,6 +14,8 @@ import * as Opts from './internal/request-options'; import { stringifyQuery } from './internal/utils/query'; import { VERSION } from './version'; import * as Errors from './core/error'; +import * as Pagination from './core/pagination'; +import { AbstractPage, type RunsCursorPageParams, RunsCursorPageResponse } from './core/pagination'; import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; @@ -26,9 +28,11 @@ import { AgentRunResponse, AgentSkill, AmbientAgentConfig, + AwsProviderConfig, CloudEnvironmentConfig, Error, ErrorCode, + GcpProviderConfig, McpServerConfig, Scope, UserProfile, @@ -260,8 +264,9 @@ export class OzAPI { : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path)); const defaultQuery = this.defaultQuery(); - if (!isEmptyObj(defaultQuery)) { - query = { ...defaultQuery, ...query }; + const pathQuery = Object.fromEntries(url.searchParams); + if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) { + query = { ...pathQuery, ...defaultQuery, ...query }; } if (typeof query === 'object' && query && !Array.isArray(query)) { @@ -483,6 +488,30 @@ export class OzAPI { return { response, options, controller, requestLogID, retryOfRequestLogID, startTime }; } + getAPIList = Pagination.AbstractPage>( + path: string, + Page: new (...args: any[]) => PageClass, + opts?: PromiseOrValue, + ): Pagination.PagePromise { + return this.requestAPIList( + Page, + opts && 'then' in opts ? + opts.then((opts) => ({ method: 'get', path, ...opts })) + : { method: 'get', path, ...opts }, + ); + } + + requestAPIList< + Item = unknown, + PageClass extends Pagination.AbstractPage = Pagination.AbstractPage, + >( + Page: new (...args: ConstructorParameters) => PageClass, + options: PromiseOrValue, + ): Pagination.PagePromise { + const request = this.makeRequest(options, null, undefined); + return new Pagination.PagePromise(this as any as OzAPI, request, Page); + } + async fetchWithTimeout( url: RequestInfo, init: RequestInit | undefined, @@ -741,13 +770,21 @@ OzAPI.Agent = Agent; export declare namespace OzAPI { export type RequestOptions = Opts.RequestOptions; + export import RunsCursorPage = Pagination.RunsCursorPage; + export { + type RunsCursorPageParams as RunsCursorPageParams, + type RunsCursorPageResponse as RunsCursorPageResponse, + }; + export { Agent as Agent, type AgentSkill as AgentSkill, type AmbientAgentConfig as AmbientAgentConfig, + type AwsProviderConfig as AwsProviderConfig, type CloudEnvironmentConfig as CloudEnvironmentConfig, type Error as Error, type ErrorCode as ErrorCode, + type GcpProviderConfig as GcpProviderConfig, type McpServerConfig as McpServerConfig, type Scope as Scope, type UserProfile as UserProfile, diff --git a/src/core/pagination.ts b/src/core/pagination.ts new file mode 100644 index 0000000..ad0dca2 --- /dev/null +++ b/src/core/pagination.ts @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { OzAPIError } from './error'; +import { FinalRequestOptions } from '../internal/request-options'; +import { defaultParseResponse } from '../internal/parse'; +import { type OzAPI } from '../client'; +import { APIPromise } from './api-promise'; +import { type APIResponseProps } from '../internal/parse'; +import { maybeObj } from '../internal/utils/values'; + +export type PageRequestOptions = Pick; + +export abstract class AbstractPage implements AsyncIterable { + #client: OzAPI; + protected options: FinalRequestOptions; + + protected response: Response; + protected body: unknown; + + constructor(client: OzAPI, response: Response, body: unknown, options: FinalRequestOptions) { + this.#client = client; + this.options = options; + this.response = response; + this.body = body; + } + + abstract nextPageRequestOptions(): PageRequestOptions | null; + + abstract getPaginatedItems(): Item[]; + + hasNextPage(): boolean { + const items = this.getPaginatedItems(); + if (!items.length) return false; + return this.nextPageRequestOptions() != null; + } + + async getNextPage(): Promise { + const nextOptions = this.nextPageRequestOptions(); + if (!nextOptions) { + throw new OzAPIError( + 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.', + ); + } + + return await this.#client.requestAPIList(this.constructor as any, nextOptions); + } + + async *iterPages(): AsyncGenerator { + let page: this = this; + yield page; + while (page.hasNextPage()) { + page = await page.getNextPage(); + yield page; + } + } + + async *[Symbol.asyncIterator](): AsyncGenerator { + for await (const page of this.iterPages()) { + for (const item of page.getPaginatedItems()) { + yield item; + } + } + } +} + +/** + * This subclass of Promise will resolve to an instantiated Page once the request completes. + * + * It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg: + * + * for await (const item of client.items.list()) { + * console.log(item) + * } + */ +export class PagePromise< + PageClass extends AbstractPage, + Item = ReturnType[number], + > + extends APIPromise + implements AsyncIterable +{ + constructor( + client: OzAPI, + request: Promise, + Page: new (...args: ConstructorParameters) => PageClass, + ) { + super( + client, + request, + async (client, props) => + new Page(client, props.response, await defaultParseResponse(client, props), props.options), + ); + } + + /** + * Allow auto-paginating iteration on an unawaited list call, eg: + * + * for await (const item of client.items.list()) { + * console.log(item) + * } + */ + async *[Symbol.asyncIterator](): AsyncGenerator { + const page = await this; + for await (const item of page) { + yield item; + } + } +} + +export interface RunsCursorPageResponse { + runs: Array; + + page_info: RunsCursorPageResponse.PageInfo; +} + +export namespace RunsCursorPageResponse { + export interface PageInfo { + has_next_page?: boolean; + + next_cursor?: string; + } +} + +export interface RunsCursorPageParams { + cursor?: string; + + limit?: number; +} + +export class RunsCursorPage extends AbstractPage implements RunsCursorPageResponse { + runs: Array; + + page_info: RunsCursorPageResponse.PageInfo; + + constructor( + client: OzAPI, + response: Response, + body: RunsCursorPageResponse, + options: FinalRequestOptions, + ) { + super(client, response, body, options); + + this.runs = body.runs || []; + this.page_info = body.page_info || {}; + } + + getPaginatedItems(): Item[] { + return this.runs ?? []; + } + + override hasNextPage(): boolean { + if (this.page_info?.has_next_page === false) { + return false; + } + + return super.hasNextPage(); + } + + nextPageRequestOptions(): PageRequestOptions | null { + const cursor = this.page_info?.next_cursor; + if (!cursor) { + return null; + } + + return { + ...this.options, + query: { + ...maybeObj(this.options.query), + cursor, + }, + }; + } +} diff --git a/src/index.ts b/src/index.ts index 19e2b42..f070959 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ export { OzAPI as default } from './client'; export { type Uploadable, toFile } from './core/uploads'; export { APIPromise } from './core/api-promise'; export { OzAPI, type ClientOptions } from './client'; +export { PagePromise } from './core/pagination'; export { OzAPIError, APIError, diff --git a/src/pagination.ts b/src/pagination.ts new file mode 100644 index 0000000..90bf015 --- /dev/null +++ b/src/pagination.ts @@ -0,0 +1,2 @@ +/** @deprecated Import from ./core/pagination instead */ +export * from './core/pagination'; diff --git a/src/resources/agent/agent.ts b/src/resources/agent/agent.ts index 750c010..9c23de5 100644 --- a/src/resources/agent/agent.ts +++ b/src/resources/agent/agent.ts @@ -1,13 +1,14 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; +import * as AgentAPI from './agent'; import * as RunsAPI from './runs'; import { ArtifactItem, RunCancelResponse, RunItem, + RunItemsRunsCursorPage, RunListParams, - RunListResponse, RunSourceType, RunState, Runs, @@ -68,18 +69,16 @@ export class Agent extends APIResource { } /** - * Spawn a cloud agent with a prompt and optional configuration. The agent will be - * queued for execution and assigned a unique run ID. + * Alias for POST /agent/run. This is the preferred endpoint for creating new agent + * runs. Behavior is identical to POST /agent/run. * * @example * ```ts - * const response = await client.agent.run({ - * prompt: 'Fix the bug in auth.go', - * }); + * const response = await client.agent.run(); * ``` */ run(body: AgentRunParams, options?: RequestOptions): APIPromise { - return this._client.post('/agent/run', { body, ...options }); + return this._client.post('/agent/runs', { body, ...options }); } } @@ -185,6 +184,19 @@ export interface AmbientAgentConfig { */ environment_id?: string; + /** + * Specifies which execution harness to use for the agent run. Default (nil/empty) + * uses Warp's built-in harness. + */ + harness?: AmbientAgentConfig.Harness; + + /** + * Number of minutes to keep the agent environment alive after task completion. If + * not set, defaults to 10 minutes. Maximum allowed value is min(60, + * floor(max_instance_runtime_seconds / 60) for your billing tier). + */ + idle_timeout_minutes?: number; + /** * Map of MCP server configurations by name */ @@ -218,6 +230,32 @@ export interface AmbientAgentConfig { worker_host?: string; } +export namespace AmbientAgentConfig { + /** + * Specifies which execution harness to use for the agent run. Default (nil/empty) + * uses Warp's built-in harness. + */ + export interface Harness { + /** + * The harness type identifier. + * + * - oz: Warp's built-in harness (default) + * - claude: Claude Code harness + */ + type?: 'oz' | 'claude'; + } +} + +/** + * AWS IAM role assumption settings + */ +export interface AwsProviderConfig { + /** + * AWS IAM role ARN to assume + */ + role_arn: string; +} + /** * Configuration for a cloud environment used by scheduled agents */ @@ -242,6 +280,11 @@ export interface CloudEnvironmentConfig { */ name?: string; + /** + * Optional cloud provider configurations for automatic auth + */ + providers?: CloudEnvironmentConfig.Providers; + /** * Shell commands to run during environment setup */ @@ -260,6 +303,21 @@ export namespace CloudEnvironmentConfig { */ repo: string; } + + /** + * Optional cloud provider configurations for automatic auth + */ + export interface Providers { + /** + * AWS IAM role assumption settings + */ + aws?: AgentAPI.AwsProviderConfig; + + /** + * GCP Workload Identity Federation settings + */ + gcp?: AgentAPI.GcpProviderConfig; + } } /** @@ -364,6 +422,26 @@ export type ErrorCode = | 'resource_unavailable' | 'internal_error'; +/** + * GCP Workload Identity Federation settings + */ +export interface GcpProviderConfig { + /** + * GCP project number + */ + project_number: string; + + /** + * Workload Identity Federation pool ID + */ + workload_identity_federation_pool_id: string; + + /** + * Workload Identity Federation provider ID + */ + workload_identity_federation_provider_id: string; +} + /** * Configuration for an MCP server. Must have exactly one of: warp_id, command, or * url. @@ -585,6 +663,12 @@ export interface AgentRunParams { */ interactive?: boolean; + /** + * Optional run ID of the parent that spawned this run. Used for orchestration + * hierarchies. + */ + parent_run_id?: string; + /** * The prompt/instruction for the agent to execute. Required unless a skill is * specified via the skill field or config.skill_spec. @@ -644,9 +728,11 @@ export declare namespace Agent { export { type AgentSkill as AgentSkill, type AmbientAgentConfig as AmbientAgentConfig, + type AwsProviderConfig as AwsProviderConfig, type CloudEnvironmentConfig as CloudEnvironmentConfig, type Error as Error, type ErrorCode as ErrorCode, + type GcpProviderConfig as GcpProviderConfig, type McpServerConfig as McpServerConfig, type Scope as Scope, type UserProfile as UserProfile, @@ -663,8 +749,8 @@ export declare namespace Agent { type RunItem as RunItem, type RunSourceType as RunSourceType, type RunState as RunState, - type RunListResponse as RunListResponse, type RunCancelResponse as RunCancelResponse, + type RunItemsRunsCursorPage as RunItemsRunsCursorPage, type RunListParams as RunListParams, }; diff --git a/src/resources/agent/index.ts b/src/resources/agent/index.ts index d29a718..4eb8c8f 100644 --- a/src/resources/agent/index.ts +++ b/src/resources/agent/index.ts @@ -4,9 +4,11 @@ export { Agent, type AgentSkill, type AmbientAgentConfig, + type AwsProviderConfig, type CloudEnvironmentConfig, type Error, type ErrorCode, + type GcpProviderConfig, type McpServerConfig, type Scope, type UserProfile, @@ -22,9 +24,9 @@ export { type RunItem, type RunSourceType, type RunState, - type RunListResponse, type RunCancelResponse, type RunListParams, + type RunItemsRunsCursorPage, } from './runs'; export { Schedules, diff --git a/src/resources/agent/runs.ts b/src/resources/agent/runs.ts index 940c3a9..5948e25 100644 --- a/src/resources/agent/runs.ts +++ b/src/resources/agent/runs.ts @@ -3,6 +3,7 @@ import { APIResource } from '../../core/resource'; import * as AgentAPI from './agent'; import { APIPromise } from '../../core/api-promise'; +import { PagePromise, RunsCursorPage, type RunsCursorPageParams } from '../../core/pagination'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; @@ -29,11 +30,17 @@ export class Runs extends APIResource { * * @example * ```ts - * const runs = await client.agent.runs.list(); + * // Automatically fetches more pages as needed. + * for await (const runItem of client.agent.runs.list()) { + * // ... + * } * ``` */ - list(query: RunListParams | null | undefined = {}, options?: RequestOptions): APIPromise { - return this._client.get('/agent/runs', { query, ...options }); + list( + query: RunListParams | null | undefined = {}, + options?: RequestOptions, + ): PagePromise { + return this._client.getAPIList('/agent/runs', RunsCursorPage, { query, ...options }); } /** @@ -54,6 +61,8 @@ export class Runs extends APIResource { } } +export type RunItemsRunsCursorPage = RunsCursorPage; + export type ArtifactItem = | ArtifactItem.PlanArtifact | ArtifactItem.PullRequestArtifact @@ -224,6 +233,14 @@ export interface RunItem { creator?: AgentAPI.UserProfile; + /** + * Where the run executed: + * + * - LOCAL: Executed in the user's local Oz environment + * - REMOTE: Executed by a remote/cloud worker + */ + execution_location?: 'LOCAL' | 'REMOTE'; + /** * Whether the sandbox environment is currently running */ @@ -442,34 +459,14 @@ export type RunState = | 'ERROR' | 'CANCELLED'; -export interface RunListResponse { - page_info: RunListResponse.PageInfo; - - runs: Array; -} - -export namespace RunListResponse { - export interface PageInfo { - /** - * Whether there are more results available - */ - has_next_page: boolean; - - /** - * Opaque cursor for fetching the next page - */ - next_cursor?: string; - } -} - /** * The ID of the cancelled run */ export type RunCancelResponse = string; -export interface RunListParams { +export interface RunListParams extends RunsCursorPageParams { /** - * Filter runs by artifact type (PLAN or PULL_REQUEST) + * Filter runs by artifact type */ artifact_type?: 'PLAN' | 'PULL_REQUEST' | 'SCREENSHOT'; @@ -488,20 +485,15 @@ export interface RunListParams { */ creator?: string; - /** - * Pagination cursor from previous response - */ - cursor?: string; - /** * Filter runs by environment ID */ environment_id?: string; /** - * Maximum number of runs to return + * Filter by where the run executed */ - limit?: number; + execution_location?: 'LOCAL' | 'REMOTE'; /** * Filter by model ID @@ -572,8 +564,8 @@ export declare namespace Runs { type RunItem as RunItem, type RunSourceType as RunSourceType, type RunState as RunState, - type RunListResponse as RunListResponse, type RunCancelResponse as RunCancelResponse, + type RunItemsRunsCursorPage as RunItemsRunsCursorPage, type RunListParams as RunListParams, }; } diff --git a/src/resources/agent/schedules.ts b/src/resources/agent/schedules.ts index 31299f1..82dc8dd 100644 --- a/src/resources/agent/schedules.ts +++ b/src/resources/agent/schedules.ts @@ -94,8 +94,7 @@ export class Schedules extends APIResource { } /** - * Pause a scheduled agent. The agent will not run until resumed. This sets the - * enabled flag to false. + * Pause a scheduled agent. The agent will not run until resumed. * * @example * ```ts @@ -109,7 +108,7 @@ export class Schedules extends APIResource { /** * Resume a paused scheduled agent. The agent will start running according to its - * cron schedule. This sets the enabled flag to true. + * cron schedule. * * @example * ```ts diff --git a/src/resources/index.ts b/src/resources/index.ts index 26da403..b60bda3 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -4,9 +4,11 @@ export { Agent, type AgentSkill, type AmbientAgentConfig, + type AwsProviderConfig, type CloudEnvironmentConfig, type Error, type ErrorCode, + type GcpProviderConfig, type McpServerConfig, type Scope, type UserProfile, diff --git a/src/version.ts b/src/version.ts index 0ac78d9..87adcc5 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '1.0.2'; // x-release-please-version +export const VERSION = '1.1.0-alpha.0'; // x-release-please-version diff --git a/tests/api-resources/agent/runs.test.ts b/tests/api-resources/agent/runs.test.ts index e94ce3f..421f15a 100644 --- a/tests/api-resources/agent/runs.test.ts +++ b/tests/api-resources/agent/runs.test.ts @@ -44,6 +44,7 @@ describe('resource runs', () => { creator: 'creator', cursor: 'cursor', environment_id: 'environment_id', + execution_location: 'LOCAL', limit: 1, model_id: 'model_id', name: 'name', diff --git a/tests/api-resources/agent/schedules.test.ts b/tests/api-resources/agent/schedules.test.ts index 5bf3c86..8b4f534 100644 --- a/tests/api-resources/agent/schedules.test.ts +++ b/tests/api-resources/agent/schedules.test.ts @@ -32,6 +32,8 @@ describe('resource schedules', () => { base_prompt: 'base_prompt', computer_use_enabled: true, environment_id: 'environment_id', + harness: { type: 'oz' }, + idle_timeout_minutes: 1, mcp_servers: { foo: { args: ['string'], @@ -91,6 +93,8 @@ describe('resource schedules', () => { base_prompt: 'base_prompt', computer_use_enabled: true, environment_id: 'environment_id', + harness: { type: 'oz' }, + idle_timeout_minutes: 1, mcp_servers: { foo: { args: ['string'],