Skip to content

Commit 0ef28fd

Browse files
feat: enhance agent authentication API with new endpoints and request…
1 parent 3ffeaa7 commit 0ef28fd

File tree

9 files changed

+244
-79
lines changed

9 files changed

+244
-79
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 80
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-8a37652fa586b8932466d16285359a89988505f850787f8257d0c4c7053da173.yml
3-
openapi_spec_hash: 042765a113f6d08109e8146b302323ec
4-
config_hash: 113f1e5bc3567628a5d51c70bc00969d
1+
configured_endpoints: 82
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-b6957db438b01d979b62de21d4e674601b37d55b850b95a6e2b4c771aad5e840.yml
3+
openapi_spec_hash: 1c8aac8322bc9df8f1b82a7e7a0c692b
4+
config_hash: a4b4d14bdf6af723b235a6981977627c

api.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,18 @@ Types:
255255

256256
- <code><a href="./src/resources/agents/auth/auth.ts">AgentAuthDiscoverResponse</a></code>
257257
- <code><a href="./src/resources/agents/auth/auth.ts">AgentAuthInvocationResponse</a></code>
258-
- <code><a href="./src/resources/agents/auth/auth.ts">AgentAuthStartResponse</a></code>
259258
- <code><a href="./src/resources/agents/auth/auth.ts">AgentAuthSubmitResponse</a></code>
260259
- <code><a href="./src/resources/agents/auth/auth.ts">AuthAgent</a></code>
260+
- <code><a href="./src/resources/agents/auth/auth.ts">AuthAgentCreateRequest</a></code>
261+
- <code><a href="./src/resources/agents/auth/auth.ts">AuthAgentInvocationCreateRequest</a></code>
262+
- <code><a href="./src/resources/agents/auth/auth.ts">AuthAgentInvocationCreateResponse</a></code>
261263
- <code><a href="./src/resources/agents/auth/auth.ts">DiscoveredField</a></code>
262264

263265
Methods:
264266

267+
- <code title="post /agents/auth">client.agents.auth.<a href="./src/resources/agents/auth/auth.ts">create</a>({ ...params }) -> AuthAgent</code>
265268
- <code title="get /agents/auth/{id}">client.agents.auth.<a href="./src/resources/agents/auth/auth.ts">retrieve</a>(id) -> AuthAgent</code>
266-
- <code title="post /agents/auth/start">client.agents.auth.<a href="./src/resources/agents/auth/auth.ts">start</a>({ ...params }) -> AgentAuthStartResponse</code>
269+
- <code title="get /agents/auth">client.agents.auth.<a href="./src/resources/agents/auth/auth.ts">list</a>({ ...params }) -> AuthAgentsOffsetPagination</code>
267270

268271
### Invocations
269272

@@ -273,6 +276,7 @@ Types:
273276

274277
Methods:
275278

279+
- <code title="post /agents/auth/invocations">client.agents.auth.invocations.<a href="./src/resources/agents/auth/invocations.ts">create</a>({ ...params }) -> AuthAgentInvocationCreateResponse</code>
276280
- <code title="get /agents/auth/invocations/{invocation_id}">client.agents.auth.invocations.<a href="./src/resources/agents/auth/invocations.ts">retrieve</a>(invocationID) -> AgentAuthInvocationResponse</code>
277281
- <code title="post /agents/auth/invocations/{invocation_id}/discover">client.agents.auth.invocations.<a href="./src/resources/agents/auth/invocations.ts">discover</a>(invocationID, { ...params }) -> AgentAuthDiscoverResponse</code>
278282
- <code title="post /agents/auth/invocations/{invocation_id}/exchange">client.agents.auth.invocations.<a href="./src/resources/agents/auth/invocations.ts">exchange</a>(invocationID, { ...params }) -> InvocationExchangeResponse</code>

src/resources/agents/agents.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ import * as AuthAPI from './auth/auth';
55
import {
66
AgentAuthDiscoverResponse,
77
AgentAuthInvocationResponse,
8-
AgentAuthStartResponse,
98
AgentAuthSubmitResponse,
109
Auth,
1110
AuthAgent,
12-
AuthStartParams,
11+
AuthAgentCreateRequest,
12+
AuthAgentInvocationCreateRequest,
13+
AuthAgentInvocationCreateResponse,
14+
AuthAgentsOffsetPagination,
15+
AuthCreateParams,
16+
AuthListParams,
1317
DiscoveredField,
1418
} from './auth/auth';
1519

@@ -24,10 +28,14 @@ export declare namespace Agents {
2428
Auth as Auth,
2529
type AgentAuthDiscoverResponse as AgentAuthDiscoverResponse,
2630
type AgentAuthInvocationResponse as AgentAuthInvocationResponse,
27-
type AgentAuthStartResponse as AgentAuthStartResponse,
2831
type AgentAuthSubmitResponse as AgentAuthSubmitResponse,
2932
type AuthAgent as AuthAgent,
33+
type AuthAgentCreateRequest as AuthAgentCreateRequest,
34+
type AuthAgentInvocationCreateRequest as AuthAgentInvocationCreateRequest,
35+
type AuthAgentInvocationCreateResponse as AuthAgentInvocationCreateResponse,
3036
type DiscoveredField as DiscoveredField,
31-
type AuthStartParams as AuthStartParams,
37+
type AuthAgentsOffsetPagination as AuthAgentsOffsetPagination,
38+
type AuthCreateParams as AuthCreateParams,
39+
type AuthListParams as AuthListParams,
3240
};
3341
}

src/resources/agents/auth/auth.ts

Lines changed: 129 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,39 @@
33
import { APIResource } from '../../../core/resource';
44
import * as InvocationsAPI from './invocations';
55
import {
6+
InvocationCreateParams,
67
InvocationDiscoverParams,
78
InvocationExchangeParams,
89
InvocationExchangeResponse,
910
InvocationSubmitParams,
1011
Invocations,
1112
} from './invocations';
1213
import { APIPromise } from '../../../core/api-promise';
14+
import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../../../core/pagination';
1315
import { RequestOptions } from '../../../internal/request-options';
1416
import { path } from '../../../internal/utils/path';
1517

1618
export class Auth extends APIResource {
1719
invocations: InvocationsAPI.Invocations = new InvocationsAPI.Invocations(this._client);
1820

21+
/**
22+
* Creates a new auth agent for the specified domain and profile combination, or
23+
* returns an existing one if it already exists. This is idempotent - calling with
24+
* the same domain and profile will return the same agent. Does NOT start an
25+
* invocation - use POST /agents/auth/invocations to start an auth flow.
26+
*
27+
* @example
28+
* ```ts
29+
* const authAgent = await client.agents.auth.create({
30+
* profile_name: 'user-123',
31+
* target_domain: 'netflix.com',
32+
* });
33+
* ```
34+
*/
35+
create(body: AuthCreateParams, options?: RequestOptions): APIPromise<AuthAgent> {
36+
return this._client.post('/agents/auth', { body, ...options });
37+
}
38+
1939
/**
2040
* Retrieve an auth agent by its ID. Returns the current authentication status of
2141
* the managed profile.
@@ -30,24 +50,26 @@ export class Auth extends APIResource {
3050
}
3151

3252
/**
33-
* Creates a browser session and returns a handoff code for the hosted flow. Uses
34-
* standard API key or JWT authentication (not the JWT returned by the exchange
35-
* endpoint).
53+
* List auth agents with optional filters for profile_name and target_domain.
3654
*
3755
* @example
3856
* ```ts
39-
* const agentAuthStartResponse =
40-
* await client.agents.auth.start({
41-
* profile_name: 'auth-abc123',
42-
* target_domain: 'doordash.com',
43-
* });
57+
* // Automatically fetches more pages as needed.
58+
* for await (const authAgent of client.agents.auth.list()) {
59+
* // ...
60+
* }
4461
* ```
4562
*/
46-
start(body: AuthStartParams, options?: RequestOptions): APIPromise<AgentAuthStartResponse> {
47-
return this._client.post('/agents/auth/start', { body, ...options });
63+
list(
64+
query: AuthListParams | null | undefined = {},
65+
options?: RequestOptions,
66+
): PagePromise<AuthAgentsOffsetPagination, AuthAgent> {
67+
return this._client.getAPIList('/agents/auth', OffsetPagination<AuthAgent>, { query, ...options });
4868
}
4969
}
5070

71+
export type AuthAgentsOffsetPagination = OffsetPagination<AuthAgent>;
72+
5173
/**
5274
* Response from discover endpoint matching AuthBlueprint schema
5375
*/
@@ -108,36 +130,6 @@ export interface AgentAuthInvocationResponse {
108130
target_domain: string;
109131
}
110132

111-
/**
112-
* Response from starting an agent authentication invocation
113-
*/
114-
export interface AgentAuthStartResponse {
115-
/**
116-
* Unique identifier for the auth agent managing this domain/profile
117-
*/
118-
auth_agent_id: string;
119-
120-
/**
121-
* When the handoff code expires
122-
*/
123-
expires_at: string;
124-
125-
/**
126-
* One-time code for handoff
127-
*/
128-
handoff_code: string;
129-
130-
/**
131-
* URL to redirect user to
132-
*/
133-
hosted_url: string;
134-
135-
/**
136-
* Unique identifier for the invocation
137-
*/
138-
invocation_id: string;
139-
}
140-
141133
/**
142134
* Response from submit endpoint matching SubmitResult schema
143135
*/
@@ -205,6 +197,79 @@ export interface AuthAgent {
205197
status: 'AUTHENTICATED' | 'NEEDS_AUTH';
206198
}
207199

200+
/**
201+
* Request to create or find an auth agent
202+
*/
203+
export interface AuthAgentCreateRequest {
204+
/**
205+
* Name of the profile to use for this auth agent
206+
*/
207+
profile_name: string;
208+
209+
/**
210+
* Target domain for authentication
211+
*/
212+
target_domain: string;
213+
214+
/**
215+
* Optional login page URL. If provided, will be stored on the agent and used to
216+
* skip discovery in future invocations.
217+
*/
218+
login_url?: string;
219+
220+
/**
221+
* Optional proxy configuration
222+
*/
223+
proxy?: AuthAgentCreateRequest.Proxy;
224+
}
225+
226+
export namespace AuthAgentCreateRequest {
227+
/**
228+
* Optional proxy configuration
229+
*/
230+
export interface Proxy {
231+
/**
232+
* ID of the proxy to use
233+
*/
234+
proxy_id?: string;
235+
}
236+
}
237+
238+
/**
239+
* Request to create an invocation for an existing auth agent
240+
*/
241+
export interface AuthAgentInvocationCreateRequest {
242+
/**
243+
* ID of the auth agent to create an invocation for
244+
*/
245+
auth_agent_id: string;
246+
}
247+
248+
/**
249+
* Response from creating an auth agent invocation
250+
*/
251+
export interface AuthAgentInvocationCreateResponse {
252+
/**
253+
* When the handoff code expires
254+
*/
255+
expires_at: string;
256+
257+
/**
258+
* One-time code for handoff
259+
*/
260+
handoff_code: string;
261+
262+
/**
263+
* URL to redirect user to
264+
*/
265+
hosted_url: string;
266+
267+
/**
268+
* Unique identifier for the invocation
269+
*/
270+
invocation_id: string;
271+
}
272+
208273
/**
209274
* A discovered form field
210275
*/
@@ -240,9 +305,9 @@ export interface DiscoveredField {
240305
required?: boolean;
241306
}
242307

243-
export interface AuthStartParams {
308+
export interface AuthCreateParams {
244309
/**
245-
* Name of the profile to use for this flow
310+
* Name of the profile to use for this auth agent
246311
*/
247312
profile_name: string;
248313

@@ -251,24 +316,19 @@ export interface AuthStartParams {
251316
*/
252317
target_domain: string;
253318

254-
/**
255-
* Optional logo URL for the application
256-
*/
257-
app_logo_url?: string;
258-
259319
/**
260320
* Optional login page URL. If provided, will be stored on the agent and used to
261-
* skip Phase 1 discovery in future invocations.
321+
* skip discovery in future invocations.
262322
*/
263323
login_url?: string;
264324

265325
/**
266326
* Optional proxy configuration
267327
*/
268-
proxy?: AuthStartParams.Proxy;
328+
proxy?: AuthCreateParams.Proxy;
269329
}
270330

271-
export namespace AuthStartParams {
331+
export namespace AuthCreateParams {
272332
/**
273333
* Optional proxy configuration
274334
*/
@@ -280,22 +340,39 @@ export namespace AuthStartParams {
280340
}
281341
}
282342

343+
export interface AuthListParams extends OffsetPaginationParams {
344+
/**
345+
* Filter by profile name
346+
*/
347+
profile_name?: string;
348+
349+
/**
350+
* Filter by target domain
351+
*/
352+
target_domain?: string;
353+
}
354+
283355
Auth.Invocations = Invocations;
284356

285357
export declare namespace Auth {
286358
export {
287359
type AgentAuthDiscoverResponse as AgentAuthDiscoverResponse,
288360
type AgentAuthInvocationResponse as AgentAuthInvocationResponse,
289-
type AgentAuthStartResponse as AgentAuthStartResponse,
290361
type AgentAuthSubmitResponse as AgentAuthSubmitResponse,
291362
type AuthAgent as AuthAgent,
363+
type AuthAgentCreateRequest as AuthAgentCreateRequest,
364+
type AuthAgentInvocationCreateRequest as AuthAgentInvocationCreateRequest,
365+
type AuthAgentInvocationCreateResponse as AuthAgentInvocationCreateResponse,
292366
type DiscoveredField as DiscoveredField,
293-
type AuthStartParams as AuthStartParams,
367+
type AuthAgentsOffsetPagination as AuthAgentsOffsetPagination,
368+
type AuthCreateParams as AuthCreateParams,
369+
type AuthListParams as AuthListParams,
294370
};
295371

296372
export {
297373
Invocations as Invocations,
298374
type InvocationExchangeResponse as InvocationExchangeResponse,
375+
type InvocationCreateParams as InvocationCreateParams,
299376
type InvocationDiscoverParams as InvocationDiscoverParams,
300377
type InvocationExchangeParams as InvocationExchangeParams,
301378
type InvocationSubmitParams as InvocationSubmitParams,

src/resources/agents/auth/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ export {
44
Auth,
55
type AgentAuthDiscoverResponse,
66
type AgentAuthInvocationResponse,
7-
type AgentAuthStartResponse,
87
type AgentAuthSubmitResponse,
98
type AuthAgent,
9+
type AuthAgentCreateRequest,
10+
type AuthAgentInvocationCreateRequest,
11+
type AuthAgentInvocationCreateResponse,
1012
type DiscoveredField,
11-
type AuthStartParams,
13+
type AuthCreateParams,
14+
type AuthListParams,
15+
type AuthAgentsOffsetPagination,
1216
} from './auth';
1317
export {
1418
Invocations,
1519
type InvocationExchangeResponse,
20+
type InvocationCreateParams,
1621
type InvocationDiscoverParams,
1722
type InvocationExchangeParams,
1823
type InvocationSubmitParams,

0 commit comments

Comments
 (0)