@ai-sdk/anthropic 3.0.93 → 3.0.95
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 +17 -0
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +3 -3
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +8 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/anthropic-messages-language-model.ts +2 -1
- package/src/anthropic-provider.ts +13 -2
- package/src/convert-to-anthropic-messages-prompt.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 3.0.95
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 327642b: fix: more precise default message for tool execution denial
|
|
8
|
+
- Updated dependencies [d559de9]
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.37
|
|
10
|
+
|
|
11
|
+
## 3.0.94
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 0952964: Prevent prototype pollution when synchronously parsing provider JSON inputs and expose `secureJsonParse` from provider-utils.
|
|
16
|
+
- 764baab: Normalize a bare `https://api.anthropic.com` base URL to include `/v1`.
|
|
17
|
+
- Updated dependencies [0952964]
|
|
18
|
+
- @ai-sdk/provider-utils@4.0.36
|
|
19
|
+
|
|
3
20
|
## 3.0.93
|
|
4
21
|
|
|
5
22
|
### 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.
|
|
35
|
+
var VERSION = true ? "3.0.95" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -2468,7 +2468,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2468
2468
|
contentValue = output.value;
|
|
2469
2469
|
break;
|
|
2470
2470
|
case "execution-denied":
|
|
2471
|
-
contentValue = (_g = output.reason) != null ? _g : "Tool execution denied.";
|
|
2471
|
+
contentValue = (_g = output.reason) != null ? _g : "Tool call execution denied.";
|
|
2472
2472
|
break;
|
|
2473
2473
|
case "json":
|
|
2474
2474
|
case "error-json":
|
|
@@ -2707,7 +2707,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2707
2707
|
let errorInfo = {};
|
|
2708
2708
|
try {
|
|
2709
2709
|
if (typeof output.value === "string") {
|
|
2710
|
-
errorInfo =
|
|
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 =
|
|
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 = (
|
|
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 :
|
|
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({
|