Skip to content

Commit 1fa19c3

Browse files
feat: Update public API and graphql to support creating multiple service accounts and API keys
1 parent ac31015 commit 1fa19c3

6 files changed

Lines changed: 248 additions & 4 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 15
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/warp-bnavetta%2Fwarp-api-11fd464a4cf5b849a565d00039093093ef93acdb99679ae94b2908543a55097b.yml
3-
openapi_spec_hash: 12840099351c5309d6cf8c4b92f028b3
4-
config_hash: 42666caf45e82675e80982d51e3b7727
1+
configured_endpoints: 19
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/warp-bnavetta%2Fwarp-api-3226a0810ae5de980509e31910138990d93d2843918730249caed1436e677ec3.yml
3+
openapi_spec_hash: 776a9087e0c342e9fcbd140e75936d75
4+
config_hash: c5fc921cc04f541a85f92299f365eba6

api.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ Methods:
6060
- <code title="post /agent/schedules/{scheduleId}/pause">client.agent.schedules.<a href="./src/resources/agent/schedules.ts">pause</a>(scheduleID) -> ScheduledAgentItem</code>
6161
- <code title="post /agent/schedules/{scheduleId}/resume">client.agent.schedules.<a href="./src/resources/agent/schedules.ts">resume</a>(scheduleID) -> ScheduledAgentItem</code>
6262

63+
## Agent
64+
65+
Types:
66+
67+
- <code><a href="./src/resources/agent/agent_.ts">AgentResponse</a></code>
68+
- <code><a href="./src/resources/agent/agent_.ts">CreateAgentRequest</a></code>
69+
- <code><a href="./src/resources/agent/agent_.ts">ListAgentIdentitiesResponse</a></code>
70+
- <code><a href="./src/resources/agent/agent_.ts">UpdateAgentRequest</a></code>
71+
72+
Methods:
73+
74+
- <code title="post /agent/identities">client.agent.agent.<a href="./src/resources/agent/agent_.ts">create</a>({ ...params }) -> AgentResponse</code>
75+
- <code title="put /agent/identities/{uid}">client.agent.agent.<a href="./src/resources/agent/agent_.ts">update</a>(uid, { ...params }) -> AgentResponse</code>
76+
- <code title="get /agent/identities">client.agent.agent.<a href="./src/resources/agent/agent_.ts">list</a>() -> ListAgentIdentitiesResponse</code>
77+
- <code title="delete /agent/identities/{uid}">client.agent.agent.<a href="./src/resources/agent/agent_.ts">delete</a>(uid) -> void</code>
78+
6379
## Sessions
6480

6581
Types:

src/resources/agent/agent.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
import { APIResource } from '../../core/resource';
44
import * as AgentAPI from './agent';
5+
import * as AgentAgentAPI from './agent_';
6+
import {
7+
Agent as AgentAPIAgent,
8+
AgentCreateParams,
9+
AgentResponse,
10+
AgentUpdateParams,
11+
CreateAgentRequest,
12+
ListAgentIdentitiesResponse,
13+
UpdateAgentRequest,
14+
} from './agent_';
515
import * as RunsAPI from './runs';
616
import {
717
ArtifactItem,
@@ -35,6 +45,7 @@ import { path } from '../../internal/utils/path';
3545
export class Agent extends APIResource {
3646
runs: RunsAPI.Runs = new RunsAPI.Runs(this._client);
3747
schedules: SchedulesAPI.Schedules = new SchedulesAPI.Schedules(this._client);
48+
agent: AgentAgentAPI.Agent = new AgentAgentAPI.Agent(this._client);
3849
sessions: SessionsAPI.Sessions = new SessionsAPI.Sessions(this._client);
3950

4051
/**
@@ -1019,6 +1030,7 @@ export namespace AgentRunParams {
10191030

10201031
Agent.Runs = Runs;
10211032
Agent.Schedules = Schedules;
1033+
Agent.Agent = AgentAPIAgent;
10221034
Agent.Sessions = Sessions;
10231035

10241036
export declare namespace Agent {
@@ -1064,5 +1076,15 @@ export declare namespace Agent {
10641076
type ScheduleUpdateParams as ScheduleUpdateParams,
10651077
};
10661078

1079+
export {
1080+
AgentAPIAgent as Agent,
1081+
type AgentResponse as AgentResponse,
1082+
type CreateAgentRequest as CreateAgentRequest,
1083+
type ListAgentIdentitiesResponse as ListAgentIdentitiesResponse,
1084+
type UpdateAgentRequest as UpdateAgentRequest,
1085+
type AgentCreateParams as AgentCreateParams,
1086+
type AgentUpdateParams as AgentUpdateParams,
1087+
};
1088+
10671089
export { Sessions as Sessions, type SessionCheckRedirectResponse as SessionCheckRedirectResponse };
10681090
}

src/resources/agent/agent_.ts

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
}

src/resources/agent/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ export {
4141
type ScheduleUpdateParams,
4242
} from './schedules';
4343
export { Sessions, type SessionCheckRedirectResponse } from './sessions';
44+
export {
45+
type AgentResponse,
46+
type CreateAgentRequest,
47+
type ListAgentIdentitiesResponse,
48+
type UpdateAgentRequest,
49+
type AgentCreateParams,
50+
type AgentUpdateParams,
51+
} from './agent_';
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import OzAPI from 'oz-agent-sdk';
4+
5+
const client = new OzAPI({
6+
apiKey: 'My API Key',
7+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8+
});
9+
10+
describe('resource agent', () => {
11+
// Mock server tests are disabled
12+
test.skip('create: only required params', async () => {
13+
const responsePromise = client.agent.agent.create({ name: 'name' });
14+
const rawResponse = await responsePromise.asResponse();
15+
expect(rawResponse).toBeInstanceOf(Response);
16+
const response = await responsePromise;
17+
expect(response).not.toBeInstanceOf(Response);
18+
const dataAndResponse = await responsePromise.withResponse();
19+
expect(dataAndResponse.data).toBe(response);
20+
expect(dataAndResponse.response).toBe(rawResponse);
21+
});
22+
23+
// Mock server tests are disabled
24+
test.skip('create: required and optional params', async () => {
25+
const response = await client.agent.agent.create({ name: 'name' });
26+
});
27+
28+
// Mock server tests are disabled
29+
test.skip('update', async () => {
30+
const responsePromise = client.agent.agent.update('uid', {});
31+
const rawResponse = await responsePromise.asResponse();
32+
expect(rawResponse).toBeInstanceOf(Response);
33+
const response = await responsePromise;
34+
expect(response).not.toBeInstanceOf(Response);
35+
const dataAndResponse = await responsePromise.withResponse();
36+
expect(dataAndResponse.data).toBe(response);
37+
expect(dataAndResponse.response).toBe(rawResponse);
38+
});
39+
40+
// Mock server tests are disabled
41+
test.skip('list', async () => {
42+
const responsePromise = client.agent.agent.list();
43+
const rawResponse = await responsePromise.asResponse();
44+
expect(rawResponse).toBeInstanceOf(Response);
45+
const response = await responsePromise;
46+
expect(response).not.toBeInstanceOf(Response);
47+
const dataAndResponse = await responsePromise.withResponse();
48+
expect(dataAndResponse.data).toBe(response);
49+
expect(dataAndResponse.response).toBe(rawResponse);
50+
});
51+
52+
// Mock server tests are disabled
53+
test.skip('delete', async () => {
54+
const responsePromise = client.agent.agent.delete('uid');
55+
const rawResponse = await responsePromise.asResponse();
56+
expect(rawResponse).toBeInstanceOf(Response);
57+
const response = await responsePromise;
58+
expect(response).not.toBeInstanceOf(Response);
59+
const dataAndResponse = await responsePromise.withResponse();
60+
expect(dataAndResponse.data).toBe(response);
61+
expect(dataAndResponse.response).toBe(rawResponse);
62+
});
63+
});

0 commit comments

Comments
 (0)