@ai-sdk/anthropic 3.0.53 → 3.0.55
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 +12 -0
- package/dist/index.d.mts +116 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.js +743 -451
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +728 -428
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +118 -2
- package/dist/internal/index.d.ts +118 -2
- package/dist/internal/index.js +736 -444
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +727 -427
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +61 -2
- package/src/anthropic-messages-language-model.ts +93 -1
- package/src/anthropic-prepare-tools.ts +37 -0
- package/src/anthropic-tools.ts +23 -0
- package/src/convert-to-anthropic-messages-prompt.ts +37 -3
- package/src/tool/code-execution_20260120.ts +38 -0
- package/src/tool/web-fetch-20260209.ts +145 -0
- package/src/tool/web-search_20260209.ts +136 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 3.0.55
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7531e72: fix(provider/anthropic): handle encrypted_code_execution_result for multi-turn with web_fetch/web_search 20260209
|
|
8
|
+
|
|
9
|
+
## 3.0.54
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 56c67d5: feat(provider/anthropic): add support for Anthropic web tools `web_fetch_20260209` and `web_search_20260209`
|
|
14
|
+
|
|
3
15
|
## 3.0.53
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -451,6 +451,15 @@ declare const anthropicTools: {
|
|
|
451
451
|
type: "code_execution_output";
|
|
452
452
|
file_id: string;
|
|
453
453
|
}>;
|
|
454
|
+
} | {
|
|
455
|
+
type: "encrypted_code_execution_result";
|
|
456
|
+
encrypted_stdout: string;
|
|
457
|
+
stderr: string;
|
|
458
|
+
return_code: number;
|
|
459
|
+
content: Array<{
|
|
460
|
+
type: "code_execution_output";
|
|
461
|
+
file_id: string;
|
|
462
|
+
}>;
|
|
454
463
|
} | {
|
|
455
464
|
type: "bash_code_execution_result";
|
|
456
465
|
content: Array<{
|
|
@@ -513,6 +522,15 @@ declare const anthropicTools: {
|
|
|
513
522
|
type: "code_execution_output";
|
|
514
523
|
file_id: string;
|
|
515
524
|
}>;
|
|
525
|
+
} | {
|
|
526
|
+
type: "encrypted_code_execution_result";
|
|
527
|
+
encrypted_stdout: string;
|
|
528
|
+
stderr: string;
|
|
529
|
+
return_code: number;
|
|
530
|
+
content: Array<{
|
|
531
|
+
type: "code_execution_output";
|
|
532
|
+
file_id: string;
|
|
533
|
+
}>;
|
|
516
534
|
} | {
|
|
517
535
|
type: "bash_code_execution_result";
|
|
518
536
|
content: Array<{
|
|
@@ -799,6 +817,68 @@ declare const anthropicTools: {
|
|
|
799
817
|
};
|
|
800
818
|
retrievedAt: string | null;
|
|
801
819
|
}>;
|
|
820
|
+
/**
|
|
821
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
822
|
+
*
|
|
823
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
824
|
+
* @param allowedDomains - Only fetch from these domains
|
|
825
|
+
* @param blockedDomains - Never fetch from these domains
|
|
826
|
+
* @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.
|
|
827
|
+
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
828
|
+
*/
|
|
829
|
+
webFetch_20260209: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
830
|
+
url: string;
|
|
831
|
+
}, {
|
|
832
|
+
type: "web_fetch_result";
|
|
833
|
+
url: string;
|
|
834
|
+
content: {
|
|
835
|
+
type: "document";
|
|
836
|
+
title: string | null;
|
|
837
|
+
citations?: {
|
|
838
|
+
enabled: boolean;
|
|
839
|
+
};
|
|
840
|
+
source: {
|
|
841
|
+
type: "base64";
|
|
842
|
+
mediaType: "application/pdf";
|
|
843
|
+
data: string;
|
|
844
|
+
} | {
|
|
845
|
+
type: "text";
|
|
846
|
+
mediaType: "text/plain";
|
|
847
|
+
data: string;
|
|
848
|
+
};
|
|
849
|
+
};
|
|
850
|
+
retrievedAt: string | null;
|
|
851
|
+
}, {
|
|
852
|
+
maxUses?: number;
|
|
853
|
+
allowedDomains?: string[];
|
|
854
|
+
blockedDomains?: string[];
|
|
855
|
+
citations?: {
|
|
856
|
+
enabled: boolean;
|
|
857
|
+
};
|
|
858
|
+
maxContentTokens?: number;
|
|
859
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
860
|
+
url: string;
|
|
861
|
+
}, {
|
|
862
|
+
type: "web_fetch_result";
|
|
863
|
+
url: string;
|
|
864
|
+
content: {
|
|
865
|
+
type: "document";
|
|
866
|
+
title: string | null;
|
|
867
|
+
citations?: {
|
|
868
|
+
enabled: boolean;
|
|
869
|
+
};
|
|
870
|
+
source: {
|
|
871
|
+
type: "base64";
|
|
872
|
+
mediaType: "application/pdf";
|
|
873
|
+
data: string;
|
|
874
|
+
} | {
|
|
875
|
+
type: "text";
|
|
876
|
+
mediaType: "text/plain";
|
|
877
|
+
data: string;
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
retrievedAt: string | null;
|
|
881
|
+
}>;
|
|
802
882
|
/**
|
|
803
883
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
804
884
|
*
|
|
@@ -835,6 +915,42 @@ declare const anthropicTools: {
|
|
|
835
915
|
pageAge: string | null;
|
|
836
916
|
encryptedContent: string;
|
|
837
917
|
}[]>;
|
|
918
|
+
/**
|
|
919
|
+
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
920
|
+
*
|
|
921
|
+
* @param maxUses - Maximum number of web searches Claude can perform during the conversation.
|
|
922
|
+
* @param allowedDomains - Optional list of domains that Claude is allowed to search.
|
|
923
|
+
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
924
|
+
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
925
|
+
*/
|
|
926
|
+
webSearch_20260209: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
927
|
+
query: string;
|
|
928
|
+
}, {
|
|
929
|
+
type: "web_search_result";
|
|
930
|
+
url: string;
|
|
931
|
+
title: string | null;
|
|
932
|
+
pageAge: string | null;
|
|
933
|
+
encryptedContent: string;
|
|
934
|
+
}[], {
|
|
935
|
+
maxUses?: number;
|
|
936
|
+
allowedDomains?: string[];
|
|
937
|
+
blockedDomains?: string[];
|
|
938
|
+
userLocation?: {
|
|
939
|
+
type: "approximate";
|
|
940
|
+
city?: string;
|
|
941
|
+
region?: string;
|
|
942
|
+
country?: string;
|
|
943
|
+
timezone?: string;
|
|
944
|
+
};
|
|
945
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
946
|
+
query: string;
|
|
947
|
+
}, {
|
|
948
|
+
type: "web_search_result";
|
|
949
|
+
url: string;
|
|
950
|
+
title: string | null;
|
|
951
|
+
pageAge: string | null;
|
|
952
|
+
encryptedContent: string;
|
|
953
|
+
}[]>;
|
|
838
954
|
/**
|
|
839
955
|
* Creates a tool search tool that uses regex patterns to find tools.
|
|
840
956
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -451,6 +451,15 @@ declare const anthropicTools: {
|
|
|
451
451
|
type: "code_execution_output";
|
|
452
452
|
file_id: string;
|
|
453
453
|
}>;
|
|
454
|
+
} | {
|
|
455
|
+
type: "encrypted_code_execution_result";
|
|
456
|
+
encrypted_stdout: string;
|
|
457
|
+
stderr: string;
|
|
458
|
+
return_code: number;
|
|
459
|
+
content: Array<{
|
|
460
|
+
type: "code_execution_output";
|
|
461
|
+
file_id: string;
|
|
462
|
+
}>;
|
|
454
463
|
} | {
|
|
455
464
|
type: "bash_code_execution_result";
|
|
456
465
|
content: Array<{
|
|
@@ -513,6 +522,15 @@ declare const anthropicTools: {
|
|
|
513
522
|
type: "code_execution_output";
|
|
514
523
|
file_id: string;
|
|
515
524
|
}>;
|
|
525
|
+
} | {
|
|
526
|
+
type: "encrypted_code_execution_result";
|
|
527
|
+
encrypted_stdout: string;
|
|
528
|
+
stderr: string;
|
|
529
|
+
return_code: number;
|
|
530
|
+
content: Array<{
|
|
531
|
+
type: "code_execution_output";
|
|
532
|
+
file_id: string;
|
|
533
|
+
}>;
|
|
516
534
|
} | {
|
|
517
535
|
type: "bash_code_execution_result";
|
|
518
536
|
content: Array<{
|
|
@@ -799,6 +817,68 @@ declare const anthropicTools: {
|
|
|
799
817
|
};
|
|
800
818
|
retrievedAt: string | null;
|
|
801
819
|
}>;
|
|
820
|
+
/**
|
|
821
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
822
|
+
*
|
|
823
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
824
|
+
* @param allowedDomains - Only fetch from these domains
|
|
825
|
+
* @param blockedDomains - Never fetch from these domains
|
|
826
|
+
* @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.
|
|
827
|
+
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
828
|
+
*/
|
|
829
|
+
webFetch_20260209: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
830
|
+
url: string;
|
|
831
|
+
}, {
|
|
832
|
+
type: "web_fetch_result";
|
|
833
|
+
url: string;
|
|
834
|
+
content: {
|
|
835
|
+
type: "document";
|
|
836
|
+
title: string | null;
|
|
837
|
+
citations?: {
|
|
838
|
+
enabled: boolean;
|
|
839
|
+
};
|
|
840
|
+
source: {
|
|
841
|
+
type: "base64";
|
|
842
|
+
mediaType: "application/pdf";
|
|
843
|
+
data: string;
|
|
844
|
+
} | {
|
|
845
|
+
type: "text";
|
|
846
|
+
mediaType: "text/plain";
|
|
847
|
+
data: string;
|
|
848
|
+
};
|
|
849
|
+
};
|
|
850
|
+
retrievedAt: string | null;
|
|
851
|
+
}, {
|
|
852
|
+
maxUses?: number;
|
|
853
|
+
allowedDomains?: string[];
|
|
854
|
+
blockedDomains?: string[];
|
|
855
|
+
citations?: {
|
|
856
|
+
enabled: boolean;
|
|
857
|
+
};
|
|
858
|
+
maxContentTokens?: number;
|
|
859
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
860
|
+
url: string;
|
|
861
|
+
}, {
|
|
862
|
+
type: "web_fetch_result";
|
|
863
|
+
url: string;
|
|
864
|
+
content: {
|
|
865
|
+
type: "document";
|
|
866
|
+
title: string | null;
|
|
867
|
+
citations?: {
|
|
868
|
+
enabled: boolean;
|
|
869
|
+
};
|
|
870
|
+
source: {
|
|
871
|
+
type: "base64";
|
|
872
|
+
mediaType: "application/pdf";
|
|
873
|
+
data: string;
|
|
874
|
+
} | {
|
|
875
|
+
type: "text";
|
|
876
|
+
mediaType: "text/plain";
|
|
877
|
+
data: string;
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
retrievedAt: string | null;
|
|
881
|
+
}>;
|
|
802
882
|
/**
|
|
803
883
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
804
884
|
*
|
|
@@ -835,6 +915,42 @@ declare const anthropicTools: {
|
|
|
835
915
|
pageAge: string | null;
|
|
836
916
|
encryptedContent: string;
|
|
837
917
|
}[]>;
|
|
918
|
+
/**
|
|
919
|
+
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
920
|
+
*
|
|
921
|
+
* @param maxUses - Maximum number of web searches Claude can perform during the conversation.
|
|
922
|
+
* @param allowedDomains - Optional list of domains that Claude is allowed to search.
|
|
923
|
+
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
924
|
+
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
925
|
+
*/
|
|
926
|
+
webSearch_20260209: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
927
|
+
query: string;
|
|
928
|
+
}, {
|
|
929
|
+
type: "web_search_result";
|
|
930
|
+
url: string;
|
|
931
|
+
title: string | null;
|
|
932
|
+
pageAge: string | null;
|
|
933
|
+
encryptedContent: string;
|
|
934
|
+
}[], {
|
|
935
|
+
maxUses?: number;
|
|
936
|
+
allowedDomains?: string[];
|
|
937
|
+
blockedDomains?: string[];
|
|
938
|
+
userLocation?: {
|
|
939
|
+
type: "approximate";
|
|
940
|
+
city?: string;
|
|
941
|
+
region?: string;
|
|
942
|
+
country?: string;
|
|
943
|
+
timezone?: string;
|
|
944
|
+
};
|
|
945
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
946
|
+
query: string;
|
|
947
|
+
}, {
|
|
948
|
+
type: "web_search_result";
|
|
949
|
+
url: string;
|
|
950
|
+
title: string | null;
|
|
951
|
+
pageAge: string | null;
|
|
952
|
+
encryptedContent: string;
|
|
953
|
+
}[]>;
|
|
838
954
|
/**
|
|
839
955
|
* Creates a tool search tool that uses regex patterns to find tools.
|
|
840
956
|
*
|