Skip to content

Commit 963aaf2

Browse files
feat: Mason/agent auth api
1 parent 852af5e commit 963aaf2

File tree

13 files changed

+591
-4
lines changed

13 files changed

+591
-4
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: 66
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2af1b468584cb44aa9babbbfb82bff4055614fbb5c815084a6b7dacc1cf1a822.yml
3-
openapi_spec_hash: 891affa2849341ea01d62011125f7edc
4-
config_hash: 9421eb86b7f3f4b274f123279da3858e
1+
configured_endpoints: 71
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-bb3f37e55117a56e7a4208bd646d3a68adeb651ced8531e13fbfc1fc9dcb05a4.yml
3+
openapi_spec_hash: 7303ce8ce3130e16a6a5c2bb49e43e9b
4+
config_hash: be146470fb2d4583b6533859f0fa48f5

api.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,32 @@ Methods:
220220
- <code title="get /extensions/{id_or_name}">client.extensions.<a href="./src/resources/extensions.ts">download</a>(idOrName) -> Response</code>
221221
- <code title="get /extensions/from_chrome_store">client.extensions.<a href="./src/resources/extensions.ts">downloadFromChromeStore</a>({ ...params }) -> Response</code>
222222
- <code title="post /extensions">client.extensions.<a href="./src/resources/extensions.ts">upload</a>({ ...params }) -> ExtensionUploadResponse</code>
223+
224+
# Agents
225+
226+
## Auth
227+
228+
Types:
229+
230+
- <code><a href="./src/resources/agents/auth/auth.ts">AgentAuthDiscoverResponse</a></code>
231+
- <code><a href="./src/resources/agents/auth/auth.ts">AgentAuthRunResponse</a></code>
232+
- <code><a href="./src/resources/agents/auth/auth.ts">AgentAuthStartResponse</a></code>
233+
- <code><a href="./src/resources/agents/auth/auth.ts">AgentAuthSubmitResponse</a></code>
234+
- <code><a href="./src/resources/agents/auth/auth.ts">DiscoveredField</a></code>
235+
236+
Methods:
237+
238+
- <code title="post /agents/auth/start">client.agents.auth.<a href="./src/resources/agents/auth/auth.ts">start</a>({ ...params }) -> AgentAuthStartResponse</code>
239+
240+
### Runs
241+
242+
Types:
243+
244+
- <code><a href="./src/resources/agents/auth/runs.ts">RunExchangeResponse</a></code>
245+
246+
Methods:
247+
248+
- <code title="get /agents/auth/runs/{run_id}">client.agents.auth.runs.<a href="./src/resources/agents/auth/runs.ts">retrieve</a>(runID) -> AgentAuthRunResponse</code>
249+
- <code title="post /agents/auth/runs/{run_id}/discover">client.agents.auth.runs.<a href="./src/resources/agents/auth/runs.ts">discover</a>(runID) -> AgentAuthDiscoverResponse</code>
250+
- <code title="post /agents/auth/runs/{run_id}/exchange">client.agents.auth.runs.<a href="./src/resources/agents/auth/runs.ts">exchange</a>(runID, { ...params }) -> RunExchangeResponse</code>
251+
- <code title="post /agents/auth/runs/{run_id}/submit">client.agents.auth.runs.<a href="./src/resources/agents/auth/runs.ts">submit</a>(runID, { ...params }) -> AgentAuthSubmitResponse</code>

src/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import {
6161
ProxyListResponse,
6262
ProxyRetrieveResponse,
6363
} from './resources/proxies';
64+
import { Agents } from './resources/agents/agents';
6465
import {
6566
BrowserCreateParams,
6667
BrowserCreateResponse,
@@ -843,6 +844,7 @@ export class Kernel {
843844
profiles: API.Profiles = new API.Profiles(this);
844845
proxies: API.Proxies = new API.Proxies(this);
845846
extensions: API.Extensions = new API.Extensions(this);
847+
agents: API.Agents = new API.Agents(this);
846848
}
847849

848850
Kernel.Deployments = Deployments;
@@ -852,6 +854,7 @@ Kernel.Browsers = Browsers;
852854
Kernel.Profiles = Profiles;
853855
Kernel.Proxies = Proxies;
854856
Kernel.Extensions = Extensions;
857+
Kernel.Agents = Agents;
855858

856859
export declare namespace Kernel {
857860
export type RequestOptions = Opts.RequestOptions;
@@ -933,6 +936,8 @@ export declare namespace Kernel {
933936
type ExtensionUploadParams as ExtensionUploadParams,
934937
};
935938

939+
export { Agents as Agents };
940+
936941
export type AppAction = API.AppAction;
937942
export type ErrorDetail = API.ErrorDetail;
938943
export type ErrorEvent = API.ErrorEvent;

src/resources/agents.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export * from './agents/index';

src/resources/agents/agents.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../core/resource';
4+
import * as AuthAPI from './auth/auth';
5+
import {
6+
AgentAuthDiscoverResponse,
7+
AgentAuthRunResponse,
8+
AgentAuthStartResponse,
9+
AgentAuthSubmitResponse,
10+
Auth,
11+
AuthStartParams,
12+
DiscoveredField,
13+
} from './auth/auth';
14+
15+
export class Agents extends APIResource {
16+
auth: AuthAPI.Auth = new AuthAPI.Auth(this._client);
17+
}
18+
19+
Agents.Auth = Auth;
20+
21+
export declare namespace Agents {
22+
export {
23+
Auth as Auth,
24+
type AgentAuthDiscoverResponse as AgentAuthDiscoverResponse,
25+
type AgentAuthRunResponse as AgentAuthRunResponse,
26+
type AgentAuthStartResponse as AgentAuthStartResponse,
27+
type AgentAuthSubmitResponse as AgentAuthSubmitResponse,
28+
type DiscoveredField as DiscoveredField,
29+
type AuthStartParams as AuthStartParams,
30+
};
31+
}

src/resources/agents/auth.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export * from './auth/index';

src/resources/agents/auth/auth.ts

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../../core/resource';
4+
import * as RunsAPI from './runs';
5+
import { RunDiscoverParams, RunExchangeParams, RunExchangeResponse, RunSubmitParams, Runs } from './runs';
6+
import { APIPromise } from '../../../core/api-promise';
7+
import { RequestOptions } from '../../../internal/request-options';
8+
9+
export class Auth extends APIResource {
10+
runs: RunsAPI.Runs = new RunsAPI.Runs(this._client);
11+
12+
/**
13+
* Creates a browser session and returns a handoff code for the hosted flow. Uses
14+
* standard API key or JWT authentication (not the JWT returned by the exchange
15+
* endpoint).
16+
*
17+
* @example
18+
* ```ts
19+
* const agentAuthStartResponse =
20+
* await client.agents.auth.start({
21+
* profile_name: 'auth-abc123',
22+
* target_domain: 'doordash.com',
23+
* });
24+
* ```
25+
*/
26+
start(body: AuthStartParams, options?: RequestOptions): APIPromise<AgentAuthStartResponse> {
27+
return this._client.post('/agents/auth/start', { body, ...options });
28+
}
29+
}
30+
31+
/**
32+
* Response from discover endpoint matching AuthBlueprint schema
33+
*/
34+
export interface AgentAuthDiscoverResponse {
35+
/**
36+
* Whether discovery succeeded
37+
*/
38+
success: boolean;
39+
40+
/**
41+
* Error message if discovery failed
42+
*/
43+
error_message?: string;
44+
45+
/**
46+
* Discovered form fields (present when success is true)
47+
*/
48+
fields?: Array<DiscoveredField>;
49+
50+
/**
51+
* Whether user is already logged in
52+
*/
53+
logged_in?: boolean;
54+
55+
/**
56+
* URL of the discovered login page
57+
*/
58+
login_url?: string;
59+
60+
/**
61+
* Title of the login page
62+
*/
63+
page_title?: string;
64+
}
65+
66+
/**
67+
* Response from get run endpoint
68+
*/
69+
export interface AgentAuthRunResponse {
70+
/**
71+
* App name (org name at time of run creation)
72+
*/
73+
app_name: string;
74+
75+
/**
76+
* When the handoff code expires
77+
*/
78+
expires_at: string;
79+
80+
/**
81+
* Run status
82+
*/
83+
status: 'ACTIVE' | 'ENDED' | 'EXPIRED' | 'CANCELED';
84+
85+
/**
86+
* Target domain for authentication
87+
*/
88+
target_domain: string;
89+
}
90+
91+
/**
92+
* Response from starting an agent authentication run
93+
*/
94+
export interface AgentAuthStartResponse {
95+
/**
96+
* When the handoff code expires
97+
*/
98+
expires_at: string;
99+
100+
/**
101+
* One-time code for handoff
102+
*/
103+
handoff_code: string;
104+
105+
/**
106+
* URL to redirect user to
107+
*/
108+
hosted_url: string;
109+
110+
/**
111+
* Unique identifier for the run
112+
*/
113+
run_id: string;
114+
}
115+
116+
/**
117+
* Response from submit endpoint matching SubmitResult schema
118+
*/
119+
export interface AgentAuthSubmitResponse {
120+
/**
121+
* Whether submission succeeded
122+
*/
123+
success: boolean;
124+
125+
/**
126+
* Additional fields needed (e.g., OTP) - present when needs_additional_auth is
127+
* true
128+
*/
129+
additional_fields?: Array<DiscoveredField>;
130+
131+
/**
132+
* App name (only present when logged_in is true)
133+
*/
134+
app_name?: string;
135+
136+
/**
137+
* Error message if submission failed
138+
*/
139+
error_message?: string;
140+
141+
/**
142+
* Whether user is now logged in
143+
*/
144+
logged_in?: boolean;
145+
146+
/**
147+
* Whether additional authentication fields are needed
148+
*/
149+
needs_additional_auth?: boolean;
150+
151+
/**
152+
* Target domain (only present when logged_in is true)
153+
*/
154+
target_domain?: string;
155+
}
156+
157+
/**
158+
* A discovered form field
159+
*/
160+
export interface DiscoveredField {
161+
/**
162+
* Field label
163+
*/
164+
label: string;
165+
166+
/**
167+
* Field name
168+
*/
169+
name: string;
170+
171+
/**
172+
* CSS selector for the field
173+
*/
174+
selector: string;
175+
176+
/**
177+
* Field type
178+
*/
179+
type: 'text' | 'email' | 'password' | 'tel' | 'number' | 'url' | 'code' | 'checkbox';
180+
181+
/**
182+
* Field placeholder
183+
*/
184+
placeholder?: string;
185+
186+
/**
187+
* Whether field is required
188+
*/
189+
required?: boolean;
190+
}
191+
192+
export interface AuthStartParams {
193+
/**
194+
* Name of the profile to use for this flow
195+
*/
196+
profile_name: string;
197+
198+
/**
199+
* Target domain for authentication
200+
*/
201+
target_domain: string;
202+
203+
/**
204+
* Optional logo URL for the application
205+
*/
206+
app_logo_url?: string;
207+
208+
/**
209+
* Optional proxy configuration
210+
*/
211+
proxy?: AuthStartParams.Proxy;
212+
}
213+
214+
export namespace AuthStartParams {
215+
/**
216+
* Optional proxy configuration
217+
*/
218+
export interface Proxy {
219+
/**
220+
* ID of the proxy to use
221+
*/
222+
proxy_id?: string;
223+
}
224+
}
225+
226+
Auth.Runs = Runs;
227+
228+
export declare namespace Auth {
229+
export {
230+
type AgentAuthDiscoverResponse as AgentAuthDiscoverResponse,
231+
type AgentAuthRunResponse as AgentAuthRunResponse,
232+
type AgentAuthStartResponse as AgentAuthStartResponse,
233+
type AgentAuthSubmitResponse as AgentAuthSubmitResponse,
234+
type DiscoveredField as DiscoveredField,
235+
type AuthStartParams as AuthStartParams,
236+
};
237+
238+
export {
239+
Runs as Runs,
240+
type RunExchangeResponse as RunExchangeResponse,
241+
type RunDiscoverParams as RunDiscoverParams,
242+
type RunExchangeParams as RunExchangeParams,
243+
type RunSubmitParams as RunSubmitParams,
244+
};
245+
}

src/resources/agents/auth/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export {
4+
Auth,
5+
type AgentAuthDiscoverResponse,
6+
type AgentAuthRunResponse,
7+
type AgentAuthStartResponse,
8+
type AgentAuthSubmitResponse,
9+
type DiscoveredField,
10+
type AuthStartParams,
11+
} from './auth';
12+
export {
13+
Runs,
14+
type RunExchangeResponse,
15+
type RunDiscoverParams,
16+
type RunExchangeParams,
17+
type RunSubmitParams,
18+
} from './runs';

0 commit comments

Comments
 (0)