diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cefcbcc0..7a9a29ad 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,7 +1,7 @@ { - ".": "0.90.0", + ".": "0.91.0", "packages/vertex-sdk": "0.16.0", - "packages/bedrock-sdk": "0.28.1", + "packages/bedrock-sdk": "0.29.0", "packages/foundry-sdk": "0.2.3", "packages/aws-sdk": "0.2.5" } diff --git a/.stats.yml b/.stats.yml index d44995ad..129aa034 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 77 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-e0696f59ae07dc1a9c5a8fc87a4eb05eb35afabaac0b5ff0ea38810fa9dd4a74.yml -openapi_spec_hash: 69278ebbb0d1aa0b322bbbd5128bcec5 -config_hash: b0dbd234c2752507397c139a416f6cba +configured_endpoints: 91 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-6811827071199207cf69c4e64cae1b41e7e74cdb14048e9c748701e474c694a7.yml +openapi_spec_hash: 0feddcbb70c1d373b305f9c95f7df8e6 +config_hash: c7cdab4e4eb2befb0d99f6db5c3d4737 diff --git a/CHANGELOG.md b/CHANGELOG.md index a777db73..c02852fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## 0.91.0 (2026-04-23) + +Full Changelog: [sdk-v0.90.0...sdk-v0.91.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.90.0...sdk-v0.91.0) + +### Features + +* **api:** CMA Memory public beta ([ddf732f](https://github.com/anthropics/anthropic-sdk-typescript/commit/ddf732f5f35c123f963fa270669e35707a2e3f7f)) +* **bedrock:** use auth header for mantle client ([#866](https://github.com/anthropics/anthropic-sdk-typescript/issues/866)) ([aec801a](https://github.com/anthropics/anthropic-sdk-typescript/commit/aec801afc7d37d9e8ca1471748ca599b442cbce4)) + + +### Bug Fixes + +* **api:** fix errors in api spec ([ae10768](https://github.com/anthropics/anthropic-sdk-typescript/commit/ae1076848587c6f994b45e3030269a635d38bc0b)) +* **api:** restore missing features ([1a5b47b](https://github.com/anthropics/anthropic-sdk-typescript/commit/1a5b47b6895ee2c47af8adea1f403b76dd3ca62f)) + + +### Chores + +* **internal:** more robust bootstrap script ([7716e19](https://github.com/anthropics/anthropic-sdk-typescript/commit/7716e19f7fceeb63bb20b9e4df904a021ae705dc)) +* **tests:** bump steady to v0.22.1 ([219a971](https://github.com/anthropics/anthropic-sdk-typescript/commit/219a9717439a458189ac83633b2d5cd9f1ad7d25)) + ## 0.90.0 (2026-04-16) Full Changelog: [sdk-v0.89.0...sdk-v0.90.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.89.0...sdk-v0.90.0) diff --git a/MIGRATION.md b/MIGRATION.md index 13eadf9a..21a0ed42 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -61,6 +61,11 @@ This affects the following methods: - `client.beta.vaults.credentials.update()` - `client.beta.vaults.credentials.delete()` - `client.beta.vaults.credentials.archive()` +- `client.beta.memoryStores.memories.retrieve()` +- `client.beta.memoryStores.memories.update()` +- `client.beta.memoryStores.memories.delete()` +- `client.beta.memoryStores.memoryVersions.retrieve()` +- `client.beta.memoryStores.memoryVersions.redact()` - `client.beta.skills.versions.retrieve()` - `client.beta.skills.versions.delete()` @@ -125,6 +130,12 @@ client.example.list(undefined, { headers: { ... } }); - `client.beta.vaults.delete()` - `client.beta.vaults.archive()` - `client.beta.vaults.credentials.list()` +- `client.beta.memoryStores.retrieve()` +- `client.beta.memoryStores.list()` +- `client.beta.memoryStores.delete()` +- `client.beta.memoryStores.archive()` +- `client.beta.memoryStores.memories.list()` +- `client.beta.memoryStores.memoryVersions.list()` - `client.beta.files.list()` - `client.beta.files.delete()` - `client.beta.files.download()` diff --git a/api.md b/api.md index 3490e280..8dce22e4 100644 --- a/api.md +++ b/api.md @@ -594,6 +594,7 @@ Types: - BetaManagedAgentsDeletedSession - BetaManagedAgentsFileResourceParams - BetaManagedAgentsGitHubRepositoryResourceParams +- BetaManagedAgentsMemoryStoreResourceParam - BetaManagedAgentsSession - BetaManagedAgentsSessionAgent - BetaManagedAgentsSessionStats @@ -678,6 +679,7 @@ Types: - BetaManagedAgentsDeleteSessionResource - BetaManagedAgentsFileResource - BetaManagedAgentsGitHubRepositoryResource +- BetaManagedAgentsMemoryStoreResource - BetaManagedAgentsSessionResource - ResourceRetrieveResponse - ResourceUpdateResponse @@ -739,6 +741,63 @@ Methods: - client.beta.vaults.credentials.delete(credentialID, { ...params }) -> BetaManagedAgentsDeletedCredential - client.beta.vaults.credentials.archive(credentialID, { ...params }) -> BetaManagedAgentsCredential +## MemoryStores + +Types: + +- BetaManagedAgentsDeletedMemoryStore +- BetaManagedAgentsMemoryStore + +Methods: + +- client.beta.memoryStores.create({ ...params }) -> BetaManagedAgentsMemoryStore +- client.beta.memoryStores.retrieve(memoryStoreID, { ...params }) -> BetaManagedAgentsMemoryStore +- client.beta.memoryStores.update(memoryStoreID, { ...params }) -> BetaManagedAgentsMemoryStore +- client.beta.memoryStores.list({ ...params }) -> BetaManagedAgentsMemoryStoresPageCursor +- client.beta.memoryStores.delete(memoryStoreID, { ...params }) -> BetaManagedAgentsDeletedMemoryStore +- client.beta.memoryStores.archive(memoryStoreID, { ...params }) -> BetaManagedAgentsMemoryStore + +### Memories + +Types: + +- BetaManagedAgentsConflictError +- BetaManagedAgentsContentSha256Precondition +- BetaManagedAgentsDeletedMemory +- BetaManagedAgentsError +- BetaManagedAgentsMemory +- BetaManagedAgentsMemoryListItem +- BetaManagedAgentsMemoryPathConflictError +- BetaManagedAgentsMemoryPreconditionFailedError +- BetaManagedAgentsMemoryPrefix +- BetaManagedAgentsMemoryView +- BetaManagedAgentsPrecondition + +Methods: + +- client.beta.memoryStores.memories.create(memoryStoreID, { ...params }) -> BetaManagedAgentsMemory +- client.beta.memoryStores.memories.retrieve(memoryID, { ...params }) -> BetaManagedAgentsMemory +- client.beta.memoryStores.memories.update(memoryID, { ...params }) -> BetaManagedAgentsMemory +- client.beta.memoryStores.memories.list(memoryStoreID, { ...params }) -> BetaManagedAgentsMemoryListItemsPageCursor +- client.beta.memoryStores.memories.delete(memoryID, { ...params }) -> BetaManagedAgentsDeletedMemory + +### MemoryVersions + +Types: + +- BetaManagedAgentsActor +- BetaManagedAgentsAPIActor +- BetaManagedAgentsMemoryVersion +- BetaManagedAgentsMemoryVersionOperation +- BetaManagedAgentsSessionActor +- BetaManagedAgentsUserActor + +Methods: + +- client.beta.memoryStores.memoryVersions.retrieve(memoryVersionID, { ...params }) -> BetaManagedAgentsMemoryVersion +- client.beta.memoryStores.memoryVersions.list(memoryStoreID, { ...params }) -> BetaManagedAgentsMemoryVersionsPageCursor +- client.beta.memoryStores.memoryVersions.redact(memoryVersionID, { ...params }) -> BetaManagedAgentsMemoryVersion + ## Files Types: diff --git a/bin/migration-config.json b/bin/migration-config.json index 3dd3840b..f577891b 100644 --- a/bin/migration-config.json +++ b/bin/migration-config.json @@ -263,6 +263,191 @@ } ] }, + { + "base": "beta.memoryStores.memories", + "name": "retrieve", + "params": [ + { + "type": "param", + "key": "memory_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": false + }, + { + "type": "options" + } + ], + "oldParams": [ + { + "type": "param", + "key": "memory_store_id", + "location": "path" + }, + { + "type": "param", + "key": "memory_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": true + }, + { + "type": "options" + } + ] + }, + { + "base": "beta.memoryStores.memories", + "name": "update", + "params": [ + { + "type": "param", + "key": "memory_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": false + }, + { + "type": "options" + } + ], + "oldParams": [ + { + "type": "param", + "key": "memory_store_id", + "location": "path" + }, + { + "type": "param", + "key": "memory_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": false + }, + { + "type": "options" + } + ] + }, + { + "base": "beta.memoryStores.memories", + "name": "delete", + "params": [ + { + "type": "param", + "key": "memory_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": false + }, + { + "type": "options" + } + ], + "oldParams": [ + { + "type": "param", + "key": "memory_store_id", + "location": "path" + }, + { + "type": "param", + "key": "memory_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": true + }, + { + "type": "options" + } + ] + }, + { + "base": "beta.memoryStores.memoryVersions", + "name": "retrieve", + "params": [ + { + "type": "param", + "key": "memory_version_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": false + }, + { + "type": "options" + } + ], + "oldParams": [ + { + "type": "param", + "key": "memory_store_id", + "location": "path" + }, + { + "type": "param", + "key": "memory_version_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": true + }, + { + "type": "options" + } + ] + }, + { + "base": "beta.memoryStores.memoryVersions", + "name": "redact", + "params": [ + { + "type": "param", + "key": "memory_version_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": false + }, + { + "type": "options" + } + ], + "oldParams": [ + { + "type": "param", + "key": "memory_store_id", + "location": "path" + }, + { + "type": "param", + "key": "memory_version_id", + "location": "path" + }, + { + "type": "params", + "maybeOverload": true + }, + { + "type": "options" + } + ] + }, { "base": "beta.skills.versions", "name": "retrieve", diff --git a/package.json b/package.json index 1f64d4ad..2a008a3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@anthropic-ai/sdk", - "version": "0.90.0", + "version": "0.91.0", "description": "The official TypeScript library for the Anthropic API", "author": "Anthropic ", "types": "dist/index.d.ts", diff --git a/packages/bedrock-sdk/CHANGELOG.md b/packages/bedrock-sdk/CHANGELOG.md index c679f0da..e20f31e9 100644 --- a/packages/bedrock-sdk/CHANGELOG.md +++ b/packages/bedrock-sdk/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.29.0 (2026-04-23) + +Full Changelog: [bedrock-sdk-v0.28.1...bedrock-sdk-v0.29.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.28.1...bedrock-sdk-v0.29.0) + +### Features + +* **bedrock:** use auth header for mantle client ([#866](https://github.com/anthropics/anthropic-sdk-typescript/issues/866)) ([aec801a](https://github.com/anthropics/anthropic-sdk-typescript/commit/aec801afc7d37d9e8ca1471748ca599b442cbce4)) + ## 0.28.1 (2026-04-08) Full Changelog: [bedrock-sdk-v0.28.0...bedrock-sdk-v0.28.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.28.0...bedrock-sdk-v0.28.1) diff --git a/packages/bedrock-sdk/package.json b/packages/bedrock-sdk/package.json index 22869bde..8204d741 100644 --- a/packages/bedrock-sdk/package.json +++ b/packages/bedrock-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@anthropic-ai/bedrock-sdk", - "version": "0.28.1", + "version": "0.29.0", "description": "The official TypeScript library for the Anthropic Bedrock API", "author": "Anthropic ", "types": "dist/index.d.ts", diff --git a/packages/bedrock-sdk/src/mantle-client.ts b/packages/bedrock-sdk/src/mantle-client.ts index f4370b54..09c9da62 100644 --- a/packages/bedrock-sdk/src/mantle-client.ts +++ b/packages/bedrock-sdk/src/mantle-client.ts @@ -20,7 +20,7 @@ export interface BedrockMantleClientOptions extends ClientOptions { awsRegion?: string | undefined; /** - * API key for x-api-key authentication. + * API key for Bearer token authentication. * * Takes precedence over AWS credential options. If neither `apiKey` nor * AWS credentials are provided, falls back to the `AWS_BEARER_TOKEN_BEDROCK` @@ -100,7 +100,7 @@ export class AnthropicBedrockMantle extends BaseAnthropic { * credentials > `awsProfile` > `AWS_BEARER_TOKEN_BEDROCK` env var > default * AWS credential chain. * - * @param {string | undefined} [opts.apiKey] - API key for x-api-key authentication. + * @param {string | undefined} [opts.apiKey] - API key for Bearer token authentication. * @param {string | null | undefined} [opts.awsAccessKey] - AWS access key ID for SigV4 authentication. * @param {string | null | undefined} [opts.awsSecretAccessKey] - AWS secret access key for SigV4 authentication. * @param {string | null | undefined} [opts.awsSessionToken] - AWS session token for temporary credentials. @@ -188,8 +188,8 @@ export class AnthropicBedrockMantle extends BaseAnthropic { } if (!this._useSigV4) { - // API key mode — use inherited x-api-key auth - return super.authHeaders(opts); + // API key / bearer token mode — use Authorization: Bearer header + return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]); } // SigV4 mode — auth is handled in prepareRequest since it needs the full request diff --git a/packages/bedrock-sdk/tests/bedrock-mantle.test.ts b/packages/bedrock-sdk/tests/bedrock-mantle.test.ts index 23555c1f..e83c1d71 100644 --- a/packages/bedrock-sdk/tests/bedrock-mantle.test.ts +++ b/packages/bedrock-sdk/tests/bedrock-mantle.test.ts @@ -120,6 +120,52 @@ describe('AnthropicBedrockMantle', () => { }); }); + describe('bearer token auth', () => { + test('sends Authorization: Bearer header when using apiKey', async () => { + const client = new AnthropicBedrockMantle({ + apiKey: 'test-bearer-token', + awsRegion: 'us-east-1', + maxRetries: 0, + }); + + await makeRequest(client); + + const requestInit = mockFetch.mock.calls[0]![1] as RequestInit; + const headers = new Headers(requestInit.headers as HeadersInit); + expect(headers.get('authorization')).toBe('Bearer test-bearer-token'); + expect(headers.get('x-api-key')).toBeNull(); + }); + + test('sends Authorization: Bearer header when using AWS_BEARER_TOKEN_BEDROCK env var', async () => { + process.env['AWS_BEARER_TOKEN_BEDROCK'] = 'env-bearer-token'; + + const client = new AnthropicBedrockMantle({ + awsRegion: 'us-east-1', + maxRetries: 0, + }); + + await makeRequest(client); + + const requestInit = mockFetch.mock.calls[0]![1] as RequestInit; + const headers = new Headers(requestInit.headers as HeadersInit); + expect(headers.get('authorization')).toBe('Bearer env-bearer-token'); + expect(headers.get('x-api-key')).toBeNull(); + }); + + test('does not send Authorization: Bearer header when using SigV4', async () => { + const client = new AnthropicBedrockMantle({ + awsAccessKey: 'my-access-key', + awsSecretAccessKey: 'my-secret-key', + awsRegion: 'us-east-1', + maxRetries: 0, + }); + + await makeRequest(client); + + expect(mockGetAuthHeaders).toHaveBeenCalledTimes(1); + }); + }); + describe('endpoint restrictions', () => { test('completions resource is not available', () => { const client = new AnthropicBedrockMantle({ diff --git a/packages/vertex-sdk/yarn.lock b/packages/vertex-sdk/yarn.lock index 52bb4e71..cdac8e66 100644 --- a/packages/vertex-sdk/yarn.lock +++ b/packages/vertex-sdk/yarn.lock @@ -17,7 +17,7 @@ "@anthropic-ai/sdk@file:../../dist": # x-release-please-start-version - version "0.90.0" + version "0.91.0" # x-release-please-end-version dependencies: json-schema-to-ts "^3.1.1" diff --git a/scripts/bootstrap b/scripts/bootstrap index 2a669c5e..9a7645e1 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { echo -n "==> Install Homebrew dependencies? (y/N): " read -r response diff --git a/scripts/detect-breaking-changes b/scripts/detect-breaking-changes index 1414fb97..f2c8c80c 100755 --- a/scripts/detect-breaking-changes +++ b/scripts/detect-breaking-changes @@ -23,6 +23,9 @@ TEST_PATHS=( tests/api-resources/beta/sessions/resources.test.ts tests/api-resources/beta/vaults/vaults.test.ts tests/api-resources/beta/vaults/credentials.test.ts + tests/api-resources/beta/memory-stores/memory-stores.test.ts + tests/api-resources/beta/memory-stores/memories.test.ts + tests/api-resources/beta/memory-stores/memory-versions.test.ts tests/api-resources/beta/files.test.ts tests/api-resources/beta/skills/skills.test.ts tests/api-resources/beta/skills/versions.test.ts diff --git a/scripts/mock b/scripts/mock index 1f84b12f..2147c2f8 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.20.2 -- steady --version + npm exec --package=@stdy/cli@0.22.1 -- steady --version - npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 489fce63..ff118ade 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 diff --git a/src/resources/beta/beta.ts b/src/resources/beta/beta.ts index 5fe0ce67..bef111d2 100644 --- a/src/resources/beta/beta.ts +++ b/src/resources/beta/beta.ts @@ -99,6 +99,19 @@ import { BetaManagedAgentsSkillParams, BetaManagedAgentsURLMCPServerParams, } from './agents/agents'; +import * as MemoryStoresAPI from './memory-stores/memory-stores'; +import { + BetaManagedAgentsDeletedMemoryStore, + BetaManagedAgentsMemoryStore, + BetaManagedAgentsMemoryStoresPageCursor, + MemoryStoreArchiveParams, + MemoryStoreCreateParams, + MemoryStoreDeleteParams, + MemoryStoreListParams, + MemoryStoreRetrieveParams, + MemoryStoreUpdateParams, + MemoryStores, +} from './memory-stores/memory-stores'; import * as MessagesAPI from './messages/messages'; import { BetaAdvisorMessageIterationUsage, @@ -317,6 +330,7 @@ import { BetaManagedAgentsDeletedSession, BetaManagedAgentsFileResourceParams, BetaManagedAgentsGitHubRepositoryResourceParams, + BetaManagedAgentsMemoryStoreResourceParam, BetaManagedAgentsSession, BetaManagedAgentsSessionAgent, BetaManagedAgentsSessionStats, @@ -364,6 +378,7 @@ export class Beta extends APIResource { environments: EnvironmentsAPI.Environments = new EnvironmentsAPI.Environments(this._client); sessions: SessionsAPI.Sessions = new SessionsAPI.Sessions(this._client); vaults: VaultsAPI.Vaults = new VaultsAPI.Vaults(this._client); + memoryStores: MemoryStoresAPI.MemoryStores = new MemoryStoresAPI.MemoryStores(this._client); files: FilesAPI.Files = new FilesAPI.Files(this._client); skills: SkillsAPI.Skills = new SkillsAPI.Skills(this._client); userProfiles: UserProfilesAPI.UserProfiles = new UserProfilesAPI.UserProfiles(this._client); @@ -392,8 +407,8 @@ export type AnthropicBeta = | 'skills-2025-10-02' | 'fast-mode-2026-02-01' | 'output-300k-2026-03-24' - | 'advisor-tool-2026-03-01' - | 'user-profiles-2026-03-24'; + | 'user-profiles-2026-03-24' + | 'advisor-tool-2026-03-01'; export interface BetaAPIError { message: string; @@ -474,6 +489,7 @@ Beta.Agents = Agents; Beta.Environments = Environments; Beta.Sessions = Sessions; Beta.Vaults = Vaults; +Beta.MemoryStores = MemoryStores; Beta.Files = Files; Beta.Skills = Skills; Beta.UserProfiles = UserProfiles; @@ -784,6 +800,7 @@ export declare namespace Beta { type BetaManagedAgentsDeletedSession as BetaManagedAgentsDeletedSession, type BetaManagedAgentsFileResourceParams as BetaManagedAgentsFileResourceParams, type BetaManagedAgentsGitHubRepositoryResourceParams as BetaManagedAgentsGitHubRepositoryResourceParams, + type BetaManagedAgentsMemoryStoreResourceParam as BetaManagedAgentsMemoryStoreResourceParam, type BetaManagedAgentsSession as BetaManagedAgentsSession, type BetaManagedAgentsSessionAgent as BetaManagedAgentsSessionAgent, type BetaManagedAgentsSessionStats as BetaManagedAgentsSessionStats, @@ -810,6 +827,19 @@ export declare namespace Beta { type VaultArchiveParams as VaultArchiveParams, }; + export { + MemoryStores as MemoryStores, + type BetaManagedAgentsDeletedMemoryStore as BetaManagedAgentsDeletedMemoryStore, + type BetaManagedAgentsMemoryStore as BetaManagedAgentsMemoryStore, + type BetaManagedAgentsMemoryStoresPageCursor as BetaManagedAgentsMemoryStoresPageCursor, + type MemoryStoreCreateParams as MemoryStoreCreateParams, + type MemoryStoreRetrieveParams as MemoryStoreRetrieveParams, + type MemoryStoreUpdateParams as MemoryStoreUpdateParams, + type MemoryStoreListParams as MemoryStoreListParams, + type MemoryStoreDeleteParams as MemoryStoreDeleteParams, + type MemoryStoreArchiveParams as MemoryStoreArchiveParams, + }; + export { Files as Files, type BetaFileScope as BetaFileScope, diff --git a/src/resources/beta/index.ts b/src/resources/beta/index.ts index 8aa3f419..09354ba2 100644 --- a/src/resources/beta/index.ts +++ b/src/resources/beta/index.ts @@ -83,6 +83,18 @@ export { type FileUploadParams, type FileMetadataPage, } from './files'; +export { + MemoryStores, + type BetaManagedAgentsDeletedMemoryStore, + type BetaManagedAgentsMemoryStore, + type MemoryStoreCreateParams, + type MemoryStoreRetrieveParams, + type MemoryStoreUpdateParams, + type MemoryStoreListParams, + type MemoryStoreDeleteParams, + type MemoryStoreArchiveParams, + type BetaManagedAgentsMemoryStoresPageCursor, +} from './memory-stores/index'; export { Messages, type BetaAdvisorMessageIterationUsage, @@ -322,6 +334,7 @@ export { type BetaManagedAgentsDeletedSession, type BetaManagedAgentsFileResourceParams, type BetaManagedAgentsGitHubRepositoryResourceParams, + type BetaManagedAgentsMemoryStoreResourceParam, type BetaManagedAgentsSession, type BetaManagedAgentsSessionAgent, type BetaManagedAgentsSessionStats, diff --git a/src/resources/beta/memory-stores.ts b/src/resources/beta/memory-stores.ts new file mode 100644 index 00000000..4de3e4b3 --- /dev/null +++ b/src/resources/beta/memory-stores.ts @@ -0,0 +1,3 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export * from './memory-stores/index'; diff --git a/src/resources/beta/memory-stores/index.ts b/src/resources/beta/memory-stores/index.ts new file mode 100644 index 00000000..30a1d403 --- /dev/null +++ b/src/resources/beta/memory-stores/index.ts @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + Memories, + type BetaManagedAgentsConflictError, + type BetaManagedAgentsContentSha256Precondition, + type BetaManagedAgentsDeletedMemory, + type BetaManagedAgentsError, + type BetaManagedAgentsMemory, + type BetaManagedAgentsMemoryListItem, + type BetaManagedAgentsMemoryPathConflictError, + type BetaManagedAgentsMemoryPreconditionFailedError, + type BetaManagedAgentsMemoryPrefix, + type BetaManagedAgentsMemoryView, + type BetaManagedAgentsPrecondition, + type MemoryCreateParams, + type MemoryRetrieveParams, + type MemoryUpdateParams, + type MemoryListParams, + type MemoryDeleteParams, + type BetaManagedAgentsMemoryListItemsPageCursor, +} from './memories'; +export { + MemoryStores, + type BetaManagedAgentsDeletedMemoryStore, + type BetaManagedAgentsMemoryStore, + type MemoryStoreCreateParams, + type MemoryStoreRetrieveParams, + type MemoryStoreUpdateParams, + type MemoryStoreListParams, + type MemoryStoreDeleteParams, + type MemoryStoreArchiveParams, + type BetaManagedAgentsMemoryStoresPageCursor, +} from './memory-stores'; +export { + MemoryVersions, + type BetaManagedAgentsActor, + type BetaManagedAgentsAPIActor, + type BetaManagedAgentsMemoryVersion, + type BetaManagedAgentsMemoryVersionOperation, + type BetaManagedAgentsSessionActor, + type BetaManagedAgentsUserActor, + type MemoryVersionRetrieveParams, + type MemoryVersionListParams, + type MemoryVersionRedactParams, + type BetaManagedAgentsMemoryVersionsPageCursor, +} from './memory-versions'; diff --git a/src/resources/beta/memory-stores/memories.ts b/src/resources/beta/memory-stores/memories.ts new file mode 100644 index 00000000..3966e268 --- /dev/null +++ b/src/resources/beta/memory-stores/memories.ts @@ -0,0 +1,399 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../core/resource'; +import * as BetaAPI from '../beta'; +import { APIPromise } from '../../../core/api-promise'; +import { PageCursor, type PageCursorParams, PagePromise } from '../../../core/pagination'; +import { buildHeaders } from '../../../internal/headers'; +import { RequestOptions } from '../../../internal/request-options'; +import { path } from '../../../internal/utils/path'; + +export class Memories extends APIResource { + /** + * CreateMemory + * + * @example + * ```ts + * const betaManagedAgentsMemory = + * await client.beta.memoryStores.memories.create( + * 'memory_store_id', + * { content: 'content', path: 'xx' }, + * ); + * ``` + */ + create( + memoryStoreID: string, + params: MemoryCreateParams, + options?: RequestOptions, + ): APIPromise { + const { view, betas, ...body } = params; + return this._client.post(path`/v1/memory_stores/${memoryStoreID}/memories?beta=true`, { + query: { view }, + body, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } + + /** + * GetMemory + * + * @example + * ```ts + * const betaManagedAgentsMemory = + * await client.beta.memoryStores.memories.retrieve( + * 'memory_id', + * { memory_store_id: 'memory_store_id' }, + * ); + * ``` + */ + retrieve( + memoryID: string, + params: MemoryRetrieveParams, + options?: RequestOptions, + ): APIPromise { + const { memory_store_id, betas, ...query } = params; + return this._client.get(path`/v1/memory_stores/${memory_store_id}/memories/${memoryID}?beta=true`, { + query, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } + + /** + * UpdateMemory + * + * @example + * ```ts + * const betaManagedAgentsMemory = + * await client.beta.memoryStores.memories.update( + * 'memory_id', + * { memory_store_id: 'memory_store_id' }, + * ); + * ``` + */ + update( + memoryID: string, + params: MemoryUpdateParams, + options?: RequestOptions, + ): APIPromise { + const { memory_store_id, view, betas, ...body } = params; + return this._client.post(path`/v1/memory_stores/${memory_store_id}/memories/${memoryID}?beta=true`, { + query: { view }, + body, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } + + /** + * ListMemories + * + * @example + * ```ts + * // Automatically fetches more pages as needed. + * for await (const betaManagedAgentsMemoryListItem of client.beta.memoryStores.memories.list( + * 'memory_store_id', + * )) { + * // ... + * } + * ``` + */ + list( + memoryStoreID: string, + params: MemoryListParams | null | undefined = {}, + options?: RequestOptions, + ): PagePromise { + const { betas, ...query } = params ?? {}; + return this._client.getAPIList( + path`/v1/memory_stores/${memoryStoreID}/memories?beta=true`, + PageCursor, + { + query, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }, + ); + } + + /** + * DeleteMemory + * + * @example + * ```ts + * const betaManagedAgentsDeletedMemory = + * await client.beta.memoryStores.memories.delete( + * 'memory_id', + * { memory_store_id: 'memory_store_id' }, + * ); + * ``` + */ + delete( + memoryID: string, + params: MemoryDeleteParams, + options?: RequestOptions, + ): APIPromise { + const { memory_store_id, expected_content_sha256, betas } = params; + return this._client.delete(path`/v1/memory_stores/${memory_store_id}/memories/${memoryID}?beta=true`, { + query: { expected_content_sha256 }, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } +} + +export type BetaManagedAgentsMemoryListItemsPageCursor = PageCursor; + +export interface BetaManagedAgentsConflictError { + type: 'conflict_error'; + + message?: string; +} + +export interface BetaManagedAgentsContentSha256Precondition { + type: 'content_sha256'; + + content_sha256?: string; +} + +export interface BetaManagedAgentsDeletedMemory { + id: string; + + type: 'memory_deleted'; +} + +export type BetaManagedAgentsError = + | BetaAPI.BetaInvalidRequestError + | BetaAPI.BetaAuthenticationError + | BetaAPI.BetaBillingError + | BetaAPI.BetaPermissionError + | BetaAPI.BetaNotFoundError + | BetaAPI.BetaRateLimitError + | BetaAPI.BetaGatewayTimeoutError + | BetaAPI.BetaAPIError + | BetaAPI.BetaOverloadedError + | BetaManagedAgentsMemoryPreconditionFailedError + | BetaManagedAgentsMemoryPathConflictError + | BetaManagedAgentsConflictError; + +export interface BetaManagedAgentsMemory { + id: string; + + content_sha256: string; + + content_size_bytes: number; + + /** + * A timestamp in RFC 3339 format + */ + created_at: string; + + memory_store_id: string; + + memory_version_id: string; + + path: string; + + type: 'memory'; + + /** + * A timestamp in RFC 3339 format + */ + updated_at: string; + + content?: string | null; +} + +export type BetaManagedAgentsMemoryListItem = BetaManagedAgentsMemory | BetaManagedAgentsMemoryPrefix; + +export interface BetaManagedAgentsMemoryPathConflictError { + type: 'memory_path_conflict_error'; + + conflicting_memory_id?: string; + + conflicting_path?: string; + + message?: string; +} + +export interface BetaManagedAgentsMemoryPreconditionFailedError { + type: 'memory_precondition_failed_error'; + + message?: string; +} + +export interface BetaManagedAgentsMemoryPrefix { + path: string; + + type: 'memory_prefix'; +} + +/** + * MemoryView enum + */ +export type BetaManagedAgentsMemoryView = 'basic' | 'full'; + +export interface BetaManagedAgentsPrecondition { + type: 'content_sha256'; + + content_sha256?: string; +} + +export interface MemoryCreateParams { + /** + * Body param + */ + content: string | null; + + /** + * Body param + */ + path: string; + + /** + * Query param: Query parameter for view + */ + view?: BetaManagedAgentsMemoryView; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryRetrieveParams { + /** + * Path param: Path parameter memory_store_id + */ + memory_store_id: string; + + /** + * Query param: Query parameter for view + */ + view?: BetaManagedAgentsMemoryView; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryUpdateParams { + /** + * Path param: Path parameter memory_store_id + */ + memory_store_id: string; + + /** + * Query param: Query parameter for view + */ + view?: BetaManagedAgentsMemoryView; + + /** + * Body param + */ + content?: string | null; + + /** + * Body param + */ + path?: string | null; + + /** + * Body param + */ + precondition?: BetaManagedAgentsPrecondition; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryListParams extends PageCursorParams { + /** + * Query param: Query parameter for depth + */ + depth?: number; + + /** + * Query param: Query parameter for order + */ + order?: 'asc' | 'desc'; + + /** + * Query param: Query parameter for order_by + */ + order_by?: string; + + /** + * Query param: Optional path prefix filter (raw string-prefix match; include a + * trailing slash for directory-scoped lists). This value appears in request URLs. + * Do not include secrets or personally identifiable information. + */ + path_prefix?: string; + + /** + * Query param: Query parameter for view + */ + view?: BetaManagedAgentsMemoryView; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryDeleteParams { + /** + * Path param: Path parameter memory_store_id + */ + memory_store_id: string; + + /** + * Query param: Query parameter for expected_content_sha256 + */ + expected_content_sha256?: string; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export declare namespace Memories { + export { + type BetaManagedAgentsConflictError as BetaManagedAgentsConflictError, + type BetaManagedAgentsContentSha256Precondition as BetaManagedAgentsContentSha256Precondition, + type BetaManagedAgentsDeletedMemory as BetaManagedAgentsDeletedMemory, + type BetaManagedAgentsError as BetaManagedAgentsError, + type BetaManagedAgentsMemory as BetaManagedAgentsMemory, + type BetaManagedAgentsMemoryListItem as BetaManagedAgentsMemoryListItem, + type BetaManagedAgentsMemoryPathConflictError as BetaManagedAgentsMemoryPathConflictError, + type BetaManagedAgentsMemoryPreconditionFailedError as BetaManagedAgentsMemoryPreconditionFailedError, + type BetaManagedAgentsMemoryPrefix as BetaManagedAgentsMemoryPrefix, + type BetaManagedAgentsMemoryView as BetaManagedAgentsMemoryView, + type BetaManagedAgentsPrecondition as BetaManagedAgentsPrecondition, + type BetaManagedAgentsMemoryListItemsPageCursor as BetaManagedAgentsMemoryListItemsPageCursor, + type MemoryCreateParams as MemoryCreateParams, + type MemoryRetrieveParams as MemoryRetrieveParams, + type MemoryUpdateParams as MemoryUpdateParams, + type MemoryListParams as MemoryListParams, + type MemoryDeleteParams as MemoryDeleteParams, + }; +} diff --git a/src/resources/beta/memory-stores/memory-stores.ts b/src/resources/beta/memory-stores/memory-stores.ts new file mode 100644 index 00000000..d2d92e51 --- /dev/null +++ b/src/resources/beta/memory-stores/memory-stores.ts @@ -0,0 +1,374 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../core/resource'; +import * as BetaAPI from '../beta'; +import * as MemoriesAPI from './memories'; +import { + BetaManagedAgentsConflictError, + BetaManagedAgentsContentSha256Precondition, + BetaManagedAgentsDeletedMemory, + BetaManagedAgentsError, + BetaManagedAgentsMemory, + BetaManagedAgentsMemoryListItem, + BetaManagedAgentsMemoryListItemsPageCursor, + BetaManagedAgentsMemoryPathConflictError, + BetaManagedAgentsMemoryPreconditionFailedError, + BetaManagedAgentsMemoryPrefix, + BetaManagedAgentsMemoryView, + BetaManagedAgentsPrecondition, + Memories, + MemoryCreateParams, + MemoryDeleteParams, + MemoryListParams, + MemoryRetrieveParams, + MemoryUpdateParams, +} from './memories'; +import * as MemoryVersionsAPI from './memory-versions'; +import { + BetaManagedAgentsAPIActor, + BetaManagedAgentsActor, + BetaManagedAgentsMemoryVersion, + BetaManagedAgentsMemoryVersionOperation, + BetaManagedAgentsMemoryVersionsPageCursor, + BetaManagedAgentsSessionActor, + BetaManagedAgentsUserActor, + MemoryVersionListParams, + MemoryVersionRedactParams, + MemoryVersionRetrieveParams, + MemoryVersions, +} from './memory-versions'; +import { APIPromise } from '../../../core/api-promise'; +import { PageCursor, type PageCursorParams, PagePromise } from '../../../core/pagination'; +import { buildHeaders } from '../../../internal/headers'; +import { RequestOptions } from '../../../internal/request-options'; +import { path } from '../../../internal/utils/path'; + +export class MemoryStores extends APIResource { + memories: MemoriesAPI.Memories = new MemoriesAPI.Memories(this._client); + memoryVersions: MemoryVersionsAPI.MemoryVersions = new MemoryVersionsAPI.MemoryVersions(this._client); + + /** + * CreateMemoryStore + * + * @example + * ```ts + * const betaManagedAgentsMemoryStore = + * await client.beta.memoryStores.create({ name: 'x' }); + * ``` + */ + create( + params: MemoryStoreCreateParams, + options?: RequestOptions, + ): APIPromise { + const { betas, ...body } = params; + return this._client.post('/v1/memory_stores?beta=true', { + body, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } + + /** + * GetMemoryStore + * + * @example + * ```ts + * const betaManagedAgentsMemoryStore = + * await client.beta.memoryStores.retrieve( + * 'memory_store_id', + * ); + * ``` + */ + retrieve( + memoryStoreID: string, + params: MemoryStoreRetrieveParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + const { betas } = params ?? {}; + return this._client.get(path`/v1/memory_stores/${memoryStoreID}?beta=true`, { + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } + + /** + * UpdateMemoryStore + * + * @example + * ```ts + * const betaManagedAgentsMemoryStore = + * await client.beta.memoryStores.update('memory_store_id'); + * ``` + */ + update( + memoryStoreID: string, + params: MemoryStoreUpdateParams, + options?: RequestOptions, + ): APIPromise { + const { betas, ...body } = params; + return this._client.post(path`/v1/memory_stores/${memoryStoreID}?beta=true`, { + body, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } + + /** + * ListMemoryStores + * + * @example + * ```ts + * // Automatically fetches more pages as needed. + * for await (const betaManagedAgentsMemoryStore of client.beta.memoryStores.list()) { + * // ... + * } + * ``` + */ + list( + params: MemoryStoreListParams | null | undefined = {}, + options?: RequestOptions, + ): PagePromise { + const { betas, ...query } = params ?? {}; + return this._client.getAPIList('/v1/memory_stores?beta=true', PageCursor, { + query, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } + + /** + * DeleteMemoryStore + * + * @example + * ```ts + * const betaManagedAgentsDeletedMemoryStore = + * await client.beta.memoryStores.delete('memory_store_id'); + * ``` + */ + delete( + memoryStoreID: string, + params: MemoryStoreDeleteParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + const { betas } = params ?? {}; + return this._client.delete(path`/v1/memory_stores/${memoryStoreID}?beta=true`, { + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } + + /** + * ArchiveMemoryStore + * + * @example + * ```ts + * const betaManagedAgentsMemoryStore = + * await client.beta.memoryStores.archive('memory_store_id'); + * ``` + */ + archive( + memoryStoreID: string, + params: MemoryStoreArchiveParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + const { betas } = params ?? {}; + return this._client.post(path`/v1/memory_stores/${memoryStoreID}/archive?beta=true`, { + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }); + } +} + +export type BetaManagedAgentsMemoryStoresPageCursor = PageCursor; + +export interface BetaManagedAgentsDeletedMemoryStore { + id: string; + + type: 'memory_store_deleted'; +} + +export interface BetaManagedAgentsMemoryStore { + id: string; + + /** + * A timestamp in RFC 3339 format + */ + created_at: string; + + name: string; + + type: 'memory_store'; + + /** + * A timestamp in RFC 3339 format + */ + updated_at: string; + + /** + * A timestamp in RFC 3339 format + */ + archived_at?: string | null; + + description?: string; + + metadata?: { [key: string]: string }; +} + +export interface MemoryStoreCreateParams { + /** + * Body param + */ + name: string; + + /** + * Body param + */ + description?: string; + + /** + * Body param + */ + metadata?: { [key: string]: string }; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryStoreRetrieveParams { + /** + * Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryStoreUpdateParams { + /** + * Body param + */ + description?: string | null; + + /** + * Body param: Metadata patch. Set a key to a string to upsert it, or to null to + * delete it. Omit the field to preserve. The stored bag is limited to 16 keys (up + * to 64 chars each) with values up to 512 chars. + */ + metadata?: { [key: string]: string | null } | null; + + /** + * Body param + */ + name?: string | null; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryStoreListParams extends PageCursorParams { + /** + * Query param: Return stores created at or after this time (inclusive). + */ + 'created_at[gte]'?: string; + + /** + * Query param: Return stores created at or before this time (inclusive). + */ + 'created_at[lte]'?: string; + + /** + * Query param: Query parameter for include_archived + */ + include_archived?: boolean; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryStoreDeleteParams { + /** + * Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryStoreArchiveParams { + /** + * Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +MemoryStores.Memories = Memories; +MemoryStores.MemoryVersions = MemoryVersions; + +export declare namespace MemoryStores { + export { + type BetaManagedAgentsDeletedMemoryStore as BetaManagedAgentsDeletedMemoryStore, + type BetaManagedAgentsMemoryStore as BetaManagedAgentsMemoryStore, + type BetaManagedAgentsMemoryStoresPageCursor as BetaManagedAgentsMemoryStoresPageCursor, + type MemoryStoreCreateParams as MemoryStoreCreateParams, + type MemoryStoreRetrieveParams as MemoryStoreRetrieveParams, + type MemoryStoreUpdateParams as MemoryStoreUpdateParams, + type MemoryStoreListParams as MemoryStoreListParams, + type MemoryStoreDeleteParams as MemoryStoreDeleteParams, + type MemoryStoreArchiveParams as MemoryStoreArchiveParams, + }; + + export { + Memories as Memories, + type BetaManagedAgentsConflictError as BetaManagedAgentsConflictError, + type BetaManagedAgentsContentSha256Precondition as BetaManagedAgentsContentSha256Precondition, + type BetaManagedAgentsDeletedMemory as BetaManagedAgentsDeletedMemory, + type BetaManagedAgentsError as BetaManagedAgentsError, + type BetaManagedAgentsMemory as BetaManagedAgentsMemory, + type BetaManagedAgentsMemoryListItem as BetaManagedAgentsMemoryListItem, + type BetaManagedAgentsMemoryPathConflictError as BetaManagedAgentsMemoryPathConflictError, + type BetaManagedAgentsMemoryPreconditionFailedError as BetaManagedAgentsMemoryPreconditionFailedError, + type BetaManagedAgentsMemoryPrefix as BetaManagedAgentsMemoryPrefix, + type BetaManagedAgentsMemoryView as BetaManagedAgentsMemoryView, + type BetaManagedAgentsPrecondition as BetaManagedAgentsPrecondition, + type BetaManagedAgentsMemoryListItemsPageCursor as BetaManagedAgentsMemoryListItemsPageCursor, + type MemoryCreateParams as MemoryCreateParams, + type MemoryRetrieveParams as MemoryRetrieveParams, + type MemoryUpdateParams as MemoryUpdateParams, + type MemoryListParams as MemoryListParams, + type MemoryDeleteParams as MemoryDeleteParams, + }; + + export { + MemoryVersions as MemoryVersions, + type BetaManagedAgentsActor as BetaManagedAgentsActor, + type BetaManagedAgentsAPIActor as BetaManagedAgentsAPIActor, + type BetaManagedAgentsMemoryVersion as BetaManagedAgentsMemoryVersion, + type BetaManagedAgentsMemoryVersionOperation as BetaManagedAgentsMemoryVersionOperation, + type BetaManagedAgentsSessionActor as BetaManagedAgentsSessionActor, + type BetaManagedAgentsUserActor as BetaManagedAgentsUserActor, + type BetaManagedAgentsMemoryVersionsPageCursor as BetaManagedAgentsMemoryVersionsPageCursor, + type MemoryVersionRetrieveParams as MemoryVersionRetrieveParams, + type MemoryVersionListParams as MemoryVersionListParams, + type MemoryVersionRedactParams as MemoryVersionRedactParams, + }; +} diff --git a/src/resources/beta/memory-stores/memory-versions.ts b/src/resources/beta/memory-stores/memory-versions.ts new file mode 100644 index 00000000..7701ddcc --- /dev/null +++ b/src/resources/beta/memory-stores/memory-versions.ts @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../core/resource'; +import * as BetaAPI from '../beta'; +import * as MemoriesAPI from './memories'; +import { APIPromise } from '../../../core/api-promise'; +import { PageCursor, type PageCursorParams, PagePromise } from '../../../core/pagination'; +import { buildHeaders } from '../../../internal/headers'; +import { RequestOptions } from '../../../internal/request-options'; +import { path } from '../../../internal/utils/path'; + +export class MemoryVersions extends APIResource { + /** + * GetMemoryVersion + * + * @example + * ```ts + * const betaManagedAgentsMemoryVersion = + * await client.beta.memoryStores.memoryVersions.retrieve( + * 'memory_version_id', + * { memory_store_id: 'memory_store_id' }, + * ); + * ``` + */ + retrieve( + memoryVersionID: string, + params: MemoryVersionRetrieveParams, + options?: RequestOptions, + ): APIPromise { + const { memory_store_id, betas, ...query } = params; + return this._client.get( + path`/v1/memory_stores/${memory_store_id}/memory_versions/${memoryVersionID}?beta=true`, + { + query, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }, + ); + } + + /** + * ListMemoryVersions + * + * @example + * ```ts + * // Automatically fetches more pages as needed. + * for await (const betaManagedAgentsMemoryVersion of client.beta.memoryStores.memoryVersions.list( + * 'memory_store_id', + * )) { + * // ... + * } + * ``` + */ + list( + memoryStoreID: string, + params: MemoryVersionListParams | null | undefined = {}, + options?: RequestOptions, + ): PagePromise { + const { betas, ...query } = params ?? {}; + return this._client.getAPIList( + path`/v1/memory_stores/${memoryStoreID}/memory_versions?beta=true`, + PageCursor, + { + query, + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }, + ); + } + + /** + * RedactMemoryVersion + * + * @example + * ```ts + * const betaManagedAgentsMemoryVersion = + * await client.beta.memoryStores.memoryVersions.redact( + * 'memory_version_id', + * { memory_store_id: 'memory_store_id' }, + * ); + * ``` + */ + redact( + memoryVersionID: string, + params: MemoryVersionRedactParams, + options?: RequestOptions, + ): APIPromise { + const { memory_store_id, betas } = params; + return this._client.post( + path`/v1/memory_stores/${memory_store_id}/memory_versions/${memoryVersionID}/redact?beta=true`, + { + ...options, + headers: buildHeaders([ + { 'anthropic-beta': [...(betas ?? []), 'managed-agents-2026-04-01'].toString() }, + options?.headers, + ]), + }, + ); + } +} + +export type BetaManagedAgentsMemoryVersionsPageCursor = PageCursor; + +export type BetaManagedAgentsActor = + | BetaManagedAgentsSessionActor + | BetaManagedAgentsAPIActor + | BetaManagedAgentsUserActor; + +export interface BetaManagedAgentsAPIActor { + api_key_id: string; + + type: 'api_actor'; +} + +export interface BetaManagedAgentsMemoryVersion { + id: string; + + /** + * A timestamp in RFC 3339 format + */ + created_at: string; + + memory_id: string; + + memory_store_id: string; + + /** + * MemoryVersionOperation enum + */ + operation: BetaManagedAgentsMemoryVersionOperation; + + type: 'memory_version'; + + content?: string | null; + + content_sha256?: string | null; + + content_size_bytes?: number | null; + + created_by?: BetaManagedAgentsActor; + + path?: string | null; + + /** + * A timestamp in RFC 3339 format + */ + redacted_at?: string | null; + + redacted_by?: BetaManagedAgentsActor; +} + +/** + * MemoryVersionOperation enum + */ +export type BetaManagedAgentsMemoryVersionOperation = 'created' | 'modified' | 'deleted'; + +export interface BetaManagedAgentsSessionActor { + session_id: string; + + type: 'session_actor'; +} + +export interface BetaManagedAgentsUserActor { + type: 'user_actor'; + + user_id: string; +} + +export interface MemoryVersionRetrieveParams { + /** + * Path param: Path parameter memory_store_id + */ + memory_store_id: string; + + /** + * Query param: Query parameter for view + */ + view?: MemoriesAPI.BetaManagedAgentsMemoryView; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryVersionListParams extends PageCursorParams { + /** + * Query param: Query parameter for api_key_id + */ + api_key_id?: string; + + /** + * Query param: Return versions created at or after this time (inclusive). + */ + 'created_at[gte]'?: string; + + /** + * Query param: Return versions created at or before this time (inclusive). + */ + 'created_at[lte]'?: string; + + /** + * Query param: Query parameter for memory_id + */ + memory_id?: string; + + /** + * Query param: Query parameter for operation + */ + operation?: BetaManagedAgentsMemoryVersionOperation; + + /** + * Query param: Query parameter for session_id + */ + session_id?: string; + + /** + * Query param: Query parameter for view + */ + view?: MemoriesAPI.BetaManagedAgentsMemoryView; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export interface MemoryVersionRedactParams { + /** + * Path param: Path parameter memory_store_id + */ + memory_store_id: string; + + /** + * Header param: Optional header to specify the beta version(s) you want to use. + */ + betas?: Array; +} + +export declare namespace MemoryVersions { + export { + type BetaManagedAgentsActor as BetaManagedAgentsActor, + type BetaManagedAgentsAPIActor as BetaManagedAgentsAPIActor, + type BetaManagedAgentsMemoryVersion as BetaManagedAgentsMemoryVersion, + type BetaManagedAgentsMemoryVersionOperation as BetaManagedAgentsMemoryVersionOperation, + type BetaManagedAgentsSessionActor as BetaManagedAgentsSessionActor, + type BetaManagedAgentsUserActor as BetaManagedAgentsUserActor, + type BetaManagedAgentsMemoryVersionsPageCursor as BetaManagedAgentsMemoryVersionsPageCursor, + type MemoryVersionRetrieveParams as MemoryVersionRetrieveParams, + type MemoryVersionListParams as MemoryVersionListParams, + type MemoryVersionRedactParams as MemoryVersionRedactParams, + }; +} diff --git a/src/resources/beta/sessions/index.ts b/src/resources/beta/sessions/index.ts index ad5ecd9a..0a93785a 100644 --- a/src/resources/beta/sessions/index.ts +++ b/src/resources/beta/sessions/index.ts @@ -64,6 +64,7 @@ export { type BetaManagedAgentsDeleteSessionResource, type BetaManagedAgentsFileResource, type BetaManagedAgentsGitHubRepositoryResource, + type BetaManagedAgentsMemoryStoreResource, type BetaManagedAgentsSessionResource, type ResourceRetrieveResponse, type ResourceUpdateResponse, @@ -83,6 +84,7 @@ export { type BetaManagedAgentsDeletedSession, type BetaManagedAgentsFileResourceParams, type BetaManagedAgentsGitHubRepositoryResourceParams, + type BetaManagedAgentsMemoryStoreResourceParam, type BetaManagedAgentsSession, type BetaManagedAgentsSessionAgent, type BetaManagedAgentsSessionStats, diff --git a/src/resources/beta/sessions/resources.ts b/src/resources/beta/sessions/resources.ts index 01f511a8..5e90fb02 100644 --- a/src/resources/beta/sessions/resources.ts +++ b/src/resources/beta/sessions/resources.ts @@ -213,23 +213,71 @@ export interface BetaManagedAgentsGitHubRepositoryResource { checkout?: SessionsAPI.BetaManagedAgentsBranchCheckout | SessionsAPI.BetaManagedAgentsCommitCheckout | null; } +/** + * A memory store attached to an agent session. + */ +export interface BetaManagedAgentsMemoryStoreResource { + /** + * The memory store ID (memstore\_...). Must belong to the caller's organization + * and workspace. + */ + memory_store_id: string; + + type: 'memory_store'; + + /** + * Access mode for an attached memory store. + */ + access?: 'read_write' | 'read_only' | null; + + /** + * Description of the memory store, snapshotted at attach time. Rendered into the + * agent's system prompt. Empty string when the store has no description. + */ + description?: string; + + /** + * Per-attachment guidance for the agent on how to use this store. Rendered into + * the memory section of the system prompt. Max 4096 chars. + */ + instructions?: string | null; + + /** + * Filesystem path where the store is mounted in the session container, e.g. + * /mnt/memory/user-preferences. Derived from the store's name. Output-only. + */ + mount_path?: string | null; + + /** + * Display name of the memory store, snapshotted at attach time. Later edits to the + * store's name do not propagate to this resource. + */ + name?: string | null; +} + +/** + * A memory store attached to an agent session. + */ export type BetaManagedAgentsSessionResource = | BetaManagedAgentsGitHubRepositoryResource - | BetaManagedAgentsFileResource; + | BetaManagedAgentsFileResource + | BetaManagedAgentsMemoryStoreResource; /** * The requested session resource. */ export type ResourceRetrieveResponse = | BetaManagedAgentsGitHubRepositoryResource - | BetaManagedAgentsFileResource; + | BetaManagedAgentsFileResource + | BetaManagedAgentsMemoryStoreResource; /** * The updated session resource. */ export type ResourceUpdateResponse = | BetaManagedAgentsGitHubRepositoryResource - | BetaManagedAgentsFileResource; + | BetaManagedAgentsFileResource + | BetaManagedAgentsMemoryStoreResource; export interface ResourceRetrieveParams { /** @@ -308,6 +356,7 @@ export declare namespace Resources { type BetaManagedAgentsDeleteSessionResource as BetaManagedAgentsDeleteSessionResource, type BetaManagedAgentsFileResource as BetaManagedAgentsFileResource, type BetaManagedAgentsGitHubRepositoryResource as BetaManagedAgentsGitHubRepositoryResource, + type BetaManagedAgentsMemoryStoreResource as BetaManagedAgentsMemoryStoreResource, type BetaManagedAgentsSessionResource as BetaManagedAgentsSessionResource, type ResourceRetrieveResponse as ResourceRetrieveResponse, type ResourceUpdateResponse as ResourceUpdateResponse, diff --git a/src/resources/beta/sessions/sessions.ts b/src/resources/beta/sessions/sessions.ts index fddc754a..1a4a460a 100644 --- a/src/resources/beta/sessions/sessions.ts +++ b/src/resources/beta/sessions/sessions.ts @@ -68,6 +68,7 @@ import { BetaManagedAgentsDeleteSessionResource, BetaManagedAgentsFileResource, BetaManagedAgentsGitHubRepositoryResource, + BetaManagedAgentsMemoryStoreResource, BetaManagedAgentsSessionResource, BetaManagedAgentsSessionResourcesPageCursor, ResourceAddParams, @@ -352,6 +353,30 @@ export interface BetaManagedAgentsGitHubRepositoryResourceParams { mount_path?: string | null; } +/** + * Parameters for attaching a memory store to an agent session. + */ +export interface BetaManagedAgentsMemoryStoreResourceParam { + /** + * The memory store ID (memstore\_...). Must belong to the caller's organization + * and workspace. + */ + memory_store_id: string; + + type: 'memory_store'; + + /** + * Access mode for an attached memory store. + */ + access?: 'read_write' | 'read_only' | null; + + /** + * Per-attachment guidance for the agent on how to use this store. Rendered into + * the memory section of the system prompt. Max 4096 chars. + */ + instructions?: string | null; +} + /** * A Managed Agents `session`. */ @@ -510,7 +535,11 @@ export interface SessionCreateParams { * Body param: Resources (e.g. repositories, files) to mount into the session's * container. */ - resources?: Array; + resources?: Array< + | BetaManagedAgentsGitHubRepositoryResourceParams + | BetaManagedAgentsFileResourceParams + | BetaManagedAgentsMemoryStoreResourceParam + >; /** * Body param: Human-readable session title. @@ -635,6 +664,7 @@ export declare namespace Sessions { type BetaManagedAgentsDeletedSession as BetaManagedAgentsDeletedSession, type BetaManagedAgentsFileResourceParams as BetaManagedAgentsFileResourceParams, type BetaManagedAgentsGitHubRepositoryResourceParams as BetaManagedAgentsGitHubRepositoryResourceParams, + type BetaManagedAgentsMemoryStoreResourceParam as BetaManagedAgentsMemoryStoreResourceParam, type BetaManagedAgentsSession as BetaManagedAgentsSession, type BetaManagedAgentsSessionAgent as BetaManagedAgentsSessionAgent, type BetaManagedAgentsSessionStats as BetaManagedAgentsSessionStats, @@ -713,6 +743,7 @@ export declare namespace Sessions { type BetaManagedAgentsDeleteSessionResource as BetaManagedAgentsDeleteSessionResource, type BetaManagedAgentsFileResource as BetaManagedAgentsFileResource, type BetaManagedAgentsGitHubRepositoryResource as BetaManagedAgentsGitHubRepositoryResource, + type BetaManagedAgentsMemoryStoreResource as BetaManagedAgentsMemoryStoreResource, type BetaManagedAgentsSessionResource as BetaManagedAgentsSessionResource, type ResourceRetrieveResponse as ResourceRetrieveResponse, type ResourceUpdateResponse as ResourceUpdateResponse, diff --git a/src/resources/completions.ts b/src/resources/completions.ts index f51e227f..d946790e 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -149,38 +149,22 @@ export interface CompletionCreateParamsBase { stream?: boolean; /** - * Body param: Amount of randomness injected into the response. - * - * Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` - * for analytical / multiple choice, and closer to `1.0` for creative and - * generative tasks. - * - * Note that even with `temperature` of `0.0`, the results will not be fully - * deterministic. + * @deprecated Deprecated. Models released after Claude Opus 4.6 do not support + * setting temperature. A value of 1.0 of will be accepted for backwards + * compatibility, all other values will be rejected with a 400 error. */ temperature?: number; /** - * Body param: Only sample from the top K options for each subsequent token. - * - * Used to remove "long tail" low probability responses. - * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277). - * - * Recommended for advanced use cases only. You usually only need to use - * `temperature`. + * @deprecated Deprecated. Models released after Claude Opus 4.6 do not accept + * top_k; any value will be rejected with a 400 error. */ top_k?: number; /** - * Body param: Use nucleus sampling. - * - * In nucleus sampling, we compute the cumulative distribution over all the options - * for each subsequent token in decreasing probability order and cut it off once it - * reaches a particular probability specified by `top_p`. You should either alter - * `temperature` or `top_p`, but not both. - * - * Recommended for advanced use cases only. You usually only need to use - * `temperature`. + * @deprecated Deprecated. Models released after Claude Opus 4.6 do not support + * setting top_p. A value >= 0.99 will be accepted for backwards compatibility, all + * other values will be rejected with a 400 error. */ top_p?: number; diff --git a/src/version.ts b/src/version.ts index f99c21e4..3fe97c6e 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.90.0'; // x-release-please-version +export const VERSION = '0.91.0'; // x-release-please-version diff --git a/tests/api-resources/beta/memory-stores/memories.test.ts b/tests/api-resources/beta/memory-stores/memories.test.ts new file mode 100644 index 00000000..f685b387 --- /dev/null +++ b/tests/api-resources/beta/memory-stores/memories.test.ts @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Anthropic from '@anthropic-ai/sdk'; + +const client = new Anthropic({ + apiKey: 'my-anthropic-api-key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource memories', () => { + test('create: only required params', async () => { + const responsePromise = client.beta.memoryStores.memories.create('memory_store_id', { + content: 'content', + path: 'xx', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.beta.memoryStores.memories.create('memory_store_id', { + content: 'content', + path: 'xx', + view: 'basic', + betas: ['message-batches-2024-09-24'], + }); + }); + + test('retrieve: only required params', async () => { + const responsePromise = client.beta.memoryStores.memories.retrieve('memory_id', { + memory_store_id: 'memory_store_id', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: required and optional params', async () => { + const response = await client.beta.memoryStores.memories.retrieve('memory_id', { + memory_store_id: 'memory_store_id', + view: 'basic', + betas: ['message-batches-2024-09-24'], + }); + }); + + test('update: only required params', async () => { + const responsePromise = client.beta.memoryStores.memories.update('memory_id', { + memory_store_id: 'memory_store_id', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: required and optional params', async () => { + const response = await client.beta.memoryStores.memories.update('memory_id', { + memory_store_id: 'memory_store_id', + view: 'basic', + content: 'content', + path: 'xx', + precondition: { type: 'content_sha256', content_sha256: 'content_sha256' }, + betas: ['message-batches-2024-09-24'], + }); + }); + + // buildURL drops path-level query params (SDK-4349) + test.skip('list', async () => { + const responsePromise = client.beta.memoryStores.memories.list('memory_store_id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // buildURL drops path-level query params (SDK-4349) + test.skip('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.beta.memoryStores.memories.list( + 'memory_store_id', + { + depth: 0, + limit: 0, + order: 'asc', + order_by: 'order_by', + page: 'page', + path_prefix: 'path_prefix', + view: 'basic', + betas: ['message-batches-2024-09-24'], + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Anthropic.NotFoundError); + }); + + test('delete: only required params', async () => { + const responsePromise = client.beta.memoryStores.memories.delete('memory_id', { + memory_store_id: 'memory_store_id', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: required and optional params', async () => { + const response = await client.beta.memoryStores.memories.delete('memory_id', { + memory_store_id: 'memory_store_id', + expected_content_sha256: 'expected_content_sha256', + betas: ['message-batches-2024-09-24'], + }); + }); +}); diff --git a/tests/api-resources/beta/memory-stores/memory-stores.test.ts b/tests/api-resources/beta/memory-stores/memory-stores.test.ts new file mode 100644 index 00000000..419a9ea9 --- /dev/null +++ b/tests/api-resources/beta/memory-stores/memory-stores.test.ts @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Anthropic from '@anthropic-ai/sdk'; + +const client = new Anthropic({ + apiKey: 'my-anthropic-api-key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource memoryStores', () => { + test('create: only required params', async () => { + const responsePromise = client.beta.memoryStores.create({ name: 'x' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.beta.memoryStores.create({ + name: 'x', + description: 'description', + metadata: { foo: 'string' }, + betas: ['message-batches-2024-09-24'], + }); + }); + + test('retrieve', async () => { + const responsePromise = client.beta.memoryStores.retrieve('memory_store_id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.beta.memoryStores.retrieve( + 'memory_store_id', + { betas: ['message-batches-2024-09-24'] }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Anthropic.NotFoundError); + }); + + test('update', async () => { + const responsePromise = client.beta.memoryStores.update('memory_store_id', {}); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // buildURL drops path-level query params (SDK-4349) + test.skip('list', async () => { + const responsePromise = client.beta.memoryStores.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // buildURL drops path-level query params (SDK-4349) + test.skip('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.beta.memoryStores.list( + { + 'created_at[gte]': '2019-12-27T18:11:19.117Z', + 'created_at[lte]': '2019-12-27T18:11:19.117Z', + include_archived: true, + limit: 0, + page: 'page', + betas: ['message-batches-2024-09-24'], + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Anthropic.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.beta.memoryStores.delete('memory_store_id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.beta.memoryStores.delete( + 'memory_store_id', + { betas: ['message-batches-2024-09-24'] }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Anthropic.NotFoundError); + }); + + test('archive', async () => { + const responsePromise = client.beta.memoryStores.archive('memory_store_id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('archive: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.beta.memoryStores.archive( + 'memory_store_id', + { betas: ['message-batches-2024-09-24'] }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Anthropic.NotFoundError); + }); +}); diff --git a/tests/api-resources/beta/memory-stores/memory-versions.test.ts b/tests/api-resources/beta/memory-stores/memory-versions.test.ts new file mode 100644 index 00000000..a90d7e40 --- /dev/null +++ b/tests/api-resources/beta/memory-stores/memory-versions.test.ts @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Anthropic from '@anthropic-ai/sdk'; + +const client = new Anthropic({ + apiKey: 'my-anthropic-api-key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource memoryVersions', () => { + test('retrieve: only required params', async () => { + const responsePromise = client.beta.memoryStores.memoryVersions.retrieve('memory_version_id', { + memory_store_id: 'memory_store_id', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: required and optional params', async () => { + const response = await client.beta.memoryStores.memoryVersions.retrieve('memory_version_id', { + memory_store_id: 'memory_store_id', + view: 'basic', + betas: ['message-batches-2024-09-24'], + }); + }); + + // buildURL drops path-level query params (SDK-4349) + test.skip('list', async () => { + const responsePromise = client.beta.memoryStores.memoryVersions.list('memory_store_id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // buildURL drops path-level query params (SDK-4349) + test.skip('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.beta.memoryStores.memoryVersions.list( + 'memory_store_id', + { + api_key_id: 'api_key_id', + 'created_at[gte]': '2019-12-27T18:11:19.117Z', + 'created_at[lte]': '2019-12-27T18:11:19.117Z', + limit: 0, + memory_id: 'memory_id', + operation: 'created', + page: 'page', + session_id: 'session_id', + view: 'basic', + betas: ['message-batches-2024-09-24'], + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Anthropic.NotFoundError); + }); + + test('redact: only required params', async () => { + const responsePromise = client.beta.memoryStores.memoryVersions.redact('memory_version_id', { + memory_store_id: 'memory_store_id', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('redact: required and optional params', async () => { + const response = await client.beta.memoryStores.memoryVersions.redact('memory_version_id', { + memory_store_id: 'memory_store_id', + betas: ['message-batches-2024-09-24'], + }); + }); +});