@ai-sdk/anthropic 4.0.0-beta.37 → 4.0.0-beta.39
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 +23 -0
- package/dist/index.d.ts +24 -24
- package/dist/index.js +59 -61
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +29 -29
- package/dist/internal/index.js +59 -60
- package/dist/internal/index.js.map +1 -1
- package/package.json +8 -6
- package/src/{anthropic-messages-api.ts → anthropic-api.ts} +4 -4
- package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +32 -37
- package/src/{anthropic-messages-options.ts → anthropic-options.ts} +1 -1
- package/src/anthropic-prepare-tools.ts +1 -1
- package/src/anthropic-provider.ts +9 -9
- package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +3 -3
- package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +9 -8
- package/src/get-cache-control.ts +1 -1
- package/src/index.ts +1 -1
- package/src/internal/index.ts +9 -3
- package/src/tool/bash_20241022.ts +2 -2
- package/src/tool/bash_20250124.ts +2 -2
- 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 +2 -2
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/anthropic",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ai-sdk/provider": "4.0.0-beta.
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.0-beta.
|
|
38
|
+
"@ai-sdk/provider": "4.0.0-beta.13",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.0-beta.28"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "20.17.24",
|
|
43
43
|
"tsup": "^8",
|
|
44
44
|
"typescript": "5.8.3",
|
|
45
45
|
"zod": "3.25.76",
|
|
46
|
-
"@ai-sdk/test-server": "2.0.0-beta.
|
|
46
|
+
"@ai-sdk/test-server": "2.0.0-beta.2",
|
|
47
47
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -53,12 +53,14 @@
|
|
|
53
53
|
"node": ">=18"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
|
-
"access": "public"
|
|
56
|
+
"access": "public",
|
|
57
|
+
"provenance": true
|
|
57
58
|
},
|
|
58
59
|
"homepage": "https://ai-sdk.dev/docs",
|
|
59
60
|
"repository": {
|
|
60
61
|
"type": "git",
|
|
61
|
-
"url": "
|
|
62
|
+
"url": "https://github.com/vercel/ai",
|
|
63
|
+
"directory": "packages/anthropic"
|
|
62
64
|
},
|
|
63
65
|
"bugs": {
|
|
64
66
|
"url": "https://github.com/vercel/ai/issues"
|
|
@@ -2,7 +2,7 @@ import { JSONSchema7 } from '@ai-sdk/provider';
|
|
|
2
2
|
import { InferSchema, lazySchema, zodSchema } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type AnthropicPrompt = {
|
|
6
6
|
system: Array<AnthropicTextContent> | undefined;
|
|
7
7
|
messages: AnthropicMessage[];
|
|
8
8
|
};
|
|
@@ -553,7 +553,7 @@ export type AnthropicResponseContextManagement = {
|
|
|
553
553
|
|
|
554
554
|
// limited version of the schema, focussed on what is needed for the implementation
|
|
555
555
|
// this approach limits breakages when the API changes and increases efficiency
|
|
556
|
-
export const
|
|
556
|
+
export const anthropicResponseSchema = lazySchema(() =>
|
|
557
557
|
zodSchema(
|
|
558
558
|
z.object({
|
|
559
559
|
type: z.literal('message'),
|
|
@@ -893,7 +893,7 @@ export const anthropicMessagesResponseSchema = lazySchema(() =>
|
|
|
893
893
|
|
|
894
894
|
// limited version of the schema, focused on what is needed for the implementation
|
|
895
895
|
// this approach limits breakages when the API changes and increases efficiency
|
|
896
|
-
export const
|
|
896
|
+
export const anthropicChunkSchema = lazySchema(() =>
|
|
897
897
|
zodSchema(
|
|
898
898
|
z.discriminatedUnion('type', [
|
|
899
899
|
z.object({
|
|
@@ -1342,7 +1342,7 @@ export type AnthropicReasoningMetadata = InferSchema<
|
|
|
1342
1342
|
>;
|
|
1343
1343
|
|
|
1344
1344
|
export type Citation = NonNullable<
|
|
1345
|
-
(InferSchema<typeof
|
|
1345
|
+
(InferSchema<typeof anthropicResponseSchema>['content'][number] & {
|
|
1346
1346
|
type: 'text';
|
|
1347
1347
|
})['citations']
|
|
1348
1348
|
>[number];
|
|
@@ -40,24 +40,24 @@ import { anthropicFailedResponseHandler } from './anthropic-error';
|
|
|
40
40
|
import { AnthropicMessageMetadata } from './anthropic-message-metadata';
|
|
41
41
|
import {
|
|
42
42
|
AnthropicContainer,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
anthropicChunkSchema,
|
|
44
|
+
anthropicResponseSchema,
|
|
45
45
|
AnthropicReasoningMetadata,
|
|
46
46
|
AnthropicResponseContextManagement,
|
|
47
47
|
AnthropicTool,
|
|
48
48
|
Citation,
|
|
49
|
-
} from './anthropic-
|
|
49
|
+
} from './anthropic-api';
|
|
50
50
|
import {
|
|
51
|
-
|
|
51
|
+
AnthropicModelId,
|
|
52
52
|
AnthropicLanguageModelOptions,
|
|
53
53
|
anthropicLanguageModelOptions,
|
|
54
|
-
} from './anthropic-
|
|
54
|
+
} from './anthropic-options';
|
|
55
55
|
import { prepareTools } from './anthropic-prepare-tools';
|
|
56
56
|
import {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} from './convert-anthropic-
|
|
60
|
-
import {
|
|
57
|
+
AnthropicUsage,
|
|
58
|
+
convertAnthropicUsage,
|
|
59
|
+
} from './convert-anthropic-usage';
|
|
60
|
+
import { convertToAnthropicPrompt } from './convert-to-anthropic-prompt';
|
|
61
61
|
import { CacheControlValidator } from './get-cache-control';
|
|
62
62
|
import { mapAnthropicStopReason } from './map-anthropic-stop-reason';
|
|
63
63
|
|
|
@@ -120,7 +120,7 @@ function createCitationSource(
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
type
|
|
123
|
+
type AnthropicLanguageModelConfig = {
|
|
124
124
|
provider: string;
|
|
125
125
|
baseURL: string;
|
|
126
126
|
headers?: Resolvable<Record<string, string | undefined>>;
|
|
@@ -145,15 +145,15 @@ type AnthropicMessagesConfig = {
|
|
|
145
145
|
supportsStrictTools?: boolean;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
export class
|
|
148
|
+
export class AnthropicLanguageModel implements LanguageModelV4 {
|
|
149
149
|
readonly specificationVersion = 'v4';
|
|
150
150
|
|
|
151
|
-
readonly modelId:
|
|
151
|
+
readonly modelId: AnthropicModelId;
|
|
152
152
|
|
|
153
|
-
private readonly config:
|
|
153
|
+
private readonly config: AnthropicLanguageModelConfig;
|
|
154
154
|
private readonly generateId: () => string;
|
|
155
155
|
|
|
156
|
-
static [WORKFLOW_SERIALIZE](model:
|
|
156
|
+
static [WORKFLOW_SERIALIZE](model: AnthropicLanguageModel) {
|
|
157
157
|
return serializeModelOptions({
|
|
158
158
|
modelId: model.modelId,
|
|
159
159
|
config: model.config,
|
|
@@ -161,16 +161,13 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
static [WORKFLOW_DESERIALIZE](options: {
|
|
164
|
-
modelId:
|
|
165
|
-
config:
|
|
164
|
+
modelId: AnthropicModelId;
|
|
165
|
+
config: AnthropicLanguageModelConfig;
|
|
166
166
|
}) {
|
|
167
|
-
return new
|
|
167
|
+
return new AnthropicLanguageModel(options.modelId, options.config);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
constructor(
|
|
171
|
-
modelId: AnthropicMessagesModelId,
|
|
172
|
-
config: AnthropicMessagesConfig,
|
|
173
|
-
) {
|
|
170
|
+
constructor(modelId: AnthropicModelId, config: AnthropicLanguageModelConfig) {
|
|
174
171
|
this.modelId = modelId;
|
|
175
172
|
this.config = config;
|
|
176
173
|
this.generateId = config.generateId ?? generateId;
|
|
@@ -382,14 +379,13 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
|
382
379
|
},
|
|
383
380
|
});
|
|
384
381
|
|
|
385
|
-
const { prompt: messagesPrompt, betas } =
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
});
|
|
382
|
+
const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
|
|
383
|
+
prompt,
|
|
384
|
+
sendReasoning: anthropicOptions?.sendReasoning ?? true,
|
|
385
|
+
warnings,
|
|
386
|
+
cacheControlValidator,
|
|
387
|
+
toolNameMapping,
|
|
388
|
+
});
|
|
393
389
|
|
|
394
390
|
/*
|
|
395
391
|
* Map top-level `reasoning` to Anthropic thinking/effort when provider
|
|
@@ -900,7 +896,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
|
900
896
|
body: this.transformRequestBody(args, betas),
|
|
901
897
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
902
898
|
successfulResponseHandler: createJsonResponseHandler(
|
|
903
|
-
|
|
899
|
+
anthropicResponseSchema,
|
|
904
900
|
),
|
|
905
901
|
abortSignal: options.abortSignal,
|
|
906
902
|
fetch: this.config.fetch,
|
|
@@ -1291,7 +1287,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
|
1291
1287
|
}),
|
|
1292
1288
|
raw: response.stop_reason ?? undefined,
|
|
1293
1289
|
},
|
|
1294
|
-
usage:
|
|
1290
|
+
usage: convertAnthropicUsage({ usage: response.usage }),
|
|
1295
1291
|
request: { body: args },
|
|
1296
1292
|
response: {
|
|
1297
1293
|
id: response.id ?? undefined,
|
|
@@ -1377,9 +1373,8 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
|
1377
1373
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1378
1374
|
body: this.transformRequestBody(body, betas),
|
|
1379
1375
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1380
|
-
successfulResponseHandler:
|
|
1381
|
-
|
|
1382
|
-
),
|
|
1376
|
+
successfulResponseHandler:
|
|
1377
|
+
createEventSourceResponseHandler(anthropicChunkSchema),
|
|
1383
1378
|
abortSignal: options.abortSignal,
|
|
1384
1379
|
fetch: this.config.fetch,
|
|
1385
1380
|
});
|
|
@@ -1388,7 +1383,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
|
1388
1383
|
unified: 'other',
|
|
1389
1384
|
raw: undefined,
|
|
1390
1385
|
};
|
|
1391
|
-
const usage:
|
|
1386
|
+
const usage: AnthropicUsage = {
|
|
1392
1387
|
input_tokens: 0,
|
|
1393
1388
|
output_tokens: 0,
|
|
1394
1389
|
cache_creation_input_tokens: 0,
|
|
@@ -1448,7 +1443,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
|
1448
1443
|
|
|
1449
1444
|
const transformedStream = response.pipeThrough(
|
|
1450
1445
|
new TransformStream<
|
|
1451
|
-
ParseResult<InferSchema<typeof
|
|
1446
|
+
ParseResult<InferSchema<typeof anthropicChunkSchema>>,
|
|
1452
1447
|
LanguageModelV4StreamPart
|
|
1453
1448
|
>({
|
|
1454
1449
|
start(controller) {
|
|
@@ -2310,7 +2305,7 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
|
2310
2305
|
controller.enqueue({
|
|
2311
2306
|
type: 'finish',
|
|
2312
2307
|
finishReason,
|
|
2313
|
-
usage:
|
|
2308
|
+
usage: convertAnthropicUsage({ usage, rawUsage }),
|
|
2314
2309
|
providerMetadata,
|
|
2315
2310
|
});
|
|
2316
2311
|
return;
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
SharedV4Warning,
|
|
4
4
|
UnsupportedFunctionalityError,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
|
-
import { AnthropicTool, AnthropicToolChoice } from './anthropic-
|
|
6
|
+
import { AnthropicTool, AnthropicToolChoice } from './anthropic-api';
|
|
7
7
|
import { CacheControlValidator } from './get-cache-control';
|
|
8
8
|
import { textEditor_20250728ArgsSchema } from './tool/text-editor_20250728';
|
|
9
9
|
import { webSearch_20260209ArgsSchema } from './tool/web-search_20260209';
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
withUserAgentSuffix,
|
|
16
16
|
} from '@ai-sdk/provider-utils';
|
|
17
17
|
import { AnthropicFiles } from './anthropic-files';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { AnthropicLanguageModel } from './anthropic-language-model';
|
|
19
|
+
import { AnthropicModelId } from './anthropic-options';
|
|
20
20
|
import { anthropicTools } from './anthropic-tools';
|
|
21
21
|
import { AnthropicSkills } from './skills/anthropic-skills';
|
|
22
22
|
import { VERSION } from './version';
|
|
@@ -25,16 +25,16 @@ export interface AnthropicProvider extends ProviderV4 {
|
|
|
25
25
|
/**
|
|
26
26
|
* Creates a model for text generation.
|
|
27
27
|
*/
|
|
28
|
-
(modelId:
|
|
28
|
+
(modelId: AnthropicModelId): LanguageModelV4;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Creates a model for text generation.
|
|
32
32
|
*/
|
|
33
|
-
languageModel(modelId:
|
|
33
|
+
languageModel(modelId: AnthropicModelId): LanguageModelV4;
|
|
34
34
|
|
|
35
|
-
chat(modelId:
|
|
35
|
+
chat(modelId: AnthropicModelId): LanguageModelV4;
|
|
36
36
|
|
|
37
|
-
messages(modelId:
|
|
37
|
+
messages(modelId: AnthropicModelId): LanguageModelV4;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* @deprecated Use `embeddingModel` instead.
|
|
@@ -141,8 +141,8 @@ export function createAnthropic(
|
|
|
141
141
|
);
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
const createChatModel = (modelId:
|
|
145
|
-
new
|
|
144
|
+
const createChatModel = (modelId: AnthropicModelId) =>
|
|
145
|
+
new AnthropicLanguageModel(modelId, {
|
|
146
146
|
provider: providerName,
|
|
147
147
|
baseURL,
|
|
148
148
|
headers: getHeaders,
|
|
@@ -162,7 +162,7 @@ export function createAnthropic(
|
|
|
162
162
|
fetch: options.fetch,
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
const provider = function (modelId:
|
|
165
|
+
const provider = function (modelId: AnthropicModelId) {
|
|
166
166
|
if (new.target) {
|
|
167
167
|
throw new Error(
|
|
168
168
|
'The Anthropic model function cannot be called with the new keyword.',
|
|
@@ -11,7 +11,7 @@ export type AnthropicUsageIteration = {
|
|
|
11
11
|
output_tokens: number;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export type
|
|
14
|
+
export type AnthropicUsage = {
|
|
15
15
|
input_tokens: number;
|
|
16
16
|
output_tokens: number;
|
|
17
17
|
cache_creation_input_tokens?: number | null;
|
|
@@ -25,11 +25,11 @@ export type AnthropicMessagesUsage = {
|
|
|
25
25
|
iterations?: AnthropicUsageIteration[] | null;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
export function
|
|
28
|
+
export function convertAnthropicUsage({
|
|
29
29
|
usage,
|
|
30
30
|
rawUsage,
|
|
31
31
|
}: {
|
|
32
|
-
usage:
|
|
32
|
+
usage: AnthropicUsage;
|
|
33
33
|
rawUsage?: JSONObject;
|
|
34
34
|
}): LanguageModelV4Usage {
|
|
35
35
|
const cacheCreationTokens = usage.cache_creation_input_tokens ?? 0;
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
} from '@ai-sdk/provider-utils';
|
|
19
19
|
import {
|
|
20
20
|
AnthropicAssistantMessage,
|
|
21
|
-
|
|
21
|
+
AnthropicPrompt,
|
|
22
22
|
anthropicReasoningMetadataSchema,
|
|
23
23
|
AnthropicToolResultContent,
|
|
24
24
|
AnthropicUserMessage,
|
|
25
25
|
AnthropicWebFetchToolResultContent,
|
|
26
|
-
} from './anthropic-
|
|
27
|
-
import { anthropicFilePartProviderOptions } from './anthropic-
|
|
26
|
+
} from './anthropic-api';
|
|
27
|
+
import { anthropicFilePartProviderOptions } from './anthropic-options';
|
|
28
28
|
import { CacheControlValidator } from './get-cache-control';
|
|
29
29
|
import { codeExecution_20250522OutputSchema } from './tool/code-execution_20250522';
|
|
30
30
|
import { codeExecution_20250825OutputSchema } from './tool/code-execution_20250825';
|
|
@@ -70,7 +70,7 @@ function getUrlString(data: LanguageModelV4DataContent): string {
|
|
|
70
70
|
return data instanceof URL ? data.toString() : (data as string);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export async function
|
|
73
|
+
export async function convertToAnthropicPrompt({
|
|
74
74
|
prompt,
|
|
75
75
|
sendReasoning,
|
|
76
76
|
warnings,
|
|
@@ -83,15 +83,15 @@ export async function convertToAnthropicMessagesPrompt({
|
|
|
83
83
|
cacheControlValidator?: CacheControlValidator;
|
|
84
84
|
toolNameMapping: ToolNameMapping;
|
|
85
85
|
}): Promise<{
|
|
86
|
-
prompt:
|
|
86
|
+
prompt: AnthropicPrompt;
|
|
87
87
|
betas: Set<string>;
|
|
88
88
|
}> {
|
|
89
89
|
const betas = new Set<string>();
|
|
90
90
|
const blocks = groupIntoBlocks(prompt);
|
|
91
91
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
92
92
|
|
|
93
|
-
let system:
|
|
94
|
-
const messages:
|
|
93
|
+
let system: AnthropicPrompt['system'] = undefined;
|
|
94
|
+
const messages: AnthropicPrompt['messages'] = [];
|
|
95
95
|
|
|
96
96
|
async function shouldEnableCitations(
|
|
97
97
|
providerMetadata: SharedV4ProviderMetadata | undefined,
|
|
@@ -413,7 +413,8 @@ export async function convertToAnthropicMessagesPrompt({
|
|
|
413
413
|
contentValue = output.value;
|
|
414
414
|
break;
|
|
415
415
|
case 'execution-denied':
|
|
416
|
-
contentValue =
|
|
416
|
+
contentValue =
|
|
417
|
+
output.reason ?? 'Tool call execution denied.';
|
|
417
418
|
break;
|
|
418
419
|
case 'json':
|
|
419
420
|
case 'error-json':
|
package/src/get-cache-control.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SharedV4Warning, SharedV4ProviderMetadata } from '@ai-sdk/provider';
|
|
2
|
-
import { AnthropicCacheControl } from './anthropic-
|
|
2
|
+
import { AnthropicCacheControl } from './anthropic-api';
|
|
3
3
|
|
|
4
4
|
// Anthropic allows a maximum of 4 cache breakpoints per request
|
|
5
5
|
const MAX_CACHE_BREAKPOINTS = 4;
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type {
|
|
|
6
6
|
AnthropicLanguageModelOptions,
|
|
7
7
|
/** @deprecated Use `AnthropicLanguageModelOptions` instead. */
|
|
8
8
|
AnthropicLanguageModelOptions as AnthropicProviderOptions,
|
|
9
|
-
} from './anthropic-
|
|
9
|
+
} from './anthropic-options';
|
|
10
10
|
export type { AnthropicToolOptions } from './anthropic-prepare-tools';
|
|
11
11
|
export { anthropic, createAnthropic } from './anthropic-provider';
|
|
12
12
|
export type {
|
package/src/internal/index.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
2
|
+
AnthropicLanguageModel,
|
|
3
|
+
/** @deprecated Use `AnthropicLanguageModel` instead. */
|
|
4
|
+
AnthropicLanguageModel as AnthropicMessagesLanguageModel,
|
|
3
5
|
getModelCapabilities,
|
|
4
|
-
} from '../anthropic-
|
|
6
|
+
} from '../anthropic-language-model';
|
|
5
7
|
export { anthropicTools } from '../anthropic-tools';
|
|
6
|
-
export type {
|
|
8
|
+
export type {
|
|
9
|
+
AnthropicModelId,
|
|
10
|
+
/** @deprecated Use `AnthropicModelId` instead. */
|
|
11
|
+
AnthropicModelId as AnthropicMessagesModelId,
|
|
12
|
+
} from '../anthropic-options';
|
|
7
13
|
export { prepareTools } from '../anthropic-prepare-tools';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -14,7 +14,7 @@ const bash_20241022InputSchema = lazySchema(() =>
|
|
|
14
14
|
),
|
|
15
15
|
);
|
|
16
16
|
|
|
17
|
-
export const bash_20241022 =
|
|
17
|
+
export const bash_20241022 = createProviderDefinedToolFactory<
|
|
18
18
|
{
|
|
19
19
|
/**
|
|
20
20
|
* The bash command to run. Required unless the tool is being restarted.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderDefinedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -14,7 +14,7 @@ const bash_20250124InputSchema = lazySchema(() =>
|
|
|
14
14
|
),
|
|
15
15
|
);
|
|
16
16
|
|
|
17
|
-
export const bash_20250124 =
|
|
17
|
+
export const bash_20250124 = createProviderDefinedToolFactory<
|
|
18
18
|
{
|
|
19
19
|
/**
|
|
20
20
|
* The bash command to run. Required unless the tool is being restarted.
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createProviderDefinedToolFactory } from '@ai-sdk/provider-utils';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
@@ -25,7 +25,7 @@ const textEditor_20250728InputSchema = lazySchema(() =>
|
|
|
25
25
|
),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
|
-
const factory =
|
|
28
|
+
const factory = createProviderDefinedToolFactory<
|
|
29
29
|
{
|
|
30
30
|
/**
|
|
31
31
|
* 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.
|