@ai-sdk/anthropic 2.0.12 → 2.0.14
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 +14 -0
- package/dist/index.d.mts +89 -61
- package/dist/index.d.ts +89 -61
- package/dist/index.js +60 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -25
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +89 -61
- package/dist/internal/index.d.ts +89 -61
- package/dist/internal/index.js +60 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +60 -25
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 2.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2338c79: feat (provider/anthropic): update jsdoc of anthropic tools
|
|
8
|
+
|
|
9
|
+
## 2.0.13
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- cd458a8: fix(anthropic): reorder tool_result parts to front of combined user messages
|
|
14
|
+
|
|
15
|
+
Reorders tool_result content to appear before user text within combined user messages, ensuring Claude API validation requirements are met while preserving the intentional message combining behavior that prevents role alternation errors. Fixes #8318.
|
|
16
|
+
|
|
3
17
|
## 2.0.12
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -16,69 +16,62 @@ type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
|
16
16
|
|
|
17
17
|
declare const anthropicTools: {
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
20
|
+
* allowing system operations, script execution, and command-line automation.
|
|
20
21
|
*
|
|
21
22
|
* Image results are supported.
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
+
* Tool name must be `bash`.
|
|
24
25
|
*/
|
|
25
26
|
bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
26
27
|
command: string;
|
|
27
28
|
restart?: boolean;
|
|
28
29
|
}, {}>;
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
32
|
+
* allowing system operations, script execution, and command-line automation.
|
|
31
33
|
*
|
|
32
34
|
* Image results are supported.
|
|
33
35
|
*
|
|
34
|
-
*
|
|
36
|
+
* Tool name must be `bash`.
|
|
35
37
|
*/
|
|
36
38
|
bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
37
39
|
command: string;
|
|
38
40
|
restart?: boolean;
|
|
39
41
|
}, {}>;
|
|
40
42
|
/**
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
old_str?: string;
|
|
50
|
-
view_range?: number[];
|
|
51
|
-
}, {}>;
|
|
52
|
-
/**
|
|
53
|
-
* Creates a tool for editing text. Must have name "str_replace_editor".
|
|
54
|
-
*/
|
|
55
|
-
textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
56
|
-
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
57
|
-
path: string;
|
|
58
|
-
file_text?: string;
|
|
59
|
-
insert_line?: number;
|
|
60
|
-
new_str?: string;
|
|
61
|
-
old_str?: string;
|
|
62
|
-
view_range?: number[];
|
|
63
|
-
}, {}>;
|
|
64
|
-
/**
|
|
65
|
-
* Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
|
|
66
|
-
* Note: This version does not support the "undo_edit" command.
|
|
43
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
44
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
45
|
+
* the API conversation.
|
|
46
|
+
*
|
|
47
|
+
* The code execution tool allows Claude to run Bash commands and manipulate files,
|
|
48
|
+
* including writing code, in a secure, sandboxed environment.
|
|
49
|
+
*
|
|
50
|
+
* Tool name must be `code_execution`.
|
|
67
51
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
codeExecution_20250522: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
|
|
53
|
+
code: string;
|
|
54
|
+
}, {
|
|
55
|
+
type: "code_execution_result";
|
|
56
|
+
stdout: string;
|
|
57
|
+
stderr: string;
|
|
58
|
+
return_code: number;
|
|
59
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
60
|
+
code: string;
|
|
61
|
+
}, {
|
|
62
|
+
type: "code_execution_result";
|
|
63
|
+
stdout: string;
|
|
64
|
+
stderr: string;
|
|
65
|
+
return_code: number;
|
|
66
|
+
}>;
|
|
77
67
|
/**
|
|
78
|
-
*
|
|
68
|
+
* Claude can interact with computer environments through the computer use tool, which
|
|
69
|
+
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
79
70
|
*
|
|
80
71
|
* Image results are supported.
|
|
81
72
|
*
|
|
73
|
+
* Tool name must be `computer`.
|
|
74
|
+
*
|
|
82
75
|
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
83
76
|
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
84
77
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
@@ -93,14 +86,16 @@ declare const anthropicTools: {
|
|
|
93
86
|
displayNumber?: number;
|
|
94
87
|
}>;
|
|
95
88
|
/**
|
|
96
|
-
*
|
|
89
|
+
* Claude can interact with computer environments through the computer use tool, which
|
|
90
|
+
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
97
91
|
*
|
|
98
92
|
* Image results are supported.
|
|
99
93
|
*
|
|
94
|
+
* Tool name must be `computer`.
|
|
95
|
+
*
|
|
100
96
|
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
101
97
|
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
102
98
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
103
|
-
* @param execute - The function to execute the tool. Optional.
|
|
104
99
|
*/
|
|
105
100
|
computer_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
106
101
|
action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot";
|
|
@@ -115,9 +110,60 @@ declare const anthropicTools: {
|
|
|
115
110
|
displayHeightPx: number;
|
|
116
111
|
displayNumber?: number;
|
|
117
112
|
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
115
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
116
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
117
|
+
*
|
|
118
|
+
* Tool name must be `str_replace_editor`.
|
|
119
|
+
*/
|
|
120
|
+
textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
121
|
+
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
122
|
+
path: string;
|
|
123
|
+
file_text?: string;
|
|
124
|
+
insert_line?: number;
|
|
125
|
+
new_str?: string;
|
|
126
|
+
old_str?: string;
|
|
127
|
+
view_range?: number[];
|
|
128
|
+
}, {}>;
|
|
129
|
+
/**
|
|
130
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
131
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
132
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
133
|
+
*
|
|
134
|
+
* Tool name must be `str_replace_editor`.
|
|
135
|
+
*/
|
|
136
|
+
textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
137
|
+
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
138
|
+
path: string;
|
|
139
|
+
file_text?: string;
|
|
140
|
+
insert_line?: number;
|
|
141
|
+
new_str?: string;
|
|
142
|
+
old_str?: string;
|
|
143
|
+
view_range?: number[];
|
|
144
|
+
}, {}>;
|
|
145
|
+
/**
|
|
146
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
147
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
148
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
149
|
+
*
|
|
150
|
+
* Note: This version does not support the "undo_edit" command.
|
|
151
|
+
*
|
|
152
|
+
* Tool name must be `str_replace_based_edit_tool`.
|
|
153
|
+
*/
|
|
154
|
+
textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
155
|
+
command: "view" | "create" | "str_replace" | "insert";
|
|
156
|
+
path: string;
|
|
157
|
+
file_text?: string;
|
|
158
|
+
insert_line?: number;
|
|
159
|
+
new_str?: string;
|
|
160
|
+
old_str?: string;
|
|
161
|
+
view_range?: number[];
|
|
162
|
+
}, {}>;
|
|
118
163
|
/**
|
|
119
164
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
120
|
-
*
|
|
165
|
+
*
|
|
166
|
+
* Tool name must be `web_search`.
|
|
121
167
|
*
|
|
122
168
|
* @param maxUses - Maximum number of web searches Claude can perform during the conversation.
|
|
123
169
|
* @param allowedDomains - Optional list of domains that Claude is allowed to search.
|
|
@@ -152,24 +198,6 @@ declare const anthropicTools: {
|
|
|
152
198
|
encryptedContent: string;
|
|
153
199
|
type: string;
|
|
154
200
|
}[]>;
|
|
155
|
-
/**
|
|
156
|
-
* Creates a tool for executing Python code. Must have name "code_execution".
|
|
157
|
-
*/
|
|
158
|
-
codeExecution_20250522: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
|
|
159
|
-
code: string;
|
|
160
|
-
}, {
|
|
161
|
-
type: "code_execution_result";
|
|
162
|
-
stdout: string;
|
|
163
|
-
stderr: string;
|
|
164
|
-
return_code: number;
|
|
165
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
166
|
-
code: string;
|
|
167
|
-
}, {
|
|
168
|
-
type: "code_execution_result";
|
|
169
|
-
stdout: string;
|
|
170
|
-
stderr: string;
|
|
171
|
-
return_code: number;
|
|
172
|
-
}>;
|
|
173
201
|
};
|
|
174
202
|
|
|
175
203
|
interface AnthropicProvider extends ProviderV2 {
|
package/dist/index.d.ts
CHANGED
|
@@ -16,69 +16,62 @@ type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
|
16
16
|
|
|
17
17
|
declare const anthropicTools: {
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
20
|
+
* allowing system operations, script execution, and command-line automation.
|
|
20
21
|
*
|
|
21
22
|
* Image results are supported.
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
+
* Tool name must be `bash`.
|
|
24
25
|
*/
|
|
25
26
|
bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
26
27
|
command: string;
|
|
27
28
|
restart?: boolean;
|
|
28
29
|
}, {}>;
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
32
|
+
* allowing system operations, script execution, and command-line automation.
|
|
31
33
|
*
|
|
32
34
|
* Image results are supported.
|
|
33
35
|
*
|
|
34
|
-
*
|
|
36
|
+
* Tool name must be `bash`.
|
|
35
37
|
*/
|
|
36
38
|
bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
37
39
|
command: string;
|
|
38
40
|
restart?: boolean;
|
|
39
41
|
}, {}>;
|
|
40
42
|
/**
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
old_str?: string;
|
|
50
|
-
view_range?: number[];
|
|
51
|
-
}, {}>;
|
|
52
|
-
/**
|
|
53
|
-
* Creates a tool for editing text. Must have name "str_replace_editor".
|
|
54
|
-
*/
|
|
55
|
-
textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
56
|
-
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
57
|
-
path: string;
|
|
58
|
-
file_text?: string;
|
|
59
|
-
insert_line?: number;
|
|
60
|
-
new_str?: string;
|
|
61
|
-
old_str?: string;
|
|
62
|
-
view_range?: number[];
|
|
63
|
-
}, {}>;
|
|
64
|
-
/**
|
|
65
|
-
* Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
|
|
66
|
-
* Note: This version does not support the "undo_edit" command.
|
|
43
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
44
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
45
|
+
* the API conversation.
|
|
46
|
+
*
|
|
47
|
+
* The code execution tool allows Claude to run Bash commands and manipulate files,
|
|
48
|
+
* including writing code, in a secure, sandboxed environment.
|
|
49
|
+
*
|
|
50
|
+
* Tool name must be `code_execution`.
|
|
67
51
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
codeExecution_20250522: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
|
|
53
|
+
code: string;
|
|
54
|
+
}, {
|
|
55
|
+
type: "code_execution_result";
|
|
56
|
+
stdout: string;
|
|
57
|
+
stderr: string;
|
|
58
|
+
return_code: number;
|
|
59
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
60
|
+
code: string;
|
|
61
|
+
}, {
|
|
62
|
+
type: "code_execution_result";
|
|
63
|
+
stdout: string;
|
|
64
|
+
stderr: string;
|
|
65
|
+
return_code: number;
|
|
66
|
+
}>;
|
|
77
67
|
/**
|
|
78
|
-
*
|
|
68
|
+
* Claude can interact with computer environments through the computer use tool, which
|
|
69
|
+
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
79
70
|
*
|
|
80
71
|
* Image results are supported.
|
|
81
72
|
*
|
|
73
|
+
* Tool name must be `computer`.
|
|
74
|
+
*
|
|
82
75
|
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
83
76
|
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
84
77
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
@@ -93,14 +86,16 @@ declare const anthropicTools: {
|
|
|
93
86
|
displayNumber?: number;
|
|
94
87
|
}>;
|
|
95
88
|
/**
|
|
96
|
-
*
|
|
89
|
+
* Claude can interact with computer environments through the computer use tool, which
|
|
90
|
+
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
97
91
|
*
|
|
98
92
|
* Image results are supported.
|
|
99
93
|
*
|
|
94
|
+
* Tool name must be `computer`.
|
|
95
|
+
*
|
|
100
96
|
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
101
97
|
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
102
98
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
103
|
-
* @param execute - The function to execute the tool. Optional.
|
|
104
99
|
*/
|
|
105
100
|
computer_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
106
101
|
action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot";
|
|
@@ -115,9 +110,60 @@ declare const anthropicTools: {
|
|
|
115
110
|
displayHeightPx: number;
|
|
116
111
|
displayNumber?: number;
|
|
117
112
|
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
115
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
116
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
117
|
+
*
|
|
118
|
+
* Tool name must be `str_replace_editor`.
|
|
119
|
+
*/
|
|
120
|
+
textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
121
|
+
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
122
|
+
path: string;
|
|
123
|
+
file_text?: string;
|
|
124
|
+
insert_line?: number;
|
|
125
|
+
new_str?: string;
|
|
126
|
+
old_str?: string;
|
|
127
|
+
view_range?: number[];
|
|
128
|
+
}, {}>;
|
|
129
|
+
/**
|
|
130
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
131
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
132
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
133
|
+
*
|
|
134
|
+
* Tool name must be `str_replace_editor`.
|
|
135
|
+
*/
|
|
136
|
+
textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
137
|
+
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
138
|
+
path: string;
|
|
139
|
+
file_text?: string;
|
|
140
|
+
insert_line?: number;
|
|
141
|
+
new_str?: string;
|
|
142
|
+
old_str?: string;
|
|
143
|
+
view_range?: number[];
|
|
144
|
+
}, {}>;
|
|
145
|
+
/**
|
|
146
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
147
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
148
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
149
|
+
*
|
|
150
|
+
* Note: This version does not support the "undo_edit" command.
|
|
151
|
+
*
|
|
152
|
+
* Tool name must be `str_replace_based_edit_tool`.
|
|
153
|
+
*/
|
|
154
|
+
textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
155
|
+
command: "view" | "create" | "str_replace" | "insert";
|
|
156
|
+
path: string;
|
|
157
|
+
file_text?: string;
|
|
158
|
+
insert_line?: number;
|
|
159
|
+
new_str?: string;
|
|
160
|
+
old_str?: string;
|
|
161
|
+
view_range?: number[];
|
|
162
|
+
}, {}>;
|
|
118
163
|
/**
|
|
119
164
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
120
|
-
*
|
|
165
|
+
*
|
|
166
|
+
* Tool name must be `web_search`.
|
|
121
167
|
*
|
|
122
168
|
* @param maxUses - Maximum number of web searches Claude can perform during the conversation.
|
|
123
169
|
* @param allowedDomains - Optional list of domains that Claude is allowed to search.
|
|
@@ -152,24 +198,6 @@ declare const anthropicTools: {
|
|
|
152
198
|
encryptedContent: string;
|
|
153
199
|
type: string;
|
|
154
200
|
}[]>;
|
|
155
|
-
/**
|
|
156
|
-
* Creates a tool for executing Python code. Must have name "code_execution".
|
|
157
|
-
*/
|
|
158
|
-
codeExecution_20250522: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
|
|
159
|
-
code: string;
|
|
160
|
-
}, {
|
|
161
|
-
type: "code_execution_result";
|
|
162
|
-
stdout: string;
|
|
163
|
-
stderr: string;
|
|
164
|
-
return_code: number;
|
|
165
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
166
|
-
code: string;
|
|
167
|
-
}, {
|
|
168
|
-
type: "code_execution_result";
|
|
169
|
-
stdout: string;
|
|
170
|
-
stderr: string;
|
|
171
|
-
return_code: number;
|
|
172
|
-
}>;
|
|
173
201
|
};
|
|
174
202
|
|
|
175
203
|
interface AnthropicProvider extends ProviderV2 {
|
package/dist/index.js
CHANGED
|
@@ -571,7 +571,14 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
|
|
574
|
+
const toolResultParts = anthropicContent.filter(
|
|
575
|
+
(part) => part.type === "tool_result"
|
|
576
|
+
);
|
|
577
|
+
const otherParts = anthropicContent.filter(
|
|
578
|
+
(part) => part.type !== "tool_result"
|
|
579
|
+
);
|
|
580
|
+
const reorderedContent = toolResultParts.length > 0 ? [...toolResultParts, ...otherParts] : anthropicContent;
|
|
581
|
+
messages.push({ role: "user", content: reorderedContent });
|
|
575
582
|
break;
|
|
576
583
|
}
|
|
577
584
|
case "assistant": {
|
|
@@ -1997,69 +2004,97 @@ var textEditor_20250429 = (0, import_provider_utils12.createProviderDefinedToolF
|
|
|
1997
2004
|
// src/anthropic-tools.ts
|
|
1998
2005
|
var anthropicTools = {
|
|
1999
2006
|
/**
|
|
2000
|
-
*
|
|
2007
|
+
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
2008
|
+
* allowing system operations, script execution, and command-line automation.
|
|
2001
2009
|
*
|
|
2002
2010
|
* Image results are supported.
|
|
2003
2011
|
*
|
|
2004
|
-
*
|
|
2012
|
+
* Tool name must be `bash`.
|
|
2005
2013
|
*/
|
|
2006
2014
|
bash_20241022,
|
|
2007
2015
|
/**
|
|
2008
|
-
*
|
|
2016
|
+
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
2017
|
+
* allowing system operations, script execution, and command-line automation.
|
|
2009
2018
|
*
|
|
2010
2019
|
* Image results are supported.
|
|
2011
2020
|
*
|
|
2012
|
-
*
|
|
2021
|
+
* Tool name must be `bash`.
|
|
2013
2022
|
*/
|
|
2014
2023
|
bash_20250124,
|
|
2015
2024
|
/**
|
|
2016
|
-
*
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
*
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
* Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
|
|
2025
|
-
* Note: This version does not support the "undo_edit" command.
|
|
2025
|
+
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
2026
|
+
* run system commands, create and edit files, and process uploaded files directly within
|
|
2027
|
+
* the API conversation.
|
|
2028
|
+
*
|
|
2029
|
+
* The code execution tool allows Claude to run Bash commands and manipulate files,
|
|
2030
|
+
* including writing code, in a secure, sandboxed environment.
|
|
2031
|
+
*
|
|
2032
|
+
* Tool name must be `code_execution`.
|
|
2026
2033
|
*/
|
|
2027
|
-
|
|
2034
|
+
codeExecution_20250522,
|
|
2028
2035
|
/**
|
|
2029
|
-
*
|
|
2036
|
+
* Claude can interact with computer environments through the computer use tool, which
|
|
2037
|
+
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
2030
2038
|
*
|
|
2031
2039
|
* Image results are supported.
|
|
2032
2040
|
*
|
|
2041
|
+
* Tool name must be `computer`.
|
|
2042
|
+
*
|
|
2033
2043
|
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
2034
2044
|
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
2035
2045
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
2036
2046
|
*/
|
|
2037
2047
|
computer_20241022,
|
|
2038
2048
|
/**
|
|
2039
|
-
*
|
|
2049
|
+
* Claude can interact with computer environments through the computer use tool, which
|
|
2050
|
+
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
2040
2051
|
*
|
|
2041
2052
|
* Image results are supported.
|
|
2042
2053
|
*
|
|
2054
|
+
* Tool name must be `computer`.
|
|
2055
|
+
*
|
|
2043
2056
|
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
2044
2057
|
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
2045
2058
|
* @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
2046
|
-
* @param execute - The function to execute the tool. Optional.
|
|
2047
2059
|
*/
|
|
2048
2060
|
computer_20250124,
|
|
2061
|
+
/**
|
|
2062
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2063
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2064
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2065
|
+
*
|
|
2066
|
+
* Tool name must be `str_replace_editor`.
|
|
2067
|
+
*/
|
|
2068
|
+
textEditor_20241022,
|
|
2069
|
+
/**
|
|
2070
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2071
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2072
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2073
|
+
*
|
|
2074
|
+
* Tool name must be `str_replace_editor`.
|
|
2075
|
+
*/
|
|
2076
|
+
textEditor_20250124,
|
|
2077
|
+
/**
|
|
2078
|
+
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
2079
|
+
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
2080
|
+
* to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
|
|
2081
|
+
*
|
|
2082
|
+
* Note: This version does not support the "undo_edit" command.
|
|
2083
|
+
*
|
|
2084
|
+
* Tool name must be `str_replace_based_edit_tool`.
|
|
2085
|
+
*/
|
|
2086
|
+
textEditor_20250429,
|
|
2049
2087
|
/**
|
|
2050
2088
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
2051
|
-
*
|
|
2089
|
+
*
|
|
2090
|
+
* Tool name must be `web_search`.
|
|
2052
2091
|
*
|
|
2053
2092
|
* @param maxUses - Maximum number of web searches Claude can perform during the conversation.
|
|
2054
2093
|
* @param allowedDomains - Optional list of domains that Claude is allowed to search.
|
|
2055
2094
|
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
2056
2095
|
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
2057
2096
|
*/
|
|
2058
|
-
webSearch_20250305
|
|
2059
|
-
/**
|
|
2060
|
-
* Creates a tool for executing Python code. Must have name "code_execution".
|
|
2061
|
-
*/
|
|
2062
|
-
codeExecution_20250522
|
|
2097
|
+
webSearch_20250305
|
|
2063
2098
|
};
|
|
2064
2099
|
|
|
2065
2100
|
// src/anthropic-provider.ts
|