@ai-sdk/anthropic 3.0.15 → 3.0.17

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
@@ -11,7 +11,7 @@ import {
11
11
  } from "@ai-sdk/provider-utils";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = true ? "3.0.15" : "0.0.0-test";
14
+ var VERSION = true ? "3.0.17" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
@@ -1589,7 +1589,7 @@ async function convertToAnthropicMessagesPrompt({
1589
1589
  cacheControlValidator,
1590
1590
  toolNameMapping
1591
1591
  }) {
1592
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1592
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1593
1593
  const betas = /* @__PURE__ */ new Set();
1594
1594
  const blocks = groupIntoBlocks(prompt);
1595
1595
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -2142,13 +2142,25 @@ async function convertToAnthropicMessagesPrompt({
2142
2142
  if (providerToolName === "web_fetch") {
2143
2143
  const output = part.output;
2144
2144
  if (output.type === "error-json") {
2145
- const errorValue = JSON.parse(output.value);
2145
+ let errorValue = {};
2146
+ try {
2147
+ if (typeof output.value === "string") {
2148
+ errorValue = JSON.parse(output.value);
2149
+ } else if (typeof output.value === "object" && output.value !== null) {
2150
+ errorValue = output.value;
2151
+ }
2152
+ } catch (e) {
2153
+ const extractedErrorCode = (_p = output.value) == null ? void 0 : _p.errorCode;
2154
+ errorValue = {
2155
+ errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unknown"
2156
+ };
2157
+ }
2146
2158
  anthropicContent.push({
2147
2159
  type: "web_fetch_tool_result",
2148
2160
  tool_use_id: part.toolCallId,
2149
2161
  content: {
2150
2162
  type: "web_fetch_tool_result_error",
2151
- error_code: errorValue.errorCode
2163
+ error_code: (_q = errorValue.errorCode) != null ? _q : "unknown"
2152
2164
  },
2153
2165
  cache_control: cacheControl
2154
2166
  });
@@ -2677,7 +2689,7 @@ var AnthropicMessagesLanguageModel = class {
2677
2689
  toolChoice: { type: "required" },
2678
2690
  disableParallelToolUse: true,
2679
2691
  cacheControlValidator,
2680
- supportsStructuredOutput
2692
+ supportsStructuredOutput: false
2681
2693
  } : {
2682
2694
  tools: tools != null ? tools : [],
2683
2695
  toolChoice,