Skip to content

Commit a86feff

Browse files
committed
fix(tool): use dynamic peerDependencies version in error message
- Import peerDependencies from package.json to dynamically show supported AI SDK version range in installation error messages - Update JSDoc comments to reference 'ai' package instead of @ai-sdk/provider-utils - Simplify try-import example to use generic install hint This ensures error messages stay in sync with peerDependencies when the supported version range changes.
1 parent b2110c4 commit a86feff

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/tool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as orama from '@orama/orama';
44
import type { ChatCompletionFunctionTool } from 'openai/resources/chat/completions';
55
import type { FunctionTool as OpenAIResponsesFunctionTool } from 'openai/resources/responses/responses';
66
import type { OverrideProperties } from 'type-fest';
7+
import { peerDependencies } from '../package.json';
78
import { DEFAULT_HYBRID_ALPHA } from './consts';
89
import { RequestBuilder } from './requestBuilder';
910
import type {
@@ -240,7 +241,7 @@ export class BaseTool {
240241
/** AI SDK is optional dependency, import only when needed */
241242
const ai = await tryImport<typeof import('ai')>(
242243
'ai',
243-
'npm install ai@4.x|5.x or pnpm add [email protected]|5.x',
244+
`npm install ai (requires ${peerDependencies.ai})`,
244245
);
245246
const schemaObject = ai.jsonSchema(schema);
246247

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export interface ToolDefinition {
176176

177177
/**
178178
* Extended AI SDK tool definition with StackOne-specific execution metadata.
179-
* Extends the base Tool type from @ai-sdk/provider-utils.
179+
* Extends the base Tool type from the 'ai' package.
180180
*
181181
* NOTE: We avoid defining our own types as much as possible and use existing
182182
* types from dependencies. This type only extends the AI SDK Tool type with

src/utils/try-import.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { StackOneError } from './error-stackone';
1010
*
1111
* @example
1212
* ```ts
13-
* const ai = await tryImport('ai', 'npm install ai@4.x|5.x');
13+
* const ai = await tryImport('ai', 'npm install ai');
1414
* const { jsonSchema } = ai;
1515
* ```
1616
*/

0 commit comments

Comments
 (0)