@ai-sdk/anthropic 3.0.119 → 3.0.120
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 +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +834 -458
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +826 -446
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +74 -2
- package/dist/internal/index.d.ts +74 -2
- package/dist/internal/index.js +827 -451
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +825 -445
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +125 -14
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +23 -0
- package/src/anthropic-messages-language-model.ts +264 -6
- package/src/anthropic-messages-options.ts +12 -2
- package/src/anthropic-prepare-tools.ts +76 -0
- package/src/anthropic-tools.ts +25 -0
- package/src/convert-to-anthropic-messages-prompt.ts +77 -1
- package/src/tool/computer-toolset_20260801.ts +165 -0
|
@@ -2,7 +2,7 @@ import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateRes
|
|
|
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
|
|
|
5
|
-
type AnthropicMessagesModelId = '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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
|
|
5
|
+
type AnthropicMessagesModelId = '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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
|
|
6
6
|
|
|
7
7
|
type AnthropicMessagesConfig = {
|
|
8
8
|
provider: string;
|
|
@@ -57,9 +57,26 @@ declare function getModelCapabilities(modelId: string): {
|
|
|
57
57
|
supportsStructuredOutput: boolean;
|
|
58
58
|
rejectsSamplingParameters: boolean;
|
|
59
59
|
rejectsThinkingDisabledAboveHighEffort: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Thinking is always adaptive: `thinking.type` `disabled` and `enabled`
|
|
62
|
+
* are rejected with a 400.
|
|
63
|
+
*/
|
|
64
|
+
rejectsThinkingDisabled: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Forced tool use (`tool_choice` `any` or a named tool) is rejected with a 400.
|
|
67
|
+
*/
|
|
68
|
+
rejectsForcedToolUse: boolean;
|
|
60
69
|
isKnownModel: boolean;
|
|
61
70
|
};
|
|
62
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Member tools of the computer toolset. Each member is returned by the API as
|
|
74
|
+
* its own `tool_use` block; the AI SDK exposes it as the `action` of a single
|
|
75
|
+
* computer tool call.
|
|
76
|
+
*/
|
|
77
|
+
declare const computerToolset_20260801Members: readonly ["screenshot", "zoom", "left_click", "right_click", "middle_click", "double_click", "triple_click", "left_click_drag", "mouse_move", "left_mouse_down", "left_mouse_up", "cursor_position", "scroll", "type", "key", "hold_key", "wait"];
|
|
78
|
+
type ComputerToolset_20260801Member = (typeof computerToolset_20260801Members)[number];
|
|
79
|
+
|
|
63
80
|
declare const anthropicTools: {
|
|
64
81
|
/**
|
|
65
82
|
* Pairs a faster executor model with a higher-intelligence advisor model
|
|
@@ -528,6 +545,44 @@ declare const anthropicTools: {
|
|
|
528
545
|
displayNumber?: number;
|
|
529
546
|
enableZoom?: boolean;
|
|
530
547
|
}>;
|
|
548
|
+
/**
|
|
549
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
550
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
551
|
+
* (`computer_20251124` and earlier) on newer models.
|
|
552
|
+
*
|
|
553
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
554
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
555
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
556
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
557
|
+
* in one turn.
|
|
558
|
+
*
|
|
559
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
560
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
561
|
+
*
|
|
562
|
+
* Does not require a beta header.
|
|
563
|
+
*
|
|
564
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
565
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
566
|
+
*
|
|
567
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
568
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
569
|
+
*/
|
|
570
|
+
computerToolset_20260801: _ai_sdk_provider_utils.ProviderToolFactory<{
|
|
571
|
+
action: ComputerToolset_20260801Member;
|
|
572
|
+
coordinate?: [number, number];
|
|
573
|
+
duration?: number;
|
|
574
|
+
region?: [number, number, number, number];
|
|
575
|
+
repeat?: number;
|
|
576
|
+
scroll_amount?: number;
|
|
577
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
578
|
+
start_coordinate?: [number, number];
|
|
579
|
+
text?: string;
|
|
580
|
+
}, {
|
|
581
|
+
configs?: Partial<Record<ComputerToolset_20260801Member, {
|
|
582
|
+
enabled?: boolean;
|
|
583
|
+
deferLoading?: boolean;
|
|
584
|
+
}>>;
|
|
585
|
+
}>;
|
|
531
586
|
/**
|
|
532
587
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
533
588
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -946,6 +1001,17 @@ type AnthropicTool = {
|
|
|
946
1001
|
display_number: number;
|
|
947
1002
|
enable_zoom?: boolean;
|
|
948
1003
|
cache_control: AnthropicCacheControl | undefined;
|
|
1004
|
+
} | {
|
|
1005
|
+
/**
|
|
1006
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
1007
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
1008
|
+
*/
|
|
1009
|
+
type: 'computer_toolset_20260801';
|
|
1010
|
+
configs?: Record<string, {
|
|
1011
|
+
enabled?: boolean;
|
|
1012
|
+
defer_loading?: boolean;
|
|
1013
|
+
}>;
|
|
1014
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
949
1015
|
} | {
|
|
950
1016
|
name: string;
|
|
951
1017
|
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
@@ -1022,7 +1088,7 @@ declare class CacheControlValidator {
|
|
|
1022
1088
|
getWarnings(): SharedV3Warning[];
|
|
1023
1089
|
}
|
|
1024
1090
|
|
|
1025
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, }: {
|
|
1091
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, rejectsForcedToolUse, }: {
|
|
1026
1092
|
tools: LanguageModelV3CallOptions['tools'];
|
|
1027
1093
|
toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
|
|
1028
1094
|
disableParallelToolUse?: boolean;
|
|
@@ -1040,6 +1106,12 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
|
|
|
1040
1106
|
* it explicitly. Driven by the model-level `toolStreaming` option.
|
|
1041
1107
|
*/
|
|
1042
1108
|
defaultEagerInputStreaming?: boolean;
|
|
1109
|
+
/**
|
|
1110
|
+
* Whether the model rejects forced tool use (`tool_choice` `any` or a
|
|
1111
|
+
* named tool). When true, `required` and `tool` tool choices fall back to
|
|
1112
|
+
* `auto` with a warning.
|
|
1113
|
+
*/
|
|
1114
|
+
rejectsForcedToolUse?: boolean;
|
|
1043
1115
|
}): Promise<{
|
|
1044
1116
|
tools: Array<AnthropicTool> | undefined;
|
|
1045
1117
|
toolChoice: AnthropicToolChoice | undefined;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateRes
|
|
|
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
|
|
|
5
|
-
type AnthropicMessagesModelId = '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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
|
|
5
|
+
type AnthropicMessagesModelId = '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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
|
|
6
6
|
|
|
7
7
|
type AnthropicMessagesConfig = {
|
|
8
8
|
provider: string;
|
|
@@ -57,9 +57,26 @@ declare function getModelCapabilities(modelId: string): {
|
|
|
57
57
|
supportsStructuredOutput: boolean;
|
|
58
58
|
rejectsSamplingParameters: boolean;
|
|
59
59
|
rejectsThinkingDisabledAboveHighEffort: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Thinking is always adaptive: `thinking.type` `disabled` and `enabled`
|
|
62
|
+
* are rejected with a 400.
|
|
63
|
+
*/
|
|
64
|
+
rejectsThinkingDisabled: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Forced tool use (`tool_choice` `any` or a named tool) is rejected with a 400.
|
|
67
|
+
*/
|
|
68
|
+
rejectsForcedToolUse: boolean;
|
|
60
69
|
isKnownModel: boolean;
|
|
61
70
|
};
|
|
62
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Member tools of the computer toolset. Each member is returned by the API as
|
|
74
|
+
* its own `tool_use` block; the AI SDK exposes it as the `action` of a single
|
|
75
|
+
* computer tool call.
|
|
76
|
+
*/
|
|
77
|
+
declare const computerToolset_20260801Members: readonly ["screenshot", "zoom", "left_click", "right_click", "middle_click", "double_click", "triple_click", "left_click_drag", "mouse_move", "left_mouse_down", "left_mouse_up", "cursor_position", "scroll", "type", "key", "hold_key", "wait"];
|
|
78
|
+
type ComputerToolset_20260801Member = (typeof computerToolset_20260801Members)[number];
|
|
79
|
+
|
|
63
80
|
declare const anthropicTools: {
|
|
64
81
|
/**
|
|
65
82
|
* Pairs a faster executor model with a higher-intelligence advisor model
|
|
@@ -528,6 +545,44 @@ declare const anthropicTools: {
|
|
|
528
545
|
displayNumber?: number;
|
|
529
546
|
enableZoom?: boolean;
|
|
530
547
|
}>;
|
|
548
|
+
/**
|
|
549
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
550
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
551
|
+
* (`computer_20251124` and earlier) on newer models.
|
|
552
|
+
*
|
|
553
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
554
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
555
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
556
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
557
|
+
* in one turn.
|
|
558
|
+
*
|
|
559
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
560
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
561
|
+
*
|
|
562
|
+
* Does not require a beta header.
|
|
563
|
+
*
|
|
564
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
565
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
566
|
+
*
|
|
567
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
568
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
569
|
+
*/
|
|
570
|
+
computerToolset_20260801: _ai_sdk_provider_utils.ProviderToolFactory<{
|
|
571
|
+
action: ComputerToolset_20260801Member;
|
|
572
|
+
coordinate?: [number, number];
|
|
573
|
+
duration?: number;
|
|
574
|
+
region?: [number, number, number, number];
|
|
575
|
+
repeat?: number;
|
|
576
|
+
scroll_amount?: number;
|
|
577
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
578
|
+
start_coordinate?: [number, number];
|
|
579
|
+
text?: string;
|
|
580
|
+
}, {
|
|
581
|
+
configs?: Partial<Record<ComputerToolset_20260801Member, {
|
|
582
|
+
enabled?: boolean;
|
|
583
|
+
deferLoading?: boolean;
|
|
584
|
+
}>>;
|
|
585
|
+
}>;
|
|
531
586
|
/**
|
|
532
587
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
533
588
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -946,6 +1001,17 @@ type AnthropicTool = {
|
|
|
946
1001
|
display_number: number;
|
|
947
1002
|
enable_zoom?: boolean;
|
|
948
1003
|
cache_control: AnthropicCacheControl | undefined;
|
|
1004
|
+
} | {
|
|
1005
|
+
/**
|
|
1006
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
1007
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
1008
|
+
*/
|
|
1009
|
+
type: 'computer_toolset_20260801';
|
|
1010
|
+
configs?: Record<string, {
|
|
1011
|
+
enabled?: boolean;
|
|
1012
|
+
defer_loading?: boolean;
|
|
1013
|
+
}>;
|
|
1014
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
949
1015
|
} | {
|
|
950
1016
|
name: string;
|
|
951
1017
|
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
@@ -1022,7 +1088,7 @@ declare class CacheControlValidator {
|
|
|
1022
1088
|
getWarnings(): SharedV3Warning[];
|
|
1023
1089
|
}
|
|
1024
1090
|
|
|
1025
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, }: {
|
|
1091
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, rejectsForcedToolUse, }: {
|
|
1026
1092
|
tools: LanguageModelV3CallOptions['tools'];
|
|
1027
1093
|
toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
|
|
1028
1094
|
disableParallelToolUse?: boolean;
|
|
@@ -1040,6 +1106,12 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
|
|
|
1040
1106
|
* it explicitly. Driven by the model-level `toolStreaming` option.
|
|
1041
1107
|
*/
|
|
1042
1108
|
defaultEagerInputStreaming?: boolean;
|
|
1109
|
+
/**
|
|
1110
|
+
* Whether the model rejects forced tool use (`tool_choice` `any` or a
|
|
1111
|
+
* named tool). When true, `required` and `tool` tool choices fall back to
|
|
1112
|
+
* `auto` with a warning.
|
|
1113
|
+
*/
|
|
1114
|
+
rejectsForcedToolUse?: boolean;
|
|
1043
1115
|
}): Promise<{
|
|
1044
1116
|
tools: Array<AnthropicTool> | undefined;
|
|
1045
1117
|
toolChoice: AnthropicToolChoice | undefined;
|