@anthropic-ai/sdk 0.125.0 → 0.127.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/client.d.mts +12 -11
- package/client.d.mts.map +1 -1
- package/client.d.ts +12 -11
- package/client.d.ts.map +1 -1
- package/client.js +865 -845
- package/client.js.map +1 -1
- package/client.mjs +866 -840
- package/client.mjs.map +1 -1
- package/core/api-promise.js +71 -68
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs +71 -64
- package/core/api-promise.mjs.map +1 -1
- package/core/error.js +5 -2
- package/core/error.js.map +1 -1
- package/core/error.mjs +5 -2
- package/core/error.mjs.map +1 -1
- package/core/pagination.js +56 -50
- package/core/pagination.js.map +1 -1
- package/core/pagination.mjs +56 -41
- package/core/pagination.mjs.map +1 -1
- package/core/streaming.js +212 -209
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +212 -209
- package/core/streaming.mjs.map +1 -1
- package/helpers/beta/mcp.js +14 -19
- package/helpers/beta/mcp.js.map +1 -1
- package/helpers/beta/mcp.mjs +14 -13
- package/helpers/beta/mcp.mjs.map +1 -1
- package/internal/constants.js +1 -1
- package/internal/constants.js.map +1 -1
- package/internal/decoders/jsonl.js +27 -24
- package/internal/decoders/jsonl.js.map +1 -1
- package/internal/decoders/jsonl.mjs +27 -24
- package/internal/decoders/jsonl.mjs.map +1 -1
- package/internal/decoders/line.js +52 -49
- package/internal/decoders/line.js.map +1 -1
- package/internal/decoders/line.mjs +52 -43
- package/internal/decoders/line.mjs.map +1 -1
- package/internal/file-store.js +256 -258
- package/internal/file-store.js.map +1 -1
- package/internal/file-store.mjs +256 -243
- package/internal/file-store.mjs.map +1 -1
- package/internal/node.browser.d.mts.map +1 -1
- package/internal/node.browser.d.ts.map +1 -1
- package/internal/node.browser.js.map +1 -1
- package/internal/node.browser.mjs +7 -7
- package/internal/node.browser.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +2 -2
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +3 -3
- package/internal/parse.mjs.map +1 -1
- package/internal/shim-types.js +0 -6
- package/internal/shim-types.js.map +1 -1
- package/internal/shim-types.mjs +0 -6
- package/internal/shim-types.mjs.map +1 -1
- package/internal/shims.d.mts +3 -3
- package/internal/shims.d.mts.map +1 -1
- package/internal/shims.d.ts +3 -3
- package/internal/shims.d.ts.map +1 -1
- package/internal/shims.js +0 -6
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +0 -6
- package/internal/shims.mjs.map +1 -1
- package/internal/stainless-helper-header.js +6 -6
- package/internal/stainless-helper-header.js.map +1 -1
- package/internal/utils/async-queue.js +66 -63
- package/internal/utils/async-queue.js.map +1 -1
- package/internal/utils/async-queue.mjs +66 -56
- package/internal/utils/async-queue.mjs.map +1 -1
- package/internal/utils/bytes.d.mts +1 -1
- package/internal/utils/bytes.d.mts.map +1 -1
- package/internal/utils/bytes.d.ts +1 -1
- package/internal/utils/bytes.d.ts.map +1 -1
- package/internal/utils/log.d.mts +7 -12
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +7 -12
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +12 -0
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +11 -0
- package/internal/utils/log.mjs.map +1 -1
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +595 -590
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +595 -590
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.js +544 -541
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +544 -541
- package/lib/MessageStream.mjs.map +1 -1
- package/lib/beta-parser.d.mts +1 -3
- package/lib/beta-parser.d.mts.map +1 -1
- package/lib/beta-parser.d.ts +1 -3
- package/lib/beta-parser.d.ts.map +1 -1
- package/lib/beta-parser.js.map +1 -1
- package/lib/beta-parser.mjs.map +1 -1
- package/lib/environments/poller.js +180 -174
- package/lib/environments/poller.js.map +1 -1
- package/lib/environments/poller.mjs +180 -153
- package/lib/environments/poller.mjs.map +1 -1
- package/lib/environments/worker.js +375 -369
- package/lib/environments/worker.js.map +1 -1
- package/lib/environments/worker.mjs +374 -329
- package/lib/environments/worker.mjs.map +1 -1
- package/lib/internal/stub.d.mts +2 -0
- package/lib/internal/stub.d.mts.map +1 -0
- package/lib/internal/stub.d.ts +2 -0
- package/lib/internal/stub.d.ts.map +1 -0
- package/lib/internal/stub.js +6 -0
- package/lib/internal/stub.js.map +1 -0
- package/lib/internal/stub.mjs +3 -0
- package/lib/internal/stub.mjs.map +1 -0
- package/lib/internal/types.d.mts +5 -0
- package/lib/internal/types.d.mts.map +1 -0
- package/lib/internal/types.d.ts +5 -0
- package/lib/internal/types.d.ts.map +1 -0
- package/lib/internal/types.js +3 -0
- package/lib/internal/types.js.map +1 -0
- package/lib/internal/types.mjs +2 -0
- package/lib/internal/types.mjs.map +1 -0
- package/lib/middleware.js +6 -1
- package/lib/middleware.js.map +1 -1
- package/lib/middleware.mjs +6 -1
- package/lib/middleware.mjs.map +1 -1
- package/lib/parser.d.mts +1 -3
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts +1 -3
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs.map +1 -1
- package/lib/tools/BetaToolRunner.d.mts +21 -6
- package/lib/tools/BetaToolRunner.d.mts.map +1 -1
- package/lib/tools/BetaToolRunner.d.ts +21 -6
- package/lib/tools/BetaToolRunner.d.ts.map +1 -1
- package/lib/tools/BetaToolRunner.js +415 -310
- package/lib/tools/BetaToolRunner.js.map +1 -1
- package/lib/tools/BetaToolRunner.mjs +414 -303
- package/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/lib/tools/SessionToolRunner.js +241 -235
- package/lib/tools/SessionToolRunner.js.map +1 -1
- package/lib/tools/SessionToolRunner.mjs +241 -192
- package/lib/tools/SessionToolRunner.mjs.map +1 -1
- package/lib/tools/ToolError.js +39 -36
- package/lib/tools/ToolError.js.map +1 -1
- package/lib/tools/ToolError.mjs +39 -13
- package/lib/tools/ToolError.mjs.map +1 -1
- package/lib/transform-json-schema.js +7 -5
- package/lib/transform-json-schema.js.map +1 -1
- package/lib/transform-json-schema.mjs +7 -5
- package/lib/transform-json-schema.mjs.map +1 -1
- package/package.json +4 -3
- package/resources/beta/agents/agents.js +135 -132
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs +135 -132
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/beta.d.mts +5 -5
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +5 -5
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +39 -36
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +39 -36
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/deployment-runs.d.mts +4 -0
- package/resources/beta/deployment-runs.d.mts.map +1 -1
- package/resources/beta/deployment-runs.d.ts +4 -0
- package/resources/beta/deployment-runs.d.ts.map +1 -1
- package/resources/beta/deployments.d.mts +5 -0
- package/resources/beta/deployments.d.mts.map +1 -1
- package/resources/beta/deployments.d.ts +5 -0
- package/resources/beta/deployments.d.ts.map +1 -1
- package/resources/beta/dreams.d.mts +19 -28
- package/resources/beta/dreams.d.mts.map +1 -1
- package/resources/beta/dreams.d.ts +19 -28
- package/resources/beta/dreams.d.ts.map +1 -1
- package/resources/beta/environments/environments.js +157 -154
- package/resources/beta/environments/environments.js.map +1 -1
- package/resources/beta/environments/environments.mjs +157 -154
- package/resources/beta/environments/environments.mjs.map +1 -1
- package/resources/beta/environments/work.js +255 -252
- package/resources/beta/environments/work.js.map +1 -1
- package/resources/beta/environments/work.mjs +255 -252
- package/resources/beta/environments/work.mjs.map +1 -1
- package/resources/beta/index.d.mts +2 -2
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +2 -2
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/memory-stores/memories.d.mts +6 -0
- package/resources/beta/memory-stores/memories.d.mts.map +1 -1
- package/resources/beta/memory-stores/memories.d.ts +6 -0
- package/resources/beta/memory-stores/memories.d.ts.map +1 -1
- package/resources/beta/memory-stores/memory-stores.js +150 -147
- package/resources/beta/memory-stores/memory-stores.js.map +1 -1
- package/resources/beta/memory-stores/memory-stores.mjs +150 -147
- package/resources/beta/memory-stores/memory-stores.mjs.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.mts +7 -0
- package/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.ts +7 -0
- package/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
- package/resources/beta/messages/batches.d.mts +12 -1
- package/resources/beta/messages/batches.d.mts.map +1 -1
- package/resources/beta/messages/batches.d.ts +12 -1
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/index.d.mts +1 -1
- package/resources/beta/messages/index.d.mts.map +1 -1
- package/resources/beta/messages/index.d.ts +1 -1
- package/resources/beta/messages/index.d.ts.map +1 -1
- package/resources/beta/messages/index.js.map +1 -1
- package/resources/beta/messages/index.mjs.map +1 -1
- package/resources/beta/messages/messages.d.mts +239 -101
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +239 -101
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +113 -110
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +113 -110
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/beta/models.d.mts +22 -1
- package/resources/beta/models.d.mts.map +1 -1
- package/resources/beta/models.d.ts +22 -1
- package/resources/beta/models.d.ts.map +1 -1
- package/resources/beta/organization/federation/federation.js +11 -8
- package/resources/beta/organization/federation/federation.js.map +1 -1
- package/resources/beta/organization/federation/federation.mjs +11 -8
- package/resources/beta/organization/federation/federation.mjs.map +1 -1
- package/resources/beta/organization/federation/rules/rules.js +187 -184
- package/resources/beta/organization/federation/rules/rules.js.map +1 -1
- package/resources/beta/organization/federation/rules/rules.mjs +187 -184
- package/resources/beta/organization/federation/rules/rules.mjs.map +1 -1
- package/resources/beta/organization/index.d.mts +1 -1
- package/resources/beta/organization/index.d.mts.map +1 -1
- package/resources/beta/organization/index.d.ts +1 -1
- package/resources/beta/organization/index.d.ts.map +1 -1
- package/resources/beta/organization/index.js.map +1 -1
- package/resources/beta/organization/index.mjs.map +1 -1
- package/resources/beta/organization/organization.d.mts +2 -2
- package/resources/beta/organization/organization.d.mts.map +1 -1
- package/resources/beta/organization/organization.d.ts +2 -2
- package/resources/beta/organization/organization.d.ts.map +1 -1
- package/resources/beta/organization/organization.js +38 -35
- package/resources/beta/organization/organization.js.map +1 -1
- package/resources/beta/organization/organization.mjs +38 -35
- package/resources/beta/organization/organization.mjs.map +1 -1
- package/resources/beta/organization/rate-limits.d.mts +87 -5
- package/resources/beta/organization/rate-limits.d.mts.map +1 -1
- package/resources/beta/organization/rate-limits.d.ts +87 -5
- package/resources/beta/organization/rate-limits.d.ts.map +1 -1
- package/resources/beta/organization/service-accounts/service-accounts.js +163 -160
- package/resources/beta/organization/service-accounts/service-accounts.js.map +1 -1
- package/resources/beta/organization/service-accounts/service-accounts.mjs +163 -160
- package/resources/beta/organization/service-accounts/service-accounts.mjs.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.d.mts +9 -4
- package/resources/beta/organization/workspaces/rate-limits.d.mts.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.d.ts +9 -4
- package/resources/beta/organization/workspaces/rate-limits.d.ts.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.js.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.mjs.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.d.mts +3 -3
- package/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.d.ts +3 -3
- package/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.js +97 -94
- package/resources/beta/organization/workspaces/workspaces.js.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.mjs +97 -94
- package/resources/beta/organization/workspaces/workspaces.mjs.map +1 -1
- package/resources/beta/sessions/events.d.mts +12 -21
- package/resources/beta/sessions/events.d.mts.map +1 -1
- package/resources/beta/sessions/events.d.ts +12 -21
- package/resources/beta/sessions/events.d.ts.map +1 -1
- package/resources/beta/sessions/events.js +118 -115
- package/resources/beta/sessions/events.js.map +1 -1
- package/resources/beta/sessions/events.mjs +118 -115
- package/resources/beta/sessions/events.mjs.map +1 -1
- package/resources/beta/sessions/resources.d.mts +0 -3
- package/resources/beta/sessions/resources.d.mts.map +1 -1
- package/resources/beta/sessions/resources.d.ts +0 -3
- package/resources/beta/sessions/resources.d.ts.map +1 -1
- package/resources/beta/sessions/sessions.d.mts +8 -2
- package/resources/beta/sessions/sessions.d.mts.map +1 -1
- package/resources/beta/sessions/sessions.d.ts +8 -2
- package/resources/beta/sessions/sessions.d.ts.map +1 -1
- package/resources/beta/sessions/sessions.js +161 -158
- package/resources/beta/sessions/sessions.js.map +1 -1
- package/resources/beta/sessions/sessions.mjs +161 -158
- package/resources/beta/sessions/sessions.mjs.map +1 -1
- package/resources/beta/sessions/threads/threads.js +86 -83
- package/resources/beta/sessions/threads/threads.js.map +1 -1
- package/resources/beta/sessions/threads/threads.mjs +86 -83
- package/resources/beta/sessions/threads/threads.mjs.map +1 -1
- package/resources/beta/skills/skills.js +104 -101
- package/resources/beta/skills/skills.js.map +1 -1
- package/resources/beta/skills/skills.mjs +104 -101
- package/resources/beta/skills/skills.mjs.map +1 -1
- package/resources/beta/tunnels/certificates.d.mts +2 -2
- package/resources/beta/tunnels/certificates.d.ts +2 -2
- package/resources/beta/tunnels/tunnels.js +188 -185
- package/resources/beta/tunnels/tunnels.js.map +1 -1
- package/resources/beta/tunnels/tunnels.mjs +188 -185
- package/resources/beta/tunnels/tunnels.mjs.map +1 -1
- package/resources/beta/user-profiles.d.mts +45 -0
- package/resources/beta/user-profiles.d.mts.map +1 -1
- package/resources/beta/user-profiles.d.ts +45 -0
- package/resources/beta/user-profiles.d.ts.map +1 -1
- package/resources/beta/user-profiles.js +25 -10
- package/resources/beta/user-profiles.js.map +1 -1
- package/resources/beta/user-profiles.mjs +25 -10
- package/resources/beta/user-profiles.mjs.map +1 -1
- package/resources/beta/vaults/credentials.d.mts +19 -19
- package/resources/beta/vaults/credentials.d.mts.map +1 -1
- package/resources/beta/vaults/credentials.d.ts +19 -19
- package/resources/beta/vaults/credentials.d.ts.map +1 -1
- package/resources/beta/vaults/vaults.js +156 -153
- package/resources/beta/vaults/vaults.js.map +1 -1
- package/resources/beta/vaults/vaults.mjs +156 -153
- package/resources/beta/vaults/vaults.mjs.map +1 -1
- package/resources/completions.d.mts +1 -1
- package/resources/completions.d.ts +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/messages/index.d.mts +1 -1
- package/resources/messages/index.d.mts.map +1 -1
- package/resources/messages/index.d.ts +1 -1
- package/resources/messages/index.d.ts.map +1 -1
- package/resources/messages/index.js.map +1 -1
- package/resources/messages/index.mjs.map +1 -1
- package/resources/messages/messages.d.mts +100 -63
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +100 -63
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +115 -112
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +115 -112
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/skills/skills.js +88 -85
- package/resources/skills/skills.js.map +1 -1
- package/resources/skills/skills.mjs +88 -85
- package/resources/skills/skills.mjs.map +1 -1
- package/resources/top-level.js +0 -1
- package/resources/top-level.js.map +1 -1
- package/resources/top-level.mjs +0 -1
- package/resources/top-level.mjs.map +1 -1
- package/src/client.ts +95 -72
- package/src/internal/node.browser.ts +7 -7
- package/src/internal/parse.ts +8 -11
- package/src/internal/shims.ts +4 -3
- package/src/internal/utils/bytes.ts +1 -1
- package/src/internal/utils/log.ts +16 -2
- package/src/lib/BetaMessageStream.ts +7 -5
- package/src/lib/beta-parser.ts +1 -3
- package/src/lib/internal/stub.ts +2 -0
- package/src/lib/internal/types.ts +2 -0
- package/src/lib/middleware.ts +6 -1
- package/src/lib/parser.ts +1 -3
- package/src/lib/tools/BetaToolRunner.ts +157 -24
- package/src/lib/transform-json-schema.ts +8 -6
- package/src/resources/beta/beta.ts +24 -1
- package/src/resources/beta/deployment-runs.ts +4 -0
- package/src/resources/beta/deployments.ts +5 -0
- package/src/resources/beta/dreams.ts +19 -28
- package/src/resources/beta/index.ts +11 -0
- package/src/resources/beta/memory-stores/memories.ts +6 -0
- package/src/resources/beta/memory-stores/memory-versions.ts +7 -0
- package/src/resources/beta/messages/batches.ts +13 -1
- package/src/resources/beta/messages/index.ts +10 -0
- package/src/resources/beta/messages/messages.ts +289 -100
- package/src/resources/beta/models.ts +25 -0
- package/src/resources/beta/organization/index.ts +6 -0
- package/src/resources/beta/organization/organization.ts +12 -0
- package/src/resources/beta/organization/rate-limits.ts +112 -4
- package/src/resources/beta/organization/workspaces/rate-limits.ts +16 -4
- package/src/resources/beta/organization/workspaces/workspaces.ts +3 -3
- package/src/resources/beta/sessions/events.ts +12 -21
- package/src/resources/beta/sessions/resources.ts +0 -3
- package/src/resources/beta/sessions/sessions.ts +8 -2
- package/src/resources/beta/tunnels/certificates.ts +2 -2
- package/src/resources/beta/user-profiles.ts +75 -10
- package/src/resources/beta/vaults/credentials.ts +19 -19
- package/src/resources/completions.ts +1 -1
- package/src/resources/index.ts +6 -0
- package/src/resources/messages/index.ts +6 -0
- package/src/resources/messages/messages.ts +128 -62
- package/src/tsconfig.json +13 -3
- package/src/version.ts +1 -1
- package/tools/agent-toolset/fs-util.js +0 -6
- package/tools/agent-toolset/fs-util.js.map +1 -1
- package/tools/agent-toolset/fs-util.mjs +0 -6
- package/tools/agent-toolset/fs-util.mjs.map +1 -1
- package/tools/agent-toolset/memories.js +4 -4
- package/tools/agent-toolset/memories.js.map +1 -1
- package/tools/agent-toolset/memories.mjs +2 -2
- package/tools/agent-toolset/memories.mjs.map +1 -1
- package/tools/agent-toolset/node.browser.js +12 -12
- package/tools/agent-toolset/node.browser.js.map +1 -1
- package/tools/agent-toolset/node.js +142 -139
- package/tools/agent-toolset/node.js.map +1 -1
- package/tools/agent-toolset/node.mjs +132 -125
- package/tools/agent-toolset/node.mjs.map +1 -1
- package/tools/agent-toolset/skills.js +5 -5
- package/tools/agent-toolset/skills.js.map +1 -1
- package/tools/agent-toolset/sync-interval.js +3 -3
- package/tools/agent-toolset/sync-interval.js.map +1 -1
- package/tools/memory/node.browser.js +2 -2
- package/tools/memory/node.browser.js.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -3,6 +3,7 @@ import { ToolError } from './ToolError';
|
|
|
3
3
|
import { Anthropic } from '../..';
|
|
4
4
|
import { AnthropicError } from '../../core/error';
|
|
5
5
|
import {
|
|
6
|
+
BetaCompactionConfig,
|
|
6
7
|
BetaContentBlockParam,
|
|
7
8
|
BetaMessage,
|
|
8
9
|
BetaMessageParam,
|
|
@@ -20,12 +21,14 @@ import { RequestOptions } from '../../internal/request-options';
|
|
|
20
21
|
import { buildHeaders } from '../../internal/headers';
|
|
21
22
|
import { promiseWithResolvers } from '../../internal/utils/promise';
|
|
22
23
|
import { checkNever } from '../../internal/utils/values';
|
|
24
|
+
import { loggerFor } from '../../internal/utils/log';
|
|
23
25
|
import { CompactionControl, DEFAULT_SUMMARY_PROMPT, DEFAULT_TOKEN_THRESHOLD } from './CompactionControl';
|
|
24
26
|
import {
|
|
25
27
|
collectStainlessHelpers,
|
|
26
28
|
helperHeader,
|
|
27
29
|
STAINLESS_HELPER_HEADER,
|
|
28
30
|
} from '../../internal/stainless-helper-header';
|
|
31
|
+
import type { Simplify } from '../internal/types';
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* A ToolRunner handles the automatic conversation loop between the assistant and tools.
|
|
@@ -43,6 +46,8 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
43
46
|
#options: BetaToolRunnerRequestOptions;
|
|
44
47
|
/** Promise for the last message received from the assistant */
|
|
45
48
|
#message?: Promise<BetaMessage> | undefined;
|
|
49
|
+
/** The stream of the request in progress, when streaming */
|
|
50
|
+
#stream?: BetaMessageStream | undefined;
|
|
46
51
|
/** Cached tool response to avoid redundant executions */
|
|
47
52
|
#toolResponse?: Promise<BetaMessageParam | null> | undefined;
|
|
48
53
|
/** Promise resolvers for waiting on completion */
|
|
@@ -53,12 +58,17 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
53
58
|
};
|
|
54
59
|
/** Number of iterations (API requests) made so far */
|
|
55
60
|
#iterationCount = 0;
|
|
61
|
+
/** A compaction scheduled with `compactBeforeNextTurn()`, in flight until its response has been handled */
|
|
62
|
+
#compaction: Compaction = { status: 'idle' };
|
|
63
|
+
/** Whether the last turn was paused; a scheduled compaction waits for it to be resumed */
|
|
64
|
+
#turnPaused = false;
|
|
56
65
|
|
|
57
66
|
constructor(
|
|
58
67
|
private client: Anthropic,
|
|
59
68
|
params: BetaToolRunnerParams,
|
|
60
69
|
options?: BetaToolRunnerRequestOptions,
|
|
61
70
|
) {
|
|
71
|
+
rejectCompactionParam(params);
|
|
62
72
|
this.#state = {
|
|
63
73
|
params: {
|
|
64
74
|
// You can't clone the entire params since there are functions as handlers.
|
|
@@ -190,7 +200,6 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
190
200
|
|
|
191
201
|
try {
|
|
192
202
|
while (true) {
|
|
193
|
-
let stream;
|
|
194
203
|
try {
|
|
195
204
|
if (
|
|
196
205
|
this.#state.params.max_iterations &&
|
|
@@ -199,6 +208,12 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
199
208
|
break;
|
|
200
209
|
}
|
|
201
210
|
|
|
211
|
+
// The API can't compact a conversation that ends mid-turn, so a paused turn is resumed first.
|
|
212
|
+
if (this.#compaction.status === 'scheduled' && !this.#turnPaused) {
|
|
213
|
+
yield* this.#compact(this.#compaction.config);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
|
|
202
217
|
this.#mutated = false;
|
|
203
218
|
this.#toolResponse = undefined;
|
|
204
219
|
this.#iterationCount++;
|
|
@@ -206,23 +221,14 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
206
221
|
|
|
207
222
|
const { max_iterations, compactionControl, ...params } = this.#state.params;
|
|
208
223
|
|
|
209
|
-
|
|
210
|
-
stream = this.client.beta.messages.stream({ ...params }, this.#options);
|
|
211
|
-
this.#message = stream.finalMessage();
|
|
212
|
-
// Make sure that this promise doesn't throw before we get the option to do something about it.
|
|
213
|
-
// Error will be caught when we call await this.#message ultimately
|
|
214
|
-
this.#message.catch(() => {});
|
|
215
|
-
yield stream as any;
|
|
216
|
-
} else {
|
|
217
|
-
this.#message = this.client.beta.messages.create({ ...params, stream: false }, this.#options);
|
|
218
|
-
yield this.#message as any;
|
|
219
|
-
}
|
|
224
|
+
yield* this.#send(params);
|
|
220
225
|
|
|
221
226
|
const isCompacted = await this.#checkAndCompact();
|
|
222
227
|
if (!isCompacted) {
|
|
223
228
|
if (!this.#mutated) {
|
|
224
|
-
const message = await this.#message
|
|
229
|
+
const message = await this.#message!;
|
|
225
230
|
const nextStep = determineNextStepFromStopReason(message.stop_reason);
|
|
231
|
+
this.#turnPaused = nextStep === 'resume';
|
|
226
232
|
this.#state.params.messages.push({ role: message.role, content: message.content });
|
|
227
233
|
|
|
228
234
|
// Container-bound server tools reject a follow-up request that omits the container the
|
|
@@ -237,24 +243,28 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
if (nextStep === 'stop') {
|
|
246
|
+
yield* this.#compactAfterFinalTurn();
|
|
240
247
|
break;
|
|
241
248
|
}
|
|
242
249
|
if (nextStep === 'resume') {
|
|
243
250
|
continue;
|
|
244
251
|
}
|
|
252
|
+
} else {
|
|
253
|
+
// The caller has taken over the history, so the last response no longer says how it ends.
|
|
254
|
+
this.#turnPaused = false;
|
|
245
255
|
}
|
|
246
256
|
|
|
247
257
|
const toolMessage = await this.#generateToolResponse(this.#state.params.messages.at(-1)!);
|
|
248
258
|
if (toolMessage) {
|
|
249
259
|
this.#state.params.messages.push(toolMessage);
|
|
250
260
|
} else if (!this.#mutated) {
|
|
261
|
+
yield* this.#compactAfterFinalTurn();
|
|
251
262
|
break;
|
|
252
263
|
}
|
|
253
264
|
}
|
|
254
265
|
} finally {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
266
|
+
this.#stream?.abort();
|
|
267
|
+
this.#stream = undefined;
|
|
258
268
|
}
|
|
259
269
|
}
|
|
260
270
|
|
|
@@ -273,6 +283,69 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
273
283
|
}
|
|
274
284
|
}
|
|
275
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Sends one request and yields its message, or its stream when streaming. `#message` and `#stream` are set
|
|
288
|
+
* before the yield, so they are there while the caller handles the item; the loop aborts the stream at the
|
|
289
|
+
* end of the iteration.
|
|
290
|
+
*/
|
|
291
|
+
async *#send(params: MessageCreateParams): AsyncGenerator<BetaToolRunnerItem<Stream>, void, undefined> {
|
|
292
|
+
if (params.stream) {
|
|
293
|
+
this.#stream = this.client.beta.messages.stream({ ...params }, this.#options);
|
|
294
|
+
this.#message = this.#stream.finalMessage();
|
|
295
|
+
// Make sure that this promise doesn't throw before we get the option to do something about it.
|
|
296
|
+
// Error will be caught when we call await this.#message ultimately
|
|
297
|
+
this.#message.catch(() => {});
|
|
298
|
+
yield this.#stream as any;
|
|
299
|
+
} else {
|
|
300
|
+
this.#message = this.client.beta.messages.create({ ...params, stream: false }, this.#options);
|
|
301
|
+
yield this.#message as any;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async *#compact(
|
|
306
|
+
compaction: BetaCompactionConfig,
|
|
307
|
+
): AsyncGenerator<BetaToolRunnerItem<Stream>, void, undefined> {
|
|
308
|
+
rejectCompactionEdit(this.#state.params);
|
|
309
|
+
// The API refuses `compaction` alongside `context_management`; later requests keep it.
|
|
310
|
+
const { max_iterations, compactionControl, context_management, ...params } = this.#state.params;
|
|
311
|
+
this.#compaction = { status: 'in_flight' };
|
|
312
|
+
this.#toolResponse = undefined;
|
|
313
|
+
const lastMessage = this.#message;
|
|
314
|
+
|
|
315
|
+
try {
|
|
316
|
+
yield* this.#send({ ...params, compaction });
|
|
317
|
+
const message = await this.#message!;
|
|
318
|
+
if (message.content.some((block) => block.type === 'compaction' && block.content)) {
|
|
319
|
+
// The response has to be sent back as it came, first, replacing the messages it summarizes.
|
|
320
|
+
this.#state.params.messages = [{ role: message.role, content: message.content }];
|
|
321
|
+
} else {
|
|
322
|
+
loggerFor(this.client).warn('Compaction produced no summary; keeping the conversation as it is.');
|
|
323
|
+
// If the run ends here, `done()` resolves to the last real message rather than this response.
|
|
324
|
+
this.#message = lastMessage;
|
|
325
|
+
}
|
|
326
|
+
} finally {
|
|
327
|
+
this.#compaction = { status: 'idle' };
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async *#compactAfterFinalTurn(): AsyncGenerator<BetaToolRunnerItem<Stream>, void, undefined> {
|
|
332
|
+
if (this.#compaction.status !== 'scheduled') {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const lastContent = this.#state.params.messages.at(-1)?.content;
|
|
336
|
+
if (Array.isArray(lastContent) && lastContent.some((block) => block.type === 'tool_use')) {
|
|
337
|
+
// A turn that was cut short can end with tool calls that are never run, and the API can't
|
|
338
|
+
// compact a conversation whose last turn has an unanswered tool call.
|
|
339
|
+
loggerFor(this.client).warn(
|
|
340
|
+
'The pending compaction was skipped because the last turn ended with tool calls that were not run. ' +
|
|
341
|
+
'Call `compactBeforeNextTurn()` again if you continue the conversation.',
|
|
342
|
+
);
|
|
343
|
+
this.#compaction = { status: 'idle' };
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
yield* this.#compact(this.#compaction.config);
|
|
347
|
+
}
|
|
348
|
+
|
|
276
349
|
/**
|
|
277
350
|
* Update the parameters for the next API call. This invalidates any cached tool responses.
|
|
278
351
|
*
|
|
@@ -297,11 +370,19 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
297
370
|
setMessagesParams(
|
|
298
371
|
paramsOrMutator: BetaToolRunnerParams | ((prevParams: BetaToolRunnerParams) => BetaToolRunnerParams),
|
|
299
372
|
) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
373
|
+
const params =
|
|
374
|
+
typeof paramsOrMutator === 'function' ? paramsOrMutator(this.#state.params) : paramsOrMutator;
|
|
375
|
+
rejectCompactionParam(params);
|
|
376
|
+
if (this.#compaction.status !== 'idle') {
|
|
377
|
+
rejectCompactionEdit(params);
|
|
304
378
|
}
|
|
379
|
+
if (this.#compaction.status === 'in_flight' && params.messages !== this.#state.params.messages) {
|
|
380
|
+
throw new AnthropicError(
|
|
381
|
+
"Message params can't be changed while the conversation is being compacted, because the compaction " +
|
|
382
|
+
'response is about to replace them. Change them after this iteration instead.',
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
this.#state.params = params;
|
|
305
386
|
this.#mutated = true;
|
|
306
387
|
// Invalidate cached tool response since parameters changed
|
|
307
388
|
this.#toolResponse = undefined;
|
|
@@ -458,6 +539,28 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
458
539
|
}));
|
|
459
540
|
}
|
|
460
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Schedule a compaction of the conversation. Once the current turn has finished, including any tool
|
|
544
|
+
* calls, the runner requests a summary and replaces the message history with the compaction response,
|
|
545
|
+
* which is yielded like any other message. Requires the `compact-2026-09-04` beta.
|
|
546
|
+
*
|
|
547
|
+
* @param compaction - The config to send, as `messages.create()` takes it. Defaults to `{ type: 'summarize' }`
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* for await (const message of runner) {
|
|
551
|
+
* if (message.usage.input_tokens > 100_000) {
|
|
552
|
+
* runner.compactBeforeNextTurn();
|
|
553
|
+
* }
|
|
554
|
+
* }
|
|
555
|
+
*/
|
|
556
|
+
compactBeforeNextTurn(compaction?: BetaCompactionConfig): void {
|
|
557
|
+
if (this.#compaction.status === 'in_flight') {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
rejectCompactionEdit(this.#state.params);
|
|
561
|
+
this.#compaction = { status: 'scheduled', config: compaction ?? { type: 'summarize' } };
|
|
562
|
+
}
|
|
563
|
+
|
|
461
564
|
/**
|
|
462
565
|
* Makes the ToolRunner directly awaitable, equivalent to calling .runUntilDone()
|
|
463
566
|
* This allows using `await runner` instead of `await runner.runUntilDone()`
|
|
@@ -470,6 +573,26 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
470
573
|
}
|
|
471
574
|
}
|
|
472
575
|
|
|
576
|
+
function rejectCompactionParam(params: BetaToolRunnerParams): void {
|
|
577
|
+
if ('compaction' in params && params.compaction != null) {
|
|
578
|
+
throw new AnthropicError(
|
|
579
|
+
'`compaction` cannot be set on a tool runner: every request in the loop would compact again. ' +
|
|
580
|
+
'Call `runner.compactBeforeNextTurn()` when the conversation should be compacted instead.',
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function rejectCompactionEdit(params: BetaToolRunnerParams): void {
|
|
586
|
+
// The compaction request is sent without `context_management`, so the API can't refuse the pair there:
|
|
587
|
+
// it would run and bill the compaction, then refuse the next request.
|
|
588
|
+
if (params.context_management?.edits?.some((edit) => edit.type.startsWith('compact_'))) {
|
|
589
|
+
throw new AnthropicError(
|
|
590
|
+
"`compactBeforeNextTurn()` can't be used while `context_management` has a compaction edit, " +
|
|
591
|
+
"because the API doesn't accept a compaction block together with one. Remove the edit first.",
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
473
596
|
async function generateToolResponse(
|
|
474
597
|
params: BetaToolRunnerParams,
|
|
475
598
|
lastMessage = params.messages.at(-1),
|
|
@@ -644,14 +767,14 @@ function determineNextStepFromStopReason(stopReason: BetaStopReason | null): Nex
|
|
|
644
767
|
}
|
|
645
768
|
}
|
|
646
769
|
|
|
647
|
-
// vendored from typefest just to make things look a bit nicer on hover
|
|
648
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
649
|
-
|
|
650
770
|
/**
|
|
651
771
|
* Parameters for creating a ToolRunner, extending MessageCreateParams with runnable tools.
|
|
772
|
+
*
|
|
773
|
+
* `compaction` is left out because every request in the loop would compact again; call
|
|
774
|
+
* `BetaToolRunner.compactBeforeNextTurn()` instead.
|
|
652
775
|
*/
|
|
653
776
|
export type BetaToolRunnerParams = Simplify<
|
|
654
|
-
Omit<MessageCreateParams, 'tools'> & {
|
|
777
|
+
Omit<MessageCreateParams, 'tools' | 'compaction'> & {
|
|
655
778
|
tools: (BetaToolUnion | BetaRunnableTool<any>)[];
|
|
656
779
|
/**
|
|
657
780
|
* Maximum number of iterations (API requests) to make in the tool execution loop.
|
|
@@ -669,3 +792,13 @@ export type BetaToolRunnerParams = Simplify<
|
|
|
669
792
|
>;
|
|
670
793
|
|
|
671
794
|
export type BetaToolRunnerRequestOptions = Pick<RequestOptions, 'headers' | 'signal' | 'fallbackState'>;
|
|
795
|
+
|
|
796
|
+
type Compaction =
|
|
797
|
+
| { status: 'idle' }
|
|
798
|
+
| { status: 'scheduled'; config: BetaCompactionConfig }
|
|
799
|
+
| { status: 'in_flight' };
|
|
800
|
+
|
|
801
|
+
type BetaToolRunnerItem<Stream extends boolean> =
|
|
802
|
+
Stream extends true ? BetaMessageStream
|
|
803
|
+
: Stream extends false ? BetaMessage
|
|
804
|
+
: BetaMessage | BetaMessageStream;
|
|
@@ -28,12 +28,8 @@ export function transformJSONSchema(jsonSchema: JSONSchema): JSONSchema {
|
|
|
28
28
|
function _transformJSONSchema(jsonSchema: JSONSchema): JSONSchema {
|
|
29
29
|
const strictSchema: JSONSchema = {};
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
strictSchema['$ref'] = ref;
|
|
34
|
-
return strictSchema;
|
|
35
|
-
}
|
|
36
|
-
|
|
31
|
+
// `$defs` must be handled before the `$ref` early-return so that a root-level
|
|
32
|
+
// `$ref` with sibling `$defs` keeps its (transformed) definitions.
|
|
37
33
|
const defs = pop(jsonSchema, '$defs');
|
|
38
34
|
if (defs !== undefined) {
|
|
39
35
|
const strictDefs: Record<string, any> = {};
|
|
@@ -43,6 +39,12 @@ function _transformJSONSchema(jsonSchema: JSONSchema): JSONSchema {
|
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
|
|
42
|
+
const ref = pop(jsonSchema, '$ref');
|
|
43
|
+
if (ref !== undefined) {
|
|
44
|
+
strictSchema['$ref'] = ref;
|
|
45
|
+
return strictSchema;
|
|
46
|
+
}
|
|
47
|
+
|
|
46
48
|
const type = pop(jsonSchema, 'type');
|
|
47
49
|
const anyOf = pop(jsonSchema, 'anyOf');
|
|
48
50
|
const oneOf = pop(jsonSchema, 'oneOf');
|
|
@@ -115,6 +115,7 @@ import {
|
|
|
115
115
|
import * as ModelsAPI from './models';
|
|
116
116
|
import {
|
|
117
117
|
BetaCapabilitySupport,
|
|
118
|
+
BetaCompactionCapability,
|
|
118
119
|
BetaContextManagementCapability,
|
|
119
120
|
BetaEffortCapability,
|
|
120
121
|
BetaModelCapabilities,
|
|
@@ -407,6 +408,7 @@ import {
|
|
|
407
408
|
BetaCompact20260112Edit,
|
|
408
409
|
BetaCompactionBlock,
|
|
409
410
|
BetaCompactionBlockParam,
|
|
411
|
+
BetaCompactionConfig,
|
|
410
412
|
BetaCompactionContentBlockDelta,
|
|
411
413
|
BetaCompactionIterationUsage,
|
|
412
414
|
BetaComputerCursorPositionConfig,
|
|
@@ -466,6 +468,7 @@ import {
|
|
|
466
468
|
BetaJSONOutputFormat,
|
|
467
469
|
BetaInputTokensClearAtLeast,
|
|
468
470
|
BetaInputTokensTrigger,
|
|
471
|
+
BetaInputTransformation,
|
|
469
472
|
BetaMCPToolResultBlock,
|
|
470
473
|
BetaMCPToolUseBlock,
|
|
471
474
|
BetaMCPToolUseBlockParam,
|
|
@@ -513,6 +516,7 @@ import {
|
|
|
513
516
|
BetaSignatureDelta,
|
|
514
517
|
BetaSkillParams,
|
|
515
518
|
BetaStopReason,
|
|
519
|
+
BetaSummarizeCompaction,
|
|
516
520
|
BetaSystemMessageOutputConfig,
|
|
517
521
|
BetaTextBlock,
|
|
518
522
|
BetaTextBlockParam,
|
|
@@ -538,6 +542,7 @@ import {
|
|
|
538
542
|
BetaThinkingConfigParam,
|
|
539
543
|
BetaThinkingDelta,
|
|
540
544
|
BetaThinkingDroppedInputTransformation,
|
|
545
|
+
BetaThinkingMismatchAllowedInputTransformation,
|
|
541
546
|
BetaThinkingPrefixMismatchBehavior,
|
|
542
547
|
BetaThinkingTurns,
|
|
543
548
|
BetaTokenTaskBudget,
|
|
@@ -582,6 +587,12 @@ import {
|
|
|
582
587
|
BetaWebFetchToolResultErrorBlock,
|
|
583
588
|
BetaWebFetchToolResultErrorBlockParam,
|
|
584
589
|
BetaWebFetchToolResultErrorCode,
|
|
590
|
+
BetaWebFetchURLSourceAll,
|
|
591
|
+
BetaWebFetchURLSourceExcept,
|
|
592
|
+
BetaWebFetchURLSourceNone,
|
|
593
|
+
BetaWebFetchURLSourceOnly,
|
|
594
|
+
BetaWebFetchURLSourceToolReference,
|
|
595
|
+
BetaWebFetchURLSources,
|
|
585
596
|
BetaWebSearchResultBlock,
|
|
586
597
|
BetaWebSearchResultBlockParam,
|
|
587
598
|
BetaWebSearchTool20250305,
|
|
@@ -753,7 +764,8 @@ export type AnthropicBeta =
|
|
|
753
764
|
| 'ce-user-management-2026-07-13'
|
|
754
765
|
| 'mid-conversation-output-config-2026-07-01'
|
|
755
766
|
| 'thinking-binding-controls-2026-08-01'
|
|
756
|
-
| 'mid-conversation-system-clear-at-2026-08-21'
|
|
767
|
+
| 'mid-conversation-system-clear-at-2026-08-21'
|
|
768
|
+
| 'compact-2026-09-04';
|
|
757
769
|
|
|
758
770
|
export interface BetaAPIError {
|
|
759
771
|
message: string;
|
|
@@ -887,6 +899,7 @@ export declare namespace Beta {
|
|
|
887
899
|
export {
|
|
888
900
|
Models as Models,
|
|
889
901
|
type BetaCapabilitySupport as BetaCapabilitySupport,
|
|
902
|
+
type BetaCompactionCapability as BetaCompactionCapability,
|
|
890
903
|
type BetaContextManagementCapability as BetaContextManagementCapability,
|
|
891
904
|
type BetaEffortCapability as BetaEffortCapability,
|
|
892
905
|
type BetaModelCapabilities as BetaModelCapabilities,
|
|
@@ -1004,6 +1017,7 @@ export declare namespace Beta {
|
|
|
1004
1017
|
type BetaCompact20260112Edit as BetaCompact20260112Edit,
|
|
1005
1018
|
type BetaCompactionBlock as BetaCompactionBlock,
|
|
1006
1019
|
type BetaCompactionBlockParam as BetaCompactionBlockParam,
|
|
1020
|
+
type BetaCompactionConfig as BetaCompactionConfig,
|
|
1007
1021
|
type BetaCompactionContentBlockDelta as BetaCompactionContentBlockDelta,
|
|
1008
1022
|
type BetaCompactionIterationUsage as BetaCompactionIterationUsage,
|
|
1009
1023
|
type BetaComputerCursorPositionConfig as BetaComputerCursorPositionConfig,
|
|
@@ -1063,6 +1077,7 @@ export declare namespace Beta {
|
|
|
1063
1077
|
type BetaJSONOutputFormat as BetaJSONOutputFormat,
|
|
1064
1078
|
type BetaInputTokensClearAtLeast as BetaInputTokensClearAtLeast,
|
|
1065
1079
|
type BetaInputTokensTrigger as BetaInputTokensTrigger,
|
|
1080
|
+
type BetaInputTransformation as BetaInputTransformation,
|
|
1066
1081
|
type BetaMCPToolConfig as BetaMCPToolConfig,
|
|
1067
1082
|
type BetaMCPToolDefaultConfig as BetaMCPToolDefaultConfig,
|
|
1068
1083
|
type BetaMCPToolResultBlock as BetaMCPToolResultBlock,
|
|
@@ -1112,6 +1127,7 @@ export declare namespace Beta {
|
|
|
1112
1127
|
type BetaSignatureDelta as BetaSignatureDelta,
|
|
1113
1128
|
type BetaSkillParams as BetaSkillParams,
|
|
1114
1129
|
type BetaStopReason as BetaStopReason,
|
|
1130
|
+
type BetaSummarizeCompaction as BetaSummarizeCompaction,
|
|
1115
1131
|
type BetaSystemMessageOutputConfig as BetaSystemMessageOutputConfig,
|
|
1116
1132
|
type BetaTextBlock as BetaTextBlock,
|
|
1117
1133
|
type BetaTextBlockParam as BetaTextBlockParam,
|
|
@@ -1137,6 +1153,7 @@ export declare namespace Beta {
|
|
|
1137
1153
|
type BetaThinkingConfigParam as BetaThinkingConfigParam,
|
|
1138
1154
|
type BetaThinkingDelta as BetaThinkingDelta,
|
|
1139
1155
|
type BetaThinkingDroppedInputTransformation as BetaThinkingDroppedInputTransformation,
|
|
1156
|
+
type BetaThinkingMismatchAllowedInputTransformation as BetaThinkingMismatchAllowedInputTransformation,
|
|
1140
1157
|
type BetaThinkingPrefixMismatchBehavior as BetaThinkingPrefixMismatchBehavior,
|
|
1141
1158
|
type BetaThinkingTurns as BetaThinkingTurns,
|
|
1142
1159
|
type BetaTokenTaskBudget as BetaTokenTaskBudget,
|
|
@@ -1181,6 +1198,12 @@ export declare namespace Beta {
|
|
|
1181
1198
|
type BetaWebFetchToolResultErrorBlock as BetaWebFetchToolResultErrorBlock,
|
|
1182
1199
|
type BetaWebFetchToolResultErrorBlockParam as BetaWebFetchToolResultErrorBlockParam,
|
|
1183
1200
|
type BetaWebFetchToolResultErrorCode as BetaWebFetchToolResultErrorCode,
|
|
1201
|
+
type BetaWebFetchURLSourceAll as BetaWebFetchURLSourceAll,
|
|
1202
|
+
type BetaWebFetchURLSourceExcept as BetaWebFetchURLSourceExcept,
|
|
1203
|
+
type BetaWebFetchURLSourceNone as BetaWebFetchURLSourceNone,
|
|
1204
|
+
type BetaWebFetchURLSourceOnly as BetaWebFetchURLSourceOnly,
|
|
1205
|
+
type BetaWebFetchURLSourceToolReference as BetaWebFetchURLSourceToolReference,
|
|
1206
|
+
type BetaWebFetchURLSources as BetaWebFetchURLSources,
|
|
1184
1207
|
type BetaWebSearchResultBlock as BetaWebSearchResultBlock,
|
|
1185
1208
|
type BetaWebSearchResultBlockParam as BetaWebSearchResultBlockParam,
|
|
1186
1209
|
type BetaWebSearchTool20250305 as BetaWebSearchTool20250305,
|
|
@@ -311,6 +311,10 @@ export type BetaManagedAgentsTriggerContext =
|
|
|
311
311
|
|
|
312
312
|
/**
|
|
313
313
|
* What triggered a deployment run.
|
|
314
|
+
*
|
|
315
|
+
* - `schedule` - The run was fired by the deployment's cron schedule.
|
|
316
|
+
* - `manual` - The run was started manually by creating a session directly against
|
|
317
|
+
* the deployment.
|
|
314
318
|
*/
|
|
315
319
|
export type BetaManagedAgentsTriggerType = 'schedule' | 'manual';
|
|
316
320
|
|
|
@@ -460,6 +460,11 @@ export type BetaManagedAgentsDeploymentPausedReasonError =
|
|
|
460
460
|
|
|
461
461
|
/**
|
|
462
462
|
* Lifecycle status of a deployment.
|
|
463
|
+
*
|
|
464
|
+
* - `active` - The deployment is active and can run sessions. Archived deployments
|
|
465
|
+
* also report this status; check `archived_at` to distinguish them.
|
|
466
|
+
* - `paused` - The deployment is paused. Autonomous triggers are suppressed;
|
|
467
|
+
* manual runs are still permitted.
|
|
463
468
|
*/
|
|
464
469
|
export type BetaManagedAgentsDeploymentStatus = 'active' | 'paused';
|
|
465
470
|
|
|
@@ -190,11 +190,6 @@ export interface BetaDream {
|
|
|
190
190
|
*/
|
|
191
191
|
model: BetaDreamModelConfig;
|
|
192
192
|
|
|
193
|
-
/**
|
|
194
|
-
* The default destination: the job creates a new output memory store as a clone of
|
|
195
|
-
* the memory_store input and writes the consolidated memories into it. The input
|
|
196
|
-
* store is never mutated.
|
|
197
|
-
*/
|
|
198
193
|
output_behavior: BetaOutputBehavior;
|
|
199
194
|
|
|
200
195
|
outputs: Array<BetaDreamOutput>;
|
|
@@ -223,11 +218,6 @@ export interface BetaDreamError {
|
|
|
223
218
|
type: string;
|
|
224
219
|
}
|
|
225
220
|
|
|
226
|
-
/**
|
|
227
|
-
* An input memory store the dream reads from. The dream never mutates this store
|
|
228
|
-
* unless it is also the destination: with output_behavior {type:
|
|
229
|
-
* "update_existing"} the job consolidates this store in place.
|
|
230
|
-
*/
|
|
231
221
|
export type BetaDreamInput = BetaDreamMemoryStoreInput | BetaDreamSessionsInput;
|
|
232
222
|
|
|
233
223
|
/**
|
|
@@ -305,6 +295,23 @@ export interface BetaDreamSessionsInput {
|
|
|
305
295
|
|
|
306
296
|
/**
|
|
307
297
|
* Lifecycle status of a Dream.
|
|
298
|
+
*
|
|
299
|
+
* - `pending` - The dream is waiting to start and hasn't read its inputs yet.
|
|
300
|
+
*
|
|
301
|
+
* `outputs` is empty and every `usage` count is zero.
|
|
302
|
+
*
|
|
303
|
+
* - `running` - The dream is reading its inputs and writing its result.
|
|
304
|
+
*
|
|
305
|
+
* `usage` updates while the dream has this status.
|
|
306
|
+
*
|
|
307
|
+
* - `completed` - The dream finished and its output memory store holds the
|
|
308
|
+
* complete result.
|
|
309
|
+
* - `failed` - The dream stopped with an error, which `error` describes.
|
|
310
|
+
*
|
|
311
|
+
* If `outputs` references a memory store, that memory store keeps what the dream
|
|
312
|
+
* wrote before it stopped.
|
|
313
|
+
*
|
|
314
|
+
* - `canceled` - The caller canceled the dream before it completed.
|
|
308
315
|
*/
|
|
309
316
|
export type BetaDreamStatus = 'pending' | 'running' | 'completed' | 'failed' | 'canceled';
|
|
310
317
|
|
|
@@ -333,15 +340,6 @@ export interface BetaDreamUsage {
|
|
|
333
340
|
output_tokens: number;
|
|
334
341
|
}
|
|
335
342
|
|
|
336
|
-
/**
|
|
337
|
-
* The `output_behavior.memory_store_id` target is still held by a prior
|
|
338
|
-
* `{type: "update_existing"}` dream — one that is `pending` or `running`, or was
|
|
339
|
-
* canceled with its final writes still landing. Rarely the named dream has just
|
|
340
|
-
* finished (`completed`/`failed`) and its execution is still closing; an immediate
|
|
341
|
-
* retry then almost always succeeds. The message names the holding dream when the
|
|
342
|
-
* server can identify it (rarely omitted); poll it to a terminal state or cancel
|
|
343
|
-
* it, then retry. Carried with `x-should-retry: false`.
|
|
344
|
-
*/
|
|
345
343
|
export type BetaDreamingError =
|
|
346
344
|
| BetaAPI.BetaInvalidRequestError
|
|
347
345
|
| BetaAPI.BetaAuthenticationError
|
|
@@ -354,11 +352,6 @@ export type BetaDreamingError =
|
|
|
354
352
|
| BetaAPI.BetaOverloadedError
|
|
355
353
|
| BetaTargetStoreHeldError;
|
|
356
354
|
|
|
357
|
-
/**
|
|
358
|
-
* The default destination: the job creates a new output memory store as a clone of
|
|
359
|
-
* the memory_store input and writes the consolidated memories into it. The input
|
|
360
|
-
* store is never mutated.
|
|
361
|
-
*/
|
|
362
355
|
export type BetaOutputBehavior = BetaOutputBehaviorCreateNew | BetaOutputBehaviorUpdateExisting;
|
|
363
356
|
|
|
364
357
|
/**
|
|
@@ -407,7 +400,7 @@ export interface DreamCreateParams {
|
|
|
407
400
|
inputs: Array<BetaDreamInput>;
|
|
408
401
|
|
|
409
402
|
/**
|
|
410
|
-
* Body param
|
|
403
|
+
* Body param
|
|
411
404
|
*/
|
|
412
405
|
model: string | BetaDreamModelConfigParam;
|
|
413
406
|
|
|
@@ -417,9 +410,7 @@ export interface DreamCreateParams {
|
|
|
417
410
|
instructions?: string | null;
|
|
418
411
|
|
|
419
412
|
/**
|
|
420
|
-
* Body param
|
|
421
|
-
* as a clone of the memory_store input and writes the consolidated memories into
|
|
422
|
-
* it. The input store is never mutated.
|
|
413
|
+
* Body param
|
|
423
414
|
*/
|
|
424
415
|
output_behavior?: BetaOutputBehavior;
|
|
425
416
|
|
|
@@ -335,6 +335,7 @@ export {
|
|
|
335
335
|
type BetaCompact20260112Edit,
|
|
336
336
|
type BetaCompactionBlock,
|
|
337
337
|
type BetaCompactionBlockParam,
|
|
338
|
+
type BetaCompactionConfig,
|
|
338
339
|
type BetaCompactionContentBlockDelta,
|
|
339
340
|
type BetaCompactionIterationUsage,
|
|
340
341
|
type BetaComputerCursorPositionConfig,
|
|
@@ -393,6 +394,7 @@ export {
|
|
|
393
394
|
type BetaInputJSONDelta,
|
|
394
395
|
type BetaInputTokensClearAtLeast,
|
|
395
396
|
type BetaInputTokensTrigger,
|
|
397
|
+
type BetaInputTransformation,
|
|
396
398
|
type BetaIterationsUsage,
|
|
397
399
|
type BetaJSONOutputFormat,
|
|
398
400
|
type BetaMCPToolConfig,
|
|
@@ -444,6 +446,7 @@ export {
|
|
|
444
446
|
type BetaSignatureDelta,
|
|
445
447
|
type BetaSkillParams,
|
|
446
448
|
type BetaStopReason,
|
|
449
|
+
type BetaSummarizeCompaction,
|
|
447
450
|
type BetaSystemMessageOutputConfig,
|
|
448
451
|
type BetaTextBlock,
|
|
449
452
|
type BetaTextBlockParam,
|
|
@@ -469,6 +472,7 @@ export {
|
|
|
469
472
|
type BetaThinkingConfigParam,
|
|
470
473
|
type BetaThinkingDelta,
|
|
471
474
|
type BetaThinkingDroppedInputTransformation,
|
|
475
|
+
type BetaThinkingMismatchAllowedInputTransformation,
|
|
472
476
|
type BetaThinkingPrefixMismatchBehavior,
|
|
473
477
|
type BetaThinkingTurns,
|
|
474
478
|
type BetaTokenTaskBudget,
|
|
@@ -521,6 +525,12 @@ export {
|
|
|
521
525
|
type BetaWebFetchToolResultErrorBlock,
|
|
522
526
|
type BetaWebFetchToolResultErrorBlockParam,
|
|
523
527
|
type BetaWebFetchToolResultErrorCode,
|
|
528
|
+
type BetaWebFetchURLSourceAll,
|
|
529
|
+
type BetaWebFetchURLSourceExcept,
|
|
530
|
+
type BetaWebFetchURLSourceNone,
|
|
531
|
+
type BetaWebFetchURLSourceOnly,
|
|
532
|
+
type BetaWebFetchURLSourceToolReference,
|
|
533
|
+
type BetaWebFetchURLSources,
|
|
524
534
|
type BetaWebSearchResultBlock,
|
|
525
535
|
type BetaWebSearchResultBlockParam,
|
|
526
536
|
type BetaWebSearchTool20250305,
|
|
@@ -543,6 +553,7 @@ export {
|
|
|
543
553
|
export {
|
|
544
554
|
Models,
|
|
545
555
|
type BetaCapabilitySupport,
|
|
556
|
+
type BetaCompactionCapability,
|
|
546
557
|
type BetaContextManagementCapability,
|
|
547
558
|
type BetaEffortCapability,
|
|
548
559
|
type BetaModelCapabilities,
|
|
@@ -346,6 +346,12 @@ export interface BetaManagedAgentsMemoryPrefix {
|
|
|
346
346
|
* `content`. When omitted, the default is endpoint-specific: retrieve operations
|
|
347
347
|
* default to `full`; list, create, and update operations default to `basic`.
|
|
348
348
|
* Listing with `view=full` caps `limit` at 20.
|
|
349
|
+
*
|
|
350
|
+
* - `basic` - Return the object with `content` set to `null`. The
|
|
351
|
+
* `content_size_bytes` and `content_sha256` fields remain populated, so sync
|
|
352
|
+
* clients can diff without fetching content.
|
|
353
|
+
* - `full` - Return the object with `content` populated. On list endpoints,
|
|
354
|
+
* `view=full` caps `limit` at 20.
|
|
349
355
|
*/
|
|
350
356
|
export type BetaManagedAgentsMemoryView = 'basic' | 'full';
|
|
351
357
|
|
|
@@ -236,6 +236,13 @@ export interface BetaManagedAgentsMemoryVersion {
|
|
|
236
236
|
/**
|
|
237
237
|
* The kind of mutation a `memory_version` records. Every non-no-op mutation to a
|
|
238
238
|
* memory appends exactly one version row with one of these values.
|
|
239
|
+
*
|
|
240
|
+
* - `created` - The memory was created. The first version in any memory's lineage.
|
|
241
|
+
* - `modified` - The memory's `content`, `path`, or both were changed via update.
|
|
242
|
+
* Writes the agent makes through the filesystem mount also appear as `modified`.
|
|
243
|
+
* - `deleted` - The memory was deleted. The `content`, `content_size_bytes`, and
|
|
244
|
+
* `content_sha256` fields are `null` on this version. The preceding version,
|
|
245
|
+
* while it is retained, records the deleted content's size and hash.
|
|
239
246
|
*/
|
|
240
247
|
export type BetaManagedAgentsMemoryVersionOperation = 'created' | 'modified' | 'deleted';
|
|
241
248
|
|
|
@@ -589,6 +589,18 @@ export namespace BatchCreateParams {
|
|
|
589
589
|
*/
|
|
590
590
|
cache_control?: BetaMessagesAPI.BetaCacheControlEphemeral | null;
|
|
591
591
|
|
|
592
|
+
/**
|
|
593
|
+
* Compact the whole conversation and return a signed `compaction` block, alone,
|
|
594
|
+
* that a later request sends back first in `messages`, in place of the messages it
|
|
595
|
+
* summarizes. There is no trigger and no pause flag: sending the parameter
|
|
596
|
+
* compacts, and nothing is sampled after the block.
|
|
597
|
+
*
|
|
598
|
+
* The summarization prompt is the server's own unless `instructions` are given,
|
|
599
|
+
* which then replace it for this request; a value that is empty or only whitespace
|
|
600
|
+
* counts as absent.
|
|
601
|
+
*/
|
|
602
|
+
compaction?: BetaMessagesAPI.BetaCompactionConfig | null;
|
|
603
|
+
|
|
592
604
|
/**
|
|
593
605
|
* Container identifier for reuse across requests.
|
|
594
606
|
*/
|
|
@@ -718,7 +730,7 @@ export namespace BatchCreateParams {
|
|
|
718
730
|
|
|
719
731
|
/**
|
|
720
732
|
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support
|
|
721
|
-
* setting temperature. A value of 1.0
|
|
733
|
+
* setting temperature. A value of 1.0 will be accepted for backwards
|
|
722
734
|
* compatibility, all other values will be rejected with a 400 error.
|
|
723
735
|
*/
|
|
724
736
|
temperature?: number;
|