33import { APIResource } from '../../../core/resource' ;
44import * as InvocationsAPI from './invocations' ;
55import {
6+ InvocationCreateParams ,
67 InvocationDiscoverParams ,
78 InvocationExchangeParams ,
89 InvocationExchangeResponse ,
910 InvocationSubmitParams ,
1011 Invocations ,
1112} from './invocations' ;
1213import { APIPromise } from '../../../core/api-promise' ;
14+ import { OffsetPagination , type OffsetPaginationParams , PagePromise } from '../../../core/pagination' ;
1315import { RequestOptions } from '../../../internal/request-options' ;
1416import { path } from '../../../internal/utils/path' ;
1517
1618export 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+
283355Auth . Invocations = Invocations ;
284356
285357export 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 ,
0 commit comments