github.com/anthropics/anthropic-sdk-go@v1.70.1/betasession.go (about)

     1  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
     2  
     3  package anthropic
     4  
     5  import (
     6  	"context"
     7  	"encoding/json"
     8  	"errors"
     9  	"fmt"
    10  	"net/http"
    11  	"net/url"
    12  	"slices"
    13  	"time"
    14  
    15  	"github.com/anthropics/anthropic-sdk-go/internal/apijson"
    16  	"github.com/anthropics/anthropic-sdk-go/internal/apiquery"
    17  	"github.com/anthropics/anthropic-sdk-go/internal/paramutil"
    18  	"github.com/anthropics/anthropic-sdk-go/internal/requestconfig"
    19  	"github.com/anthropics/anthropic-sdk-go/option"
    20  	"github.com/anthropics/anthropic-sdk-go/packages/pagination"
    21  	"github.com/anthropics/anthropic-sdk-go/packages/param"
    22  	"github.com/anthropics/anthropic-sdk-go/packages/respjson"
    23  )
    24  
    25  // BetaSessionService contains methods and other services that help with
    26  // interacting with the anthropic API.
    27  //
    28  // Note, unlike clients, this service does not read variables from the environment
    29  // automatically. You should not instantiate this service directly, and instead use
    30  // the [NewBetaSessionService] method instead.
    31  type BetaSessionService struct {
    32  	Options   []option.RequestOption
    33  	Events    BetaSessionEventService
    34  	Resources BetaSessionResourceService
    35  	Threads   BetaSessionThreadService
    36  }
    37  
    38  // NewBetaSessionService generates a new service that applies the given options to
    39  // each request. These options are applied after the parent client's options (if
    40  // there is one), and before any request-specific options.
    41  func NewBetaSessionService(opts ...option.RequestOption) (r BetaSessionService) {
    42  	r = BetaSessionService{}
    43  	r.Options = opts
    44  	r.Events = NewBetaSessionEventService(opts...)
    45  	r.Resources = NewBetaSessionResourceService(opts...)
    46  	r.Threads = NewBetaSessionThreadService(opts...)
    47  	return
    48  }
    49  
    50  // Create Session
    51  func (r *BetaSessionService) New(ctx context.Context, params BetaSessionNewParams, opts ...option.RequestOption) (res *BetaManagedAgentsSession, err error) {
    52  	for _, v := range params.Betas {
    53  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
    54  	}
    55  	if !param.IsOmitted(params.WorkspaceID) {
    56  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value)))
    57  	}
    58  	opts = slices.Concat(r.Options, opts)
    59  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
    60  	path := "v1/sessions?beta=true"
    61  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
    62  	return res, err
    63  }
    64  
    65  // Get Session
    66  func (r *BetaSessionService) Get(ctx context.Context, sessionID string, query BetaSessionGetParams, opts ...option.RequestOption) (res *BetaManagedAgentsSession, err error) {
    67  	for _, v := range query.Betas {
    68  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
    69  	}
    70  	if !param.IsOmitted(query.WorkspaceID) {
    71  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", query.WorkspaceID.Value)))
    72  	}
    73  	opts = slices.Concat(r.Options, opts)
    74  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
    75  	if sessionID == "" {
    76  		err = errors.New("missing required session_id parameter")
    77  		return nil, err
    78  	}
    79  	path := fmt.Sprintf("v1/sessions/%s?beta=true", sessionID)
    80  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
    81  	return res, err
    82  }
    83  
    84  // Update Session
    85  func (r *BetaSessionService) Update(ctx context.Context, sessionID string, params BetaSessionUpdateParams, opts ...option.RequestOption) (res *BetaManagedAgentsSession, err error) {
    86  	for _, v := range params.Betas {
    87  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
    88  	}
    89  	if !param.IsOmitted(params.WorkspaceID) {
    90  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value)))
    91  	}
    92  	opts = slices.Concat(r.Options, opts)
    93  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
    94  	if sessionID == "" {
    95  		err = errors.New("missing required session_id parameter")
    96  		return nil, err
    97  	}
    98  	path := fmt.Sprintf("v1/sessions/%s?beta=true", sessionID)
    99  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
   100  	return res, err
   101  }
   102  
   103  // List Sessions
   104  func (r *BetaSessionService) List(ctx context.Context, params BetaSessionListParams, opts ...option.RequestOption) (res *pagination.BidirectionalPageCursor[BetaManagedAgentsSession], err error) {
   105  	var raw *http.Response
   106  	for _, v := range params.Betas {
   107  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
   108  	}
   109  	if !param.IsOmitted(params.WorkspaceID) {
   110  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value)))
   111  	}
   112  	opts = slices.Concat(r.Options, opts)
   113  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01"), option.WithResponseInto(&raw)}, opts...)
   114  	path := "v1/sessions?beta=true"
   115  	cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
   116  	if err != nil {
   117  		return nil, err
   118  	}
   119  	err = cfg.Execute()
   120  	if err != nil {
   121  		return nil, err
   122  	}
   123  	res.SetPageConfig(cfg, raw)
   124  	return res, nil
   125  }
   126  
   127  // List Sessions
   128  func (r *BetaSessionService) ListAutoPaging(ctx context.Context, params BetaSessionListParams, opts ...option.RequestOption) *pagination.BidirectionalPageCursorAutoPager[BetaManagedAgentsSession] {
   129  	return pagination.NewBidirectionalPageCursorAutoPager(r.List(ctx, params, opts...))
   130  }
   131  
   132  // Delete Session
   133  func (r *BetaSessionService) Delete(ctx context.Context, sessionID string, body BetaSessionDeleteParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeletedSession, err error) {
   134  	for _, v := range body.Betas {
   135  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
   136  	}
   137  	if !param.IsOmitted(body.WorkspaceID) {
   138  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", body.WorkspaceID.Value)))
   139  	}
   140  	opts = slices.Concat(r.Options, opts)
   141  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
   142  	if sessionID == "" {
   143  		err = errors.New("missing required session_id parameter")
   144  		return nil, err
   145  	}
   146  	path := fmt.Sprintf("v1/sessions/%s?beta=true", sessionID)
   147  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
   148  	return res, err
   149  }
   150  
   151  // Archive Session
   152  func (r *BetaSessionService) Archive(ctx context.Context, sessionID string, body BetaSessionArchiveParams, opts ...option.RequestOption) (res *BetaManagedAgentsSession, err error) {
   153  	for _, v := range body.Betas {
   154  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
   155  	}
   156  	if !param.IsOmitted(body.WorkspaceID) {
   157  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", body.WorkspaceID.Value)))
   158  	}
   159  	opts = slices.Concat(r.Options, opts)
   160  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
   161  	if sessionID == "" {
   162  		err = errors.New("missing required session_id parameter")
   163  		return nil, err
   164  	}
   165  	path := fmt.Sprintf("v1/sessions/%s/archive?beta=true", sessionID)
   166  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
   167  	return res, err
   168  }
   169  
   170  // Platform advisor roster entry: a model the session's primary thread may consult
   171  // mid-turn. At most one per roster; the entry occupies the roster name
   172  // `anthropic.advisor`.
   173  //
   174  // The properties Model, Type are required.
   175  type BetaManagedAgentsAdvisorParams struct {
   176  	// A Claude model id. The model must be permitted as an advisor for this agent's
   177  	// model — see the sessions/threads/advisor spec.
   178  	Model string `json:"model" api:"required"`
   179  	// Any of "advisor".
   180  	Type BetaManagedAgentsAdvisorParamsType `json:"type,omitzero" api:"required"`
   181  	paramObj
   182  }
   183  
   184  func (r BetaManagedAgentsAdvisorParams) MarshalJSON() (data []byte, err error) {
   185  	type shadow BetaManagedAgentsAdvisorParams
   186  	return param.MarshalObject(r, (*shadow)(&r))
   187  }
   188  func (r *BetaManagedAgentsAdvisorParams) UnmarshalJSON(data []byte) error {
   189  	return apijson.UnmarshalRoot(data, r)
   190  }
   191  
   192  type BetaManagedAgentsAdvisorParamsType string
   193  
   194  const (
   195  	BetaManagedAgentsAdvisorParamsTypeAdvisor BetaManagedAgentsAdvisorParamsType = "advisor"
   196  )
   197  
   198  type BetaManagedAgentsAgentMessagePreview struct {
   199  	// The id the buffered agent.message will carry if it is emitted. Matches the
   200  	// event_id on this preview's event_delta events.
   201  	ID string `json:"id" api:"required"`
   202  	// Any of "agent.message".
   203  	Type BetaManagedAgentsAgentMessagePreviewType `json:"type" api:"required"`
   204  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   205  	JSON struct {
   206  		ID          respjson.Field
   207  		Type        respjson.Field
   208  		ExtraFields map[string]respjson.Field
   209  		raw         string
   210  	} `json:"-"`
   211  }
   212  
   213  // Returns the unmodified JSON received from the API
   214  func (r BetaManagedAgentsAgentMessagePreview) RawJSON() string { return r.JSON.raw }
   215  func (r *BetaManagedAgentsAgentMessagePreview) UnmarshalJSON(data []byte) error {
   216  	return apijson.UnmarshalRoot(data, r)
   217  }
   218  
   219  type BetaManagedAgentsAgentMessagePreviewType string
   220  
   221  const (
   222  	BetaManagedAgentsAgentMessagePreviewTypeAgentMessage BetaManagedAgentsAgentMessagePreviewType = "agent.message"
   223  )
   224  
   225  // Specification for an Agent. Provide a specific `version` or use the short-form
   226  // `agent="agent_id"` for the most recent version
   227  //
   228  // The properties ID, Type are required.
   229  type BetaManagedAgentsAgentParams struct {
   230  	// The `agent` ID.
   231  	ID string `json:"id" api:"required"`
   232  	// Any of "agent".
   233  	Type BetaManagedAgentsAgentParamsType `json:"type,omitzero" api:"required"`
   234  	// The specific `agent` version to use. Omit to use the latest version. Must be at
   235  	// least 1 if specified.
   236  	Version param.Opt[int64] `json:"version,omitzero"`
   237  	paramObj
   238  }
   239  
   240  func (r BetaManagedAgentsAgentParams) MarshalJSON() (data []byte, err error) {
   241  	type shadow BetaManagedAgentsAgentParams
   242  	return param.MarshalObject(r, (*shadow)(&r))
   243  }
   244  func (r *BetaManagedAgentsAgentParams) UnmarshalJSON(data []byte) error {
   245  	return apijson.UnmarshalRoot(data, r)
   246  }
   247  
   248  type BetaManagedAgentsAgentParamsType string
   249  
   250  const (
   251  	BetaManagedAgentsAgentParamsTypeAgent BetaManagedAgentsAgentParamsType = "agent"
   252  )
   253  
   254  type BetaManagedAgentsAgentThinkingPreview struct {
   255  	// The id the buffered agent.thinking will carry if it is emitted. Start-only — no
   256  	// event_delta events follow.
   257  	ID string `json:"id" api:"required"`
   258  	// Any of "agent.thinking".
   259  	Type BetaManagedAgentsAgentThinkingPreviewType `json:"type" api:"required"`
   260  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   261  	JSON struct {
   262  		ID          respjson.Field
   263  		Type        respjson.Field
   264  		ExtraFields map[string]respjson.Field
   265  		raw         string
   266  	} `json:"-"`
   267  }
   268  
   269  // Returns the unmodified JSON received from the API
   270  func (r BetaManagedAgentsAgentThinkingPreview) RawJSON() string { return r.JSON.raw }
   271  func (r *BetaManagedAgentsAgentThinkingPreview) UnmarshalJSON(data []byte) error {
   272  	return apijson.UnmarshalRoot(data, r)
   273  }
   274  
   275  type BetaManagedAgentsAgentThinkingPreviewType string
   276  
   277  const (
   278  	BetaManagedAgentsAgentThinkingPreviewTypeAgentThinking BetaManagedAgentsAgentThinkingPreviewType = "agent.thinking"
   279  )
   280  
   281  // Reference to an `agent` plus optional configuration overrides. Each provided
   282  // field replaces the agent's value for the caller's use; the agent resource is
   283  // unchanged.
   284  //
   285  // The properties ID, Type are required.
   286  type BetaManagedAgentsAgentWithOverridesParams struct {
   287  	// The `agent` ID.
   288  	ID string `json:"id" api:"required"`
   289  	// Any of "agent_with_overrides".
   290  	Type BetaManagedAgentsAgentWithOverridesParamsType `json:"type,omitzero" api:"required"`
   291  	// Replacement system prompt. Up to 100,000 characters. Set to null to clear the
   292  	// agent's system prompt; omit to preserve it.
   293  	System param.Opt[string] `json:"system,omitzero"`
   294  	// The specific `agent` version to use. Omit to use the latest version.
   295  	Version param.Opt[int64] `json:"version,omitzero"`
   296  	// Replacement MCP server list. Full replacement: the provided array becomes the
   297  	// MCP servers. Send an empty array to clear; omit to preserve the agent's servers.
   298  	MCPServers []BetaManagedAgentsURLMCPServerParams `json:"mcp_servers,omitzero"`
   299  	// Replacement model. Accepts the model string, e.g. `claude-opus-5`, or a
   300  	// `model_config` object. Omit to use the agent's model.
   301  	Model BetaManagedAgentsModelConfigParams `json:"model,omitzero"`
   302  	// Replacement skill list. Full replacement: the provided array becomes the skills.
   303  	// Send an empty array to clear; omit to preserve the agent's skills.
   304  	Skills []BetaManagedAgentsSkillParamsUnion `json:"skills,omitzero"`
   305  	// Replacement tool list. Full replacement: the provided array becomes the tool
   306  	// configuration. Send an empty array to clear; omit to preserve the agent's tools.
   307  	Tools []BetaManagedAgentsAgentWithOverridesParamsToolUnion `json:"tools,omitzero"`
   308  	paramObj
   309  }
   310  
   311  func (r BetaManagedAgentsAgentWithOverridesParams) MarshalJSON() (data []byte, err error) {
   312  	type shadow BetaManagedAgentsAgentWithOverridesParams
   313  	return param.MarshalObject(r, (*shadow)(&r))
   314  }
   315  func (r *BetaManagedAgentsAgentWithOverridesParams) UnmarshalJSON(data []byte) error {
   316  	return apijson.UnmarshalRoot(data, r)
   317  }
   318  
   319  type BetaManagedAgentsAgentWithOverridesParamsType string
   320  
   321  const (
   322  	BetaManagedAgentsAgentWithOverridesParamsTypeAgentWithOverrides BetaManagedAgentsAgentWithOverridesParamsType = "agent_with_overrides"
   323  )
   324  
   325  // Only one field can be non-zero.
   326  //
   327  // Use [param.IsOmitted] to confirm if a field is set.
   328  type BetaManagedAgentsAgentWithOverridesParamsToolUnion struct {
   329  	OfAgentToolset20260401 *BetaManagedAgentsAgentToolset20260401Params `json:",omitzero,inline"`
   330  	OfMCPToolset           *BetaManagedAgentsMCPToolsetParams           `json:",omitzero,inline"`
   331  	OfCustom               *BetaManagedAgentsCustomToolParams           `json:",omitzero,inline"`
   332  	paramUnion
   333  }
   334  
   335  func (u BetaManagedAgentsAgentWithOverridesParamsToolUnion) MarshalJSON() ([]byte, error) {
   336  	return param.MarshalUnion(u, u.OfAgentToolset20260401, u.OfMCPToolset, u.OfCustom)
   337  }
   338  func (u *BetaManagedAgentsAgentWithOverridesParamsToolUnion) UnmarshalJSON(data []byte) error {
   339  	return apijson.UnmarshalRoot(data, u)
   340  }
   341  
   342  func (u *BetaManagedAgentsAgentWithOverridesParamsToolUnion) asAny() any {
   343  	if !param.IsOmitted(u.OfAgentToolset20260401) {
   344  		return u.OfAgentToolset20260401
   345  	} else if !param.IsOmitted(u.OfMCPToolset) {
   346  		return u.OfMCPToolset
   347  	} else if !param.IsOmitted(u.OfCustom) {
   348  		return u.OfCustom
   349  	}
   350  	return nil
   351  }
   352  
   353  // Returns a pointer to the underlying variant's property, if present.
   354  func (u BetaManagedAgentsAgentWithOverridesParamsToolUnion) GetMCPServerName() *string {
   355  	if vt := u.OfMCPToolset; vt != nil {
   356  		return &vt.MCPServerName
   357  	}
   358  	return nil
   359  }
   360  
   361  // Returns a pointer to the underlying variant's property, if present.
   362  func (u BetaManagedAgentsAgentWithOverridesParamsToolUnion) GetDescription() *string {
   363  	if vt := u.OfCustom; vt != nil {
   364  		return &vt.Description
   365  	}
   366  	return nil
   367  }
   368  
   369  // Returns a pointer to the underlying variant's property, if present.
   370  func (u BetaManagedAgentsAgentWithOverridesParamsToolUnion) GetInputSchema() *BetaManagedAgentsCustomToolInputSchemaParam {
   371  	if vt := u.OfCustom; vt != nil {
   372  		return &vt.InputSchema
   373  	}
   374  	return nil
   375  }
   376  
   377  // Returns a pointer to the underlying variant's property, if present.
   378  func (u BetaManagedAgentsAgentWithOverridesParamsToolUnion) GetName() *string {
   379  	if vt := u.OfCustom; vt != nil {
   380  		return &vt.Name
   381  	}
   382  	return nil
   383  }
   384  
   385  // Returns a pointer to the underlying variant's property, if present.
   386  func (u BetaManagedAgentsAgentWithOverridesParamsToolUnion) GetType() *string {
   387  	if vt := u.OfAgentToolset20260401; vt != nil {
   388  		return (*string)(&vt.Type)
   389  	} else if vt := u.OfMCPToolset; vt != nil {
   390  		return (*string)(&vt.Type)
   391  	} else if vt := u.OfCustom; vt != nil {
   392  		return (*string)(&vt.Type)
   393  	}
   394  	return nil
   395  }
   396  
   397  // Returns a subunion which exports methods to access subproperties
   398  //
   399  // Or use AsAny() to get the underlying value
   400  func (u BetaManagedAgentsAgentWithOverridesParamsToolUnion) GetConfigs() (res betaManagedAgentsAgentWithOverridesParamsToolUnionConfigs) {
   401  	if vt := u.OfAgentToolset20260401; vt != nil {
   402  		res.any = &vt.Configs
   403  	} else if vt := u.OfMCPToolset; vt != nil {
   404  		res.any = &vt.Configs
   405  	}
   406  	return
   407  }
   408  
   409  // Can have the runtime types [_[]BetaManagedAgentsAgentToolConfigParamsUnion],
   410  // [_[]BetaManagedAgentsMCPToolConfigParams]
   411  type betaManagedAgentsAgentWithOverridesParamsToolUnionConfigs struct{ any }
   412  
   413  // Use the following switch statement to get the type of the union:
   414  //
   415  //	switch u.AsAny().(type) {
   416  //	case *[]anthropic.BetaManagedAgentsAgentToolConfigParamsUnion:
   417  //	case *[]anthropic.BetaManagedAgentsMCPToolConfigParams:
   418  //	default:
   419  //	    fmt.Errorf("not present")
   420  //	}
   421  func (u betaManagedAgentsAgentWithOverridesParamsToolUnionConfigs) AsAny() any { return u.any }
   422  
   423  // Returns a subunion which exports methods to access subproperties
   424  //
   425  // Or use AsAny() to get the underlying value
   426  func (u BetaManagedAgentsAgentWithOverridesParamsToolUnion) GetDefaultConfig() (res betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfig) {
   427  	if vt := u.OfAgentToolset20260401; vt != nil {
   428  		res.any = &vt.DefaultConfig
   429  	} else if vt := u.OfMCPToolset; vt != nil {
   430  		res.any = &vt.DefaultConfig
   431  	}
   432  	return
   433  }
   434  
   435  // Can have the runtime types [*BetaManagedAgentsAgentToolsetDefaultConfigParams],
   436  // [*BetaManagedAgentsMCPToolsetDefaultConfigParams]
   437  type betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfig struct{ any }
   438  
   439  // Use the following switch statement to get the type of the union:
   440  //
   441  //	switch u.AsAny().(type) {
   442  //	case *anthropic.BetaManagedAgentsAgentToolsetDefaultConfigParams:
   443  //	case *anthropic.BetaManagedAgentsMCPToolsetDefaultConfigParams:
   444  //	default:
   445  //	    fmt.Errorf("not present")
   446  //	}
   447  func (u betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfig) AsAny() any { return u.any }
   448  
   449  // Returns a pointer to the underlying variant's property, if present.
   450  func (u betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfig) GetEnabled() *bool {
   451  	switch vt := u.any.(type) {
   452  	case *BetaManagedAgentsAgentToolsetDefaultConfigParams:
   453  		return paramutil.AddrIfPresent(vt.Enabled)
   454  	case *BetaManagedAgentsMCPToolsetDefaultConfigParams:
   455  		return paramutil.AddrIfPresent(vt.Enabled)
   456  	}
   457  	return nil
   458  }
   459  
   460  // Returns a subunion which exports methods to access subproperties
   461  //
   462  // Or use AsAny() to get the underlying value
   463  func (u betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfig) GetPermissionPolicy() (res betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfigPermissionPolicy) {
   464  	switch vt := u.any.(type) {
   465  	case *BetaManagedAgentsAgentToolsetDefaultConfigParams:
   466  		res.any = vt.PermissionPolicy
   467  	case *BetaManagedAgentsMCPToolsetDefaultConfigParams:
   468  		res.any = vt.PermissionPolicy
   469  	}
   470  	return res
   471  }
   472  
   473  // Can have the runtime types [*BetaManagedAgentsAlwaysAllowPolicyParam],
   474  // [*BetaManagedAgentsAlwaysAskPolicyParam]
   475  type betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfigPermissionPolicy struct{ any }
   476  
   477  // Use the following switch statement to get the type of the union:
   478  //
   479  //	switch u.AsAny().(type) {
   480  //	case *anthropic.BetaManagedAgentsAlwaysAllowPolicyParam:
   481  //	case *anthropic.BetaManagedAgentsAlwaysAskPolicyParam:
   482  //	default:
   483  //	    fmt.Errorf("not present")
   484  //	}
   485  func (u betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfigPermissionPolicy) AsAny() any {
   486  	return u.any
   487  }
   488  
   489  // Returns a pointer to the underlying variant's property, if present.
   490  func (u betaManagedAgentsAgentWithOverridesParamsToolUnionDefaultConfigPermissionPolicy) GetType() *string {
   491  	switch vt := u.any.(type) {
   492  	case *BetaManagedAgentsAgentToolsetDefaultConfigParamsPermissionPolicyUnion:
   493  		return vt.GetType()
   494  	case *BetaManagedAgentsMCPToolsetDefaultConfigParamsPermissionPolicyUnion:
   495  		return vt.GetType()
   496  	}
   497  	return nil
   498  }
   499  
   500  func init() {
   501  	apijson.RegisterUnion[BetaManagedAgentsAgentWithOverridesParamsToolUnion](
   502  		"type",
   503  		apijson.Discriminator[BetaManagedAgentsAgentToolset20260401Params]("agent_toolset_20260401"),
   504  		apijson.Discriminator[BetaManagedAgentsMCPToolsetParams]("mcp_toolset"),
   505  		apijson.Discriminator[BetaManagedAgentsCustomToolParams]("custom"),
   506  	)
   507  }
   508  
   509  type BetaManagedAgentsBranchCheckout struct {
   510  	// Branch name to check out.
   511  	Name string `json:"name" api:"required"`
   512  	// Any of "branch".
   513  	Type BetaManagedAgentsBranchCheckoutType `json:"type" api:"required"`
   514  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   515  	JSON struct {
   516  		Name        respjson.Field
   517  		Type        respjson.Field
   518  		ExtraFields map[string]respjson.Field
   519  		raw         string
   520  	} `json:"-"`
   521  }
   522  
   523  // Returns the unmodified JSON received from the API
   524  func (r BetaManagedAgentsBranchCheckout) RawJSON() string { return r.JSON.raw }
   525  func (r *BetaManagedAgentsBranchCheckout) UnmarshalJSON(data []byte) error {
   526  	return apijson.UnmarshalRoot(data, r)
   527  }
   528  
   529  // ToParam converts this BetaManagedAgentsBranchCheckout to a
   530  // BetaManagedAgentsBranchCheckoutParam.
   531  //
   532  // Warning: the fields of the param type will not be present. ToParam should only
   533  // be used at the last possible moment before sending a request. Test for this with
   534  // BetaManagedAgentsBranchCheckoutParam.Overrides()
   535  func (r BetaManagedAgentsBranchCheckout) ToParam() BetaManagedAgentsBranchCheckoutParam {
   536  	return param.Override[BetaManagedAgentsBranchCheckoutParam](json.RawMessage(r.RawJSON()))
   537  }
   538  
   539  type BetaManagedAgentsBranchCheckoutType string
   540  
   541  const (
   542  	BetaManagedAgentsBranchCheckoutTypeBranch BetaManagedAgentsBranchCheckoutType = "branch"
   543  )
   544  
   545  // The properties Name, Type are required.
   546  type BetaManagedAgentsBranchCheckoutParam struct {
   547  	// Branch name to check out.
   548  	Name string `json:"name" api:"required"`
   549  	// Any of "branch".
   550  	Type BetaManagedAgentsBranchCheckoutType `json:"type,omitzero" api:"required"`
   551  	paramObj
   552  }
   553  
   554  func (r BetaManagedAgentsBranchCheckoutParam) MarshalJSON() (data []byte, err error) {
   555  	type shadow BetaManagedAgentsBranchCheckoutParam
   556  	return param.MarshalObject(r, (*shadow)(&r))
   557  }
   558  func (r *BetaManagedAgentsBranchCheckoutParam) UnmarshalJSON(data []byte) error {
   559  	return apijson.UnmarshalRoot(data, r)
   560  }
   561  
   562  // A hard spend ceiling. The session stops issuing new model requests once the
   563  // tracked list cost reaches `max_list_cost`.
   564  type BetaManagedAgentsBudgetLimit struct {
   565  	// A monetary amount in a specific currency.
   566  	MaxListCost BetaMonetaryAmount `json:"max_list_cost" api:"required"`
   567  	// Any of "limit".
   568  	Type BetaManagedAgentsBudgetLimitType `json:"type" api:"required"`
   569  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   570  	JSON struct {
   571  		MaxListCost respjson.Field
   572  		Type        respjson.Field
   573  		ExtraFields map[string]respjson.Field
   574  		raw         string
   575  	} `json:"-"`
   576  }
   577  
   578  // Returns the unmodified JSON received from the API
   579  func (r BetaManagedAgentsBudgetLimit) RawJSON() string { return r.JSON.raw }
   580  func (r *BetaManagedAgentsBudgetLimit) UnmarshalJSON(data []byte) error {
   581  	return apijson.UnmarshalRoot(data, r)
   582  }
   583  
   584  // ToParam converts this BetaManagedAgentsBudgetLimit to a
   585  // BetaManagedAgentsBudgetLimitParam.
   586  //
   587  // Warning: the fields of the param type will not be present. ToParam should only
   588  // be used at the last possible moment before sending a request. Test for this with
   589  // BetaManagedAgentsBudgetLimitParam.Overrides()
   590  func (r BetaManagedAgentsBudgetLimit) ToParam() BetaManagedAgentsBudgetLimitParam {
   591  	return param.Override[BetaManagedAgentsBudgetLimitParam](json.RawMessage(r.RawJSON()))
   592  }
   593  
   594  type BetaManagedAgentsBudgetLimitType string
   595  
   596  const (
   597  	BetaManagedAgentsBudgetLimitTypeLimit BetaManagedAgentsBudgetLimitType = "limit"
   598  )
   599  
   600  // A hard spend ceiling. The session stops issuing new model requests once the
   601  // tracked list cost reaches `max_list_cost`.
   602  //
   603  // The properties MaxListCost, Type are required.
   604  type BetaManagedAgentsBudgetLimitParam struct {
   605  	// A monetary amount in a specific currency.
   606  	MaxListCost BetaMonetaryAmountParam `json:"max_list_cost,omitzero" api:"required"`
   607  	// Any of "limit".
   608  	Type BetaManagedAgentsBudgetLimitType `json:"type,omitzero" api:"required"`
   609  	paramObj
   610  }
   611  
   612  func (r BetaManagedAgentsBudgetLimitParam) MarshalJSON() (data []byte, err error) {
   613  	type shadow BetaManagedAgentsBudgetLimitParam
   614  	return param.MarshalObject(r, (*shadow)(&r))
   615  }
   616  func (r *BetaManagedAgentsBudgetLimitParam) UnmarshalJSON(data []byte) error {
   617  	return apijson.UnmarshalRoot(data, r)
   618  }
   619  
   620  // Prompt-cache creation token usage broken down by cache lifetime.
   621  type BetaManagedAgentsCacheCreationUsage struct {
   622  	// Tokens used to create 1-hour ephemeral cache entries.
   623  	Ephemeral1hInputTokens int64 `json:"ephemeral_1h_input_tokens"`
   624  	// Tokens used to create 5-minute ephemeral cache entries.
   625  	Ephemeral5mInputTokens int64 `json:"ephemeral_5m_input_tokens"`
   626  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   627  	JSON struct {
   628  		Ephemeral1hInputTokens respjson.Field
   629  		Ephemeral5mInputTokens respjson.Field
   630  		ExtraFields            map[string]respjson.Field
   631  		raw                    string
   632  	} `json:"-"`
   633  }
   634  
   635  // Returns the unmodified JSON received from the API
   636  func (r BetaManagedAgentsCacheCreationUsage) RawJSON() string { return r.JSON.raw }
   637  func (r *BetaManagedAgentsCacheCreationUsage) UnmarshalJSON(data []byte) error {
   638  	return apijson.UnmarshalRoot(data, r)
   639  }
   640  
   641  type BetaManagedAgentsCommitCheckout struct {
   642  	// Full commit SHA to check out.
   643  	Sha string `json:"sha" api:"required"`
   644  	// Any of "commit".
   645  	Type BetaManagedAgentsCommitCheckoutType `json:"type" api:"required"`
   646  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   647  	JSON struct {
   648  		Sha         respjson.Field
   649  		Type        respjson.Field
   650  		ExtraFields map[string]respjson.Field
   651  		raw         string
   652  	} `json:"-"`
   653  }
   654  
   655  // Returns the unmodified JSON received from the API
   656  func (r BetaManagedAgentsCommitCheckout) RawJSON() string { return r.JSON.raw }
   657  func (r *BetaManagedAgentsCommitCheckout) UnmarshalJSON(data []byte) error {
   658  	return apijson.UnmarshalRoot(data, r)
   659  }
   660  
   661  // ToParam converts this BetaManagedAgentsCommitCheckout to a
   662  // BetaManagedAgentsCommitCheckoutParam.
   663  //
   664  // Warning: the fields of the param type will not be present. ToParam should only
   665  // be used at the last possible moment before sending a request. Test for this with
   666  // BetaManagedAgentsCommitCheckoutParam.Overrides()
   667  func (r BetaManagedAgentsCommitCheckout) ToParam() BetaManagedAgentsCommitCheckoutParam {
   668  	return param.Override[BetaManagedAgentsCommitCheckoutParam](json.RawMessage(r.RawJSON()))
   669  }
   670  
   671  type BetaManagedAgentsCommitCheckoutType string
   672  
   673  const (
   674  	BetaManagedAgentsCommitCheckoutTypeCommit BetaManagedAgentsCommitCheckoutType = "commit"
   675  )
   676  
   677  // The properties Sha, Type are required.
   678  type BetaManagedAgentsCommitCheckoutParam struct {
   679  	// Full commit SHA to check out.
   680  	Sha string `json:"sha" api:"required"`
   681  	// Any of "commit".
   682  	Type BetaManagedAgentsCommitCheckoutType `json:"type,omitzero" api:"required"`
   683  	paramObj
   684  }
   685  
   686  func (r BetaManagedAgentsCommitCheckoutParam) MarshalJSON() (data []byte, err error) {
   687  	type shadow BetaManagedAgentsCommitCheckoutParam
   688  	return param.MarshalObject(r, (*shadow)(&r))
   689  }
   690  func (r *BetaManagedAgentsCommitCheckoutParam) UnmarshalJSON(data []byte) error {
   691  	return apijson.UnmarshalRoot(data, r)
   692  }
   693  
   694  // Confirmation that a `session` has been permanently deleted.
   695  type BetaManagedAgentsDeletedSession struct {
   696  	ID string `json:"id" api:"required"`
   697  	// Any of "session_deleted".
   698  	Type BetaManagedAgentsDeletedSessionType `json:"type" api:"required"`
   699  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   700  	JSON struct {
   701  		ID          respjson.Field
   702  		Type        respjson.Field
   703  		ExtraFields map[string]respjson.Field
   704  		raw         string
   705  	} `json:"-"`
   706  }
   707  
   708  // Returns the unmodified JSON received from the API
   709  func (r BetaManagedAgentsDeletedSession) RawJSON() string { return r.JSON.raw }
   710  func (r *BetaManagedAgentsDeletedSession) UnmarshalJSON(data []byte) error {
   711  	return apijson.UnmarshalRoot(data, r)
   712  }
   713  
   714  type BetaManagedAgentsDeletedSessionType string
   715  
   716  const (
   717  	BetaManagedAgentsDeletedSessionTypeSessionDeleted BetaManagedAgentsDeletedSessionType = "session_deleted"
   718  )
   719  
   720  type BetaManagedAgentsDeltaContent struct {
   721  	// Regular text content.
   722  	Content BetaManagedAgentsTextBlock `json:"content" api:"required"`
   723  	// Any of "content_delta".
   724  	Type BetaManagedAgentsDeltaContentType `json:"type" api:"required"`
   725  	// Which entry in the previewed event's content array this fragment lands in.
   726  	// Insert content as that entry when the index is new; append to the existing entry
   727  	// otherwise.
   728  	Index int64 `json:"index"`
   729  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   730  	JSON struct {
   731  		Content     respjson.Field
   732  		Type        respjson.Field
   733  		Index       respjson.Field
   734  		ExtraFields map[string]respjson.Field
   735  		raw         string
   736  	} `json:"-"`
   737  }
   738  
   739  // Returns the unmodified JSON received from the API
   740  func (r BetaManagedAgentsDeltaContent) RawJSON() string { return r.JSON.raw }
   741  func (r *BetaManagedAgentsDeltaContent) UnmarshalJSON(data []byte) error {
   742  	return apijson.UnmarshalRoot(data, r)
   743  }
   744  
   745  type BetaManagedAgentsDeltaContentType string
   746  
   747  const (
   748  	BetaManagedAgentsDeltaContentTypeContentDelta BetaManagedAgentsDeltaContentType = "content_delta"
   749  )
   750  
   751  // An incremental update to an event that is still being streamed. Deltas are
   752  // best-effort and may stop early; when the buffered event with id == event_id is
   753  // produced it carries the complete content. A model request that ends early (an
   754  // error or interrupt) produces no buffered event — its terminal
   755  // span.model_request_end closes the preview. Only sent on stream connections that
   756  // opt in via event_deltas; never appears in event history.
   757  type BetaManagedAgentsDeltaEvent struct {
   758  	// One fragment of the previewed event. The delta type is named for the previewed
   759  	// event's field it streams into: agent.message events stream content_delta
   760  	// fragments, each a partial element of the content array.
   761  	Delta BetaManagedAgentsDeltaContent `json:"delta" api:"required"`
   762  	// The id of the event being previewed. Matches event.id on the corresponding
   763  	// event_start and the buffered event that reconciles the preview.
   764  	EventID string `json:"event_id" api:"required"`
   765  	// Any of "event_delta".
   766  	Type BetaManagedAgentsDeltaEventType `json:"type" api:"required"`
   767  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   768  	JSON struct {
   769  		Delta       respjson.Field
   770  		EventID     respjson.Field
   771  		Type        respjson.Field
   772  		ExtraFields map[string]respjson.Field
   773  		raw         string
   774  	} `json:"-"`
   775  }
   776  
   777  // Returns the unmodified JSON received from the API
   778  func (r BetaManagedAgentsDeltaEvent) RawJSON() string { return r.JSON.raw }
   779  func (r *BetaManagedAgentsDeltaEvent) UnmarshalJSON(data []byte) error {
   780  	return apijson.UnmarshalRoot(data, r)
   781  }
   782  
   783  type BetaManagedAgentsDeltaEventType string
   784  
   785  const (
   786  	BetaManagedAgentsDeltaEventTypeEventDelta BetaManagedAgentsDeltaEventType = "event_delta"
   787  )
   788  
   789  // EventDeltaType enum
   790  type BetaManagedAgentsDeltaType string
   791  
   792  const (
   793  	BetaManagedAgentsDeltaTypeAgentMessage  BetaManagedAgentsDeltaType = "agent.message"
   794  	BetaManagedAgentsDeltaTypeAgentThinking BetaManagedAgentsDeltaType = "agent.thinking"
   795  )
   796  
   797  // Mount a file uploaded via the Files API into the session.
   798  //
   799  // The properties FileID, Type are required.
   800  type BetaManagedAgentsFileResourceParams struct {
   801  	// ID of a previously uploaded file.
   802  	FileID string `json:"file_id" api:"required"`
   803  	// Any of "file".
   804  	Type BetaManagedAgentsFileResourceParamsType `json:"type,omitzero" api:"required"`
   805  	// Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
   806  	MountPath param.Opt[string] `json:"mount_path,omitzero"`
   807  	paramObj
   808  }
   809  
   810  func (r BetaManagedAgentsFileResourceParams) MarshalJSON() (data []byte, err error) {
   811  	type shadow BetaManagedAgentsFileResourceParams
   812  	return param.MarshalObject(r, (*shadow)(&r))
   813  }
   814  func (r *BetaManagedAgentsFileResourceParams) UnmarshalJSON(data []byte) error {
   815  	return apijson.UnmarshalRoot(data, r)
   816  }
   817  
   818  type BetaManagedAgentsFileResourceParamsType string
   819  
   820  const (
   821  	BetaManagedAgentsFileResourceParamsTypeFile BetaManagedAgentsFileResourceParamsType = "file"
   822  )
   823  
   824  // Mount a GitHub repository into the session's container.
   825  //
   826  // The properties AuthorizationToken, Type, URL are required.
   827  type BetaManagedAgentsGitHubRepositoryResourceParams struct {
   828  	// GitHub authorization token used to clone the repository.
   829  	AuthorizationToken string `json:"authorization_token" api:"required"`
   830  	// Any of "github_repository".
   831  	Type BetaManagedAgentsGitHubRepositoryResourceParamsType `json:"type,omitzero" api:"required"`
   832  	// Github URL of the repository
   833  	URL string `json:"url" api:"required"`
   834  	// Mount path in the container. Defaults to `/workspace/<repo-name>`.
   835  	MountPath param.Opt[string] `json:"mount_path,omitzero"`
   836  	// Branch or commit to check out. Defaults to the repository's default branch.
   837  	Checkout BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion `json:"checkout,omitzero"`
   838  	paramObj
   839  }
   840  
   841  func (r BetaManagedAgentsGitHubRepositoryResourceParams) MarshalJSON() (data []byte, err error) {
   842  	type shadow BetaManagedAgentsGitHubRepositoryResourceParams
   843  	return param.MarshalObject(r, (*shadow)(&r))
   844  }
   845  func (r *BetaManagedAgentsGitHubRepositoryResourceParams) UnmarshalJSON(data []byte) error {
   846  	return apijson.UnmarshalRoot(data, r)
   847  }
   848  
   849  type BetaManagedAgentsGitHubRepositoryResourceParamsType string
   850  
   851  const (
   852  	BetaManagedAgentsGitHubRepositoryResourceParamsTypeGitHubRepository BetaManagedAgentsGitHubRepositoryResourceParamsType = "github_repository"
   853  )
   854  
   855  // Only one field can be non-zero.
   856  //
   857  // Use [param.IsOmitted] to confirm if a field is set.
   858  type BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion struct {
   859  	OfBranch *BetaManagedAgentsBranchCheckoutParam `json:",omitzero,inline"`
   860  	OfCommit *BetaManagedAgentsCommitCheckoutParam `json:",omitzero,inline"`
   861  	paramUnion
   862  }
   863  
   864  func (u BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion) MarshalJSON() ([]byte, error) {
   865  	return param.MarshalUnion(u, u.OfBranch, u.OfCommit)
   866  }
   867  func (u *BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion) UnmarshalJSON(data []byte) error {
   868  	return apijson.UnmarshalRoot(data, u)
   869  }
   870  
   871  func (u *BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion) asAny() any {
   872  	if !param.IsOmitted(u.OfBranch) {
   873  		return u.OfBranch
   874  	} else if !param.IsOmitted(u.OfCommit) {
   875  		return u.OfCommit
   876  	}
   877  	return nil
   878  }
   879  
   880  // Returns a pointer to the underlying variant's property, if present.
   881  func (u BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion) GetName() *string {
   882  	if vt := u.OfBranch; vt != nil {
   883  		return &vt.Name
   884  	}
   885  	return nil
   886  }
   887  
   888  // Returns a pointer to the underlying variant's property, if present.
   889  func (u BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion) GetSha() *string {
   890  	if vt := u.OfCommit; vt != nil {
   891  		return &vt.Sha
   892  	}
   893  	return nil
   894  }
   895  
   896  // Returns a pointer to the underlying variant's property, if present.
   897  func (u BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion) GetType() *string {
   898  	if vt := u.OfBranch; vt != nil {
   899  		return (*string)(&vt.Type)
   900  	} else if vt := u.OfCommit; vt != nil {
   901  		return (*string)(&vt.Type)
   902  	}
   903  	return nil
   904  }
   905  
   906  func init() {
   907  	apijson.RegisterUnion[BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion](
   908  		"type",
   909  		apijson.Discriminator[BetaManagedAgentsBranchCheckoutParam]("branch"),
   910  		apijson.Discriminator[BetaManagedAgentsCommitCheckoutParam]("commit"),
   911  	)
   912  }
   913  
   914  // Parameters for attaching a memory store to an agent session.
   915  //
   916  // The properties MemoryStoreID, Type are required.
   917  type BetaManagedAgentsMemoryStoreResourceParam struct {
   918  	// The memory store ID (memstore\_...). Must belong to the caller's organization
   919  	// and workspace.
   920  	MemoryStoreID string `json:"memory_store_id" api:"required"`
   921  	// Any of "memory_store".
   922  	Type BetaManagedAgentsMemoryStoreResourceParamType `json:"type,omitzero" api:"required"`
   923  	// Per-attachment guidance for the agent on how to use this store. Rendered into
   924  	// the memory section of the system prompt. Max 4096 chars.
   925  	Instructions param.Opt[string] `json:"instructions,omitzero"`
   926  	// Access mode for an attached memory store.
   927  	//
   928  	// Any of "read_write", "read_only".
   929  	Access BetaManagedAgentsMemoryStoreResourceParamAccess `json:"access,omitzero"`
   930  	paramObj
   931  }
   932  
   933  func (r BetaManagedAgentsMemoryStoreResourceParam) MarshalJSON() (data []byte, err error) {
   934  	type shadow BetaManagedAgentsMemoryStoreResourceParam
   935  	return param.MarshalObject(r, (*shadow)(&r))
   936  }
   937  func (r *BetaManagedAgentsMemoryStoreResourceParam) UnmarshalJSON(data []byte) error {
   938  	return apijson.UnmarshalRoot(data, r)
   939  }
   940  
   941  type BetaManagedAgentsMemoryStoreResourceParamType string
   942  
   943  const (
   944  	BetaManagedAgentsMemoryStoreResourceParamTypeMemoryStore BetaManagedAgentsMemoryStoreResourceParamType = "memory_store"
   945  )
   946  
   947  // Access mode for an attached memory store.
   948  type BetaManagedAgentsMemoryStoreResourceParamAccess string
   949  
   950  const (
   951  	BetaManagedAgentsMemoryStoreResourceParamAccessReadWrite BetaManagedAgentsMemoryStoreResourceParamAccess = "read_write"
   952  	BetaManagedAgentsMemoryStoreResourceParamAccessReadOnly  BetaManagedAgentsMemoryStoreResourceParamAccess = "read_only"
   953  )
   954  
   955  // Resolved coordinator topology with a concrete agent roster.
   956  type BetaManagedAgentsMultiagent struct {
   957  	// Agents the coordinator may spawn as session threads, each resolved to a specific
   958  	// version.
   959  	Agents []BetaManagedAgentsMultiagentAgentUnion `json:"agents" api:"required"`
   960  	// Any of "coordinator".
   961  	Type BetaManagedAgentsMultiagentType `json:"type" api:"required"`
   962  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   963  	JSON struct {
   964  		Agents      respjson.Field
   965  		Type        respjson.Field
   966  		ExtraFields map[string]respjson.Field
   967  		raw         string
   968  	} `json:"-"`
   969  }
   970  
   971  // Returns the unmodified JSON received from the API
   972  func (r BetaManagedAgentsMultiagent) RawJSON() string { return r.JSON.raw }
   973  func (r *BetaManagedAgentsMultiagent) UnmarshalJSON(data []byte) error {
   974  	return apijson.UnmarshalRoot(data, r)
   975  }
   976  
   977  // BetaManagedAgentsMultiagentAgentUnion contains all possible properties and
   978  // values from [BetaManagedAgentsAgentReference], [BetaManagedAgentsAdvisor].
   979  //
   980  // Use the [BetaManagedAgentsMultiagentAgentUnion.AsAny] method to switch on the
   981  // variant.
   982  //
   983  // Use the methods beginning with 'As' to cast the union to one of its variants.
   984  type BetaManagedAgentsMultiagentAgentUnion struct {
   985  	// This field is from variant [BetaManagedAgentsAgentReference].
   986  	ID string `json:"id"`
   987  	// Any of "agent", "advisor".
   988  	Type string `json:"type"`
   989  	// This field is from variant [BetaManagedAgentsAgentReference].
   990  	Version int64 `json:"version"`
   991  	// This field is from variant [BetaManagedAgentsAdvisor].
   992  	Model string `json:"model"`
   993  	JSON  struct {
   994  		ID      respjson.Field
   995  		Type    respjson.Field
   996  		Version respjson.Field
   997  		Model   respjson.Field
   998  		raw     string
   999  	} `json:"-"`
  1000  }
  1001  
  1002  // anyBetaManagedAgentsMultiagentAgent is implemented by each variant of
  1003  // [BetaManagedAgentsMultiagentAgentUnion] to add type safety for the return type
  1004  // of [BetaManagedAgentsMultiagentAgentUnion.AsAny]
  1005  type anyBetaManagedAgentsMultiagentAgent interface {
  1006  	implBetaManagedAgentsMultiagentAgentUnion()
  1007  }
  1008  
  1009  func (BetaManagedAgentsAgentReference) implBetaManagedAgentsMultiagentAgentUnion() {}
  1010  func (BetaManagedAgentsAdvisor) implBetaManagedAgentsMultiagentAgentUnion()        {}
  1011  
  1012  // Use the following switch statement to find the correct variant
  1013  //
  1014  //	switch variant := BetaManagedAgentsMultiagentAgentUnion.AsAny().(type) {
  1015  //	case anthropic.BetaManagedAgentsAgentReference:
  1016  //	case anthropic.BetaManagedAgentsAdvisor:
  1017  //	default:
  1018  //	  fmt.Errorf("no variant present")
  1019  //	}
  1020  func (u BetaManagedAgentsMultiagentAgentUnion) AsAny() anyBetaManagedAgentsMultiagentAgent {
  1021  	switch u.Type {
  1022  	case "agent":
  1023  		return u.AsAgent()
  1024  	case "advisor":
  1025  		return u.AsAdvisor()
  1026  	}
  1027  	return nil
  1028  }
  1029  
  1030  func (u BetaManagedAgentsMultiagentAgentUnion) AsAgent() (v BetaManagedAgentsAgentReference) {
  1031  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1032  	return
  1033  }
  1034  
  1035  func (u BetaManagedAgentsMultiagentAgentUnion) AsAdvisor() (v BetaManagedAgentsAdvisor) {
  1036  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1037  	return
  1038  }
  1039  
  1040  // Returns the unmodified JSON received from the API
  1041  func (u BetaManagedAgentsMultiagentAgentUnion) RawJSON() string { return u.JSON.raw }
  1042  
  1043  func (r *BetaManagedAgentsMultiagentAgentUnion) UnmarshalJSON(data []byte) error {
  1044  	return apijson.UnmarshalRoot(data, r)
  1045  }
  1046  
  1047  type BetaManagedAgentsMultiagentType string
  1048  
  1049  const (
  1050  	BetaManagedAgentsMultiagentTypeCoordinator BetaManagedAgentsMultiagentType = "coordinator"
  1051  )
  1052  
  1053  // A coordinator topology: the session's primary thread orchestrates work by
  1054  // spawning session threads, each running an agent drawn from the `agents` roster.
  1055  //
  1056  // The properties Agents, Type are required.
  1057  type BetaManagedAgentsMultiagentParams struct {
  1058  	// Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is
  1059  	// an agent ID string, a versioned `{"type":"agent","id","version"}` reference, or
  1060  	// `{"type":"self"}` to allow recursive self-invocation. Entries must reference
  1061  	// distinct agents (after resolving `self` and string forms); at most one `self`.
  1062  	// Referenced agents must exist, must not be archived, and must not themselves have
  1063  	// `multiagent` set (depth limit 1).
  1064  	Agents []BetaManagedAgentsMultiagentRosterEntryParamsUnion `json:"agents,omitzero" api:"required"`
  1065  	// Any of "coordinator".
  1066  	Type BetaManagedAgentsMultiagentParamsType `json:"type,omitzero" api:"required"`
  1067  	paramObj
  1068  }
  1069  
  1070  func (r BetaManagedAgentsMultiagentParams) MarshalJSON() (data []byte, err error) {
  1071  	type shadow BetaManagedAgentsMultiagentParams
  1072  	return param.MarshalObject(r, (*shadow)(&r))
  1073  }
  1074  func (r *BetaManagedAgentsMultiagentParams) UnmarshalJSON(data []byte) error {
  1075  	return apijson.UnmarshalRoot(data, r)
  1076  }
  1077  
  1078  type BetaManagedAgentsMultiagentParamsType string
  1079  
  1080  const (
  1081  	BetaManagedAgentsMultiagentParamsTypeCoordinator BetaManagedAgentsMultiagentParamsType = "coordinator"
  1082  )
  1083  
  1084  func BetaManagedAgentsMultiagentRosterEntryParamsOfBetaManagedAgentsAgents(id string, type_ BetaManagedAgentsAgentParamsType) BetaManagedAgentsMultiagentRosterEntryParamsUnion {
  1085  	var variant BetaManagedAgentsAgentParams
  1086  	variant.ID = id
  1087  	variant.Type = type_
  1088  	return BetaManagedAgentsMultiagentRosterEntryParamsUnion{OfBetaManagedAgentsAgents: &variant}
  1089  }
  1090  
  1091  func BetaManagedAgentsMultiagentRosterEntryParamsOfBetaManagedAgentsMultiagentSelfs(type_ BetaManagedAgentsMultiagentSelfParamsType) BetaManagedAgentsMultiagentRosterEntryParamsUnion {
  1092  	var variant BetaManagedAgentsMultiagentSelfParams
  1093  	variant.Type = type_
  1094  	return BetaManagedAgentsMultiagentRosterEntryParamsUnion{OfBetaManagedAgentsMultiagentSelfs: &variant}
  1095  }
  1096  
  1097  func BetaManagedAgentsMultiagentRosterEntryParamsOfBetaManagedAgentsAdvisors(model string, type_ BetaManagedAgentsAdvisorParamsType) BetaManagedAgentsMultiagentRosterEntryParamsUnion {
  1098  	var variant BetaManagedAgentsAdvisorParams
  1099  	variant.Model = model
  1100  	variant.Type = type_
  1101  	return BetaManagedAgentsMultiagentRosterEntryParamsUnion{OfBetaManagedAgentsAdvisors: &variant}
  1102  }
  1103  
  1104  // Only one field can be non-zero.
  1105  //
  1106  // Use [param.IsOmitted] to confirm if a field is set.
  1107  type BetaManagedAgentsMultiagentRosterEntryParamsUnion struct {
  1108  	OfString                           param.Opt[string]                      `json:",omitzero,inline"`
  1109  	OfBetaManagedAgentsAgents          *BetaManagedAgentsAgentParams          `json:",omitzero,inline"`
  1110  	OfBetaManagedAgentsMultiagentSelfs *BetaManagedAgentsMultiagentSelfParams `json:",omitzero,inline"`
  1111  	OfBetaManagedAgentsAdvisors        *BetaManagedAgentsAdvisorParams        `json:",omitzero,inline"`
  1112  	paramUnion
  1113  }
  1114  
  1115  func (u BetaManagedAgentsMultiagentRosterEntryParamsUnion) MarshalJSON() ([]byte, error) {
  1116  	return param.MarshalUnion(u, u.OfString, u.OfBetaManagedAgentsAgents, u.OfBetaManagedAgentsMultiagentSelfs, u.OfBetaManagedAgentsAdvisors)
  1117  }
  1118  func (u *BetaManagedAgentsMultiagentRosterEntryParamsUnion) UnmarshalJSON(data []byte) error {
  1119  	return apijson.UnmarshalRoot(data, u)
  1120  }
  1121  
  1122  func (u *BetaManagedAgentsMultiagentRosterEntryParamsUnion) asAny() any {
  1123  	if !param.IsOmitted(u.OfString) {
  1124  		return &u.OfString.Value
  1125  	} else if !param.IsOmitted(u.OfBetaManagedAgentsAgents) {
  1126  		return u.OfBetaManagedAgentsAgents
  1127  	} else if !param.IsOmitted(u.OfBetaManagedAgentsMultiagentSelfs) {
  1128  		return u.OfBetaManagedAgentsMultiagentSelfs
  1129  	} else if !param.IsOmitted(u.OfBetaManagedAgentsAdvisors) {
  1130  		return u.OfBetaManagedAgentsAdvisors
  1131  	}
  1132  	return nil
  1133  }
  1134  
  1135  // Returns a pointer to the underlying variant's property, if present.
  1136  func (u BetaManagedAgentsMultiagentRosterEntryParamsUnion) GetID() *string {
  1137  	if vt := u.OfBetaManagedAgentsAgents; vt != nil {
  1138  		return &vt.ID
  1139  	}
  1140  	return nil
  1141  }
  1142  
  1143  // Returns a pointer to the underlying variant's property, if present.
  1144  func (u BetaManagedAgentsMultiagentRosterEntryParamsUnion) GetVersion() *int64 {
  1145  	if vt := u.OfBetaManagedAgentsAgents; vt != nil && vt.Version.Valid() {
  1146  		return &vt.Version.Value
  1147  	}
  1148  	return nil
  1149  }
  1150  
  1151  // Returns a pointer to the underlying variant's property, if present.
  1152  func (u BetaManagedAgentsMultiagentRosterEntryParamsUnion) GetModel() *string {
  1153  	if vt := u.OfBetaManagedAgentsAdvisors; vt != nil {
  1154  		return &vt.Model
  1155  	}
  1156  	return nil
  1157  }
  1158  
  1159  // Returns a pointer to the underlying variant's property, if present.
  1160  func (u BetaManagedAgentsMultiagentRosterEntryParamsUnion) GetType() *string {
  1161  	if vt := u.OfBetaManagedAgentsAgents; vt != nil {
  1162  		return (*string)(&vt.Type)
  1163  	} else if vt := u.OfBetaManagedAgentsMultiagentSelfs; vt != nil {
  1164  		return (*string)(&vt.Type)
  1165  	} else if vt := u.OfBetaManagedAgentsAdvisors; vt != nil {
  1166  		return (*string)(&vt.Type)
  1167  	}
  1168  	return nil
  1169  }
  1170  
  1171  // Evaluation state for a single outcome defined via a `define_outcome` event.
  1172  type BetaManagedAgentsOutcomeEvaluationResource struct {
  1173  	// A timestamp in RFC 3339 format
  1174  	CompletedAt time.Time `json:"completed_at" api:"required" format:"date-time"`
  1175  	// What the agent should produce.
  1176  	Description string `json:"description" api:"required"`
  1177  	// Grader's verdict text from the most recent evaluation. For `satisfied`, explains
  1178  	// why criteria are met; for `needs_revision` (intermediate), what's missing; for
  1179  	// `failed`, why unrecoverable.
  1180  	Explanation string `json:"explanation" api:"required"`
  1181  	// 0-indexed revision cycle the outcome is currently on.
  1182  	Iteration int64 `json:"iteration" api:"required"`
  1183  	// Server-generated outc\_ ID for this outcome.
  1184  	OutcomeID string `json:"outcome_id" api:"required"`
  1185  	// Current evaluation state. `pending` before the agent begins work; `running`
  1186  	// while producing or revising; `evaluating` while the grader scores;
  1187  	// `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
  1188  	Result string `json:"result" api:"required"`
  1189  	// Any of "outcome_evaluation".
  1190  	Type BetaManagedAgentsOutcomeEvaluationResourceType `json:"type" api:"required"`
  1191  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  1192  	JSON struct {
  1193  		CompletedAt respjson.Field
  1194  		Description respjson.Field
  1195  		Explanation respjson.Field
  1196  		Iteration   respjson.Field
  1197  		OutcomeID   respjson.Field
  1198  		Result      respjson.Field
  1199  		Type        respjson.Field
  1200  		ExtraFields map[string]respjson.Field
  1201  		raw         string
  1202  	} `json:"-"`
  1203  }
  1204  
  1205  // Returns the unmodified JSON received from the API
  1206  func (r BetaManagedAgentsOutcomeEvaluationResource) RawJSON() string { return r.JSON.raw }
  1207  func (r *BetaManagedAgentsOutcomeEvaluationResource) UnmarshalJSON(data []byte) error {
  1208  	return apijson.UnmarshalRoot(data, r)
  1209  }
  1210  
  1211  type BetaManagedAgentsOutcomeEvaluationResourceType string
  1212  
  1213  const (
  1214  	BetaManagedAgentsOutcomeEvaluationResourceTypeOutcomeEvaluation BetaManagedAgentsOutcomeEvaluationResourceType = "outcome_evaluation"
  1215  )
  1216  
  1217  // Cumulative count of server-executed tool invocations, broken down by tool.
  1218  type BetaManagedAgentsServerToolUsage struct {
  1219  	// Number of server-executed web fetch requests.
  1220  	WebFetchRequests int64 `json:"web_fetch_requests"`
  1221  	// Number of server-executed web search requests.
  1222  	WebSearchRequests int64 `json:"web_search_requests"`
  1223  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  1224  	JSON struct {
  1225  		WebFetchRequests  respjson.Field
  1226  		WebSearchRequests respjson.Field
  1227  		ExtraFields       map[string]respjson.Field
  1228  		raw               string
  1229  	} `json:"-"`
  1230  }
  1231  
  1232  // Returns the unmodified JSON received from the API
  1233  func (r BetaManagedAgentsServerToolUsage) RawJSON() string { return r.JSON.raw }
  1234  func (r *BetaManagedAgentsServerToolUsage) UnmarshalJSON(data []byte) error {
  1235  	return apijson.UnmarshalRoot(data, r)
  1236  }
  1237  
  1238  // A Managed Agents `session`.
  1239  type BetaManagedAgentsSession struct {
  1240  	ID string `json:"id" api:"required"`
  1241  	// Resolved `agent` definition for a `session`. Snapshot of the `agent` at
  1242  	// `session` creation time.
  1243  	Agent BetaManagedAgentsSessionAgent `json:"agent" api:"required"`
  1244  	// A timestamp in RFC 3339 format
  1245  	ArchivedAt time.Time `json:"archived_at" api:"required" format:"date-time"`
  1246  	// A hard spend ceiling. The session stops issuing new model requests once the
  1247  	// tracked list cost reaches `max_list_cost`.
  1248  	Budget BetaManagedAgentsBudgetLimit `json:"budget" api:"required"`
  1249  	// A timestamp in RFC 3339 format
  1250  	CreatedAt     time.Time         `json:"created_at" api:"required" format:"date-time"`
  1251  	EnvironmentID string            `json:"environment_id" api:"required"`
  1252  	Metadata      map[string]string `json:"metadata" api:"required"`
  1253  	// Per-outcome evaluation state. One entry per `define_outcome` event sent to the
  1254  	// session.
  1255  	OutcomeEvaluations []BetaManagedAgentsOutcomeEvaluationResource `json:"outcome_evaluations" api:"required"`
  1256  	Resources          []BetaManagedAgentsSessionResourceUnion      `json:"resources" api:"required"`
  1257  	// Timing statistics for a session.
  1258  	Stats BetaManagedAgentsSessionStats `json:"stats" api:"required"`
  1259  	// SessionStatus enum
  1260  	//
  1261  	// Any of "rescheduling", "running", "idle", "terminated".
  1262  	Status BetaManagedAgentsSessionStatus `json:"status" api:"required"`
  1263  	Title  string                         `json:"title" api:"required"`
  1264  	// Any of "session".
  1265  	Type BetaManagedAgentsSessionType `json:"type" api:"required"`
  1266  	// A timestamp in RFC 3339 format
  1267  	UpdatedAt time.Time `json:"updated_at" api:"required" format:"date-time"`
  1268  	// Cumulative token usage for a session across all turns.
  1269  	Usage BetaManagedAgentsSessionUsage `json:"usage" api:"required"`
  1270  	// Vault IDs attached to the session at creation. Empty when no vaults were
  1271  	// supplied.
  1272  	VaultIDs []string `json:"vault_ids" api:"required"`
  1273  	// Deployment ID when the session was created from a deployment reference. Null
  1274  	// otherwise.
  1275  	DeploymentID string `json:"deployment_id" api:"nullable"`
  1276  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  1277  	JSON struct {
  1278  		ID                 respjson.Field
  1279  		Agent              respjson.Field
  1280  		ArchivedAt         respjson.Field
  1281  		Budget             respjson.Field
  1282  		CreatedAt          respjson.Field
  1283  		EnvironmentID      respjson.Field
  1284  		Metadata           respjson.Field
  1285  		OutcomeEvaluations respjson.Field
  1286  		Resources          respjson.Field
  1287  		Stats              respjson.Field
  1288  		Status             respjson.Field
  1289  		Title              respjson.Field
  1290  		Type               respjson.Field
  1291  		UpdatedAt          respjson.Field
  1292  		Usage              respjson.Field
  1293  		VaultIDs           respjson.Field
  1294  		DeploymentID       respjson.Field
  1295  		ExtraFields        map[string]respjson.Field
  1296  		raw                string
  1297  	} `json:"-"`
  1298  }
  1299  
  1300  // Returns the unmodified JSON received from the API
  1301  func (r BetaManagedAgentsSession) RawJSON() string { return r.JSON.raw }
  1302  func (r *BetaManagedAgentsSession) UnmarshalJSON(data []byte) error {
  1303  	return apijson.UnmarshalRoot(data, r)
  1304  }
  1305  
  1306  // SessionStatus enum
  1307  type BetaManagedAgentsSessionStatus string
  1308  
  1309  const (
  1310  	BetaManagedAgentsSessionStatusRescheduling BetaManagedAgentsSessionStatus = "rescheduling"
  1311  	BetaManagedAgentsSessionStatusRunning      BetaManagedAgentsSessionStatus = "running"
  1312  	BetaManagedAgentsSessionStatusIdle         BetaManagedAgentsSessionStatus = "idle"
  1313  	BetaManagedAgentsSessionStatusTerminated   BetaManagedAgentsSessionStatus = "terminated"
  1314  )
  1315  
  1316  type BetaManagedAgentsSessionType string
  1317  
  1318  const (
  1319  	BetaManagedAgentsSessionTypeSession BetaManagedAgentsSessionType = "session"
  1320  )
  1321  
  1322  // Resolved `agent` definition for a `session`. Snapshot of the `agent` at
  1323  // `session` creation time.
  1324  type BetaManagedAgentsSessionAgent struct {
  1325  	ID          string                                    `json:"id" api:"required"`
  1326  	Description string                                    `json:"description" api:"required"`
  1327  	MCPServers  []BetaManagedAgentsMCPServerURLDefinition `json:"mcp_servers" api:"required"`
  1328  	// Model identifier and configuration.
  1329  	Model BetaManagedAgentsModelConfig `json:"model" api:"required"`
  1330  	// Resolved coordinator topology with full agent definitions for each roster
  1331  	// member.
  1332  	Multiagent BetaManagedAgentsSessionMultiagentCoordinator `json:"multiagent" api:"required"`
  1333  	Name       string                                        `json:"name" api:"required"`
  1334  	Skills     []BetaManagedAgentsSessionAgentSkillUnion     `json:"skills" api:"required"`
  1335  	System     string                                        `json:"system" api:"required"`
  1336  	Tools      []BetaManagedAgentsSessionAgentToolUnion      `json:"tools" api:"required"`
  1337  	// Any of "agent".
  1338  	Type    BetaManagedAgentsSessionAgentType `json:"type" api:"required"`
  1339  	Version int64                             `json:"version" api:"required"`
  1340  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  1341  	JSON struct {
  1342  		ID          respjson.Field
  1343  		Description respjson.Field
  1344  		MCPServers  respjson.Field
  1345  		Model       respjson.Field
  1346  		Multiagent  respjson.Field
  1347  		Name        respjson.Field
  1348  		Skills      respjson.Field
  1349  		System      respjson.Field
  1350  		Tools       respjson.Field
  1351  		Type        respjson.Field
  1352  		Version     respjson.Field
  1353  		ExtraFields map[string]respjson.Field
  1354  		raw         string
  1355  	} `json:"-"`
  1356  }
  1357  
  1358  // Returns the unmodified JSON received from the API
  1359  func (r BetaManagedAgentsSessionAgent) RawJSON() string { return r.JSON.raw }
  1360  func (r *BetaManagedAgentsSessionAgent) UnmarshalJSON(data []byte) error {
  1361  	return apijson.UnmarshalRoot(data, r)
  1362  }
  1363  
  1364  // BetaManagedAgentsSessionAgentSkillUnion contains all possible properties and
  1365  // values from [BetaManagedAgentsAnthropicSkill], [BetaManagedAgentsCustomSkill].
  1366  //
  1367  // Use the [BetaManagedAgentsSessionAgentSkillUnion.AsAny] method to switch on the
  1368  // variant.
  1369  //
  1370  // Use the methods beginning with 'As' to cast the union to one of its variants.
  1371  type BetaManagedAgentsSessionAgentSkillUnion struct {
  1372  	SkillID string `json:"skill_id"`
  1373  	// Any of "anthropic", "custom".
  1374  	Type    string `json:"type"`
  1375  	Version string `json:"version"`
  1376  	JSON    struct {
  1377  		SkillID respjson.Field
  1378  		Type    respjson.Field
  1379  		Version respjson.Field
  1380  		raw     string
  1381  	} `json:"-"`
  1382  }
  1383  
  1384  // anyBetaManagedAgentsSessionAgentSkill is implemented by each variant of
  1385  // [BetaManagedAgentsSessionAgentSkillUnion] to add type safety for the return type
  1386  // of [BetaManagedAgentsSessionAgentSkillUnion.AsAny]
  1387  type anyBetaManagedAgentsSessionAgentSkill interface {
  1388  	implBetaManagedAgentsSessionAgentSkillUnion()
  1389  }
  1390  
  1391  func (BetaManagedAgentsAnthropicSkill) implBetaManagedAgentsSessionAgentSkillUnion() {}
  1392  func (BetaManagedAgentsCustomSkill) implBetaManagedAgentsSessionAgentSkillUnion()    {}
  1393  
  1394  // Use the following switch statement to find the correct variant
  1395  //
  1396  //	switch variant := BetaManagedAgentsSessionAgentSkillUnion.AsAny().(type) {
  1397  //	case anthropic.BetaManagedAgentsAnthropicSkill:
  1398  //	case anthropic.BetaManagedAgentsCustomSkill:
  1399  //	default:
  1400  //	  fmt.Errorf("no variant present")
  1401  //	}
  1402  func (u BetaManagedAgentsSessionAgentSkillUnion) AsAny() anyBetaManagedAgentsSessionAgentSkill {
  1403  	switch u.Type {
  1404  	case "anthropic":
  1405  		return u.AsAnthropic()
  1406  	case "custom":
  1407  		return u.AsCustom()
  1408  	}
  1409  	return nil
  1410  }
  1411  
  1412  func (u BetaManagedAgentsSessionAgentSkillUnion) AsAnthropic() (v BetaManagedAgentsAnthropicSkill) {
  1413  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1414  	return
  1415  }
  1416  
  1417  func (u BetaManagedAgentsSessionAgentSkillUnion) AsCustom() (v BetaManagedAgentsCustomSkill) {
  1418  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1419  	return
  1420  }
  1421  
  1422  // Returns the unmodified JSON received from the API
  1423  func (u BetaManagedAgentsSessionAgentSkillUnion) RawJSON() string { return u.JSON.raw }
  1424  
  1425  func (r *BetaManagedAgentsSessionAgentSkillUnion) UnmarshalJSON(data []byte) error {
  1426  	return apijson.UnmarshalRoot(data, r)
  1427  }
  1428  
  1429  // BetaManagedAgentsSessionAgentToolUnion contains all possible properties and
  1430  // values from [BetaManagedAgentsAgentToolset20260401],
  1431  // [BetaManagedAgentsMCPToolset], [BetaManagedAgentsCustomTool].
  1432  //
  1433  // Use the [BetaManagedAgentsSessionAgentToolUnion.AsAny] method to switch on the
  1434  // variant.
  1435  //
  1436  // Use the methods beginning with 'As' to cast the union to one of its variants.
  1437  type BetaManagedAgentsSessionAgentToolUnion struct {
  1438  	// This field is a union of [[]BetaManagedAgentsAgentToolConfigUnion],
  1439  	// [[]BetaManagedAgentsMCPToolConfig]
  1440  	Configs BetaManagedAgentsSessionAgentToolUnionConfigs `json:"configs"`
  1441  	// This field is a union of [BetaManagedAgentsAgentToolsetDefaultConfig],
  1442  	// [BetaManagedAgentsMCPToolsetDefaultConfig]
  1443  	DefaultConfig BetaManagedAgentsSessionAgentToolUnionDefaultConfig `json:"default_config"`
  1444  	// Any of "agent_toolset_20260401", "mcp_toolset", "custom".
  1445  	Type string `json:"type"`
  1446  	// This field is from variant [BetaManagedAgentsMCPToolset].
  1447  	MCPServerName string `json:"mcp_server_name"`
  1448  	// This field is from variant [BetaManagedAgentsCustomTool].
  1449  	Description string `json:"description"`
  1450  	// This field is from variant [BetaManagedAgentsCustomTool].
  1451  	InputSchema BetaManagedAgentsCustomToolInputSchema `json:"input_schema"`
  1452  	// This field is from variant [BetaManagedAgentsCustomTool].
  1453  	Name string `json:"name"`
  1454  	JSON struct {
  1455  		Configs       respjson.Field
  1456  		DefaultConfig respjson.Field
  1457  		Type          respjson.Field
  1458  		MCPServerName respjson.Field
  1459  		Description   respjson.Field
  1460  		InputSchema   respjson.Field
  1461  		Name          respjson.Field
  1462  		raw           string
  1463  	} `json:"-"`
  1464  }
  1465  
  1466  // anyBetaManagedAgentsSessionAgentTool is implemented by each variant of
  1467  // [BetaManagedAgentsSessionAgentToolUnion] to add type safety for the return type
  1468  // of [BetaManagedAgentsSessionAgentToolUnion.AsAny]
  1469  type anyBetaManagedAgentsSessionAgentTool interface {
  1470  	implBetaManagedAgentsSessionAgentToolUnion()
  1471  }
  1472  
  1473  func (BetaManagedAgentsAgentToolset20260401) implBetaManagedAgentsSessionAgentToolUnion() {}
  1474  func (BetaManagedAgentsMCPToolset) implBetaManagedAgentsSessionAgentToolUnion()           {}
  1475  func (BetaManagedAgentsCustomTool) implBetaManagedAgentsSessionAgentToolUnion()           {}
  1476  
  1477  // Use the following switch statement to find the correct variant
  1478  //
  1479  //	switch variant := BetaManagedAgentsSessionAgentToolUnion.AsAny().(type) {
  1480  //	case anthropic.BetaManagedAgentsAgentToolset20260401:
  1481  //	case anthropic.BetaManagedAgentsMCPToolset:
  1482  //	case anthropic.BetaManagedAgentsCustomTool:
  1483  //	default:
  1484  //	  fmt.Errorf("no variant present")
  1485  //	}
  1486  func (u BetaManagedAgentsSessionAgentToolUnion) AsAny() anyBetaManagedAgentsSessionAgentTool {
  1487  	switch u.Type {
  1488  	case "agent_toolset_20260401":
  1489  		return u.AsAgentToolset20260401()
  1490  	case "mcp_toolset":
  1491  		return u.AsMCPToolset()
  1492  	case "custom":
  1493  		return u.AsCustom()
  1494  	}
  1495  	return nil
  1496  }
  1497  
  1498  func (u BetaManagedAgentsSessionAgentToolUnion) AsAgentToolset20260401() (v BetaManagedAgentsAgentToolset20260401) {
  1499  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1500  	return
  1501  }
  1502  
  1503  func (u BetaManagedAgentsSessionAgentToolUnion) AsMCPToolset() (v BetaManagedAgentsMCPToolset) {
  1504  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1505  	return
  1506  }
  1507  
  1508  func (u BetaManagedAgentsSessionAgentToolUnion) AsCustom() (v BetaManagedAgentsCustomTool) {
  1509  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1510  	return
  1511  }
  1512  
  1513  // Returns the unmodified JSON received from the API
  1514  func (u BetaManagedAgentsSessionAgentToolUnion) RawJSON() string { return u.JSON.raw }
  1515  
  1516  func (r *BetaManagedAgentsSessionAgentToolUnion) UnmarshalJSON(data []byte) error {
  1517  	return apijson.UnmarshalRoot(data, r)
  1518  }
  1519  
  1520  // BetaManagedAgentsSessionAgentToolUnionConfigs is an implicit subunion of
  1521  // [BetaManagedAgentsSessionAgentToolUnion].
  1522  // BetaManagedAgentsSessionAgentToolUnionConfigs provides convenient access to the
  1523  // sub-properties of the union.
  1524  //
  1525  // For type safety it is recommended to directly use a variant of the
  1526  // [BetaManagedAgentsSessionAgentToolUnion].
  1527  //
  1528  // If the underlying value is not a json object, one of the following properties
  1529  // will be valid: OfBetaManagedAgentsAgentToolConfigArray
  1530  // OfBetaManagedAgentsMCPToolConfigArray]
  1531  type BetaManagedAgentsSessionAgentToolUnionConfigs struct {
  1532  	// This field will be present if the value is a
  1533  	// [[]BetaManagedAgentsAgentToolConfigUnion] instead of an object.
  1534  	OfBetaManagedAgentsAgentToolConfigArray []BetaManagedAgentsAgentToolConfigUnion `json:",inline"`
  1535  	// This field will be present if the value is a [[]BetaManagedAgentsMCPToolConfig]
  1536  	// instead of an object.
  1537  	OfBetaManagedAgentsMCPToolConfigArray []BetaManagedAgentsMCPToolConfig `json:",inline"`
  1538  	JSON                                  struct {
  1539  		OfBetaManagedAgentsAgentToolConfigArray respjson.Field
  1540  		OfBetaManagedAgentsMCPToolConfigArray   respjson.Field
  1541  		raw                                     string
  1542  	} `json:"-"`
  1543  }
  1544  
  1545  func (r *BetaManagedAgentsSessionAgentToolUnionConfigs) UnmarshalJSON(data []byte) error {
  1546  	return apijson.UnmarshalRoot(data, r)
  1547  }
  1548  
  1549  // BetaManagedAgentsSessionAgentToolUnionDefaultConfig is an implicit subunion of
  1550  // [BetaManagedAgentsSessionAgentToolUnion].
  1551  // BetaManagedAgentsSessionAgentToolUnionDefaultConfig provides convenient access
  1552  // to the sub-properties of the union.
  1553  //
  1554  // For type safety it is recommended to directly use a variant of the
  1555  // [BetaManagedAgentsSessionAgentToolUnion].
  1556  type BetaManagedAgentsSessionAgentToolUnionDefaultConfig struct {
  1557  	Enabled bool `json:"enabled"`
  1558  	// This field is a union of
  1559  	// [BetaManagedAgentsAgentToolsetDefaultConfigPermissionPolicyUnion],
  1560  	// [BetaManagedAgentsMCPToolsetDefaultConfigPermissionPolicyUnion]
  1561  	PermissionPolicy BetaManagedAgentsSessionAgentToolUnionDefaultConfigPermissionPolicy `json:"permission_policy"`
  1562  	JSON             struct {
  1563  		Enabled          respjson.Field
  1564  		PermissionPolicy respjson.Field
  1565  		raw              string
  1566  	} `json:"-"`
  1567  }
  1568  
  1569  func (r *BetaManagedAgentsSessionAgentToolUnionDefaultConfig) UnmarshalJSON(data []byte) error {
  1570  	return apijson.UnmarshalRoot(data, r)
  1571  }
  1572  
  1573  // BetaManagedAgentsSessionAgentToolUnionDefaultConfigPermissionPolicy is an
  1574  // implicit subunion of [BetaManagedAgentsSessionAgentToolUnion].
  1575  // BetaManagedAgentsSessionAgentToolUnionDefaultConfigPermissionPolicy provides
  1576  // convenient access to the sub-properties of the union.
  1577  //
  1578  // For type safety it is recommended to directly use a variant of the
  1579  // [BetaManagedAgentsSessionAgentToolUnion].
  1580  type BetaManagedAgentsSessionAgentToolUnionDefaultConfigPermissionPolicy struct {
  1581  	Type string `json:"type"`
  1582  	JSON struct {
  1583  		Type respjson.Field
  1584  		raw  string
  1585  	} `json:"-"`
  1586  }
  1587  
  1588  func (r *BetaManagedAgentsSessionAgentToolUnionDefaultConfigPermissionPolicy) UnmarshalJSON(data []byte) error {
  1589  	return apijson.UnmarshalRoot(data, r)
  1590  }
  1591  
  1592  type BetaManagedAgentsSessionAgentType string
  1593  
  1594  const (
  1595  	BetaManagedAgentsSessionAgentTypeAgent BetaManagedAgentsSessionAgentType = "agent"
  1596  )
  1597  
  1598  // Mid-session agent configuration update. Only `tools` and `mcp_servers` are
  1599  // updatable. Full replacement: the provided array becomes the new value. To
  1600  // preserve existing entries, GET the session, modify the array, and POST it back.
  1601  type BetaManagedAgentsSessionAgentUpdateParam struct {
  1602  	// Replacement MCP server list. Full replacement: the provided array becomes the
  1603  	// new value. Send an empty array to clear; omit to preserve.
  1604  	MCPServers []BetaManagedAgentsURLMCPServerParams `json:"mcp_servers,omitzero"`
  1605  	// Replacement tool list. Full replacement: the provided array becomes the new
  1606  	// value. Send an empty array to clear; omit to preserve.
  1607  	Tools []BetaManagedAgentsSessionAgentUpdateToolUnionParam `json:"tools,omitzero"`
  1608  	paramObj
  1609  }
  1610  
  1611  func (r BetaManagedAgentsSessionAgentUpdateParam) MarshalJSON() (data []byte, err error) {
  1612  	type shadow BetaManagedAgentsSessionAgentUpdateParam
  1613  	return param.MarshalObject(r, (*shadow)(&r))
  1614  }
  1615  func (r *BetaManagedAgentsSessionAgentUpdateParam) UnmarshalJSON(data []byte) error {
  1616  	return apijson.UnmarshalRoot(data, r)
  1617  }
  1618  
  1619  // Only one field can be non-zero.
  1620  //
  1621  // Use [param.IsOmitted] to confirm if a field is set.
  1622  type BetaManagedAgentsSessionAgentUpdateToolUnionParam struct {
  1623  	OfAgentToolset20260401 *BetaManagedAgentsAgentToolset20260401Params `json:",omitzero,inline"`
  1624  	OfMCPToolset           *BetaManagedAgentsMCPToolsetParams           `json:",omitzero,inline"`
  1625  	OfCustom               *BetaManagedAgentsCustomToolParams           `json:",omitzero,inline"`
  1626  	paramUnion
  1627  }
  1628  
  1629  func (u BetaManagedAgentsSessionAgentUpdateToolUnionParam) MarshalJSON() ([]byte, error) {
  1630  	return param.MarshalUnion(u, u.OfAgentToolset20260401, u.OfMCPToolset, u.OfCustom)
  1631  }
  1632  func (u *BetaManagedAgentsSessionAgentUpdateToolUnionParam) UnmarshalJSON(data []byte) error {
  1633  	return apijson.UnmarshalRoot(data, u)
  1634  }
  1635  
  1636  func (u *BetaManagedAgentsSessionAgentUpdateToolUnionParam) asAny() any {
  1637  	if !param.IsOmitted(u.OfAgentToolset20260401) {
  1638  		return u.OfAgentToolset20260401
  1639  	} else if !param.IsOmitted(u.OfMCPToolset) {
  1640  		return u.OfMCPToolset
  1641  	} else if !param.IsOmitted(u.OfCustom) {
  1642  		return u.OfCustom
  1643  	}
  1644  	return nil
  1645  }
  1646  
  1647  // Returns a pointer to the underlying variant's property, if present.
  1648  func (u BetaManagedAgentsSessionAgentUpdateToolUnionParam) GetMCPServerName() *string {
  1649  	if vt := u.OfMCPToolset; vt != nil {
  1650  		return &vt.MCPServerName
  1651  	}
  1652  	return nil
  1653  }
  1654  
  1655  // Returns a pointer to the underlying variant's property, if present.
  1656  func (u BetaManagedAgentsSessionAgentUpdateToolUnionParam) GetDescription() *string {
  1657  	if vt := u.OfCustom; vt != nil {
  1658  		return &vt.Description
  1659  	}
  1660  	return nil
  1661  }
  1662  
  1663  // Returns a pointer to the underlying variant's property, if present.
  1664  func (u BetaManagedAgentsSessionAgentUpdateToolUnionParam) GetInputSchema() *BetaManagedAgentsCustomToolInputSchemaParam {
  1665  	if vt := u.OfCustom; vt != nil {
  1666  		return &vt.InputSchema
  1667  	}
  1668  	return nil
  1669  }
  1670  
  1671  // Returns a pointer to the underlying variant's property, if present.
  1672  func (u BetaManagedAgentsSessionAgentUpdateToolUnionParam) GetName() *string {
  1673  	if vt := u.OfCustom; vt != nil {
  1674  		return &vt.Name
  1675  	}
  1676  	return nil
  1677  }
  1678  
  1679  // Returns a pointer to the underlying variant's property, if present.
  1680  func (u BetaManagedAgentsSessionAgentUpdateToolUnionParam) GetType() *string {
  1681  	if vt := u.OfAgentToolset20260401; vt != nil {
  1682  		return (*string)(&vt.Type)
  1683  	} else if vt := u.OfMCPToolset; vt != nil {
  1684  		return (*string)(&vt.Type)
  1685  	} else if vt := u.OfCustom; vt != nil {
  1686  		return (*string)(&vt.Type)
  1687  	}
  1688  	return nil
  1689  }
  1690  
  1691  // Returns a subunion which exports methods to access subproperties
  1692  //
  1693  // Or use AsAny() to get the underlying value
  1694  func (u BetaManagedAgentsSessionAgentUpdateToolUnionParam) GetConfigs() (res betaManagedAgentsSessionAgentUpdateToolUnionParamConfigs) {
  1695  	if vt := u.OfAgentToolset20260401; vt != nil {
  1696  		res.any = &vt.Configs
  1697  	} else if vt := u.OfMCPToolset; vt != nil {
  1698  		res.any = &vt.Configs
  1699  	}
  1700  	return
  1701  }
  1702  
  1703  // Can have the runtime types [_[]BetaManagedAgentsAgentToolConfigParamsUnion],
  1704  // [_[]BetaManagedAgentsMCPToolConfigParams]
  1705  type betaManagedAgentsSessionAgentUpdateToolUnionParamConfigs struct{ any }
  1706  
  1707  // Use the following switch statement to get the type of the union:
  1708  //
  1709  //	switch u.AsAny().(type) {
  1710  //	case *[]anthropic.BetaManagedAgentsAgentToolConfigParamsUnion:
  1711  //	case *[]anthropic.BetaManagedAgentsMCPToolConfigParams:
  1712  //	default:
  1713  //	    fmt.Errorf("not present")
  1714  //	}
  1715  func (u betaManagedAgentsSessionAgentUpdateToolUnionParamConfigs) AsAny() any { return u.any }
  1716  
  1717  // Returns a subunion which exports methods to access subproperties
  1718  //
  1719  // Or use AsAny() to get the underlying value
  1720  func (u BetaManagedAgentsSessionAgentUpdateToolUnionParam) GetDefaultConfig() (res betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfig) {
  1721  	if vt := u.OfAgentToolset20260401; vt != nil {
  1722  		res.any = &vt.DefaultConfig
  1723  	} else if vt := u.OfMCPToolset; vt != nil {
  1724  		res.any = &vt.DefaultConfig
  1725  	}
  1726  	return
  1727  }
  1728  
  1729  // Can have the runtime types [*BetaManagedAgentsAgentToolsetDefaultConfigParams],
  1730  // [*BetaManagedAgentsMCPToolsetDefaultConfigParams]
  1731  type betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfig struct{ any }
  1732  
  1733  // Use the following switch statement to get the type of the union:
  1734  //
  1735  //	switch u.AsAny().(type) {
  1736  //	case *anthropic.BetaManagedAgentsAgentToolsetDefaultConfigParams:
  1737  //	case *anthropic.BetaManagedAgentsMCPToolsetDefaultConfigParams:
  1738  //	default:
  1739  //	    fmt.Errorf("not present")
  1740  //	}
  1741  func (u betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfig) AsAny() any { return u.any }
  1742  
  1743  // Returns a pointer to the underlying variant's property, if present.
  1744  func (u betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfig) GetEnabled() *bool {
  1745  	switch vt := u.any.(type) {
  1746  	case *BetaManagedAgentsAgentToolsetDefaultConfigParams:
  1747  		return paramutil.AddrIfPresent(vt.Enabled)
  1748  	case *BetaManagedAgentsMCPToolsetDefaultConfigParams:
  1749  		return paramutil.AddrIfPresent(vt.Enabled)
  1750  	}
  1751  	return nil
  1752  }
  1753  
  1754  // Returns a subunion which exports methods to access subproperties
  1755  //
  1756  // Or use AsAny() to get the underlying value
  1757  func (u betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfig) GetPermissionPolicy() (res betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfigPermissionPolicy) {
  1758  	switch vt := u.any.(type) {
  1759  	case *BetaManagedAgentsAgentToolsetDefaultConfigParams:
  1760  		res.any = vt.PermissionPolicy
  1761  	case *BetaManagedAgentsMCPToolsetDefaultConfigParams:
  1762  		res.any = vt.PermissionPolicy
  1763  	}
  1764  	return res
  1765  }
  1766  
  1767  // Can have the runtime types [*BetaManagedAgentsAlwaysAllowPolicyParam],
  1768  // [*BetaManagedAgentsAlwaysAskPolicyParam]
  1769  type betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfigPermissionPolicy struct{ any }
  1770  
  1771  // Use the following switch statement to get the type of the union:
  1772  //
  1773  //	switch u.AsAny().(type) {
  1774  //	case *anthropic.BetaManagedAgentsAlwaysAllowPolicyParam:
  1775  //	case *anthropic.BetaManagedAgentsAlwaysAskPolicyParam:
  1776  //	default:
  1777  //	    fmt.Errorf("not present")
  1778  //	}
  1779  func (u betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfigPermissionPolicy) AsAny() any {
  1780  	return u.any
  1781  }
  1782  
  1783  // Returns a pointer to the underlying variant's property, if present.
  1784  func (u betaManagedAgentsSessionAgentUpdateToolUnionParamDefaultConfigPermissionPolicy) GetType() *string {
  1785  	switch vt := u.any.(type) {
  1786  	case *BetaManagedAgentsAgentToolsetDefaultConfigParamsPermissionPolicyUnion:
  1787  		return vt.GetType()
  1788  	case *BetaManagedAgentsMCPToolsetDefaultConfigParamsPermissionPolicyUnion:
  1789  		return vt.GetType()
  1790  	}
  1791  	return nil
  1792  }
  1793  
  1794  func init() {
  1795  	apijson.RegisterUnion[BetaManagedAgentsSessionAgentUpdateToolUnionParam](
  1796  		"type",
  1797  		apijson.Discriminator[BetaManagedAgentsAgentToolset20260401Params]("agent_toolset_20260401"),
  1798  		apijson.Discriminator[BetaManagedAgentsMCPToolsetParams]("mcp_toolset"),
  1799  		apijson.Discriminator[BetaManagedAgentsCustomToolParams]("custom"),
  1800  	)
  1801  }
  1802  
  1803  // Resolved coordinator topology with full agent definitions for each roster
  1804  // member.
  1805  type BetaManagedAgentsSessionMultiagentCoordinator struct {
  1806  	// Full `agent` definitions the coordinator may spawn as session threads.
  1807  	Agents []BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion `json:"agents" api:"required"`
  1808  	// Any of "coordinator".
  1809  	Type BetaManagedAgentsSessionMultiagentCoordinatorType `json:"type" api:"required"`
  1810  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  1811  	JSON struct {
  1812  		Agents      respjson.Field
  1813  		Type        respjson.Field
  1814  		ExtraFields map[string]respjson.Field
  1815  		raw         string
  1816  	} `json:"-"`
  1817  }
  1818  
  1819  // Returns the unmodified JSON received from the API
  1820  func (r BetaManagedAgentsSessionMultiagentCoordinator) RawJSON() string { return r.JSON.raw }
  1821  func (r *BetaManagedAgentsSessionMultiagentCoordinator) UnmarshalJSON(data []byte) error {
  1822  	return apijson.UnmarshalRoot(data, r)
  1823  }
  1824  
  1825  // BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion contains all possible
  1826  // properties and values from [BetaManagedAgentsSessionThreadAgent],
  1827  // [BetaManagedAgentsAdvisor].
  1828  //
  1829  // Use the [BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion.AsAny] method
  1830  // to switch on the variant.
  1831  //
  1832  // Use the methods beginning with 'As' to cast the union to one of its variants.
  1833  type BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion struct {
  1834  	// This field is from variant [BetaManagedAgentsSessionThreadAgent].
  1835  	ID string `json:"id"`
  1836  	// This field is from variant [BetaManagedAgentsSessionThreadAgent].
  1837  	Description string `json:"description"`
  1838  	// This field is from variant [BetaManagedAgentsSessionThreadAgent].
  1839  	MCPServers []BetaManagedAgentsMCPServerURLDefinition `json:"mcp_servers"`
  1840  	// This field is a union of [BetaManagedAgentsModelConfig], [string]
  1841  	Model BetaManagedAgentsSessionMultiagentCoordinatorAgentUnionModel `json:"model"`
  1842  	// This field is from variant [BetaManagedAgentsSessionThreadAgent].
  1843  	Name string `json:"name"`
  1844  	// This field is from variant [BetaManagedAgentsSessionThreadAgent].
  1845  	Skills []BetaManagedAgentsSessionThreadAgentSkillUnion `json:"skills"`
  1846  	// This field is from variant [BetaManagedAgentsSessionThreadAgent].
  1847  	System string `json:"system"`
  1848  	// This field is from variant [BetaManagedAgentsSessionThreadAgent].
  1849  	Tools []BetaManagedAgentsSessionThreadAgentToolUnion `json:"tools"`
  1850  	// Any of "agent", "advisor".
  1851  	Type string `json:"type"`
  1852  	// This field is from variant [BetaManagedAgentsSessionThreadAgent].
  1853  	Version int64 `json:"version"`
  1854  	JSON    struct {
  1855  		ID          respjson.Field
  1856  		Description respjson.Field
  1857  		MCPServers  respjson.Field
  1858  		Model       respjson.Field
  1859  		Name        respjson.Field
  1860  		Skills      respjson.Field
  1861  		System      respjson.Field
  1862  		Tools       respjson.Field
  1863  		Type        respjson.Field
  1864  		Version     respjson.Field
  1865  		raw         string
  1866  	} `json:"-"`
  1867  }
  1868  
  1869  // anyBetaManagedAgentsSessionMultiagentCoordinatorAgent is implemented by each
  1870  // variant of [BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion] to add type
  1871  // safety for the return type of
  1872  // [BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion.AsAny]
  1873  type anyBetaManagedAgentsSessionMultiagentCoordinatorAgent interface {
  1874  	implBetaManagedAgentsSessionMultiagentCoordinatorAgentUnion()
  1875  }
  1876  
  1877  func (BetaManagedAgentsSessionThreadAgent) implBetaManagedAgentsSessionMultiagentCoordinatorAgentUnion() {
  1878  }
  1879  func (BetaManagedAgentsAdvisor) implBetaManagedAgentsSessionMultiagentCoordinatorAgentUnion() {}
  1880  
  1881  // Use the following switch statement to find the correct variant
  1882  //
  1883  //	switch variant := BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion.AsAny().(type) {
  1884  //	case anthropic.BetaManagedAgentsSessionThreadAgent:
  1885  //	case anthropic.BetaManagedAgentsAdvisor:
  1886  //	default:
  1887  //	  fmt.Errorf("no variant present")
  1888  //	}
  1889  func (u BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion) AsAny() anyBetaManagedAgentsSessionMultiagentCoordinatorAgent {
  1890  	switch u.Type {
  1891  	case "agent":
  1892  		return u.AsAgent()
  1893  	case "advisor":
  1894  		return u.AsAdvisor()
  1895  	}
  1896  	return nil
  1897  }
  1898  
  1899  func (u BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion) AsAgent() (v BetaManagedAgentsSessionThreadAgent) {
  1900  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1901  	return
  1902  }
  1903  
  1904  func (u BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion) AsAdvisor() (v BetaManagedAgentsAdvisor) {
  1905  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  1906  	return
  1907  }
  1908  
  1909  // Returns the unmodified JSON received from the API
  1910  func (u BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion) RawJSON() string { return u.JSON.raw }
  1911  
  1912  func (r *BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion) UnmarshalJSON(data []byte) error {
  1913  	return apijson.UnmarshalRoot(data, r)
  1914  }
  1915  
  1916  // BetaManagedAgentsSessionMultiagentCoordinatorAgentUnionModel is an implicit
  1917  // subunion of [BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion].
  1918  // BetaManagedAgentsSessionMultiagentCoordinatorAgentUnionModel provides convenient
  1919  // access to the sub-properties of the union.
  1920  //
  1921  // For type safety it is recommended to directly use a variant of the
  1922  // [BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion].
  1923  //
  1924  // If the underlying value is not a json object, one of the following properties
  1925  // will be valid: OfString]
  1926  type BetaManagedAgentsSessionMultiagentCoordinatorAgentUnionModel struct {
  1927  	// This field will be present if the value is a [string] instead of an object.
  1928  	OfString string `json:",inline"`
  1929  	// This field is from variant [BetaManagedAgentsModelConfig].
  1930  	ID BetaManagedAgentsModel `json:"id"`
  1931  	// This field is from variant [BetaManagedAgentsModelConfig].
  1932  	Effort BetaManagedAgentsModelConfigEffortUnion `json:"effort"`
  1933  	// This field is from variant [BetaManagedAgentsModelConfig].
  1934  	InferenceGeo string `json:"inference_geo"`
  1935  	// This field is from variant [BetaManagedAgentsModelConfig].
  1936  	Speed BetaManagedAgentsModelConfigSpeed `json:"speed"`
  1937  	JSON  struct {
  1938  		OfString     respjson.Field
  1939  		ID           respjson.Field
  1940  		Effort       respjson.Field
  1941  		InferenceGeo respjson.Field
  1942  		Speed        respjson.Field
  1943  		raw          string
  1944  	} `json:"-"`
  1945  }
  1946  
  1947  func (r *BetaManagedAgentsSessionMultiagentCoordinatorAgentUnionModel) UnmarshalJSON(data []byte) error {
  1948  	return apijson.UnmarshalRoot(data, r)
  1949  }
  1950  
  1951  type BetaManagedAgentsSessionMultiagentCoordinatorType string
  1952  
  1953  const (
  1954  	BetaManagedAgentsSessionMultiagentCoordinatorTypeCoordinator BetaManagedAgentsSessionMultiagentCoordinatorType = "coordinator"
  1955  )
  1956  
  1957  // Timing statistics for a session.
  1958  type BetaManagedAgentsSessionStats struct {
  1959  	// Cumulative time in seconds the session spent in `running` status. Excludes idle
  1960  	// time.
  1961  	ActiveSeconds float64 `json:"active_seconds"`
  1962  	// Elapsed time since session creation in seconds. For terminated sessions, frozen
  1963  	// at the final update.
  1964  	DurationSeconds float64 `json:"duration_seconds"`
  1965  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  1966  	JSON struct {
  1967  		ActiveSeconds   respjson.Field
  1968  		DurationSeconds respjson.Field
  1969  		ExtraFields     map[string]respjson.Field
  1970  		raw             string
  1971  	} `json:"-"`
  1972  }
  1973  
  1974  // Returns the unmodified JSON received from the API
  1975  func (r BetaManagedAgentsSessionStats) RawJSON() string { return r.JSON.raw }
  1976  func (r *BetaManagedAgentsSessionStats) UnmarshalJSON(data []byte) error {
  1977  	return apijson.UnmarshalRoot(data, r)
  1978  }
  1979  
  1980  // Emitted when an UpdateSession request changed at least one field. Carries only
  1981  // the fields that changed; absent fields were not part of the update. The new
  1982  // configuration applies from the next turn.
  1983  type BetaManagedAgentsSessionUpdatedEvent struct {
  1984  	// Unique identifier for this event.
  1985  	ID string `json:"id" api:"required"`
  1986  	// A timestamp in RFC 3339 format
  1987  	ProcessedAt time.Time `json:"processed_at" api:"required" format:"date-time"`
  1988  	// Any of "session.updated".
  1989  	Type BetaManagedAgentsSessionUpdatedEventType `json:"type" api:"required"`
  1990  	// Resolved `agent` definition for a `session`. Snapshot of the `agent` at
  1991  	// `session` creation time.
  1992  	Agent BetaManagedAgentsSessionAgent `json:"agent" api:"nullable"`
  1993  	// A hard spend ceiling. The session stops issuing new model requests once the
  1994  	// tracked list cost reaches `max_list_cost`.
  1995  	Budget BetaManagedAgentsBudgetLimit `json:"budget" api:"nullable"`
  1996  	// The session's full metadata bag after the update. Present when the update set
  1997  	// non-empty metadata; absent when metadata was unchanged or cleared to empty.
  1998  	Metadata map[string]string `json:"metadata"`
  1999  	// The session's new title. Present only when the update changed it.
  2000  	Title string `json:"title" api:"nullable"`
  2001  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  2002  	JSON struct {
  2003  		ID          respjson.Field
  2004  		ProcessedAt respjson.Field
  2005  		Type        respjson.Field
  2006  		Agent       respjson.Field
  2007  		Budget      respjson.Field
  2008  		Metadata    respjson.Field
  2009  		Title       respjson.Field
  2010  		ExtraFields map[string]respjson.Field
  2011  		raw         string
  2012  	} `json:"-"`
  2013  }
  2014  
  2015  // Returns the unmodified JSON received from the API
  2016  func (r BetaManagedAgentsSessionUpdatedEvent) RawJSON() string { return r.JSON.raw }
  2017  func (r *BetaManagedAgentsSessionUpdatedEvent) UnmarshalJSON(data []byte) error {
  2018  	return apijson.UnmarshalRoot(data, r)
  2019  }
  2020  
  2021  type BetaManagedAgentsSessionUpdatedEventType string
  2022  
  2023  const (
  2024  	BetaManagedAgentsSessionUpdatedEventTypeSessionUpdated BetaManagedAgentsSessionUpdatedEventType = "session.updated"
  2025  )
  2026  
  2027  // Cumulative token usage for a session across all turns.
  2028  type BetaManagedAgentsSessionUsage struct {
  2029  	// Cumulative time in seconds during which the session had at least one thread in
  2030  	// running status. Overlapping activity from concurrent threads is counted once,
  2031  	// unlike `stats.active_seconds`, which sums each thread's own active time. This is
  2032  	// the duration the session's runtime cost is priced on.
  2033  	ActiveSeconds float64 `json:"active_seconds"`
  2034  	// Prompt-cache creation token usage broken down by cache lifetime.
  2035  	CacheCreation BetaManagedAgentsCacheCreationUsage `json:"cache_creation"`
  2036  	// Total tokens read from prompt cache.
  2037  	CacheReadInputTokens int64 `json:"cache_read_input_tokens"`
  2038  	// Total input tokens consumed across all turns.
  2039  	InputTokens int64 `json:"input_tokens"`
  2040  	// A monetary amount in a specific currency.
  2041  	ListCost BetaMonetaryAmount `json:"list_cost" api:"nullable"`
  2042  	// Total output tokens generated across all turns.
  2043  	OutputTokens int64 `json:"output_tokens"`
  2044  	// Cumulative count of server-executed tool invocations, broken down by tool.
  2045  	ServerToolUse BetaManagedAgentsServerToolUsage `json:"server_tool_use" api:"nullable"`
  2046  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  2047  	JSON struct {
  2048  		ActiveSeconds        respjson.Field
  2049  		CacheCreation        respjson.Field
  2050  		CacheReadInputTokens respjson.Field
  2051  		InputTokens          respjson.Field
  2052  		ListCost             respjson.Field
  2053  		OutputTokens         respjson.Field
  2054  		ServerToolUse        respjson.Field
  2055  		ExtraFields          map[string]respjson.Field
  2056  		raw                  string
  2057  	} `json:"-"`
  2058  }
  2059  
  2060  // Returns the unmodified JSON received from the API
  2061  func (r BetaManagedAgentsSessionUsage) RawJSON() string { return r.JSON.raw }
  2062  func (r *BetaManagedAgentsSessionUsage) UnmarshalJSON(data []byte) error {
  2063  	return apijson.UnmarshalRoot(data, r)
  2064  }
  2065  
  2066  // Periodic snapshot of the session's cumulative usage and tracked list cost.
  2067  type BetaManagedAgentsSessionUsageEvent struct {
  2068  	// Unique identifier for this event.
  2069  	ID string `json:"id" api:"required"`
  2070  	// A timestamp in RFC 3339 format
  2071  	ProcessedAt time.Time `json:"processed_at" api:"required" format:"date-time"`
  2072  	// Any of "session.usage".
  2073  	Type BetaManagedAgentsSessionUsageEventType `json:"type" api:"required"`
  2074  	// Point-in-time snapshot of a session's cumulative usage.
  2075  	Usage BetaManagedAgentsSessionUsageSnapshot `json:"usage" api:"required"`
  2076  	// A hard spend ceiling. The session stops issuing new model requests once the
  2077  	// tracked list cost reaches `max_list_cost`.
  2078  	Budget BetaManagedAgentsBudgetLimit `json:"budget" api:"nullable"`
  2079  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  2080  	JSON struct {
  2081  		ID          respjson.Field
  2082  		ProcessedAt respjson.Field
  2083  		Type        respjson.Field
  2084  		Usage       respjson.Field
  2085  		Budget      respjson.Field
  2086  		ExtraFields map[string]respjson.Field
  2087  		raw         string
  2088  	} `json:"-"`
  2089  }
  2090  
  2091  // Returns the unmodified JSON received from the API
  2092  func (r BetaManagedAgentsSessionUsageEvent) RawJSON() string { return r.JSON.raw }
  2093  func (r *BetaManagedAgentsSessionUsageEvent) UnmarshalJSON(data []byte) error {
  2094  	return apijson.UnmarshalRoot(data, r)
  2095  }
  2096  
  2097  type BetaManagedAgentsSessionUsageEventType string
  2098  
  2099  const (
  2100  	BetaManagedAgentsSessionUsageEventTypeSessionUsage BetaManagedAgentsSessionUsageEventType = "session.usage"
  2101  )
  2102  
  2103  // Opens a preview of a buffered event. Carries the previewed event's type and id
  2104  // only. Followed by zero or more event_delta events with the same event id,
  2105  // normally concluded by the buffered event carrying that id. If the producing
  2106  // model request ends without that event (an error or interrupt mid-stream), its
  2107  // terminal span.model_request_end closes the preview. Only sent on stream
  2108  // connections that opt in via event_deltas; never appears in event history.
  2109  type BetaManagedAgentsStartEvent struct {
  2110  	// The previewed event's type and id. The event type determines which delta types
  2111  	// the preview's event_delta events carry: agent.message events stream
  2112  	// content_delta fragments; agent.thinking previews are start-only — no deltas
  2113  	// follow, and the buffered agent.thinking with the same id concludes them.
  2114  	Event BetaManagedAgentsStartEventPreviewUnion `json:"event" api:"required"`
  2115  	// Any of "event_start".
  2116  	Type BetaManagedAgentsStartEventType `json:"type" api:"required"`
  2117  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  2118  	JSON struct {
  2119  		Event       respjson.Field
  2120  		Type        respjson.Field
  2121  		ExtraFields map[string]respjson.Field
  2122  		raw         string
  2123  	} `json:"-"`
  2124  }
  2125  
  2126  // Returns the unmodified JSON received from the API
  2127  func (r BetaManagedAgentsStartEvent) RawJSON() string { return r.JSON.raw }
  2128  func (r *BetaManagedAgentsStartEvent) UnmarshalJSON(data []byte) error {
  2129  	return apijson.UnmarshalRoot(data, r)
  2130  }
  2131  
  2132  type BetaManagedAgentsStartEventType string
  2133  
  2134  const (
  2135  	BetaManagedAgentsStartEventTypeEventStart BetaManagedAgentsStartEventType = "event_start"
  2136  )
  2137  
  2138  // BetaManagedAgentsStartEventPreviewUnion contains all possible properties and
  2139  // values from [BetaManagedAgentsAgentMessagePreview],
  2140  // [BetaManagedAgentsAgentThinkingPreview].
  2141  //
  2142  // Use the [BetaManagedAgentsStartEventPreviewUnion.AsAny] method to switch on the
  2143  // variant.
  2144  //
  2145  // Use the methods beginning with 'As' to cast the union to one of its variants.
  2146  type BetaManagedAgentsStartEventPreviewUnion struct {
  2147  	ID string `json:"id"`
  2148  	// Any of "agent.message", "agent.thinking".
  2149  	Type string `json:"type"`
  2150  	JSON struct {
  2151  		ID   respjson.Field
  2152  		Type respjson.Field
  2153  		raw  string
  2154  	} `json:"-"`
  2155  }
  2156  
  2157  // anyBetaManagedAgentsStartEventPreview is implemented by each variant of
  2158  // [BetaManagedAgentsStartEventPreviewUnion] to add type safety for the return type
  2159  // of [BetaManagedAgentsStartEventPreviewUnion.AsAny]
  2160  type anyBetaManagedAgentsStartEventPreview interface {
  2161  	implBetaManagedAgentsStartEventPreviewUnion()
  2162  }
  2163  
  2164  func (BetaManagedAgentsAgentMessagePreview) implBetaManagedAgentsStartEventPreviewUnion()  {}
  2165  func (BetaManagedAgentsAgentThinkingPreview) implBetaManagedAgentsStartEventPreviewUnion() {}
  2166  
  2167  // Use the following switch statement to find the correct variant
  2168  //
  2169  //	switch variant := BetaManagedAgentsStartEventPreviewUnion.AsAny().(type) {
  2170  //	case anthropic.BetaManagedAgentsAgentMessagePreview:
  2171  //	case anthropic.BetaManagedAgentsAgentThinkingPreview:
  2172  //	default:
  2173  //	  fmt.Errorf("no variant present")
  2174  //	}
  2175  func (u BetaManagedAgentsStartEventPreviewUnion) AsAny() anyBetaManagedAgentsStartEventPreview {
  2176  	switch u.Type {
  2177  	case "agent.message":
  2178  		return u.AsAgentMessage()
  2179  	case "agent.thinking":
  2180  		return u.AsAgentThinking()
  2181  	}
  2182  	return nil
  2183  }
  2184  
  2185  func (u BetaManagedAgentsStartEventPreviewUnion) AsAgentMessage() (v BetaManagedAgentsAgentMessagePreview) {
  2186  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  2187  	return
  2188  }
  2189  
  2190  func (u BetaManagedAgentsStartEventPreviewUnion) AsAgentThinking() (v BetaManagedAgentsAgentThinkingPreview) {
  2191  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  2192  	return
  2193  }
  2194  
  2195  // Returns the unmodified JSON received from the API
  2196  func (u BetaManagedAgentsStartEventPreviewUnion) RawJSON() string { return u.JSON.raw }
  2197  
  2198  func (r *BetaManagedAgentsStartEventPreviewUnion) UnmarshalJSON(data []byte) error {
  2199  	return apijson.UnmarshalRoot(data, r)
  2200  }
  2201  
  2202  // Regular text content.
  2203  type BetaManagedAgentsSystemContentBlock struct {
  2204  	// The text content.
  2205  	Text string `json:"text" api:"required"`
  2206  	// Any of "text".
  2207  	Type BetaManagedAgentsSystemContentBlockType `json:"type" api:"required"`
  2208  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  2209  	JSON struct {
  2210  		Text        respjson.Field
  2211  		Type        respjson.Field
  2212  		ExtraFields map[string]respjson.Field
  2213  		raw         string
  2214  	} `json:"-"`
  2215  }
  2216  
  2217  // Returns the unmodified JSON received from the API
  2218  func (r BetaManagedAgentsSystemContentBlock) RawJSON() string { return r.JSON.raw }
  2219  func (r *BetaManagedAgentsSystemContentBlock) UnmarshalJSON(data []byte) error {
  2220  	return apijson.UnmarshalRoot(data, r)
  2221  }
  2222  
  2223  // ToParam converts this BetaManagedAgentsSystemContentBlock to a
  2224  // BetaManagedAgentsSystemContentBlockParam.
  2225  //
  2226  // Warning: the fields of the param type will not be present. ToParam should only
  2227  // be used at the last possible moment before sending a request. Test for this with
  2228  // BetaManagedAgentsSystemContentBlockParam.Overrides()
  2229  func (r BetaManagedAgentsSystemContentBlock) ToParam() BetaManagedAgentsSystemContentBlockParam {
  2230  	return param.Override[BetaManagedAgentsSystemContentBlockParam](json.RawMessage(r.RawJSON()))
  2231  }
  2232  
  2233  type BetaManagedAgentsSystemContentBlockType string
  2234  
  2235  const (
  2236  	BetaManagedAgentsSystemContentBlockTypeText BetaManagedAgentsSystemContentBlockType = "text"
  2237  )
  2238  
  2239  // Regular text content.
  2240  //
  2241  // The properties Text, Type are required.
  2242  type BetaManagedAgentsSystemContentBlockParam struct {
  2243  	// The text content.
  2244  	Text string `json:"text" api:"required"`
  2245  	// Any of "text".
  2246  	Type BetaManagedAgentsSystemContentBlockType `json:"type,omitzero" api:"required"`
  2247  	paramObj
  2248  }
  2249  
  2250  func (r BetaManagedAgentsSystemContentBlockParam) MarshalJSON() (data []byte, err error) {
  2251  	type shadow BetaManagedAgentsSystemContentBlockParam
  2252  	return param.MarshalObject(r, (*shadow)(&r))
  2253  }
  2254  func (r *BetaManagedAgentsSystemContentBlockParam) UnmarshalJSON(data []byte) error {
  2255  	return apijson.UnmarshalRoot(data, r)
  2256  }
  2257  
  2258  // A mid-conversation system message event. Carries system-role content that is
  2259  // appended to the session as a `role: "system"` turn.
  2260  type BetaManagedAgentsSystemMessageEvent struct {
  2261  	// Unique identifier for this event.
  2262  	ID string `json:"id" api:"required"`
  2263  	// System content blocks. Text-only.
  2264  	Content []BetaManagedAgentsSystemContentBlock `json:"content" api:"required"`
  2265  	// Any of "system.message".
  2266  	Type BetaManagedAgentsSystemMessageEventType `json:"type" api:"required"`
  2267  	// A timestamp in RFC 3339 format
  2268  	ProcessedAt time.Time `json:"processed_at" api:"nullable" format:"date-time"`
  2269  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  2270  	JSON struct {
  2271  		ID          respjson.Field
  2272  		Content     respjson.Field
  2273  		Type        respjson.Field
  2274  		ProcessedAt respjson.Field
  2275  		ExtraFields map[string]respjson.Field
  2276  		raw         string
  2277  	} `json:"-"`
  2278  }
  2279  
  2280  // Returns the unmodified JSON received from the API
  2281  func (r BetaManagedAgentsSystemMessageEvent) RawJSON() string { return r.JSON.raw }
  2282  func (r *BetaManagedAgentsSystemMessageEvent) UnmarshalJSON(data []byte) error {
  2283  	return apijson.UnmarshalRoot(data, r)
  2284  }
  2285  
  2286  type BetaManagedAgentsSystemMessageEventType string
  2287  
  2288  const (
  2289  	BetaManagedAgentsSystemMessageEventTypeSystemMessage BetaManagedAgentsSystemMessageEventType = "system.message"
  2290  )
  2291  
  2292  // Event sent by the client providing the result of an agent-toolset tool
  2293  // execution. Only valid on `self_hosted` environments, where sandbox-routed tools
  2294  // are executed by the client rather than the server.
  2295  type BetaManagedAgentsUserToolResultEvent struct {
  2296  	// Unique identifier for this event.
  2297  	ID string `json:"id" api:"required"`
  2298  	// The id of the `agent.tool_use` event this result corresponds to, which can be
  2299  	// found in the last `session.status_idle`
  2300  	// [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids)
  2301  	// `stop_reason.event_ids` field.
  2302  	ToolUseID string `json:"tool_use_id" api:"required"`
  2303  	// Any of "user.tool_result".
  2304  	Type BetaManagedAgentsUserToolResultEventType `json:"type" api:"required"`
  2305  	// The result content returned by the tool.
  2306  	Content []BetaManagedAgentsUserToolResultEventContentUnion `json:"content"`
  2307  	// Whether the tool execution resulted in an error.
  2308  	IsError bool `json:"is_error" api:"nullable"`
  2309  	// A timestamp in RFC 3339 format
  2310  	ProcessedAt time.Time `json:"processed_at" api:"nullable" format:"date-time"`
  2311  	// Routes this result to a subagent thread. Copy from the `agent.tool_use` event's
  2312  	// `session_thread_id`.
  2313  	SessionThreadID string `json:"session_thread_id" api:"nullable"`
  2314  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
  2315  	JSON struct {
  2316  		ID              respjson.Field
  2317  		ToolUseID       respjson.Field
  2318  		Type            respjson.Field
  2319  		Content         respjson.Field
  2320  		IsError         respjson.Field
  2321  		ProcessedAt     respjson.Field
  2322  		SessionThreadID respjson.Field
  2323  		ExtraFields     map[string]respjson.Field
  2324  		raw             string
  2325  	} `json:"-"`
  2326  }
  2327  
  2328  // Returns the unmodified JSON received from the API
  2329  func (r BetaManagedAgentsUserToolResultEvent) RawJSON() string { return r.JSON.raw }
  2330  func (r *BetaManagedAgentsUserToolResultEvent) UnmarshalJSON(data []byte) error {
  2331  	return apijson.UnmarshalRoot(data, r)
  2332  }
  2333  
  2334  type BetaManagedAgentsUserToolResultEventType string
  2335  
  2336  const (
  2337  	BetaManagedAgentsUserToolResultEventTypeUserToolResult BetaManagedAgentsUserToolResultEventType = "user.tool_result"
  2338  )
  2339  
  2340  // BetaManagedAgentsUserToolResultEventContentUnion contains all possible
  2341  // properties and values from [BetaManagedAgentsTextBlock],
  2342  // [BetaManagedAgentsImageBlock], [BetaManagedAgentsDocumentBlock],
  2343  // [BetaManagedAgentsSearchResultBlock].
  2344  //
  2345  // Use the [BetaManagedAgentsUserToolResultEventContentUnion.AsAny] method to
  2346  // switch on the variant.
  2347  //
  2348  // Use the methods beginning with 'As' to cast the union to one of its variants.
  2349  type BetaManagedAgentsUserToolResultEventContentUnion struct {
  2350  	// This field is from variant [BetaManagedAgentsTextBlock].
  2351  	Text string `json:"text"`
  2352  	// Any of "text", "image", "document", "search_result".
  2353  	Type string `json:"type"`
  2354  	// This field is a union of [BetaManagedAgentsImageBlockSourceUnion],
  2355  	// [BetaManagedAgentsDocumentBlockSourceUnion], [string]
  2356  	Source BetaManagedAgentsUserToolResultEventContentUnionSource `json:"source"`
  2357  	// This field is from variant [BetaManagedAgentsDocumentBlock].
  2358  	Context string `json:"context"`
  2359  	Title   string `json:"title"`
  2360  	// This field is from variant [BetaManagedAgentsSearchResultBlock].
  2361  	Citations BetaManagedAgentsSearchResultCitations `json:"citations"`
  2362  	// This field is from variant [BetaManagedAgentsSearchResultBlock].
  2363  	Content []BetaManagedAgentsSearchResultContent `json:"content"`
  2364  	JSON    struct {
  2365  		Text      respjson.Field
  2366  		Type      respjson.Field
  2367  		Source    respjson.Field
  2368  		Context   respjson.Field
  2369  		Title     respjson.Field
  2370  		Citations respjson.Field
  2371  		Content   respjson.Field
  2372  		raw       string
  2373  	} `json:"-"`
  2374  }
  2375  
  2376  // anyBetaManagedAgentsUserToolResultEventContent is implemented by each variant of
  2377  // [BetaManagedAgentsUserToolResultEventContentUnion] to add type safety for the
  2378  // return type of [BetaManagedAgentsUserToolResultEventContentUnion.AsAny]
  2379  type anyBetaManagedAgentsUserToolResultEventContent interface {
  2380  	implBetaManagedAgentsUserToolResultEventContentUnion()
  2381  }
  2382  
  2383  func (BetaManagedAgentsTextBlock) implBetaManagedAgentsUserToolResultEventContentUnion()         {}
  2384  func (BetaManagedAgentsImageBlock) implBetaManagedAgentsUserToolResultEventContentUnion()        {}
  2385  func (BetaManagedAgentsDocumentBlock) implBetaManagedAgentsUserToolResultEventContentUnion()     {}
  2386  func (BetaManagedAgentsSearchResultBlock) implBetaManagedAgentsUserToolResultEventContentUnion() {}
  2387  
  2388  // Use the following switch statement to find the correct variant
  2389  //
  2390  //	switch variant := BetaManagedAgentsUserToolResultEventContentUnion.AsAny().(type) {
  2391  //	case anthropic.BetaManagedAgentsTextBlock:
  2392  //	case anthropic.BetaManagedAgentsImageBlock:
  2393  //	case anthropic.BetaManagedAgentsDocumentBlock:
  2394  //	case anthropic.BetaManagedAgentsSearchResultBlock:
  2395  //	default:
  2396  //	  fmt.Errorf("no variant present")
  2397  //	}
  2398  func (u BetaManagedAgentsUserToolResultEventContentUnion) AsAny() anyBetaManagedAgentsUserToolResultEventContent {
  2399  	switch u.Type {
  2400  	case "text":
  2401  		return u.AsText()
  2402  	case "image":
  2403  		return u.AsImage()
  2404  	case "document":
  2405  		return u.AsDocument()
  2406  	case "search_result":
  2407  		return u.AsSearchResult()
  2408  	}
  2409  	return nil
  2410  }
  2411  
  2412  func (u BetaManagedAgentsUserToolResultEventContentUnion) AsText() (v BetaManagedAgentsTextBlock) {
  2413  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  2414  	return
  2415  }
  2416  
  2417  func (u BetaManagedAgentsUserToolResultEventContentUnion) AsImage() (v BetaManagedAgentsImageBlock) {
  2418  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  2419  	return
  2420  }
  2421  
  2422  func (u BetaManagedAgentsUserToolResultEventContentUnion) AsDocument() (v BetaManagedAgentsDocumentBlock) {
  2423  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  2424  	return
  2425  }
  2426  
  2427  func (u BetaManagedAgentsUserToolResultEventContentUnion) AsSearchResult() (v BetaManagedAgentsSearchResultBlock) {
  2428  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
  2429  	return
  2430  }
  2431  
  2432  // Returns the unmodified JSON received from the API
  2433  func (u BetaManagedAgentsUserToolResultEventContentUnion) RawJSON() string { return u.JSON.raw }
  2434  
  2435  func (r *BetaManagedAgentsUserToolResultEventContentUnion) UnmarshalJSON(data []byte) error {
  2436  	return apijson.UnmarshalRoot(data, r)
  2437  }
  2438  
  2439  // BetaManagedAgentsUserToolResultEventContentUnionSource is an implicit subunion
  2440  // of [BetaManagedAgentsUserToolResultEventContentUnion].
  2441  // BetaManagedAgentsUserToolResultEventContentUnionSource provides convenient
  2442  // access to the sub-properties of the union.
  2443  //
  2444  // For type safety it is recommended to directly use a variant of the
  2445  // [BetaManagedAgentsUserToolResultEventContentUnion].
  2446  //
  2447  // If the underlying value is not a json object, one of the following properties
  2448  // will be valid: OfString]
  2449  type BetaManagedAgentsUserToolResultEventContentUnionSource struct {
  2450  	// This field will be present if the value is a [string] instead of an object.
  2451  	OfString  string `json:",inline"`
  2452  	Data      string `json:"data"`
  2453  	MediaType string `json:"media_type"`
  2454  	Type      string `json:"type"`
  2455  	URL       string `json:"url"`
  2456  	FileID    string `json:"file_id"`
  2457  	JSON      struct {
  2458  		OfString  respjson.Field
  2459  		Data      respjson.Field
  2460  		MediaType respjson.Field
  2461  		Type      respjson.Field
  2462  		URL       respjson.Field
  2463  		FileID    respjson.Field
  2464  		raw       string
  2465  	} `json:"-"`
  2466  }
  2467  
  2468  func (r *BetaManagedAgentsUserToolResultEventContentUnionSource) UnmarshalJSON(data []byte) error {
  2469  	return apijson.UnmarshalRoot(data, r)
  2470  }
  2471  
  2472  type BetaSessionNewParams struct {
  2473  	// Agent identifier. Accepts the `agent` ID string, which pins the latest version
  2474  	// for the session, or an `agent` object with both id and version specified.
  2475  	Agent BetaSessionNewParamsAgentUnion `json:"agent,omitzero" api:"required"`
  2476  	// ID of the `environment` defining the container configuration for this session.
  2477  	EnvironmentID string `json:"environment_id" api:"required"`
  2478  	// Human-readable session title.
  2479  	Title       param.Opt[string] `json:"title,omitzero"`
  2480  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
  2481  	// A hard spend ceiling. The session stops issuing new model requests once the
  2482  	// tracked list cost reaches `max_list_cost`.
  2483  	Budget BetaManagedAgentsBudgetLimitParam `json:"budget,omitzero"`
  2484  	// Initial events to send to the `session` at creation, processed in order.
  2485  	// Supports `user.message` and `user.define_outcome` events. Maximum 50 events.
  2486  	InitialEvents []BetaSessionNewParamsInitialEventUnion `json:"initial_events,omitzero"`
  2487  	// Arbitrary key-value metadata attached to the session. Maximum 16 pairs, keys up
  2488  	// to 64 chars, values up to 512 chars.
  2489  	Metadata map[string]string `json:"metadata,omitzero"`
  2490  	// Resources (e.g. repositories, files) to mount into the session's container.
  2491  	Resources []BetaSessionNewParamsResourceUnion `json:"resources,omitzero"`
  2492  	// Vault IDs for stored credentials the agent can use during the session.
  2493  	VaultIDs []string `json:"vault_ids,omitzero"`
  2494  	// Optional header to specify the beta version(s) you want to use.
  2495  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
  2496  	paramObj
  2497  }
  2498  
  2499  func (r BetaSessionNewParams) MarshalJSON() (data []byte, err error) {
  2500  	type shadow BetaSessionNewParams
  2501  	return param.MarshalObject(r, (*shadow)(&r))
  2502  }
  2503  func (r *BetaSessionNewParams) UnmarshalJSON(data []byte) error {
  2504  	return apijson.UnmarshalRoot(data, r)
  2505  }
  2506  
  2507  // Only one field can be non-zero.
  2508  //
  2509  // Use [param.IsOmitted] to confirm if a field is set.
  2510  type BetaSessionNewParamsAgentUnion struct {
  2511  	OfString                               param.Opt[string]                          `json:",omitzero,inline"`
  2512  	OfBetaManagedAgentsAgents              *BetaManagedAgentsAgentParams              `json:",omitzero,inline"`
  2513  	OfBetaManagedAgentsAgentWithOverridess *BetaManagedAgentsAgentWithOverridesParams `json:",omitzero,inline"`
  2514  	paramUnion
  2515  }
  2516  
  2517  func (u BetaSessionNewParamsAgentUnion) MarshalJSON() ([]byte, error) {
  2518  	return param.MarshalUnion(u, u.OfString, u.OfBetaManagedAgentsAgents, u.OfBetaManagedAgentsAgentWithOverridess)
  2519  }
  2520  func (u *BetaSessionNewParamsAgentUnion) UnmarshalJSON(data []byte) error {
  2521  	return apijson.UnmarshalRoot(data, u)
  2522  }
  2523  
  2524  func (u *BetaSessionNewParamsAgentUnion) asAny() any {
  2525  	if !param.IsOmitted(u.OfString) {
  2526  		return &u.OfString.Value
  2527  	} else if !param.IsOmitted(u.OfBetaManagedAgentsAgents) {
  2528  		return u.OfBetaManagedAgentsAgents
  2529  	} else if !param.IsOmitted(u.OfBetaManagedAgentsAgentWithOverridess) {
  2530  		return u.OfBetaManagedAgentsAgentWithOverridess
  2531  	}
  2532  	return nil
  2533  }
  2534  
  2535  // Returns a pointer to the underlying variant's property, if present.
  2536  func (u BetaSessionNewParamsAgentUnion) GetMCPServers() []BetaManagedAgentsURLMCPServerParams {
  2537  	if vt := u.OfBetaManagedAgentsAgentWithOverridess; vt != nil {
  2538  		return vt.MCPServers
  2539  	}
  2540  	return nil
  2541  }
  2542  
  2543  // Returns a pointer to the underlying variant's property, if present.
  2544  func (u BetaSessionNewParamsAgentUnion) GetModel() *BetaManagedAgentsModelConfigParams {
  2545  	if vt := u.OfBetaManagedAgentsAgentWithOverridess; vt != nil {
  2546  		return &vt.Model
  2547  	}
  2548  	return nil
  2549  }
  2550  
  2551  // Returns a pointer to the underlying variant's property, if present.
  2552  func (u BetaSessionNewParamsAgentUnion) GetSkills() []BetaManagedAgentsSkillParamsUnion {
  2553  	if vt := u.OfBetaManagedAgentsAgentWithOverridess; vt != nil {
  2554  		return vt.Skills
  2555  	}
  2556  	return nil
  2557  }
  2558  
  2559  // Returns a pointer to the underlying variant's property, if present.
  2560  func (u BetaSessionNewParamsAgentUnion) GetSystem() *string {
  2561  	if vt := u.OfBetaManagedAgentsAgentWithOverridess; vt != nil && vt.System.Valid() {
  2562  		return &vt.System.Value
  2563  	}
  2564  	return nil
  2565  }
  2566  
  2567  // Returns a pointer to the underlying variant's property, if present.
  2568  func (u BetaSessionNewParamsAgentUnion) GetTools() []BetaManagedAgentsAgentWithOverridesParamsToolUnion {
  2569  	if vt := u.OfBetaManagedAgentsAgentWithOverridess; vt != nil {
  2570  		return vt.Tools
  2571  	}
  2572  	return nil
  2573  }
  2574  
  2575  // Returns a pointer to the underlying variant's property, if present.
  2576  func (u BetaSessionNewParamsAgentUnion) GetID() *string {
  2577  	if vt := u.OfBetaManagedAgentsAgents; vt != nil {
  2578  		return (*string)(&vt.ID)
  2579  	} else if vt := u.OfBetaManagedAgentsAgentWithOverridess; vt != nil {
  2580  		return (*string)(&vt.ID)
  2581  	}
  2582  	return nil
  2583  }
  2584  
  2585  // Returns a pointer to the underlying variant's property, if present.
  2586  func (u BetaSessionNewParamsAgentUnion) GetType() *string {
  2587  	if vt := u.OfBetaManagedAgentsAgents; vt != nil {
  2588  		return (*string)(&vt.Type)
  2589  	} else if vt := u.OfBetaManagedAgentsAgentWithOverridess; vt != nil {
  2590  		return (*string)(&vt.Type)
  2591  	}
  2592  	return nil
  2593  }
  2594  
  2595  // Returns a pointer to the underlying variant's property, if present.
  2596  func (u BetaSessionNewParamsAgentUnion) GetVersion() *int64 {
  2597  	if vt := u.OfBetaManagedAgentsAgents; vt != nil && vt.Version.Valid() {
  2598  		return &vt.Version.Value
  2599  	} else if vt := u.OfBetaManagedAgentsAgentWithOverridess; vt != nil && vt.Version.Valid() {
  2600  		return &vt.Version.Value
  2601  	}
  2602  	return nil
  2603  }
  2604  
  2605  // Only one field can be non-zero.
  2606  //
  2607  // Use [param.IsOmitted] to confirm if a field is set.
  2608  type BetaSessionNewParamsInitialEventUnion struct {
  2609  	OfUserMessage       *BetaManagedAgentsUserMessageEventParams       `json:",omitzero,inline"`
  2610  	OfUserDefineOutcome *BetaManagedAgentsUserDefineOutcomeEventParams `json:",omitzero,inline"`
  2611  	paramUnion
  2612  }
  2613  
  2614  func (u BetaSessionNewParamsInitialEventUnion) MarshalJSON() ([]byte, error) {
  2615  	return param.MarshalUnion(u, u.OfUserMessage, u.OfUserDefineOutcome)
  2616  }
  2617  func (u *BetaSessionNewParamsInitialEventUnion) UnmarshalJSON(data []byte) error {
  2618  	return apijson.UnmarshalRoot(data, u)
  2619  }
  2620  
  2621  func (u *BetaSessionNewParamsInitialEventUnion) asAny() any {
  2622  	if !param.IsOmitted(u.OfUserMessage) {
  2623  		return u.OfUserMessage
  2624  	} else if !param.IsOmitted(u.OfUserDefineOutcome) {
  2625  		return u.OfUserDefineOutcome
  2626  	}
  2627  	return nil
  2628  }
  2629  
  2630  // Returns a pointer to the underlying variant's property, if present.
  2631  func (u BetaSessionNewParamsInitialEventUnion) GetContent() []BetaManagedAgentsUserMessageEventParamsContentUnion {
  2632  	if vt := u.OfUserMessage; vt != nil {
  2633  		return vt.Content
  2634  	}
  2635  	return nil
  2636  }
  2637  
  2638  // Returns a pointer to the underlying variant's property, if present.
  2639  func (u BetaSessionNewParamsInitialEventUnion) GetDescription() *string {
  2640  	if vt := u.OfUserDefineOutcome; vt != nil {
  2641  		return &vt.Description
  2642  	}
  2643  	return nil
  2644  }
  2645  
  2646  // Returns a pointer to the underlying variant's property, if present.
  2647  func (u BetaSessionNewParamsInitialEventUnion) GetRubric() *BetaManagedAgentsUserDefineOutcomeEventParamsRubricUnion {
  2648  	if vt := u.OfUserDefineOutcome; vt != nil {
  2649  		return &vt.Rubric
  2650  	}
  2651  	return nil
  2652  }
  2653  
  2654  // Returns a pointer to the underlying variant's property, if present.
  2655  func (u BetaSessionNewParamsInitialEventUnion) GetMaxIterations() *int64 {
  2656  	if vt := u.OfUserDefineOutcome; vt != nil && vt.MaxIterations.Valid() {
  2657  		return &vt.MaxIterations.Value
  2658  	}
  2659  	return nil
  2660  }
  2661  
  2662  // Returns a pointer to the underlying variant's property, if present.
  2663  func (u BetaSessionNewParamsInitialEventUnion) GetType() *string {
  2664  	if vt := u.OfUserMessage; vt != nil {
  2665  		return (*string)(&vt.Type)
  2666  	} else if vt := u.OfUserDefineOutcome; vt != nil {
  2667  		return (*string)(&vt.Type)
  2668  	}
  2669  	return nil
  2670  }
  2671  
  2672  func init() {
  2673  	apijson.RegisterUnion[BetaSessionNewParamsInitialEventUnion](
  2674  		"type",
  2675  		apijson.Discriminator[BetaManagedAgentsUserMessageEventParams]("user.message"),
  2676  		apijson.Discriminator[BetaManagedAgentsUserDefineOutcomeEventParams]("user.define_outcome"),
  2677  	)
  2678  }
  2679  
  2680  // Only one field can be non-zero.
  2681  //
  2682  // Use [param.IsOmitted] to confirm if a field is set.
  2683  type BetaSessionNewParamsResourceUnion struct {
  2684  	OfGitHubRepository *BetaManagedAgentsGitHubRepositoryResourceParams `json:",omitzero,inline"`
  2685  	OfFile             *BetaManagedAgentsFileResourceParams             `json:",omitzero,inline"`
  2686  	OfMemoryStore      *BetaManagedAgentsMemoryStoreResourceParam       `json:",omitzero,inline"`
  2687  	paramUnion
  2688  }
  2689  
  2690  func (u BetaSessionNewParamsResourceUnion) MarshalJSON() ([]byte, error) {
  2691  	return param.MarshalUnion(u, u.OfGitHubRepository, u.OfFile, u.OfMemoryStore)
  2692  }
  2693  func (u *BetaSessionNewParamsResourceUnion) UnmarshalJSON(data []byte) error {
  2694  	return apijson.UnmarshalRoot(data, u)
  2695  }
  2696  
  2697  func (u *BetaSessionNewParamsResourceUnion) asAny() any {
  2698  	if !param.IsOmitted(u.OfGitHubRepository) {
  2699  		return u.OfGitHubRepository
  2700  	} else if !param.IsOmitted(u.OfFile) {
  2701  		return u.OfFile
  2702  	} else if !param.IsOmitted(u.OfMemoryStore) {
  2703  		return u.OfMemoryStore
  2704  	}
  2705  	return nil
  2706  }
  2707  
  2708  // Returns a pointer to the underlying variant's property, if present.
  2709  func (u BetaSessionNewParamsResourceUnion) GetAuthorizationToken() *string {
  2710  	if vt := u.OfGitHubRepository; vt != nil {
  2711  		return &vt.AuthorizationToken
  2712  	}
  2713  	return nil
  2714  }
  2715  
  2716  // Returns a pointer to the underlying variant's property, if present.
  2717  func (u BetaSessionNewParamsResourceUnion) GetURL() *string {
  2718  	if vt := u.OfGitHubRepository; vt != nil {
  2719  		return &vt.URL
  2720  	}
  2721  	return nil
  2722  }
  2723  
  2724  // Returns a pointer to the underlying variant's property, if present.
  2725  func (u BetaSessionNewParamsResourceUnion) GetCheckout() *BetaManagedAgentsGitHubRepositoryResourceParamsCheckoutUnion {
  2726  	if vt := u.OfGitHubRepository; vt != nil {
  2727  		return &vt.Checkout
  2728  	}
  2729  	return nil
  2730  }
  2731  
  2732  // Returns a pointer to the underlying variant's property, if present.
  2733  func (u BetaSessionNewParamsResourceUnion) GetFileID() *string {
  2734  	if vt := u.OfFile; vt != nil {
  2735  		return &vt.FileID
  2736  	}
  2737  	return nil
  2738  }
  2739  
  2740  // Returns a pointer to the underlying variant's property, if present.
  2741  func (u BetaSessionNewParamsResourceUnion) GetMemoryStoreID() *string {
  2742  	if vt := u.OfMemoryStore; vt != nil {
  2743  		return &vt.MemoryStoreID
  2744  	}
  2745  	return nil
  2746  }
  2747  
  2748  // Returns a pointer to the underlying variant's property, if present.
  2749  func (u BetaSessionNewParamsResourceUnion) GetAccess() *string {
  2750  	if vt := u.OfMemoryStore; vt != nil {
  2751  		return (*string)(&vt.Access)
  2752  	}
  2753  	return nil
  2754  }
  2755  
  2756  // Returns a pointer to the underlying variant's property, if present.
  2757  func (u BetaSessionNewParamsResourceUnion) GetInstructions() *string {
  2758  	if vt := u.OfMemoryStore; vt != nil && vt.Instructions.Valid() {
  2759  		return &vt.Instructions.Value
  2760  	}
  2761  	return nil
  2762  }
  2763  
  2764  // Returns a pointer to the underlying variant's property, if present.
  2765  func (u BetaSessionNewParamsResourceUnion) GetType() *string {
  2766  	if vt := u.OfGitHubRepository; vt != nil {
  2767  		return (*string)(&vt.Type)
  2768  	} else if vt := u.OfFile; vt != nil {
  2769  		return (*string)(&vt.Type)
  2770  	} else if vt := u.OfMemoryStore; vt != nil {
  2771  		return (*string)(&vt.Type)
  2772  	}
  2773  	return nil
  2774  }
  2775  
  2776  // Returns a pointer to the underlying variant's property, if present.
  2777  func (u BetaSessionNewParamsResourceUnion) GetMountPath() *string {
  2778  	if vt := u.OfGitHubRepository; vt != nil && vt.MountPath.Valid() {
  2779  		return &vt.MountPath.Value
  2780  	} else if vt := u.OfFile; vt != nil && vt.MountPath.Valid() {
  2781  		return &vt.MountPath.Value
  2782  	}
  2783  	return nil
  2784  }
  2785  
  2786  func init() {
  2787  	apijson.RegisterUnion[BetaSessionNewParamsResourceUnion](
  2788  		"type",
  2789  		apijson.Discriminator[BetaManagedAgentsGitHubRepositoryResourceParams]("github_repository"),
  2790  		apijson.Discriminator[BetaManagedAgentsFileResourceParams]("file"),
  2791  		apijson.Discriminator[BetaManagedAgentsMemoryStoreResourceParam]("memory_store"),
  2792  	)
  2793  }
  2794  
  2795  type BetaSessionGetParams struct {
  2796  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
  2797  	// Optional header to specify the beta version(s) you want to use.
  2798  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
  2799  	paramObj
  2800  }
  2801  
  2802  type BetaSessionUpdateParams struct {
  2803  	// Human-readable session title.
  2804  	Title       param.Opt[string] `json:"title,omitzero"`
  2805  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
  2806  	// Metadata patch. Set a key to a string to upsert it, or to null to delete it.
  2807  	// Omit the field to preserve.
  2808  	Metadata map[string]string `json:"metadata,omitzero"`
  2809  	// Mid-session agent configuration update. Only `tools` and `mcp_servers` are
  2810  	// updatable. Full replacement: the provided array becomes the new value. To
  2811  	// preserve existing entries, GET the session, modify the array, and POST it back.
  2812  	Agent BetaManagedAgentsSessionAgentUpdateParam `json:"agent,omitzero"`
  2813  	// A hard spend ceiling. The session stops issuing new model requests once the
  2814  	// tracked list cost reaches `max_list_cost`.
  2815  	Budget BetaManagedAgentsBudgetLimitParam `json:"budget,omitzero"`
  2816  	// Vault IDs (`vlt_*`) to attach to the session. Not yet supported; requests
  2817  	// setting this field are rejected. Reserved for future use.
  2818  	VaultIDs []string `json:"vault_ids,omitzero"`
  2819  	// Optional header to specify the beta version(s) you want to use.
  2820  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
  2821  	paramObj
  2822  }
  2823  
  2824  func (r BetaSessionUpdateParams) MarshalJSON() (data []byte, err error) {
  2825  	type shadow BetaSessionUpdateParams
  2826  	return param.MarshalObject(r, (*shadow)(&r))
  2827  }
  2828  func (r *BetaSessionUpdateParams) UnmarshalJSON(data []byte) error {
  2829  	return apijson.UnmarshalRoot(data, r)
  2830  }
  2831  
  2832  type BetaSessionListParams struct {
  2833  	// Filter sessions created with this agent ID.
  2834  	AgentID param.Opt[string] `query:"agent_id,omitzero" json:"-"`
  2835  	// Filter by agent version. Only applies when `agent_id` is also set.
  2836  	AgentVersion param.Opt[int64] `query:"agent_version,omitzero" json:"-"`
  2837  	// Return sessions created after this time (exclusive).
  2838  	CreatedAtGt param.Opt[time.Time] `query:"created_at[gt],omitzero" format:"date-time" json:"-"`
  2839  	// Return sessions created at or after this time (inclusive).
  2840  	CreatedAtGte param.Opt[time.Time] `query:"created_at[gte],omitzero" format:"date-time" json:"-"`
  2841  	// Return sessions created before this time (exclusive).
  2842  	CreatedAtLt param.Opt[time.Time] `query:"created_at[lt],omitzero" format:"date-time" json:"-"`
  2843  	// Return sessions created at or before this time (inclusive).
  2844  	CreatedAtLte param.Opt[time.Time] `query:"created_at[lte],omitzero" format:"date-time" json:"-"`
  2845  	// Filter sessions created by this deployment ID.
  2846  	DeploymentID param.Opt[string] `query:"deployment_id,omitzero" json:"-"`
  2847  	// When true, includes archived sessions. Default: false (exclude archived).
  2848  	IncludeArchived param.Opt[bool] `query:"include_archived,omitzero" json:"-"`
  2849  	// Maximum number of results to return.
  2850  	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
  2851  	// Filter sessions whose resources contain a `memory_store` with this memory store
  2852  	// ID.
  2853  	MemoryStoreID param.Opt[string] `query:"memory_store_id,omitzero" json:"-"`
  2854  	// Opaque pagination cursor from a previous response.
  2855  	Page        param.Opt[string] `query:"page,omitzero" json:"-"`
  2856  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
  2857  	// Sort direction for results, ordered by `created_at`. Defaults to `desc` (newest
  2858  	// first).
  2859  	//
  2860  	// Any of "asc", "desc".
  2861  	Order BetaSessionListParamsOrder `query:"order,omitzero" json:"-"`
  2862  	// Filter by session status. Repeat the parameter to match any of multiple
  2863  	// statuses.
  2864  	//
  2865  	// Any of "rescheduling", "running", "idle", "terminated".
  2866  	Statuses []string `query:"statuses,omitzero" json:"-"`
  2867  	// Optional header to specify the beta version(s) you want to use.
  2868  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
  2869  	paramObj
  2870  }
  2871  
  2872  // URLQuery serializes [BetaSessionListParams]'s query parameters as `url.Values`.
  2873  func (r BetaSessionListParams) URLQuery() (v url.Values, err error) {
  2874  	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2875  		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
  2876  		NestedFormat: apiquery.NestedQueryFormatBrackets,
  2877  	})
  2878  }
  2879  
  2880  // Sort direction for results, ordered by `created_at`. Defaults to `desc` (newest
  2881  // first).
  2882  type BetaSessionListParamsOrder string
  2883  
  2884  const (
  2885  	BetaSessionListParamsOrderAsc  BetaSessionListParamsOrder = "asc"
  2886  	BetaSessionListParamsOrderDesc BetaSessionListParamsOrder = "desc"
  2887  )
  2888  
  2889  type BetaSessionDeleteParams struct {
  2890  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
  2891  	// Optional header to specify the beta version(s) you want to use.
  2892  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
  2893  	paramObj
  2894  }
  2895  
  2896  type BetaSessionArchiveParams struct {
  2897  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
  2898  	// Optional header to specify the beta version(s) you want to use.
  2899  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
  2900  	paramObj
  2901  }