import { escapeHtml, getActionButtonsHtml, getGitHubUrl, getInstallDropdownHtml, getLastUpdatedHtml, } from "../utils"; export interface RenderableAgent { title: string; description?: string; path: string; model?: string | string[]; tools?: string[]; hasHandoffs?: boolean; lastUpdated?: string | null; } export type AgentSortOption = "title" | "lastUpdated"; const resourceType = "agent"; export function sortAgents( items: T[], sort: AgentSortOption ): T[] { return [...items].sort((a, b) => { if (sort === "lastUpdated") { const dateA = a.lastUpdated ? new Date(a.lastUpdated).getTime() : 0; const dateB = b.lastUpdated ? new Date(b.lastUpdated).getTime() : 0; return dateB - dateA; } return a.title.localeCompare(b.title); }); } export function renderAgentsHtml( items: RenderableAgent[], options: { query?: string; highlightTitle?: (title: string, query: string) => string; } = {} ): string { const { query = "", highlightTitle } = options; if (items.length === 0) { return `

No agents found

Try a different search term or adjust filters

`; } return items .map((item) => { const titleHtml = query && highlightTitle ? highlightTitle(item.title, query) : escapeHtml(item.title); return `
${getInstallDropdownHtml(resourceType, item.path, true)} ${getActionButtonsHtml(item.path, true)} GitHub
`; }) .join(""); }