@ai-sdk/anthropic 3.0.31 → 3.0.33
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 +12 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +24 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -20
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +5 -0
- package/dist/internal/index.d.ts +5 -0
- package/dist/internal/index.js +23 -19
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +23 -19
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +3 -2
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +18 -18
- package/src/anthropic-messages-language-model.ts +2 -2
- package/src/tool/text-editor_20241022.ts +7 -1
- package/src/tool/text-editor_20250124.ts +7 -1
- package/src/tool/text-editor_20250429.ts +7 -1
- package/src/tool/text-editor_20250728.ts +7 -1
package/docs/05-anthropic.mdx
CHANGED
|
@@ -499,7 +499,7 @@ The Text Editor Tool provides functionality for viewing and editing text files.
|
|
|
499
499
|
const tools = {
|
|
500
500
|
str_replace_based_edit_tool: anthropic.tools.textEditor_20250728({
|
|
501
501
|
maxCharacters: 10000, // optional
|
|
502
|
-
async execute({ command, path, old_str, new_str }) {
|
|
502
|
+
async execute({ command, path, old_str, new_str, insert_text }) {
|
|
503
503
|
// ...
|
|
504
504
|
},
|
|
505
505
|
}),
|
|
@@ -523,7 +523,8 @@ Parameters:
|
|
|
523
523
|
- `path` (string): Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.
|
|
524
524
|
- `file_text` (string, optional): Required for `create` command, with the content of the file to be created.
|
|
525
525
|
- `insert_line` (number, optional): Required for `insert` command. The line number after which to insert the new string.
|
|
526
|
-
- `new_str` (string, optional): New string for `str_replace`
|
|
526
|
+
- `new_str` (string, optional): New string for `str_replace` command.
|
|
527
|
+
- `insert_text` (string, optional): Required for `insert` command, containing the text to insert.
|
|
527
528
|
- `old_str` (string, optional): Required for `str_replace` command, containing the string to replace.
|
|
528
529
|
- `view_range` (number[], optional): Optional for `view` command to specify line range to show.
|
|
529
530
|
|
package/package.json
CHANGED
|
@@ -1142,24 +1142,6 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
|
|
|
1142
1142
|
.nullish(),
|
|
1143
1143
|
})
|
|
1144
1144
|
.nullish(),
|
|
1145
|
-
context_management: z
|
|
1146
|
-
.object({
|
|
1147
|
-
applied_edits: z.array(
|
|
1148
|
-
z.union([
|
|
1149
|
-
z.object({
|
|
1150
|
-
type: z.literal('clear_tool_uses_20250919'),
|
|
1151
|
-
cleared_tool_uses: z.number(),
|
|
1152
|
-
cleared_input_tokens: z.number(),
|
|
1153
|
-
}),
|
|
1154
|
-
z.object({
|
|
1155
|
-
type: z.literal('clear_thinking_20251015'),
|
|
1156
|
-
cleared_thinking_turns: z.number(),
|
|
1157
|
-
cleared_input_tokens: z.number(),
|
|
1158
|
-
}),
|
|
1159
|
-
]),
|
|
1160
|
-
),
|
|
1161
|
-
})
|
|
1162
|
-
.nullish(),
|
|
1163
1145
|
}),
|
|
1164
1146
|
usage: z.looseObject({
|
|
1165
1147
|
input_tokens: z.number().nullish(),
|
|
@@ -1167,6 +1149,24 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
|
|
|
1167
1149
|
cache_creation_input_tokens: z.number().nullish(),
|
|
1168
1150
|
cache_read_input_tokens: z.number().nullish(),
|
|
1169
1151
|
}),
|
|
1152
|
+
context_management: z
|
|
1153
|
+
.object({
|
|
1154
|
+
applied_edits: z.array(
|
|
1155
|
+
z.union([
|
|
1156
|
+
z.object({
|
|
1157
|
+
type: z.literal('clear_tool_uses_20250919'),
|
|
1158
|
+
cleared_tool_uses: z.number(),
|
|
1159
|
+
cleared_input_tokens: z.number(),
|
|
1160
|
+
}),
|
|
1161
|
+
z.object({
|
|
1162
|
+
type: z.literal('clear_thinking_20251015'),
|
|
1163
|
+
cleared_thinking_turns: z.number(),
|
|
1164
|
+
cleared_input_tokens: z.number(),
|
|
1165
|
+
}),
|
|
1166
|
+
]),
|
|
1167
|
+
),
|
|
1168
|
+
})
|
|
1169
|
+
.nullish(),
|
|
1170
1170
|
}),
|
|
1171
1171
|
z.object({
|
|
1172
1172
|
type: z.literal('message_stop'),
|
|
@@ -1981,9 +1981,9 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
: null;
|
|
1983
1983
|
|
|
1984
|
-
if (value.
|
|
1984
|
+
if (value.context_management) {
|
|
1985
1985
|
contextManagement = mapAnthropicResponseContextManagement(
|
|
1986
|
-
value.
|
|
1986
|
+
value.context_management,
|
|
1987
1987
|
);
|
|
1988
1988
|
}
|
|
1989
1989
|
|
|
@@ -13,6 +13,7 @@ const textEditor_20241022InputSchema = lazySchema(() =>
|
|
|
13
13
|
file_text: z.string().optional(),
|
|
14
14
|
insert_line: z.number().int().optional(),
|
|
15
15
|
new_str: z.string().optional(),
|
|
16
|
+
insert_text: z.string().optional(),
|
|
16
17
|
old_str: z.string().optional(),
|
|
17
18
|
view_range: z.array(z.number().int()).optional(),
|
|
18
19
|
}),
|
|
@@ -42,10 +43,15 @@ export const textEditor_20241022 = createProviderToolFactory<
|
|
|
42
43
|
insert_line?: number;
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
|
-
* Optional parameter of `str_replace` command containing the new string (if not given, no string will be added).
|
|
46
|
+
* Optional parameter of `str_replace` command containing the new string (if not given, no string will be added).
|
|
46
47
|
*/
|
|
47
48
|
new_str?: string;
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Required parameter of `insert` command containing the text to insert.
|
|
52
|
+
*/
|
|
53
|
+
insert_text?: string;
|
|
54
|
+
|
|
49
55
|
/**
|
|
50
56
|
* Required parameter of `str_replace` command containing the string in `path` to replace.
|
|
51
57
|
*/
|
|
@@ -13,6 +13,7 @@ const textEditor_20250124InputSchema = lazySchema(() =>
|
|
|
13
13
|
file_text: z.string().optional(),
|
|
14
14
|
insert_line: z.number().int().optional(),
|
|
15
15
|
new_str: z.string().optional(),
|
|
16
|
+
insert_text: z.string().optional(),
|
|
16
17
|
old_str: z.string().optional(),
|
|
17
18
|
view_range: z.array(z.number().int()).optional(),
|
|
18
19
|
}),
|
|
@@ -42,10 +43,15 @@ export const textEditor_20250124 = createProviderToolFactory<
|
|
|
42
43
|
insert_line?: number;
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
|
-
* Optional parameter of `str_replace` command containing the new string (if not given, no string will be added).
|
|
46
|
+
* Optional parameter of `str_replace` command containing the new string (if not given, no string will be added).
|
|
46
47
|
*/
|
|
47
48
|
new_str?: string;
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Required parameter of `insert` command containing the text to insert.
|
|
52
|
+
*/
|
|
53
|
+
insert_text?: string;
|
|
54
|
+
|
|
49
55
|
/**
|
|
50
56
|
* Required parameter of `str_replace` command containing the string in `path` to replace.
|
|
51
57
|
*/
|
|
@@ -13,6 +13,7 @@ const textEditor_20250429InputSchema = lazySchema(() =>
|
|
|
13
13
|
file_text: z.string().optional(),
|
|
14
14
|
insert_line: z.number().int().optional(),
|
|
15
15
|
new_str: z.string().optional(),
|
|
16
|
+
insert_text: z.string().optional(),
|
|
16
17
|
old_str: z.string().optional(),
|
|
17
18
|
view_range: z.array(z.number().int()).optional(),
|
|
18
19
|
}),
|
|
@@ -43,10 +44,15 @@ export const textEditor_20250429 = createProviderToolFactory<
|
|
|
43
44
|
insert_line?: number;
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
|
-
* Optional parameter of `str_replace` command containing the new string (if not given, no string will be added).
|
|
47
|
+
* Optional parameter of `str_replace` command containing the new string (if not given, no string will be added).
|
|
47
48
|
*/
|
|
48
49
|
new_str?: string;
|
|
49
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Required parameter of `insert` command containing the text to insert.
|
|
53
|
+
*/
|
|
54
|
+
insert_text?: string;
|
|
55
|
+
|
|
50
56
|
/**
|
|
51
57
|
* Required parameter of `str_replace` command containing the string in `path` to replace.
|
|
52
58
|
*/
|
|
@@ -18,6 +18,7 @@ const textEditor_20250728InputSchema = lazySchema(() =>
|
|
|
18
18
|
file_text: z.string().optional(),
|
|
19
19
|
insert_line: z.number().int().optional(),
|
|
20
20
|
new_str: z.string().optional(),
|
|
21
|
+
insert_text: z.string().optional(),
|
|
21
22
|
old_str: z.string().optional(),
|
|
22
23
|
view_range: z.array(z.number().int()).optional(),
|
|
23
24
|
}),
|
|
@@ -48,10 +49,15 @@ const factory = createProviderToolFactory<
|
|
|
48
49
|
insert_line?: number;
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
|
-
* Optional parameter of `str_replace` command containing the new string (if not given, no string will be added).
|
|
52
|
+
* Optional parameter of `str_replace` command containing the new string (if not given, no string will be added).
|
|
52
53
|
*/
|
|
53
54
|
new_str?: string;
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Required parameter of `insert` command containing the text to insert.
|
|
58
|
+
*/
|
|
59
|
+
insert_text?: string;
|
|
60
|
+
|
|
55
61
|
/**
|
|
56
62
|
* Required parameter of `str_replace` command containing the string in `path` to replace.
|
|
57
63
|
*/
|