@ai-sdk/anthropic 4.0.54 → 4.0.56
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 +26 -0
- package/dist/index.d.ts +107 -1
- package/dist/index.js +662 -484
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +109 -2
- package/dist/internal/index.js +608 -435
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +91 -7
- package/package.json +3 -3
- package/src/anthropic-api.ts +8 -2
- package/src/anthropic-language-model.ts +14 -12
- package/src/anthropic-prepare-tools.ts +38 -0
- package/src/anthropic-provider.ts +10 -0
- package/src/anthropic-tools.ts +26 -0
- package/src/convert-to-anthropic-prompt.ts +8 -7
- package/src/tool/web-fetch-20260318.ts +159 -0
- package/src/tool/web-search_20260318.ts +143 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
6
|
+
import { z } from 'zod/v4';
|
|
7
|
+
|
|
8
|
+
export const webSearch_20260318ArgsSchema = 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
|
+
responseInclusion: z.enum(['full', 'excluded']).optional(),
|
|
24
|
+
}),
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const webSearch_20260318OutputSchema = lazySchema(() =>
|
|
29
|
+
zodSchema(
|
|
30
|
+
z.array(
|
|
31
|
+
z.object({
|
|
32
|
+
url: z.string(),
|
|
33
|
+
title: z.string().nullable(),
|
|
34
|
+
pageAge: z.string().nullable(),
|
|
35
|
+
encryptedContent: z.string(),
|
|
36
|
+
type: z.literal('web_search_result'),
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const webSearch_20260318InputSchema = lazySchema(() =>
|
|
43
|
+
zodSchema(
|
|
44
|
+
z.object({
|
|
45
|
+
query: z.string(),
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const factory = createProviderExecutedToolFactory<
|
|
51
|
+
{
|
|
52
|
+
/**
|
|
53
|
+
* The search query to execute.
|
|
54
|
+
*/
|
|
55
|
+
query: string;
|
|
56
|
+
},
|
|
57
|
+
Array<{
|
|
58
|
+
type: 'web_search_result';
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The URL of the source page.
|
|
62
|
+
*/
|
|
63
|
+
url: string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The title of the source page.
|
|
67
|
+
*/
|
|
68
|
+
title: string | null;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* When the site was last updated
|
|
72
|
+
*/
|
|
73
|
+
pageAge: string | null;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Encrypted content that must be passed back in multi-turn conversations for citations
|
|
77
|
+
*/
|
|
78
|
+
encryptedContent: string;
|
|
79
|
+
}>,
|
|
80
|
+
{
|
|
81
|
+
/**
|
|
82
|
+
* Maximum number of web searches Claude can perform during the conversation.
|
|
83
|
+
*/
|
|
84
|
+
maxUses?: number;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Optional list of domains that Claude is allowed to search.
|
|
88
|
+
*/
|
|
89
|
+
allowedDomains?: string[];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Optional list of domains that Claude should avoid when searching.
|
|
93
|
+
*/
|
|
94
|
+
blockedDomains?: string[];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Optional user location information to provide geographically relevant search results.
|
|
98
|
+
*/
|
|
99
|
+
userLocation?: {
|
|
100
|
+
/**
|
|
101
|
+
* The type of location (must be approximate)
|
|
102
|
+
*/
|
|
103
|
+
type: 'approximate';
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The city name
|
|
107
|
+
*/
|
|
108
|
+
city?: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The region or state
|
|
112
|
+
*/
|
|
113
|
+
region?: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The country
|
|
117
|
+
*/
|
|
118
|
+
country?: string;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The IANA timezone ID.
|
|
122
|
+
*/
|
|
123
|
+
timezone?: string;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Controls whether web search result blocks consumed by completed code
|
|
128
|
+
* execution calls are included in the response. Defaults to `full`.
|
|
129
|
+
*/
|
|
130
|
+
responseInclusion?: 'full' | 'excluded';
|
|
131
|
+
}
|
|
132
|
+
>({
|
|
133
|
+
id: 'anthropic.web_search_20260318',
|
|
134
|
+
inputSchema: webSearch_20260318InputSchema,
|
|
135
|
+
outputSchema: webSearch_20260318OutputSchema,
|
|
136
|
+
supportsDeferredResults: true,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export const webSearch_20260318 = (
|
|
140
|
+
args: Parameters<typeof factory>[0] = {}, // default
|
|
141
|
+
) => {
|
|
142
|
+
return factory(args);
|
|
143
|
+
};
|