import { useQuery } from "@tanstack/react-query"; import { Activity, FileCode2, Fingerprint, Gauge, History, KeyRound, Library, MessageSquare, PlayCircle, ReceiptText, Settings2, ShieldCheck, Sparkles, Wrench, } from "lucide-react"; import { usePluginSlots } from "@/plugins/slots"; import { agentsApi } from "@/api/agents"; import { useCompany } from "@/context/CompanyContext"; import { queryKeys } from "@/lib/queryKeys"; import { ContextualSidebarFrame } from "./ContextualSidebarFrame"; import { SidebarNavItem } from "./SidebarNavItem"; import { contextualSidebarStyles } from "./contextual-sidebar-styles"; import { AGENT_DETAIL_NAVIGATION, agentDetailHref, type AgentLocalDetailView, } from "@/pages/agent-detail-navigation"; const localIcons = { overview: Sparkles, instructions: Fingerprint, skills: Library, runtime: Settings2, secrets: KeyRound, tools: Wrench, channels: MessageSquare, permissions: ShieldCheck, "api-keys": KeyRound, revisions: History, advanced: FileCode2, activity: Activity, runs: PlayCircle, costs: ReceiptText, budgets: Gauge, } satisfies Record; export function AgentContextualSidebar({ agentRef, agentId, agentName, labels, }: { agentRef: string; agentId?: string; agentName?: string; labels?: Partial>; }) { const { selectedCompanyId } = useCompany(); const shouldResolveAgent = !agentId || !agentName; const { data: resolvedAgent } = useQuery({ queryKey: [...queryKeys.agents.detail(agentRef), selectedCompanyId ?? null, "contextual-sidebar"], queryFn: () => agentsApi.get(agentRef, selectedCompanyId ?? undefined), enabled: shouldResolveAgent && Boolean(agentRef && selectedCompanyId), }); const resolvedId = agentId ?? resolvedAgent?.id; const { slots: pluginTabs } = usePluginSlots({ slotTypes: ["detailTab"], entityType: "agent", companyId: resolvedAgent?.companyId ?? selectedCompanyId, enabled: Boolean(resolvedId) }); const resolvedName = agentName ?? resolvedAgent?.name ?? "Agent"; return ( ); }