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, 03:37 UTC
| 1 | import { z } from 'zod'; |
| 2 | import type { ToolkitSummary } from '../types/toolkit'; |
| 3 | |
| 4 | export const instantToolkitSlugsSchema = z.object({ slugs: z.array(z.string()) }); |
| 5 | |
| 6 | export function filterToolkits(toolkits: ToolkitSummary[], search: string, instantOnly: boolean) { |
| 7 | const query = search.trim().toLowerCase(); |
| 8 | return toolkits.filter(toolkit => |
| 9 | (!instantOnly || toolkit.instant?.supported === true) && |
| 10 | (!query || toolkit.name.toLowerCase().includes(query) || toolkit.slug.toLowerCase().includes(query)) |
| 11 | ); |
| 12 | } |
| 13 | |
| 14 | export function withInstantEligibility(toolkits: ToolkitSummary[], slugs: string[]): ToolkitSummary[] { |
| 15 | const supported = new Set(slugs.map(slug => slug.toLowerCase())); |
| 16 | return toolkits.map(toolkit => ({ ...toolkit, instant: { supported: supported.has(toolkit.slug.toLowerCase()) } })); |
| 17 | } |