diff --git a/package.json b/package.json index 40bd255..f54dd6c 100644 --- a/package.json +++ b/package.json @@ -57,14 +57,12 @@ "zod": "catalog:prod" }, "devDependencies": { - "@ai-sdk/provider": "catalog:dev", - "@ai-sdk/provider-utils": "catalog:dev", "@fast-check/vitest": "catalog:dev", "@hono/mcp": "catalog:dev", "@types/node": "catalog:dev", "@typescript/native-preview": "catalog:dev", "@vitest/coverage-v8": "catalog:dev", - "ai": "catalog:peer", + "ai": "catalog:dev", "hono": "catalog:dev", "knip": "catalog:dev", "lefthook": "catalog:dev", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea530fe..c83501b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,14 +7,8 @@ settings: catalogs: dev: '@ai-sdk/openai': - specifier: ^2.0.80 - version: 2.0.80 - '@ai-sdk/provider': - specifier: ^2.0.0 - version: 2.0.0 - '@ai-sdk/provider-utils': - specifier: ^3.0.18 - version: 3.0.18 + specifier: ^3.0.2 + version: 3.0.2 '@clack/prompts': specifier: ^0.11.0 version: 0.11.0 @@ -33,6 +27,9 @@ catalogs: '@vitest/coverage-v8': specifier: ^4.0.15 version: 4.0.15 + ai: + specifier: ^6.0.7 + version: 6.0.7 hono: specifier: ^4.9.10 version: 4.10.7 @@ -87,8 +84,8 @@ catalogs: specifier: ^0.52.0 version: 0.52.0 ai: - specifier: ^5.0.108 - version: 5.0.108 + specifier: '>=5.0.108 <7.0.0' + version: 6.0.6 openai: specifier: ^6.2.0 version: 6.9.1 @@ -126,12 +123,6 @@ importers: specifier: catalog:prod version: 4.1.13 devDependencies: - '@ai-sdk/provider': - specifier: catalog:dev - version: 2.0.0 - '@ai-sdk/provider-utils': - specifier: catalog:dev - version: 3.0.18(zod@4.1.13) '@fast-check/vitest': specifier: catalog:dev version: 0.2.4(vitest@4.0.15(@opentelemetry/api@1.9.0)(@types/node@22.19.1)(jiti@2.6.1)(msw@2.12.3(@types/node@22.19.1)(typescript@5.9.3))(tsx@4.21.0)(yaml@2.8.2)) @@ -148,8 +139,8 @@ importers: specifier: catalog:dev version: 4.0.15(vitest@4.0.15(@opentelemetry/api@1.9.0)(@types/node@22.19.1)(jiti@2.6.1)(msw@2.12.3(@types/node@22.19.1)(typescript@5.9.3))(tsx@4.21.0)(yaml@2.8.2)) ai: - specifier: catalog:peer - version: 5.0.108(zod@4.1.13) + specifier: catalog:dev + version: 6.0.7(zod@4.1.13) hono: specifier: catalog:dev version: 4.10.7 @@ -200,7 +191,7 @@ importers: dependencies: '@ai-sdk/openai': specifier: catalog:dev - version: 2.0.80(zod@4.1.13) + version: 3.0.2(zod@4.1.13) '@anthropic-ai/claude-agent-sdk': specifier: catalog:examples version: 0.1.67(zod@4.1.13) @@ -221,7 +212,7 @@ importers: version: 0.0.3(@tanstack/ai@0.0.3(@alcyone-labs/zod-to-json-schema@4.0.10(zod@4.1.13))(zod@4.1.13))(zod@4.1.13) ai: specifier: catalog:peer - version: 5.0.108(zod@4.1.13) + version: 6.0.6(zod@4.1.13) openai: specifier: catalog:peer version: 6.9.1(zod@4.1.13) @@ -238,26 +229,32 @@ importers: packages: - '@ai-sdk/gateway@2.0.18': - resolution: {integrity: sha512-sDQcW+6ck2m0pTIHW6BPHD7S125WD3qNkx/B8sEzJp/hurocmJ5Cni0ybExg6sQMGo+fr/GWOwpHF1cmCdg5rQ==} + '@ai-sdk/gateway@3.0.5': + resolution: {integrity: sha512-AtxA1wcoKTHr9uFoC5KZEXqJP4SMW4j3VbcliUECUYssbWbePJ9+b3AaCny1lxf1xhDK9EIyAgBOKhXoQSr9nA==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + + '@ai-sdk/gateway@3.0.6': + resolution: {integrity: sha512-oEpwjM0PIaSUErtZI8Ag+gQ+ZelysRWA96N5ahvOc5e9d7QkKJWF0POWx0nI1qBxvmUSw7ca0sLTVw+J5yn7Tg==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/openai@2.0.80': - resolution: {integrity: sha512-tNHuraF11db+8xJEDBoU9E3vMcpnHFKRhnLQ3DQX2LnEzfPB9DksZ8rE+yVuDN1WRW9cm2OWAhgHFgVKs7ICuw==} + '@ai-sdk/openai@3.0.2': + resolution: {integrity: sha512-GONwavgSWtcWO+t9+GpGK8l7nIYh+zNtCL/NYDSeHxHiw6ksQS9XMRWrZyE5NpJ0EXNxSAWCHIDmb1WvTqhq9Q==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider-utils@3.0.18': - resolution: {integrity: sha512-ypv1xXMsgGcNKUP+hglKqtdDuMg68nWHucPPAhIENrbFAI+xCHiqPVN8Zllxyv1TNZwGWUghPxJXU+Mqps0YRQ==} + '@ai-sdk/provider-utils@4.0.2': + resolution: {integrity: sha512-KaykkuRBdF/ffpI5bwpL4aSCmO/99p8/ci+VeHwJO8tmvXtiVAb99QeyvvvXmL61e9Zrvv4GBGoajW19xdjkVQ==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 - '@ai-sdk/provider@2.0.0': - resolution: {integrity: sha512-6o7Y2SeO9vFKB8lArHXehNuusnpddKPk7xqL7T2/b+OvXMRIXUO1rR4wcv1hAFUAT9avGZshty3Wlua/XA7TvA==} + '@ai-sdk/provider@3.0.1': + resolution: {integrity: sha512-2lR4w7mr9XrydzxBSjir4N6YMGdXD+Np1Sh0RXABh7tWdNFFwIeRI1Q+SaYZMbfL8Pg8RRLcrxQm51yxTLhokg==} engines: {node: '>=18'} '@alcyone-labs/zod-to-json-schema@4.0.10': @@ -1272,6 +1269,9 @@ packages: '@standard-schema/spec@1.0.0': resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==} + '@standard-schema/spec@1.1.0': + resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} + '@tanstack/ai-openai@0.0.3': resolution: {integrity: sha512-JyV5KMvaUIkS/9mt8zdu+8Sl0+/btbwrsreuFXftbrL8H+ysvbmFW3KwD2eUdTBwNPv2szUn5su17X1yt1CphQ==} peerDependencies: @@ -1396,8 +1396,14 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - ai@5.0.108: - resolution: {integrity: sha512-Jex3Lb7V41NNpuqJHKgrwoU6BCLHdI1Pg4qb4GJH4jRIDRXUBySJErHjyN4oTCwbiYCeb/8II9EnqSRPq9EifA==} + ai@6.0.6: + resolution: {integrity: sha512-LM0eAMWVn3RTj+0X5O1m/8g+7QiTeWG5aN5FsDbdmCkAQHVg93XxLbljFOLzi0NMjuJgf7fKLKmWoPsrdMyqfw==} + engines: {node: '>=18'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + + ai@6.0.7: + resolution: {integrity: sha512-kLzSXHdW6cAcb2mFSIfkbfzxYqqjrUnyhrB1sg855qlC+6XkLI8hmwFE8f/4SnjmtcTDOnkIaVjWoO5i5Ir0bw==} engines: {node: '>=18'} peerDependencies: zod: ^3.25.76 || ^4.1.8 @@ -2578,27 +2584,34 @@ packages: snapshots: - '@ai-sdk/gateway@2.0.18(zod@4.1.13)': + '@ai-sdk/gateway@3.0.5(zod@4.1.13)': dependencies: - '@ai-sdk/provider': 2.0.0 - '@ai-sdk/provider-utils': 3.0.18(zod@4.1.13) + '@ai-sdk/provider': 3.0.1 + '@ai-sdk/provider-utils': 4.0.2(zod@4.1.13) '@vercel/oidc': 3.0.5 zod: 4.1.13 - '@ai-sdk/openai@2.0.80(zod@4.1.13)': + '@ai-sdk/gateway@3.0.6(zod@4.1.13)': dependencies: - '@ai-sdk/provider': 2.0.0 - '@ai-sdk/provider-utils': 3.0.18(zod@4.1.13) + '@ai-sdk/provider': 3.0.1 + '@ai-sdk/provider-utils': 4.0.2(zod@4.1.13) + '@vercel/oidc': 3.0.5 zod: 4.1.13 - '@ai-sdk/provider-utils@3.0.18(zod@4.1.13)': + '@ai-sdk/openai@3.0.2(zod@4.1.13)': dependencies: - '@ai-sdk/provider': 2.0.0 - '@standard-schema/spec': 1.0.0 + '@ai-sdk/provider': 3.0.1 + '@ai-sdk/provider-utils': 4.0.2(zod@4.1.13) + zod: 4.1.13 + + '@ai-sdk/provider-utils@4.0.2(zod@4.1.13)': + dependencies: + '@ai-sdk/provider': 3.0.1 + '@standard-schema/spec': 1.1.0 eventsource-parser: 3.0.6 zod: 4.1.13 - '@ai-sdk/provider@2.0.0': + '@ai-sdk/provider@3.0.1': dependencies: json-schema: 0.4.0 @@ -3250,6 +3263,8 @@ snapshots: '@standard-schema/spec@1.0.0': {} + '@standard-schema/spec@1.1.0': {} + '@tanstack/ai-openai@0.0.3(@tanstack/ai@0.0.3(@alcyone-labs/zod-to-json-schema@4.0.10(zod@4.1.13))(zod@4.1.13))(zod@4.1.13)': dependencies: '@tanstack/ai': 0.0.3(@alcyone-labs/zod-to-json-schema@4.0.10(zod@4.1.13))(zod@4.1.13) @@ -3384,11 +3399,19 @@ snapshots: acorn@8.15.0: {} - ai@5.0.108(zod@4.1.13): + ai@6.0.6(zod@4.1.13): + dependencies: + '@ai-sdk/gateway': 3.0.5(zod@4.1.13) + '@ai-sdk/provider': 3.0.1 + '@ai-sdk/provider-utils': 4.0.2(zod@4.1.13) + '@opentelemetry/api': 1.9.0 + zod: 4.1.13 + + ai@6.0.7(zod@4.1.13): dependencies: - '@ai-sdk/gateway': 2.0.18(zod@4.1.13) - '@ai-sdk/provider': 2.0.0 - '@ai-sdk/provider-utils': 3.0.18(zod@4.1.13) + '@ai-sdk/gateway': 3.0.6(zod@4.1.13) + '@ai-sdk/provider': 3.0.1 + '@ai-sdk/provider-utils': 4.0.2(zod@4.1.13) '@opentelemetry/api': 1.9.0 zod: 4.1.13 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 76d9e30..e3269a1 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -6,10 +6,9 @@ catalogMode: strict catalogs: dev: - '@ai-sdk/openai': ^2.0.80 - '@ai-sdk/provider': ^2.0.0 + '@ai-sdk/openai': ^3.0.2 + ai: ^6.0.7 '@fast-check/vitest': ^0.2.0 - '@ai-sdk/provider-utils': ^3.0.18 '@clack/prompts': ^0.11.0 '@hono/mcp': ^0.1.4 '@types/node': ^22.13.5 @@ -34,7 +33,7 @@ catalogs: '@tanstack/ai-openai': ^0.0.3 peer: '@anthropic-ai/sdk': ^0.52.0 - ai: ^5.0.108 + ai: '>=5.0.108 <7.0.0' openai: ^6.2.0 prod: '@modelcontextprotocol/sdk': ^1.24.3 @@ -47,9 +46,14 @@ enablePrePostScripts: true minimumReleaseAge: 1440 minimumReleaseAgeExclude: + - '@ai-sdk/gateway' + - '@ai-sdk/openai' + - '@ai-sdk/provider' + - '@ai-sdk/provider-utils' - '@anthropic-ai/claude-agent-sdk' - '@tanstack/ai' - '@tanstack/ai-openai' + - ai onlyBuiltDependencies: - esbuild diff --git a/src/tool.ts b/src/tool.ts index af0f612..f574562 100644 --- a/src/tool.ts +++ b/src/tool.ts @@ -1,9 +1,10 @@ -import type { JSONSchema7 as AISDKJSONSchema } from '@ai-sdk/provider'; +import type { JSONSchema7 as AISDKJSONSchema } from 'ai'; import type { Tool as AnthropicTool } from '@anthropic-ai/sdk/resources'; import * as orama from '@orama/orama'; import type { ChatCompletionFunctionTool } from 'openai/resources/chat/completions'; import type { FunctionTool as OpenAIResponsesFunctionTool } from 'openai/resources/responses/responses'; import type { OverrideProperties } from 'type-fest'; +import { peerDependencies } from '../package.json'; import { DEFAULT_HYBRID_ALPHA } from './consts'; import { RequestBuilder } from './requestBuilder'; import type { @@ -52,7 +53,9 @@ export class BaseTool { method: this.executeConfig.method, url: this.executeConfig.url, bodyType: this.executeConfig.bodyType, - params: this.executeConfig.params.map((param) => ({ ...param })), + params: this.executeConfig.params.map((param) => ({ + ...param, + })), } satisfies HttpExecuteConfig; case 'rpc': return { @@ -145,7 +148,9 @@ export class BaseTool { typeof inputParams !== 'object' ) { throw new StackOneError( - `Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(inputParams)}`, + `Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify( + inputParams, + )}`, ); } @@ -236,7 +241,7 @@ export class BaseTool { /** AI SDK is optional dependency, import only when needed */ const ai = await tryImport( 'ai', - 'npm install ai@4.x|5.x or pnpm add ai@4.x|5.x', + `npm install ai (requires ${peerDependencies.ai})`, ); const schemaObject = ai.jsonSchema(schema); @@ -257,7 +262,9 @@ export class BaseTool { try { return await this.execute(args as JsonObject); } catch (error) { - return `Error executing tool: ${error instanceof Error ? error.message : String(error)}`; + return `Error executing tool: ${ + error instanceof Error ? error.message : String(error) + }`; } } : undefined, @@ -582,7 +589,9 @@ function metaSearchTools( typeof inputParams !== 'object' ) { throw new StackOneError( - `Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(inputParams)}`, + `Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify( + inputParams, + )}`, ); } @@ -712,7 +721,9 @@ function metaExecuteTool(tools: Tools): BaseTool { typeof inputParams !== 'object' ) { throw new StackOneError( - `Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify(inputParams)}`, + `Invalid parameters type. Expected object or string, got ${typeof inputParams}. Parameters: ${JSON.stringify( + inputParams, + )}`, ); } diff --git a/src/types.ts b/src/types.ts index f531b1b..c8e10e3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,7 +2,7 @@ * Common type definitions for the StackOne SDK */ -import type { Tool } from '@ai-sdk/provider-utils'; +import type { Tool } from 'ai'; import type { ToolSet } from 'ai'; import type { JsonObject, JsonValue, ValueOf } from 'type-fest'; @@ -176,7 +176,7 @@ export interface ToolDefinition { /** * Extended AI SDK tool definition with StackOne-specific execution metadata. - * Extends the base Tool type from @ai-sdk/provider-utils. + * Extends the base Tool type from the 'ai' package. * * NOTE: We avoid defining our own types as much as possible and use existing * types from dependencies. This type only extends the AI SDK Tool type with diff --git a/src/utils/try-import.ts b/src/utils/try-import.ts index 0ba1540..db6eaaf 100644 --- a/src/utils/try-import.ts +++ b/src/utils/try-import.ts @@ -10,7 +10,7 @@ import { StackOneError } from './error-stackone'; * * @example * ```ts - * const ai = await tryImport('ai', 'npm install ai@4.x|5.x'); + * const ai = await tryImport('ai', 'npm install ai'); * const { jsonSchema } = ai; * ``` */ diff --git a/tsdown.config.ts b/tsdown.config.ts index 0edd12b..1ba916c 100644 --- a/tsdown.config.ts +++ b/tsdown.config.ts @@ -9,7 +9,7 @@ export default defineConfig({ treeshake: true, dts: { tsgo: true, - resolve: [/^@types\//, 'type-fest', 'ai', '@ai-sdk/provider-utils'], + resolve: [/^@types\//, 'type-fest', 'ai'], }, publint: true, unused: true,