import { useQuery } from "@tanstack/react-query"; import { Link } from "@/lib/router"; import { AGENT_ROLE_LABELS, type Agent, type AgentRuntimeState } from "@paperclipai/shared"; import { agentsApi } from "../api/agents"; import { useCompany } from "../context/CompanyContext"; import { getAdapterLabel } from "../adapters/adapter-display-registry"; import { queryKeys } from "../lib/queryKeys"; import { StatusBadge } from "./StatusBadge"; import { Identity } from "./Identity"; import { formatDate, agentUrl } from "../lib/utils"; import { Separator } from "@/components/ui/separator"; interface AgentPropertiesProps { agent: Agent; runtimeState?: AgentRuntimeState; } const roleLabels = AGENT_ROLE_LABELS as Record; function PropertyRow({ label, children }: { label: string; children: React.ReactNode }) { return (
{label}
{children}
); } export function AgentProperties({ agent, runtimeState }: AgentPropertiesProps) { const { selectedCompanyId } = useCompany(); const { data: agents } = useQuery({ queryKey: queryKeys.agents.list(selectedCompanyId!), queryFn: () => agentsApi.list(selectedCompanyId!), enabled: !!selectedCompanyId && !!agent.reportsTo, }); const reportsToAgent = agent.reportsTo ? agents?.find((a) => a.id === agent.reportsTo) : null; return (
{roleLabels[agent.role] ?? agent.role} {agent.title && ( {agent.title} )} {getAdapterLabel(agent.adapterType)}
{(runtimeState?.sessionDisplayId ?? runtimeState?.sessionId) && ( {String(runtimeState.sessionDisplayId ?? runtimeState.sessionId).slice(0, 12)}... )} {runtimeState?.lastError && ( {runtimeState.lastError} )} {agent.lastHeartbeatAt && ( {formatDate(agent.lastHeartbeatAt)} )} {agent.reportsTo && ( {reportsToAgent ? ( ) : ( {agent.reportsTo.slice(0, 8)} )} )} {formatDate(agent.createdAt)}
); }