@ai-sdk/anthropic 4.0.60 → 4.0.62
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 +19 -0
- package/dist/index.js +25 -15
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +13 -5
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/anthropic-api.ts +1 -1
- package/src/anthropic-batch.ts +5 -1
- package/src/anthropic-language-model.ts +4 -0
- package/src/convert-to-anthropic-prompt.ts +10 -4
- package/src/forward-anthropic-container-id-from-last-step.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.62
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 771e74b: chore: enable dead code lint rules
|
|
8
|
+
- Updated dependencies [fe07867]
|
|
9
|
+
- Updated dependencies [a4b0940]
|
|
10
|
+
- Updated dependencies [771e74b]
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.47
|
|
12
|
+
|
|
13
|
+
## 4.0.61
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 3733d6e: fix(anthropic): omit empty compaction blocks from replay
|
|
18
|
+
- Updated dependencies [ffb0e76]
|
|
19
|
+
- @ai-sdk/provider@4.0.18
|
|
20
|
+
- @ai-sdk/provider-utils@5.0.46
|
|
21
|
+
|
|
3
22
|
## 4.0.60
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -272,7 +272,7 @@ var anthropicResponseSchema = lazySchema3(
|
|
|
272
272
|
}),
|
|
273
273
|
z3.object({
|
|
274
274
|
type: z3.literal("compaction"),
|
|
275
|
-
content: z3.string()
|
|
275
|
+
content: z3.string().nullish()
|
|
276
276
|
}),
|
|
277
277
|
z3.object({
|
|
278
278
|
type: z3.literal("tool_use"),
|
|
@@ -3243,6 +3243,9 @@ async function convertToAnthropicPrompt({
|
|
|
3243
3243
|
case "text": {
|
|
3244
3244
|
const textMetadata = (_k = part.providerOptions) == null ? void 0 : _k.anthropic;
|
|
3245
3245
|
if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
|
|
3246
|
+
if (part.text === "") {
|
|
3247
|
+
break;
|
|
3248
|
+
}
|
|
3246
3249
|
anthropicContent.push({
|
|
3247
3250
|
type: "compaction",
|
|
3248
3251
|
content: part.text,
|
|
@@ -3769,10 +3772,12 @@ async function convertToAnthropicPrompt({
|
|
|
3769
3772
|
}
|
|
3770
3773
|
}
|
|
3771
3774
|
}
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3775
|
+
if (anthropicContent.length > 0) {
|
|
3776
|
+
messages.push({
|
|
3777
|
+
role: "assistant",
|
|
3778
|
+
content: moveToolUseBlocksToEnd(anthropicContent)
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3776
3781
|
break;
|
|
3777
3782
|
}
|
|
3778
3783
|
default: {
|
|
@@ -4893,6 +4898,9 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
4893
4898
|
break;
|
|
4894
4899
|
}
|
|
4895
4900
|
case "compaction": {
|
|
4901
|
+
if (!part.content) {
|
|
4902
|
+
break;
|
|
4903
|
+
}
|
|
4896
4904
|
content.push({
|
|
4897
4905
|
type: "text",
|
|
4898
4906
|
text: part.content,
|
|
@@ -7106,7 +7114,7 @@ async function parseAnthropicBatchResponse(message) {
|
|
|
7106
7114
|
return recovered.success ? recovered.value : void 0;
|
|
7107
7115
|
}
|
|
7108
7116
|
function convertAnthropicBatchResponse(response, generateId4) {
|
|
7109
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
7117
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7110
7118
|
const content = [];
|
|
7111
7119
|
const mcpToolCalls = {};
|
|
7112
7120
|
const serverToolCalls = {};
|
|
@@ -7160,6 +7168,9 @@ function convertAnthropicBatchResponse(response, generateId4) {
|
|
|
7160
7168
|
});
|
|
7161
7169
|
break;
|
|
7162
7170
|
case "compaction":
|
|
7171
|
+
if (!part.content) {
|
|
7172
|
+
break;
|
|
7173
|
+
}
|
|
7163
7174
|
content.push({
|
|
7164
7175
|
type: "text",
|
|
7165
7176
|
text: part.content,
|
|
@@ -7187,7 +7198,7 @@ function convertAnthropicBatchResponse(response, generateId4) {
|
|
|
7187
7198
|
toolCallId: part.id,
|
|
7188
7199
|
toolName,
|
|
7189
7200
|
input: JSON.stringify(
|
|
7190
|
-
isCodeExecutionAlias ? { type: part.name, ...
|
|
7201
|
+
isCodeExecutionAlias ? { type: part.name, ...part.input } : part.name === "code_execution" && part.input != null && "code" in part.input && !("type" in part.input) ? { type: "programmatic-tool-call", ...part.input } : part.input
|
|
7191
7202
|
),
|
|
7192
7203
|
providerExecuted: true,
|
|
7193
7204
|
// Batch results are retrieved without the original request tools, so
|
|
@@ -7221,7 +7232,7 @@ function convertAnthropicBatchResponse(response, generateId4) {
|
|
|
7221
7232
|
content.push({
|
|
7222
7233
|
type: "tool-result",
|
|
7223
7234
|
toolCallId: part.tool_use_id,
|
|
7224
|
-
toolName: (
|
|
7235
|
+
toolName: (_b = toolCall == null ? void 0 : toolCall.toolName) != null ? _b : "mcp",
|
|
7225
7236
|
isError: part.is_error,
|
|
7226
7237
|
result: part.content,
|
|
7227
7238
|
dynamic: true,
|
|
@@ -7297,7 +7308,7 @@ function convertAnthropicBatchResponse(response, generateId4) {
|
|
|
7297
7308
|
...result.title != null ? { title: result.title } : {},
|
|
7298
7309
|
providerMetadata: {
|
|
7299
7310
|
anthropic: {
|
|
7300
|
-
pageAge: (
|
|
7311
|
+
pageAge: (_c = result.page_age) != null ? _c : null
|
|
7301
7312
|
}
|
|
7302
7313
|
}
|
|
7303
7314
|
});
|
|
@@ -7328,7 +7339,7 @@ function convertAnthropicBatchResponse(response, generateId4) {
|
|
|
7328
7339
|
});
|
|
7329
7340
|
break;
|
|
7330
7341
|
case "tool_search_tool_result": {
|
|
7331
|
-
const toolName = (
|
|
7342
|
+
const toolName = (_d = serverToolCalls[part.tool_use_id]) != null ? _d : "tool_search_tool_regex";
|
|
7332
7343
|
content.push({
|
|
7333
7344
|
type: "tool-result",
|
|
7334
7345
|
toolCallId: part.tool_use_id,
|
|
@@ -7394,12 +7405,12 @@ function convertAnthropicBatchResponse(response, generateId4) {
|
|
|
7394
7405
|
unified: mapAnthropicStopReason({
|
|
7395
7406
|
finishReason: response.stop_reason
|
|
7396
7407
|
}),
|
|
7397
|
-
raw: (
|
|
7408
|
+
raw: (_e = response.stop_reason) != null ? _e : void 0
|
|
7398
7409
|
},
|
|
7399
7410
|
usage: convertAnthropicUsage({ usage: response.usage }),
|
|
7400
7411
|
response: {
|
|
7401
|
-
id: (
|
|
7402
|
-
modelId: (
|
|
7412
|
+
id: (_f = response.id) != null ? _f : void 0,
|
|
7413
|
+
modelId: (_g = response.model) != null ? _g : void 0
|
|
7403
7414
|
},
|
|
7404
7415
|
warnings: [],
|
|
7405
7416
|
providerMetadata: {
|
|
@@ -8275,7 +8286,7 @@ var AnthropicSkills = class {
|
|
|
8275
8286
|
};
|
|
8276
8287
|
|
|
8277
8288
|
// src/version.ts
|
|
8278
|
-
var VERSION = true ? "4.0.
|
|
8289
|
+
var VERSION = true ? "4.0.62" : "0.0.0-test";
|
|
8279
8290
|
|
|
8280
8291
|
// src/anthropic-provider.ts
|
|
8281
8292
|
var ANTHROPIC_API_URL = "https://api.anthropic.com";
|
|
@@ -8395,7 +8406,6 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
8395
8406
|
};
|
|
8396
8407
|
}
|
|
8397
8408
|
}
|
|
8398
|
-
return void 0;
|
|
8399
8409
|
}
|
|
8400
8410
|
export {
|
|
8401
8411
|
VERSION,
|