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 | import { defineTool } from 'eve/tools'; |
| 2 | import { z } from 'zod'; |
| 3 | import { DEFAULT_SEARCH_LIMIT, searchDocs } from '../lib/docs-search'; |
| 4 | |
| 5 | /** |
| 6 | * search_docs — find the most relevant Composio docs pages for a query. |
| 7 | * |
| 8 | * This is a local, in-memory lexical retriever. It uses a BM25-style body score |
| 9 | * plus field boosts for title, description, headings, and URL. The top results |
| 10 | * include full page content (bounded per page), so the model gets rich context |
| 11 | * in the same fast tool call instead of doing a serial search -> read round trip. |
| 12 | */ |
| 13 | |
| 14 | export default defineTool({ |
| 15 | description: |
| 16 | 'Search the Composio documentation and Knowledge Base troubleshooting guides (/kb/guide/...) with a fast BM25-style local retriever. Returns relevant pages and includes full bounded content for the top matches, so you can answer from the returned context. Call read_doc only if you need a page beyond the included content.', |
| 17 | inputSchema: z.object({ |
| 18 | query: z |
| 19 | .string() |
| 20 | .min(1) |
| 21 | .describe( |
| 22 | 'What to look for, e.g. "authentication", "create a session", "trigger webhook verification".' |
| 23 | ), |
| 24 | limit: z |
| 25 | .number() |
| 26 | .int() |
| 27 | .min(1) |
| 28 | .max(12) |
| 29 | .optional() |
| 30 | .describe('How many pages to return. Defaults to 5.'), |
| 31 | }), |
| 32 | async execute({ query, limit = DEFAULT_SEARCH_LIMIT }) { |
| 33 | return searchDocs(query, { limit, invocation: 'tool' }); |
| 34 | }, |
| 35 | }); |