@ai-sdk/anthropic 3.0.79 → 3.0.81
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 +12 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +37 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -16
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -2
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +36 -15
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +36 -15
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +5 -4
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +9 -1
- package/src/anthropic-messages-language-model.ts +34 -9
- package/src/anthropic-messages-options.ts +1 -0
- package/src/anthropic-tools.ts +1 -1
- package/src/convert-to-anthropic-messages-prompt.ts +9 -9
- package/src/tool/advisor_20260301.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@ai-sdk/provider-utils";
|
|
13
13
|
|
|
14
14
|
// src/version.ts
|
|
15
|
-
var VERSION = true ? "3.0.
|
|
15
|
+
var VERSION = true ? "3.0.81" : "0.0.0-test";
|
|
16
16
|
|
|
17
17
|
// src/anthropic-messages-language-model.ts
|
|
18
18
|
import {
|
|
@@ -2259,19 +2259,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2259
2259
|
const type = block.type;
|
|
2260
2260
|
switch (type) {
|
|
2261
2261
|
case "system": {
|
|
2262
|
-
|
|
2263
|
-
throw new UnsupportedFunctionalityError2({
|
|
2264
|
-
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2265
|
-
});
|
|
2266
|
-
}
|
|
2267
|
-
system = block.messages.map(({ content, providerOptions }) => ({
|
|
2262
|
+
const content = block.messages.map(({ content: content2, providerOptions }) => ({
|
|
2268
2263
|
type: "text",
|
|
2269
|
-
text:
|
|
2264
|
+
text: content2,
|
|
2270
2265
|
cache_control: validator.getCacheControl(providerOptions, {
|
|
2271
2266
|
type: "system message",
|
|
2272
2267
|
canCache: true
|
|
2273
2268
|
})
|
|
2274
2269
|
}));
|
|
2270
|
+
if (system == null) {
|
|
2271
|
+
system = content;
|
|
2272
|
+
} else {
|
|
2273
|
+
messages.push({ role: "system", content });
|
|
2274
|
+
betas.add("mid-conversation-system-2026-04-07");
|
|
2275
|
+
}
|
|
2275
2276
|
break;
|
|
2276
2277
|
}
|
|
2277
2278
|
case "user": {
|
|
@@ -3905,12 +3906,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3905
3906
|
}
|
|
3906
3907
|
case "server_tool_use": {
|
|
3907
3908
|
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
3909
|
+
const providerToolName = "code_execution";
|
|
3908
3910
|
content.push({
|
|
3909
3911
|
type: "tool-call",
|
|
3910
3912
|
toolCallId: part.id,
|
|
3911
3913
|
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
3912
3914
|
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
3913
|
-
providerExecuted: true
|
|
3915
|
+
providerExecuted: true,
|
|
3916
|
+
// Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
|
|
3917
|
+
// implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
|
|
3918
|
+
// tool was not explicitly provided. We therefore bypass the general validation by marking the
|
|
3919
|
+
// tool as dynamic.
|
|
3920
|
+
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
|
|
3914
3921
|
});
|
|
3915
3922
|
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
3916
3923
|
const inputToSerialize = part.name === "code_execution" && part.input != null && typeof part.input === "object" && "code" in part.input && !("type" in part.input) ? { type: "programmatic-tool-call", ...part.input } : part.input;
|
|
@@ -3920,8 +3927,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3920
3927
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
3921
3928
|
input: JSON.stringify(inputToSerialize),
|
|
3922
3929
|
providerExecuted: true,
|
|
3923
|
-
//
|
|
3924
|
-
//
|
|
3930
|
+
// Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
|
|
3931
|
+
// implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
|
|
3932
|
+
// tool was not explicitly provided. We therefore bypass the general validation by marking the
|
|
3933
|
+
// tool as dynamic.
|
|
3925
3934
|
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
|
|
3926
3935
|
});
|
|
3927
3936
|
} else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
|
|
@@ -4441,15 +4450,23 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4441
4450
|
toolName: customToolName,
|
|
4442
4451
|
input: finalInput,
|
|
4443
4452
|
providerExecuted: true,
|
|
4453
|
+
// Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
|
|
4454
|
+
// implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
|
|
4455
|
+
// tool was not explicitly provided. We therefore bypass the general validation by marking the
|
|
4456
|
+
// tool as dynamic.
|
|
4444
4457
|
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
4445
4458
|
firstDelta: true,
|
|
4446
|
-
providerToolName
|
|
4459
|
+
providerToolName
|
|
4447
4460
|
};
|
|
4448
4461
|
controller.enqueue({
|
|
4449
4462
|
type: "tool-input-start",
|
|
4450
4463
|
id: part.id,
|
|
4451
4464
|
toolName: customToolName,
|
|
4452
4465
|
providerExecuted: true,
|
|
4466
|
+
// Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
|
|
4467
|
+
// implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
|
|
4468
|
+
// tool was not explicitly provided. We therefore bypass the general validation by marking the
|
|
4469
|
+
// tool as dynamic.
|
|
4453
4470
|
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
|
|
4454
4471
|
});
|
|
4455
4472
|
} else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
|
|
@@ -4792,6 +4809,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4792
4809
|
toolName: contentBlock.toolName,
|
|
4793
4810
|
input: finalInput,
|
|
4794
4811
|
providerExecuted: contentBlock.providerExecuted,
|
|
4812
|
+
// Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
|
|
4813
|
+
// implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
|
|
4814
|
+
// tool was not explicitly provided. We therefore bypass the general validation by marking the
|
|
4815
|
+
// tool as dynamic.
|
|
4795
4816
|
...markCodeExecutionDynamic && contentBlock.providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
4796
4817
|
...contentBlock.caller && {
|
|
4797
4818
|
providerMetadata: {
|
|
@@ -4875,8 +4896,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4875
4896
|
if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
|
|
4876
4897
|
return;
|
|
4877
4898
|
}
|
|
4878
|
-
if (contentBlock.firstDelta &&
|
|
4879
|
-
delta = `{"type": "
|
|
4899
|
+
if (contentBlock.firstDelta && contentBlock.providerToolName === "code_execution") {
|
|
4900
|
+
delta = `{"type": "programmatic-tool-call",${delta.substring(1)}`;
|
|
4880
4901
|
}
|
|
4881
4902
|
controller.enqueue({
|
|
4882
4903
|
type: "tool-input-delta",
|
|
@@ -5113,7 +5134,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5113
5134
|
}
|
|
5114
5135
|
};
|
|
5115
5136
|
function getModelCapabilities(modelId) {
|
|
5116
|
-
if (modelId.includes("claude-opus-4-7")) {
|
|
5137
|
+
if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7")) {
|
|
5117
5138
|
return {
|
|
5118
5139
|
maxOutputTokens: 128e3,
|
|
5119
5140
|
supportsStructuredOutput: true,
|
|
@@ -5571,7 +5592,7 @@ var anthropicTools = {
|
|
|
5571
5592
|
* Supported executor models: Claude Haiku 4.5, Sonnet 4.6, Opus 4.6,
|
|
5572
5593
|
* Opus 4.7. The advisor must be at least as capable as the executor.
|
|
5573
5594
|
*
|
|
5574
|
-
* @param model - The advisor model ID (required), e.g. `"claude-opus-4-
|
|
5595
|
+
* @param model - The advisor model ID (required), e.g. `"claude-opus-4-8"`.
|
|
5575
5596
|
* @param maxUses - Maximum advisor calls per request (per-request cap).
|
|
5576
5597
|
* @param caching - Enables prompt caching for the advisor's transcript
|
|
5577
5598
|
* across calls within a conversation. Worthwhile from ~3 advisor calls
|