@ai-sdk/anthropic 3.0.93 → 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.
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  } from "@ai-sdk/provider-utils";
13
13
 
14
14
  // src/version.ts
15
- var VERSION = true ? "3.0.93" : "0.0.0-test";
15
+ var VERSION = true ? "3.0.94" : "0.0.0-test";
16
16
 
17
17
  // src/anthropic-messages-language-model.ts
18
18
  import {
@@ -26,7 +26,8 @@ import {
26
26
  generateId,
27
27
  parseProviderOptions as parseProviderOptions2,
28
28
  postJsonToApi,
29
- resolve
29
+ resolve,
30
+ secureJsonParse as secureJsonParse2
30
31
  } from "@ai-sdk/provider-utils";
31
32
 
32
33
  // src/anthropic-error.ts
@@ -1890,8 +1891,9 @@ import {
1890
1891
  convertToBase64,
1891
1892
  parseProviderOptions,
1892
1893
  safeParseJSON,
1893
- validateTypes as validateTypes2,
1894
- isNonNullable
1894
+ isNonNullable,
1895
+ secureJsonParse,
1896
+ validateTypes as validateTypes2
1895
1897
  } from "@ai-sdk/provider-utils";
1896
1898
 
1897
1899
  // src/tool/code-execution_20250522.ts
@@ -2756,7 +2758,7 @@ async function convertToAnthropicMessagesPrompt({
2756
2758
  let errorInfo = {};
2757
2759
  try {
2758
2760
  if (typeof output.value === "string") {
2759
- errorInfo = JSON.parse(output.value);
2761
+ errorInfo = secureJsonParse(output.value);
2760
2762
  } else if (typeof output.value === "object" && output.value !== null) {
2761
2763
  errorInfo = output.value;
2762
2764
  }
@@ -4864,7 +4866,7 @@ var AnthropicMessagesLanguageModel = class {
4864
4866
  let finalInput = contentBlock.input === "" ? "{}" : contentBlock.input;
4865
4867
  if (contentBlock.providerToolName === "code_execution") {
4866
4868
  try {
4867
- const parsed = JSON.parse(finalInput);
4869
+ const parsed = secureJsonParse2(finalInput);
4868
4870
  if (parsed != null && typeof parsed === "object" && "code" in parsed && !("type" in parsed)) {
4869
4871
  finalInput = JSON.stringify({
4870
4872
  type: "programmatic-tool-call",
@@ -5874,14 +5876,20 @@ var anthropicTools = {
5874
5876
  };
5875
5877
 
5876
5878
  // src/anthropic-provider.ts
5879
+ var ANTHROPIC_API_URL = "https://api.anthropic.com";
5880
+ var ANTHROPIC_API_VERSIONED_URL = `${ANTHROPIC_API_URL}/v1`;
5881
+ function normalizeBaseURL(baseURL) {
5882
+ const baseURLWithoutTrailingSlash = withoutTrailingSlash(baseURL);
5883
+ return baseURLWithoutTrailingSlash === ANTHROPIC_API_URL ? ANTHROPIC_API_VERSIONED_URL : baseURLWithoutTrailingSlash;
5884
+ }
5877
5885
  function createAnthropic(options = {}) {
5878
5886
  var _a, _b;
5879
- const baseURL = (_a = withoutTrailingSlash(
5887
+ const baseURL = (_a = normalizeBaseURL(
5880
5888
  loadOptionalSetting({
5881
5889
  settingValue: options.baseURL,
5882
5890
  environmentVariableName: "ANTHROPIC_BASE_URL"
5883
5891
  })
5884
- )) != null ? _a : "https://api.anthropic.com/v1";
5892
+ )) != null ? _a : ANTHROPIC_API_VERSIONED_URL;
5885
5893
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
5886
5894
  if (options.apiKey && options.authToken) {
5887
5895
  throw new InvalidArgumentError({