Skip to content

Commit f5adb12

Browse files
committed
feat(deps): support AI SDK v5 and v6 via unified imports
Remove direct dependencies on @ai-sdk/provider and @ai-sdk/provider-utils internal packages. Import JSONSchema7 and Tool types directly from the main 'ai' package instead. This change: - Removes @ai-sdk/provider and @ai-sdk/provider-utils from devDependencies - Updates peerDependencies to accept ai >=5.0.0 <7.0.0 - Simplifies the dependency tree for consumers Both AI SDK v5 and v6 export the required types from the main package, making the internal package dependencies unnecessary.
1 parent a633b26 commit f5adb12

File tree

6 files changed

+20
-26
lines changed

6 files changed

+20
-26
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
"zod": "catalog:prod"
5858
},
5959
"devDependencies": {
60-
"@ai-sdk/provider": "catalog:dev",
61-
"@ai-sdk/provider-utils": "catalog:dev",
6260
"@fast-check/vitest": "catalog:dev",
6361
"@hono/mcp": "catalog:dev",
6462
"@types/node": "catalog:dev",

pnpm-lock.yaml

Lines changed: 1 addition & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ catalogMode: strict
77
catalogs:
88
dev:
99
'@ai-sdk/openai': ^3.0.2
10-
'@ai-sdk/provider': ^3.0.1
1110
'@fast-check/vitest': ^0.2.0
12-
'@ai-sdk/provider-utils': ^4.0.2
1311
'@clack/prompts': ^0.11.0
1412
'@hono/mcp': ^0.1.4
1513
'@types/node': ^22.13.5
@@ -34,7 +32,7 @@ catalogs:
3432
'@tanstack/ai-openai': ^0.0.3
3533
peer:
3634
'@anthropic-ai/sdk': ^0.52.0
37-
ai: ^6.0.6
35+
ai: '>=5.0.0 <7.0.0'
3836
openai: ^6.2.0
3937
prod:
4038
'@modelcontextprotocol/sdk': ^1.24.3

src/tool.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { JSONSchema7 as AISDKJSONSchema } from '@ai-sdk/provider';
1+
import type { JSONSchema7 as AISDKJSONSchema } from 'ai';
22
import type { Tool as AnthropicTool } from '@anthropic-ai/sdk/resources';
33
import * as orama from '@orama/orama';
44
import type { ChatCompletionFunctionTool } from 'openai/resources/chat/completions';
@@ -52,7 +52,9 @@ export class BaseTool {
5252
method: this.executeConfig.method,
5353
url: this.executeConfig.url,
5454
bodyType: this.executeConfig.bodyType,
55-
params: this.executeConfig.params.map((param) => ({ ...param })),
55+
params: this.executeConfig.params.map((param) => ({
56+
...param,
57+
})),
5658
} satisfies HttpExecuteConfig;
5759
case 'rpc':
5860
return {
@@ -145,7 +147,9 @@ export class BaseTool {
145147
typeof inputParams !== 'object'
146148
) {
147149
throw new StackOneError(
148-
`Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(inputParams)}`,
150+
`Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(
151+
inputParams,
152+
)}`,
149153
);
150154
}
151155

@@ -257,7 +261,9 @@ export class BaseTool {
257261
try {
258262
return await this.execute(args as JsonObject);
259263
} catch (error) {
260-
return `Error executing tool: ${error instanceof Error ? error.message : String(error)}`;
264+
return `Error executing tool: ${
265+
error instanceof Error ? error.message : String(error)
266+
}`;
261267
}
262268
}
263269
: undefined,
@@ -582,7 +588,9 @@ function metaSearchTools(
582588
typeof inputParams !== 'object'
583589
) {
584590
throw new StackOneError(
585-
`Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(inputParams)}`,
591+
`Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(
592+
inputParams,
593+
)}`,
586594
);
587595
}
588596

@@ -712,7 +720,9 @@ function metaExecuteTool(tools: Tools): BaseTool {
712720
typeof inputParams !== 'object'
713721
) {
714722
throw new StackOneError(
715-
`Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(inputParams)}`,
723+
`Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(
724+
inputParams,
725+
)}`,
716726
);
717727
}
718728

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Common type definitions for the StackOne SDK
33
*/
44

5-
import type { Tool } from '@ai-sdk/provider-utils';
5+
import type { Tool } from 'ai';
66
import type { ToolSet } from 'ai';
77
import type { JsonObject, JsonValue, ValueOf } from 'type-fest';
88

tsdown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default defineConfig({
99
treeshake: true,
1010
dts: {
1111
tsgo: true,
12-
resolve: [/^@types\//, 'type-fest', 'ai', '@ai-sdk/provider-utils'],
12+
resolve: [/^@types\//, 'type-fest', 'ai'],
1313
},
1414
publint: true,
1515
unused: true,

0 commit comments

Comments
 (0)