@ai-sdk/anthropic 2.0.101 → 2.0.103
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 +21 -0
- package/dist/index.d.mts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +732 -366
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +719 -349
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +67 -2
- package/dist/internal/index.d.ts +67 -2
- package/dist/internal/index.js +725 -359
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +718 -348
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { LanguageModelV2, JSONSchema7, SharedV2ProviderMetadata, LanguageModelV2
|
|
|
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-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | '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-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | '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;
|
|
@@ -33,6 +33,14 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV2 {
|
|
|
33
33
|
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Member tools of the computer toolset. Each member is returned by the API as
|
|
38
|
+
* its own `tool_use` block; the AI SDK exposes it as the `action` of a single
|
|
39
|
+
* computer tool call.
|
|
40
|
+
*/
|
|
41
|
+
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"];
|
|
42
|
+
type ComputerToolset_20260801Member = (typeof computerToolset_20260801Members)[number];
|
|
43
|
+
|
|
36
44
|
declare const anthropicTools: {
|
|
37
45
|
/**
|
|
38
46
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
@@ -379,6 +387,46 @@ declare const anthropicTools: {
|
|
|
379
387
|
displayHeightPx: number;
|
|
380
388
|
displayNumber?: number;
|
|
381
389
|
}>;
|
|
390
|
+
/**
|
|
391
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
392
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
393
|
+
* (`computer_20250124` and earlier) on newer models.
|
|
394
|
+
*
|
|
395
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
396
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
397
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
398
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
399
|
+
* in one turn.
|
|
400
|
+
*
|
|
401
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
402
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
403
|
+
*
|
|
404
|
+
* Does not require a beta header.
|
|
405
|
+
*
|
|
406
|
+
* Tool name must be `computer`.
|
|
407
|
+
*
|
|
408
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
409
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
410
|
+
*
|
|
411
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
412
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
413
|
+
*/
|
|
414
|
+
computerToolset_20260801: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
415
|
+
action: ComputerToolset_20260801Member;
|
|
416
|
+
coordinate?: [number, number];
|
|
417
|
+
duration?: number;
|
|
418
|
+
region?: [number, number, number, number];
|
|
419
|
+
repeat?: number;
|
|
420
|
+
scroll_amount?: number;
|
|
421
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
422
|
+
start_coordinate?: [number, number];
|
|
423
|
+
text?: string;
|
|
424
|
+
}, {
|
|
425
|
+
configs?: Partial<Record<ComputerToolset_20260801Member, {
|
|
426
|
+
enabled?: boolean;
|
|
427
|
+
deferLoading?: boolean;
|
|
428
|
+
}>>;
|
|
429
|
+
}>;
|
|
382
430
|
/**
|
|
383
431
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
384
432
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -634,6 +682,17 @@ type AnthropicTool = {
|
|
|
634
682
|
display_height_px: number;
|
|
635
683
|
display_number: number;
|
|
636
684
|
cache_control: AnthropicCacheControl | undefined;
|
|
685
|
+
} | {
|
|
686
|
+
/**
|
|
687
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
688
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
689
|
+
*/
|
|
690
|
+
type: 'computer_toolset_20260801';
|
|
691
|
+
configs?: Record<string, {
|
|
692
|
+
enabled?: boolean;
|
|
693
|
+
defer_loading?: boolean;
|
|
694
|
+
}>;
|
|
695
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
637
696
|
} | {
|
|
638
697
|
name: string;
|
|
639
698
|
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
@@ -695,11 +754,17 @@ declare class CacheControlValidator {
|
|
|
695
754
|
getWarnings(): LanguageModelV2CallWarning[];
|
|
696
755
|
}
|
|
697
756
|
|
|
698
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, }: {
|
|
757
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, rejectsForcedToolUse, }: {
|
|
699
758
|
tools: LanguageModelV2CallOptions['tools'];
|
|
700
759
|
toolChoice?: LanguageModelV2CallOptions['toolChoice'];
|
|
701
760
|
disableParallelToolUse?: boolean;
|
|
702
761
|
cacheControlValidator?: CacheControlValidator;
|
|
762
|
+
/**
|
|
763
|
+
* Whether the model rejects forced tool use (`tool_choice` `any` or a
|
|
764
|
+
* named tool). When true, `required` and `tool` tool choices fall back to
|
|
765
|
+
* `auto` with a warning.
|
|
766
|
+
*/
|
|
767
|
+
rejectsForcedToolUse?: boolean;
|
|
703
768
|
}): Promise<{
|
|
704
769
|
tools: Array<AnthropicTool> | undefined;
|
|
705
770
|
toolChoice: AnthropicToolChoice | undefined;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LanguageModelV2, JSONSchema7, SharedV2ProviderMetadata, LanguageModelV2
|
|
|
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-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | '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-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | '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;
|
|
@@ -33,6 +33,14 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV2 {
|
|
|
33
33
|
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Member tools of the computer toolset. Each member is returned by the API as
|
|
38
|
+
* its own `tool_use` block; the AI SDK exposes it as the `action` of a single
|
|
39
|
+
* computer tool call.
|
|
40
|
+
*/
|
|
41
|
+
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"];
|
|
42
|
+
type ComputerToolset_20260801Member = (typeof computerToolset_20260801Members)[number];
|
|
43
|
+
|
|
36
44
|
declare const anthropicTools: {
|
|
37
45
|
/**
|
|
38
46
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
@@ -379,6 +387,46 @@ declare const anthropicTools: {
|
|
|
379
387
|
displayHeightPx: number;
|
|
380
388
|
displayNumber?: number;
|
|
381
389
|
}>;
|
|
390
|
+
/**
|
|
391
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
392
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
393
|
+
* (`computer_20250124` and earlier) on newer models.
|
|
394
|
+
*
|
|
395
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
396
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
397
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
398
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
399
|
+
* in one turn.
|
|
400
|
+
*
|
|
401
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
402
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
403
|
+
*
|
|
404
|
+
* Does not require a beta header.
|
|
405
|
+
*
|
|
406
|
+
* Tool name must be `computer`.
|
|
407
|
+
*
|
|
408
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
409
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
410
|
+
*
|
|
411
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
412
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
413
|
+
*/
|
|
414
|
+
computerToolset_20260801: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
415
|
+
action: ComputerToolset_20260801Member;
|
|
416
|
+
coordinate?: [number, number];
|
|
417
|
+
duration?: number;
|
|
418
|
+
region?: [number, number, number, number];
|
|
419
|
+
repeat?: number;
|
|
420
|
+
scroll_amount?: number;
|
|
421
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
422
|
+
start_coordinate?: [number, number];
|
|
423
|
+
text?: string;
|
|
424
|
+
}, {
|
|
425
|
+
configs?: Partial<Record<ComputerToolset_20260801Member, {
|
|
426
|
+
enabled?: boolean;
|
|
427
|
+
deferLoading?: boolean;
|
|
428
|
+
}>>;
|
|
429
|
+
}>;
|
|
382
430
|
/**
|
|
383
431
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
384
432
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -634,6 +682,17 @@ type AnthropicTool = {
|
|
|
634
682
|
display_height_px: number;
|
|
635
683
|
display_number: number;
|
|
636
684
|
cache_control: AnthropicCacheControl | undefined;
|
|
685
|
+
} | {
|
|
686
|
+
/**
|
|
687
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
688
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
689
|
+
*/
|
|
690
|
+
type: 'computer_toolset_20260801';
|
|
691
|
+
configs?: Record<string, {
|
|
692
|
+
enabled?: boolean;
|
|
693
|
+
defer_loading?: boolean;
|
|
694
|
+
}>;
|
|
695
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
637
696
|
} | {
|
|
638
697
|
name: string;
|
|
639
698
|
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
@@ -695,11 +754,17 @@ declare class CacheControlValidator {
|
|
|
695
754
|
getWarnings(): LanguageModelV2CallWarning[];
|
|
696
755
|
}
|
|
697
756
|
|
|
698
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, }: {
|
|
757
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, rejectsForcedToolUse, }: {
|
|
699
758
|
tools: LanguageModelV2CallOptions['tools'];
|
|
700
759
|
toolChoice?: LanguageModelV2CallOptions['toolChoice'];
|
|
701
760
|
disableParallelToolUse?: boolean;
|
|
702
761
|
cacheControlValidator?: CacheControlValidator;
|
|
762
|
+
/**
|
|
763
|
+
* Whether the model rejects forced tool use (`tool_choice` `any` or a
|
|
764
|
+
* named tool). When true, `required` and `tool` tool choices fall back to
|
|
765
|
+
* `auto` with a warning.
|
|
766
|
+
*/
|
|
767
|
+
rejectsForcedToolUse?: boolean;
|
|
703
768
|
}): Promise<{
|
|
704
769
|
tools: Array<AnthropicTool> | undefined;
|
|
705
770
|
toolChoice: AnthropicToolChoice | undefined;
|