Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

1.3 KB
Raw Blame
import { VercelProvider, type VercelToolCollection } from '@composio/vercel';
import type { Tool as ComposioTool, ExecuteToolFn } from '@composio/core';
import type { ToolExecutionOptions, ToolSet } from 'ai';

const composioTool = {
  slug: 'TEST_TOOL',
  name: 'Test Tool',
  description: 'A tool used by the AI SDK compatibility fixture',
  version: '20260625_00',
  availableVersions: ['20260625_00'],
  inputParameters: {
    type: 'object',
    properties: {
      query: {
        type: 'string',
        description: 'Query text',
      },
    },
    required: ['query'],
  },
  tags: [],
} satisfies ComposioTool;

const executeTool = (async () => ({
  data: { ok: true },
  error: null,
  successful: true,
})) satisfies ExecuteToolFn;

const provider = new VercelProvider();
const wrapped = provider.wrapTool(composioTool, executeTool);
const tools = provider.wrapTools([composioTool], executeTool);

// Assignability smoke check: the wrapped collection must satisfy both the
// provider's exported type and the installed AI SDK's ToolSet.
const _wrappedToolSet: VercelToolCollection = tools satisfies ToolSet;

if (wrapped.execute) {
  const options = {
    toolCallId: 'call_1',
    messages: [],
    context: {},
  } satisfies ToolExecutionOptions<unknown>;

  await wrapped.execute({ query: 'typed input' }, options);
}