github.com/anthropics/anthropic-sdk-go@v1.70.1/betamemorystorememory.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/requestconfig"
    18  	"github.com/anthropics/anthropic-sdk-go/option"
    19  	"github.com/anthropics/anthropic-sdk-go/packages/pagination"
    20  	"github.com/anthropics/anthropic-sdk-go/packages/param"
    21  	"github.com/anthropics/anthropic-sdk-go/packages/respjson"
    22  )
    23  
    24  // BetaMemoryStoreMemoryService contains methods and other services that help with
    25  // interacting with the anthropic API.
    26  //
    27  // Note, unlike clients, this service does not read variables from the environment
    28  // automatically. You should not instantiate this service directly, and instead use
    29  // the [NewBetaMemoryStoreMemoryService] method instead.
    30  type BetaMemoryStoreMemoryService struct {
    31  	Options []option.RequestOption
    32  }
    33  
    34  // NewBetaMemoryStoreMemoryService generates a new service that applies the given
    35  // options to each request. These options are applied after the parent client's
    36  // options (if there is one), and before any request-specific options.
    37  func NewBetaMemoryStoreMemoryService(opts ...option.RequestOption) (r BetaMemoryStoreMemoryService) {
    38  	r = BetaMemoryStoreMemoryService{}
    39  	r.Options = opts
    40  	return
    41  }
    42  
    43  // Create a memory
    44  func (r *BetaMemoryStoreMemoryService) New(ctx context.Context, memoryStoreID string, params BetaMemoryStoreMemoryNewParams, opts ...option.RequestOption) (res *BetaManagedAgentsMemory, err error) {
    45  	for _, v := range params.Betas {
    46  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
    47  	}
    48  	if !param.IsOmitted(params.WorkspaceID) {
    49  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value)))
    50  	}
    51  	opts = slices.Concat(r.Options, opts)
    52  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "agent-memory-2026-07-22")}, opts...)
    53  	if memoryStoreID == "" {
    54  		err = errors.New("missing required memory_store_id parameter")
    55  		return nil, err
    56  	}
    57  	path := fmt.Sprintf("v1/memory_stores/%s/memories?beta=true", memoryStoreID)
    58  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
    59  	return res, err
    60  }
    61  
    62  // Retrieve a memory
    63  func (r *BetaMemoryStoreMemoryService) Get(ctx context.Context, memoryID string, params BetaMemoryStoreMemoryGetParams, opts ...option.RequestOption) (res *BetaManagedAgentsMemory, err error) {
    64  	for _, v := range params.Betas {
    65  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
    66  	}
    67  	if !param.IsOmitted(params.WorkspaceID) {
    68  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value)))
    69  	}
    70  	opts = slices.Concat(r.Options, opts)
    71  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "agent-memory-2026-07-22")}, opts...)
    72  	if params.MemoryStoreID == "" {
    73  		err = errors.New("missing required memory_store_id parameter")
    74  		return nil, err
    75  	}
    76  	if memoryID == "" {
    77  		err = errors.New("missing required memory_id parameter")
    78  		return nil, err
    79  	}
    80  	path := fmt.Sprintf("v1/memory_stores/%s/memories/%s?beta=true", params.MemoryStoreID, memoryID)
    81  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &res, opts...)
    82  	return res, err
    83  }
    84  
    85  // Update a memory
    86  func (r *BetaMemoryStoreMemoryService) Update(ctx context.Context, memoryID string, params BetaMemoryStoreMemoryUpdateParams, opts ...option.RequestOption) (res *BetaManagedAgentsMemory, err error) {
    87  	for _, v := range params.Betas {
    88  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
    89  	}
    90  	if !param.IsOmitted(params.WorkspaceID) {
    91  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value)))
    92  	}
    93  	opts = slices.Concat(r.Options, opts)
    94  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "agent-memory-2026-07-22")}, opts...)
    95  	if params.MemoryStoreID == "" {
    96  		err = errors.New("missing required memory_store_id parameter")
    97  		return nil, err
    98  	}
    99  	if memoryID == "" {
   100  		err = errors.New("missing required memory_id parameter")
   101  		return nil, err
   102  	}
   103  	path := fmt.Sprintf("v1/memory_stores/%s/memories/%s?beta=true", params.MemoryStoreID, memoryID)
   104  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
   105  	return res, err
   106  }
   107  
   108  // List memories
   109  func (r *BetaMemoryStoreMemoryService) List(ctx context.Context, memoryStoreID string, params BetaMemoryStoreMemoryListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaManagedAgentsMemoryListItemUnion], err error) {
   110  	var raw *http.Response
   111  	for _, v := range params.Betas {
   112  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
   113  	}
   114  	if !param.IsOmitted(params.WorkspaceID) {
   115  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value)))
   116  	}
   117  	opts = slices.Concat(r.Options, opts)
   118  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "agent-memory-2026-07-22"), option.WithResponseInto(&raw)}, opts...)
   119  	if memoryStoreID == "" {
   120  		err = errors.New("missing required memory_store_id parameter")
   121  		return nil, err
   122  	}
   123  	path := fmt.Sprintf("v1/memory_stores/%s/memories?beta=true", memoryStoreID)
   124  	cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
   125  	if err != nil {
   126  		return nil, err
   127  	}
   128  	err = cfg.Execute()
   129  	if err != nil {
   130  		return nil, err
   131  	}
   132  	res.SetPageConfig(cfg, raw)
   133  	return res, nil
   134  }
   135  
   136  // List memories
   137  func (r *BetaMemoryStoreMemoryService) ListAutoPaging(ctx context.Context, memoryStoreID string, params BetaMemoryStoreMemoryListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaManagedAgentsMemoryListItemUnion] {
   138  	return pagination.NewPageCursorAutoPager(r.List(ctx, memoryStoreID, params, opts...))
   139  }
   140  
   141  // Delete a memory
   142  func (r *BetaMemoryStoreMemoryService) Delete(ctx context.Context, memoryID string, params BetaMemoryStoreMemoryDeleteParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeletedMemory, err error) {
   143  	for _, v := range params.Betas {
   144  		opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
   145  	}
   146  	if !param.IsOmitted(params.WorkspaceID) {
   147  		opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value)))
   148  	}
   149  	opts = slices.Concat(r.Options, opts)
   150  	opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "agent-memory-2026-07-22")}, opts...)
   151  	if params.MemoryStoreID == "" {
   152  		err = errors.New("missing required memory_store_id parameter")
   153  		return nil, err
   154  	}
   155  	if memoryID == "" {
   156  		err = errors.New("missing required memory_id parameter")
   157  		return nil, err
   158  	}
   159  	path := fmt.Sprintf("v1/memory_stores/%s/memories/%s?beta=true", params.MemoryStoreID, memoryID)
   160  	err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &res, opts...)
   161  	return res, err
   162  }
   163  
   164  // Tombstone returned by
   165  // [Delete a memory](/en/api/beta/memory_stores/memories/delete). Deleting a memory
   166  // does not erase its version history: its versions remain listable via
   167  // [List memory versions](/en/api/beta/memory_stores/memory_versions/list) while
   168  // they are retained (each version is kept for at least the version retention
   169  // period after it was written, unless the store itself is deleted).
   170  type BetaManagedAgentsDeletedMemory struct {
   171  	// ID of the deleted memory (a `mem_...` value).
   172  	ID string `json:"id" api:"required"`
   173  	// Any of "memory_deleted".
   174  	Type BetaManagedAgentsDeletedMemoryType `json:"type" api:"required"`
   175  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   176  	JSON struct {
   177  		ID          respjson.Field
   178  		Type        respjson.Field
   179  		ExtraFields map[string]respjson.Field
   180  		raw         string
   181  	} `json:"-"`
   182  }
   183  
   184  // Returns the unmodified JSON received from the API
   185  func (r BetaManagedAgentsDeletedMemory) RawJSON() string { return r.JSON.raw }
   186  func (r *BetaManagedAgentsDeletedMemory) UnmarshalJSON(data []byte) error {
   187  	return apijson.UnmarshalRoot(data, r)
   188  }
   189  
   190  type BetaManagedAgentsDeletedMemoryType string
   191  
   192  const (
   193  	BetaManagedAgentsDeletedMemoryTypeMemoryDeleted BetaManagedAgentsDeletedMemoryType = "memory_deleted"
   194  )
   195  
   196  // A `memory` object: a single text document at a hierarchical path inside a memory
   197  // store. The `content` field is populated when `view=full` and `null` when
   198  // `view=basic`; the `content_size_bytes` and `content_sha256` fields are always
   199  // populated so sync clients can diff without fetching content. Memories are
   200  // addressed by their `mem_...` ID; the path is the create key and can be changed
   201  // via update.
   202  type BetaManagedAgentsMemory struct {
   203  	// Unique identifier for this memory (a `mem_...` value). Stable across renames;
   204  	// use this ID, not the path, to read, update, or delete the memory.
   205  	ID string `json:"id" api:"required"`
   206  	// Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The
   207  	// server applies no normalization, so clients can compute the same hash locally
   208  	// for staleness checks and as the value for a `content_sha256` precondition on
   209  	// update. Always populated, regardless of `view`.
   210  	ContentSha256 string `json:"content_sha256" api:"required"`
   211  	// Size of `content` in bytes (the UTF-8 plaintext length). Always populated,
   212  	// regardless of `view`.
   213  	ContentSizeBytes int64 `json:"content_size_bytes" api:"required"`
   214  	// A timestamp in RFC 3339 format
   215  	CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
   216  	// ID of the memory store this memory belongs to (a `memstore_...` value).
   217  	MemoryStoreID string `json:"memory_store_id" api:"required"`
   218  	// ID of the `memory_version` representing this memory's current content (a
   219  	// `memver_...` value). This is the authoritative head pointer; `memory_version`
   220  	// objects do not carry an `is_latest` flag, so compare against this field instead.
   221  	// Enumerate the history via
   222  	// [List memory versions](/en/api/beta/memory_stores/memory_versions/list).
   223  	MemoryVersionID string `json:"memory_version_id" api:"required"`
   224  	// Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`.
   225  	// Always starts with `/`. Paths are case-sensitive and unique within a store.
   226  	// Maximum 1,024 bytes.
   227  	Path string `json:"path" api:"required"`
   228  	// Any of "memory".
   229  	Type BetaManagedAgentsMemoryType `json:"type" api:"required"`
   230  	// A timestamp in RFC 3339 format
   231  	UpdatedAt time.Time `json:"updated_at" api:"required" format:"date-time"`
   232  	// The memory's UTF-8 text content. Populated when `view=full`; `null` when
   233  	// `view=basic`. Maximum 100 kB (102,400 bytes).
   234  	Content string `json:"content" api:"nullable"`
   235  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   236  	JSON struct {
   237  		ID               respjson.Field
   238  		ContentSha256    respjson.Field
   239  		ContentSizeBytes respjson.Field
   240  		CreatedAt        respjson.Field
   241  		MemoryStoreID    respjson.Field
   242  		MemoryVersionID  respjson.Field
   243  		Path             respjson.Field
   244  		Type             respjson.Field
   245  		UpdatedAt        respjson.Field
   246  		Content          respjson.Field
   247  		ExtraFields      map[string]respjson.Field
   248  		raw              string
   249  	} `json:"-"`
   250  }
   251  
   252  // Returns the unmodified JSON received from the API
   253  func (r BetaManagedAgentsMemory) RawJSON() string { return r.JSON.raw }
   254  func (r *BetaManagedAgentsMemory) UnmarshalJSON(data []byte) error {
   255  	return apijson.UnmarshalRoot(data, r)
   256  }
   257  
   258  type BetaManagedAgentsMemoryType string
   259  
   260  const (
   261  	BetaManagedAgentsMemoryTypeMemory BetaManagedAgentsMemoryType = "memory"
   262  )
   263  
   264  // BetaManagedAgentsMemoryListItemUnion contains all possible properties and values
   265  // from [BetaManagedAgentsMemory], [BetaManagedAgentsMemoryPrefix].
   266  //
   267  // Use the [BetaManagedAgentsMemoryListItemUnion.AsAny] method to switch on the
   268  // variant.
   269  //
   270  // Use the methods beginning with 'As' to cast the union to one of its variants.
   271  type BetaManagedAgentsMemoryListItemUnion struct {
   272  	// This field is from variant [BetaManagedAgentsMemory].
   273  	ID string `json:"id"`
   274  	// This field is from variant [BetaManagedAgentsMemory].
   275  	ContentSha256 string `json:"content_sha256"`
   276  	// This field is from variant [BetaManagedAgentsMemory].
   277  	ContentSizeBytes int64 `json:"content_size_bytes"`
   278  	// This field is from variant [BetaManagedAgentsMemory].
   279  	CreatedAt time.Time `json:"created_at"`
   280  	// This field is from variant [BetaManagedAgentsMemory].
   281  	MemoryStoreID string `json:"memory_store_id"`
   282  	// This field is from variant [BetaManagedAgentsMemory].
   283  	MemoryVersionID string `json:"memory_version_id"`
   284  	Path            string `json:"path"`
   285  	// Any of "memory", "memory_prefix".
   286  	Type string `json:"type"`
   287  	// This field is from variant [BetaManagedAgentsMemory].
   288  	UpdatedAt time.Time `json:"updated_at"`
   289  	// This field is from variant [BetaManagedAgentsMemory].
   290  	Content string `json:"content"`
   291  	JSON    struct {
   292  		ID               respjson.Field
   293  		ContentSha256    respjson.Field
   294  		ContentSizeBytes respjson.Field
   295  		CreatedAt        respjson.Field
   296  		MemoryStoreID    respjson.Field
   297  		MemoryVersionID  respjson.Field
   298  		Path             respjson.Field
   299  		Type             respjson.Field
   300  		UpdatedAt        respjson.Field
   301  		Content          respjson.Field
   302  		raw              string
   303  	} `json:"-"`
   304  }
   305  
   306  // anyBetaManagedAgentsMemoryListItem is implemented by each variant of
   307  // [BetaManagedAgentsMemoryListItemUnion] to add type safety for the return type of
   308  // [BetaManagedAgentsMemoryListItemUnion.AsAny]
   309  type anyBetaManagedAgentsMemoryListItem interface {
   310  	implBetaManagedAgentsMemoryListItemUnion()
   311  }
   312  
   313  func (BetaManagedAgentsMemory) implBetaManagedAgentsMemoryListItemUnion()       {}
   314  func (BetaManagedAgentsMemoryPrefix) implBetaManagedAgentsMemoryListItemUnion() {}
   315  
   316  // Use the following switch statement to find the correct variant
   317  //
   318  //	switch variant := BetaManagedAgentsMemoryListItemUnion.AsAny().(type) {
   319  //	case anthropic.BetaManagedAgentsMemory:
   320  //	case anthropic.BetaManagedAgentsMemoryPrefix:
   321  //	default:
   322  //	  fmt.Errorf("no variant present")
   323  //	}
   324  func (u BetaManagedAgentsMemoryListItemUnion) AsAny() anyBetaManagedAgentsMemoryListItem {
   325  	switch u.Type {
   326  	case "memory":
   327  		return u.AsMemory()
   328  	case "memory_prefix":
   329  		return u.AsMemoryPrefix()
   330  	}
   331  	return nil
   332  }
   333  
   334  func (u BetaManagedAgentsMemoryListItemUnion) AsMemory() (v BetaManagedAgentsMemory) {
   335  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
   336  	return
   337  }
   338  
   339  func (u BetaManagedAgentsMemoryListItemUnion) AsMemoryPrefix() (v BetaManagedAgentsMemoryPrefix) {
   340  	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
   341  	return
   342  }
   343  
   344  // Returns the unmodified JSON received from the API
   345  func (u BetaManagedAgentsMemoryListItemUnion) RawJSON() string { return u.JSON.raw }
   346  
   347  func (r *BetaManagedAgentsMemoryListItemUnion) UnmarshalJSON(data []byte) error {
   348  	return apijson.UnmarshalRoot(data, r)
   349  }
   350  
   351  // A rolled-up directory marker returned by
   352  // [List memories](/en/api/beta/memory_stores/memories/list) when `depth` is set.
   353  // Indicates that one or more memories exist deeper than the requested depth under
   354  // this prefix. This is a list-time rollup, not a stored resource; it has no ID and
   355  // no lifecycle. Each prefix counts toward the page `limit` and interleaves with
   356  // `memory` items in path order.
   357  type BetaManagedAgentsMemoryPrefix struct {
   358  	// The rolled-up path prefix, including a trailing `/` (e.g. `/projects/foo/`).
   359  	// Pass this value as `path_prefix` on a subsequent list call to drill into the
   360  	// directory.
   361  	Path string `json:"path" api:"required"`
   362  	// Any of "memory_prefix".
   363  	Type BetaManagedAgentsMemoryPrefixType `json:"type" api:"required"`
   364  	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
   365  	JSON struct {
   366  		Path        respjson.Field
   367  		Type        respjson.Field
   368  		ExtraFields map[string]respjson.Field
   369  		raw         string
   370  	} `json:"-"`
   371  }
   372  
   373  // Returns the unmodified JSON received from the API
   374  func (r BetaManagedAgentsMemoryPrefix) RawJSON() string { return r.JSON.raw }
   375  func (r *BetaManagedAgentsMemoryPrefix) UnmarshalJSON(data []byte) error {
   376  	return apijson.UnmarshalRoot(data, r)
   377  }
   378  
   379  type BetaManagedAgentsMemoryPrefixType string
   380  
   381  const (
   382  	BetaManagedAgentsMemoryPrefixTypeMemoryPrefix BetaManagedAgentsMemoryPrefixType = "memory_prefix"
   383  )
   384  
   385  // Selects which projection of a `memory` or `memory_version` the server returns.
   386  // `basic` returns the object with `content` set to `null`; `full` populates
   387  // `content`. When omitted, the default is endpoint-specific: retrieve operations
   388  // default to `full`; list, create, and update operations default to `basic`.
   389  // Listing with `view=full` caps `limit` at 20.
   390  type BetaManagedAgentsMemoryView string
   391  
   392  const (
   393  	BetaManagedAgentsMemoryViewBasic BetaManagedAgentsMemoryView = "basic"
   394  	BetaManagedAgentsMemoryViewFull  BetaManagedAgentsMemoryView = "full"
   395  )
   396  
   397  // Optimistic-concurrency precondition: the update applies only if the memory's
   398  // stored `content_sha256` equals the supplied value. On mismatch, the request
   399  // returns `memory_precondition_failed_error` (HTTP 409); re-read the memory and
   400  // retry against the fresh state. If the precondition fails but the stored state
   401  // already exactly matches the requested `content` and `path`, the server returns
   402  // 200 instead of 409.
   403  //
   404  // The property Type is required.
   405  type BetaManagedAgentsPreconditionParam struct {
   406  	// Any of "content_sha256".
   407  	Type BetaManagedAgentsPreconditionType `json:"type,omitzero" api:"required"`
   408  	// Expected `content_sha256` of the stored memory (64 lowercase hexadecimal
   409  	// characters). Typically the `content_sha256` returned by a prior read or list
   410  	// call. Because the server applies no content normalization, clients can also
   411  	// compute this locally as the SHA-256 of the UTF-8 content bytes.
   412  	ContentSha256 param.Opt[string] `json:"content_sha256,omitzero"`
   413  	paramObj
   414  }
   415  
   416  func (r BetaManagedAgentsPreconditionParam) MarshalJSON() (data []byte, err error) {
   417  	type shadow BetaManagedAgentsPreconditionParam
   418  	return param.MarshalObject(r, (*shadow)(&r))
   419  }
   420  func (r *BetaManagedAgentsPreconditionParam) UnmarshalJSON(data []byte) error {
   421  	return apijson.UnmarshalRoot(data, r)
   422  }
   423  
   424  type BetaManagedAgentsPreconditionType string
   425  
   426  const (
   427  	BetaManagedAgentsPreconditionTypeContentSha256 BetaManagedAgentsPreconditionType = "content_sha256"
   428  )
   429  
   430  type BetaMemoryStoreMemoryNewParams struct {
   431  	// UTF-8 text content for the new memory. Maximum 100 kB (102,400 bytes). Required;
   432  	// pass `""` explicitly to create an empty memory.
   433  	Content param.Opt[string] `json:"content,omitzero" api:"required"`
   434  	// Hierarchical path for the new memory, e.g. `/projects/foo/notes.md`. Must start
   435  	// with `/`, contain at least one non-empty segment, and be at most 1,024 bytes.
   436  	// Must not contain empty segments, `.` or `..` segments, control or format
   437  	// characters, or the Unicode line and paragraph separators (U+2028, U+2029), and
   438  	// must be NFC-normalized. Paths are case-sensitive.
   439  	Path        string            `json:"path" api:"required"`
   440  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
   441  	// Query parameter for view
   442  	//
   443  	// Any of "basic", "full".
   444  	View BetaManagedAgentsMemoryView `query:"view,omitzero" json:"-"`
   445  	// Optional header to specify the beta version(s) you want to use.
   446  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
   447  	paramObj
   448  }
   449  
   450  func (r BetaMemoryStoreMemoryNewParams) MarshalJSON() (data []byte, err error) {
   451  	type shadow BetaMemoryStoreMemoryNewParams
   452  	return param.MarshalObject(r, (*shadow)(&r))
   453  }
   454  func (r *BetaMemoryStoreMemoryNewParams) UnmarshalJSON(data []byte) error {
   455  	return apijson.UnmarshalRoot(data, r)
   456  }
   457  
   458  // URLQuery serializes [BetaMemoryStoreMemoryNewParams]'s query parameters as
   459  // `url.Values`.
   460  func (r BetaMemoryStoreMemoryNewParams) URLQuery() (v url.Values, err error) {
   461  	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
   462  		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
   463  		NestedFormat: apiquery.NestedQueryFormatBrackets,
   464  	})
   465  }
   466  
   467  type BetaMemoryStoreMemoryGetParams struct {
   468  	MemoryStoreID string            `path:"memory_store_id" api:"required" json:"-"`
   469  	WorkspaceID   param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
   470  	// Query parameter for view
   471  	//
   472  	// Any of "basic", "full".
   473  	View BetaManagedAgentsMemoryView `query:"view,omitzero" json:"-"`
   474  	// Optional header to specify the beta version(s) you want to use.
   475  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
   476  	paramObj
   477  }
   478  
   479  // URLQuery serializes [BetaMemoryStoreMemoryGetParams]'s query parameters as
   480  // `url.Values`.
   481  func (r BetaMemoryStoreMemoryGetParams) URLQuery() (v url.Values, err error) {
   482  	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
   483  		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
   484  		NestedFormat: apiquery.NestedQueryFormatBrackets,
   485  	})
   486  }
   487  
   488  type BetaMemoryStoreMemoryUpdateParams struct {
   489  	MemoryStoreID string `path:"memory_store_id" api:"required" json:"-"`
   490  	// New UTF-8 text content for the memory. Maximum 100 kB (102,400 bytes). Omit to
   491  	// leave the content unchanged (e.g., for a rename-only update).
   492  	Content param.Opt[string] `json:"content,omitzero"`
   493  	// New path for the memory (a rename). Must start with `/`, contain at least one
   494  	// non-empty segment, and be at most 1,024 bytes. Must not contain empty segments,
   495  	// `.` or `..` segments, control or format characters, or the Unicode line and
   496  	// paragraph separators (U+2028, U+2029), and must be NFC-normalized. Paths are
   497  	// case-sensitive. The memory's `id` is preserved across renames. Omit to leave the
   498  	// path unchanged.
   499  	Path        param.Opt[string] `json:"path,omitzero"`
   500  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
   501  	// Query parameter for view
   502  	//
   503  	// Any of "basic", "full".
   504  	View BetaManagedAgentsMemoryView `query:"view,omitzero" json:"-"`
   505  	// Optimistic-concurrency precondition: the update applies only if the memory's
   506  	// stored `content_sha256` equals the supplied value. On mismatch, the request
   507  	// returns `memory_precondition_failed_error` (HTTP 409); re-read the memory and
   508  	// retry against the fresh state. If the precondition fails but the stored state
   509  	// already exactly matches the requested `content` and `path`, the server returns
   510  	// 200 instead of 409.
   511  	Precondition BetaManagedAgentsPreconditionParam `json:"precondition,omitzero"`
   512  	// Optional header to specify the beta version(s) you want to use.
   513  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
   514  	paramObj
   515  }
   516  
   517  func (r BetaMemoryStoreMemoryUpdateParams) MarshalJSON() (data []byte, err error) {
   518  	type shadow BetaMemoryStoreMemoryUpdateParams
   519  	return param.MarshalObject(r, (*shadow)(&r))
   520  }
   521  func (r *BetaMemoryStoreMemoryUpdateParams) UnmarshalJSON(data []byte) error {
   522  	return apijson.UnmarshalRoot(data, r)
   523  }
   524  
   525  // URLQuery serializes [BetaMemoryStoreMemoryUpdateParams]'s query parameters as
   526  // `url.Values`.
   527  func (r BetaMemoryStoreMemoryUpdateParams) URLQuery() (v url.Values, err error) {
   528  	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
   529  		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
   530  		NestedFormat: apiquery.NestedQueryFormatBrackets,
   531  	})
   532  }
   533  
   534  type BetaMemoryStoreMemoryListParams struct {
   535  	// `0` (or omitted) returns all descendants below `path_prefix` (recursive). `1`
   536  	// returns immediate children only; deeper entries roll up as `memory_prefix`
   537  	// items. `depth=1` behaves like `ls`; omitting `depth` behaves like `find`.
   538  	Depth param.Opt[int64] `query:"depth,omitzero" json:"-"`
   539  	// Maximum number of items to return per page. Must be between 1 and 100. Defaults
   540  	// to 20 when omitted. Capped at 20 when `view=full`. Both `memory` and
   541  	// `memory_prefix` items count toward the limit.
   542  	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
   543  	// Opaque pagination cursor (a `page_...` value). Pass the `next_page` value from a
   544  	// previous response to fetch the next page; omit for the first page.
   545  	Page param.Opt[string] `query:"page,omitzero" json:"-"`
   546  	// Optional path prefix filter. Must end with `/` (segment-aligned), e.g.,
   547  	// `/notes/`. This value appears in request URLs. Do not include secrets or
   548  	// personally identifiable information.
   549  	PathPrefix  param.Opt[string] `query:"path_prefix,omitzero" json:"-"`
   550  	WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
   551  	// Which projection of each `memory` to return. Defaults to `basic` (content
   552  	// omitted). `full` populates `content` on each item and caps `limit` at 20; use
   553  	// this as the bulk-read path for export and sync.
   554  	//
   555  	// Any of "basic", "full".
   556  	View BetaManagedAgentsMemoryView `query:"view,omitzero" json:"-"`
   557  	// Optional header to specify the beta version(s) you want to use.
   558  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
   559  	paramObj
   560  }
   561  
   562  // URLQuery serializes [BetaMemoryStoreMemoryListParams]'s query parameters as
   563  // `url.Values`.
   564  func (r BetaMemoryStoreMemoryListParams) URLQuery() (v url.Values, err error) {
   565  	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
   566  		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
   567  		NestedFormat: apiquery.NestedQueryFormatBrackets,
   568  	})
   569  }
   570  
   571  type BetaMemoryStoreMemoryDeleteParams struct {
   572  	MemoryStoreID string `path:"memory_store_id" api:"required" json:"-"`
   573  	// Query parameter for expected_content_sha256
   574  	ExpectedContentSha256 param.Opt[string] `query:"expected_content_sha256,omitzero" json:"-"`
   575  	WorkspaceID           param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"`
   576  	// Optional header to specify the beta version(s) you want to use.
   577  	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
   578  	paramObj
   579  }
   580  
   581  // URLQuery serializes [BetaMemoryStoreMemoryDeleteParams]'s query parameters as
   582  // `url.Values`.
   583  func (r BetaMemoryStoreMemoryDeleteParams) URLQuery() (v url.Values, err error) {
   584  	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
   585  		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
   586  		NestedFormat: apiquery.NestedQueryFormatBrackets,
   587  	})
   588  }