@ai-sdk/anthropic 4.0.0-beta.5 → 4.0.0-beta.67
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 +500 -4
- package/README.md +2 -0
- package/dist/index.d.ts +265 -68
- package/dist/index.js +2636 -1427
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +234 -62
- package/dist/internal/index.js +2605 -1413
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +303 -20
- package/package.json +16 -17
- package/src/{anthropic-messages-api.ts → anthropic-api.ts} +158 -17
- package/src/anthropic-error.ts +1 -1
- package/src/anthropic-files.ts +95 -0
- package/src/{anthropic-messages-options.ts → anthropic-language-model-options.ts} +104 -11
- package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +494 -96
- package/src/anthropic-message-metadata.ts +69 -9
- package/src/anthropic-prepare-tools.ts +31 -7
- package/src/anthropic-provider.ts +42 -13
- package/src/anthropic-tools.ts +31 -0
- package/src/convert-anthropic-usage.ts +109 -0
- package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +376 -198
- package/src/forward-anthropic-container-id-from-last-step.ts +2 -2
- package/src/get-cache-control.ts +5 -2
- package/src/index.ts +1 -1
- package/src/internal/index.ts +13 -2
- package/src/map-anthropic-stop-reason.ts +1 -1
- package/src/sanitize-json-schema.ts +203 -0
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +132 -0
- package/src/tool/advisor_20260301.ts +128 -0
- package/src/tool/bash_20241022.ts +84 -13
- package/src/tool/bash_20250124.ts +84 -13
- package/src/tool/code-execution_20250522.ts +2 -2
- package/src/tool/code-execution_20250825.ts +2 -2
- package/src/tool/code-execution_20260120.ts +2 -2
- package/src/tool/computer_20241022.ts +2 -2
- package/src/tool/computer_20250124.ts +2 -2
- package/src/tool/computer_20251124.ts +2 -2
- package/src/tool/memory_20250818.ts +2 -2
- package/src/tool/text-editor_20241022.ts +2 -2
- package/src/tool/text-editor_20250124.ts +2 -2
- package/src/tool/text-editor_20250429.ts +2 -2
- package/src/tool/text-editor_20250728.ts +6 -3
- package/src/tool/tool-search-bm25_20251119.ts +2 -2
- package/src/tool/tool-search-regex_20251119.ts +2 -2
- package/src/tool/web-fetch-20250910.ts +2 -2
- package/src/tool/web-fetch-20260209.ts +2 -2
- package/src/tool/web-search_20250305.ts +2 -2
- package/src/tool/web-search_20260209.ts +2 -2
- package/dist/index.d.mts +0 -1090
- package/dist/index.mjs +0 -5244
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -969
- package/dist/internal/index.mjs +0 -5136
- package/dist/internal/index.mjs.map +0 -1
- package/src/convert-anthropic-messages-usage.ts +0 -73
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
|
+
type Experimental_SandboxSession as SandboxSession,
|
|
5
|
+
type ProviderDefinedTool,
|
|
6
|
+
type Tool,
|
|
7
|
+
type ToolExecuteFunction,
|
|
4
8
|
zodSchema,
|
|
5
9
|
} from '@ai-sdk/provider-utils';
|
|
6
10
|
import { z } from 'zod/v4';
|
|
7
11
|
|
|
12
|
+
type Bash20250124Input = {
|
|
13
|
+
/**
|
|
14
|
+
* The bash command to run. Required unless the tool is being restarted.
|
|
15
|
+
*/
|
|
16
|
+
command: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Specifying true will restart this tool. Otherwise, leave this unspecified.
|
|
20
|
+
*/
|
|
21
|
+
restart?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
8
24
|
const bash_20250124InputSchema = lazySchema(() =>
|
|
9
25
|
zodSchema(
|
|
10
26
|
z.object({
|
|
@@ -14,20 +30,75 @@ const bash_20250124InputSchema = lazySchema(() =>
|
|
|
14
30
|
),
|
|
15
31
|
);
|
|
16
32
|
|
|
17
|
-
export const
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The bash command to run. Required unless the tool is being restarted.
|
|
21
|
-
*/
|
|
22
|
-
command: string;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Specifying true will restart this tool. Otherwise, leave this unspecified.
|
|
26
|
-
*/
|
|
27
|
-
restart?: boolean;
|
|
28
|
-
},
|
|
33
|
+
export const bash_20250124_internal = createProviderDefinedToolFactory<
|
|
34
|
+
Bash20250124Input,
|
|
29
35
|
{}
|
|
30
36
|
>({
|
|
31
37
|
id: 'anthropic.bash_20250124',
|
|
32
38
|
inputSchema: bash_20250124InputSchema,
|
|
33
39
|
});
|
|
40
|
+
|
|
41
|
+
type Bash20250124Options<OUTPUT> = {
|
|
42
|
+
execute?: ToolExecuteFunction<Bash20250124Input, OUTPUT, {}>;
|
|
43
|
+
needsApproval?: Tool<Bash20250124Input, OUTPUT, {}>['needsApproval'];
|
|
44
|
+
toModelOutput?: Tool<Bash20250124Input, OUTPUT, {}>['toModelOutput'];
|
|
45
|
+
onInputStart?: Tool<Bash20250124Input, OUTPUT, {}>['onInputStart'];
|
|
46
|
+
onInputDelta?: Tool<Bash20250124Input, OUTPUT, {}>['onInputDelta'];
|
|
47
|
+
onInputAvailable?: Tool<Bash20250124Input, OUTPUT, {}>['onInputAvailable'];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type Bash20250124OptionsWithNullableExecute<OUTPUT> = Omit<
|
|
51
|
+
Bash20250124Options<OUTPUT>,
|
|
52
|
+
'execute'
|
|
53
|
+
> & {
|
|
54
|
+
execute?: Bash20250124Options<OUTPUT>['execute'] | null;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type Bash20250124DefaultOutput = Awaited<ReturnType<SandboxSession['run']>>;
|
|
58
|
+
|
|
59
|
+
export function bash_20250124(
|
|
60
|
+
options?: Omit<Bash20250124Options<Bash20250124DefaultOutput>, 'execute'> & {
|
|
61
|
+
execute?: undefined;
|
|
62
|
+
},
|
|
63
|
+
): ProviderDefinedTool<Bash20250124Input, Bash20250124DefaultOutput, {}>;
|
|
64
|
+
export function bash_20250124<OUTPUT = never>(
|
|
65
|
+
options: Omit<Bash20250124Options<OUTPUT>, 'execute'> & {
|
|
66
|
+
execute: null;
|
|
67
|
+
},
|
|
68
|
+
): ProviderDefinedTool<Bash20250124Input, OUTPUT, {}>;
|
|
69
|
+
export function bash_20250124<OUTPUT>(
|
|
70
|
+
options: Omit<Bash20250124Options<OUTPUT>, 'execute'> & {
|
|
71
|
+
execute: Bash20250124Options<OUTPUT>['execute'];
|
|
72
|
+
},
|
|
73
|
+
): ProviderDefinedTool<Bash20250124Input, OUTPUT, {}>;
|
|
74
|
+
export function bash_20250124<OUTPUT>(
|
|
75
|
+
options: Bash20250124OptionsWithNullableExecute<OUTPUT> = {},
|
|
76
|
+
): ProviderDefinedTool<Bash20250124Input, OUTPUT, {}> {
|
|
77
|
+
const { execute, ...rest } = options;
|
|
78
|
+
|
|
79
|
+
if (execute === undefined) {
|
|
80
|
+
return bash_20250124_internal({
|
|
81
|
+
...rest,
|
|
82
|
+
execute: async (
|
|
83
|
+
{ command },
|
|
84
|
+
{ abortSignal, experimental_sandbox: sandbox },
|
|
85
|
+
) => {
|
|
86
|
+
if (!sandbox) {
|
|
87
|
+
throw new Error('Sandbox session is not available');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return await sandbox.run({
|
|
91
|
+
command,
|
|
92
|
+
abortSignal,
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
} as Bash20250124Options<Bash20250124DefaultOutput>) as ReturnType<
|
|
96
|
+
typeof bash_20250124_internal<OUTPUT>
|
|
97
|
+
>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return bash_20250124_internal({
|
|
101
|
+
...rest,
|
|
102
|
+
...(execute === null ? {} : { execute }),
|
|
103
|
+
} as Bash20250124Options<OUTPUT>);
|
|
104
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -33,7 +33,7 @@ const codeExecution_20250522InputSchema = lazySchema(() =>
|
|
|
33
33
|
),
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
const factory =
|
|
36
|
+
const factory = createProviderExecutedToolFactory<
|
|
37
37
|
{
|
|
38
38
|
/**
|
|
39
39
|
* The Python code to execute.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -103,7 +103,7 @@ export const codeExecution_20250825InputSchema = lazySchema(() =>
|
|
|
103
103
|
),
|
|
104
104
|
);
|
|
105
105
|
|
|
106
|
-
const factory =
|
|
106
|
+
const factory = createProviderExecutedToolFactory<
|
|
107
107
|
| {
|
|
108
108
|
type: 'programmatic-tool-call';
|
|
109
109
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -117,7 +117,7 @@ export const codeExecution_20260120InputSchema = lazySchema(() =>
|
|
|
117
117
|
),
|
|
118
118
|
);
|
|
119
119
|
|
|
120
|
-
const factory =
|
|
120
|
+
const factory = createProviderExecutedToolFactory<
|
|
121
121
|
| {
|
|
122
122
|
type: 'programmatic-tool-call';
|
|
123
123
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -26,7 +26,7 @@ const computer_20241022InputSchema = lazySchema(() =>
|
|
|
26
26
|
),
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
export const computer_20241022 =
|
|
29
|
+
export const computer_20241022 = createProviderDefinedToolFactory<
|
|
30
30
|
{
|
|
31
31
|
/**
|
|
32
32
|
* The action to perform. The available actions are:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -38,7 +38,7 @@ const computer_20250124InputSchema = lazySchema(() =>
|
|
|
38
38
|
),
|
|
39
39
|
);
|
|
40
40
|
|
|
41
|
-
export const computer_20250124 =
|
|
41
|
+
export const computer_20250124 = createProviderDefinedToolFactory<
|
|
42
42
|
{
|
|
43
43
|
/**
|
|
44
44
|
* - `key`: Press a key or key-combination on the keyboard.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -47,7 +47,7 @@ const computer_20251124InputSchema = lazySchema(() =>
|
|
|
47
47
|
),
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
export const computer_20251124 =
|
|
50
|
+
export const computer_20251124 = createProviderDefinedToolFactory<
|
|
51
51
|
{
|
|
52
52
|
/**
|
|
53
53
|
* - `key`: Press a key or key-combination on the keyboard.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -43,7 +43,7 @@ const memory_20250818InputSchema = lazySchema(() =>
|
|
|
43
43
|
),
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
export const memory_20250818 =
|
|
46
|
+
export const memory_20250818 = createProviderDefinedToolFactory<
|
|
47
47
|
| { command: 'view'; path: string; view_range?: [number, number] }
|
|
48
48
|
| { command: 'create'; path: string; file_text: string }
|
|
49
49
|
| { command: 'str_replace'; path: string; old_str: string; new_str: string }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -20,7 +20,7 @@ const textEditor_20241022InputSchema = lazySchema(() =>
|
|
|
20
20
|
),
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
export const textEditor_20241022 =
|
|
23
|
+
export const textEditor_20241022 = createProviderDefinedToolFactory<
|
|
24
24
|
{
|
|
25
25
|
/**
|
|
26
26
|
* The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -20,7 +20,7 @@ const textEditor_20250124InputSchema = lazySchema(() =>
|
|
|
20
20
|
),
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
export const textEditor_20250124 =
|
|
23
|
+
export const textEditor_20250124 = createProviderDefinedToolFactory<
|
|
24
24
|
{
|
|
25
25
|
/**
|
|
26
26
|
* The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -20,7 +20,7 @@ const textEditor_20250429InputSchema = lazySchema(() =>
|
|
|
20
20
|
),
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
export const textEditor_20250429 =
|
|
23
|
+
export const textEditor_20250429 = createProviderDefinedToolFactory<
|
|
24
24
|
{
|
|
25
25
|
/**
|
|
26
26
|
* The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
2
6
|
import { z } from 'zod/v4';
|
|
3
|
-
import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
|
|
4
7
|
|
|
5
8
|
export const textEditor_20250728ArgsSchema = lazySchema(() =>
|
|
6
9
|
zodSchema(
|
|
@@ -25,7 +28,7 @@ const textEditor_20250728InputSchema = lazySchema(() =>
|
|
|
25
28
|
),
|
|
26
29
|
);
|
|
27
30
|
|
|
28
|
-
const factory =
|
|
31
|
+
const factory = createProviderDefinedToolFactory<
|
|
29
32
|
{
|
|
30
33
|
/**
|
|
31
34
|
* The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -40,7 +40,7 @@ const toolSearchBm25_20251119InputSchema = lazySchema(() =>
|
|
|
40
40
|
),
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
-
const factory =
|
|
43
|
+
const factory = createProviderExecutedToolFactory<
|
|
44
44
|
{
|
|
45
45
|
/**
|
|
46
46
|
* A natural language query to search for tools.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -46,7 +46,7 @@ const toolSearchRegex_20251119InputSchema = lazySchema(() =>
|
|
|
46
46
|
),
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
const factory =
|
|
49
|
+
const factory = createProviderExecutedToolFactory<
|
|
50
50
|
{
|
|
51
51
|
/**
|
|
52
52
|
* A regex pattern to search for tools.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -52,7 +52,7 @@ const webFetch_20250910InputSchema = lazySchema(() =>
|
|
|
52
52
|
),
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
const factory =
|
|
55
|
+
const factory = createProviderExecutedToolFactory<
|
|
56
56
|
{
|
|
57
57
|
/**
|
|
58
58
|
* The URL to fetch.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -52,7 +52,7 @@ const webFetch_20260209InputSchema = lazySchema(() =>
|
|
|
52
52
|
),
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
const factory =
|
|
55
|
+
const factory = createProviderExecutedToolFactory<
|
|
56
56
|
{
|
|
57
57
|
/**
|
|
58
58
|
* The URL to fetch.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -46,7 +46,7 @@ const webSearch_20250305InputSchema = lazySchema(() =>
|
|
|
46
46
|
),
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
const factory =
|
|
49
|
+
const factory = createProviderExecutedToolFactory<
|
|
50
50
|
{
|
|
51
51
|
/**
|
|
52
52
|
* The search query to execute.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -46,7 +46,7 @@ const webSearch_20260209InputSchema = lazySchema(() =>
|
|
|
46
46
|
),
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
const factory =
|
|
49
|
+
const factory = createProviderExecutedToolFactory<
|
|
50
50
|
{
|
|
51
51
|
/**
|
|
52
52
|
* The search query to execute.
|