-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathbetaenvironmentwork.go
More file actions
626 lines (577 loc) · 26.4 KB
/
betaenvironmentwork.go
File metadata and controls
626 lines (577 loc) · 26.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package anthropic
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"github.com/anthropics/anthropic-sdk-go/internal/apijson"
"github.com/anthropics/anthropic-sdk-go/internal/apiquery"
shimjson "github.com/anthropics/anthropic-sdk-go/internal/encoding/json"
"github.com/anthropics/anthropic-sdk-go/internal/requestconfig"
"github.com/anthropics/anthropic-sdk-go/option"
"github.com/anthropics/anthropic-sdk-go/packages/pagination"
"github.com/anthropics/anthropic-sdk-go/packages/param"
"github.com/anthropics/anthropic-sdk-go/packages/respjson"
"github.com/anthropics/anthropic-sdk-go/shared/constant"
)
// BetaEnvironmentWorkService contains methods and other services that help with
// interacting with the anthropic API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaEnvironmentWorkService] method instead.
type BetaEnvironmentWorkService struct {
Options []option.RequestOption
}
// NewBetaEnvironmentWorkService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewBetaEnvironmentWorkService(opts ...option.RequestOption) (r BetaEnvironmentWorkService) {
r = BetaEnvironmentWorkService{}
r.Options = opts
return
}
// Note: these endpoints are called automatically by the pre-built environment
// worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted
// sandbox environments. They are included here as a reference; you do not need to
// invoke them directly.
//
// Retrieve detailed information about a specific work item.
func (r *BetaEnvironmentWorkService) Get(ctx context.Context, workID string, params BetaEnvironmentWorkGetParams, opts ...option.RequestOption) (res *BetaSelfHostedWork, err error) {
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if params.EnvironmentID == "" {
err = errors.New("missing required environment_id parameter")
return nil, err
}
if workID == "" {
err = errors.New("missing required work_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/environments/%s/work/%s?beta=true", params.EnvironmentID, workID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Note: these endpoints are called automatically by the pre-built environment
// worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted
// sandbox environments. They are included here as a reference; you do not need to
// invoke them directly.
//
// Update work item metadata with merge semantics.
func (r *BetaEnvironmentWorkService) Update(ctx context.Context, workID string, params BetaEnvironmentWorkUpdateParams, opts ...option.RequestOption) (res *BetaSelfHostedWork, err error) {
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if params.EnvironmentID == "" {
err = errors.New("missing required environment_id parameter")
return nil, err
}
if workID == "" {
err = errors.New("missing required work_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/environments/%s/work/%s?beta=true", params.EnvironmentID, workID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// Note: these endpoints are called automatically by the pre-built environment
// worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted
// sandbox environments. They are included here as a reference; you do not need to
// invoke them directly.
//
// List work items in an environment.
func (r *BetaEnvironmentWorkService) List(ctx context.Context, environmentID string, params BetaEnvironmentWorkListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaSelfHostedWork], err error) {
var raw *http.Response
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01"), option.WithResponseInto(&raw)}, opts...)
if environmentID == "" {
err = errors.New("missing required environment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/environments/%s/work?beta=true", environmentID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Note: these endpoints are called automatically by the pre-built environment
// worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted
// sandbox environments. They are included here as a reference; you do not need to
// invoke them directly.
//
// List work items in an environment.
func (r *BetaEnvironmentWorkService) ListAutoPaging(ctx context.Context, environmentID string, params BetaEnvironmentWorkListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaSelfHostedWork] {
return pagination.NewPageCursorAutoPager(r.List(ctx, environmentID, params, opts...))
}
// Note: these endpoints are called automatically by the pre-built environment
// worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted
// sandbox environments. They are included here as a reference; you do not need to
// invoke them directly.
//
// Acknowledge receipt of a work item, transitioning it from 'queued' to 'starting'
// and removing it from the queue.
func (r *BetaEnvironmentWorkService) Ack(ctx context.Context, workID string, params BetaEnvironmentWorkAckParams, opts ...option.RequestOption) (res *BetaSelfHostedWork, err error) {
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if params.EnvironmentID == "" {
err = errors.New("missing required environment_id parameter")
return nil, err
}
if workID == "" {
err = errors.New("missing required work_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/environments/%s/work/%s/ack?beta=true", params.EnvironmentID, workID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
// Note: these endpoints are called automatically by the pre-built environment
// worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted
// sandbox environments. They are included here as a reference; you do not need to
// invoke them directly.
//
// Record a heartbeat for a work item to maintain the lease.
func (r *BetaEnvironmentWorkService) Heartbeat(ctx context.Context, workID string, params BetaEnvironmentWorkHeartbeatParams, opts ...option.RequestOption) (res *BetaSelfHostedWorkHeartbeatResponse, err error) {
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if params.EnvironmentID == "" {
err = errors.New("missing required environment_id parameter")
return nil, err
}
if workID == "" {
err = errors.New("missing required work_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/environments/%s/work/%s/heartbeat?beta=true", params.EnvironmentID, workID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// Note: these endpoints are called automatically by the pre-built environment
// worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted
// sandbox environments. They are included here as a reference; you do not need to
// invoke them directly.
//
// Long poll for work items in the queue.
func (r *BetaEnvironmentWorkService) Poll(ctx context.Context, environmentID string, params BetaEnvironmentWorkPollParams, opts ...option.RequestOption) (res *BetaSelfHostedWork, err error) {
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
if !param.IsOmitted(params.AnthropicWorkerID) {
opts = append(opts, option.WithHeader("Anthropic-Worker-ID", fmt.Sprintf("%v", params.AnthropicWorkerID.Value)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if environmentID == "" {
err = errors.New("missing required environment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/environments/%s/work/poll?beta=true", environmentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &res, opts...)
return res, err
}
// Get statistics about the work queue for an environment.
func (r *BetaEnvironmentWorkService) Stats(ctx context.Context, environmentID string, query BetaEnvironmentWorkStatsParams, opts ...option.RequestOption) (res *BetaSelfHostedWorkQueueStats, err error) {
for _, v := range query.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if environmentID == "" {
err = errors.New("missing required environment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/environments/%s/work/stats?beta=true", environmentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Note: these endpoints are called automatically by the pre-built environment
// worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted
// sandbox environments. They are included here as a reference; you do not need to
// invoke them directly.
//
// Stop a work item, initiating graceful or forced shutdown.
func (r *BetaEnvironmentWorkService) Stop(ctx context.Context, workID string, params BetaEnvironmentWorkStopParams, opts ...option.RequestOption) (res *BetaSelfHostedWork, err error) {
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if params.EnvironmentID == "" {
err = errors.New("missing required environment_id parameter")
return nil, err
}
if workID == "" {
err = errors.New("missing required work_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/environments/%s/work/%s/stop?beta=true", params.EnvironmentID, workID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// Work data for environment health checks.
//
// This resource type is used for assessing the health of containers where work
// occurs. The data is opaque to users; the runner handles the health check by
// probing connectivity to required services.
type BetaHealthCheckWorkData struct {
// Health check identifier
ID string `json:"id" api:"required"`
// Type of work data
//
// Any of "healthcheck".
Type BetaHealthCheckWorkDataType `json:"type"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaHealthCheckWorkData) RawJSON() string { return r.JSON.raw }
func (r *BetaHealthCheckWorkData) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Type of work data
type BetaHealthCheckWorkDataType string
const (
BetaHealthCheckWorkDataTypeHealthcheck BetaHealthCheckWorkDataType = "healthcheck"
)
// Work resource representing a unit of work in a self-hosted environment.
//
// Work items are queued when sessions are created or when long-dormant sessions
// receive new messages. The Environment Manager polls for work items and executes
// them on customer-hosted infrastructure.
type BetaSelfHostedWork struct {
// Work identifier (e.g., 'work\_...')
ID string `json:"id" api:"required"`
// RFC 3339 timestamp when work was acknowledged by Environment Manager
AcknowledgedAt string `json:"acknowledged_at" api:"required"`
// RFC 3339 timestamp when work was created
CreatedAt string `json:"created_at" api:"required"`
// The actual work to be performed
Data BetaSessionWorkData `json:"data" api:"required"`
// Environment identifier this work belongs to (e.g., `env_...`)
EnvironmentID string `json:"environment_id" api:"required"`
// RFC 3339 timestamp of the most recent heartbeat
LatestHeartbeatAt string `json:"latest_heartbeat_at" api:"required"`
// User-provided metadata key-value pairs associated with this work item
Metadata map[string]string `json:"metadata" api:"required"`
// Session instance JWT secret (only included in certain retrieval paths)
Secret string `json:"secret" api:"required"`
// RFC 3339 timestamp when work execution started
StartedAt string `json:"started_at" api:"required"`
// Current state of the work item
//
// Any of "queued", "starting", "active", "stopping", "stopped".
State BetaSelfHostedWorkState `json:"state" api:"required"`
// RFC 3339 timestamp when stop was requested
StopRequestedAt string `json:"stop_requested_at" api:"required"`
// RFC 3339 timestamp when work execution stopped
StoppedAt string `json:"stopped_at" api:"required"`
// The type of object (always 'work')
Type constant.Work `json:"type" default:"work"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
AcknowledgedAt respjson.Field
CreatedAt respjson.Field
Data respjson.Field
EnvironmentID respjson.Field
LatestHeartbeatAt respjson.Field
Metadata respjson.Field
Secret respjson.Field
StartedAt respjson.Field
State respjson.Field
StopRequestedAt respjson.Field
StoppedAt respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaSelfHostedWork) RawJSON() string { return r.JSON.raw }
func (r *BetaSelfHostedWork) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Current state of the work item
type BetaSelfHostedWorkState string
const (
BetaSelfHostedWorkStateQueued BetaSelfHostedWorkState = "queued"
BetaSelfHostedWorkStateStarting BetaSelfHostedWorkState = "starting"
BetaSelfHostedWorkStateActive BetaSelfHostedWorkState = "active"
BetaSelfHostedWorkStateStopping BetaSelfHostedWorkState = "stopping"
BetaSelfHostedWorkStateStopped BetaSelfHostedWorkState = "stopped"
)
// Response after recording a heartbeat for a work item.
type BetaSelfHostedWorkHeartbeatResponse struct {
// RFC 3339 timestamp of the actual heartbeat from DB
LastHeartbeat string `json:"last_heartbeat" api:"required"`
// Whether the heartbeat succeeded in extending the lease
LeaseExtended bool `json:"lease_extended" api:"required"`
// Current state of the work item (active/stopping/stopped)
//
// Any of "queued", "starting", "active", "stopping", "stopped".
State BetaSelfHostedWorkHeartbeatResponseState `json:"state" api:"required"`
// Effective TTL applied to the lease
TTLSeconds int64 `json:"ttl_seconds" api:"required"`
// The type of response
Type constant.WorkHeartbeat `json:"type" default:"work_heartbeat"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
LastHeartbeat respjson.Field
LeaseExtended respjson.Field
State respjson.Field
TTLSeconds respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaSelfHostedWorkHeartbeatResponse) RawJSON() string { return r.JSON.raw }
func (r *BetaSelfHostedWorkHeartbeatResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Current state of the work item (active/stopping/stopped)
type BetaSelfHostedWorkHeartbeatResponseState string
const (
BetaSelfHostedWorkHeartbeatResponseStateQueued BetaSelfHostedWorkHeartbeatResponseState = "queued"
BetaSelfHostedWorkHeartbeatResponseStateStarting BetaSelfHostedWorkHeartbeatResponseState = "starting"
BetaSelfHostedWorkHeartbeatResponseStateActive BetaSelfHostedWorkHeartbeatResponseState = "active"
BetaSelfHostedWorkHeartbeatResponseStateStopping BetaSelfHostedWorkHeartbeatResponseState = "stopping"
BetaSelfHostedWorkHeartbeatResponseStateStopped BetaSelfHostedWorkHeartbeatResponseState = "stopped"
)
// Response when listing work items with cursor-based pagination.
type BetaSelfHostedWorkListResponse struct {
// List of work items
Data []BetaSelfHostedWork `json:"data" api:"required"`
// Opaque cursor for fetching the next page of results
NextPage string `json:"next_page" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Data respjson.Field
NextPage respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaSelfHostedWorkListResponse) RawJSON() string { return r.JSON.raw }
func (r *BetaSelfHostedWorkListResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Statistics about the work queue for an environment.
//
// Uses Redis Stream consumer group metrics for O(1) queries.
type BetaSelfHostedWorkQueueStats struct {
// Number of work items waiting to be picked up (lag from consumer group)
Depth int64 `json:"depth" api:"required"`
// RFC 3339 timestamp of oldest item in the work stream (includes both queued and
// pending items), null if stream empty
OldestQueuedAt string `json:"oldest_queued_at" api:"required"`
// Number of work items being processed (polled but not acknowledged)
Pending int64 `json:"pending" api:"required"`
// The type of object
Type constant.WorkQueueStats `json:"type" default:"work_queue_stats"`
// Number of workers that have polled for work in the last 30 seconds. Requires
// worker_id to be sent with poll requests.
WorkersPolling int64 `json:"workers_polling" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Depth respjson.Field
OldestQueuedAt respjson.Field
Pending respjson.Field
Type respjson.Field
WorkersPolling respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaSelfHostedWorkQueueStats) RawJSON() string { return r.JSON.raw }
func (r *BetaSelfHostedWorkQueueStats) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Request to stop a work item.
type BetaSelfHostedWorkStopRequestParam struct {
// If true, immediately stop work without graceful shutdown
Force param.Opt[bool] `json:"force,omitzero"`
paramObj
}
func (r BetaSelfHostedWorkStopRequestParam) MarshalJSON() (data []byte, err error) {
type shadow BetaSelfHostedWorkStopRequestParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaSelfHostedWorkStopRequestParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Request to update work item metadata.
//
// The property Metadata is required.
type BetaSelfHostedWorkUpdateRequestParam struct {
// Metadata patch. Set a key to a string to upsert it, or to null to delete it.
// Omit the field to preserve existing metadata.
Metadata map[string]string `json:"metadata,omitzero" api:"required"`
paramObj
}
func (r BetaSelfHostedWorkUpdateRequestParam) MarshalJSON() (data []byte, err error) {
type shadow BetaSelfHostedWorkUpdateRequestParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaSelfHostedWorkUpdateRequestParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Work data for session work items.
//
// This resource type is used when work represents a session that needs to be
// executed in a self-hosted environment.
type BetaSessionWorkData struct {
// Session identifier (e.g., 'session\_...')
ID string `json:"id" api:"required"`
// Type of work data
Type constant.Session `json:"type" default:"session"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaSessionWorkData) RawJSON() string { return r.JSON.raw }
func (r *BetaSessionWorkData) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaEnvironmentWorkGetParams struct {
EnvironmentID string `path:"environment_id" api:"required" json:"-"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
type BetaEnvironmentWorkUpdateParams struct {
EnvironmentID string `path:"environment_id" api:"required" json:"-"`
// Request to update work item metadata.
BetaSelfHostedWorkUpdateRequest BetaSelfHostedWorkUpdateRequestParam
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
func (r BetaEnvironmentWorkUpdateParams) MarshalJSON() (data []byte, err error) {
return shimjson.Marshal(r.BetaSelfHostedWorkUpdateRequest)
}
func (r *BetaEnvironmentWorkUpdateParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaEnvironmentWorkListParams struct {
// Opaque cursor from previous response for pagination
Page param.Opt[string] `query:"page,omitzero" json:"-"`
// Maximum number of work items to return
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
// URLQuery serializes [BetaEnvironmentWorkListParams]'s query parameters as
// `url.Values`.
func (r BetaEnvironmentWorkListParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type BetaEnvironmentWorkAckParams struct {
EnvironmentID string `path:"environment_id" api:"required" json:"-"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
type BetaEnvironmentWorkHeartbeatParams struct {
EnvironmentID string `path:"environment_id" api:"required" json:"-"`
// Desired TTL in seconds
DesiredTTLSeconds param.Opt[int64] `query:"desired_ttl_seconds,omitzero" json:"-"`
// Expected last_heartbeat for conditional update (optimistic concurrency). Use
// literal 'NO_HEARTBEAT' to claim an unclaimed lease (first heartbeat). For
// subsequent heartbeats, echo the server's previous last_heartbeat value exactly.
// Returns 412 Precondition Failed if the actual value doesn't match.
ExpectedLastHeartbeat param.Opt[string] `query:"expected_last_heartbeat,omitzero" json:"-"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
// URLQuery serializes [BetaEnvironmentWorkHeartbeatParams]'s query parameters as
// `url.Values`.
func (r BetaEnvironmentWorkHeartbeatParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type BetaEnvironmentWorkPollParams struct {
// How long to wait for work to arrive before returning. Must be 1-999 in
// milliseconds. Defaults to non-blocking (returns immediately if no work is
// available).
BlockMs param.Opt[int64] `query:"block_ms,omitzero" json:"-"`
// Reclaim unacknowledged work items older than this many milliseconds. If omitted,
// uses the default (5000ms).
ReclaimOlderThanMs param.Opt[int64] `query:"reclaim_older_than_ms,omitzero" json:"-"`
// Unique identifier for the specific worker polling, used to track aggregated
// environment-level work metrics in Console
AnthropicWorkerID param.Opt[string] `header:"Anthropic-Worker-ID,omitzero" json:"-"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
// URLQuery serializes [BetaEnvironmentWorkPollParams]'s query parameters as
// `url.Values`.
func (r BetaEnvironmentWorkPollParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type BetaEnvironmentWorkStatsParams struct {
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
type BetaEnvironmentWorkStopParams struct {
EnvironmentID string `path:"environment_id" api:"required" json:"-"`
// Request to stop a work item.
BetaSelfHostedWorkStopRequest BetaSelfHostedWorkStopRequestParam
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
func (r BetaEnvironmentWorkStopParams) MarshalJSON() (data []byte, err error) {
return shimjson.Marshal(r.BetaSelfHostedWorkStopRequest)
}
func (r *BetaEnvironmentWorkStopParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}