@ai-sdk/anthropic 4.0.4 → 4.0.6

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.
@@ -115,6 +115,7 @@ import {
115
115
  postJsonToApi,
116
116
  resolve,
117
117
  resolveProviderReference as resolveProviderReference2,
118
+ secureJsonParse as secureJsonParse2,
118
119
  serializeModelOptions,
119
120
  WORKFLOW_SERIALIZE,
120
121
  WORKFLOW_DESERIALIZE
@@ -1969,11 +1970,12 @@ import {
1969
1970
  convertBase64ToUint8Array,
1970
1971
  convertToBase64,
1971
1972
  getTopLevelMediaType,
1973
+ isNonNullable,
1972
1974
  parseProviderOptions,
1973
1975
  resolveFullMediaType,
1974
1976
  resolveProviderReference,
1975
- validateTypes as validateTypes2,
1976
- isNonNullable
1977
+ secureJsonParse,
1978
+ validateTypes as validateTypes2
1977
1979
  } from "@ai-sdk/provider-utils";
1978
1980
 
1979
1981
  // src/tool/code-execution_20250522.ts
@@ -2307,7 +2309,7 @@ function convertBytesDataToString(data) {
2307
2309
  function extractErrorValue(value) {
2308
2310
  try {
2309
2311
  if (typeof value === "string") {
2310
- return JSON.parse(value);
2312
+ return secureJsonParse(value);
2311
2313
  } else if (typeof value === "object" && value !== null) {
2312
2314
  return value;
2313
2315
  }
@@ -2908,7 +2910,7 @@ async function convertToAnthropicPrompt({
2908
2910
  let errorInfo = {};
2909
2911
  try {
2910
2912
  if (typeof output.value === "string") {
2911
- errorInfo = JSON.parse(output.value);
2913
+ errorInfo = secureJsonParse(output.value);
2912
2914
  } else if (typeof output.value === "object" && output.value !== null) {
2913
2915
  errorInfo = output.value;
2914
2916
  }
@@ -5044,7 +5046,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
5044
5046
  let finalInput = contentBlock.input === "" ? "{}" : contentBlock.input;
5045
5047
  if (contentBlock.providerToolName === "code_execution") {
5046
5048
  try {
5047
- const parsed = JSON.parse(finalInput);
5049
+ const parsed = secureJsonParse2(finalInput);
5048
5050
  if (parsed != null && typeof parsed === "object" && "code" in parsed && !("type" in parsed)) {
5049
5051
  finalInput = JSON.stringify({
5050
5052
  type: "programmatic-tool-call",