@tanstack/ai-anthropic 0.0.1
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/LICENSE +21 -0
- package/dist/esm/anthropic-adapter.d.ts +69 -0
- package/dist/esm/anthropic-adapter.js +473 -0
- package/dist/esm/anthropic-adapter.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/message-types.d.ts +69 -0
- package/dist/esm/model-meta.d.ts +215 -0
- package/dist/esm/model-meta.js +42 -0
- package/dist/esm/model-meta.js.map +1 -0
- package/dist/esm/text/text-provider-options.d.ts +139 -0
- package/dist/esm/text/text-provider-options.js +30 -0
- package/dist/esm/text/text-provider-options.js.map +1 -0
- package/dist/esm/tools/bash-tool.d.ts +5 -0
- package/dist/esm/tools/bash-tool.js +8 -0
- package/dist/esm/tools/bash-tool.js.map +1 -0
- package/dist/esm/tools/code-execution-tool.d.ts +5 -0
- package/dist/esm/tools/code-execution-tool.js +8 -0
- package/dist/esm/tools/code-execution-tool.js.map +1 -0
- package/dist/esm/tools/computer-use-tool.d.ts +5 -0
- package/dist/esm/tools/computer-use-tool.js +8 -0
- package/dist/esm/tools/computer-use-tool.js.map +1 -0
- package/dist/esm/tools/custom-tool.d.ts +25 -0
- package/dist/esm/tools/custom-tool.js +21 -0
- package/dist/esm/tools/custom-tool.js.map +1 -0
- package/dist/esm/tools/index.d.ts +10 -0
- package/dist/esm/tools/memory-tool.d.ts +5 -0
- package/dist/esm/tools/memory-tool.js +11 -0
- package/dist/esm/tools/memory-tool.js.map +1 -0
- package/dist/esm/tools/text-editor-tool.d.ts +5 -0
- package/dist/esm/tools/text-editor-tool.js +10 -0
- package/dist/esm/tools/text-editor-tool.js.map +1 -0
- package/dist/esm/tools/tool-converter.d.ts +27 -0
- package/dist/esm/tools/tool-converter.js +35 -0
- package/dist/esm/tools/tool-converter.js.map +1 -0
- package/dist/esm/tools/web-fetch-tool.d.ts +5 -0
- package/dist/esm/tools/web-fetch-tool.js +12 -0
- package/dist/esm/tools/web-fetch-tool.js.map +1 -0
- package/dist/esm/tools/web-search-tool.d.ts +5 -0
- package/dist/esm/tools/web-search-tool.js +16 -0
- package/dist/esm/tools/web-search-tool.js.map +1 -0
- package/package.json +53 -0
- package/src/anthropic-adapter.ts +680 -0
- package/src/index.ts +25 -0
- package/src/message-types.ts +85 -0
- package/src/model-meta.ts +482 -0
- package/src/text/text-provider-options.ts +205 -0
- package/src/tools/bash-tool.ts +19 -0
- package/src/tools/code-execution-tool.ts +24 -0
- package/src/tools/computer-use-tool.ts +24 -0
- package/src/tools/custom-tool.ts +64 -0
- package/src/tools/index.ts +30 -0
- package/src/tools/memory-tool.ts +20 -0
- package/src/tools/text-editor-tool.ts +28 -0
- package/src/tools/tool-converter.ts +61 -0
- package/src/tools/web-fetch-tool.ts +23 -0
- package/src/tools/web-search-tool.ts +81 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic-specific metadata types for multimodal content parts.
|
|
3
|
+
* These types extend the base ContentPart metadata with Anthropic-specific options.
|
|
4
|
+
*
|
|
5
|
+
* @see https://docs.anthropic.com/claude/docs/vision
|
|
6
|
+
* @see https://docs.anthropic.com/claude/docs/pdf-support
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Supported image media types for Anthropic.
|
|
10
|
+
*/
|
|
11
|
+
export type AnthropicImageMediaType = 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
|
12
|
+
/**
|
|
13
|
+
* Metadata for Anthropic image content parts.
|
|
14
|
+
*/
|
|
15
|
+
export interface AnthropicImageMetadata {
|
|
16
|
+
/**
|
|
17
|
+
* The MIME type of the image.
|
|
18
|
+
* Required when using base64 source type.
|
|
19
|
+
*
|
|
20
|
+
* @see https://docs.anthropic.com/claude/docs/vision#supported-image-types
|
|
21
|
+
*/
|
|
22
|
+
mediaType?: AnthropicImageMediaType;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Supported document media types for Anthropic.
|
|
26
|
+
*/
|
|
27
|
+
export type AnthropicDocumentMediaType = 'application/pdf';
|
|
28
|
+
/**
|
|
29
|
+
* Metadata for Anthropic document content parts (e.g., PDFs).
|
|
30
|
+
*/
|
|
31
|
+
export interface AnthropicDocumentMetadata {
|
|
32
|
+
/**
|
|
33
|
+
* The MIME type of the document.
|
|
34
|
+
* Required for document content, typically 'application/pdf'.
|
|
35
|
+
*
|
|
36
|
+
* @see https://docs.anthropic.com/claude/docs/pdf-support
|
|
37
|
+
*/
|
|
38
|
+
mediaType?: AnthropicDocumentMediaType;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Metadata for Anthropic audio content parts.
|
|
42
|
+
* Note: Audio support in Anthropic may be limited; check current API capabilities.
|
|
43
|
+
*/
|
|
44
|
+
export interface AnthropicAudioMetadata {
|
|
45
|
+
/**
|
|
46
|
+
* The MIME type of the audio.
|
|
47
|
+
*/
|
|
48
|
+
mediaType?: 'audio/mpeg' | 'audio/wav' | 'audio/ogg' | 'audio/webm' | 'audio/flac';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Metadata for Anthropic video content parts.
|
|
52
|
+
* Note: Video support in Anthropic may be limited; check current API capabilities.
|
|
53
|
+
*/
|
|
54
|
+
export interface AnthropicVideoMetadata {
|
|
55
|
+
/**
|
|
56
|
+
* The MIME type of the video.
|
|
57
|
+
*/
|
|
58
|
+
mediaType?: 'video/mp4' | 'video/webm' | 'video/mpeg';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Map of modality types to their Anthropic-specific metadata types.
|
|
62
|
+
* Used for type inference when constructing multimodal messages.
|
|
63
|
+
*/
|
|
64
|
+
export interface AnthropicMessageMetadataByModality {
|
|
65
|
+
image: AnthropicImageMetadata;
|
|
66
|
+
audio: AnthropicAudioMetadata;
|
|
67
|
+
video: AnthropicVideoMetadata;
|
|
68
|
+
document: AnthropicDocumentMetadata;
|
|
69
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { AnthropicContainerOptions, AnthropicContextManagementOptions, AnthropicMCPOptions, AnthropicSamplingOptions, AnthropicServiceTierOptions, AnthropicStopSequencesOptions, AnthropicThinkingOptions, AnthropicToolChoiceOptions } from './text/text-provider-options.js';
|
|
2
|
+
declare const CLAUDE_SONNET_4_5: {
|
|
3
|
+
readonly name: "claude-sonnet-4-5";
|
|
4
|
+
readonly id: "claude-sonnet-4-5";
|
|
5
|
+
readonly context_window: 200000;
|
|
6
|
+
readonly max_output_tokens: 64000;
|
|
7
|
+
readonly knowledge_cutoff: "2025-09-29";
|
|
8
|
+
readonly pricing: {
|
|
9
|
+
readonly input: {
|
|
10
|
+
readonly normal: 3;
|
|
11
|
+
};
|
|
12
|
+
readonly output: {
|
|
13
|
+
readonly normal: 15;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly supports: {
|
|
17
|
+
readonly input: ["text", "image", "document"];
|
|
18
|
+
readonly extended_thinking: true;
|
|
19
|
+
readonly priority_tier: true;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
declare const CLAUDE_HAIKU_4_5: {
|
|
23
|
+
readonly name: "claude-haiku-4-5";
|
|
24
|
+
readonly id: "claude-haiku-4-5";
|
|
25
|
+
readonly context_window: 200000;
|
|
26
|
+
readonly max_output_tokens: 64000;
|
|
27
|
+
readonly knowledge_cutoff: "2025-10-01";
|
|
28
|
+
readonly pricing: {
|
|
29
|
+
readonly input: {
|
|
30
|
+
readonly normal: 1;
|
|
31
|
+
};
|
|
32
|
+
readonly output: {
|
|
33
|
+
readonly normal: 5;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly supports: {
|
|
37
|
+
readonly input: ["text", "image", "document"];
|
|
38
|
+
readonly extended_thinking: true;
|
|
39
|
+
readonly priority_tier: true;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
declare const CLAUDE_OPUS_4_1: {
|
|
43
|
+
readonly name: "claude-opus-4-1";
|
|
44
|
+
readonly id: "claude-opus-4-1";
|
|
45
|
+
readonly context_window: 200000;
|
|
46
|
+
readonly max_output_tokens: 64000;
|
|
47
|
+
readonly knowledge_cutoff: "2025-08-05";
|
|
48
|
+
readonly pricing: {
|
|
49
|
+
readonly input: {
|
|
50
|
+
readonly normal: 15;
|
|
51
|
+
};
|
|
52
|
+
readonly output: {
|
|
53
|
+
readonly normal: 75;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
readonly supports: {
|
|
57
|
+
readonly input: ["text", "image", "document"];
|
|
58
|
+
readonly extended_thinking: true;
|
|
59
|
+
readonly priority_tier: true;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
declare const CLAUDE_OPUS_4_5: {
|
|
63
|
+
readonly name: "claude-opus-4-5";
|
|
64
|
+
readonly id: "claude-opus-4-5";
|
|
65
|
+
readonly context_window: 200000;
|
|
66
|
+
readonly max_output_tokens: 32000;
|
|
67
|
+
readonly knowledge_cutoff: "2025-11-01";
|
|
68
|
+
readonly pricing: {
|
|
69
|
+
readonly input: {
|
|
70
|
+
readonly normal: 15;
|
|
71
|
+
};
|
|
72
|
+
readonly output: {
|
|
73
|
+
readonly normal: 75;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
readonly supports: {
|
|
77
|
+
readonly input: ["text", "image", "document"];
|
|
78
|
+
readonly extended_thinking: true;
|
|
79
|
+
readonly priority_tier: true;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
declare const CLAUDE_SONNET_4: {
|
|
83
|
+
readonly name: "claude-sonnet-4";
|
|
84
|
+
readonly id: "claude-sonnet-4";
|
|
85
|
+
readonly context_window: 200000;
|
|
86
|
+
readonly max_output_tokens: 64000;
|
|
87
|
+
readonly knowledge_cutoff: "2025-05-14";
|
|
88
|
+
readonly pricing: {
|
|
89
|
+
readonly input: {
|
|
90
|
+
readonly normal: 3;
|
|
91
|
+
};
|
|
92
|
+
readonly output: {
|
|
93
|
+
readonly normal: 15;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
readonly supports: {
|
|
97
|
+
readonly input: ["text", "image", "document"];
|
|
98
|
+
readonly extended_thinking: true;
|
|
99
|
+
readonly priority_tier: true;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
declare const CLAUDE_SONNET_3_7: {
|
|
103
|
+
readonly name: "claude-sonnet-3-7";
|
|
104
|
+
readonly id: "claude-3-7-sonnet";
|
|
105
|
+
readonly max_output_tokens: 64000;
|
|
106
|
+
readonly knowledge_cutoff: "2025-05-14";
|
|
107
|
+
readonly pricing: {
|
|
108
|
+
readonly input: {
|
|
109
|
+
readonly normal: 3;
|
|
110
|
+
};
|
|
111
|
+
readonly output: {
|
|
112
|
+
readonly normal: 15;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
readonly supports: {
|
|
116
|
+
readonly input: ["text", "image", "document"];
|
|
117
|
+
readonly extended_thinking: true;
|
|
118
|
+
readonly priority_tier: true;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
declare const CLAUDE_OPUS_4: {
|
|
122
|
+
readonly name: "claude-opus-4";
|
|
123
|
+
readonly id: "claude-opus-4";
|
|
124
|
+
readonly context_window: 200000;
|
|
125
|
+
readonly max_output_tokens: 32000;
|
|
126
|
+
readonly knowledge_cutoff: "2025-05-14";
|
|
127
|
+
readonly pricing: {
|
|
128
|
+
readonly input: {
|
|
129
|
+
readonly normal: 15;
|
|
130
|
+
};
|
|
131
|
+
readonly output: {
|
|
132
|
+
readonly normal: 75;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
readonly supports: {
|
|
136
|
+
readonly input: ["text", "image", "document"];
|
|
137
|
+
readonly extended_thinking: true;
|
|
138
|
+
readonly priority_tier: true;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
declare const CLAUDE_HAIKU_3_5: {
|
|
142
|
+
readonly name: "claude-haiku-3-5";
|
|
143
|
+
readonly id: "claude-3-5-haiku";
|
|
144
|
+
readonly context_window: 200000;
|
|
145
|
+
readonly max_output_tokens: 8000;
|
|
146
|
+
readonly knowledge_cutoff: "2025-10-22";
|
|
147
|
+
readonly pricing: {
|
|
148
|
+
readonly input: {
|
|
149
|
+
readonly normal: 0.8;
|
|
150
|
+
};
|
|
151
|
+
readonly output: {
|
|
152
|
+
readonly normal: 4;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
readonly supports: {
|
|
156
|
+
readonly input: ["text", "image", "document"];
|
|
157
|
+
readonly extended_thinking: false;
|
|
158
|
+
readonly priority_tier: true;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
declare const CLAUDE_HAIKU_3: {
|
|
162
|
+
readonly name: "claude-haiku-3";
|
|
163
|
+
readonly id: "claude-3-haiku";
|
|
164
|
+
readonly context_window: 200000;
|
|
165
|
+
readonly max_output_tokens: 4000;
|
|
166
|
+
readonly knowledge_cutoff: "2024-03-07";
|
|
167
|
+
readonly pricing: {
|
|
168
|
+
readonly input: {
|
|
169
|
+
readonly normal: 0.25;
|
|
170
|
+
};
|
|
171
|
+
readonly output: {
|
|
172
|
+
readonly normal: 1.25;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
readonly supports: {
|
|
176
|
+
readonly input: ["text", "image", "document"];
|
|
177
|
+
readonly extended_thinking: false;
|
|
178
|
+
readonly priority_tier: false;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export declare const ANTHROPIC_MODELS: readonly ["claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5", "claude-opus-4-1", "claude-sonnet-4", "claude-3-7-sonnet", "claude-opus-4", "claude-3-5-haiku", "claude-3-haiku"];
|
|
182
|
+
export type AnthropicChatModelProviderOptionsByName = {
|
|
183
|
+
[CLAUDE_OPUS_4_5.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
184
|
+
[CLAUDE_SONNET_4_5.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
185
|
+
[CLAUDE_HAIKU_4_5.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
186
|
+
[CLAUDE_OPUS_4_1.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
187
|
+
[CLAUDE_SONNET_4.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
188
|
+
[CLAUDE_SONNET_3_7.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
189
|
+
[CLAUDE_OPUS_4.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
190
|
+
[CLAUDE_HAIKU_3_5.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
191
|
+
[CLAUDE_HAIKU_3.id]: AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicStopSequencesOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Type-only map from chat model name to its supported input modalities.
|
|
195
|
+
* All Anthropic Claude models support text, image, and document (PDF) input.
|
|
196
|
+
* Used by the core AI types to constrain ContentPart types based on the selected model.
|
|
197
|
+
* Note: These must be inlined as readonly arrays (not typeof) because the model
|
|
198
|
+
* constants are not exported and typeof references don't work in .d.ts files
|
|
199
|
+
* when consumed by external packages.
|
|
200
|
+
*
|
|
201
|
+
* @see https://docs.anthropic.com/claude/docs/vision
|
|
202
|
+
* @see https://docs.anthropic.com/claude/docs/pdf-support
|
|
203
|
+
*/
|
|
204
|
+
export type AnthropicModelInputModalitiesByName = {
|
|
205
|
+
[CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input;
|
|
206
|
+
[CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input;
|
|
207
|
+
[CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input;
|
|
208
|
+
[CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.input;
|
|
209
|
+
[CLAUDE_SONNET_4.id]: typeof CLAUDE_SONNET_4.supports.input;
|
|
210
|
+
[CLAUDE_SONNET_3_7.id]: typeof CLAUDE_SONNET_3_7.supports.input;
|
|
211
|
+
[CLAUDE_OPUS_4.id]: typeof CLAUDE_OPUS_4.supports.input;
|
|
212
|
+
[CLAUDE_HAIKU_3_5.id]: typeof CLAUDE_HAIKU_3_5.supports.input;
|
|
213
|
+
[CLAUDE_HAIKU_3.id]: typeof CLAUDE_HAIKU_3.supports.input;
|
|
214
|
+
};
|
|
215
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const CLAUDE_SONNET_4_5 = {
|
|
2
|
+
id: "claude-sonnet-4-5"
|
|
3
|
+
};
|
|
4
|
+
const CLAUDE_HAIKU_4_5 = {
|
|
5
|
+
id: "claude-haiku-4-5"
|
|
6
|
+
};
|
|
7
|
+
const CLAUDE_OPUS_4_1 = {
|
|
8
|
+
id: "claude-opus-4-1"
|
|
9
|
+
};
|
|
10
|
+
const CLAUDE_OPUS_4_5 = {
|
|
11
|
+
id: "claude-opus-4-5"
|
|
12
|
+
};
|
|
13
|
+
const CLAUDE_SONNET_4 = {
|
|
14
|
+
id: "claude-sonnet-4"
|
|
15
|
+
};
|
|
16
|
+
const CLAUDE_SONNET_3_7 = {
|
|
17
|
+
id: "claude-3-7-sonnet"
|
|
18
|
+
};
|
|
19
|
+
const CLAUDE_OPUS_4 = {
|
|
20
|
+
id: "claude-opus-4"
|
|
21
|
+
};
|
|
22
|
+
const CLAUDE_HAIKU_3_5 = {
|
|
23
|
+
id: "claude-3-5-haiku"
|
|
24
|
+
};
|
|
25
|
+
const CLAUDE_HAIKU_3 = {
|
|
26
|
+
id: "claude-3-haiku"
|
|
27
|
+
};
|
|
28
|
+
const ANTHROPIC_MODELS = [
|
|
29
|
+
CLAUDE_OPUS_4_5.id,
|
|
30
|
+
CLAUDE_SONNET_4_5.id,
|
|
31
|
+
CLAUDE_HAIKU_4_5.id,
|
|
32
|
+
CLAUDE_OPUS_4_1.id,
|
|
33
|
+
CLAUDE_SONNET_4.id,
|
|
34
|
+
CLAUDE_SONNET_3_7.id,
|
|
35
|
+
CLAUDE_OPUS_4.id,
|
|
36
|
+
CLAUDE_HAIKU_3_5.id,
|
|
37
|
+
CLAUDE_HAIKU_3.id
|
|
38
|
+
];
|
|
39
|
+
export {
|
|
40
|
+
ANTHROPIC_MODELS
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=model-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["import type {\n AnthropicContainerOptions,\n AnthropicContextManagementOptions,\n AnthropicMCPOptions,\n AnthropicSamplingOptions,\n AnthropicServiceTierOptions,\n AnthropicStopSequencesOptions,\n AnthropicThinkingOptions,\n AnthropicToolChoiceOptions,\n} from './text/text-provider-options'\n\ninterface ModelMeta<\n TProviderOptions = unknown,\n TToolCapabilities = unknown,\n TMessageCapabilities = unknown,\n> {\n name: string\n id: string\n supports: {\n input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>\n extended_thinking?: boolean\n priority_tier?: boolean\n }\n context_window?: number\n max_output_tokens?: number\n knowledge_cutoff?: string\n pricing: {\n input: {\n normal: number\n cached?: number\n }\n output: {\n normal: number\n }\n }\n /**\n * Type-level description of which provider options this model supports.\n */\n providerOptions?: TProviderOptions\n /**\n * Type-level description of which tool capabilities this model supports.\n */\n toolCapabilities?: TToolCapabilities\n /**\n * Type-level description of which message/input capabilities this model supports.\n */\n messageCapabilities?: TMessageCapabilities\n}\nconst CLAUDE_SONNET_4_5 = {\n name: 'claude-sonnet-4-5',\n id: 'claude-sonnet-4-5',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-09-29',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_HAIKU_4_5 = {\n name: 'claude-haiku-4-5',\n id: 'claude-haiku-4-5',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-10-01',\n pricing: {\n input: {\n normal: 1,\n },\n output: {\n normal: 5,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4_1 = {\n name: 'claude-opus-4-1',\n id: 'claude-opus-4-1',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-08-05',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4_5 = {\n name: 'claude-opus-4-5',\n id: 'claude-opus-4-5',\n context_window: 200_000,\n max_output_tokens: 32_000,\n knowledge_cutoff: '2025-11-01',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_SONNET_4 = {\n name: 'claude-sonnet-4',\n id: 'claude-sonnet-4',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-05-14',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_SONNET_3_7 = {\n name: 'claude-sonnet-3-7',\n id: 'claude-3-7-sonnet',\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-05-14',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4 = {\n name: 'claude-opus-4',\n id: 'claude-opus-4',\n context_window: 200_000,\n max_output_tokens: 32_000,\n knowledge_cutoff: '2025-05-14',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_HAIKU_3_5 = {\n name: 'claude-haiku-3-5',\n id: 'claude-3-5-haiku',\n context_window: 200_000,\n max_output_tokens: 8_000,\n knowledge_cutoff: '2025-10-22',\n pricing: {\n input: {\n normal: 0.8,\n },\n output: {\n normal: 4,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n priority_tier: true,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_HAIKU_3 = {\n name: 'claude-haiku-3',\n id: 'claude-3-haiku',\n context_window: 200_000,\n max_output_tokens: 4_000,\n knowledge_cutoff: '2024-03-07',\n pricing: {\n input: {\n normal: 0.25,\n },\n output: {\n normal: 1.25,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n priority_tier: false,\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\n/* const ANTHROPIC_MODEL_META = {\n [CLAUDE_OPUS_4_5.name]: CLAUDE_OPUS_4_5,\n [CLAUDE_SONNET_4_5.name]: CLAUDE_SONNET_4_5,\n [CLAUDE_HAIKU_4_5.name]: CLAUDE_HAIKU_4_5,\n [CLAUDE_OPUS_4_1.name]: CLAUDE_OPUS_4_1,\n [CLAUDE_SONNET_4.name]: CLAUDE_SONNET_4,\n [CLAUDE_SONNET_3_7.name]: CLAUDE_SONNET_3_7,\n [CLAUDE_OPUS_4.name]: CLAUDE_OPUS_4,\n [CLAUDE_HAIKU_3_5.name]: CLAUDE_HAIKU_3_5,\n [CLAUDE_HAIKU_3.name]: CLAUDE_HAIKU_3,\n} as const */\n\n/* export type AnthropicModelProviderOptions<\n TModel extends keyof AnthropicModelMetaMap,\n> =\n AnthropicModelMetaMap[TModel] extends ModelMeta<\n infer TProviderOptions,\n any,\n any\n >\n ? TProviderOptions\n : unknown */\n\n/* export type AnthropicModelToolCapabilities<\n TModel extends keyof AnthropicModelMetaMap,\n> =\n AnthropicModelMetaMap[TModel] extends ModelMeta<\n any,\n infer TToolCapabilities,\n any\n >\n ? TToolCapabilities\n : unknown\n */\n/* export type AnthropicModelMessageCapabilities<\n TModel extends keyof AnthropicModelMetaMap,\n> =\n AnthropicModelMetaMap[TModel] extends ModelMeta<\n any,\n any,\n infer TMessageCapabilities\n >\n ? TMessageCapabilities\n : unknown */\n\nexport const ANTHROPIC_MODELS = [\n CLAUDE_OPUS_4_5.id,\n CLAUDE_SONNET_4_5.id,\n CLAUDE_HAIKU_4_5.id,\n CLAUDE_OPUS_4_1.id,\n CLAUDE_SONNET_4.id,\n CLAUDE_SONNET_3_7.id,\n CLAUDE_OPUS_4.id,\n CLAUDE_HAIKU_3_5.id,\n CLAUDE_HAIKU_3.id,\n] as const\n\n// const ANTHROPIC_IMAGE_MODELS = [] as const\n// const ANTHROPIC_EMBEDDING_MODELS = [] as const\n// const ANTHROPIC_AUDIO_MODELS = [] as const\n// const ANTHROPIC_VIDEO_MODELS = [] as const\n\n/* type AnthropicModel = (typeof ANTHROPIC_MODELS)[number] */\n\n// Manual type map for per-model provider options\n// Models are differentiated by extended_thinking and priority_tier support\nexport type AnthropicChatModelProviderOptionsByName = {\n // Models with both extended_thinking and priority_tier\n [CLAUDE_OPUS_4_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_4_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_HAIKU_4_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_OPUS_4_1.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_4.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_3_7.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_OPUS_4.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\n // Model with priority_tier but NO extended_thinking\n [CLAUDE_HAIKU_3_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\n // Model with neither extended_thinking nor priority_tier\n [CLAUDE_HAIKU_3.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicStopSequencesOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n}\n\n/**\n * Type-only map from chat model name to its supported input modalities.\n * All Anthropic Claude models support text, image, and document (PDF) input.\n * Used by the core AI types to constrain ContentPart types based on the selected model.\n * Note: These must be inlined as readonly arrays (not typeof) because the model\n * constants are not exported and typeof references don't work in .d.ts files\n * when consumed by external packages.\n *\n * @see https://docs.anthropic.com/claude/docs/vision\n * @see https://docs.anthropic.com/claude/docs/pdf-support\n */\nexport type AnthropicModelInputModalitiesByName = {\n [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input\n [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input\n [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input\n [CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.input\n [CLAUDE_SONNET_4.id]: typeof CLAUDE_SONNET_4.supports.input\n [CLAUDE_SONNET_3_7.id]: typeof CLAUDE_SONNET_3_7.supports.input\n [CLAUDE_OPUS_4.id]: typeof CLAUDE_OPUS_4.supports.input\n [CLAUDE_HAIKU_3_5.id]: typeof CLAUDE_HAIKU_3_5.supports.input\n [CLAUDE_HAIKU_3.id]: typeof CLAUDE_HAIKU_3.supports.input\n}\n"],"names":[],"mappings":"AAgDA,MAAM,oBAAoB;AAAA,EAExB,IAAI;AAiBN;AAWA,MAAM,mBAAmB;AAAA,EAEvB,IAAI;AAiBN;AAWA,MAAM,kBAAkB;AAAA,EAEtB,IAAI;AAiBN;AAWA,MAAM,kBAAkB;AAAA,EAEtB,IAAI;AAiBN;AAWA,MAAM,kBAAkB;AAAA,EAEtB,IAAI;AAiBN;AAWA,MAAM,oBAAoB;AAAA,EAExB,IAAI;AAgBN;AAWA,MAAM,gBAAgB;AAAA,EAEpB,IAAI;AAiBN;AAWA,MAAM,mBAAmB;AAAA,EAEvB,IAAI;AAiBN;AAWA,MAAM,iBAAiB;AAAA,EAErB,IAAI;AAiBN;AAwDO,MAAM,mBAAmB;AAAA,EAC9B,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,eAAe;AACjB;"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { BetaContextManagementConfig, BetaToolChoiceAny, BetaToolChoiceAuto, BetaToolChoiceTool } from '@anthropic-ai/sdk/resources/beta/messages/messages';
|
|
2
|
+
import { AnthropicTool } from '../tools.js';
|
|
3
|
+
import { MessageParam, TextBlockParam } from '@anthropic-ai/sdk/resources/messages';
|
|
4
|
+
export interface AnthropicContainerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Container identifier for reuse across requests.
|
|
7
|
+
* Container parameters with skills to be loaded.
|
|
8
|
+
*/
|
|
9
|
+
container?: {
|
|
10
|
+
id: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* List of skills to load into the container
|
|
13
|
+
*/
|
|
14
|
+
skills: Array<{
|
|
15
|
+
/**
|
|
16
|
+
* Between 1-64 characters
|
|
17
|
+
*/
|
|
18
|
+
skill_id: string;
|
|
19
|
+
type: 'anthropic' | 'custom';
|
|
20
|
+
/**
|
|
21
|
+
* Skill version or latest by default
|
|
22
|
+
*/
|
|
23
|
+
version?: string;
|
|
24
|
+
}> | null;
|
|
25
|
+
} | null;
|
|
26
|
+
}
|
|
27
|
+
export interface AnthropicContextManagementOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Context management configuration.
|
|
30
|
+
|
|
31
|
+
This allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not.
|
|
32
|
+
*/
|
|
33
|
+
context_management?: BetaContextManagementConfig | null;
|
|
34
|
+
}
|
|
35
|
+
export interface AnthropicMCPOptions {
|
|
36
|
+
/**
|
|
37
|
+
* MCP servers to be utilized in this request
|
|
38
|
+
* Maximum of 20 servers
|
|
39
|
+
*/
|
|
40
|
+
mcp_servers?: Array<MCPServer>;
|
|
41
|
+
}
|
|
42
|
+
export interface AnthropicServiceTierOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Determines whether to use priority capacity (if available) or standard capacity for this request.
|
|
45
|
+
*/
|
|
46
|
+
service_tier?: 'auto' | 'standard_only';
|
|
47
|
+
}
|
|
48
|
+
export interface AnthropicStopSequencesOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Custom text sequences that will cause the model to stop generating.
|
|
51
|
+
|
|
52
|
+
Anthropic models will normally stop when they have naturally completed their turn, which will result in a response stop_reason of "end_turn".
|
|
53
|
+
|
|
54
|
+
If you want the model to stop generating when it encounters custom strings of text, you can use the stop_sequences parameter. If the model encounters one of the custom sequences, the response stop_reason value will be "stop_sequence" and the response stop_sequence value will contain the matched stop sequence.
|
|
55
|
+
*/
|
|
56
|
+
stop_sequences?: Array<string>;
|
|
57
|
+
}
|
|
58
|
+
export interface AnthropicThinkingOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Configuration for enabling Claude's extended thinking.
|
|
61
|
+
|
|
62
|
+
When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.
|
|
63
|
+
*/
|
|
64
|
+
thinking?: {
|
|
65
|
+
/**
|
|
66
|
+
* Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.
|
|
67
|
+
|
|
68
|
+
Must be ≥1024 and less than max_tokens
|
|
69
|
+
*/
|
|
70
|
+
budget_tokens: number;
|
|
71
|
+
type: 'enabled';
|
|
72
|
+
} | {
|
|
73
|
+
type: 'disabled';
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface AnthropicToolChoiceOptions {
|
|
77
|
+
tool_choice?: BetaToolChoiceAny | BetaToolChoiceTool | BetaToolChoiceAuto;
|
|
78
|
+
}
|
|
79
|
+
export interface AnthropicSamplingOptions {
|
|
80
|
+
/**
|
|
81
|
+
* Only sample from the top K options for each subsequent token.
|
|
82
|
+
|
|
83
|
+
Used to remove "long tail" low probability responses.
|
|
84
|
+
Recommended for advanced use cases only. You usually only need to use temperature.
|
|
85
|
+
|
|
86
|
+
Required range: x >= 0
|
|
87
|
+
*/
|
|
88
|
+
top_k?: number;
|
|
89
|
+
}
|
|
90
|
+
export type ExternalTextProviderOptions = AnthropicContainerOptions & AnthropicContextManagementOptions & AnthropicMCPOptions & AnthropicServiceTierOptions & AnthropicStopSequencesOptions & AnthropicThinkingOptions & AnthropicToolChoiceOptions & AnthropicSamplingOptions;
|
|
91
|
+
export interface InternalTextProviderOptions extends ExternalTextProviderOptions {
|
|
92
|
+
model: string;
|
|
93
|
+
messages: Array<MessageParam>;
|
|
94
|
+
/**
|
|
95
|
+
* The maximum number of tokens to generate before stopping. This parameter only specifies the absolute maximum number of tokens to generate.
|
|
96
|
+
* Range x >= 1.
|
|
97
|
+
*/
|
|
98
|
+
max_tokens: number;
|
|
99
|
+
/**
|
|
100
|
+
* Whether to incrementally stream the response using server-sent events.
|
|
101
|
+
*/
|
|
102
|
+
stream?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* stem prompt.
|
|
105
|
+
|
|
106
|
+
A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role.
|
|
107
|
+
*/
|
|
108
|
+
system?: string | Array<TextBlockParam>;
|
|
109
|
+
/**
|
|
110
|
+
* Amount of randomness injected into the response.
|
|
111
|
+
* Either use this or top_p, but not both.
|
|
112
|
+
* 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.
|
|
113
|
+
* @default 1.0
|
|
114
|
+
*/
|
|
115
|
+
temperature?: number;
|
|
116
|
+
tools?: Array<AnthropicTool>;
|
|
117
|
+
/**
|
|
118
|
+
* Use nucleus sampling.
|
|
119
|
+
|
|
120
|
+
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.
|
|
121
|
+
*/
|
|
122
|
+
top_p?: number;
|
|
123
|
+
}
|
|
124
|
+
export interface CacheControl {
|
|
125
|
+
type: 'ephemeral';
|
|
126
|
+
ttl: '5m' | '1h';
|
|
127
|
+
}
|
|
128
|
+
interface MCPServer {
|
|
129
|
+
name: string;
|
|
130
|
+
url: string;
|
|
131
|
+
type: 'url';
|
|
132
|
+
authorization_token?: string | null;
|
|
133
|
+
tool_configuration: {
|
|
134
|
+
allowed_tools?: Array<string> | null;
|
|
135
|
+
enabled?: boolean | null;
|
|
136
|
+
} | null;
|
|
137
|
+
}
|
|
138
|
+
export declare const validateTextProviderOptions: (options: InternalTextProviderOptions) => void;
|
|
139
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const validateTopPandTemperature = (options) => {
|
|
2
|
+
if (options.top_p !== void 0 && options.temperature !== void 0) {
|
|
3
|
+
throw new Error("You should either set top_p or temperature, but not both.");
|
|
4
|
+
}
|
|
5
|
+
};
|
|
6
|
+
const validateThinking = (options) => {
|
|
7
|
+
const thinking = options.thinking;
|
|
8
|
+
if (thinking && thinking.type === "enabled") {
|
|
9
|
+
if (thinking.budget_tokens < 1024) {
|
|
10
|
+
throw new Error("thinking.budget_tokens must be at least 1024.");
|
|
11
|
+
}
|
|
12
|
+
if (thinking.budget_tokens >= options.max_tokens) {
|
|
13
|
+
throw new Error("thinking.budget_tokens must be less than max_tokens.");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const validateMaxTokens = (options) => {
|
|
18
|
+
if (options.max_tokens < 1) {
|
|
19
|
+
throw new Error("max_tokens must be at least 1.");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const validateTextProviderOptions = (options) => {
|
|
23
|
+
validateTopPandTemperature(options);
|
|
24
|
+
validateThinking(options);
|
|
25
|
+
validateMaxTokens(options);
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
validateTextProviderOptions
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=text-provider-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-provider-options.js","sources":["../../../src/text/text-provider-options.ts"],"sourcesContent":["import type {\n BetaContextManagementConfig,\n BetaToolChoiceAny,\n BetaToolChoiceAuto,\n BetaToolChoiceTool,\n} from '@anthropic-ai/sdk/resources/beta/messages/messages'\nimport type { AnthropicTool } from '../tools'\nimport type {\n MessageParam,\n TextBlockParam,\n} from '@anthropic-ai/sdk/resources/messages'\n\nexport interface AnthropicContainerOptions {\n /**\n * Container identifier for reuse across requests.\n * Container parameters with skills to be loaded.\n */\n container?: {\n id: string | null\n /**\n * List of skills to load into the container\n */\n skills: Array<{\n /**\n * Between 1-64 characters\n */\n skill_id: string\n\n type: 'anthropic' | 'custom'\n /**\n * Skill version or latest by default\n */\n version?: string\n }> | null\n } | null\n}\n\nexport interface AnthropicContextManagementOptions {\n /**\n * Context management configuration.\n\nThis allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not.\n */\n context_management?: BetaContextManagementConfig | null\n}\n\nexport interface AnthropicMCPOptions {\n /**\n * MCP servers to be utilized in this request\n * Maximum of 20 servers\n */\n mcp_servers?: Array<MCPServer>\n}\n\nexport interface AnthropicServiceTierOptions {\n /**\n * Determines whether to use priority capacity (if available) or standard capacity for this request.\n */\n service_tier?: 'auto' | 'standard_only'\n}\n\nexport interface AnthropicStopSequencesOptions {\n /**\n * Custom text sequences that will cause the model to stop generating.\n\nAnthropic models will normally stop when they have naturally completed their turn, which will result in a response stop_reason of \"end_turn\".\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the stop_sequences parameter. If the model encounters one of the custom sequences, the response stop_reason value will be \"stop_sequence\" and the response stop_sequence value will contain the matched stop sequence.\n */\n stop_sequences?: Array<string>\n}\n\nexport interface AnthropicThinkingOptions {\n /**\n * Configuration for enabling Claude's extended thinking.\n\nWhen enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.\n */\n thinking?:\n | {\n /**\n* Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.\n\nMust be ≥1024 and less than max_tokens\n*/\n budget_tokens: number\n\n type: 'enabled'\n }\n | {\n type: 'disabled'\n }\n}\n\nexport interface AnthropicToolChoiceOptions {\n tool_choice?: BetaToolChoiceAny | BetaToolChoiceTool | BetaToolChoiceAuto\n}\n\nexport interface AnthropicSamplingOptions {\n /**\n * Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses.\nRecommended for advanced use cases only. You usually only need to use temperature.\n\nRequired range: x >= 0\n */\n top_k?: number\n}\n\nexport type ExternalTextProviderOptions = AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\nexport interface InternalTextProviderOptions\n extends ExternalTextProviderOptions {\n model: string\n\n messages: Array<MessageParam>\n\n /**\n * The maximum number of tokens to generate before stopping. This parameter only specifies the absolute maximum number of tokens to generate.\n * Range x >= 1.\n */\n max_tokens: number\n /**\n * Whether to incrementally stream the response using server-sent events.\n */\n stream?: boolean\n /**\n * stem prompt.\n \n A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role.\n */\n system?: string | Array<TextBlockParam>\n /**\n * Amount of randomness injected into the response.\n * Either use this or top_p, but not both.\n * 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.\n * @default 1.0\n */\n temperature?: number\n\n tools?: Array<AnthropicTool>\n\n /**\n * Use nucleus sampling.\n\nIn 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.\n */\n top_p?: number\n}\n\nconst validateTopPandTemperature = (options: InternalTextProviderOptions) => {\n if (options.top_p !== undefined && options.temperature !== undefined) {\n throw new Error('You should either set top_p or temperature, but not both.')\n }\n}\n\nexport interface CacheControl {\n type: 'ephemeral'\n ttl: '5m' | '1h'\n}\n\nconst validateThinking = (options: InternalTextProviderOptions) => {\n const thinking = options.thinking\n if (thinking && thinking.type === 'enabled') {\n if (thinking.budget_tokens < 1024) {\n throw new Error('thinking.budget_tokens must be at least 1024.')\n }\n if (thinking.budget_tokens >= options.max_tokens) {\n throw new Error('thinking.budget_tokens must be less than max_tokens.')\n }\n }\n}\n\ninterface MCPServer {\n name: string\n url: string\n type: 'url'\n authorization_token?: string | null\n tool_configuration: {\n allowed_tools?: Array<string> | null\n enabled?: boolean | null\n } | null\n}\n\nconst validateMaxTokens = (options: InternalTextProviderOptions) => {\n if (options.max_tokens < 1) {\n throw new Error('max_tokens must be at least 1.')\n }\n}\n\nexport const validateTextProviderOptions = (\n options: InternalTextProviderOptions,\n) => {\n validateTopPandTemperature(options)\n validateThinking(options)\n validateMaxTokens(options)\n}\n"],"names":[],"mappings":"AA8JA,MAAM,6BAA6B,CAAC,YAAyC;AAC3E,MAAI,QAAQ,UAAU,UAAa,QAAQ,gBAAgB,QAAW;AACpE,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACF;AAOA,MAAM,mBAAmB,CAAC,YAAyC;AACjE,QAAM,WAAW,QAAQ;AACzB,MAAI,YAAY,SAAS,SAAS,WAAW;AAC3C,QAAI,SAAS,gBAAgB,MAAM;AACjC,YAAM,IAAI,MAAM,+CAA+C;AAAA,IACjE;AACA,QAAI,SAAS,iBAAiB,QAAQ,YAAY;AAChD,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAAA,EACF;AACF;AAaA,MAAM,oBAAoB,CAAC,YAAyC;AAClE,MAAI,QAAQ,aAAa,GAAG;AAC1B,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AACF;AAEO,MAAM,8BAA8B,CACzC,YACG;AACH,6BAA2B,OAAO;AAClC,mBAAiB,OAAO;AACxB,oBAAkB,OAAO;AAC3B;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BetaToolBash20241022, BetaToolBash20250124 } from '@anthropic-ai/sdk/resources/beta';
|
|
2
|
+
import { Tool } from '@tanstack/ai';
|
|
3
|
+
export type BashTool = BetaToolBash20241022 | BetaToolBash20250124;
|
|
4
|
+
export declare function convertBashToolToAdapterFormat(tool: Tool): BashTool;
|
|
5
|
+
export declare function bashTool(config: BashTool): Tool;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-tool.js","sources":["../../../src/tools/bash-tool.ts"],"sourcesContent":["import type {\n BetaToolBash20241022,\n BetaToolBash20250124,\n} from '@anthropic-ai/sdk/resources/beta'\nimport type { Tool } from '@tanstack/ai'\n\nexport type BashTool = BetaToolBash20241022 | BetaToolBash20250124\n\nexport function convertBashToolToAdapterFormat(tool: Tool): BashTool {\n const metadata = tool.metadata as BashTool\n return metadata\n}\nexport function bashTool(config: BashTool): Tool {\n return {\n name: 'bash',\n description: '',\n metadata: config,\n }\n}\n"],"names":[],"mappings":"AAQO,SAAS,+BAA+B,MAAsB;AACnE,QAAM,WAAW,KAAK;AACtB,SAAO;AACT;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BetaCodeExecutionTool20250522, BetaCodeExecutionTool20250825 } from '@anthropic-ai/sdk/resources/beta';
|
|
2
|
+
import { Tool } from '@tanstack/ai';
|
|
3
|
+
export type CodeExecutionTool = BetaCodeExecutionTool20250522 | BetaCodeExecutionTool20250825;
|
|
4
|
+
export declare function convertCodeExecutionToolToAdapterFormat(tool: Tool): CodeExecutionTool;
|
|
5
|
+
export declare function codeExecutionTool(config: CodeExecutionTool): Tool;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-execution-tool.js","sources":["../../../src/tools/code-execution-tool.ts"],"sourcesContent":["import type {\n BetaCodeExecutionTool20250522,\n BetaCodeExecutionTool20250825,\n} from '@anthropic-ai/sdk/resources/beta'\nimport type { Tool } from '@tanstack/ai'\n\nexport type CodeExecutionTool =\n | BetaCodeExecutionTool20250522\n | BetaCodeExecutionTool20250825\n\nexport function convertCodeExecutionToolToAdapterFormat(\n tool: Tool,\n): CodeExecutionTool {\n const metadata = tool.metadata as CodeExecutionTool\n return metadata\n}\n\nexport function codeExecutionTool(config: CodeExecutionTool): Tool {\n return {\n name: 'code_execution',\n description: '',\n metadata: config,\n }\n}\n"],"names":[],"mappings":"AAUO,SAAS,wCACd,MACmB;AACnB,QAAM,WAAW,KAAK;AACtB,SAAO;AACT;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BetaToolComputerUse20241022, BetaToolComputerUse20250124 } from '@anthropic-ai/sdk/resources/beta';
|
|
2
|
+
import { Tool } from '@tanstack/ai';
|
|
3
|
+
export type ComputerUseTool = BetaToolComputerUse20241022 | BetaToolComputerUse20250124;
|
|
4
|
+
export declare function convertComputerUseToolToAdapterFormat(tool: Tool): ComputerUseTool;
|
|
5
|
+
export declare function computerUseTool(config: ComputerUseTool): Tool;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computer-use-tool.js","sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import type {\n BetaToolComputerUse20241022,\n BetaToolComputerUse20250124,\n} from '@anthropic-ai/sdk/resources/beta'\nimport type { Tool } from '@tanstack/ai'\n\nexport type ComputerUseTool =\n | BetaToolComputerUse20241022\n | BetaToolComputerUse20250124\n\nexport function convertComputerUseToolToAdapterFormat(\n tool: Tool,\n): ComputerUseTool {\n const metadata = tool.metadata as ComputerUseTool\n return metadata\n}\n\nexport function computerUseTool(config: ComputerUseTool): Tool {\n return {\n name: 'computer',\n description: '',\n metadata: config,\n }\n}\n"],"names":[],"mappings":"AAUO,SAAS,sCACd,MACiB;AACjB,QAAM,WAAW,KAAK;AACtB,SAAO;AACT;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Tool } from '@tanstack/ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { CacheControl } from '../text/text-provider-options.js';
|
|
4
|
+
export interface CustomTool {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the tool.
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
type: 'custom';
|
|
10
|
+
/**
|
|
11
|
+
* A brief description of what the tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
|
|
12
|
+
*/
|
|
13
|
+
description: string;
|
|
14
|
+
/**
|
|
15
|
+
* This defines the shape of the input that your tool accepts and that the model will produce.
|
|
16
|
+
*/
|
|
17
|
+
input_schema: {
|
|
18
|
+
type: 'object';
|
|
19
|
+
properties: Record<string, any> | null;
|
|
20
|
+
required?: Array<string> | null;
|
|
21
|
+
};
|
|
22
|
+
cache_control?: CacheControl | null;
|
|
23
|
+
}
|
|
24
|
+
export declare function convertCustomToolToAdapterFormat(tool: Tool): CustomTool;
|
|
25
|
+
export declare function customTool(name: string, description: string, inputSchema: z.ZodType, cacheControl?: CacheControl | null): Tool;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { convertZodToJsonSchema } from "@tanstack/ai";
|
|
2
|
+
function convertCustomToolToAdapterFormat(tool) {
|
|
3
|
+
const metadata = tool.metadata || {};
|
|
4
|
+
const jsonSchema = convertZodToJsonSchema(tool.inputSchema);
|
|
5
|
+
const inputSchema = {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: jsonSchema?.properties || null,
|
|
8
|
+
required: jsonSchema?.required || null
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
name: tool.name,
|
|
12
|
+
type: "custom",
|
|
13
|
+
description: tool.description,
|
|
14
|
+
input_schema: inputSchema,
|
|
15
|
+
cache_control: metadata.cacheControl || null
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
convertCustomToolToAdapterFormat
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=custom-tool.js.map
|