@ai-sdk/anthropic 4.0.26 → 4.0.28
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 +14 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +13 -4
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/convert-to-anthropic-prompt.ts +19 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/anthropic",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ai-sdk/provider": "4.0.
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
38
|
+
"@ai-sdk/provider": "4.0.5",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.19"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "22.19.19",
|
|
@@ -754,7 +754,7 @@ export async function convertToAnthropicPrompt({
|
|
|
754
754
|
cache_control: cacheControl,
|
|
755
755
|
});
|
|
756
756
|
} else if (
|
|
757
|
-
// code execution
|
|
757
|
+
// code execution subtools:
|
|
758
758
|
providerToolName === 'code_execution' &&
|
|
759
759
|
part.input != null &&
|
|
760
760
|
typeof part.input === 'object' &&
|
|
@@ -763,11 +763,14 @@ export async function convertToAnthropicPrompt({
|
|
|
763
763
|
(part.input.type === 'bash_code_execution' ||
|
|
764
764
|
part.input.type === 'text_editor_code_execution')
|
|
765
765
|
) {
|
|
766
|
+
const { type: codeExecutionType, ...inputWithoutType } =
|
|
767
|
+
part.input;
|
|
768
|
+
|
|
766
769
|
anthropicContent.push({
|
|
767
770
|
type: 'server_tool_use',
|
|
768
771
|
id: part.toolCallId,
|
|
769
|
-
name:
|
|
770
|
-
input:
|
|
772
|
+
name: codeExecutionType, // map back to subtool name
|
|
773
|
+
input: inputWithoutType,
|
|
771
774
|
cache_control: cacheControl,
|
|
772
775
|
});
|
|
773
776
|
} else if (
|
|
@@ -1036,7 +1039,19 @@ export async function convertToAnthropicPrompt({
|
|
|
1036
1039
|
type: 'bash_code_execution_tool_result',
|
|
1037
1040
|
tool_use_id: part.toolCallId,
|
|
1038
1041
|
cache_control: cacheControl,
|
|
1039
|
-
|
|
1042
|
+
// Prompt caching requires stable key ordering:
|
|
1043
|
+
// https://platform.claude.com/docs/en/build-with-claude/prompt-caching#troubleshooting-common-issues
|
|
1044
|
+
content:
|
|
1045
|
+
codeExecutionOutput.type ===
|
|
1046
|
+
'bash_code_execution_result'
|
|
1047
|
+
? {
|
|
1048
|
+
type: codeExecutionOutput.type,
|
|
1049
|
+
stdout: codeExecutionOutput.stdout,
|
|
1050
|
+
stderr: codeExecutionOutput.stderr,
|
|
1051
|
+
return_code: codeExecutionOutput.return_code,
|
|
1052
|
+
content: codeExecutionOutput.content,
|
|
1053
|
+
}
|
|
1054
|
+
: codeExecutionOutput,
|
|
1040
1055
|
});
|
|
1041
1056
|
} else {
|
|
1042
1057
|
anthropicContent.push({
|