"use client"; import { ExternalLink } from "lucide-react"; import Link from "next/link"; import { renderToolIcon } from "@/app/tools/config"; import type { ToolResponse } from "@/client/types.gen"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { Label } from "@/components/ui/label"; interface ToolSelectorProps { value: string[]; onChange: (uuids: string[]) => void; tools: ToolResponse[]; disabled?: boolean; label?: string; description?: string; showLabel?: boolean; } export function ToolSelector({ value, onChange, tools, disabled = false, label = "Tools", description = "Select tools that the agent can use during the conversation.", showLabel = true, }: ToolSelectorProps) { // Filter to only show active tools const activeTools = tools.filter((tool) => tool.status === "active"); const handleToggle = (toolUuid: string, checked: boolean) => { if (checked) { onChange([...value, toolUuid]); } else { onChange(value.filter((id) => id !== toolUuid)); } }; return (
{showLabel && ( <> {description && ( )} )} {activeTools.length === 0 ? (

No tools available.

) : (
{activeTools.map((tool) => { const isSelected = value.includes(tool.tool_uuid); return ( ); })}
Manage Tools
)} {value.length > 0 && (

{value.length} tool{value.length !== 1 ? "s" : ""} selected

)}
); }