/* ┌──────────────────────────────────────────────────────────────────────────────┐ │ @author: Davidson Gomes │ │ @file: shared-chat/AgentInfo.tsx │ │ Developed by: Davidson Gomes │ │ Creation date: May 13, 2025 │ │ Contact: contato@evolution-api.com │ ├──────────────────────────────────────────────────────────────────────────────┤ │ @copyright © Evolution API 2025. All rights reserved. │ │ Licensed under the Apache License, Version 2.0 │ │ │ │ You may not use this file except in compliance with the License. │ │ You may obtain a copy of the License at │ │ │ │ http://www.apache.org/licenses/LICENSE-2.0 │ │ │ │ Unless required by applicable law or agreed to in writing, software │ │ distributed under the License is distributed on an "AS IS" BASIS, │ │ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ├──────────────────────────────────────────────────────────────────────────────┤ │ @important │ │ For any future changes to the code in this file, it is recommended to │ │ include, together with the modification, the information of the developer │ │ who changed it and the date of modification. │ └──────────────────────────────────────────────────────────────────────────────┘ */ "use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent } from "@/components/ui/card"; import { ExternalLink, Code, ChevronDown, ChevronUp, User, Calendar, Tag, Info, ArrowRight, Workflow, Bot, GitBranch, RefreshCw, Key, Users, BookOpenCheck, } from "lucide-react"; import { Agent, AgentType } from "@/types/agent"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog"; import { cn } from "@/lib/utils"; interface AgentInfoProps { agent: Agent; isShared?: boolean; } export function AgentInfo({ agent, isShared = false }: AgentInfoProps) { const [isCardDialogOpen, setIsCardDialogOpen] = useState(false); const getAgentTypeInfo = () => { const types: Record< AgentType, { label: string; icon: React.ElementType; color: string } > = { llm: { label: "LLM Agent", icon: Code, color: "#00cc7d" }, a2a: { label: "A2A Agent", icon: ExternalLink, color: "#3b82f6" }, sequential: { label: "Sequential Agent", icon: ArrowRight, color: "#f59e0b", }, parallel: { label: "Parallel Agent", icon: GitBranch, color: "#8b5cf6" }, loop: { label: "Loop Agent", icon: RefreshCw, color: "#ec4899" }, workflow: { label: "Workflow Agent", icon: Workflow, color: "#14b8a6" }, task: { label: "Task Agent", icon: BookOpenCheck, color: "#00cc7d" }, }; return ( types[agent.type as AgentType] || { label: agent.type, icon: Bot, color: "#00cc7d", } ); }; const agentTypeInfo = getAgentTypeInfo(); const IconComponent = agentTypeInfo.icon; const getModelName = () => { if (agent.type === "llm" && agent.model) { return agent.model; } return "N/A"; }; const getCreatedAt = () => { if (!agent.created_at) return "Unknown"; return new Date(agent.created_at).toLocaleDateString(); }; const getTotalTools = () => { if (agent.type === "llm" && agent.config?.mcp_servers) { return agent.config.mcp_servers.reduce( (total, mcp) => total + (mcp.tools?.length || 0), 0 ); } return 0; }; const getSubAgents = () => { if (agent.config?.sub_agents) { return agent.config.sub_agents.length; } return 0; }; const showAgentCard = () => { if (agent.agent_card_url) { setIsCardDialogOpen(true); } }; return ( <>
{agentTypeInfo.label}
{agent.description}
)}
{getTotalTools()}
{isShared ? "Shared" : "Not Shared"}
This is a {isShared ? "shared" : "not shared"} API key. Be careful when sharing it with third parties.