@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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.94
4
+
5
+ ### Patch Changes
6
+
7
+ - 0952964: Prevent prototype pollution when synchronously parsing provider JSON inputs and expose `secureJsonParse` from provider-utils.
8
+ - 764baab: Normalize a bare `https://api.anthropic.com` base URL to include `/v1`.
9
+ - Updated dependencies [0952964]
10
+ - @ai-sdk/provider-utils@4.0.36
11
+
3
12
  ## 3.0.93
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.93" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.94" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -2707,7 +2707,7 @@ async function convertToAnthropicMessagesPrompt({
2707
2707
  let errorInfo = {};
2708
2708
  try {
2709
2709
  if (typeof output.value === "string") {
2710
- errorInfo = JSON.parse(output.value);
2710
+ errorInfo = (0, import_provider_utils14.secureJsonParse)(output.value);
2711
2711
  } else if (typeof output.value === "object" && output.value !== null) {
2712
2712
  errorInfo = output.value;
2713
2713
  }
@@ -4815,7 +4815,7 @@ var AnthropicMessagesLanguageModel = class {
4815
4815
  let finalInput = contentBlock.input === "" ? "{}" : contentBlock.input;
4816
4816
  if (contentBlock.providerToolName === "code_execution") {
4817
4817
  try {
4818
- const parsed = JSON.parse(finalInput);
4818
+ const parsed = (0, import_provider_utils15.secureJsonParse)(finalInput);
4819
4819
  if (parsed != null && typeof parsed === "object" && "code" in parsed && !("type" in parsed)) {
4820
4820
  finalInput = JSON.stringify({
4821
4821
  type: "programmatic-tool-call",
@@ -5785,14 +5785,20 @@ var anthropicTools = {
5785
5785
  };
5786
5786
 
5787
5787
  // src/anthropic-provider.ts
5788
+ var ANTHROPIC_API_URL = "https://api.anthropic.com";
5789
+ var ANTHROPIC_API_VERSIONED_URL = `${ANTHROPIC_API_URL}/v1`;
5790
+ function normalizeBaseURL(baseURL) {
5791
+ const baseURLWithoutTrailingSlash = (0, import_provider_utils26.withoutTrailingSlash)(baseURL);
5792
+ return baseURLWithoutTrailingSlash === ANTHROPIC_API_URL ? ANTHROPIC_API_VERSIONED_URL : baseURLWithoutTrailingSlash;
5793
+ }
5788
5794
  function createAnthropic(options = {}) {
5789
5795
  var _a, _b;
5790
- const baseURL = (_a = (0, import_provider_utils26.withoutTrailingSlash)(
5796
+ const baseURL = (_a = normalizeBaseURL(
5791
5797
  (0, import_provider_utils26.loadOptionalSetting)({
5792
5798
  settingValue: options.baseURL,
5793
5799
  environmentVariableName: "ANTHROPIC_BASE_URL"
5794
5800
  })
5795
- )) != null ? _a : "https://api.anthropic.com/v1";
5801
+ )) != null ? _a : ANTHROPIC_API_VERSIONED_URL;
5796
5802
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
5797
5803
  if (options.apiKey && options.authToken) {
5798
5804
  throw new import_provider4.InvalidArgumentError({