@ai-sdk/anthropic 3.0.76 → 3.0.77
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 +6 -0
- package/dist/index.d.mts +99 -4
- package/dist/index.d.ts +99 -4
- package/dist/index.js +810 -454
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +790 -430
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +63 -0
- package/dist/internal/index.d.ts +63 -0
- package/dist/internal/index.js +803 -447
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +789 -429
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +57 -0
- package/package.json +1 -1
- package/src/anthropic-message-metadata.ts +63 -13
- package/src/anthropic-messages-api.ts +113 -11
- package/src/anthropic-messages-language-model.ts +186 -11
- package/src/anthropic-prepare-tools.ts +17 -0
- package/src/anthropic-tools.ts +31 -0
- package/src/convert-anthropic-messages-usage.ts +50 -22
- package/src/convert-to-anthropic-messages-prompt.ts +62 -0
- package/src/tool/advisor_20260301.ts +128 -0
|
@@ -48,6 +48,60 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
declare const anthropicTools: {
|
|
51
|
+
/**
|
|
52
|
+
* Pairs a faster executor model with a higher-intelligence advisor model
|
|
53
|
+
* that provides strategic guidance mid-generation.
|
|
54
|
+
*
|
|
55
|
+
* The advisor lets a faster, lower-cost executor model consult a
|
|
56
|
+
* higher-intelligence advisor model server-side. The advisor reads the
|
|
57
|
+
* executor's full transcript and produces a plan or course correction;
|
|
58
|
+
* the executor continues with the task, informed by the advice. All of
|
|
59
|
+
* this happens inside a single `/v1/messages` request.
|
|
60
|
+
*
|
|
61
|
+
* Beta header `advisor-tool-2026-03-01` is added automatically when this
|
|
62
|
+
* tool is included.
|
|
63
|
+
*
|
|
64
|
+
* Multi-turn conversations: pass the full assistant content (including
|
|
65
|
+
* `advisor_tool_result` blocks) back to the API on subsequent turns. If
|
|
66
|
+
* you omit the advisor tool from `tools` on a follow-up turn while the
|
|
67
|
+
* message history still contains `advisor_tool_result` blocks, the API
|
|
68
|
+
* returns a `400 invalid_request_error`.
|
|
69
|
+
*
|
|
70
|
+
* Supported executor models: Claude Haiku 4.5, Sonnet 4.6, Opus 4.6,
|
|
71
|
+
* Opus 4.7. The advisor must be at least as capable as the executor.
|
|
72
|
+
*
|
|
73
|
+
* @param model - The advisor model ID (required), e.g. `"claude-opus-4-7"`.
|
|
74
|
+
* @param maxUses - Maximum advisor calls per request (per-request cap).
|
|
75
|
+
* @param caching - Enables prompt caching for the advisor's transcript
|
|
76
|
+
* across calls within a conversation. Worthwhile from ~3 advisor calls
|
|
77
|
+
* per conversation.
|
|
78
|
+
*/
|
|
79
|
+
advisor_20260301: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
80
|
+
type: "advisor_result";
|
|
81
|
+
text: string;
|
|
82
|
+
} | {
|
|
83
|
+
type: "advisor_redacted_result";
|
|
84
|
+
encryptedContent: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: "advisor_tool_result_error";
|
|
87
|
+
errorCode: string;
|
|
88
|
+
}, {
|
|
89
|
+
model: string;
|
|
90
|
+
maxUses?: number;
|
|
91
|
+
caching?: {
|
|
92
|
+
type: "ephemeral";
|
|
93
|
+
ttl: "5m" | "1h";
|
|
94
|
+
};
|
|
95
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
96
|
+
type: "advisor_result";
|
|
97
|
+
text: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: "advisor_redacted_result";
|
|
100
|
+
encryptedContent: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: "advisor_tool_result_error";
|
|
103
|
+
errorCode: string;
|
|
104
|
+
}>;
|
|
51
105
|
/**
|
|
52
106
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
53
107
|
* allowing system operations, script execution, and command-line automation.
|
|
@@ -926,6 +980,15 @@ type AnthropicTool = {
|
|
|
926
980
|
} | {
|
|
927
981
|
type: 'tool_search_tool_bm25_20251119';
|
|
928
982
|
name: string;
|
|
983
|
+
} | {
|
|
984
|
+
type: 'advisor_20260301';
|
|
985
|
+
name: 'advisor';
|
|
986
|
+
model: string;
|
|
987
|
+
max_uses?: number;
|
|
988
|
+
caching?: {
|
|
989
|
+
type: 'ephemeral';
|
|
990
|
+
ttl: '5m' | '1h';
|
|
991
|
+
};
|
|
929
992
|
};
|
|
930
993
|
type AnthropicToolChoice = {
|
|
931
994
|
type: 'auto' | 'any';
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -48,6 +48,60 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
declare const anthropicTools: {
|
|
51
|
+
/**
|
|
52
|
+
* Pairs a faster executor model with a higher-intelligence advisor model
|
|
53
|
+
* that provides strategic guidance mid-generation.
|
|
54
|
+
*
|
|
55
|
+
* The advisor lets a faster, lower-cost executor model consult a
|
|
56
|
+
* higher-intelligence advisor model server-side. The advisor reads the
|
|
57
|
+
* executor's full transcript and produces a plan or course correction;
|
|
58
|
+
* the executor continues with the task, informed by the advice. All of
|
|
59
|
+
* this happens inside a single `/v1/messages` request.
|
|
60
|
+
*
|
|
61
|
+
* Beta header `advisor-tool-2026-03-01` is added automatically when this
|
|
62
|
+
* tool is included.
|
|
63
|
+
*
|
|
64
|
+
* Multi-turn conversations: pass the full assistant content (including
|
|
65
|
+
* `advisor_tool_result` blocks) back to the API on subsequent turns. If
|
|
66
|
+
* you omit the advisor tool from `tools` on a follow-up turn while the
|
|
67
|
+
* message history still contains `advisor_tool_result` blocks, the API
|
|
68
|
+
* returns a `400 invalid_request_error`.
|
|
69
|
+
*
|
|
70
|
+
* Supported executor models: Claude Haiku 4.5, Sonnet 4.6, Opus 4.6,
|
|
71
|
+
* Opus 4.7. The advisor must be at least as capable as the executor.
|
|
72
|
+
*
|
|
73
|
+
* @param model - The advisor model ID (required), e.g. `"claude-opus-4-7"`.
|
|
74
|
+
* @param maxUses - Maximum advisor calls per request (per-request cap).
|
|
75
|
+
* @param caching - Enables prompt caching for the advisor's transcript
|
|
76
|
+
* across calls within a conversation. Worthwhile from ~3 advisor calls
|
|
77
|
+
* per conversation.
|
|
78
|
+
*/
|
|
79
|
+
advisor_20260301: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
80
|
+
type: "advisor_result";
|
|
81
|
+
text: string;
|
|
82
|
+
} | {
|
|
83
|
+
type: "advisor_redacted_result";
|
|
84
|
+
encryptedContent: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: "advisor_tool_result_error";
|
|
87
|
+
errorCode: string;
|
|
88
|
+
}, {
|
|
89
|
+
model: string;
|
|
90
|
+
maxUses?: number;
|
|
91
|
+
caching?: {
|
|
92
|
+
type: "ephemeral";
|
|
93
|
+
ttl: "5m" | "1h";
|
|
94
|
+
};
|
|
95
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
96
|
+
type: "advisor_result";
|
|
97
|
+
text: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: "advisor_redacted_result";
|
|
100
|
+
encryptedContent: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: "advisor_tool_result_error";
|
|
103
|
+
errorCode: string;
|
|
104
|
+
}>;
|
|
51
105
|
/**
|
|
52
106
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
53
107
|
* allowing system operations, script execution, and command-line automation.
|
|
@@ -926,6 +980,15 @@ type AnthropicTool = {
|
|
|
926
980
|
} | {
|
|
927
981
|
type: 'tool_search_tool_bm25_20251119';
|
|
928
982
|
name: string;
|
|
983
|
+
} | {
|
|
984
|
+
type: 'advisor_20260301';
|
|
985
|
+
name: 'advisor';
|
|
986
|
+
model: string;
|
|
987
|
+
max_uses?: number;
|
|
988
|
+
caching?: {
|
|
989
|
+
type: 'ephemeral';
|
|
990
|
+
ttl: '5m' | '1h';
|
|
991
|
+
};
|
|
929
992
|
};
|
|
930
993
|
type AnthropicToolChoice = {
|
|
931
994
|
type: 'auto' | 'any';
|