Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 06:00 UTC
| 1 | import { VercelProvider, type VercelToolCollection } from '@composio/vercel'; |
| 2 | import type { Tool as ComposioTool, ExecuteToolFn } from '@composio/core'; |
| 3 | import type { ToolExecutionOptions, ToolSet } from 'ai'; |
| 4 | |
| 5 | const composioTool = { |
| 6 | slug: 'TEST_TOOL', |
| 7 | name: 'Test Tool', |
| 8 | description: 'A tool used by the AI SDK compatibility fixture', |
| 9 | version: '20260625_00', |
| 10 | availableVersions: ['20260625_00'], |
| 11 | inputParameters: { |
| 12 | type: 'object', |
| 13 | properties: { |
| 14 | query: { |
| 15 | type: 'string', |
| 16 | description: 'Query text', |
| 17 | }, |
| 18 | }, |
| 19 | required: ['query'], |
| 20 | }, |
| 21 | tags: [], |
| 22 | } satisfies ComposioTool; |
| 23 | |
| 24 | const executeTool = (async () => ({ |
| 25 | data: { ok: true }, |
| 26 | error: null, |
| 27 | successful: true, |
| 28 | })) satisfies ExecuteToolFn; |
| 29 | |
| 30 | const provider = new VercelProvider(); |
| 31 | const wrapped = provider.wrapTool(composioTool, executeTool); |
| 32 | const tools = provider.wrapTools([composioTool], executeTool); |
| 33 | |
| 34 | // Assignability smoke check: the wrapped collection must satisfy both the |
| 35 | // provider's exported type and the installed AI SDK's ToolSet. |
| 36 | const _wrappedToolSet: VercelToolCollection = tools satisfies ToolSet; |
| 37 | |
| 38 | if (wrapped.execute) { |
| 39 | const options = { |
| 40 | toolCallId: 'call_1', |
| 41 | messages: [], |
| 42 | context: {}, |
| 43 | } satisfies ToolExecutionOptions<unknown>; |
| 44 | |
| 45 | await wrapped.execute({ query: 'typed input' }, options); |
| 46 | } |