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 | 'use client'; |
| 2 | |
| 3 | import { Check, Copy } from 'lucide-react'; |
| 4 | import { useEffect, useRef, useState } from 'react'; |
| 5 | |
| 6 | import { promptFor, type AgentFirstPromptProps } from '@/lib/agent-prompts'; |
| 7 | |
| 8 | export function AgentFirstPrompt({ agent }: AgentFirstPromptProps) { |
| 9 | const [copied, setCopied] = useState(false); |
| 10 | const timerRef = useRef<ReturnType<typeof setTimeout>>(undefined); |
| 11 | const prompt = promptFor(agent); |
| 12 | |
| 13 | useEffect(() => () => clearTimeout(timerRef.current), []); |
| 14 | |
| 15 | const copyPrompt = async () => { |
| 16 | try { |
| 17 | await navigator.clipboard.writeText(prompt); |
| 18 | clearTimeout(timerRef.current); |
| 19 | setCopied(true); |
| 20 | timerRef.current = setTimeout(() => setCopied(false), 2000); |
| 21 | } catch { |
| 22 | setCopied(false); |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | return ( |
| 27 | <aside className="not-prose my-5 rounded-[12px] border border-fd-border bg-fd-card p-4"> |
| 28 | <div className="mb-2 flex items-center justify-between gap-4"> |
| 29 | <p className="text-[13px] font-medium text-fd-foreground">Try the skill</p> |
| 30 | <button |
| 31 | aria-label="Copy suggested first prompt" |
| 32 | className="inline-flex cursor-pointer items-center gap-1.5 rounded-md px-2 py-1 text-[12px] font-medium text-fd-foreground/65 transition-colors hover:bg-fd-accent hover:text-fd-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-fd-ring" |
| 33 | onClick={copyPrompt} |
| 34 | type="button" |
| 35 | > |
| 36 | {copied ? <Check aria-hidden="true" className="size-3.5" /> : <Copy aria-hidden="true" className="size-3.5" />} |
| 37 | <span aria-live="polite">{copied ? 'Copied' : 'Copy prompt'}</span> |
| 38 | </button> |
| 39 | </div> |
| 40 | <p className="whitespace-pre-line text-[13px] leading-[1.6] text-fd-foreground/70">{prompt}</p> |
| 41 | </aside> |
| 42 | ); |
| 43 | } |