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 type { Metadata } from 'next'; |
| 2 | import { headers } from 'next/headers'; |
| 3 | import Link from 'next/link'; |
| 4 | import { ArrowLeft } from 'lucide-react'; |
| 5 | import { KnowledgeSearchForm } from '@/components/kb/knowledge-search-form'; |
| 6 | import { KnowledgeSearchResults } from '@/components/kb/knowledge-search-results'; |
| 7 | import { searchPublicKnowledge } from '@/lib/knowledge/search-service'; |
| 8 | |
| 9 | export const metadata: Metadata = { |
| 10 | title: 'Search Composio knowledge', |
| 11 | description: 'Search all public Composio product knowledge.', |
| 12 | robots: { index: false, follow: true }, |
| 13 | alternates: { types: { 'text/markdown': '/kb/search.md' } }, |
| 14 | }; |
| 15 | |
| 16 | interface KnowledgeSearchPageProps { |
| 17 | searchParams: Promise<Record<string, string | string[] | undefined>>; |
| 18 | } |
| 19 | |
| 20 | function first(value: string | string[] | undefined): string { |
| 21 | return Array.isArray(value) ? value[0] ?? '' : value ?? ''; |
| 22 | } |
| 23 | |
| 24 | export default async function KnowledgeSearchPage({ searchParams }: KnowledgeSearchPageProps) { |
| 25 | const params = await searchParams; |
| 26 | const query = first(params.q).slice(0, 200); |
| 27 | const execution = await searchPublicKnowledge({ |
| 28 | query, |
| 29 | filter: 'all', |
| 30 | headers: await headers(), |
| 31 | }); |
| 32 | const initialResponse = 'results' in execution.response ? execution.response : null; |
| 33 | const failed = execution.status !== 200 || initialResponse === null; |
| 34 | |
| 35 | return ( |
| 36 | <main className="mx-auto w-full max-w-7xl px-4 py-10 sm:px-6 sm:py-14 lg:px-8"> |
| 37 | <Link |
| 38 | href="/kb" |
| 39 | className="mb-8 inline-flex items-center gap-2 text-sm text-fd-muted-foreground transition-colors hover:text-fd-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring" |
| 40 | > |
| 41 | <ArrowLeft className="size-4" aria-hidden="true" /> |
| 42 | Knowledge Base |
| 43 | </Link> |
| 44 | <div className="max-w-3xl"> |
| 45 | <h1 className="text-3xl font-semibold tracking-tight sm:text-4xl">Search Composio support knowledge</h1> |
| 46 | <p className="mt-3 text-fd-muted-foreground"> |
| 47 | Find public troubleshooting answers, setup guidance, exact errors, and toolkit-specific fixes. |
| 48 | </p> |
| 49 | <div className="sticky top-14 z-20 -mx-4 mt-7 border-y border-fd-border bg-fd-background/95 px-4 py-3 backdrop-blur sm:static sm:mx-0 sm:border-0 sm:bg-transparent sm:p-0 sm:backdrop-blur-none"> |
| 50 | <KnowledgeSearchForm defaultQuery={query} compact /> |
| 51 | </div> |
| 52 | </div> |
| 53 | <div className="mt-10"> |
| 54 | <KnowledgeSearchResults |
| 55 | query={query} |
| 56 | initialResponse={initialResponse} |
| 57 | failed={failed} |
| 58 | /> |
| 59 | </div> |
| 60 | </main> |
| 61 | ); |
| 62 | } |