@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.
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  } from "@ai-sdk/provider-utils";
11
11
 
12
12
  // src/version.ts
13
- var VERSION = true ? "2.1.0-beta.9" : "0.0.0-test";
13
+ var VERSION = true ? "3.0.0-beta.15" : "0.0.0-test";
14
14
 
15
15
  // src/anthropic-messages-language-model.ts
16
16
  import {
@@ -25,11 +25,11 @@ import {
25
25
  postJsonToApi,
26
26
  resolve
27
27
  } from "@ai-sdk/provider-utils";
28
- import { z as z7 } from "zod/v4";
28
+ import * as z7 from "zod/v4";
29
29
 
30
30
  // src/anthropic-error.ts
31
31
  import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
32
- import { z } from "zod/v4";
32
+ import * as z from "zod/v4";
33
33
  var anthropicErrorDataSchema = z.object({
34
34
  type: z.literal("error"),
35
35
  error: z.object({
@@ -43,7 +43,7 @@ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
43
43
  });
44
44
 
45
45
  // src/anthropic-messages-options.ts
46
- import { z as z2 } from "zod/v4";
46
+ import * as z2 from "zod/v4";
47
47
  var anthropicFilePartProviderOptions = z2.object({
48
48
  /**
49
49
  * Citation configuration for this document.
@@ -103,7 +103,7 @@ function getCacheControl(providerMetadata) {
103
103
 
104
104
  // src/tool/text-editor_20250728.ts
105
105
  import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
106
- import { z as z3 } from "zod/v4";
106
+ import * as z3 from "zod/v4";
107
107
  var textEditor_20250728ArgsSchema = z3.object({
108
108
  maxCharacters: z3.number().optional()
109
109
  });
@@ -126,7 +126,7 @@ var textEditor_20250728 = (args = {}) => {
126
126
 
127
127
  // src/tool/web-search_20250305.ts
128
128
  import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
129
- import { z as z4 } from "zod/v4";
129
+ import * as z4 from "zod/v4";
130
130
  var webSearch_20250305ArgsSchema = z4.object({
131
131
  maxUses: z4.number().optional(),
132
132
  allowedDomains: z4.array(z4.string()).optional(),
@@ -162,7 +162,7 @@ var webSearch_20250305 = (args = {}) => {
162
162
 
163
163
  // src/tool/web-fetch-20250910.ts
164
164
  import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
165
- import { z as z5 } from "zod/v4";
165
+ import * as z5 from "zod/v4";
166
166
  var webFetch_20250910ArgsSchema = z5.object({
167
167
  maxUses: z5.number().optional(),
168
168
  allowedDomains: z5.array(z5.string()).optional(),
@@ -409,7 +409,7 @@ import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
409
409
 
410
410
  // src/tool/code-execution_20250522.ts
411
411
  import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@ai-sdk/provider-utils";
412
- import { z as z6 } from "zod/v4";
412
+ import * as z6 from "zod/v4";
413
413
  var codeExecution_20250522OutputSchema = z6.object({
414
414
  type: z6.literal("code_execution_result"),
415
415
  stdout: z6.string(),
@@ -450,7 +450,7 @@ async function convertToAnthropicMessagesPrompt({
450
450
  sendReasoning,
451
451
  warnings
452
452
  }) {
453
- var _a, _b, _c, _d, _e;
453
+ var _a, _b, _c, _d, _e, _f;
454
454
  const betas = /* @__PURE__ */ new Set();
455
455
  const blocks = groupIntoBlocks(prompt);
456
456
  let system = void 0;
@@ -626,6 +626,9 @@ async function convertToAnthropicMessagesPrompt({
626
626
  case "error-text":
627
627
  contentValue = output.value;
628
628
  break;
629
+ case "execution-denied":
630
+ contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
631
+ break;
629
632
  case "json":
630
633
  case "error-json":
631
634
  default:
@@ -660,7 +663,7 @@ async function convertToAnthropicMessagesPrompt({
660
663
  for (let k = 0; k < content.length; k++) {
661
664
  const part = content[k];
662
665
  const isLastContentPart = k === content.length - 1;
663
- const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
666
+ const cacheControl = (_f = getCacheControl(part.providerOptions)) != null ? _f : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
664
667
  switch (part.type) {
665
668
  case "text": {
666
669
  anthropicContent.push({
@@ -1197,7 +1200,7 @@ var AnthropicMessagesLanguageModel = class {
1197
1200
  });
1198
1201
  }
1199
1202
  async doGenerate(options) {
1200
- var _a, _b, _c, _d, _e;
1203
+ var _a, _b, _c, _d, _e, _f;
1201
1204
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1202
1205
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1203
1206
  const {
@@ -1424,7 +1427,8 @@ var AnthropicMessagesLanguageModel = class {
1424
1427
  providerMetadata: {
1425
1428
  anthropic: {
1426
1429
  usage: response.usage,
1427
- cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1430
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
1431
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null
1428
1432
  }
1429
1433
  }
1430
1434
  };
@@ -1453,6 +1457,7 @@ var AnthropicMessagesLanguageModel = class {
1453
1457
  const contentBlocks = {};
1454
1458
  let rawUsage = void 0;
1455
1459
  let cacheCreationInputTokens = null;
1460
+ let stopSequence = null;
1456
1461
  let blockType = void 0;
1457
1462
  const generateId3 = this.generateId;
1458
1463
  return {
@@ -1462,7 +1467,7 @@ var AnthropicMessagesLanguageModel = class {
1462
1467
  controller.enqueue({ type: "stream-start", warnings });
1463
1468
  },
1464
1469
  transform(chunk, controller) {
1465
- var _a, _b, _c, _d, _e, _f, _g;
1470
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1466
1471
  if (options.includeRawChunks) {
1467
1472
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1468
1473
  }
@@ -1800,6 +1805,7 @@ var AnthropicMessagesLanguageModel = class {
1800
1805
  finishReason: value.delta.stop_reason,
1801
1806
  isJsonResponseFromTool: usesJsonResponseTool
1802
1807
  });
1808
+ stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
1803
1809
  rawUsage = {
1804
1810
  ...rawUsage,
1805
1811
  ...value.usage
@@ -1814,7 +1820,8 @@ var AnthropicMessagesLanguageModel = class {
1814
1820
  providerMetadata: {
1815
1821
  anthropic: {
1816
1822
  usage: rawUsage != null ? rawUsage : null,
1817
- cacheCreationInputTokens
1823
+ cacheCreationInputTokens,
1824
+ stopSequence
1818
1825
  }
1819
1826
  }
1820
1827
  });
@@ -1932,6 +1939,7 @@ var anthropicMessagesResponseSchema = z7.object({
1932
1939
  ])
1933
1940
  ),
1934
1941
  stop_reason: z7.string().nullish(),
1942
+ stop_sequence: z7.string().nullish(),
1935
1943
  usage: z7.looseObject({
1936
1944
  input_tokens: z7.number(),
1937
1945
  output_tokens: z7.number(),
@@ -2080,7 +2088,10 @@ var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
2080
2088
  }),
2081
2089
  z7.object({
2082
2090
  type: z7.literal("message_delta"),
2083
- delta: z7.object({ stop_reason: z7.string().nullish() }),
2091
+ delta: z7.object({
2092
+ stop_reason: z7.string().nullish(),
2093
+ stop_sequence: z7.string().nullish()
2094
+ }),
2084
2095
  usage: z7.looseObject({
2085
2096
  output_tokens: z7.number(),
2086
2097
  cache_creation_input_tokens: z7.number().nullish()
@@ -2124,7 +2135,7 @@ var bash_20250124 = createProviderDefinedToolFactory3({
2124
2135
 
2125
2136
  // src/tool/computer_20241022.ts
2126
2137
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
2127
- import { z as z10 } from "zod/v4";
2138
+ import * as z10 from "zod/v4";
2128
2139
  var computer_20241022 = createProviderDefinedToolFactory4({
2129
2140
  id: "anthropic.computer_20241022",
2130
2141
  name: "computer",
@@ -2148,7 +2159,7 @@ var computer_20241022 = createProviderDefinedToolFactory4({
2148
2159
 
2149
2160
  // src/tool/computer_20250124.ts
2150
2161
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
2151
- import { z as z11 } from "zod/v4";
2162
+ import * as z11 from "zod/v4";
2152
2163
  var computer_20250124 = createProviderDefinedToolFactory5({
2153
2164
  id: "anthropic.computer_20250124",
2154
2165
  name: "computer",
@@ -2182,7 +2193,7 @@ var computer_20250124 = createProviderDefinedToolFactory5({
2182
2193
 
2183
2194
  // src/tool/text-editor_20241022.ts
2184
2195
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
2185
- import { z as z12 } from "zod/v4";
2196
+ import * as z12 from "zod/v4";
2186
2197
  var textEditor_20241022 = createProviderDefinedToolFactory6({
2187
2198
  id: "anthropic.text_editor_20241022",
2188
2199
  name: "str_replace_editor",
@@ -2199,7 +2210,7 @@ var textEditor_20241022 = createProviderDefinedToolFactory6({
2199
2210
 
2200
2211
  // src/tool/text-editor_20250124.ts
2201
2212
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
2202
- import { z as z13 } from "zod/v4";
2213
+ import * as z13 from "zod/v4";
2203
2214
  var textEditor_20250124 = createProviderDefinedToolFactory7({
2204
2215
  id: "anthropic.text_editor_20250124",
2205
2216
  name: "str_replace_editor",
@@ -2216,7 +2227,7 @@ var textEditor_20250124 = createProviderDefinedToolFactory7({
2216
2227
 
2217
2228
  // src/tool/text-editor_20250429.ts
2218
2229
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory8 } from "@ai-sdk/provider-utils";
2219
- import { z as z14 } from "zod/v4";
2230
+ import * as z14 from "zod/v4";
2220
2231
  var textEditor_20250429 = createProviderDefinedToolFactory8({
2221
2232
  id: "anthropic.text_editor_20250429",
2222
2233
  name: "str_replace_based_edit_tool",