@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.
@@ -1558,7 +1558,7 @@ async function convertToAnthropicMessagesPrompt({
1558
1558
  cacheControlValidator,
1559
1559
  toolNameMapping
1560
1560
  }) {
1561
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1561
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1562
1562
  const betas = /* @__PURE__ */ new Set();
1563
1563
  const blocks = groupIntoBlocks(prompt);
1564
1564
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -2111,13 +2111,25 @@ async function convertToAnthropicMessagesPrompt({
2111
2111
  if (providerToolName === "web_fetch") {
2112
2112
  const output = part.output;
2113
2113
  if (output.type === "error-json") {
2114
- const errorValue = JSON.parse(output.value);
2114
+ let errorValue = {};
2115
+ try {
2116
+ if (typeof output.value === "string") {
2117
+ errorValue = JSON.parse(output.value);
2118
+ } else if (typeof output.value === "object" && output.value !== null) {
2119
+ errorValue = output.value;
2120
+ }
2121
+ } catch (e) {
2122
+ const extractedErrorCode = (_p = output.value) == null ? void 0 : _p.errorCode;
2123
+ errorValue = {
2124
+ errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unknown"
2125
+ };
2126
+ }
2115
2127
  anthropicContent.push({
2116
2128
  type: "web_fetch_tool_result",
2117
2129
  tool_use_id: part.toolCallId,
2118
2130
  content: {
2119
2131
  type: "web_fetch_tool_result_error",
2120
- error_code: errorValue.errorCode
2132
+ error_code: (_q = errorValue.errorCode) != null ? _q : "unknown"
2121
2133
  },
2122
2134
  cache_control: cacheControl
2123
2135
  });
@@ -2646,7 +2658,7 @@ var AnthropicMessagesLanguageModel = class {
2646
2658
  toolChoice: { type: "required" },
2647
2659
  disableParallelToolUse: true,
2648
2660
  cacheControlValidator,
2649
- supportsStructuredOutput
2661
+ supportsStructuredOutput: false
2650
2662
  } : {
2651
2663
  tools: tools != null ? tools : [],
2652
2664
  toolChoice,