@ai-sdk/anthropic 2.0.102 → 2.0.104
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 +90 -3
- package/dist/internal/index.d.ts +90 -3
- package/dist/internal/index.js +727 -359
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +719 -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;
|
|
@@ -32,6 +32,36 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV2 {
|
|
|
32
32
|
doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
33
33
|
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the capabilities of a Claude model that are used for defaults and feature selection.
|
|
37
|
+
*
|
|
38
|
+
* @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
|
|
39
|
+
* @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
|
|
40
|
+
*/
|
|
41
|
+
declare function getModelCapabilities(modelId: string): {
|
|
42
|
+
maxOutputTokens: number;
|
|
43
|
+
supportsStructuredOutput: boolean;
|
|
44
|
+
rejectsSamplingParameters: boolean;
|
|
45
|
+
rejectsThinkingDisabledAboveHighEffort: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Thinking is always adaptive: `thinking.type` `disabled` and `enabled`
|
|
48
|
+
* are rejected with a 400.
|
|
49
|
+
*/
|
|
50
|
+
rejectsThinkingDisabled: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Forced tool use (`tool_choice` `any` or a named tool) is rejected with a 400.
|
|
53
|
+
*/
|
|
54
|
+
rejectsForcedToolUse: boolean;
|
|
55
|
+
isKnownModel: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Member tools of the computer toolset. Each member is returned by the API as
|
|
60
|
+
* its own `tool_use` block; the AI SDK exposes it as the `action` of a single
|
|
61
|
+
* computer tool call.
|
|
62
|
+
*/
|
|
63
|
+
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"];
|
|
64
|
+
type ComputerToolset_20260801Member = (typeof computerToolset_20260801Members)[number];
|
|
35
65
|
|
|
36
66
|
declare const anthropicTools: {
|
|
37
67
|
/**
|
|
@@ -379,6 +409,46 @@ declare const anthropicTools: {
|
|
|
379
409
|
displayHeightPx: number;
|
|
380
410
|
displayNumber?: number;
|
|
381
411
|
}>;
|
|
412
|
+
/**
|
|
413
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
414
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
415
|
+
* (`computer_20250124` and earlier) on newer models.
|
|
416
|
+
*
|
|
417
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
418
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
419
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
420
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
421
|
+
* in one turn.
|
|
422
|
+
*
|
|
423
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
424
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
425
|
+
*
|
|
426
|
+
* Does not require a beta header.
|
|
427
|
+
*
|
|
428
|
+
* Tool name must be `computer`.
|
|
429
|
+
*
|
|
430
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
431
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
432
|
+
*
|
|
433
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
434
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
435
|
+
*/
|
|
436
|
+
computerToolset_20260801: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
437
|
+
action: ComputerToolset_20260801Member;
|
|
438
|
+
coordinate?: [number, number];
|
|
439
|
+
duration?: number;
|
|
440
|
+
region?: [number, number, number, number];
|
|
441
|
+
repeat?: number;
|
|
442
|
+
scroll_amount?: number;
|
|
443
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
444
|
+
start_coordinate?: [number, number];
|
|
445
|
+
text?: string;
|
|
446
|
+
}, {
|
|
447
|
+
configs?: Partial<Record<ComputerToolset_20260801Member, {
|
|
448
|
+
enabled?: boolean;
|
|
449
|
+
deferLoading?: boolean;
|
|
450
|
+
}>>;
|
|
451
|
+
}>;
|
|
382
452
|
/**
|
|
383
453
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
384
454
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -634,6 +704,17 @@ type AnthropicTool = {
|
|
|
634
704
|
display_height_px: number;
|
|
635
705
|
display_number: number;
|
|
636
706
|
cache_control: AnthropicCacheControl | undefined;
|
|
707
|
+
} | {
|
|
708
|
+
/**
|
|
709
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
710
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
711
|
+
*/
|
|
712
|
+
type: 'computer_toolset_20260801';
|
|
713
|
+
configs?: Record<string, {
|
|
714
|
+
enabled?: boolean;
|
|
715
|
+
defer_loading?: boolean;
|
|
716
|
+
}>;
|
|
717
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
637
718
|
} | {
|
|
638
719
|
name: string;
|
|
639
720
|
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
@@ -695,11 +776,17 @@ declare class CacheControlValidator {
|
|
|
695
776
|
getWarnings(): LanguageModelV2CallWarning[];
|
|
696
777
|
}
|
|
697
778
|
|
|
698
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, }: {
|
|
779
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, rejectsForcedToolUse, }: {
|
|
699
780
|
tools: LanguageModelV2CallOptions['tools'];
|
|
700
781
|
toolChoice?: LanguageModelV2CallOptions['toolChoice'];
|
|
701
782
|
disableParallelToolUse?: boolean;
|
|
702
783
|
cacheControlValidator?: CacheControlValidator;
|
|
784
|
+
/**
|
|
785
|
+
* Whether the model rejects forced tool use (`tool_choice` `any` or a
|
|
786
|
+
* named tool). When true, `required` and `tool` tool choices fall back to
|
|
787
|
+
* `auto` with a warning.
|
|
788
|
+
*/
|
|
789
|
+
rejectsForcedToolUse?: boolean;
|
|
703
790
|
}): Promise<{
|
|
704
791
|
tools: Array<AnthropicTool> | undefined;
|
|
705
792
|
toolChoice: AnthropicToolChoice | undefined;
|
|
@@ -716,4 +803,4 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
|
|
|
716
803
|
*/
|
|
717
804
|
declare function sanitizeJsonSchema(schema: JSONSchema7): JSONSchema7;
|
|
718
805
|
|
|
719
|
-
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools, sanitizeJsonSchema };
|
|
806
|
+
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools, sanitizeJsonSchema };
|
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;
|
|
@@ -32,6 +32,36 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV2 {
|
|
|
32
32
|
doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
33
33
|
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the capabilities of a Claude model that are used for defaults and feature selection.
|
|
37
|
+
*
|
|
38
|
+
* @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
|
|
39
|
+
* @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
|
|
40
|
+
*/
|
|
41
|
+
declare function getModelCapabilities(modelId: string): {
|
|
42
|
+
maxOutputTokens: number;
|
|
43
|
+
supportsStructuredOutput: boolean;
|
|
44
|
+
rejectsSamplingParameters: boolean;
|
|
45
|
+
rejectsThinkingDisabledAboveHighEffort: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Thinking is always adaptive: `thinking.type` `disabled` and `enabled`
|
|
48
|
+
* are rejected with a 400.
|
|
49
|
+
*/
|
|
50
|
+
rejectsThinkingDisabled: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Forced tool use (`tool_choice` `any` or a named tool) is rejected with a 400.
|
|
53
|
+
*/
|
|
54
|
+
rejectsForcedToolUse: boolean;
|
|
55
|
+
isKnownModel: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Member tools of the computer toolset. Each member is returned by the API as
|
|
60
|
+
* its own `tool_use` block; the AI SDK exposes it as the `action` of a single
|
|
61
|
+
* computer tool call.
|
|
62
|
+
*/
|
|
63
|
+
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"];
|
|
64
|
+
type ComputerToolset_20260801Member = (typeof computerToolset_20260801Members)[number];
|
|
35
65
|
|
|
36
66
|
declare const anthropicTools: {
|
|
37
67
|
/**
|
|
@@ -379,6 +409,46 @@ declare const anthropicTools: {
|
|
|
379
409
|
displayHeightPx: number;
|
|
380
410
|
displayNumber?: number;
|
|
381
411
|
}>;
|
|
412
|
+
/**
|
|
413
|
+
* The computer toolset lets Claude control a computer through screenshots,
|
|
414
|
+
* mouse, and keyboard. It replaces the versioned computer tools
|
|
415
|
+
* (`computer_20250124` and earlier) on newer models.
|
|
416
|
+
*
|
|
417
|
+
* The API returns each computer action as its own `tool_use` block with
|
|
418
|
+
* `toolset_name: 'computer'`. The AI SDK maps every member call to this tool
|
|
419
|
+
* and exposes the member name as `action`, so `execute` receives the same
|
|
420
|
+
* input shape as the older computer tools. Claude may return several actions
|
|
421
|
+
* in one turn.
|
|
422
|
+
*
|
|
423
|
+
* Coordinates are always in the pixel space of the screenshots you return;
|
|
424
|
+
* there are no display size parameters. Zoom is enabled by default.
|
|
425
|
+
*
|
|
426
|
+
* Does not require a beta header.
|
|
427
|
+
*
|
|
428
|
+
* Tool name must be `computer`.
|
|
429
|
+
*
|
|
430
|
+
* Supported models: Claude Opus 5.5 (required; older computer tool types
|
|
431
|
+
* are rejected), Opus 5, Sonnet 5, Fable 5, Fable 5.1, Opus 4.8.
|
|
432
|
+
*
|
|
433
|
+
* @param configs - Per-member settings keyed by member name, e.g.
|
|
434
|
+
* `{ zoom: { enabled: false } }`. Omitted members keep their defaults.
|
|
435
|
+
*/
|
|
436
|
+
computerToolset_20260801: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
437
|
+
action: ComputerToolset_20260801Member;
|
|
438
|
+
coordinate?: [number, number];
|
|
439
|
+
duration?: number;
|
|
440
|
+
region?: [number, number, number, number];
|
|
441
|
+
repeat?: number;
|
|
442
|
+
scroll_amount?: number;
|
|
443
|
+
scroll_direction?: "up" | "down" | "left" | "right";
|
|
444
|
+
start_coordinate?: [number, number];
|
|
445
|
+
text?: string;
|
|
446
|
+
}, {
|
|
447
|
+
configs?: Partial<Record<ComputerToolset_20260801Member, {
|
|
448
|
+
enabled?: boolean;
|
|
449
|
+
deferLoading?: boolean;
|
|
450
|
+
}>>;
|
|
451
|
+
}>;
|
|
382
452
|
/**
|
|
383
453
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
384
454
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -634,6 +704,17 @@ type AnthropicTool = {
|
|
|
634
704
|
display_height_px: number;
|
|
635
705
|
display_number: number;
|
|
636
706
|
cache_control: AnthropicCacheControl | undefined;
|
|
707
|
+
} | {
|
|
708
|
+
/**
|
|
709
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
710
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
711
|
+
*/
|
|
712
|
+
type: 'computer_toolset_20260801';
|
|
713
|
+
configs?: Record<string, {
|
|
714
|
+
enabled?: boolean;
|
|
715
|
+
defer_loading?: boolean;
|
|
716
|
+
}>;
|
|
717
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
637
718
|
} | {
|
|
638
719
|
name: string;
|
|
639
720
|
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
@@ -695,11 +776,17 @@ declare class CacheControlValidator {
|
|
|
695
776
|
getWarnings(): LanguageModelV2CallWarning[];
|
|
696
777
|
}
|
|
697
778
|
|
|
698
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, }: {
|
|
779
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, rejectsForcedToolUse, }: {
|
|
699
780
|
tools: LanguageModelV2CallOptions['tools'];
|
|
700
781
|
toolChoice?: LanguageModelV2CallOptions['toolChoice'];
|
|
701
782
|
disableParallelToolUse?: boolean;
|
|
702
783
|
cacheControlValidator?: CacheControlValidator;
|
|
784
|
+
/**
|
|
785
|
+
* Whether the model rejects forced tool use (`tool_choice` `any` or a
|
|
786
|
+
* named tool). When true, `required` and `tool` tool choices fall back to
|
|
787
|
+
* `auto` with a warning.
|
|
788
|
+
*/
|
|
789
|
+
rejectsForcedToolUse?: boolean;
|
|
703
790
|
}): Promise<{
|
|
704
791
|
tools: Array<AnthropicTool> | undefined;
|
|
705
792
|
toolChoice: AnthropicToolChoice | undefined;
|
|
@@ -716,4 +803,4 @@ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cache
|
|
|
716
803
|
*/
|
|
717
804
|
declare function sanitizeJsonSchema(schema: JSONSchema7): JSONSchema7;
|
|
718
805
|
|
|
719
|
-
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools, sanitizeJsonSchema };
|
|
806
|
+
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools, sanitizeJsonSchema };
|