@ai-sdk/anthropic 3.0.128 → 3.0.129

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,12 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.129
4
+
5
+ ### Patch Changes
6
+
7
+ - ed0cd89: fix(anthropic): preserve tools when disabling tool calls
8
+ - b5d3c2f: fix(anthropic): preserve failed tool search results in conversation history
9
+
3
10
  ## 3.0.128
4
11
 
5
12
  ### Patch Changes
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils27 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.128" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.129" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -1990,7 +1990,12 @@ async function prepareTools({
1990
1990
  betas
1991
1991
  };
1992
1992
  case "none":
1993
- return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
1993
+ return {
1994
+ tools: anthropicTools2,
1995
+ toolChoice: { type: "none" },
1996
+ toolWarnings,
1997
+ betas
1998
+ };
1994
1999
  case "tool":
1995
2000
  if (rejectsForcedToolUse) {
1996
2001
  toolWarnings.push({
@@ -2439,7 +2444,7 @@ async function convertToAnthropicMessagesPrompt({
2439
2444
  toolNameMapping,
2440
2445
  toolsetNames = {}
2441
2446
  }) {
2442
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2447
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2443
2448
  const betas = /* @__PURE__ */ new Set();
2444
2449
  const blocks = groupIntoBlocks(prompt);
2445
2450
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -3251,6 +3256,18 @@ async function convertToAnthropicMessagesPrompt({
3251
3256
  }
3252
3257
  if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
3253
3258
  const output = part.output;
3259
+ if (output.type === "error-json" || output.type === "json" && output.value != null && typeof output.value === "object" && !Array.isArray(output.value) && "type" in output.value && output.value.type === "tool_search_tool_result_error") {
3260
+ anthropicContent.push({
3261
+ type: "tool_search_tool_result",
3262
+ tool_use_id: part.toolCallId,
3263
+ content: {
3264
+ type: "tool_search_tool_result_error",
3265
+ error_code: (_v = (await extractErrorValue(output.value)).errorCode) != null ? _v : "unavailable"
3266
+ },
3267
+ cache_control: cacheControl
3268
+ });
3269
+ break;
3270
+ }
3254
3271
  if (output.type !== "json") {
3255
3272
  warnings.push({
3256
3273
  type: "other",