@anthropic-ai/sdk 0.63.1 → 0.65.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 +33 -0
- package/README.md +14 -14
- package/bin/cli +5 -12
- package/helpers/beta/memory.d.mts +11 -0
- package/helpers/beta/memory.d.mts.map +1 -0
- package/helpers/beta/memory.d.ts +11 -0
- package/helpers/beta/memory.d.ts.map +1 -0
- package/helpers/beta/memory.js +18 -0
- package/helpers/beta/memory.js.map +1 -0
- package/helpers/beta/memory.mjs +15 -0
- package/helpers/beta/memory.mjs.map +1 -0
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +1 -0
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +1 -0
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/tools/BetaRunnableTool.d.mts +3 -3
- package/lib/tools/BetaRunnableTool.d.mts.map +1 -1
- package/lib/tools/BetaRunnableTool.d.ts +3 -3
- package/lib/tools/BetaRunnableTool.d.ts.map +1 -1
- package/lib/tools/BetaToolRunner.d.mts +3 -1
- package/lib/tools/BetaToolRunner.d.mts.map +1 -1
- package/lib/tools/BetaToolRunner.d.ts +3 -1
- package/lib/tools/BetaToolRunner.d.ts.map +1 -1
- package/lib/tools/BetaToolRunner.js +11 -5
- package/lib/tools/BetaToolRunner.js.map +1 -1
- package/lib/tools/BetaToolRunner.mjs +11 -5
- package/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/beta.d.mts +2 -2
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +2 -2
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/index.d.mts +1 -1
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -1
- 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/messages/batches.d.mts +1 -1
- package/resources/beta/messages/batches.d.ts +1 -1
- package/resources/beta/messages/batches.js +1 -1
- package/resources/beta/messages/batches.mjs +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 +212 -9
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +212 -9
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +2 -2
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +3 -3
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/messages/batches.d.mts +1 -1
- package/resources/messages/batches.d.ts +1 -1
- package/resources/messages/batches.js +1 -1
- package/resources/messages/batches.mjs +1 -1
- package/resources/messages/messages.d.mts +3 -3
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +3 -3
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs.map +1 -1
- package/src/helpers/beta/memory.ts +28 -0
- package/src/lib/BetaMessageStream.ts +1 -0
- package/src/lib/tools/BetaRunnableTool.ts +3 -3
- package/src/lib/tools/BetaToolRunner.ts +12 -2
- package/src/resources/beta/beta.ts +34 -0
- package/src/resources/beta/index.ts +17 -0
- package/src/resources/beta/messages/batches.ts +1 -1
- package/src/resources/beta/messages/index.ts +17 -0
- package/src/resources/beta/messages/messages.ts +295 -8
- package/src/resources/messages/batches.ts +1 -1
- package/src/resources/messages/messages.ts +11 -2
- package/src/version.ts +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,8 @@ import { Anthropic } from '../..';
|
|
|
3
3
|
import { AnthropicError } from '../../core/error';
|
|
4
4
|
import { BetaMessage, BetaMessageParam, BetaToolUnion, MessageCreateParams } from '../../resources/beta';
|
|
5
5
|
import { BetaMessageStream } from '../BetaMessageStream';
|
|
6
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
7
|
+
import { buildHeaders } from '../../internal/headers';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Just Promise.withResolvers(), which is not available in all environments.
|
|
@@ -34,6 +36,7 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
34
36
|
#mutated = false;
|
|
35
37
|
/** Current state containing the request parameters */
|
|
36
38
|
#state: { params: BetaToolRunnerParams };
|
|
39
|
+
#options: BetaToolRunnerRequestOptions;
|
|
37
40
|
/** Promise for the last message received from the assistant */
|
|
38
41
|
#message?: Promise<BetaMessage> | undefined;
|
|
39
42
|
/** Cached tool response to avoid redundant executions */
|
|
@@ -50,6 +53,7 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
50
53
|
constructor(
|
|
51
54
|
private client: Anthropic,
|
|
52
55
|
params: BetaToolRunnerParams,
|
|
56
|
+
options?: BetaToolRunnerRequestOptions,
|
|
53
57
|
) {
|
|
54
58
|
this.#state = {
|
|
55
59
|
params: {
|
|
@@ -61,6 +65,10 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
61
65
|
},
|
|
62
66
|
};
|
|
63
67
|
|
|
68
|
+
this.#options = {
|
|
69
|
+
...options,
|
|
70
|
+
headers: buildHeaders([{ 'x-stainless-helper': 'BetaToolRunner' }, options?.headers]),
|
|
71
|
+
};
|
|
64
72
|
this.#completion = promiseWithResolvers();
|
|
65
73
|
}
|
|
66
74
|
|
|
@@ -95,11 +103,11 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
95
103
|
|
|
96
104
|
const { max_iterations, ...params } = this.#state.params;
|
|
97
105
|
if (params.stream) {
|
|
98
|
-
stream = this.client.beta.messages.stream({ ...params });
|
|
106
|
+
stream = this.client.beta.messages.stream({ ...params }, this.#options);
|
|
99
107
|
this.#message = stream.finalMessage();
|
|
100
108
|
yield stream as any;
|
|
101
109
|
} else {
|
|
102
|
-
this.#message = this.client.beta.messages.create({ ...params, stream: false });
|
|
110
|
+
this.#message = this.client.beta.messages.create({ ...params, stream: false }, this.#options);
|
|
103
111
|
yield this.#message as any;
|
|
104
112
|
}
|
|
105
113
|
|
|
@@ -372,3 +380,5 @@ export type BetaToolRunnerParams = Simplify<
|
|
|
372
380
|
max_iterations?: number;
|
|
373
381
|
}
|
|
374
382
|
>;
|
|
383
|
+
|
|
384
|
+
export type BetaToolRunnerRequestOptions = Pick<RequestOptions, 'headers'>;
|
|
@@ -43,6 +43,8 @@ import {
|
|
|
43
43
|
BetaCitationsConfigParam,
|
|
44
44
|
BetaCitationsDelta,
|
|
45
45
|
BetaCitationsWebSearchResultLocation,
|
|
46
|
+
BetaClearToolUses20250919Edit,
|
|
47
|
+
BetaClearToolUses20250919EditResponse,
|
|
46
48
|
BetaCodeExecutionOutputBlock,
|
|
47
49
|
BetaCodeExecutionOutputBlockParam,
|
|
48
50
|
BetaCodeExecutionResultBlock,
|
|
@@ -63,14 +65,27 @@ import {
|
|
|
63
65
|
BetaContentBlockParam,
|
|
64
66
|
BetaContentBlockSource,
|
|
65
67
|
BetaContentBlockSourceContent,
|
|
68
|
+
BetaContextManagementConfig,
|
|
69
|
+
BetaContextManagementResponse,
|
|
70
|
+
BetaCountTokensContextManagementResponse,
|
|
66
71
|
BetaDocumentBlock,
|
|
67
72
|
BetaFileDocumentSource,
|
|
68
73
|
BetaFileImageSource,
|
|
69
74
|
BetaImageBlockParam,
|
|
70
75
|
BetaInputJSONDelta,
|
|
76
|
+
BetaInputTokensClearAtLeast,
|
|
77
|
+
BetaInputTokensTrigger,
|
|
71
78
|
BetaMCPToolResultBlock,
|
|
72
79
|
BetaMCPToolUseBlock,
|
|
73
80
|
BetaMCPToolUseBlockParam,
|
|
81
|
+
BetaMemoryTool20250818,
|
|
82
|
+
BetaMemoryTool20250818Command,
|
|
83
|
+
BetaMemoryTool20250818CreateCommand,
|
|
84
|
+
BetaMemoryTool20250818DeleteCommand,
|
|
85
|
+
BetaMemoryTool20250818InsertCommand,
|
|
86
|
+
BetaMemoryTool20250818RenameCommand,
|
|
87
|
+
BetaMemoryTool20250818StrReplaceCommand,
|
|
88
|
+
BetaMemoryTool20250818ViewCommand,
|
|
74
89
|
BetaMessage,
|
|
75
90
|
BetaMessageDeltaUsage,
|
|
76
91
|
BetaMessageParam,
|
|
@@ -137,6 +152,8 @@ import {
|
|
|
137
152
|
BetaToolUnion,
|
|
138
153
|
BetaToolUseBlock,
|
|
139
154
|
BetaToolUseBlockParam,
|
|
155
|
+
BetaToolUsesKeep,
|
|
156
|
+
BetaToolUsesTrigger,
|
|
140
157
|
BetaURLImageSource,
|
|
141
158
|
BetaURLPDFSource,
|
|
142
159
|
BetaUsage,
|
|
@@ -317,6 +334,8 @@ export declare namespace Beta {
|
|
|
317
334
|
type BetaCitationsConfigParam as BetaCitationsConfigParam,
|
|
318
335
|
type BetaCitationsDelta as BetaCitationsDelta,
|
|
319
336
|
type BetaCitationsWebSearchResultLocation as BetaCitationsWebSearchResultLocation,
|
|
337
|
+
type BetaClearToolUses20250919Edit as BetaClearToolUses20250919Edit,
|
|
338
|
+
type BetaClearToolUses20250919EditResponse as BetaClearToolUses20250919EditResponse,
|
|
320
339
|
type BetaCodeExecutionOutputBlock as BetaCodeExecutionOutputBlock,
|
|
321
340
|
type BetaCodeExecutionOutputBlockParam as BetaCodeExecutionOutputBlockParam,
|
|
322
341
|
type BetaCodeExecutionResultBlock as BetaCodeExecutionResultBlock,
|
|
@@ -337,14 +356,27 @@ export declare namespace Beta {
|
|
|
337
356
|
type BetaContentBlockParam as BetaContentBlockParam,
|
|
338
357
|
type BetaContentBlockSource as BetaContentBlockSource,
|
|
339
358
|
type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
|
|
359
|
+
type BetaContextManagementConfig as BetaContextManagementConfig,
|
|
360
|
+
type BetaContextManagementResponse as BetaContextManagementResponse,
|
|
361
|
+
type BetaCountTokensContextManagementResponse as BetaCountTokensContextManagementResponse,
|
|
340
362
|
type BetaDocumentBlock as BetaDocumentBlock,
|
|
341
363
|
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
342
364
|
type BetaFileImageSource as BetaFileImageSource,
|
|
343
365
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
344
366
|
type BetaInputJSONDelta as BetaInputJSONDelta,
|
|
367
|
+
type BetaInputTokensClearAtLeast as BetaInputTokensClearAtLeast,
|
|
368
|
+
type BetaInputTokensTrigger as BetaInputTokensTrigger,
|
|
345
369
|
type BetaMCPToolResultBlock as BetaMCPToolResultBlock,
|
|
346
370
|
type BetaMCPToolUseBlock as BetaMCPToolUseBlock,
|
|
347
371
|
type BetaMCPToolUseBlockParam as BetaMCPToolUseBlockParam,
|
|
372
|
+
type BetaMemoryTool20250818 as BetaMemoryTool20250818,
|
|
373
|
+
type BetaMemoryTool20250818Command as BetaMemoryTool20250818Command,
|
|
374
|
+
type BetaMemoryTool20250818CreateCommand as BetaMemoryTool20250818CreateCommand,
|
|
375
|
+
type BetaMemoryTool20250818DeleteCommand as BetaMemoryTool20250818DeleteCommand,
|
|
376
|
+
type BetaMemoryTool20250818InsertCommand as BetaMemoryTool20250818InsertCommand,
|
|
377
|
+
type BetaMemoryTool20250818RenameCommand as BetaMemoryTool20250818RenameCommand,
|
|
378
|
+
type BetaMemoryTool20250818StrReplaceCommand as BetaMemoryTool20250818StrReplaceCommand,
|
|
379
|
+
type BetaMemoryTool20250818ViewCommand as BetaMemoryTool20250818ViewCommand,
|
|
348
380
|
type BetaMessage as BetaMessage,
|
|
349
381
|
type BetaMessageDeltaUsage as BetaMessageDeltaUsage,
|
|
350
382
|
type BetaMessageParam as BetaMessageParam,
|
|
@@ -411,6 +443,8 @@ export declare namespace Beta {
|
|
|
411
443
|
type BetaToolUnion as BetaToolUnion,
|
|
412
444
|
type BetaToolUseBlock as BetaToolUseBlock,
|
|
413
445
|
type BetaToolUseBlockParam as BetaToolUseBlockParam,
|
|
446
|
+
type BetaToolUsesKeep as BetaToolUsesKeep,
|
|
447
|
+
type BetaToolUsesTrigger as BetaToolUsesTrigger,
|
|
414
448
|
type BetaURLImageSource as BetaURLImageSource,
|
|
415
449
|
type BetaURLPDFSource as BetaURLPDFSource,
|
|
416
450
|
type BetaUsage as BetaUsage,
|
|
@@ -53,6 +53,8 @@ export {
|
|
|
53
53
|
type BetaCitationsConfigParam,
|
|
54
54
|
type BetaCitationsDelta,
|
|
55
55
|
type BetaCitationsWebSearchResultLocation,
|
|
56
|
+
type BetaClearToolUses20250919Edit,
|
|
57
|
+
type BetaClearToolUses20250919EditResponse,
|
|
56
58
|
type BetaCodeExecutionOutputBlock,
|
|
57
59
|
type BetaCodeExecutionOutputBlockParam,
|
|
58
60
|
type BetaCodeExecutionResultBlock,
|
|
@@ -73,14 +75,27 @@ export {
|
|
|
73
75
|
type BetaContentBlockParam,
|
|
74
76
|
type BetaContentBlockSource,
|
|
75
77
|
type BetaContentBlockSourceContent,
|
|
78
|
+
type BetaContextManagementConfig,
|
|
79
|
+
type BetaContextManagementResponse,
|
|
80
|
+
type BetaCountTokensContextManagementResponse,
|
|
76
81
|
type BetaDocumentBlock,
|
|
77
82
|
type BetaFileDocumentSource,
|
|
78
83
|
type BetaFileImageSource,
|
|
79
84
|
type BetaImageBlockParam,
|
|
80
85
|
type BetaInputJSONDelta,
|
|
86
|
+
type BetaInputTokensClearAtLeast,
|
|
87
|
+
type BetaInputTokensTrigger,
|
|
81
88
|
type BetaMCPToolResultBlock,
|
|
82
89
|
type BetaMCPToolUseBlock,
|
|
83
90
|
type BetaMCPToolUseBlockParam,
|
|
91
|
+
type BetaMemoryTool20250818,
|
|
92
|
+
type BetaMemoryTool20250818Command,
|
|
93
|
+
type BetaMemoryTool20250818CreateCommand,
|
|
94
|
+
type BetaMemoryTool20250818DeleteCommand,
|
|
95
|
+
type BetaMemoryTool20250818InsertCommand,
|
|
96
|
+
type BetaMemoryTool20250818RenameCommand,
|
|
97
|
+
type BetaMemoryTool20250818StrReplaceCommand,
|
|
98
|
+
type BetaMemoryTool20250818ViewCommand,
|
|
84
99
|
type BetaMessage,
|
|
85
100
|
type BetaMessageDeltaUsage,
|
|
86
101
|
type BetaMessageParam,
|
|
@@ -147,6 +162,8 @@ export {
|
|
|
147
162
|
type BetaToolUnion,
|
|
148
163
|
type BetaToolUseBlock,
|
|
149
164
|
type BetaToolUseBlockParam,
|
|
165
|
+
type BetaToolUsesKeep,
|
|
166
|
+
type BetaToolUsesTrigger,
|
|
150
167
|
type BetaURLImageSource,
|
|
151
168
|
type BetaURLPDFSource,
|
|
152
169
|
type BetaUsage,
|
|
@@ -46,6 +46,8 @@ export {
|
|
|
46
46
|
type BetaCitationsConfigParam,
|
|
47
47
|
type BetaCitationsDelta,
|
|
48
48
|
type BetaCitationsWebSearchResultLocation,
|
|
49
|
+
type BetaClearToolUses20250919Edit,
|
|
50
|
+
type BetaClearToolUses20250919EditResponse,
|
|
49
51
|
type BetaCodeExecutionOutputBlock,
|
|
50
52
|
type BetaCodeExecutionOutputBlockParam,
|
|
51
53
|
type BetaCodeExecutionResultBlock,
|
|
@@ -66,14 +68,27 @@ export {
|
|
|
66
68
|
type BetaContentBlockParam,
|
|
67
69
|
type BetaContentBlockSource,
|
|
68
70
|
type BetaContentBlockSourceContent,
|
|
71
|
+
type BetaContextManagementConfig,
|
|
72
|
+
type BetaContextManagementResponse,
|
|
73
|
+
type BetaCountTokensContextManagementResponse,
|
|
69
74
|
type BetaDocumentBlock,
|
|
70
75
|
type BetaFileDocumentSource,
|
|
71
76
|
type BetaFileImageSource,
|
|
72
77
|
type BetaImageBlockParam,
|
|
73
78
|
type BetaInputJSONDelta,
|
|
79
|
+
type BetaInputTokensClearAtLeast,
|
|
80
|
+
type BetaInputTokensTrigger,
|
|
74
81
|
type BetaMCPToolResultBlock,
|
|
75
82
|
type BetaMCPToolUseBlock,
|
|
76
83
|
type BetaMCPToolUseBlockParam,
|
|
84
|
+
type BetaMemoryTool20250818,
|
|
85
|
+
type BetaMemoryTool20250818Command,
|
|
86
|
+
type BetaMemoryTool20250818CreateCommand,
|
|
87
|
+
type BetaMemoryTool20250818DeleteCommand,
|
|
88
|
+
type BetaMemoryTool20250818InsertCommand,
|
|
89
|
+
type BetaMemoryTool20250818RenameCommand,
|
|
90
|
+
type BetaMemoryTool20250818StrReplaceCommand,
|
|
91
|
+
type BetaMemoryTool20250818ViewCommand,
|
|
77
92
|
type BetaMessage,
|
|
78
93
|
type BetaMessageDeltaUsage,
|
|
79
94
|
type BetaMessageParam,
|
|
@@ -140,6 +155,8 @@ export {
|
|
|
140
155
|
type BetaToolUnion,
|
|
141
156
|
type BetaToolUseBlock,
|
|
142
157
|
type BetaToolUseBlockParam,
|
|
158
|
+
type BetaToolUsesKeep,
|
|
159
|
+
type BetaToolUsesTrigger,
|
|
143
160
|
type BetaURLImageSource,
|
|
144
161
|
type BetaURLPDFSource,
|
|
145
162
|
type BetaUsage,
|
|
@@ -31,7 +31,11 @@ import { RequestOptions } from '../../../internal/request-options';
|
|
|
31
31
|
import type { Model } from '../../messages/messages';
|
|
32
32
|
import { BetaMessageStream } from '../../../lib/BetaMessageStream';
|
|
33
33
|
import { MODEL_NONSTREAMING_TOKENS } from '../../../internal/constants';
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
BetaToolRunner,
|
|
36
|
+
BetaToolRunnerParams,
|
|
37
|
+
BetaToolRunnerRequestOptions,
|
|
38
|
+
} from '../../../lib/tools/BetaToolRunner';
|
|
35
39
|
import { Anthropic } from '../../../client';
|
|
36
40
|
|
|
37
41
|
const DEPRECATED_MODELS: {
|
|
@@ -67,7 +71,7 @@ export class Messages extends APIResource {
|
|
|
67
71
|
* const betaMessage = await client.beta.messages.create({
|
|
68
72
|
* max_tokens: 1024,
|
|
69
73
|
* messages: [{ content: 'Hello, world', role: 'user' }],
|
|
70
|
-
* model: 'claude-sonnet-4-
|
|
74
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
71
75
|
* });
|
|
72
76
|
* ```
|
|
73
77
|
*/
|
|
@@ -151,11 +155,17 @@ export class Messages extends APIResource {
|
|
|
151
155
|
});
|
|
152
156
|
}
|
|
153
157
|
|
|
154
|
-
toolRunner(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
toolRunner(
|
|
159
|
+
body: BetaToolRunnerParams & { stream?: false },
|
|
160
|
+
options?: BetaToolRunnerRequestOptions,
|
|
161
|
+
): BetaToolRunner<false>;
|
|
162
|
+
toolRunner(
|
|
163
|
+
body: BetaToolRunnerParams & { stream: true },
|
|
164
|
+
options?: BetaToolRunnerRequestOptions,
|
|
165
|
+
): BetaToolRunner<true>;
|
|
166
|
+
toolRunner(body: BetaToolRunnerParams, options?: BetaToolRunnerRequestOptions): BetaToolRunner<boolean>;
|
|
167
|
+
toolRunner(body: BetaToolRunnerParams, options?: BetaToolRunnerRequestOptions): BetaToolRunner<boolean> {
|
|
168
|
+
return new BetaToolRunner(this._client as Anthropic, body, options);
|
|
159
169
|
}
|
|
160
170
|
}
|
|
161
171
|
|
|
@@ -449,6 +459,56 @@ export interface BetaCitationsWebSearchResultLocation {
|
|
|
449
459
|
url: string;
|
|
450
460
|
}
|
|
451
461
|
|
|
462
|
+
export interface BetaClearToolUses20250919Edit {
|
|
463
|
+
type: 'clear_tool_uses_20250919';
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Minimum number of tokens that must be cleared when triggered. Context will only
|
|
467
|
+
* be modified if at least this many tokens can be removed.
|
|
468
|
+
*/
|
|
469
|
+
clear_at_least?: BetaInputTokensClearAtLeast | null;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
|
|
473
|
+
*/
|
|
474
|
+
clear_tool_inputs?: boolean | Array<string> | null;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Tool names whose uses are preserved from clearing
|
|
478
|
+
*/
|
|
479
|
+
exclude_tools?: Array<string> | null;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Number of tool uses to retain in the conversation
|
|
483
|
+
*/
|
|
484
|
+
keep?: BetaToolUsesKeep;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Condition that triggers the context management strategy
|
|
488
|
+
*/
|
|
489
|
+
trigger?: BetaInputTokensTrigger | BetaToolUsesTrigger;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Results for clear_tool_uses_20250919 edit.
|
|
494
|
+
*/
|
|
495
|
+
export interface BetaClearToolUses20250919EditResponse {
|
|
496
|
+
/**
|
|
497
|
+
* Number of input tokens cleared by this edit.
|
|
498
|
+
*/
|
|
499
|
+
cleared_input_tokens: number;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Number of tool uses that were cleared.
|
|
503
|
+
*/
|
|
504
|
+
cleared_tool_uses: number;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* The type of context management edit applied.
|
|
508
|
+
*/
|
|
509
|
+
type: 'clear_tool_uses_20250919';
|
|
510
|
+
}
|
|
511
|
+
|
|
452
512
|
export interface BetaCodeExecutionOutputBlock {
|
|
453
513
|
file_id: string;
|
|
454
514
|
|
|
@@ -652,6 +712,33 @@ export interface BetaContentBlockSource {
|
|
|
652
712
|
|
|
653
713
|
export type BetaContentBlockSourceContent = BetaTextBlockParam | BetaImageBlockParam;
|
|
654
714
|
|
|
715
|
+
/**
|
|
716
|
+
* Configuration for context management operations.
|
|
717
|
+
*/
|
|
718
|
+
export interface BetaContextManagementConfig {
|
|
719
|
+
/**
|
|
720
|
+
* List of context management edits to apply
|
|
721
|
+
*/
|
|
722
|
+
edits?: Array<BetaClearToolUses20250919Edit>;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Information about context management operations applied during the request.
|
|
727
|
+
*/
|
|
728
|
+
export interface BetaContextManagementResponse {
|
|
729
|
+
/**
|
|
730
|
+
* List of context management edits that were applied.
|
|
731
|
+
*/
|
|
732
|
+
applied_edits: Array<BetaClearToolUses20250919EditResponse>;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
export interface BetaCountTokensContextManagementResponse {
|
|
736
|
+
/**
|
|
737
|
+
* The original token count before context management was applied
|
|
738
|
+
*/
|
|
739
|
+
original_input_tokens: number;
|
|
740
|
+
}
|
|
741
|
+
|
|
655
742
|
export interface BetaDocumentBlock {
|
|
656
743
|
/**
|
|
657
744
|
* Citation configuration for the document
|
|
@@ -697,6 +784,18 @@ export interface BetaInputJSONDelta {
|
|
|
697
784
|
type: 'input_json_delta';
|
|
698
785
|
}
|
|
699
786
|
|
|
787
|
+
export interface BetaInputTokensClearAtLeast {
|
|
788
|
+
type: 'input_tokens';
|
|
789
|
+
|
|
790
|
+
value: number;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
export interface BetaInputTokensTrigger {
|
|
794
|
+
type: 'input_tokens';
|
|
795
|
+
|
|
796
|
+
value: number;
|
|
797
|
+
}
|
|
798
|
+
|
|
700
799
|
export interface BetaMCPToolResultBlock {
|
|
701
800
|
content: string | Array<BetaTextBlock>;
|
|
702
801
|
|
|
@@ -745,6 +844,137 @@ export interface BetaMCPToolUseBlockParam {
|
|
|
745
844
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
746
845
|
}
|
|
747
846
|
|
|
847
|
+
export interface BetaMemoryTool20250818 {
|
|
848
|
+
/**
|
|
849
|
+
* Name of the tool.
|
|
850
|
+
*
|
|
851
|
+
* This is how the tool will be called by the model and in `tool_use` blocks.
|
|
852
|
+
*/
|
|
853
|
+
name: 'memory';
|
|
854
|
+
|
|
855
|
+
type: 'memory_20250818';
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Create a cache control breakpoint at this content block.
|
|
859
|
+
*/
|
|
860
|
+
cache_control?: BetaCacheControlEphemeral | null;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
export type BetaMemoryTool20250818Command =
|
|
864
|
+
| BetaMemoryTool20250818ViewCommand
|
|
865
|
+
| BetaMemoryTool20250818CreateCommand
|
|
866
|
+
| BetaMemoryTool20250818StrReplaceCommand
|
|
867
|
+
| BetaMemoryTool20250818InsertCommand
|
|
868
|
+
| BetaMemoryTool20250818DeleteCommand
|
|
869
|
+
| BetaMemoryTool20250818RenameCommand;
|
|
870
|
+
|
|
871
|
+
export interface BetaMemoryTool20250818CreateCommand {
|
|
872
|
+
/**
|
|
873
|
+
* Command type identifier
|
|
874
|
+
*/
|
|
875
|
+
command: 'create';
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Content to write to the file
|
|
879
|
+
*/
|
|
880
|
+
file_text: string;
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Path where the file should be created
|
|
884
|
+
*/
|
|
885
|
+
path: string;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
export interface BetaMemoryTool20250818DeleteCommand {
|
|
889
|
+
/**
|
|
890
|
+
* Command type identifier
|
|
891
|
+
*/
|
|
892
|
+
command: 'delete';
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* Path to the file or directory to delete
|
|
896
|
+
*/
|
|
897
|
+
path: string;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
export interface BetaMemoryTool20250818InsertCommand {
|
|
901
|
+
/**
|
|
902
|
+
* Command type identifier
|
|
903
|
+
*/
|
|
904
|
+
command: 'insert';
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Line number where text should be inserted
|
|
908
|
+
*/
|
|
909
|
+
insert_line: number;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Text to insert at the specified line
|
|
913
|
+
*/
|
|
914
|
+
insert_text: string;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Path to the file where text should be inserted
|
|
918
|
+
*/
|
|
919
|
+
path: string;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
export interface BetaMemoryTool20250818RenameCommand {
|
|
923
|
+
/**
|
|
924
|
+
* Command type identifier
|
|
925
|
+
*/
|
|
926
|
+
command: 'rename';
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* New path for the file or directory
|
|
930
|
+
*/
|
|
931
|
+
new_path: string;
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Current path of the file or directory
|
|
935
|
+
*/
|
|
936
|
+
old_path: string;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
export interface BetaMemoryTool20250818StrReplaceCommand {
|
|
940
|
+
/**
|
|
941
|
+
* Command type identifier
|
|
942
|
+
*/
|
|
943
|
+
command: 'str_replace';
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Text to replace with
|
|
947
|
+
*/
|
|
948
|
+
new_str: string;
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Text to search for and replace
|
|
952
|
+
*/
|
|
953
|
+
old_str: string;
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Path to the file where text should be replaced
|
|
957
|
+
*/
|
|
958
|
+
path: string;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
export interface BetaMemoryTool20250818ViewCommand {
|
|
962
|
+
/**
|
|
963
|
+
* Command type identifier
|
|
964
|
+
*/
|
|
965
|
+
command: 'view';
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Path to directory or file to view
|
|
969
|
+
*/
|
|
970
|
+
path: string;
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Optional line range for viewing specific lines
|
|
974
|
+
*/
|
|
975
|
+
view_range?: Array<number>;
|
|
976
|
+
}
|
|
977
|
+
|
|
748
978
|
export interface BetaMessage {
|
|
749
979
|
/**
|
|
750
980
|
* Unique object identifier.
|
|
@@ -795,6 +1025,11 @@ export interface BetaMessage {
|
|
|
795
1025
|
*/
|
|
796
1026
|
content: Array<BetaContentBlock>;
|
|
797
1027
|
|
|
1028
|
+
/**
|
|
1029
|
+
* Information about context management operations applied during the request.
|
|
1030
|
+
*/
|
|
1031
|
+
context_management: BetaContextManagementResponse | null;
|
|
1032
|
+
|
|
798
1033
|
/**
|
|
799
1034
|
* The model that will complete your prompt.\n\nSee
|
|
800
1035
|
* [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
@@ -897,6 +1132,11 @@ export interface BetaMessageParam {
|
|
|
897
1132
|
}
|
|
898
1133
|
|
|
899
1134
|
export interface BetaMessageTokensCount {
|
|
1135
|
+
/**
|
|
1136
|
+
* Information about context management applied to the message.
|
|
1137
|
+
*/
|
|
1138
|
+
context_management: BetaCountTokensContextManagementResponse | null;
|
|
1139
|
+
|
|
900
1140
|
/**
|
|
901
1141
|
* The total number of tokens across the provided list of messages, system prompt,
|
|
902
1142
|
* and tools.
|
|
@@ -969,6 +1209,11 @@ export interface BetaRawContentBlockStopEvent {
|
|
|
969
1209
|
}
|
|
970
1210
|
|
|
971
1211
|
export interface BetaRawMessageDeltaEvent {
|
|
1212
|
+
/**
|
|
1213
|
+
* Information about context management operations applied during the request.
|
|
1214
|
+
*/
|
|
1215
|
+
context_management: BetaContextManagementResponse | null;
|
|
1216
|
+
|
|
972
1217
|
delta: BetaRawMessageDeltaEvent.Delta;
|
|
973
1218
|
|
|
974
1219
|
type: 'message_delta';
|
|
@@ -1158,7 +1403,8 @@ export type BetaStopReason =
|
|
|
1158
1403
|
| 'stop_sequence'
|
|
1159
1404
|
| 'tool_use'
|
|
1160
1405
|
| 'pause_turn'
|
|
1161
|
-
| 'refusal'
|
|
1406
|
+
| 'refusal'
|
|
1407
|
+
| 'model_context_window_exceeded';
|
|
1162
1408
|
|
|
1163
1409
|
export interface BetaTextBlock {
|
|
1164
1410
|
/**
|
|
@@ -1692,6 +1938,7 @@ export type BetaToolUnion =
|
|
|
1692
1938
|
| BetaCodeExecutionTool20250522
|
|
1693
1939
|
| BetaCodeExecutionTool20250825
|
|
1694
1940
|
| BetaToolComputerUse20241022
|
|
1941
|
+
| BetaMemoryTool20250818
|
|
1695
1942
|
| BetaToolComputerUse20250124
|
|
1696
1943
|
| BetaToolTextEditor20241022
|
|
1697
1944
|
| BetaToolTextEditor20250124
|
|
@@ -1725,6 +1972,18 @@ export interface BetaToolUseBlockParam {
|
|
|
1725
1972
|
cache_control?: BetaCacheControlEphemeral | null;
|
|
1726
1973
|
}
|
|
1727
1974
|
|
|
1975
|
+
export interface BetaToolUsesKeep {
|
|
1976
|
+
type: 'tool_uses';
|
|
1977
|
+
|
|
1978
|
+
value: number;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
export interface BetaToolUsesTrigger {
|
|
1982
|
+
type: 'tool_uses';
|
|
1983
|
+
|
|
1984
|
+
value: number;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1728
1987
|
export interface BetaURLImageSource {
|
|
1729
1988
|
type: 'url';
|
|
1730
1989
|
|
|
@@ -2135,6 +2394,11 @@ export interface MessageCreateParamsBase {
|
|
|
2135
2394
|
*/
|
|
2136
2395
|
container?: string | null;
|
|
2137
2396
|
|
|
2397
|
+
/**
|
|
2398
|
+
* Body param: Configuration for context management operations.
|
|
2399
|
+
*/
|
|
2400
|
+
context_management?: BetaContextManagementConfig | null;
|
|
2401
|
+
|
|
2138
2402
|
/**
|
|
2139
2403
|
* Body param: MCP servers to be utilized in this request
|
|
2140
2404
|
*/
|
|
@@ -2429,6 +2693,11 @@ export interface MessageCountTokensParams {
|
|
|
2429
2693
|
*/
|
|
2430
2694
|
model: MessagesAPI.Model;
|
|
2431
2695
|
|
|
2696
|
+
/**
|
|
2697
|
+
* Body param: Configuration for context management operations.
|
|
2698
|
+
*/
|
|
2699
|
+
context_management?: BetaContextManagementConfig | null;
|
|
2700
|
+
|
|
2432
2701
|
/**
|
|
2433
2702
|
* Body param: MCP servers to be utilized in this request
|
|
2434
2703
|
*/
|
|
@@ -2546,6 +2815,7 @@ export interface MessageCountTokensParams {
|
|
|
2546
2815
|
| BetaCodeExecutionTool20250522
|
|
2547
2816
|
| BetaCodeExecutionTool20250825
|
|
2548
2817
|
| BetaToolComputerUse20241022
|
|
2818
|
+
| BetaMemoryTool20250818
|
|
2549
2819
|
| BetaToolComputerUse20250124
|
|
2550
2820
|
| BetaToolTextEditor20241022
|
|
2551
2821
|
| BetaToolTextEditor20250124
|
|
@@ -2594,6 +2864,8 @@ export declare namespace Messages {
|
|
|
2594
2864
|
type BetaCitationsConfigParam as BetaCitationsConfigParam,
|
|
2595
2865
|
type BetaCitationsDelta as BetaCitationsDelta,
|
|
2596
2866
|
type BetaCitationsWebSearchResultLocation as BetaCitationsWebSearchResultLocation,
|
|
2867
|
+
type BetaClearToolUses20250919Edit as BetaClearToolUses20250919Edit,
|
|
2868
|
+
type BetaClearToolUses20250919EditResponse as BetaClearToolUses20250919EditResponse,
|
|
2597
2869
|
type BetaCodeExecutionOutputBlock as BetaCodeExecutionOutputBlock,
|
|
2598
2870
|
type BetaCodeExecutionOutputBlockParam as BetaCodeExecutionOutputBlockParam,
|
|
2599
2871
|
type BetaCodeExecutionResultBlock as BetaCodeExecutionResultBlock,
|
|
@@ -2614,14 +2886,27 @@ export declare namespace Messages {
|
|
|
2614
2886
|
type BetaContentBlockParam as BetaContentBlockParam,
|
|
2615
2887
|
type BetaContentBlockSource as BetaContentBlockSource,
|
|
2616
2888
|
type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
|
|
2889
|
+
type BetaContextManagementConfig as BetaContextManagementConfig,
|
|
2890
|
+
type BetaContextManagementResponse as BetaContextManagementResponse,
|
|
2891
|
+
type BetaCountTokensContextManagementResponse as BetaCountTokensContextManagementResponse,
|
|
2617
2892
|
type BetaDocumentBlock as BetaDocumentBlock,
|
|
2618
2893
|
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
2619
2894
|
type BetaFileImageSource as BetaFileImageSource,
|
|
2620
2895
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
2621
2896
|
type BetaInputJSONDelta as BetaInputJSONDelta,
|
|
2897
|
+
type BetaInputTokensClearAtLeast as BetaInputTokensClearAtLeast,
|
|
2898
|
+
type BetaInputTokensTrigger as BetaInputTokensTrigger,
|
|
2622
2899
|
type BetaMCPToolResultBlock as BetaMCPToolResultBlock,
|
|
2623
2900
|
type BetaMCPToolUseBlock as BetaMCPToolUseBlock,
|
|
2624
2901
|
type BetaMCPToolUseBlockParam as BetaMCPToolUseBlockParam,
|
|
2902
|
+
type BetaMemoryTool20250818 as BetaMemoryTool20250818,
|
|
2903
|
+
type BetaMemoryTool20250818Command as BetaMemoryTool20250818Command,
|
|
2904
|
+
type BetaMemoryTool20250818CreateCommand as BetaMemoryTool20250818CreateCommand,
|
|
2905
|
+
type BetaMemoryTool20250818DeleteCommand as BetaMemoryTool20250818DeleteCommand,
|
|
2906
|
+
type BetaMemoryTool20250818InsertCommand as BetaMemoryTool20250818InsertCommand,
|
|
2907
|
+
type BetaMemoryTool20250818RenameCommand as BetaMemoryTool20250818RenameCommand,
|
|
2908
|
+
type BetaMemoryTool20250818StrReplaceCommand as BetaMemoryTool20250818StrReplaceCommand,
|
|
2909
|
+
type BetaMemoryTool20250818ViewCommand as BetaMemoryTool20250818ViewCommand,
|
|
2625
2910
|
type BetaMessage as BetaMessage,
|
|
2626
2911
|
type BetaMessageDeltaUsage as BetaMessageDeltaUsage,
|
|
2627
2912
|
type BetaMessageParam as BetaMessageParam,
|
|
@@ -2688,6 +2973,8 @@ export declare namespace Messages {
|
|
|
2688
2973
|
type BetaToolUnion as BetaToolUnion,
|
|
2689
2974
|
type BetaToolUseBlock as BetaToolUseBlock,
|
|
2690
2975
|
type BetaToolUseBlockParam as BetaToolUseBlockParam,
|
|
2976
|
+
type BetaToolUsesKeep as BetaToolUsesKeep,
|
|
2977
|
+
type BetaToolUsesTrigger as BetaToolUsesTrigger,
|
|
2691
2978
|
type BetaURLImageSource as BetaURLImageSource,
|
|
2692
2979
|
type BetaURLPDFSource as BetaURLPDFSource,
|
|
2693
2980
|
type BetaUsage as BetaUsage,
|