diff --git a/bun.lock b/bun.lock index 25f32bf8..d47d1d96 100644 --- a/bun.lock +++ b/bun.lock @@ -23,7 +23,7 @@ "lint-staged": "^15.2.0", "mkdocs": "^0.0.1", "msw": "^2.10.4", - "openai": "^5.7.0", + "openai": "^6.2.0", "openapi-types": "^12.1.3", "publint": "^0.3.12", "tsdown": "^0.15.6", @@ -32,8 +32,8 @@ "zod": "^3.23.8", }, "peerDependencies": { - "ai": "^5.0.63", - "openai": "4.x|5.x", + "ai": "4.x|5.x", + "openai": "5.x|6.x", }, }, }, @@ -434,7 +434,7 @@ "onetime": ["onetime@6.0.0", "", { "dependencies": { "mimic-fn": "^4.0.0" } }, "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ=="], - "openai": ["openai@5.23.2", "", { "peerDependencies": { "ws": "^8.18.0", "zod": "^3.23.8" }, "optionalPeers": ["ws", "zod"], "bin": { "openai": "bin/cli" } }, "sha512-MQBzmTulj+MM5O8SKEk/gL8a7s5mktS9zUtAkU257WjvobGc9nKcBuVwjyEEcb9SI8a8Y2G/mzn3vm9n1Jlleg=="], + "openai": ["openai@6.2.0", "", { "peerDependencies": { "ws": "^8.18.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["ws", "zod"], "bin": { "openai": "bin/cli" } }, "sha512-qqjzHls7F5xkXNGy9P1Ei1rorI5LWupUUFWP66zPU8FlZbiITX8SFcHMKNZg/NATJ0LpIZcMUFxSwQmdeQPwSw=="], "openapi-types": ["openapi-types@12.1.3", "", {}, "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw=="], diff --git a/package.json b/package.json index bfa3add9..5fbe3695 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "lint-staged": "^15.2.0", "mkdocs": "^0.0.1", "msw": "^2.10.4", - "openai": "^5.7.0", + "openai": "^6.2.0", "openapi-types": "^12.1.3", "publint": "^0.3.12", "tsdown": "^0.15.6", @@ -65,7 +65,7 @@ }, "peerDependencies": { "ai": "4.x|5.x", - "openai": "4.x|5.x" + "openai": "5.x|6.x" }, "repository": { "type": "git", diff --git a/src/tests/json-schema.spec.ts b/src/tests/json-schema.spec.ts index 43221537..a17237ed 100644 --- a/src/tests/json-schema.spec.ts +++ b/src/tests/json-schema.spec.ts @@ -258,20 +258,20 @@ describe('Schema Validation', () => { expect(toolObj).toBeDefined(); expect(typeof toolObj.execute).toBe('function'); - // Check that parameters and jsonSchema are properly structured - expect(toolObj.parameters).toBeDefined(); - expect(toolObj.parameters.jsonSchema).toBeDefined(); - expect(toolObj.parameters.jsonSchema.type).toBe('object'); - expect(toolObj.parameters.jsonSchema.properties).toBeDefined(); + // Check that inputSchema and jsonSchema are properly structured + expect(toolObj.inputSchema).toBeDefined(); + expect(toolObj.inputSchema.jsonSchema).toBeDefined(); + expect(toolObj.inputSchema.jsonSchema.type).toBe('object'); + expect(toolObj.inputSchema.jsonSchema.properties).toBeDefined(); // Check array item properties specifically // Using simpleArray which is defined in createArrayTestTool - const simpleArray = toolObj.parameters.jsonSchema.properties.simpleArray; + const simpleArray = toolObj.inputSchema.jsonSchema.properties.simpleArray; expect(simpleArray).toBeDefined(); expect(simpleArray.type).toBe('array'); // Check that array with items is properly structured - const arrayWithItems = toolObj.parameters.jsonSchema.properties.arrayWithItems; + const arrayWithItems = toolObj.inputSchema.jsonSchema.properties.arrayWithItems; expect(arrayWithItems).toBeDefined(); expect(arrayWithItems.type).toBe('array'); expect(arrayWithItems.items).toBeDefined(); @@ -310,11 +310,11 @@ describe('Schema Validation', () => { const toolObj = aiSdkTool[tool.name]; expect(toolObj).toBeDefined(); - expect(toolObj.parameters).toBeDefined(); - expect(toolObj.parameters.jsonSchema).toBeDefined(); + expect(toolObj.inputSchema).toBeDefined(); + expect(toolObj.inputSchema.jsonSchema).toBeDefined(); // Specifically check the nested schema structure - const filterProp = toolObj.parameters.jsonSchema.properties.filter; + const filterProp = toolObj.inputSchema.jsonSchema.properties.filter; expect(filterProp).toBeDefined(); expect(filterProp.type).toBe('object'); expect(filterProp.properties).toBeDefined(); diff --git a/src/tests/tool.spec.ts b/src/tests/tool.spec.ts index 92d1a6c0..e80e4416 100644 --- a/src/tests/tool.spec.ts +++ b/src/tests/tool.spec.ts @@ -104,10 +104,10 @@ describe('StackOneTool', () => { expect(aiSdkTool.test_tool).toBeDefined(); expect(typeof aiSdkTool.test_tool.execute).toBe('function'); expect(aiSdkTool.test_tool.description).toBe('Test tool'); - expect(aiSdkTool.test_tool.parameters).toBeDefined(); + expect(aiSdkTool.test_tool.inputSchema).toBeDefined(); - // The actual schema is in parameters.jsonSchema - const schema = aiSdkTool.test_tool.parameters.jsonSchema; + // The actual schema is in inputSchema.jsonSchema + const schema = aiSdkTool.test_tool.inputSchema.jsonSchema; expect(schema).toBeDefined(); expect(schema.type).toBe('object'); expect(schema.properties.id).toBeDefined(); @@ -171,11 +171,11 @@ describe('StackOneTool', () => { expect(aiSdkTool).toBeDefined(); expect(aiSdkTool.complex_tool).toBeDefined(); - // Check that parameters are defined - expect(aiSdkTool.complex_tool.parameters).toBeDefined(); + // Check that inputSchema is defined + expect(aiSdkTool.complex_tool.inputSchema).toBeDefined(); - // The actual schema is in parameters.jsonSchema - const schema = aiSdkTool.complex_tool.parameters.jsonSchema; + // The actual schema is in inputSchema.jsonSchema + const schema = aiSdkTool.complex_tool.inputSchema.jsonSchema; expect(schema).toBeDefined(); expect(schema.type).toBe('object'); diff --git a/src/tool.ts b/src/tool.ts index bc480ca9..ec42403c 100644 --- a/src/tool.ts +++ b/src/tool.ts @@ -1,5 +1,5 @@ import * as orama from '@orama/orama'; -import { type ToolSet, jsonSchema } from 'ai'; +import { jsonSchema } from 'ai'; import type { ChatCompletionTool } from 'openai/resources/chat/completions'; import { RequestBuilder } from './modules/requestBuilder'; import type { @@ -185,7 +185,7 @@ export class BaseTool { options: { executable?: boolean; execution?: ToolExecution | false } = { executable: true, } - ): ToolSet { + ) { const schema = { type: 'object' as const, properties: this.parameters.properties || {}, @@ -193,8 +193,10 @@ export class BaseTool { additionalProperties: false, }; + const schemaObject = jsonSchema(schema); const toolDefinition: Record = { - parameters: jsonSchema(schema), + inputSchema: schemaObject, // v5 + parameters: schemaObject, // v4 (backward compatibility) description: this.description, }; @@ -348,8 +350,8 @@ export class Tools implements Iterable { options: { executable?: boolean; execution?: ToolExecution | false } = { executable: true, } - ): ToolSet { - const result: ToolSet = {}; + ) { + const result: Record = {}; for (const tool of this.tools) { Object.assign(result, tool.toAISDK(options)); } diff --git a/src/toolsets/tests/stackone.mcp-fetch.spec.ts b/src/toolsets/tests/stackone.mcp-fetch.spec.ts index 6037f275..33f49498 100644 --- a/src/toolsets/tests/stackone.mcp-fetch.spec.ts +++ b/src/toolsets/tests/stackone.mcp-fetch.spec.ts @@ -111,7 +111,7 @@ describe('ToolSet.fetchTools (MCP + RPC integration)', () => { const aiToolDefinition = aiTools.dummy_action; expect(aiToolDefinition).toBeDefined(); expect(aiToolDefinition.description).toBe('Dummy tool'); - expect(aiToolDefinition.parameters.jsonSchema.properties.foo.type).toBe('string'); + expect(aiToolDefinition.inputSchema.jsonSchema.properties.foo.type).toBe('string'); expect(aiToolDefinition.execution).toBeUndefined(); const executableTool = tool.toAISDK().dummy_action;