@ai-sdk/anthropic 3.0.17 → 3.0.19
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.js +57 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -30
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +56 -29
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +56 -29
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/__fixtures__/anthropic-code-execution-20250825.1.chunks.txt +248 -0
- package/src/__fixtures__/anthropic-code-execution-20250825.1.json +70 -0
- package/src/__fixtures__/anthropic-code-execution-20250825.2.chunks.txt +984 -0
- package/src/__fixtures__/anthropic-code-execution-20250825.2.json +111 -0
- package/src/__fixtures__/anthropic-code-execution-20250825.pptx-skill.chunks.txt +691 -0
- package/src/__fixtures__/anthropic-code-execution-20250825.pptx-skill.json +1801 -0
- package/src/__fixtures__/anthropic-json-other-tool.1.chunks.txt +13 -0
- package/src/__fixtures__/anthropic-json-other-tool.1.json +26 -0
- package/src/__fixtures__/anthropic-json-output-format.1.chunks.txt +120 -0
- package/src/__fixtures__/anthropic-json-output-format.1.json +25 -0
- package/src/__fixtures__/anthropic-json-tool.1.chunks.txt +9 -0
- package/src/__fixtures__/anthropic-json-tool.1.json +37 -0
- package/src/__fixtures__/anthropic-json-tool.2.chunks.txt +14 -0
- package/src/__fixtures__/anthropic-mcp.1.chunks.txt +17 -0
- package/src/__fixtures__/anthropic-mcp.1.json +39 -0
- package/src/__fixtures__/anthropic-memory-20250818.1.json +28 -0
- package/src/__fixtures__/anthropic-message-delta-input-tokens.chunks.txt +8 -0
- package/src/__fixtures__/anthropic-programmatic-tool-calling.1.chunks.txt +278 -0
- package/src/__fixtures__/anthropic-programmatic-tool-calling.1.json +106 -0
- package/src/__fixtures__/anthropic-tool-no-args.chunks.txt +13 -0
- package/src/__fixtures__/anthropic-tool-no-args.json +31 -0
- package/src/__fixtures__/anthropic-tool-search-bm25.1.chunks.txt +47 -0
- package/src/__fixtures__/anthropic-tool-search-bm25.1.json +67 -0
- package/src/__fixtures__/anthropic-tool-search-regex.1.chunks.txt +51 -0
- package/src/__fixtures__/anthropic-tool-search-regex.1.json +65 -0
- package/src/__fixtures__/anthropic-web-fetch-tool.1.chunks.txt +64 -0
- package/src/__fixtures__/anthropic-web-fetch-tool.1.json +54 -0
- package/src/__fixtures__/anthropic-web-fetch-tool.2.json +56 -0
- package/src/__fixtures__/anthropic-web-fetch-tool.error.json +46 -0
- package/src/__fixtures__/anthropic-web-search-tool.1.chunks.txt +120 -0
- package/src/__fixtures__/anthropic-web-search-tool.1.json +181 -0
- package/src/__snapshots__/anthropic-messages-language-model.test.ts.snap +16719 -0
- package/src/anthropic-error.test.ts +42 -0
- package/src/anthropic-error.ts +26 -0
- package/src/anthropic-message-metadata.ts +105 -0
- package/src/anthropic-messages-api.ts +1188 -0
- package/src/anthropic-messages-language-model.test.ts +7170 -0
- package/src/anthropic-messages-language-model.ts +2067 -0
- package/src/anthropic-messages-options.ts +213 -0
- package/src/anthropic-prepare-tools.test.ts +1219 -0
- package/src/anthropic-prepare-tools.ts +341 -0
- package/src/anthropic-provider.test.ts +162 -0
- package/src/anthropic-provider.ts +152 -0
- package/src/anthropic-tools.ts +182 -0
- package/src/convert-anthropic-messages-usage.ts +32 -0
- package/src/convert-to-anthropic-messages-prompt.test.ts +2902 -0
- package/src/convert-to-anthropic-messages-prompt.ts +1050 -0
- package/src/forward-anthropic-container-id-from-last-step.ts +38 -0
- package/src/get-cache-control.ts +63 -0
- package/src/index.ts +10 -0
- package/src/internal/index.ts +4 -0
- package/src/map-anthropic-stop-reason.ts +28 -0
- package/src/tool/bash_20241022.ts +33 -0
- package/src/tool/bash_20250124.ts +33 -0
- package/src/tool/code-execution_20250522.ts +61 -0
- package/src/tool/code-execution_20250825.ts +281 -0
- package/src/tool/computer_20241022.ts +87 -0
- package/src/tool/computer_20250124.ts +130 -0
- package/src/tool/memory_20250818.ts +62 -0
- package/src/tool/text-editor_20241022.ts +63 -0
- package/src/tool/text-editor_20250124.ts +63 -0
- package/src/tool/text-editor_20250429.ts +64 -0
- package/src/tool/text-editor_20250728.ts +80 -0
- package/src/tool/tool-search-bm25_20251119.ts +98 -0
- package/src/tool/tool-search-regex_20251119.ts +110 -0
- package/src/tool/web-fetch-20250910.ts +145 -0
- package/src/tool/web-search_20250305.ts +136 -0
- package/src/version.ts +6 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderToolFactoryWithOutputSchema,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
6
|
+
import { z } from 'zod/v4';
|
|
7
|
+
|
|
8
|
+
export const webFetch_20250910ArgsSchema = lazySchema(() =>
|
|
9
|
+
zodSchema(
|
|
10
|
+
z.object({
|
|
11
|
+
maxUses: z.number().optional(),
|
|
12
|
+
allowedDomains: z.array(z.string()).optional(),
|
|
13
|
+
blockedDomains: z.array(z.string()).optional(),
|
|
14
|
+
citations: z.object({ enabled: z.boolean() }).optional(),
|
|
15
|
+
maxContentTokens: z.number().optional(),
|
|
16
|
+
}),
|
|
17
|
+
),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const webFetch_20250910OutputSchema = lazySchema(() =>
|
|
21
|
+
zodSchema(
|
|
22
|
+
z.object({
|
|
23
|
+
type: z.literal('web_fetch_result'),
|
|
24
|
+
url: z.string(),
|
|
25
|
+
content: z.object({
|
|
26
|
+
type: z.literal('document'),
|
|
27
|
+
title: z.string().nullable(),
|
|
28
|
+
citations: z.object({ enabled: z.boolean() }).optional(),
|
|
29
|
+
source: z.union([
|
|
30
|
+
z.object({
|
|
31
|
+
type: z.literal('base64'),
|
|
32
|
+
mediaType: z.literal('application/pdf'),
|
|
33
|
+
data: z.string(),
|
|
34
|
+
}),
|
|
35
|
+
z.object({
|
|
36
|
+
type: z.literal('text'),
|
|
37
|
+
mediaType: z.literal('text/plain'),
|
|
38
|
+
data: z.string(),
|
|
39
|
+
}),
|
|
40
|
+
]),
|
|
41
|
+
}),
|
|
42
|
+
retrievedAt: z.string().nullable(),
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const webFetch_20250910InputSchema = lazySchema(() =>
|
|
48
|
+
zodSchema(
|
|
49
|
+
z.object({
|
|
50
|
+
url: z.string(),
|
|
51
|
+
}),
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const factory = createProviderToolFactoryWithOutputSchema<
|
|
56
|
+
{
|
|
57
|
+
/**
|
|
58
|
+
* The URL to fetch.
|
|
59
|
+
*/
|
|
60
|
+
url: string;
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'web_fetch_result';
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Fetched content URL
|
|
67
|
+
*/
|
|
68
|
+
url: string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Fetched content.
|
|
72
|
+
*/
|
|
73
|
+
content: {
|
|
74
|
+
type: 'document';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Title of the document
|
|
78
|
+
*/
|
|
79
|
+
title: string | null;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Citation configuration for the document
|
|
83
|
+
*/
|
|
84
|
+
citations?: { enabled: boolean };
|
|
85
|
+
|
|
86
|
+
source:
|
|
87
|
+
| {
|
|
88
|
+
type: 'base64';
|
|
89
|
+
mediaType: 'application/pdf';
|
|
90
|
+
data: string;
|
|
91
|
+
}
|
|
92
|
+
| {
|
|
93
|
+
type: 'text';
|
|
94
|
+
mediaType: 'text/plain';
|
|
95
|
+
data: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* ISO 8601 timestamp when the content was retrieved
|
|
101
|
+
*/
|
|
102
|
+
retrievedAt: string | null;
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
/**
|
|
106
|
+
* The maxUses parameter limits the number of web fetches performed
|
|
107
|
+
*/
|
|
108
|
+
maxUses?: number;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Only fetch from these domains
|
|
112
|
+
*/
|
|
113
|
+
allowedDomains?: string[];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Never fetch from these domains
|
|
117
|
+
*/
|
|
118
|
+
blockedDomains?: string[];
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Unlike web search where citations are always enabled, citations are optional for
|
|
122
|
+
* web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages
|
|
123
|
+
* from fetched documents.
|
|
124
|
+
*/
|
|
125
|
+
citations?: {
|
|
126
|
+
enabled: boolean;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The maxContentTokens parameter limits the amount of content that will be included in the context.
|
|
131
|
+
*/
|
|
132
|
+
maxContentTokens?: number;
|
|
133
|
+
}
|
|
134
|
+
>({
|
|
135
|
+
id: 'anthropic.web_fetch_20250910',
|
|
136
|
+
inputSchema: webFetch_20250910InputSchema,
|
|
137
|
+
outputSchema: webFetch_20250910OutputSchema,
|
|
138
|
+
supportsDeferredResults: true,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
export const webFetch_20250910 = (
|
|
142
|
+
args: Parameters<typeof factory>[0] = {}, // default
|
|
143
|
+
) => {
|
|
144
|
+
return factory(args);
|
|
145
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderToolFactoryWithOutputSchema,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
6
|
+
import { z } from 'zod/v4';
|
|
7
|
+
|
|
8
|
+
export const webSearch_20250305ArgsSchema = lazySchema(() =>
|
|
9
|
+
zodSchema(
|
|
10
|
+
z.object({
|
|
11
|
+
maxUses: z.number().optional(),
|
|
12
|
+
allowedDomains: z.array(z.string()).optional(),
|
|
13
|
+
blockedDomains: z.array(z.string()).optional(),
|
|
14
|
+
userLocation: z
|
|
15
|
+
.object({
|
|
16
|
+
type: z.literal('approximate'),
|
|
17
|
+
city: z.string().optional(),
|
|
18
|
+
region: z.string().optional(),
|
|
19
|
+
country: z.string().optional(),
|
|
20
|
+
timezone: z.string().optional(),
|
|
21
|
+
})
|
|
22
|
+
.optional(),
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const webSearch_20250305OutputSchema = lazySchema(() =>
|
|
28
|
+
zodSchema(
|
|
29
|
+
z.array(
|
|
30
|
+
z.object({
|
|
31
|
+
url: z.string(),
|
|
32
|
+
title: z.string().nullable(),
|
|
33
|
+
pageAge: z.string().nullable(),
|
|
34
|
+
encryptedContent: z.string(),
|
|
35
|
+
type: z.literal('web_search_result'),
|
|
36
|
+
}),
|
|
37
|
+
),
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const webSearch_20250305InputSchema = lazySchema(() =>
|
|
42
|
+
zodSchema(
|
|
43
|
+
z.object({
|
|
44
|
+
query: z.string(),
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const factory = createProviderToolFactoryWithOutputSchema<
|
|
50
|
+
{
|
|
51
|
+
/**
|
|
52
|
+
* The search query to execute.
|
|
53
|
+
*/
|
|
54
|
+
query: string;
|
|
55
|
+
},
|
|
56
|
+
Array<{
|
|
57
|
+
type: 'web_search_result';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The URL of the source page.
|
|
61
|
+
*/
|
|
62
|
+
url: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The title of the source page.
|
|
66
|
+
*/
|
|
67
|
+
title: string | null;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* When the site was last updated
|
|
71
|
+
*/
|
|
72
|
+
pageAge: string | null;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Encrypted content that must be passed back in multi-turn conversations for citations
|
|
76
|
+
*/
|
|
77
|
+
encryptedContent: string;
|
|
78
|
+
}>,
|
|
79
|
+
{
|
|
80
|
+
/**
|
|
81
|
+
* Maximum number of web searches Claude can perform during the conversation.
|
|
82
|
+
*/
|
|
83
|
+
maxUses?: number;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Optional list of domains that Claude is allowed to search.
|
|
87
|
+
*/
|
|
88
|
+
allowedDomains?: string[];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Optional list of domains that Claude should avoid when searching.
|
|
92
|
+
*/
|
|
93
|
+
blockedDomains?: string[];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Optional user location information to provide geographically relevant search results.
|
|
97
|
+
*/
|
|
98
|
+
userLocation?: {
|
|
99
|
+
/**
|
|
100
|
+
* The type of location (must be approximate)
|
|
101
|
+
*/
|
|
102
|
+
type: 'approximate';
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The city name
|
|
106
|
+
*/
|
|
107
|
+
city?: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The region or state
|
|
111
|
+
*/
|
|
112
|
+
region?: string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The country
|
|
116
|
+
*/
|
|
117
|
+
country?: string;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The IANA timezone ID.
|
|
121
|
+
*/
|
|
122
|
+
timezone?: string;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
>({
|
|
126
|
+
id: 'anthropic.web_search_20250305',
|
|
127
|
+
inputSchema: webSearch_20250305InputSchema,
|
|
128
|
+
outputSchema: webSearch_20250305OutputSchema,
|
|
129
|
+
supportsDeferredResults: true,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export const webSearch_20250305 = (
|
|
133
|
+
args: Parameters<typeof factory>[0] = {}, // default
|
|
134
|
+
) => {
|
|
135
|
+
return factory(args);
|
|
136
|
+
};
|