@onkernel/sdk 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +1 -1
  3. package/README.md +7 -2
  4. package/client.d.mts +4 -4
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +4 -4
  7. package/client.d.ts.map +1 -1
  8. package/client.js.map +1 -1
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/agents/agents.d.mts +2 -2
  12. package/resources/agents/agents.d.mts.map +1 -1
  13. package/resources/agents/agents.d.ts +2 -2
  14. package/resources/agents/agents.d.ts.map +1 -1
  15. package/resources/agents/agents.js.map +1 -1
  16. package/resources/agents/agents.mjs.map +1 -1
  17. package/resources/agents/auth/auth.d.mts +107 -129
  18. package/resources/agents/auth/auth.d.mts.map +1 -1
  19. package/resources/agents/auth/auth.d.ts +107 -129
  20. package/resources/agents/auth/auth.d.ts.map +1 -1
  21. package/resources/agents/auth/auth.js +2 -18
  22. package/resources/agents/auth/auth.js.map +1 -1
  23. package/resources/agents/auth/auth.mjs +2 -18
  24. package/resources/agents/auth/auth.mjs.map +1 -1
  25. package/resources/agents/auth/index.d.mts +2 -2
  26. package/resources/agents/auth/index.d.mts.map +1 -1
  27. package/resources/agents/auth/index.d.ts +2 -2
  28. package/resources/agents/auth/index.d.ts.map +1 -1
  29. package/resources/agents/auth/index.js.map +1 -1
  30. package/resources/agents/auth/index.mjs.map +1 -1
  31. package/resources/agents/auth/invocations.d.mts +22 -33
  32. package/resources/agents/auth/invocations.d.mts.map +1 -1
  33. package/resources/agents/auth/invocations.d.ts +22 -33
  34. package/resources/agents/auth/invocations.d.ts.map +1 -1
  35. package/resources/agents/auth/invocations.js +5 -20
  36. package/resources/agents/auth/invocations.js.map +1 -1
  37. package/resources/agents/auth/invocations.mjs +5 -20
  38. package/resources/agents/auth/invocations.mjs.map +1 -1
  39. package/resources/agents/index.d.mts +1 -1
  40. package/resources/agents/index.d.mts.map +1 -1
  41. package/resources/agents/index.d.ts +1 -1
  42. package/resources/agents/index.d.ts.map +1 -1
  43. package/resources/agents/index.js.map +1 -1
  44. package/resources/agents/index.mjs.map +1 -1
  45. package/resources/credentials.d.mts +107 -16
  46. package/resources/credentials.d.mts.map +1 -1
  47. package/resources/credentials.d.ts +107 -16
  48. package/resources/credentials.d.ts.map +1 -1
  49. package/resources/credentials.js +33 -14
  50. package/resources/credentials.js.map +1 -1
  51. package/resources/credentials.mjs +33 -14
  52. package/resources/credentials.mjs.map +1 -1
  53. package/resources/index.d.mts +2 -2
  54. package/resources/index.d.mts.map +1 -1
  55. package/resources/index.d.ts +2 -2
  56. package/resources/index.d.ts.map +1 -1
  57. package/resources/index.js.map +1 -1
  58. package/resources/index.mjs.map +1 -1
  59. package/resources/proxies.d.mts +137 -1
  60. package/resources/proxies.d.mts.map +1 -1
  61. package/resources/proxies.d.ts +137 -1
  62. package/resources/proxies.d.ts.map +1 -1
  63. package/resources/proxies.js +6 -0
  64. package/resources/proxies.js.map +1 -1
  65. package/resources/proxies.mjs +6 -0
  66. package/resources/proxies.mjs.map +1 -1
  67. package/src/client.ts +4 -0
  68. package/src/resources/agents/agents.ts +0 -4
  69. package/src/resources/agents/auth/auth.ts +114 -141
  70. package/src/resources/agents/auth/index.ts +0 -3
  71. package/src/resources/agents/auth/invocations.ts +21 -39
  72. package/src/resources/agents/index.ts +0 -2
  73. package/src/resources/credentials.ts +127 -18
  74. package/src/resources/index.ts +2 -0
  75. package/src/resources/proxies.ts +228 -0
  76. package/src/version.ts +1 -1
  77. package/version.d.mts +1 -1
  78. package/version.d.ts +1 -1
  79. package/version.js +1 -1
  80. package/version.mjs +1 -1
@@ -4,7 +4,6 @@ import { APIResource } from '../../../core/resource';
4
4
  import * as InvocationsAPI from './invocations';
5
5
  import {
6
6
  InvocationCreateParams,
7
- InvocationDiscoverParams,
8
7
  InvocationExchangeParams,
9
8
  InvocationExchangeResponse,
10
9
  InvocationSubmitParams,
@@ -28,8 +27,8 @@ export class Auth extends APIResource {
28
27
  * @example
29
28
  * ```ts
30
29
  * const authAgent = await client.agents.auth.create({
30
+ * domain: 'netflix.com',
31
31
  * profile_name: 'user-123',
32
- * target_domain: 'netflix.com',
33
32
  * });
34
33
  * ```
35
34
  */
@@ -51,7 +50,7 @@ export class Auth extends APIResource {
51
50
  }
52
51
 
53
52
  /**
54
- * List auth agents with optional filters for profile_name and target_domain.
53
+ * List auth agents with optional filters for profile_name and domain.
55
54
  *
56
55
  * @example
57
56
  * ```ts
@@ -86,126 +85,117 @@ export class Auth extends APIResource {
86
85
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
87
86
  });
88
87
  }
89
-
90
- /**
91
- * Triggers automatic re-authentication for an auth agent using stored credentials.
92
- * Requires the auth agent to have a linked credential, stored selectors, and
93
- * login_url. Returns immediately with status indicating whether re-auth was
94
- * started.
95
- *
96
- * @example
97
- * ```ts
98
- * const reauthResponse = await client.agents.auth.reauth(
99
- * 'id',
100
- * );
101
- * ```
102
- */
103
- reauth(id: string, options?: RequestOptions): APIPromise<ReauthResponse> {
104
- return this._client.post(path`/agents/auth/${id}/reauth`, options);
105
- }
106
88
  }
107
89
 
108
90
  export type AuthAgentsOffsetPagination = OffsetPagination<AuthAgent>;
109
91
 
110
92
  /**
111
- * Response from discover endpoint matching AuthBlueprint schema
93
+ * Response from get invocation endpoint
112
94
  */
113
- export interface AgentAuthDiscoverResponse {
114
- /**
115
- * Whether discovery succeeded
116
- */
117
- success: boolean;
118
-
95
+ export interface AgentAuthInvocationResponse {
119
96
  /**
120
- * Error message if discovery failed
97
+ * App name (org name at time of invocation creation)
121
98
  */
122
- error_message?: string;
99
+ app_name: string;
123
100
 
124
101
  /**
125
- * Discovered form fields (present when success is true)
102
+ * Domain for authentication
126
103
  */
127
- fields?: Array<DiscoveredField>;
104
+ domain: string;
128
105
 
129
106
  /**
130
- * Whether user is already logged in
107
+ * When the handoff code expires
131
108
  */
132
- logged_in?: boolean;
109
+ expires_at: string;
133
110
 
134
111
  /**
135
- * URL of the discovered login page
112
+ * Invocation status
136
113
  */
137
- login_url?: string;
114
+ status: 'IN_PROGRESS' | 'SUCCESS' | 'EXPIRED' | 'CANCELED' | 'FAILED';
138
115
 
139
116
  /**
140
- * Title of the login page
117
+ * Current step in the invocation workflow
141
118
  */
142
- page_title?: string;
143
- }
119
+ step:
120
+ | 'initialized'
121
+ | 'discovering'
122
+ | 'awaiting_input'
123
+ | 'awaiting_external_action'
124
+ | 'submitting'
125
+ | 'completed'
126
+ | 'expired';
144
127
 
145
- /**
146
- * Response from get invocation endpoint
147
- */
148
- export interface AgentAuthInvocationResponse {
149
128
  /**
150
- * App name (org name at time of invocation creation)
129
+ * The invocation type:
130
+ *
131
+ * - login: First-time authentication
132
+ * - reauth: Re-authentication for previously authenticated agents
133
+ * - auto_login: Legacy type (no longer created, kept for backward compatibility)
151
134
  */
152
- app_name: string;
135
+ type: 'login' | 'auto_login' | 'reauth';
153
136
 
154
137
  /**
155
- * When the handoff code expires
138
+ * Error message explaining why the invocation failed (present when status=FAILED)
156
139
  */
157
- expires_at: string;
140
+ error_message?: string | null;
158
141
 
159
142
  /**
160
- * Invocation status
143
+ * Instructions for user when external action is required (present when
144
+ * step=awaiting_external_action)
161
145
  */
162
- status: 'IN_PROGRESS' | 'SUCCESS' | 'EXPIRED' | 'CANCELED';
146
+ external_action_message?: string | null;
163
147
 
164
148
  /**
165
- * Target domain for authentication
149
+ * Browser live view URL for debugging the invocation
166
150
  */
167
- target_domain: string;
168
- }
151
+ live_view_url?: string | null;
169
152
 
170
- /**
171
- * Response from submit endpoint matching SubmitResult schema
172
- */
173
- export interface AgentAuthSubmitResponse {
174
153
  /**
175
- * Whether submission succeeded
154
+ * Fields currently awaiting input (present when step=awaiting_input)
176
155
  */
177
- success: boolean;
156
+ pending_fields?: Array<DiscoveredField> | null;
178
157
 
179
158
  /**
180
- * Additional fields needed (e.g., OTP) - present when needs_additional_auth is
181
- * true
159
+ * SSO buttons available on the page (present when step=awaiting_input)
182
160
  */
183
- additional_fields?: Array<DiscoveredField>;
161
+ pending_sso_buttons?: Array<AgentAuthInvocationResponse.PendingSSOButton> | null;
184
162
 
185
163
  /**
186
- * App name (only present when logged_in is true)
164
+ * Names of fields that have been submitted (present when step=submitting or later)
187
165
  */
188
- app_name?: string;
166
+ submitted_fields?: Array<string> | null;
167
+ }
189
168
 
169
+ export namespace AgentAuthInvocationResponse {
190
170
  /**
191
- * Error message if submission failed
171
+ * An SSO button for signing in with an external identity provider
192
172
  */
193
- error_message?: string;
173
+ export interface PendingSSOButton {
174
+ /**
175
+ * Visible button text
176
+ */
177
+ label: string;
194
178
 
195
- /**
196
- * Whether user is now logged in
197
- */
198
- logged_in?: boolean;
179
+ /**
180
+ * Identity provider name
181
+ */
182
+ provider: string;
199
183
 
200
- /**
201
- * Whether additional authentication fields are needed
202
- */
203
- needs_additional_auth?: boolean;
184
+ /**
185
+ * XPath selector for the button
186
+ */
187
+ selector: string;
188
+ }
189
+ }
204
190
 
191
+ /**
192
+ * Response from submit endpoint - returns immediately after submission is accepted
193
+ */
194
+ export interface AgentAuthSubmitResponse {
205
195
  /**
206
- * Target domain (only present when logged_in is true)
196
+ * Whether the submission was accepted for processing
207
197
  */
208
- target_domain?: string;
198
+ accepted: boolean;
209
199
  }
210
200
 
211
201
  /**
@@ -233,6 +223,13 @@ export interface AuthAgent {
233
223
  */
234
224
  status: 'AUTHENTICATED' | 'NEEDS_AUTH';
235
225
 
226
+ /**
227
+ * Additional domains that are valid for this auth agent's authentication flow
228
+ * (besides the primary domain). Useful when login pages redirect to different
229
+ * domains.
230
+ */
231
+ allowed_domains?: Array<string>;
232
+
236
233
  /**
237
234
  * Whether automatic re-authentication is possible (has credential_id, selectors,
238
235
  * and login_url)
@@ -264,15 +261,22 @@ export interface AuthAgent {
264
261
  * Request to create or find an auth agent
265
262
  */
266
263
  export interface AuthAgentCreateRequest {
264
+ /**
265
+ * Domain for authentication
266
+ */
267
+ domain: string;
268
+
267
269
  /**
268
270
  * Name of the profile to use for this auth agent
269
271
  */
270
272
  profile_name: string;
271
273
 
272
274
  /**
273
- * Target domain for authentication
275
+ * Additional domains that are valid for this auth agent's authentication flow
276
+ * (besides the primary domain). Useful when login pages redirect to different
277
+ * domains.
274
278
  */
275
- target_domain: string;
279
+ allowed_domains?: Array<string>;
276
280
 
277
281
  /**
278
282
  * Optional name of an existing credential to use for this auth agent. If provided,
@@ -323,52 +327,37 @@ export interface AuthAgentInvocationCreateRequest {
323
327
  }
324
328
 
325
329
  /**
326
- * Response when the agent is already authenticated.
330
+ * Response from creating an invocation. Always returns an invocation_id.
327
331
  */
328
- export type AuthAgentInvocationCreateResponse =
329
- | AuthAgentInvocationCreateResponse.AuthAgentAlreadyAuthenticated
330
- | AuthAgentInvocationCreateResponse.AuthAgentInvocationCreated;
331
-
332
- export namespace AuthAgentInvocationCreateResponse {
332
+ export interface AuthAgentInvocationCreateResponse {
333
333
  /**
334
- * Response when the agent is already authenticated.
334
+ * When the handoff code expires.
335
335
  */
336
- export interface AuthAgentAlreadyAuthenticated {
337
- /**
338
- * Indicates the agent is already authenticated and no invocation was created.
339
- */
340
- status: 'already_authenticated';
341
- }
336
+ expires_at: string;
342
337
 
343
338
  /**
344
- * Response when a new invocation was created.
339
+ * One-time code for handoff.
345
340
  */
346
- export interface AuthAgentInvocationCreated {
347
- /**
348
- * When the handoff code expires.
349
- */
350
- expires_at: string;
351
-
352
- /**
353
- * One-time code for handoff.
354
- */
355
- handoff_code: string;
341
+ handoff_code: string;
356
342
 
357
- /**
358
- * URL to redirect user to.
359
- */
360
- hosted_url: string;
343
+ /**
344
+ * URL to redirect user to.
345
+ */
346
+ hosted_url: string;
361
347
 
362
- /**
363
- * Unique identifier for the invocation.
364
- */
365
- invocation_id: string;
348
+ /**
349
+ * Unique identifier for the invocation.
350
+ */
351
+ invocation_id: string;
366
352
 
367
- /**
368
- * Indicates an invocation was created.
369
- */
370
- status: 'invocation_created';
371
- }
353
+ /**
354
+ * The invocation type:
355
+ *
356
+ * - login: First-time authentication
357
+ * - reauth: Re-authentication for previously authenticated agents
358
+ * - auto_login: Legacy type (no longer created, kept for backward compatibility)
359
+ */
360
+ type: 'login' | 'auto_login' | 'reauth';
372
361
  }
373
362
 
374
363
  /**
@@ -393,7 +382,7 @@ export interface DiscoveredField {
393
382
  /**
394
383
  * Field type
395
384
  */
396
- type: 'text' | 'email' | 'password' | 'tel' | 'number' | 'url' | 'code';
385
+ type: 'text' | 'email' | 'password' | 'tel' | 'number' | 'url' | 'code' | 'totp';
397
386
 
398
387
  /**
399
388
  * Field placeholder
@@ -406,36 +395,23 @@ export interface DiscoveredField {
406
395
  required?: boolean;
407
396
  }
408
397
 
409
- /**
410
- * Response from triggering re-authentication
411
- */
412
- export interface ReauthResponse {
413
- /**
414
- * Result of the re-authentication attempt
415
- */
416
- status: 'reauth_started' | 'already_authenticated' | 'cannot_reauth';
417
-
418
- /**
419
- * ID of the re-auth invocation if one was created
420
- */
421
- invocation_id?: string;
422
-
398
+ export interface AuthCreateParams {
423
399
  /**
424
- * Human-readable description of the result
400
+ * Domain for authentication
425
401
  */
426
- message?: string;
427
- }
402
+ domain: string;
428
403
 
429
- export interface AuthCreateParams {
430
404
  /**
431
405
  * Name of the profile to use for this auth agent
432
406
  */
433
407
  profile_name: string;
434
408
 
435
409
  /**
436
- * Target domain for authentication
410
+ * Additional domains that are valid for this auth agent's authentication flow
411
+ * (besides the primary domain). Useful when login pages redirect to different
412
+ * domains.
437
413
  */
438
- target_domain: string;
414
+ allowed_domains?: Array<string>;
439
415
 
440
416
  /**
441
417
  * Optional name of an existing credential to use for this auth agent. If provided,
@@ -470,21 +446,20 @@ export namespace AuthCreateParams {
470
446
 
471
447
  export interface AuthListParams extends OffsetPaginationParams {
472
448
  /**
473
- * Filter by profile name
449
+ * Filter by domain
474
450
  */
475
- profile_name?: string;
451
+ domain?: string;
476
452
 
477
453
  /**
478
- * Filter by target domain
454
+ * Filter by profile name
479
455
  */
480
- target_domain?: string;
456
+ profile_name?: string;
481
457
  }
482
458
 
483
459
  Auth.Invocations = Invocations;
484
460
 
485
461
  export declare namespace Auth {
486
462
  export {
487
- type AgentAuthDiscoverResponse as AgentAuthDiscoverResponse,
488
463
  type AgentAuthInvocationResponse as AgentAuthInvocationResponse,
489
464
  type AgentAuthSubmitResponse as AgentAuthSubmitResponse,
490
465
  type AuthAgent as AuthAgent,
@@ -492,7 +467,6 @@ export declare namespace Auth {
492
467
  type AuthAgentInvocationCreateRequest as AuthAgentInvocationCreateRequest,
493
468
  type AuthAgentInvocationCreateResponse as AuthAgentInvocationCreateResponse,
494
469
  type DiscoveredField as DiscoveredField,
495
- type ReauthResponse as ReauthResponse,
496
470
  type AuthAgentsOffsetPagination as AuthAgentsOffsetPagination,
497
471
  type AuthCreateParams as AuthCreateParams,
498
472
  type AuthListParams as AuthListParams,
@@ -502,7 +476,6 @@ export declare namespace Auth {
502
476
  Invocations as Invocations,
503
477
  type InvocationExchangeResponse as InvocationExchangeResponse,
504
478
  type InvocationCreateParams as InvocationCreateParams,
505
- type InvocationDiscoverParams as InvocationDiscoverParams,
506
479
  type InvocationExchangeParams as InvocationExchangeParams,
507
480
  type InvocationSubmitParams as InvocationSubmitParams,
508
481
  };
@@ -2,7 +2,6 @@
2
2
 
3
3
  export {
4
4
  Auth,
5
- type AgentAuthDiscoverResponse,
6
5
  type AgentAuthInvocationResponse,
7
6
  type AgentAuthSubmitResponse,
8
7
  type AuthAgent,
@@ -10,7 +9,6 @@ export {
10
9
  type AuthAgentInvocationCreateRequest,
11
10
  type AuthAgentInvocationCreateResponse,
12
11
  type DiscoveredField,
13
- type ReauthResponse,
14
12
  type AuthCreateParams,
15
13
  type AuthListParams,
16
14
  type AuthAgentsOffsetPagination,
@@ -19,7 +17,6 @@ export {
19
17
  Invocations,
20
18
  type InvocationExchangeResponse,
21
19
  type InvocationCreateParams,
22
- type InvocationDiscoverParams,
23
20
  type InvocationExchangeParams,
24
21
  type InvocationSubmitParams,
25
22
  } from './invocations';
@@ -28,8 +28,8 @@ export class Invocations extends APIResource {
28
28
  }
29
29
 
30
30
  /**
31
- * Returns invocation details including app_name and target_domain. Uses the JWT
32
- * returned by the exchange endpoint, or standard API key or JWT authentication.
31
+ * Returns invocation details including status, app_name, and domain. Supports both
32
+ * API key and JWT (from exchange endpoint) authentication.
33
33
  *
34
34
  * @example
35
35
  * ```ts
@@ -43,27 +43,6 @@ export class Invocations extends APIResource {
43
43
  return this._client.get(path`/agents/auth/invocations/${invocationID}`, options);
44
44
  }
45
45
 
46
- /**
47
- * Inspects the target site to detect logged-in state or discover required fields.
48
- * Returns 200 with success: true when fields are found, or 4xx/5xx for failures.
49
- * Requires the JWT returned by the exchange endpoint.
50
- *
51
- * @example
52
- * ```ts
53
- * const agentAuthDiscoverResponse =
54
- * await client.agents.auth.invocations.discover(
55
- * 'invocation_id',
56
- * );
57
- * ```
58
- */
59
- discover(
60
- invocationID: string,
61
- body: InvocationDiscoverParams | null | undefined = {},
62
- options?: RequestOptions,
63
- ): APIPromise<AuthAPI.AgentAuthDiscoverResponse> {
64
- return this._client.post(path`/agents/auth/invocations/${invocationID}/discover`, { body, ...options });
65
- }
66
-
67
46
  /**
68
47
  * Validates the handoff code and returns a JWT token for subsequent requests. No
69
48
  * authentication required (the handoff code serves as the credential).
@@ -86,8 +65,9 @@ export class Invocations extends APIResource {
86
65
  }
87
66
 
88
67
  /**
89
- * Submits field values for the discovered login form and may return additional
90
- * auth fields or success. Requires the JWT returned by the exchange endpoint.
68
+ * Submits field values for the discovered login form. Returns immediately after
69
+ * submission is accepted. Poll the invocation endpoint to track progress and get
70
+ * results.
91
71
  *
92
72
  * @example
93
73
  * ```ts
@@ -141,14 +121,6 @@ export interface InvocationCreateParams {
141
121
  save_credential_as?: string;
142
122
  }
143
123
 
144
- export interface InvocationDiscoverParams {
145
- /**
146
- * Optional login page URL. If provided, will override the stored login URL for
147
- * this discovery invocation and skip Phase 1 discovery.
148
- */
149
- login_url?: string;
150
- }
151
-
152
124
  export interface InvocationExchangeParams {
153
125
  /**
154
126
  * Handoff code from start endpoint
@@ -156,18 +128,28 @@ export interface InvocationExchangeParams {
156
128
  code: string;
157
129
  }
158
130
 
159
- export interface InvocationSubmitParams {
160
- /**
161
- * Values for the discovered login fields
162
- */
163
- field_values: { [key: string]: string };
131
+ export type InvocationSubmitParams = InvocationSubmitParams.Variant0 | InvocationSubmitParams.Variant1;
132
+
133
+ export declare namespace InvocationSubmitParams {
134
+ export interface Variant0 {
135
+ /**
136
+ * Values for the discovered login fields
137
+ */
138
+ field_values: { [key: string]: string };
139
+ }
140
+
141
+ export interface Variant1 {
142
+ /**
143
+ * Selector of SSO button to click
144
+ */
145
+ sso_button: string;
146
+ }
164
147
  }
165
148
 
166
149
  export declare namespace Invocations {
167
150
  export {
168
151
  type InvocationExchangeResponse as InvocationExchangeResponse,
169
152
  type InvocationCreateParams as InvocationCreateParams,
170
- type InvocationDiscoverParams as InvocationDiscoverParams,
171
153
  type InvocationExchangeParams as InvocationExchangeParams,
172
154
  type InvocationSubmitParams as InvocationSubmitParams,
173
155
  };
@@ -3,7 +3,6 @@
3
3
  export { Agents } from './agents';
4
4
  export {
5
5
  Auth,
6
- type AgentAuthDiscoverResponse,
7
6
  type AgentAuthInvocationResponse,
8
7
  type AgentAuthSubmitResponse,
9
8
  type AuthAgent,
@@ -11,7 +10,6 @@ export {
11
10
  type AuthAgentInvocationCreateRequest,
12
11
  type AuthAgentInvocationCreateResponse,
13
12
  type DiscoveredField,
14
- type ReauthResponse,
15
13
  type AuthCreateParams,
16
14
  type AuthListParams,
17
15
  type AuthAgentsOffsetPagination,