You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

agent-tools.tsx 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { BlockButton } from '@/components/ui/button';
  2. import { cn } from '@/lib/utils';
  3. import { PencilLine, X } from 'lucide-react';
  4. import { PropsWithChildren } from 'react';
  5. import { ToolPopover } from './tool-popover';
  6. import { useDeleteAgentNodeTools } from './tool-popover/use-update-tools';
  7. import { useGetAgentToolNames } from './use-get-tools';
  8. export function ToolCard({
  9. children,
  10. className,
  11. ...props
  12. }: PropsWithChildren & React.HTMLAttributes<HTMLLIElement>) {
  13. return (
  14. <li
  15. {...props}
  16. className={cn(
  17. 'flex bg-background-card p-1 rounded-sm justify-between',
  18. className,
  19. )}
  20. >
  21. {children}
  22. </li>
  23. );
  24. }
  25. export function AgentTools() {
  26. const { toolNames } = useGetAgentToolNames();
  27. const { deleteNodeTool } = useDeleteAgentNodeTools();
  28. return (
  29. <section className="space-y-2.5">
  30. <span className="text-text-sub-title">Tools</span>
  31. <ul className="space-y-2">
  32. {toolNames.map((x) => (
  33. <ToolCard key={x}>
  34. {x}
  35. <div className="flex items-center gap-2 text-text-sub-title">
  36. <PencilLine className="size-4 cursor-pointer" />
  37. <X
  38. className="size-4 cursor-pointer"
  39. onClick={deleteNodeTool(x)}
  40. />
  41. </div>
  42. </ToolCard>
  43. ))}
  44. </ul>
  45. <ToolPopover>
  46. <BlockButton>Add Tool</BlockButton>
  47. </ToolPopover>
  48. </section>
  49. );
  50. }