@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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.81
4
+
5
+ ### Patch Changes
6
+
7
+ - 4084fcd: feat(provider/anthropic): add support for `claude-opus-4-8`
8
+
9
+ ## 3.0.80
10
+
11
+ ### Patch Changes
12
+
13
+ - 263d3e6: fix(provider/anthropic): fix remaining errors with Anthropic `code_execution` tool dynamic calls from latest `web_fetch` or `web_search`
14
+
3
15
  ## 3.0.79
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -169,7 +169,7 @@ interface AnthropicMessageMetadata {
169
169
  } | null;
170
170
  }
171
171
 
172
- type AnthropicMessagesModelId = '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' | (string & {});
172
+ type AnthropicMessagesModelId = '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' | (string & {});
173
173
  declare const anthropicLanguageModelOptions: z.ZodObject<{
174
174
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
175
175
  structuredOutputMode: z.ZodOptional<z.ZodEnum<{
@@ -305,7 +305,7 @@ declare const anthropicTools: {
305
305
  * Supported executor models: Claude Haiku 4.5, Sonnet 4.6, Opus 4.6,
306
306
  * Opus 4.7. The advisor must be at least as capable as the executor.
307
307
  *
308
- * @param model - The advisor model ID (required), e.g. `"claude-opus-4-7"`.
308
+ * @param model - The advisor model ID (required), e.g. `"claude-opus-4-8"`.
309
309
  * @param maxUses - Maximum advisor calls per request (per-request cap).
310
310
  * @param caching - Enables prompt caching for the advisor's transcript
311
311
  * across calls within a conversation. Worthwhile from ~3 advisor calls
package/dist/index.d.ts CHANGED
@@ -169,7 +169,7 @@ interface AnthropicMessageMetadata {
169
169
  } | null;
170
170
  }
171
171
 
172
- type AnthropicMessagesModelId = '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' | (string & {});
172
+ type AnthropicMessagesModelId = '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' | (string & {});
173
173
  declare const anthropicLanguageModelOptions: z.ZodObject<{
174
174
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
175
175
  structuredOutputMode: z.ZodOptional<z.ZodEnum<{
@@ -305,7 +305,7 @@ declare const anthropicTools: {
305
305
  * Supported executor models: Claude Haiku 4.5, Sonnet 4.6, Opus 4.6,
306
306
  * Opus 4.7. The advisor must be at least as capable as the executor.
307
307
  *
308
- * @param model - The advisor model ID (required), e.g. `"claude-opus-4-7"`.
308
+ * @param model - The advisor model ID (required), e.g. `"claude-opus-4-8"`.
309
309
  * @param maxUses - Maximum advisor calls per request (per-request cap).
310
310
  * @param caching - Enables prompt caching for the advisor's transcript
311
311
  * across calls within a conversation. Worthwhile from ~3 advisor calls
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.79" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.81" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -2210,19 +2210,20 @@ async function convertToAnthropicMessagesPrompt({
2210
2210
  const type = block.type;
2211
2211
  switch (type) {
2212
2212
  case "system": {
2213
- if (system != null) {
2214
- throw new import_provider2.UnsupportedFunctionalityError({
2215
- functionality: "Multiple system messages that are separated by user/assistant messages"
2216
- });
2217
- }
2218
- system = block.messages.map(({ content, providerOptions }) => ({
2213
+ const content = block.messages.map(({ content: content2, providerOptions }) => ({
2219
2214
  type: "text",
2220
- text: content,
2215
+ text: content2,
2221
2216
  cache_control: validator.getCacheControl(providerOptions, {
2222
2217
  type: "system message",
2223
2218
  canCache: true
2224
2219
  })
2225
2220
  }));
2221
+ if (system == null) {
2222
+ system = content;
2223
+ } else {
2224
+ messages.push({ role: "system", content });
2225
+ betas.add("mid-conversation-system-2026-04-07");
2226
+ }
2226
2227
  break;
2227
2228
  }
2228
2229
  case "user": {
@@ -3856,12 +3857,18 @@ var AnthropicMessagesLanguageModel = class {
3856
3857
  }
3857
3858
  case "server_tool_use": {
3858
3859
  if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
3860
+ const providerToolName = "code_execution";
3859
3861
  content.push({
3860
3862
  type: "tool-call",
3861
3863
  toolCallId: part.id,
3862
3864
  toolName: toolNameMapping.toCustomToolName("code_execution"),
3863
3865
  input: JSON.stringify({ type: part.name, ...part.input }),
3864
- providerExecuted: true
3866
+ providerExecuted: true,
3867
+ // Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
3868
+ // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
3869
+ // tool was not explicitly provided. We therefore bypass the general validation by marking the
3870
+ // tool as dynamic.
3871
+ ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
3865
3872
  });
3866
3873
  } else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
3867
3874
  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;
@@ -3871,8 +3878,10 @@ var AnthropicMessagesLanguageModel = class {
3871
3878
  toolName: toolNameMapping.toCustomToolName(part.name),
3872
3879
  input: JSON.stringify(inputToSerialize),
3873
3880
  providerExecuted: true,
3874
- // We want this 'code_execution' tool call to be allowed even if the tool is not explicitly provided.
3875
- // Since the validation generally bypasses dynamic tools, we mark this specific tool as dynamic.
3881
+ // Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
3882
+ // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
3883
+ // tool was not explicitly provided. We therefore bypass the general validation by marking the
3884
+ // tool as dynamic.
3876
3885
  ...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
3877
3886
  });
3878
3887
  } else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
@@ -4392,15 +4401,23 @@ var AnthropicMessagesLanguageModel = class {
4392
4401
  toolName: customToolName,
4393
4402
  input: finalInput,
4394
4403
  providerExecuted: true,
4404
+ // Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
4405
+ // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
4406
+ // tool was not explicitly provided. We therefore bypass the general validation by marking the
4407
+ // tool as dynamic.
4395
4408
  ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
4396
4409
  firstDelta: true,
4397
- providerToolName: part.name
4410
+ providerToolName
4398
4411
  };
4399
4412
  controller.enqueue({
4400
4413
  type: "tool-input-start",
4401
4414
  id: part.id,
4402
4415
  toolName: customToolName,
4403
4416
  providerExecuted: true,
4417
+ // Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
4418
+ // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
4419
+ // tool was not explicitly provided. We therefore bypass the general validation by marking the
4420
+ // tool as dynamic.
4404
4421
  ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
4405
4422
  });
4406
4423
  } else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
@@ -4743,6 +4760,10 @@ var AnthropicMessagesLanguageModel = class {
4743
4760
  toolName: contentBlock.toolName,
4744
4761
  input: finalInput,
4745
4762
  providerExecuted: contentBlock.providerExecuted,
4763
+ // Specific 'web_fetch' or 'web_search' tools may need code execution, which the Anthropic API
4764
+ // implicitly allows. In this scenario, we need to allow 'code_execution' tool calls even if the
4765
+ // tool was not explicitly provided. We therefore bypass the general validation by marking the
4766
+ // tool as dynamic.
4746
4767
  ...markCodeExecutionDynamic && contentBlock.providerToolName === "code_execution" ? { dynamic: true } : {},
4747
4768
  ...contentBlock.caller && {
4748
4769
  providerMetadata: {
@@ -4826,8 +4847,8 @@ var AnthropicMessagesLanguageModel = class {
4826
4847
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
4827
4848
  return;
4828
4849
  }
4829
- if (contentBlock.firstDelta && (contentBlock.providerToolName === "bash_code_execution" || contentBlock.providerToolName === "text_editor_code_execution")) {
4830
- delta = `{"type": "${contentBlock.providerToolName}",${delta.substring(1)}`;
4850
+ if (contentBlock.firstDelta && contentBlock.providerToolName === "code_execution") {
4851
+ delta = `{"type": "programmatic-tool-call",${delta.substring(1)}`;
4831
4852
  }
4832
4853
  controller.enqueue({
4833
4854
  type: "tool-input-delta",
@@ -5064,7 +5085,7 @@ var AnthropicMessagesLanguageModel = class {
5064
5085
  }
5065
5086
  };
5066
5087
  function getModelCapabilities(modelId) {
5067
- if (modelId.includes("claude-opus-4-7")) {
5088
+ if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7")) {
5068
5089
  return {
5069
5090
  maxOutputTokens: 128e3,
5070
5091
  supportsStructuredOutput: true,
@@ -5482,7 +5503,7 @@ var anthropicTools = {
5482
5503
  * Supported executor models: Claude Haiku 4.5, Sonnet 4.6, Opus 4.6,
5483
5504
  * Opus 4.7. The advisor must be at least as capable as the executor.
5484
5505
  *
5485
- * @param model - The advisor model ID (required), e.g. `"claude-opus-4-7"`.
5506
+ * @param model - The advisor model ID (required), e.g. `"claude-opus-4-8"`.
5486
5507
  * @param maxUses - Maximum advisor calls per request (per-request cap).
5487
5508
  * @param caching - Enables prompt caching for the advisor's transcript
5488
5509
  * across calls within a conversation. Worthwhile from ~3 advisor calls