@ai-sdk/anthropic 4.0.0-beta.37 → 4.0.0-beta.39
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 +23 -0
- package/dist/index.d.ts +24 -24
- package/dist/index.js +59 -61
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +29 -29
- package/dist/internal/index.js +59 -60
- package/dist/internal/index.js.map +1 -1
- package/package.json +8 -6
- package/src/{anthropic-messages-api.ts → anthropic-api.ts} +4 -4
- package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +32 -37
- package/src/{anthropic-messages-options.ts → anthropic-options.ts} +1 -1
- package/src/anthropic-prepare-tools.ts +1 -1
- package/src/anthropic-provider.ts +9 -9
- package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +3 -3
- package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +9 -8
- package/src/get-cache-control.ts +1 -1
- package/src/index.ts +1 -1
- package/src/internal/index.ts +9 -3
- package/src/tool/bash_20241022.ts +2 -2
- package/src/tool/bash_20250124.ts +2 -2
- package/src/tool/code-execution_20250522.ts +2 -2
- package/src/tool/code-execution_20250825.ts +2 -2
- package/src/tool/code-execution_20260120.ts +2 -2
- package/src/tool/computer_20241022.ts +2 -2
- package/src/tool/computer_20250124.ts +2 -2
- package/src/tool/computer_20251124.ts +2 -2
- package/src/tool/memory_20250818.ts +2 -2
- package/src/tool/text-editor_20241022.ts +2 -2
- package/src/tool/text-editor_20250124.ts +2 -2
- package/src/tool/text-editor_20250429.ts +2 -2
- package/src/tool/text-editor_20250728.ts +2 -2
- package/src/tool/tool-search-bm25_20251119.ts +2 -2
- package/src/tool/tool-search-regex_20251119.ts +2 -2
- package/src/tool/web-fetch-20250910.ts +2 -2
- package/src/tool/web-fetch-20260209.ts +2 -2
- package/src/tool/web-search_20250305.ts +2 -2
- package/src/tool/web-search_20260209.ts +2 -2
package/dist/internal/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, LanguageModelV
|
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type AnthropicModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | (string & {});
|
|
6
6
|
|
|
7
|
-
type
|
|
7
|
+
type AnthropicLanguageModelConfig = {
|
|
8
8
|
provider: string;
|
|
9
9
|
baseURL: string;
|
|
10
10
|
headers?: Resolvable<Record<string, string | undefined>>;
|
|
@@ -23,20 +23,20 @@ type AnthropicMessagesConfig = {
|
|
|
23
23
|
*/
|
|
24
24
|
supportsStrictTools?: boolean;
|
|
25
25
|
};
|
|
26
|
-
declare class
|
|
26
|
+
declare class AnthropicLanguageModel implements LanguageModelV4 {
|
|
27
27
|
readonly specificationVersion = "v4";
|
|
28
|
-
readonly modelId:
|
|
28
|
+
readonly modelId: AnthropicModelId;
|
|
29
29
|
private readonly config;
|
|
30
30
|
private readonly generateId;
|
|
31
|
-
static [WORKFLOW_SERIALIZE](model:
|
|
31
|
+
static [WORKFLOW_SERIALIZE](model: AnthropicLanguageModel): {
|
|
32
32
|
modelId: string;
|
|
33
33
|
config: JSONObject;
|
|
34
34
|
};
|
|
35
35
|
static [WORKFLOW_DESERIALIZE](options: {
|
|
36
|
-
modelId:
|
|
37
|
-
config:
|
|
38
|
-
}):
|
|
39
|
-
constructor(modelId:
|
|
36
|
+
modelId: AnthropicModelId;
|
|
37
|
+
config: AnthropicLanguageModelConfig;
|
|
38
|
+
}): AnthropicLanguageModel;
|
|
39
|
+
constructor(modelId: AnthropicModelId, config: AnthropicLanguageModelConfig);
|
|
40
40
|
supportsUrl(url: URL): boolean;
|
|
41
41
|
get provider(): string;
|
|
42
42
|
/**
|
|
@@ -76,7 +76,7 @@ declare const anthropicTools: {
|
|
|
76
76
|
*
|
|
77
77
|
* Image results are supported.
|
|
78
78
|
*/
|
|
79
|
-
bash_20241022: _ai_sdk_provider_utils.
|
|
79
|
+
bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
80
80
|
command: string;
|
|
81
81
|
restart?: boolean;
|
|
82
82
|
}, {}, {}>;
|
|
@@ -86,7 +86,7 @@ declare const anthropicTools: {
|
|
|
86
86
|
*
|
|
87
87
|
* Image results are supported.
|
|
88
88
|
*/
|
|
89
|
-
bash_20250124: _ai_sdk_provider_utils.
|
|
89
|
+
bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
90
90
|
command: string;
|
|
91
91
|
restart?: boolean;
|
|
92
92
|
}, {}, {}>;
|
|
@@ -98,7 +98,7 @@ declare const anthropicTools: {
|
|
|
98
98
|
* The code execution tool allows Claude to run Bash commands and manipulate files,
|
|
99
99
|
* including writing code, in a secure, sandboxed environment.
|
|
100
100
|
*/
|
|
101
|
-
codeExecution_20250522: (args?: Parameters<_ai_sdk_provider_utils.
|
|
101
|
+
codeExecution_20250522: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
102
102
|
code: string;
|
|
103
103
|
}, {
|
|
104
104
|
type: "code_execution_result";
|
|
@@ -131,7 +131,7 @@ declare const anthropicTools: {
|
|
|
131
131
|
*
|
|
132
132
|
* This is the latest version with enhanced Bash support and file operations.
|
|
133
133
|
*/
|
|
134
|
-
codeExecution_20250825: (args?: Parameters<_ai_sdk_provider_utils.
|
|
134
|
+
codeExecution_20250825: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
135
135
|
type: "programmatic-tool-call";
|
|
136
136
|
code: string;
|
|
137
137
|
} | {
|
|
@@ -268,7 +268,7 @@ declare const anthropicTools: {
|
|
|
268
268
|
*
|
|
269
269
|
* Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5
|
|
270
270
|
*/
|
|
271
|
-
codeExecution_20260120: (args?: Parameters<_ai_sdk_provider_utils.
|
|
271
|
+
codeExecution_20260120: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
272
272
|
type: "programmatic-tool-call";
|
|
273
273
|
code: string;
|
|
274
274
|
} | {
|
|
@@ -421,7 +421,7 @@ declare const anthropicTools: {
|
|
|
421
421
|
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
422
422
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
423
423
|
*/
|
|
424
|
-
computer_20241022: _ai_sdk_provider_utils.
|
|
424
|
+
computer_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
425
425
|
action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
|
|
426
426
|
coordinate?: number[];
|
|
427
427
|
text?: string;
|
|
@@ -440,7 +440,7 @@ declare const anthropicTools: {
|
|
|
440
440
|
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
441
441
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
442
442
|
*/
|
|
443
|
-
computer_20250124: _ai_sdk_provider_utils.
|
|
443
|
+
computer_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
444
444
|
action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot";
|
|
445
445
|
coordinate?: [number, number];
|
|
446
446
|
duration?: number;
|
|
@@ -468,7 +468,7 @@ declare const anthropicTools: {
|
|
|
468
468
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
469
469
|
* @param enableZoom - Enable zoom action. Set to true to allow Claude to zoom into specific screen regions. Default: false.
|
|
470
470
|
*/
|
|
471
|
-
computer_20251124: _ai_sdk_provider_utils.
|
|
471
|
+
computer_20251124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
472
472
|
action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot" | "zoom";
|
|
473
473
|
coordinate?: [number, number];
|
|
474
474
|
duration?: number;
|
|
@@ -491,7 +491,7 @@ declare const anthropicTools: {
|
|
|
491
491
|
*
|
|
492
492
|
* Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
|
|
493
493
|
*/
|
|
494
|
-
memory_20250818: _ai_sdk_provider_utils.
|
|
494
|
+
memory_20250818: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
495
495
|
command: "view";
|
|
496
496
|
path: string;
|
|
497
497
|
view_range?: [number, number];
|
|
@@ -524,7 +524,7 @@ declare const anthropicTools: {
|
|
|
524
524
|
*
|
|
525
525
|
* Supported models: Claude Sonnet 3.5
|
|
526
526
|
*/
|
|
527
|
-
textEditor_20241022: _ai_sdk_provider_utils.
|
|
527
|
+
textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
528
528
|
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
529
529
|
path: string;
|
|
530
530
|
file_text?: string;
|
|
@@ -541,7 +541,7 @@ declare const anthropicTools: {
|
|
|
541
541
|
*
|
|
542
542
|
* Supported models: Claude Sonnet 3.7
|
|
543
543
|
*/
|
|
544
|
-
textEditor_20250124: _ai_sdk_provider_utils.
|
|
544
|
+
textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
545
545
|
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
546
546
|
path: string;
|
|
547
547
|
file_text?: string;
|
|
@@ -560,7 +560,7 @@ declare const anthropicTools: {
|
|
|
560
560
|
*
|
|
561
561
|
* @deprecated Use textEditor_20250728 instead
|
|
562
562
|
*/
|
|
563
|
-
textEditor_20250429: _ai_sdk_provider_utils.
|
|
563
|
+
textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
564
564
|
command: "view" | "create" | "str_replace" | "insert";
|
|
565
565
|
path: string;
|
|
566
566
|
file_text?: string;
|
|
@@ -581,7 +581,7 @@ declare const anthropicTools: {
|
|
|
581
581
|
*
|
|
582
582
|
* @param maxCharacters - Optional maximum number of characters to view in the file
|
|
583
583
|
*/
|
|
584
|
-
textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.
|
|
584
|
+
textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
585
585
|
command: "view" | "create" | "str_replace" | "insert";
|
|
586
586
|
path: string;
|
|
587
587
|
file_text?: string;
|
|
@@ -611,7 +611,7 @@ declare const anthropicTools: {
|
|
|
611
611
|
* @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
|
|
612
612
|
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
613
613
|
*/
|
|
614
|
-
webFetch_20250910: (args?: Parameters<_ai_sdk_provider_utils.
|
|
614
|
+
webFetch_20250910: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
615
615
|
url: string;
|
|
616
616
|
}, {
|
|
617
617
|
type: "web_fetch_result";
|
|
@@ -673,7 +673,7 @@ declare const anthropicTools: {
|
|
|
673
673
|
* @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
|
|
674
674
|
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
675
675
|
*/
|
|
676
|
-
webFetch_20260209: (args?: Parameters<_ai_sdk_provider_utils.
|
|
676
|
+
webFetch_20260209: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
677
677
|
url: string;
|
|
678
678
|
}, {
|
|
679
679
|
type: "web_fetch_result";
|
|
@@ -734,7 +734,7 @@ declare const anthropicTools: {
|
|
|
734
734
|
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
735
735
|
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
736
736
|
*/
|
|
737
|
-
webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.
|
|
737
|
+
webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
738
738
|
query: string;
|
|
739
739
|
}, {
|
|
740
740
|
type: "web_search_result";
|
|
@@ -770,7 +770,7 @@ declare const anthropicTools: {
|
|
|
770
770
|
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
771
771
|
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
772
772
|
*/
|
|
773
|
-
webSearch_20260209: (args?: Parameters<_ai_sdk_provider_utils.
|
|
773
|
+
webSearch_20260209: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
774
774
|
query: string;
|
|
775
775
|
}, {
|
|
776
776
|
type: "web_search_result";
|
|
@@ -811,7 +811,7 @@ declare const anthropicTools: {
|
|
|
811
811
|
*
|
|
812
812
|
* Supported models: Claude Opus 4.5, Claude Sonnet 4.5
|
|
813
813
|
*/
|
|
814
|
-
toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.
|
|
814
|
+
toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
815
815
|
pattern: string;
|
|
816
816
|
limit?: number;
|
|
817
817
|
}, {
|
|
@@ -837,7 +837,7 @@ declare const anthropicTools: {
|
|
|
837
837
|
*
|
|
838
838
|
* Supported models: Claude Opus 4.5, Claude Sonnet 4.5
|
|
839
839
|
*/
|
|
840
|
-
toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.
|
|
840
|
+
toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
841
841
|
query: string;
|
|
842
842
|
limit?: number;
|
|
843
843
|
}, {
|
|
@@ -993,4 +993,4 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
|
|
|
993
993
|
betas: Set<string>;
|
|
994
994
|
}>;
|
|
995
995
|
|
|
996
|
-
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools };
|
|
996
|
+
export { AnthropicLanguageModel, AnthropicLanguageModel as AnthropicMessagesLanguageModel, type AnthropicModelId as AnthropicMessagesModelId, type AnthropicModelId, anthropicTools, getModelCapabilities, prepareTools };
|