@ai-sdk/anthropic 2.1.0-beta.9 → 3.0.0-beta.15

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.
@@ -11,11 +11,11 @@ import {
11
11
  postJsonToApi,
12
12
  resolve
13
13
  } from "@ai-sdk/provider-utils";
14
- import { z as z7 } from "zod/v4";
14
+ import * as z7 from "zod/v4";
15
15
 
16
16
  // src/anthropic-error.ts
17
17
  import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
18
- import { z } from "zod/v4";
18
+ import * as z from "zod/v4";
19
19
  var anthropicErrorDataSchema = z.object({
20
20
  type: z.literal("error"),
21
21
  error: z.object({
@@ -29,7 +29,7 @@ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
29
29
  });
30
30
 
31
31
  // src/anthropic-messages-options.ts
32
- import { z as z2 } from "zod/v4";
32
+ import * as z2 from "zod/v4";
33
33
  var anthropicFilePartProviderOptions = z2.object({
34
34
  /**
35
35
  * Citation configuration for this document.
@@ -89,7 +89,7 @@ function getCacheControl(providerMetadata) {
89
89
 
90
90
  // src/tool/text-editor_20250728.ts
91
91
  import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
92
- import { z as z3 } from "zod/v4";
92
+ import * as z3 from "zod/v4";
93
93
  var textEditor_20250728ArgsSchema = z3.object({
94
94
  maxCharacters: z3.number().optional()
95
95
  });
@@ -112,7 +112,7 @@ var textEditor_20250728 = (args = {}) => {
112
112
 
113
113
  // src/tool/web-search_20250305.ts
114
114
  import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
115
- import { z as z4 } from "zod/v4";
115
+ import * as z4 from "zod/v4";
116
116
  var webSearch_20250305ArgsSchema = z4.object({
117
117
  maxUses: z4.number().optional(),
118
118
  allowedDomains: z4.array(z4.string()).optional(),
@@ -148,7 +148,7 @@ var webSearch_20250305 = (args = {}) => {
148
148
 
149
149
  // src/tool/web-fetch-20250910.ts
150
150
  import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
151
- import { z as z5 } from "zod/v4";
151
+ import * as z5 from "zod/v4";
152
152
  var webFetch_20250910ArgsSchema = z5.object({
153
153
  maxUses: z5.number().optional(),
154
154
  allowedDomains: z5.array(z5.string()).optional(),
@@ -395,7 +395,7 @@ import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
395
395
 
396
396
  // src/tool/code-execution_20250522.ts
397
397
  import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@ai-sdk/provider-utils";
398
- import { z as z6 } from "zod/v4";
398
+ import * as z6 from "zod/v4";
399
399
  var codeExecution_20250522OutputSchema = z6.object({
400
400
  type: z6.literal("code_execution_result"),
401
401
  stdout: z6.string(),
@@ -436,7 +436,7 @@ async function convertToAnthropicMessagesPrompt({
436
436
  sendReasoning,
437
437
  warnings
438
438
  }) {
439
- var _a, _b, _c, _d, _e;
439
+ var _a, _b, _c, _d, _e, _f;
440
440
  const betas = /* @__PURE__ */ new Set();
441
441
  const blocks = groupIntoBlocks(prompt);
442
442
  let system = void 0;
@@ -612,6 +612,9 @@ async function convertToAnthropicMessagesPrompt({
612
612
  case "error-text":
613
613
  contentValue = output.value;
614
614
  break;
615
+ case "execution-denied":
616
+ contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
617
+ break;
615
618
  case "json":
616
619
  case "error-json":
617
620
  default:
@@ -646,7 +649,7 @@ async function convertToAnthropicMessagesPrompt({
646
649
  for (let k = 0; k < content.length; k++) {
647
650
  const part = content[k];
648
651
  const isLastContentPart = k === content.length - 1;
649
- const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
652
+ const cacheControl = (_f = getCacheControl(part.providerOptions)) != null ? _f : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
650
653
  switch (part.type) {
651
654
  case "text": {
652
655
  anthropicContent.push({
@@ -1183,7 +1186,7 @@ var AnthropicMessagesLanguageModel = class {
1183
1186
  });
1184
1187
  }
1185
1188
  async doGenerate(options) {
1186
- var _a, _b, _c, _d, _e;
1189
+ var _a, _b, _c, _d, _e, _f;
1187
1190
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1188
1191
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1189
1192
  const {
@@ -1410,7 +1413,8 @@ var AnthropicMessagesLanguageModel = class {
1410
1413
  providerMetadata: {
1411
1414
  anthropic: {
1412
1415
  usage: response.usage,
1413
- cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1416
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
1417
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null
1414
1418
  }
1415
1419
  }
1416
1420
  };
@@ -1439,6 +1443,7 @@ var AnthropicMessagesLanguageModel = class {
1439
1443
  const contentBlocks = {};
1440
1444
  let rawUsage = void 0;
1441
1445
  let cacheCreationInputTokens = null;
1446
+ let stopSequence = null;
1442
1447
  let blockType = void 0;
1443
1448
  const generateId2 = this.generateId;
1444
1449
  return {
@@ -1448,7 +1453,7 @@ var AnthropicMessagesLanguageModel = class {
1448
1453
  controller.enqueue({ type: "stream-start", warnings });
1449
1454
  },
1450
1455
  transform(chunk, controller) {
1451
- var _a, _b, _c, _d, _e, _f, _g;
1456
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1452
1457
  if (options.includeRawChunks) {
1453
1458
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1454
1459
  }
@@ -1786,6 +1791,7 @@ var AnthropicMessagesLanguageModel = class {
1786
1791
  finishReason: value.delta.stop_reason,
1787
1792
  isJsonResponseFromTool: usesJsonResponseTool
1788
1793
  });
1794
+ stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
1789
1795
  rawUsage = {
1790
1796
  ...rawUsage,
1791
1797
  ...value.usage
@@ -1800,7 +1806,8 @@ var AnthropicMessagesLanguageModel = class {
1800
1806
  providerMetadata: {
1801
1807
  anthropic: {
1802
1808
  usage: rawUsage != null ? rawUsage : null,
1803
- cacheCreationInputTokens
1809
+ cacheCreationInputTokens,
1810
+ stopSequence
1804
1811
  }
1805
1812
  }
1806
1813
  });
@@ -1918,6 +1925,7 @@ var anthropicMessagesResponseSchema = z7.object({
1918
1925
  ])
1919
1926
  ),
1920
1927
  stop_reason: z7.string().nullish(),
1928
+ stop_sequence: z7.string().nullish(),
1921
1929
  usage: z7.looseObject({
1922
1930
  input_tokens: z7.number(),
1923
1931
  output_tokens: z7.number(),
@@ -2066,7 +2074,10 @@ var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
2066
2074
  }),
2067
2075
  z7.object({
2068
2076
  type: z7.literal("message_delta"),
2069
- delta: z7.object({ stop_reason: z7.string().nullish() }),
2077
+ delta: z7.object({
2078
+ stop_reason: z7.string().nullish(),
2079
+ stop_sequence: z7.string().nullish()
2080
+ }),
2070
2081
  usage: z7.looseObject({
2071
2082
  output_tokens: z7.number(),
2072
2083
  cache_creation_input_tokens: z7.number().nullish()
@@ -2110,7 +2121,7 @@ var bash_20250124 = createProviderDefinedToolFactory3({
2110
2121
 
2111
2122
  // src/tool/computer_20241022.ts
2112
2123
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
2113
- import { z as z10 } from "zod/v4";
2124
+ import * as z10 from "zod/v4";
2114
2125
  var computer_20241022 = createProviderDefinedToolFactory4({
2115
2126
  id: "anthropic.computer_20241022",
2116
2127
  name: "computer",
@@ -2134,7 +2145,7 @@ var computer_20241022 = createProviderDefinedToolFactory4({
2134
2145
 
2135
2146
  // src/tool/computer_20250124.ts
2136
2147
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
2137
- import { z as z11 } from "zod/v4";
2148
+ import * as z11 from "zod/v4";
2138
2149
  var computer_20250124 = createProviderDefinedToolFactory5({
2139
2150
  id: "anthropic.computer_20250124",
2140
2151
  name: "computer",
@@ -2168,7 +2179,7 @@ var computer_20250124 = createProviderDefinedToolFactory5({
2168
2179
 
2169
2180
  // src/tool/text-editor_20241022.ts
2170
2181
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
2171
- import { z as z12 } from "zod/v4";
2182
+ import * as z12 from "zod/v4";
2172
2183
  var textEditor_20241022 = createProviderDefinedToolFactory6({
2173
2184
  id: "anthropic.text_editor_20241022",
2174
2185
  name: "str_replace_editor",
@@ -2185,7 +2196,7 @@ var textEditor_20241022 = createProviderDefinedToolFactory6({
2185
2196
 
2186
2197
  // src/tool/text-editor_20250124.ts
2187
2198
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
2188
- import { z as z13 } from "zod/v4";
2199
+ import * as z13 from "zod/v4";
2189
2200
  var textEditor_20250124 = createProviderDefinedToolFactory7({
2190
2201
  id: "anthropic.text_editor_20250124",
2191
2202
  name: "str_replace_editor",
@@ -2202,7 +2213,7 @@ var textEditor_20250124 = createProviderDefinedToolFactory7({
2202
2213
 
2203
2214
  // src/tool/text-editor_20250429.ts
2204
2215
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory8 } from "@ai-sdk/provider-utils";
2205
- import { z as z14 } from "zod/v4";
2216
+ import * as z14 from "zod/v4";
2206
2217
  var textEditor_20250429 = createProviderDefinedToolFactory8({
2207
2218
  id: "anthropic.text_editor_20250429",
2208
2219
  name: "str_replace_based_edit_tool",