@fairyhunter13/ai-anthropic 3.0.58-fork.2 → 3.0.58-fork.21

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.
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, JSONSchema7, SharedV3ProviderMetadata, SharedV3Warning } from '@ai-sdk/provider';
1
+ import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, JSONSchema7, SharedV4ProviderMetadata, SharedV4Warning } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
@@ -11,15 +11,20 @@ type AnthropicMessagesConfig = {
11
11
  fetch?: FetchFunction;
12
12
  buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
13
13
  transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
14
- supportedUrls?: () => LanguageModelV3['supportedUrls'];
14
+ supportedUrls?: () => LanguageModelV4['supportedUrls'];
15
15
  generateId?: () => string;
16
16
  /**
17
17
  * When false, the model will use JSON tool fallback for structured outputs.
18
18
  */
19
19
  supportsNativeStructuredOutput?: boolean;
20
+ /**
21
+ * When false, `strict` on tool definitions will be ignored and a warning emitted.
22
+ * Defaults to true.
23
+ */
24
+ supportsStrictTools?: boolean;
20
25
  };
21
- declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
22
- readonly specificationVersion = "v3";
26
+ declare class AnthropicMessagesLanguageModel implements LanguageModelV4 {
27
+ readonly specificationVersion = "v4";
23
28
  readonly modelId: AnthropicMessagesModelId;
24
29
  private readonly config;
25
30
  private readonly generateId;
@@ -38,9 +43,21 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
38
43
  private buildRequestUrl;
39
44
  private transformRequestBody;
40
45
  private extractCitationDocuments;
41
- doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
42
- doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
46
+ doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
47
+ doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
43
48
  }
49
+ /**
50
+ * Returns the capabilities of a Claude model that are used for defaults and feature selection.
51
+ *
52
+ * @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
53
+ * @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
54
+ */
55
+ declare function getModelCapabilities(modelId: string): {
56
+ maxOutputTokens: number;
57
+ supportsStructuredOutput: boolean;
58
+ supportsAdaptiveThinking: boolean;
59
+ isKnownModel: boolean;
60
+ };
44
61
 
45
62
  declare const anthropicTools: {
46
63
  /**
@@ -699,6 +716,78 @@ declare const anthropicTools: {
699
716
  };
700
717
  retrievedAt: string | null;
701
718
  }>;
719
+ /**
720
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
721
+ * GA version (no beta header required). Includes caller restrictions, cache control,
722
+ * deferred loading, and strict mode.
723
+ *
724
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
725
+ * @param allowedDomains - Only fetch from these domains
726
+ * @param blockedDomains - Never fetch from these domains
727
+ * @param citations - Citations configuration for fetched documents
728
+ * @param maxContentTokens - Max content tokens included in context
729
+ * @param allowedCallers - Restrict callers (e.g. ["direct"] to prevent code_execution usage)
730
+ * @param useCache - Whether to use cached content (set false for fresh content)
731
+ * @param deferLoading - Defer loading until tool_search discovers it
732
+ * @param strict - Enable strict schema validation
733
+ */
734
+ webFetch_20260309: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
735
+ url: string;
736
+ }, {
737
+ type: "web_fetch_result";
738
+ url: string;
739
+ content: {
740
+ type: "document";
741
+ title: string | null;
742
+ citations?: {
743
+ enabled: boolean;
744
+ };
745
+ source: {
746
+ type: "base64";
747
+ mediaType: "application/pdf";
748
+ data: string;
749
+ } | {
750
+ type: "text";
751
+ mediaType: "text/plain";
752
+ data: string;
753
+ };
754
+ };
755
+ retrievedAt: string | null;
756
+ }, {
757
+ maxUses?: number;
758
+ allowedDomains?: string[];
759
+ blockedDomains?: string[];
760
+ citations?: {
761
+ enabled: boolean;
762
+ };
763
+ maxContentTokens?: number;
764
+ allowedCallers?: Array<"direct" | "code_execution_20250825" | "code_execution_20260120">;
765
+ useCache?: boolean;
766
+ deferLoading?: boolean;
767
+ strict?: boolean;
768
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
769
+ url: string;
770
+ }, {
771
+ type: "web_fetch_result";
772
+ url: string;
773
+ content: {
774
+ type: "document";
775
+ title: string | null;
776
+ citations?: {
777
+ enabled: boolean;
778
+ };
779
+ source: {
780
+ type: "base64";
781
+ mediaType: "application/pdf";
782
+ data: string;
783
+ } | {
784
+ type: "text";
785
+ mediaType: "text/plain";
786
+ data: string;
787
+ };
788
+ };
789
+ retrievedAt: string | null;
790
+ }>;
702
791
  /**
703
792
  * Creates a web search tool that gives Claude direct access to real-time web content.
704
793
  *
@@ -762,6 +851,7 @@ declare const anthropicTools: {
762
851
  country?: string;
763
852
  timezone?: string;
764
853
  };
854
+ allowedCallers?: Array<"direct" | "code_execution_20250825" | "code_execution_20260120">;
765
855
  }>>[0]) => _ai_sdk_provider_utils.Tool<{
766
856
  query: string;
767
857
  }, {
@@ -901,6 +991,21 @@ type AnthropicTool = {
901
991
  };
902
992
  max_content_tokens?: number;
903
993
  cache_control: AnthropicCacheControl | undefined;
994
+ } | {
995
+ type: 'web_fetch_20260309';
996
+ name: string;
997
+ max_uses?: number;
998
+ allowed_domains?: string[];
999
+ blocked_domains?: string[];
1000
+ citations?: {
1001
+ enabled: boolean;
1002
+ };
1003
+ max_content_tokens?: number;
1004
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1005
+ use_cache?: boolean;
1006
+ defer_loading?: boolean;
1007
+ strict?: boolean;
1008
+ cache_control: AnthropicCacheControl | undefined;
904
1009
  } | {
905
1010
  type: 'web_search_20250305' | 'web_search_20260209';
906
1011
  name: string;
@@ -914,6 +1019,7 @@ type AnthropicTool = {
914
1019
  country?: string;
915
1020
  timezone?: string;
916
1021
  };
1022
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
917
1023
  cache_control: AnthropicCacheControl | undefined;
918
1024
  } | {
919
1025
  type: 'tool_search_tool_regex_20251119';
@@ -934,27 +1040,31 @@ type AnthropicToolChoice = {
934
1040
  declare class CacheControlValidator {
935
1041
  private breakpointCount;
936
1042
  private warnings;
937
- getCacheControl(providerMetadata: SharedV3ProviderMetadata | undefined, context: {
1043
+ getCacheControl(providerMetadata: SharedV4ProviderMetadata | undefined, context: {
938
1044
  type: string;
939
1045
  canCache: boolean;
940
1046
  }): AnthropicCacheControl | undefined;
941
- getWarnings(): SharedV3Warning[];
1047
+ getWarnings(): SharedV4Warning[];
942
1048
  }
943
1049
 
944
- declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, }: {
945
- tools: LanguageModelV3CallOptions['tools'];
946
- toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
1050
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, }: {
1051
+ tools: LanguageModelV4CallOptions['tools'];
1052
+ toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
947
1053
  disableParallelToolUse?: boolean;
948
1054
  cacheControlValidator?: CacheControlValidator;
949
1055
  /**
950
- * Whether the model supports structured output.
1056
+ * Whether the model supports native structured output response format.
951
1057
  */
952
1058
  supportsStructuredOutput: boolean;
1059
+ /**
1060
+ * Whether the model supports strict mode on tool definitions.
1061
+ */
1062
+ supportsStrictTools: boolean;
953
1063
  }): Promise<{
954
1064
  tools: Array<AnthropicTool> | undefined;
955
1065
  toolChoice: AnthropicToolChoice | undefined;
956
- toolWarnings: SharedV3Warning[];
1066
+ toolWarnings: SharedV4Warning[];
957
1067
  betas: Set<string>;
958
1068
  }>;
959
1069
 
960
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
1070
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools };
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, JSONSchema7, SharedV3ProviderMetadata, SharedV3Warning } from '@ai-sdk/provider';
1
+ import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, JSONSchema7, SharedV4ProviderMetadata, SharedV4Warning } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
@@ -11,15 +11,20 @@ type AnthropicMessagesConfig = {
11
11
  fetch?: FetchFunction;
12
12
  buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
13
13
  transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
14
- supportedUrls?: () => LanguageModelV3['supportedUrls'];
14
+ supportedUrls?: () => LanguageModelV4['supportedUrls'];
15
15
  generateId?: () => string;
16
16
  /**
17
17
  * When false, the model will use JSON tool fallback for structured outputs.
18
18
  */
19
19
  supportsNativeStructuredOutput?: boolean;
20
+ /**
21
+ * When false, `strict` on tool definitions will be ignored and a warning emitted.
22
+ * Defaults to true.
23
+ */
24
+ supportsStrictTools?: boolean;
20
25
  };
21
- declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
22
- readonly specificationVersion = "v3";
26
+ declare class AnthropicMessagesLanguageModel implements LanguageModelV4 {
27
+ readonly specificationVersion = "v4";
23
28
  readonly modelId: AnthropicMessagesModelId;
24
29
  private readonly config;
25
30
  private readonly generateId;
@@ -38,9 +43,21 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
38
43
  private buildRequestUrl;
39
44
  private transformRequestBody;
40
45
  private extractCitationDocuments;
41
- doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
42
- doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
46
+ doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
47
+ doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
43
48
  }
49
+ /**
50
+ * Returns the capabilities of a Claude model that are used for defaults and feature selection.
51
+ *
52
+ * @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
53
+ * @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
54
+ */
55
+ declare function getModelCapabilities(modelId: string): {
56
+ maxOutputTokens: number;
57
+ supportsStructuredOutput: boolean;
58
+ supportsAdaptiveThinking: boolean;
59
+ isKnownModel: boolean;
60
+ };
44
61
 
45
62
  declare const anthropicTools: {
46
63
  /**
@@ -699,6 +716,78 @@ declare const anthropicTools: {
699
716
  };
700
717
  retrievedAt: string | null;
701
718
  }>;
719
+ /**
720
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
721
+ * GA version (no beta header required). Includes caller restrictions, cache control,
722
+ * deferred loading, and strict mode.
723
+ *
724
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
725
+ * @param allowedDomains - Only fetch from these domains
726
+ * @param blockedDomains - Never fetch from these domains
727
+ * @param citations - Citations configuration for fetched documents
728
+ * @param maxContentTokens - Max content tokens included in context
729
+ * @param allowedCallers - Restrict callers (e.g. ["direct"] to prevent code_execution usage)
730
+ * @param useCache - Whether to use cached content (set false for fresh content)
731
+ * @param deferLoading - Defer loading until tool_search discovers it
732
+ * @param strict - Enable strict schema validation
733
+ */
734
+ webFetch_20260309: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
735
+ url: string;
736
+ }, {
737
+ type: "web_fetch_result";
738
+ url: string;
739
+ content: {
740
+ type: "document";
741
+ title: string | null;
742
+ citations?: {
743
+ enabled: boolean;
744
+ };
745
+ source: {
746
+ type: "base64";
747
+ mediaType: "application/pdf";
748
+ data: string;
749
+ } | {
750
+ type: "text";
751
+ mediaType: "text/plain";
752
+ data: string;
753
+ };
754
+ };
755
+ retrievedAt: string | null;
756
+ }, {
757
+ maxUses?: number;
758
+ allowedDomains?: string[];
759
+ blockedDomains?: string[];
760
+ citations?: {
761
+ enabled: boolean;
762
+ };
763
+ maxContentTokens?: number;
764
+ allowedCallers?: Array<"direct" | "code_execution_20250825" | "code_execution_20260120">;
765
+ useCache?: boolean;
766
+ deferLoading?: boolean;
767
+ strict?: boolean;
768
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
769
+ url: string;
770
+ }, {
771
+ type: "web_fetch_result";
772
+ url: string;
773
+ content: {
774
+ type: "document";
775
+ title: string | null;
776
+ citations?: {
777
+ enabled: boolean;
778
+ };
779
+ source: {
780
+ type: "base64";
781
+ mediaType: "application/pdf";
782
+ data: string;
783
+ } | {
784
+ type: "text";
785
+ mediaType: "text/plain";
786
+ data: string;
787
+ };
788
+ };
789
+ retrievedAt: string | null;
790
+ }>;
702
791
  /**
703
792
  * Creates a web search tool that gives Claude direct access to real-time web content.
704
793
  *
@@ -762,6 +851,7 @@ declare const anthropicTools: {
762
851
  country?: string;
763
852
  timezone?: string;
764
853
  };
854
+ allowedCallers?: Array<"direct" | "code_execution_20250825" | "code_execution_20260120">;
765
855
  }>>[0]) => _ai_sdk_provider_utils.Tool<{
766
856
  query: string;
767
857
  }, {
@@ -901,6 +991,21 @@ type AnthropicTool = {
901
991
  };
902
992
  max_content_tokens?: number;
903
993
  cache_control: AnthropicCacheControl | undefined;
994
+ } | {
995
+ type: 'web_fetch_20260309';
996
+ name: string;
997
+ max_uses?: number;
998
+ allowed_domains?: string[];
999
+ blocked_domains?: string[];
1000
+ citations?: {
1001
+ enabled: boolean;
1002
+ };
1003
+ max_content_tokens?: number;
1004
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1005
+ use_cache?: boolean;
1006
+ defer_loading?: boolean;
1007
+ strict?: boolean;
1008
+ cache_control: AnthropicCacheControl | undefined;
904
1009
  } | {
905
1010
  type: 'web_search_20250305' | 'web_search_20260209';
906
1011
  name: string;
@@ -914,6 +1019,7 @@ type AnthropicTool = {
914
1019
  country?: string;
915
1020
  timezone?: string;
916
1021
  };
1022
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
917
1023
  cache_control: AnthropicCacheControl | undefined;
918
1024
  } | {
919
1025
  type: 'tool_search_tool_regex_20251119';
@@ -934,27 +1040,31 @@ type AnthropicToolChoice = {
934
1040
  declare class CacheControlValidator {
935
1041
  private breakpointCount;
936
1042
  private warnings;
937
- getCacheControl(providerMetadata: SharedV3ProviderMetadata | undefined, context: {
1043
+ getCacheControl(providerMetadata: SharedV4ProviderMetadata | undefined, context: {
938
1044
  type: string;
939
1045
  canCache: boolean;
940
1046
  }): AnthropicCacheControl | undefined;
941
- getWarnings(): SharedV3Warning[];
1047
+ getWarnings(): SharedV4Warning[];
942
1048
  }
943
1049
 
944
- declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, }: {
945
- tools: LanguageModelV3CallOptions['tools'];
946
- toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
1050
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, }: {
1051
+ tools: LanguageModelV4CallOptions['tools'];
1052
+ toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
947
1053
  disableParallelToolUse?: boolean;
948
1054
  cacheControlValidator?: CacheControlValidator;
949
1055
  /**
950
- * Whether the model supports structured output.
1056
+ * Whether the model supports native structured output response format.
951
1057
  */
952
1058
  supportsStructuredOutput: boolean;
1059
+ /**
1060
+ * Whether the model supports strict mode on tool definitions.
1061
+ */
1062
+ supportsStrictTools: boolean;
953
1063
  }): Promise<{
954
1064
  tools: Array<AnthropicTool> | undefined;
955
1065
  toolChoice: AnthropicToolChoice | undefined;
956
- toolWarnings: SharedV3Warning[];
1066
+ toolWarnings: SharedV4Warning[];
957
1067
  betas: Set<string>;
958
1068
  }>;
959
1069
 
960
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
1070
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools };