@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.
- package/CHANGELOG.md +16 -0
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +7 -5
- package/dist/internal/index.js.map +1 -1
- package/package.json +2 -2
- package/src/anthropic-language-model.ts +2 -1
- package/src/anthropic-provider.ts +13 -2
- package/src/convert-to-anthropic-prompt.ts +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c6f5e62: Prevent prototype pollution when synchronously parsing provider JSON inputs and expose `secureJsonParse` from provider-utils.
|
|
8
|
+
- 679c52a: Normalize a bare `https://api.anthropic.com` base URL to include `/v1`.
|
|
9
|
+
- Updated dependencies [c6f5e62]
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.4
|
|
11
|
+
|
|
12
|
+
## 4.0.5
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [8c616f0]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.3
|
|
18
|
+
|
|
3
19
|
## 4.0.4
|
|
4
20
|
|
|
5
21
|
### 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
|
-
|
|
1989
|
-
|
|
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
|
|
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 =
|
|
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 =
|
|
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.
|
|
6294
|
+
var VERSION = true ? "4.0.6" : "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 =
|
|
6305
|
+
const baseURL = (_a = normalizeBaseURL(
|
|
6298
6306
|
loadOptionalSetting({
|
|
6299
6307
|
settingValue: options.baseURL,
|
|
6300
6308
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
6301
6309
|
})
|
|
6302
|
-
)) != null ? _a :
|
|
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({
|