Skip to content

Commit b5da06a

Browse files
authored
changed to LanguageModelV2ProviderDefinedClientTool (vercel#6741)
## background The `LanguageModelV2ProviderDefinedClientTool` type was renamed from `LanguageModelV2ProviderDefinedTool` so we can add a defined server tool later on ## summary - updated all export for `LanguageModelV2ProviderDefinedClientTool` type ## verification - updated imports resolved - type is properly exported from `@ai-sdk/provider`
1 parent 834ab13 commit b5da06a

28 files changed

+80
-65
lines changed

.changeset/cold-bags-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ai-sdk/provider': patch
3+
---
4+
5+
update to LanguageModelV2ProviderDefinedClientTool to add server side tool later on

content/docs/02-guides/05-computer-use.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ First, ensure you have the AI SDK and [Anthropic AI SDK provider](/providers/ai-
8383

8484
<Snippet text="pnpm add ai@alpha @ai-sdk/anthropic@alpha" />
8585

86-
You can add Computer Use to your AI SDK applications using provider-defined tools. These tools accept various input parameters (like display height and width in the case of the computer tool) and then require that you define an execute function.
86+
You can add Computer Use to your AI SDK applications using provider-defined-client tools. These tools accept various input parameters (like display height and width in the case of the computer tool) and then require that you define an execute function.
8787

8888
Here's how you could set up the Computer Tool with the AI SDK:
8989

content/docs/03-ai-sdk-core/60-telemetry.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ const result = await generateText({
9696
- `operation.name`: `ai.generateText.doGenerate` and the functionId that was set through `telemetry.functionId`
9797
- `ai.operationId`: `"ai.generateText.doGenerate"`
9898
- `ai.prompt.messages`: the messages that were passed into the provider
99-
- `ai.prompt.tools`: array of stringified tool definitions. The tools can be of type `function` or `provider-defined`.
99+
- `ai.prompt.tools`: array of stringified tool definitions. The tools can be of type `function` or `provider-defined-client`.
100100
Function tools have a `name`, `description` (optional), and `parameters` (JSON schema).
101-
Provider-defined tools have a `name`, `id`, and `args` (Record).
101+
Provider-defined-client tools have a `name`, `id`, and `args` (Record).
102102
- `ai.prompt.toolChoice`: the stringified tool choice setting (JSON). It has a `type` property
103103
(`auto`, `none`, `required`, `tool`), and if the type is `tool`, a `toolName` property with the specific tool.
104104
- `ai.response.text`: the text that was generated
@@ -129,9 +129,9 @@ const result = await generateText({
129129
- `operation.name`: `ai.streamText.doStream` and the functionId that was set through `telemetry.functionId`
130130
- `ai.operationId`: `"ai.streamText.doStream"`
131131
- `ai.prompt.messages`: the messages that were passed into the provider
132-
- `ai.prompt.tools`: array of stringified tool definitions. The tools can be of type `function` or `provider-defined`.
132+
- `ai.prompt.tools`: array of stringified tool definitions. The tools can be of type `function` or `provider-defined-client`.
133133
Function tools have a `name`, `description` (optional), and `parameters` (JSON schema).
134-
Provider-defined tools have a `name`, `id`, and `args` (Record).
134+
Provider-defined-client tools have a `name`, `id`, and `args` (Record).
135135
- `ai.prompt.toolChoice`: the stringified tool choice setting (JSON). It has a `type` property
136136
(`auto`, `none`, `required`, `tool`), and if the type is `tool`, a `toolName` property with the specific tool.
137137
- `ai.response.text`: the text that was generated

content/providers/03-community-providers/01-custom-providers.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ type LanguageModelV2FunctionTool = {
336336
};
337337
```
338338

339-
#### Provider-Defined Tools
339+
#### Provider-Defined Client Tools
340340

341341
Native provider capabilities exposed as tools:
342342

343343
```ts
344-
export type LanguageModelV2ProviderDefinedTool = {
345-
type: 'provider-defined';
344+
export type LanguageModelV2ProviderClientDefinedTool = {
345+
type: 'provider-defined-client';
346346
id: string; // e.g., 'anthropic.computer-use'
347347
name: string; // Human-readable name
348348
args: Record<string, unknown>;

packages/ai/core/generate-text/generate-text.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
LanguageModelV2CallOptions,
33
LanguageModelV2FunctionTool,
4-
LanguageModelV2ProviderDefinedTool,
4+
LanguageModelV2ProviderDefinedClientTool,
55
} from '@ai-sdk/provider';
66
import { jsonSchema } from '@ai-sdk/provider-utils';
77
import { mockId } from '@ai-sdk/provider-utils/test';
@@ -1361,7 +1361,10 @@ describe('options.abortSignal', () => {
13611361
describe('options.activeTools', () => {
13621362
it('should filter available tools to only the ones in activeTools', async () => {
13631363
let tools:
1364-
| (LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool)[]
1364+
| (
1365+
| LanguageModelV2FunctionTool
1366+
| LanguageModelV2ProviderDefinedClientTool
1367+
)[]
13651368
| undefined;
13661369

13671370
await generateText({

packages/ai/core/generate-text/stream-text.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
LanguageModelV2CallOptions,
44
LanguageModelV2CallWarning,
55
LanguageModelV2FunctionTool,
6-
LanguageModelV2ProviderDefinedTool,
6+
LanguageModelV2ProviderDefinedClientTool,
77
LanguageModelV2StreamPart,
88
SharedV2ProviderMetadata,
99
} from '@ai-sdk/provider';
@@ -6463,7 +6463,10 @@ describe('streamText', () => {
64636463
describe('options.activeTools', () => {
64646464
it('should filter available tools to only the ones in activeTools', async () => {
64656465
let tools:
6466-
| (LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool)[]
6466+
| (
6467+
| LanguageModelV2FunctionTool
6468+
| LanguageModelV2ProviderDefinedClientTool
6469+
)[]
64676470
| undefined;
64686471

64696472
const result = streamText({

packages/ai/core/prompt/prepare-tools-and-tool-choice.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const mockTools: ToolSet = {
1515
};
1616

1717
const mockProviderDefinedTool: Tool = {
18-
type: 'provider-defined',
18+
type: 'provider-defined-client',
1919
id: 'provider.tool-id',
2020
args: { key: 'value' },
2121
parameters: z.object({}),
@@ -97,15 +97,15 @@ it('should correctly map tool properties', () => {
9797
});
9898
});
9999

100-
it('should handle provider-defined tool type', () => {
100+
it('should handle provider-defined-client tool type', () => {
101101
const result = prepareToolsAndToolChoice({
102102
tools: mockToolsWithProviderDefined,
103103
toolChoice: undefined,
104104
activeTools: undefined,
105105
});
106106
expect(result.tools).toHaveLength(3);
107107
expect(result.tools?.[2]).toEqual({
108-
type: 'provider-defined',
108+
type: 'provider-defined-client',
109109
name: 'providerTool',
110110
id: 'provider.tool-id',
111111
args: { key: 'value' },

packages/ai/core/prompt/prepare-tools-and-tool-choice.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
LanguageModelV2FunctionTool,
3-
LanguageModelV2ProviderDefinedTool,
3+
LanguageModelV2ProviderDefinedClientTool,
44
LanguageModelV2ToolChoice,
55
} from '@ai-sdk/provider';
66
import { asSchema } from '@ai-sdk/provider-utils';
@@ -18,7 +18,9 @@ export function prepareToolsAndToolChoice<TOOLS extends ToolSet>({
1818
activeTools: Array<keyof TOOLS> | undefined;
1919
}): {
2020
tools:
21-
| Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool>
21+
| Array<
22+
LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedClientTool
23+
>
2224
| undefined;
2325
toolChoice: LanguageModelV2ToolChoice | undefined;
2426
} {
@@ -49,9 +51,9 @@ export function prepareToolsAndToolChoice<TOOLS extends ToolSet>({
4951
description: tool.description,
5052
parameters: asSchema(tool.parameters).jsonSchema,
5153
};
52-
case 'provider-defined':
54+
case 'provider-defined-client':
5355
return {
54-
type: 'provider-defined' as const,
56+
type: 'provider-defined-client' as const,
5557
name,
5658
id: tool.id,
5759
args: tool.args,

packages/ai/core/tool/tool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export type Tool<
4747
/**
4848
An optional description of what the tool does.
4949
Will be used by the language model to decide whether to use the tool.
50-
Not used for provider-defined tools.
50+
Not used for provider-defined-client tools.
5151
*/
5252
description?: string;
5353
} & NeverOptional<
@@ -119,9 +119,9 @@ Function tool.
119119
}
120120
| {
121121
/**
122-
Provider-defined tool.
122+
Provider-defined-client tool.
123123
*/
124-
type: 'provider-defined';
124+
type: 'provider-defined-client';
125125

126126
/**
127127
The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.

packages/amazon-bedrock/src/bedrock-prepare-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function prepareTools({
3030
const bedrockTools: BedrockTool[] = [];
3131

3232
for (const tool of tools) {
33-
if (tool.type === 'provider-defined') {
33+
if (tool.type === 'provider-defined-client') {
3434
toolWarnings.push({ type: 'unsupported-tool', tool });
3535
} else {
3636
bedrockTools.push({

packages/anthropic/src/anthropic-prepare-tools.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ it('should correctly prepare function tools', () => {
4242
expect(result.toolWarnings).toEqual([]);
4343
});
4444

45-
it('should correctly prepare provider-defined tools', () => {
45+
it('should correctly prepare provider-defined-client tools', () => {
4646
const result = prepareTools({
4747
tools: [
4848
{
49-
type: 'provider-defined',
49+
type: 'provider-defined-client',
5050
id: 'anthropic.computer_20241022',
5151
name: 'computer',
5252
args: { displayWidthPx: 800, displayHeightPx: 600, displayNumber: 1 },
5353
},
5454
{
55-
type: 'provider-defined',
55+
type: 'provider-defined-client',
5656
id: 'anthropic.text_editor_20241022',
5757
name: 'text_editor',
5858
args: {},
5959
},
6060
{
61-
type: 'provider-defined',
61+
type: 'provider-defined-client',
6262
id: 'anthropic.bash_20241022',
6363
name: 'bash',
6464
args: {},
@@ -90,7 +90,7 @@ it('should add warnings for unsupported tools', () => {
9090
const result = prepareTools({
9191
tools: [
9292
{
93-
type: 'provider-defined',
93+
type: 'provider-defined-client',
9494
id: 'unsupported.tool',
9595
name: 'unsupportedProviderTool',
9696
args: {},
@@ -103,7 +103,7 @@ it('should add warnings for unsupported tools', () => {
103103
{
104104
type: 'unsupported-tool',
105105
tool: {
106-
type: 'provider-defined',
106+
type: 'provider-defined-client',
107107
id: 'unsupported.tool',
108108
name: 'unsupportedProviderTool',
109109
args: {},

packages/anthropic/src/anthropic-prepare-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function prepareTools({
5555
input_schema: tool.parameters,
5656
});
5757
break;
58-
case 'provider-defined':
58+
case 'provider-defined-client':
5959
switch (tool.id) {
6060
case 'anthropic.computer_20250124':
6161
betas.add('computer-use-2025-01-24');

packages/anthropic/src/anthropic-tools.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ function bashTool_20241022<RESULT>(
3939
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
4040
} = {},
4141
): {
42-
type: 'provider-defined';
42+
type: 'provider-defined-client';
4343
id: 'anthropic.bash_20241022';
4444
args: {};
4545
parameters: typeof Bash20241022Parameters;
4646
execute: ExecuteFunction<z.infer<typeof Bash20241022Parameters>, RESULT>;
4747
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
4848
} {
4949
return {
50-
type: 'provider-defined',
50+
type: 'provider-defined-client',
5151
id: 'anthropic.bash_20241022',
5252
args: {},
5353
parameters: Bash20241022Parameters,
@@ -87,15 +87,15 @@ function bashTool_20250124<RESULT>(
8787
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
8888
} = {},
8989
): {
90-
type: 'provider-defined';
90+
type: 'provider-defined-client';
9191
id: 'anthropic.bash_20250124';
9292
args: {};
9393
parameters: typeof Bash20250124Parameters;
9494
execute: ExecuteFunction<z.infer<typeof Bash20250124Parameters>, RESULT>;
9595
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
9696
} {
9797
return {
98-
type: 'provider-defined',
98+
type: 'provider-defined-client',
9999
id: 'anthropic.bash_20250124',
100100
args: {},
101101
parameters: Bash20250124Parameters,
@@ -165,7 +165,7 @@ function textEditorTool_20241022<RESULT>(
165165
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
166166
} = {},
167167
): {
168-
type: 'provider-defined';
168+
type: 'provider-defined-client';
169169
id: 'anthropic.text_editor_20241022';
170170
args: {};
171171
parameters: typeof TextEditor20241022Parameters;
@@ -176,7 +176,7 @@ function textEditorTool_20241022<RESULT>(
176176
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
177177
} {
178178
return {
179-
type: 'provider-defined',
179+
type: 'provider-defined-client',
180180
id: 'anthropic.text_editor_20241022',
181181
args: {},
182182
parameters: TextEditor20241022Parameters,
@@ -246,7 +246,7 @@ function textEditorTool_20250124<RESULT>(
246246
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
247247
} = {},
248248
): {
249-
type: 'provider-defined';
249+
type: 'provider-defined-client';
250250
id: 'anthropic.text_editor_20250124';
251251
args: {};
252252
parameters: typeof TextEditor20250124Parameters;
@@ -257,7 +257,7 @@ function textEditorTool_20250124<RESULT>(
257257
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
258258
} {
259259
return {
260-
type: 'provider-defined',
260+
type: 'provider-defined-client',
261261
id: 'anthropic.text_editor_20250124',
262262
args: {},
263263
parameters: TextEditor20250124Parameters,
@@ -340,15 +340,15 @@ function computerTool_20241022<RESULT>(options: {
340340
>;
341341
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
342342
}): {
343-
type: 'provider-defined';
343+
type: 'provider-defined-client';
344344
id: 'anthropic.computer_20241022';
345345
args: {};
346346
parameters: typeof Computer20241022Parameters;
347347
execute: ExecuteFunction<z.infer<typeof Computer20241022Parameters>, RESULT>;
348348
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
349349
} {
350350
return {
351-
type: 'provider-defined',
351+
type: 'provider-defined-client',
352352
id: 'anthropic.computer_20241022',
353353
args: {
354354
displayWidthPx: options.displayWidthPx,
@@ -476,15 +476,15 @@ function computerTool_20250124<RESULT>(options: {
476476
>;
477477
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
478478
}): {
479-
type: 'provider-defined';
479+
type: 'provider-defined-client';
480480
id: 'anthropic.computer_20250124';
481481
args: {};
482482
parameters: typeof Computer20250124Parameters;
483483
execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;
484484
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
485485
} {
486486
return {
487-
type: 'provider-defined',
487+
type: 'provider-defined-client',
488488
id: 'anthropic.computer_20250124',
489489
args: {
490490
displayWidthPx: options.displayWidthPx,

packages/cohere/src/cohere-prepare-tools.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ it('should process function tools correctly', () => {
4040
});
4141
});
4242

43-
it('should add warnings for provider-defined tools', () => {
43+
it('should add warnings for provider-defined-client tools', () => {
4444
const result = prepareTools({
4545
tools: [
4646
{
47-
type: 'provider-defined' as const,
47+
type: 'provider-defined-client' as const,
4848
name: 'providerTool',
4949
id: 'provider.tool',
5050
args: {},
@@ -59,7 +59,7 @@ it('should add warnings for provider-defined tools', () => {
5959
{
6060
type: 'unsupported-tool',
6161
tool: {
62-
type: 'provider-defined' as const,
62+
type: 'provider-defined-client' as const,
6363
name: 'providerTool',
6464
id: 'provider.tool',
6565
args: {},

packages/cohere/src/cohere-prepare-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function prepareTools({
4444
}> = [];
4545

4646
for (const tool of tools) {
47-
if (tool.type === 'provider-defined') {
47+
if (tool.type === 'provider-defined-client') {
4848
toolWarnings.push({ type: 'unsupported-tool', tool });
4949
} else {
5050
cohereTools.push({

packages/google/src/google-prepare-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function prepareTools({
7777

7878
const functionDeclarations = [];
7979
for (const tool of tools) {
80-
if (tool.type === 'provider-defined') {
80+
if (tool.type === 'provider-defined-client') {
8181
toolWarnings.push({ type: 'unsupported-tool', tool });
8282
} else {
8383
functionDeclarations.push({

packages/groq/src/groq-prepare-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function prepareTools({
4848
}> = [];
4949

5050
for (const tool of tools) {
51-
if (tool.type === 'provider-defined') {
51+
if (tool.type === 'provider-defined-client') {
5252
toolWarnings.push({ type: 'unsupported-tool', tool });
5353
} else {
5454
groqTools.push({

0 commit comments

Comments
 (0)