import { useQuery } from "@tanstack/react-query"; import { Link } from "@/lib/router"; import type { Agent, AgentRuntimeState } from "@paperclipai/shared"; import { agentsApi } from "../api/agents"; import { useCompany } from "../context/CompanyContext"; 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 adapterLabels: Record = { claude_local: "Claude (local)", codex_local: "Codex (local)", opencode_local: "OpenCode (local)", openclaw: "OpenClaw", cursor: "Cursor (local)", process: "Process", http: "HTTP", }; 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 (
{agent.role} {agent.title && ( {agent.title} )} {adapterLabels[agent.adapterType] ?? 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)}
); }