Skip to content

Commit ccb1425

Browse files
feat: Enhance AuthAgentInvocation with step and last activity tracking
1 parent 0320876 commit ccb1425

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 89
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-13214b99e392aab631aa1ca99b6a51a58df81e34156d21b8d639bea779566123.yml
3-
openapi_spec_hash: a88d175fc3980de3097ac1411d8dcbff
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2cf104c4b88159c6a50713b019188f83983748b9cacec598089cf9068dc5b1cd.yml
3+
openapi_spec_hash: 84ea30ae65ad7ebcc04d2f3907d1e73b
44
config_hash: 179f33af31ece83563163d5b3d751d13

agentauth.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,19 @@ type AgentAuthInvocationResponse struct {
166166
//
167167
// Any of "IN_PROGRESS", "SUCCESS", "EXPIRED", "CANCELED".
168168
Status AgentAuthInvocationResponseStatus `json:"status,required"`
169+
// Current step in the invocation workflow
170+
//
171+
// Any of "initialized", "discovering", "awaiting_input", "submitting",
172+
// "completed", "expired".
173+
Step AgentAuthInvocationResponseStep `json:"step,required"`
169174
// Target domain for authentication
170175
TargetDomain string `json:"target_domain,required"`
171176
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
172177
JSON struct {
173178
AppName respjson.Field
174179
ExpiresAt respjson.Field
175180
Status respjson.Field
181+
Step respjson.Field
176182
TargetDomain respjson.Field
177183
ExtraFields map[string]respjson.Field
178184
raw string
@@ -195,6 +201,18 @@ const (
195201
AgentAuthInvocationResponseStatusCanceled AgentAuthInvocationResponseStatus = "CANCELED"
196202
)
197203

204+
// Current step in the invocation workflow
205+
type AgentAuthInvocationResponseStep string
206+
207+
const (
208+
AgentAuthInvocationResponseStepInitialized AgentAuthInvocationResponseStep = "initialized"
209+
AgentAuthInvocationResponseStepDiscovering AgentAuthInvocationResponseStep = "discovering"
210+
AgentAuthInvocationResponseStepAwaitingInput AgentAuthInvocationResponseStep = "awaiting_input"
211+
AgentAuthInvocationResponseStepSubmitting AgentAuthInvocationResponseStep = "submitting"
212+
AgentAuthInvocationResponseStepCompleted AgentAuthInvocationResponseStep = "completed"
213+
AgentAuthInvocationResponseStepExpired AgentAuthInvocationResponseStep = "expired"
214+
)
215+
198216
// Response from submit endpoint matching SubmitResult schema
199217
type AgentAuthSubmitResponse struct {
200218
// Whether submission succeeded
@@ -359,7 +377,7 @@ func (r *AuthAgentInvocationCreateRequestParam) UnmarshalJSON(data []byte) error
359377
//
360378
// Use the methods beginning with 'As' to cast the union to one of its variants.
361379
type AuthAgentInvocationCreateResponseUnion struct {
362-
// Any of "already_authenticated", "invocation_created".
380+
// Any of "ALREADY_AUTHENTICATED", "INVOCATION_CREATED".
363381
Status string `json:"status"`
364382
// This field is from variant [AuthAgentInvocationCreateResponseInvocationCreated].
365383
ExpiresAt time.Time `json:"expires_at"`
@@ -401,9 +419,9 @@ func (AuthAgentInvocationCreateResponseInvocationCreated) implAuthAgentInvocatio
401419
// }
402420
func (u AuthAgentInvocationCreateResponseUnion) AsAny() anyAuthAgentInvocationCreateResponse {
403421
switch u.Status {
404-
case "already_authenticated":
422+
case "ALREADY_AUTHENTICATED":
405423
return u.AsAlreadyAuthenticated()
406-
case "invocation_created":
424+
case "INVOCATION_CREATED":
407425
return u.AsInvocationCreated()
408426
}
409427
return nil
@@ -526,7 +544,7 @@ const (
526544
type ReauthResponse struct {
527545
// Result of the re-authentication attempt
528546
//
529-
// Any of "reauth_started", "already_authenticated", "cannot_reauth".
547+
// Any of "REAUTH_STARTED", "ALREADY_AUTHENTICATED", "CANNOT_REAUTH".
530548
Status ReauthResponseStatus `json:"status,required"`
531549
// ID of the re-auth invocation if one was created
532550
InvocationID string `json:"invocation_id"`
@@ -552,9 +570,9 @@ func (r *ReauthResponse) UnmarshalJSON(data []byte) error {
552570
type ReauthResponseStatus string
553571

554572
const (
555-
ReauthResponseStatusReauthStarted ReauthResponseStatus = "reauth_started"
556-
ReauthResponseStatusAlreadyAuthenticated ReauthResponseStatus = "already_authenticated"
557-
ReauthResponseStatusCannotReauth ReauthResponseStatus = "cannot_reauth"
573+
ReauthResponseStatusReauthStarted ReauthResponseStatus = "REAUTH_STARTED"
574+
ReauthResponseStatusAlreadyAuthenticated ReauthResponseStatus = "ALREADY_AUTHENTICATED"
575+
ReauthResponseStatusCannotReauth ReauthResponseStatus = "CANNOT_REAUTH"
558576
)
559577

560578
type AgentAuthNewParams struct {

agentauthinvocation.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func (r *AgentAuthInvocationService) New(ctx context.Context, body AgentAuthInvo
4747
return
4848
}
4949

50-
// Returns invocation details including app_name and target_domain. Uses the JWT
51-
// returned by the exchange endpoint, or standard API key or JWT authentication.
50+
// Returns invocation details including status, app_name, and target_domain.
51+
// Supports both API key and JWT (from exchange endpoint) authentication.
5252
func (r *AgentAuthInvocationService) Get(ctx context.Context, invocationID string, opts ...option.RequestOption) (res *AgentAuthInvocationResponse, err error) {
5353
opts = slices.Concat(r.Options, opts)
5454
if invocationID == "" {
@@ -62,7 +62,7 @@ func (r *AgentAuthInvocationService) Get(ctx context.Context, invocationID strin
6262

6363
// Inspects the target site to detect logged-in state or discover required fields.
6464
// Returns 200 with success: true when fields are found, or 4xx/5xx for failures.
65-
// Requires the JWT returned by the exchange endpoint.
65+
// Supports both API key and JWT (from exchange endpoint) authentication.
6666
func (r *AgentAuthInvocationService) Discover(ctx context.Context, invocationID string, body AgentAuthInvocationDiscoverParams, opts ...option.RequestOption) (res *AgentAuthDiscoverResponse, err error) {
6767
opts = slices.Concat(r.Options, opts)
6868
if invocationID == "" {
@@ -88,7 +88,8 @@ func (r *AgentAuthInvocationService) Exchange(ctx context.Context, invocationID
8888
}
8989

9090
// Submits field values for the discovered login form and may return additional
91-
// auth fields or success. Requires the JWT returned by the exchange endpoint.
91+
// auth fields or success. Supports both API key and JWT (from exchange endpoint)
92+
// authentication.
9293
func (r *AgentAuthInvocationService) Submit(ctx context.Context, invocationID string, body AgentAuthInvocationSubmitParams, opts ...option.RequestOption) (res *AgentAuthSubmitResponse, err error) {
9394
opts = slices.Concat(r.Options, opts)
9495
if invocationID == "" {

shared/constant/constants.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ func ValueOf[T Constant[T]]() T {
1818
return t.Default()
1919
}
2020

21-
type AlreadyAuthenticated string // Always "already_authenticated"
21+
type AlreadyAuthenticated string // Always "ALREADY_AUTHENTICATED"
2222
type AppVersionSummary string // Always "app_version_summary"
2323
type AwsUsEast1a string // Always "aws.us-east-1a"
2424
type DeploymentState string // Always "deployment_state"
2525
type Error string // Always "error"
26-
type InvocationCreated string // Always "invocation_created"
26+
type InvocationCreated string // Always "INVOCATION_CREATED"
2727
type InvocationState string // Always "invocation_state"
2828
type Log string // Always "log"
2929
type SseHeartbeat string // Always "sse_heartbeat"
3030

31-
func (c AlreadyAuthenticated) Default() AlreadyAuthenticated { return "already_authenticated" }
31+
func (c AlreadyAuthenticated) Default() AlreadyAuthenticated { return "ALREADY_AUTHENTICATED" }
3232
func (c AppVersionSummary) Default() AppVersionSummary { return "app_version_summary" }
3333
func (c AwsUsEast1a) Default() AwsUsEast1a { return "aws.us-east-1a" }
3434
func (c DeploymentState) Default() DeploymentState { return "deployment_state" }
3535
func (c Error) Default() Error { return "error" }
36-
func (c InvocationCreated) Default() InvocationCreated { return "invocation_created" }
36+
func (c InvocationCreated) Default() InvocationCreated { return "INVOCATION_CREATED" }
3737
func (c InvocationState) Default() InvocationState { return "invocation_state" }
3838
func (c Log) Default() Log { return "log" }
3939
func (c SseHeartbeat) Default() SseHeartbeat { return "sse_heartbeat" }

0 commit comments

Comments
 (0)