|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../../core/resource'; |
| 4 | +import { APIPromise } from '../../core/api-promise'; |
| 5 | +import { buildHeaders } from '../../internal/headers'; |
| 6 | +import { RequestOptions } from '../../internal/request-options'; |
| 7 | +import { path } from '../../internal/utils/path'; |
| 8 | + |
| 9 | +/** |
| 10 | + * Operations for running and managing cloud agents |
| 11 | + */ |
| 12 | +export class Agent extends APIResource { |
| 13 | + /** |
| 14 | + * Create a new agent for the caller's team. Agents can be used as the execution |
| 15 | + * principal for team-owned runs. |
| 16 | + * |
| 17 | + * @example |
| 18 | + * ```ts |
| 19 | + * const agentResponse = await client.agent.agent.create({ |
| 20 | + * name: 'name', |
| 21 | + * }); |
| 22 | + * ``` |
| 23 | + */ |
| 24 | + create(body: AgentCreateParams, options?: RequestOptions): APIPromise<AgentResponse> { |
| 25 | + return this._client.post('/agent/identities', { body, ...options }); |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Update an existing agent. |
| 30 | + * |
| 31 | + * @example |
| 32 | + * ```ts |
| 33 | + * const agentResponse = await client.agent.agent.update( |
| 34 | + * 'uid', |
| 35 | + * ); |
| 36 | + * ``` |
| 37 | + */ |
| 38 | + update(uid: string, body: AgentUpdateParams, options?: RequestOptions): APIPromise<AgentResponse> { |
| 39 | + return this._client.put(path`/agent/identities/${uid}`, { body, ...options }); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * List all agents for the caller's team. Each agent includes an `available` flag |
| 44 | + * indicating whether it is within the team's plan limit and may be used for runs. |
| 45 | + * |
| 46 | + * @example |
| 47 | + * ```ts |
| 48 | + * const listAgentIdentitiesResponse = |
| 49 | + * await client.agent.agent.list(); |
| 50 | + * ``` |
| 51 | + */ |
| 52 | + list(options?: RequestOptions): APIPromise<ListAgentIdentitiesResponse> { |
| 53 | + return this._client.get('/agent/identities', options); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * Delete an agent. All API keys associated with the agent are deleted atomically. |
| 58 | + * |
| 59 | + * @example |
| 60 | + * ```ts |
| 61 | + * await client.agent.agent.delete('uid'); |
| 62 | + * ``` |
| 63 | + */ |
| 64 | + delete(uid: string, options?: RequestOptions): APIPromise<void> { |
| 65 | + return this._client.delete(path`/agent/identities/${uid}`, { |
| 66 | + ...options, |
| 67 | + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), |
| 68 | + }); |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +export interface AgentResponse { |
| 73 | + /** |
| 74 | + * Whether this agent is within the team's plan limit and can be used for runs |
| 75 | + */ |
| 76 | + available: boolean; |
| 77 | + |
| 78 | + /** |
| 79 | + * When the agent was created (RFC3339) |
| 80 | + */ |
| 81 | + created_at: string; |
| 82 | + |
| 83 | + /** |
| 84 | + * Name of the agent |
| 85 | + */ |
| 86 | + name: string; |
| 87 | + |
| 88 | + /** |
| 89 | + * Unique identifier for the agent |
| 90 | + */ |
| 91 | + uid: string; |
| 92 | +} |
| 93 | + |
| 94 | +export interface CreateAgentRequest { |
| 95 | + /** |
| 96 | + * A name for the agent |
| 97 | + */ |
| 98 | + name: string; |
| 99 | +} |
| 100 | + |
| 101 | +export interface ListAgentIdentitiesResponse { |
| 102 | + agents: Array<AgentResponse>; |
| 103 | +} |
| 104 | + |
| 105 | +export interface UpdateAgentRequest { |
| 106 | + /** |
| 107 | + * The new name for the agent |
| 108 | + */ |
| 109 | + name?: string; |
| 110 | +} |
| 111 | + |
| 112 | +export interface AgentCreateParams { |
| 113 | + /** |
| 114 | + * A name for the agent |
| 115 | + */ |
| 116 | + name: string; |
| 117 | +} |
| 118 | + |
| 119 | +export interface AgentUpdateParams { |
| 120 | + /** |
| 121 | + * The new name for the agent |
| 122 | + */ |
| 123 | + name?: string; |
| 124 | +} |
| 125 | + |
| 126 | +export declare namespace Agent { |
| 127 | + export { |
| 128 | + type AgentResponse as AgentResponse, |
| 129 | + type CreateAgentRequest as CreateAgentRequest, |
| 130 | + type ListAgentIdentitiesResponse as ListAgentIdentitiesResponse, |
| 131 | + type UpdateAgentRequest as UpdateAgentRequest, |
| 132 | + type AgentCreateParams as AgentCreateParams, |
| 133 | + type AgentUpdateParams as AgentUpdateParams, |
| 134 | + }; |
| 135 | +} |
0 commit comments