@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.60
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 49295bb: feat(anthropic): add Claude Opus 5.5 support
|
|
8
|
+
|
|
9
|
+
- add the `claude-opus-5-5` model ID to `@ai-sdk/anthropic` and `anthropic/claude-opus-5.5` to `@ai-sdk/gateway`
|
|
10
|
+
- models that always use adaptive thinking (`claude-opus-5-5`, `claude-fable-5`, `claude-fable-5-1`) no longer receive `thinking: { type: 'disabled' }` or budget-based thinking; the provider drops the unsupported setting, maps `reasoning: 'none'` to `effort: 'low'`, and emits a warning
|
|
11
|
+
- models that reject forced tool use (`claude-opus-5-5`, `claude-fable-5-1`) fall back to `auto` tool choice for `required` and named tool choices, and to native structured outputs when `structuredOutputMode: 'jsonTool'` is requested, each with a warning
|
|
12
|
+
- add the `computerToolset_20260801` computer use tool (`computer_toolset_20260801`), which is required for computer use on `claude-opus-5-5`
|
|
13
|
+
- use the documented `mid-conversation-output-config-2026-07-01` beta header for per-message effort
|
|
14
|
+
|
|
15
|
+
## 4.0.59
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- f7b7b2a: feat(provider/anthropic): add `safeguards` provider option and `safeguardResults` provider metadata (dangerous tool use classifier)
|
|
20
|
+
|
|
3
21
|
## 4.0.58
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,19 @@ import { z } from 'zod/v4';
|
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { ToolExecuteFunction, Tool, Experimental_SandboxSession, ProviderDefinedTool, FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
|
+
declare const anthropicSafeguardResultSchema: z.ZodObject<{
|
|
7
|
+
type: z.ZodString;
|
|
8
|
+
status: z.ZodObject<{
|
|
9
|
+
type: z.ZodString;
|
|
10
|
+
tool_uses: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
11
|
+
type: z.ZodString;
|
|
12
|
+
outcome: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
explanation: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>>>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
type AnthropicSafeguardResult = z.infer<typeof anthropicSafeguardResultSchema>;
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* Represents a single iteration in the usage breakdown.
|
|
8
21
|
*
|
|
@@ -57,6 +70,18 @@ interface AnthropicMessageMetadata {
|
|
|
57
70
|
path: string;
|
|
58
71
|
reason: string;
|
|
59
72
|
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Verdicts of the server-side safeguards requested with
|
|
75
|
+
* `providerOptions.anthropic.safeguards`, one entry per requested safeguard.
|
|
76
|
+
* For `dangerous_tool_use`, `status.type` is `'available'` when the
|
|
77
|
+
* classifier ran and `status.tool_uses` maps each tool call id to its
|
|
78
|
+
* verdict (`type: 'evaluated'` with an `outcome` of `'not_flagged'` or
|
|
79
|
+
* `'flagged'` plus an `explanation`, `'skipped'`, or `'unavailable'`).
|
|
80
|
+
*
|
|
81
|
+
* Kept in the API's wire shape (snake_case), since consumers such as Claude
|
|
82
|
+
* Code read the verdicts verbatim.
|
|
83
|
+
*/
|
|
84
|
+
safeguardResults?: AnthropicSafeguardResult[];
|
|
60
85
|
/**
|
|
61
86
|
* Details about why the request stopped. Present only when the API returns
|
|
62
87
|
* a `refusal` stop reason together with a `stop_details` object (a
|
|
@@ -194,7 +219,7 @@ interface AnthropicMessageMetadata {
|
|
|
194
219
|
} | null;
|
|
195
220
|
}
|
|
196
221
|
|
|
197
|
-
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 & {});
|
|
222
|
+
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 & {});
|
|
198
223
|
/**
|
|
199
224
|
* Anthropic provider options for system messages.
|
|
200
225
|
*/
|
|
@@ -219,9 +244,9 @@ type AnthropicSystemMessageProviderOptions = z.infer<typeof anthropicSystemMessa
|
|
|
219
244
|
declare const anthropicLanguageModelOptions: z.ZodObject<{
|
|
220
245
|
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
221
246
|
structuredOutputMode: z.ZodOptional<z.ZodEnum<{
|
|
247
|
+
auto: "auto";
|
|
222
248
|
outputFormat: "outputFormat";
|
|
223
249
|
jsonTool: "jsonTool";
|
|
224
|
-
auto: "auto";
|
|
225
250
|
}>>;
|
|
226
251
|
thinking: z.ZodOptional<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
227
252
|
type: z.ZodLiteral<"adaptive">;
|
|
@@ -316,6 +341,10 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
|
|
|
316
341
|
}>>;
|
|
317
342
|
}, z.core.$strip>>]>>;
|
|
318
343
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
344
|
+
safeguards: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
345
|
+
type: z.ZodLiteral<"dangerous_tool_use">;
|
|
346
|
+
classifierContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
347
|
+
}, z.core.$strip>>>;
|
|
319
348
|
contextManagement: z.ZodOptional<z.ZodObject<{
|
|
320
349
|
edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
321
350
|
type: z.ZodLiteral<"clear_tool_uses_20250919">;
|
|
@@ -361,6 +390,14 @@ interface AnthropicToolOptions {
|
|
|
361
390
|
eagerInputStreaming?: boolean;
|
|
362
391
|
}
|
|
363
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Member tools of the computer toolset. Each member is returned by the API as
|
|
395
|
+
* its own `tool_use` block; the AI SDK exposes it as the `action` of a single
|
|
396
|
+
* computer tool call.
|
|
397
|
+
*/
|
|
398
|
+
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"];
|
|
399
|
+
type ComputerToolset_20260801Member = (typeof computerToolset_20260801Members)[number];
|
|
400
|
+
|
|
364
401
|
type Bash20241022Input = {
|
|
365
402
|
/**
|
|
366
403
|
* The bash command to run. Required unless the tool is being restarted.
|
|
@@ -888,6 +925,44 @@ declare const anthropicTools: {
|
|
|
888
925
|
displayNumber?: number;
|
|
889
926
|
enableZoom?: boolean;
|
|
890
927
|
}, {}>;
|
|
928
|
+
/**
|
|
929
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
930
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
931
|
+
* (`computer_20251124` and earlier) on newer models.
|
|
932
|
+
*
|
|
933
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
934
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
935
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
936
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
937
|
+
* in one turn.
|
|
938
|
+
*
|
|
939
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
940
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
941
|
+
*
|
|
942
|
+
* Does not require a beta header.
|
|
943
|
+
*
|
|
944
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
945
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
946
|
+
*
|
|
947
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
948
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
949
|
+
*/
|
|
950
|
+
computerToolset_20260801: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
951
|
+
action: ComputerToolset_20260801Member;
|
|
952
|
+
coordinate?: [number, number];
|
|
953
|
+
duration?: number;
|
|
954
|
+
region?: [number, number, number, number];
|
|
955
|
+
repeat?: number;
|
|
956
|
+
scroll_amount?: number;
|
|
957
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
958
|
+
start_coordinate?: [number, number];
|
|
959
|
+
text?: string;
|
|
960
|
+
}, {
|
|
961
|
+
configs?: Partial<Record<ComputerToolset_20260801Member, {
|
|
962
|
+
enabled?: boolean;
|
|
963
|
+
deferLoading?: boolean;
|
|
964
|
+
}>>;
|
|
965
|
+
}, {}>;
|
|
891
966
|
/**
|
|
892
967
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
893
968
|
* Claude can create, read, update, and delete files that persist between sessions,
|