@ai-sdk/anthropic 4.0.5 → 4.0.7

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,23 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 5c5c0f5: Add experimental streaming transcription support for transcription models, including OpenAI `gpt-realtime-whisper` and xAI WebSocket STT.
8
+ - Updated dependencies [5c5c0f5]
9
+ - @ai-sdk/provider@4.0.2
10
+ - @ai-sdk/provider-utils@5.0.5
11
+
12
+ ## 4.0.6
13
+
14
+ ### Patch Changes
15
+
16
+ - c6f5e62: Prevent prototype pollution when synchronously parsing provider JSON inputs and expose `secureJsonParse` from provider-utils.
17
+ - 679c52a: Normalize a bare `https://api.anthropic.com` base URL to include `/v1`.
18
+ - Updated dependencies [c6f5e62]
19
+ - @ai-sdk/provider-utils@5.0.4
20
+
3
21
  ## 4.0.5
4
22
 
5
23
  ### Patch Changes
package/dist/index.js CHANGED
@@ -128,6 +128,7 @@ import {
128
128
  postJsonToApi,
129
129
  resolve,
130
130
  resolveProviderReference as resolveProviderReference2,
131
+ secureJsonParse as secureJsonParse2,
131
132
  serializeModelOptions,
132
133
  WORKFLOW_SERIALIZE,
133
134
  WORKFLOW_DESERIALIZE
@@ -1982,11 +1983,12 @@ import {
1982
1983
  convertBase64ToUint8Array,
1983
1984
  convertToBase64,
1984
1985
  getTopLevelMediaType,
1986
+ isNonNullable,
1985
1987
  parseProviderOptions,
1986
1988
  resolveFullMediaType,
1987
1989
  resolveProviderReference,
1988
- validateTypes as validateTypes2,
1989
- isNonNullable
1990
+ secureJsonParse,
1991
+ validateTypes as validateTypes2
1990
1992
  } from "@ai-sdk/provider-utils";
1991
1993
 
1992
1994
  // src/tool/code-execution_20250522.ts
@@ -2320,7 +2322,7 @@ function convertBytesDataToString(data) {
2320
2322
  function extractErrorValue(value) {
2321
2323
  try {
2322
2324
  if (typeof value === "string") {
2323
- return JSON.parse(value);
2325
+ return secureJsonParse(value);
2324
2326
  } else if (typeof value === "object" && value !== null) {
2325
2327
  return value;
2326
2328
  }
@@ -2921,7 +2923,7 @@ async function convertToAnthropicPrompt({
2921
2923
  let errorInfo = {};
2922
2924
  try {
2923
2925
  if (typeof output.value === "string") {
2924
- errorInfo = JSON.parse(output.value);
2926
+ errorInfo = secureJsonParse(output.value);
2925
2927
  } else if (typeof output.value === "object" && output.value !== null) {
2926
2928
  errorInfo = output.value;
2927
2929
  }
@@ -5057,7 +5059,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
5057
5059
  let finalInput = contentBlock.input === "" ? "{}" : contentBlock.input;
5058
5060
  if (contentBlock.providerToolName === "code_execution") {
5059
5061
  try {
5060
- const parsed = JSON.parse(finalInput);
5062
+ const parsed = secureJsonParse2(finalInput);
5061
5063
  if (parsed != null && typeof parsed === "object" && "code" in parsed && !("type" in parsed)) {
5062
5064
  finalInput = JSON.stringify({
5063
5065
  type: "programmatic-tool-call",
@@ -6289,17 +6291,23 @@ var AnthropicSkills = class {
6289
6291
  };
6290
6292
 
6291
6293
  // src/version.ts
6292
- var VERSION = true ? "4.0.5" : "0.0.0-test";
6294
+ var VERSION = true ? "4.0.7" : "0.0.0-test";
6293
6295
 
6294
6296
  // src/anthropic-provider.ts
6297
+ var ANTHROPIC_API_URL = "https://api.anthropic.com";
6298
+ var ANTHROPIC_API_VERSIONED_URL = `${ANTHROPIC_API_URL}/v1`;
6299
+ function normalizeBaseURL(baseURL) {
6300
+ const baseURLWithoutTrailingSlash = withoutTrailingSlash(baseURL);
6301
+ return baseURLWithoutTrailingSlash === ANTHROPIC_API_URL ? ANTHROPIC_API_VERSIONED_URL : baseURLWithoutTrailingSlash;
6302
+ }
6295
6303
  function createAnthropic(options = {}) {
6296
6304
  var _a, _b;
6297
- const baseURL = (_a = withoutTrailingSlash(
6305
+ const baseURL = (_a = normalizeBaseURL(
6298
6306
  loadOptionalSetting({
6299
6307
  settingValue: options.baseURL,
6300
6308
  environmentVariableName: "ANTHROPIC_BASE_URL"
6301
6309
  })
6302
- )) != null ? _a : "https://api.anthropic.com/v1";
6310
+ )) != null ? _a : ANTHROPIC_API_VERSIONED_URL;
6303
6311
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
6304
6312
  if (options.apiKey && options.authToken) {
6305
6313
  throw new InvalidArgumentError({