@ai-sdk/anthropic 4.0.58 → 4.0.60
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 +18 -0
- package/dist/index.d.ts +77 -2
- package/dist/index.js +1005 -556
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +99 -2
- package/dist/internal/index.js +955 -507
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +176 -14
- package/package.json +1 -1
- package/src/anthropic-api.ts +46 -0
- package/src/anthropic-batch.ts +3 -0
- package/src/anthropic-language-model-options.ts +32 -3
- package/src/anthropic-language-model.ts +315 -5
- package/src/anthropic-message-metadata.ts +14 -0
- package/src/anthropic-prepare-tools.ts +76 -0
- package/src/anthropic-tools.ts +25 -0
- package/src/convert-to-anthropic-prompt.ts +74 -1
- package/src/tool/computer-toolset_20260801.ts +165 -0
package/dist/internal/index.d.ts
CHANGED
|
@@ -134,6 +134,11 @@ interface AnthropicToolCallContent {
|
|
|
134
134
|
* (e.g., code execution calling a user-defined tool programmatically).
|
|
135
135
|
*/
|
|
136
136
|
caller?: AnthropicToolCallCaller;
|
|
137
|
+
/**
|
|
138
|
+
* Present when this tool call is a member call of a toolset
|
|
139
|
+
* (e.g. `computer` for the computer toolset). `name` is then the member name.
|
|
140
|
+
*/
|
|
141
|
+
toolset_name?: string;
|
|
137
142
|
cache_control: AnthropicCacheControl | undefined;
|
|
138
143
|
}
|
|
139
144
|
interface AnthropicServerToolUseContent {
|
|
@@ -160,6 +165,10 @@ interface AnthropicToolReferenceContent {
|
|
|
160
165
|
interface AnthropicToolResultContent {
|
|
161
166
|
type: 'tool_result';
|
|
162
167
|
tool_use_id: string;
|
|
168
|
+
/**
|
|
169
|
+
* Required for results of toolset member calls (e.g. `computer`).
|
|
170
|
+
*/
|
|
171
|
+
toolset_name?: string;
|
|
163
172
|
content: string | Array<AnthropicNestedTextContent | AnthropicNestedImageContent | AnthropicNestedDocumentContent | AnthropicToolReferenceContent>;
|
|
164
173
|
is_error: boolean | undefined;
|
|
165
174
|
cache_control: AnthropicCacheControl | undefined;
|
|
@@ -382,6 +391,17 @@ type AnthropicTool = {
|
|
|
382
391
|
display_number: number;
|
|
383
392
|
enable_zoom?: boolean;
|
|
384
393
|
cache_control: AnthropicCacheControl | undefined;
|
|
394
|
+
} | {
|
|
395
|
+
/**
|
|
396
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
397
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
398
|
+
*/
|
|
399
|
+
type: 'computer_toolset_20260801';
|
|
400
|
+
configs?: Record<string, {
|
|
401
|
+
enabled?: boolean;
|
|
402
|
+
defer_loading?: boolean;
|
|
403
|
+
}>;
|
|
404
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
385
405
|
} | {
|
|
386
406
|
name: string;
|
|
387
407
|
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
@@ -519,6 +539,7 @@ declare const anthropicResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
519
539
|
} | {
|
|
520
540
|
type: "direct";
|
|
521
541
|
} | undefined;
|
|
542
|
+
toolset_name?: string | null | undefined;
|
|
522
543
|
} | {
|
|
523
544
|
type: "server_tool_use";
|
|
524
545
|
id: string;
|
|
@@ -738,6 +759,17 @@ declare const anthropicResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
738
759
|
path: string;
|
|
739
760
|
reason: string;
|
|
740
761
|
}[] | null | undefined;
|
|
762
|
+
safeguard_results?: {
|
|
763
|
+
type: string;
|
|
764
|
+
status: {
|
|
765
|
+
type: string;
|
|
766
|
+
tool_uses?: Record<string, {
|
|
767
|
+
type: string;
|
|
768
|
+
outcome?: string | null | undefined;
|
|
769
|
+
explanation?: string | null | undefined;
|
|
770
|
+
}> | null | undefined;
|
|
771
|
+
};
|
|
772
|
+
}[] | null | undefined;
|
|
741
773
|
container?: {
|
|
742
774
|
expires_at: string;
|
|
743
775
|
id: string;
|
|
@@ -765,7 +797,7 @@ type Citation = NonNullable<(InferSchema<typeof anthropicResponseSchema>['conten
|
|
|
765
797
|
type: 'text';
|
|
766
798
|
})['citations']>[number];
|
|
767
799
|
|
|
768
|
-
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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
|
|
800
|
+
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' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
|
|
769
801
|
|
|
770
802
|
type AnthropicLanguageModelConfig = {
|
|
771
803
|
provider: string;
|
|
@@ -844,6 +876,10 @@ declare class AnthropicLanguageModel implements LanguageModelV4 {
|
|
|
844
876
|
type: "compact_20260112";
|
|
845
877
|
})[];
|
|
846
878
|
} | undefined;
|
|
879
|
+
safeguards?: {
|
|
880
|
+
classifier_context?: Record<string, unknown> | undefined;
|
|
881
|
+
type: "dangerous_tool_use";
|
|
882
|
+
}[] | undefined;
|
|
847
883
|
system: AnthropicTextContent[] | undefined;
|
|
848
884
|
messages: AnthropicMessage[];
|
|
849
885
|
container?: string | {
|
|
@@ -937,9 +973,26 @@ declare function getModelCapabilities(modelId: string): {
|
|
|
937
973
|
rejectsSamplingParameters: boolean;
|
|
938
974
|
supportsXhighEffort: boolean;
|
|
939
975
|
rejectsThinkingDisabledAboveHighEffort: boolean;
|
|
976
|
+
/**
|
|
977
|
+
* Thinking is always adaptive: `thinking.type` `disabled` and `enabled`
|
|
978
|
+
* are rejected with a 400.
|
|
979
|
+
*/
|
|
980
|
+
rejectsThinkingDisabled: boolean;
|
|
981
|
+
/**
|
|
982
|
+
* Forced tool use (`tool_choice` `any` or a named tool) is rejected with a 400.
|
|
983
|
+
*/
|
|
984
|
+
rejectsForcedToolUse: boolean;
|
|
940
985
|
isKnownModel: boolean;
|
|
941
986
|
};
|
|
942
987
|
|
|
988
|
+
/**
|
|
989
|
+
* Member tools of the computer toolset. Each member is returned by the API as
|
|
990
|
+
* its own `tool_use` block; the AI SDK exposes it as the `action` of a single
|
|
991
|
+
* computer tool call.
|
|
992
|
+
*/
|
|
993
|
+
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"];
|
|
994
|
+
type ComputerToolset_20260801Member = (typeof computerToolset_20260801Members)[number];
|
|
995
|
+
|
|
943
996
|
type Bash20241022Input = {
|
|
944
997
|
/**
|
|
945
998
|
* The bash command to run. Required unless the tool is being restarted.
|
|
@@ -1467,6 +1520,44 @@ declare const anthropicTools: {
|
|
|
1467
1520
|
displayNumber?: number;
|
|
1468
1521
|
enableZoom?: boolean;
|
|
1469
1522
|
}, {}>;
|
|
1523
|
+
/**
|
|
1524
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
1525
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
1526
|
+
* (`computer_20251124` and earlier) on newer models.
|
|
1527
|
+
*
|
|
1528
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
1529
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
1530
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
1531
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
1532
|
+
* in one turn.
|
|
1533
|
+
*
|
|
1534
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
1535
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
1536
|
+
*
|
|
1537
|
+
* Does not require a beta header.
|
|
1538
|
+
*
|
|
1539
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
1540
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
1541
|
+
*
|
|
1542
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
1543
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
1544
|
+
*/
|
|
1545
|
+
computerToolset_20260801: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
1546
|
+
action: ComputerToolset_20260801Member;
|
|
1547
|
+
coordinate?: [number, number];
|
|
1548
|
+
duration?: number;
|
|
1549
|
+
region?: [number, number, number, number];
|
|
1550
|
+
repeat?: number;
|
|
1551
|
+
scroll_amount?: number;
|
|
1552
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
1553
|
+
start_coordinate?: [number, number];
|
|
1554
|
+
text?: string;
|
|
1555
|
+
}, {
|
|
1556
|
+
configs?: Partial<Record<ComputerToolset_20260801Member, {
|
|
1557
|
+
enabled?: boolean;
|
|
1558
|
+
deferLoading?: boolean;
|
|
1559
|
+
}>>;
|
|
1560
|
+
}, {}>;
|
|
1470
1561
|
/**
|
|
1471
1562
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
1472
1563
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -1950,7 +2041,7 @@ declare class CacheControlValidator {
|
|
|
1950
2041
|
getWarnings(): SharedV4Warning[];
|
|
1951
2042
|
}
|
|
1952
2043
|
|
|
1953
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, }: {
|
|
2044
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, rejectsForcedToolUse, }: {
|
|
1954
2045
|
tools: LanguageModelV4CallOptions['tools'];
|
|
1955
2046
|
toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
|
|
1956
2047
|
disableParallelToolUse?: boolean;
|
|
@@ -1968,6 +2059,12 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
|
|
|
1968
2059
|
* it explicitly. Driven by the model-level `toolStreaming` option.
|
|
1969
2060
|
*/
|
|
1970
2061
|
defaultEagerInputStreaming?: boolean;
|
|
2062
|
+
/**
|
|
2063
|
+
* Whether the model rejects forced tool use (`tool_choice` `any` or a
|
|
2064
|
+
* named tool). When true, `required` and `tool` tool choices fall back to
|
|
2065
|
+
* `auto` with a warning.
|
|
2066
|
+
*/
|
|
2067
|
+
rejectsForcedToolUse?: boolean;
|
|
1971
2068
|
}): Promise<{
|
|
1972
2069
|
tools: Array<AnthropicTool> | undefined;
|
|
1973
2070
|
toolChoice: AnthropicToolChoice | undefined;
|