@ai-sdk/anthropic 3.0.92 → 3.0.94

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.
@@ -10,7 +10,8 @@ import {
10
10
  generateId,
11
11
  parseProviderOptions as parseProviderOptions2,
12
12
  postJsonToApi,
13
- resolve
13
+ resolve,
14
+ secureJsonParse as secureJsonParse2
14
15
  } from "@ai-sdk/provider-utils";
15
16
 
16
17
  // src/anthropic-error.ts
@@ -1874,8 +1875,9 @@ import {
1874
1875
  convertToBase64,
1875
1876
  parseProviderOptions,
1876
1877
  safeParseJSON,
1877
- validateTypes as validateTypes2,
1878
- isNonNullable
1878
+ isNonNullable,
1879
+ secureJsonParse,
1880
+ validateTypes as validateTypes2
1879
1881
  } from "@ai-sdk/provider-utils";
1880
1882
 
1881
1883
  // src/tool/code-execution_20250522.ts
@@ -2740,7 +2742,7 @@ async function convertToAnthropicMessagesPrompt({
2740
2742
  let errorInfo = {};
2741
2743
  try {
2742
2744
  if (typeof output.value === "string") {
2743
- errorInfo = JSON.parse(output.value);
2745
+ errorInfo = secureJsonParse(output.value);
2744
2746
  } else if (typeof output.value === "object" && output.value !== null) {
2745
2747
  errorInfo = output.value;
2746
2748
  }
@@ -3498,6 +3500,7 @@ var AnthropicMessagesLanguageModel = class {
3498
3500
  });
3499
3501
  const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3500
3502
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3503
+ const sendThinking = isThinking || thinkingType === "disabled";
3501
3504
  let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3502
3505
  const thinkingDisplay = thinkingType === "adaptive" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.display : void 0;
3503
3506
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
@@ -3511,7 +3514,7 @@ var AnthropicMessagesLanguageModel = class {
3511
3514
  top_p: topP,
3512
3515
  stop_sequences: stopSequences,
3513
3516
  // provider specific settings:
3514
- ...isThinking && {
3517
+ ...sendThinking && {
3515
3518
  thinking: {
3516
3519
  type: thinkingType,
3517
3520
  ...thinkingBudget != null && { budget_tokens: thinkingBudget },
@@ -4847,7 +4850,7 @@ var AnthropicMessagesLanguageModel = class {
4847
4850
  let finalInput = contentBlock.input === "" ? "{}" : contentBlock.input;
4848
4851
  if (contentBlock.providerToolName === "code_execution") {
4849
4852
  try {
4850
- const parsed = JSON.parse(finalInput);
4853
+ const parsed = secureJsonParse2(finalInput);
4851
4854
  if (parsed != null && typeof parsed === "object" && "code" in parsed && !("type" in parsed)) {
4852
4855
  finalInput = JSON.stringify({
4853
4856
  type: "programmatic-tool-call",