|
| 1 | +import { notFound } from "next/navigation"; |
| 2 | +import Link from "next/link"; |
| 3 | +import type { Metadata } from "next"; |
| 4 | +import { getAgent, getAllSlugs } from "@/lib/data"; |
| 5 | +import { ScoreBadge } from "@/components/score-badge"; |
| 6 | +import { ScoreBar } from "@/components/score-bar"; |
| 7 | +import { RadarChart } from "@/components/radar-chart"; |
| 8 | +import { ToolCard } from "@/components/tool-card"; |
| 9 | + |
| 10 | +// Generate static pages for all evaluated agents |
| 11 | +export function generateStaticParams() { |
| 12 | + return getAllSlugs().map((slug) => ({ slug })); |
| 13 | +} |
| 14 | + |
| 15 | +// Dynamic metadata per agent |
| 16 | +export async function generateMetadata({ |
| 17 | + params, |
| 18 | +}: { |
| 19 | + params: Promise<{ slug: string }>; |
| 20 | +}): Promise<Metadata> { |
| 21 | + const { slug } = await params; |
| 22 | + const report = getAgent(slug); |
| 23 | + if (!report) return { title: "Agent Not Found" }; |
| 24 | + |
| 25 | + return { |
| 26 | + title: `${report.meta.agentName} — ${report.scores.overall}/100`, |
| 27 | + description: `Evaluation report for ${report.meta.agentName}: ${report.scores.overall}/100 overall score across ${report.tools.length} tools.`, |
| 28 | + }; |
| 29 | +} |
| 30 | + |
| 31 | +export default async function AgentPage({ |
| 32 | + params, |
| 33 | +}: { |
| 34 | + params: Promise<{ slug: string }>; |
| 35 | +}) { |
| 36 | + const { slug } = await params; |
| 37 | + const report = getAgent(slug); |
| 38 | + if (!report) notFound(); |
| 39 | + |
| 40 | + const { meta, scores, tools, execution } = report; |
| 41 | + |
| 42 | + return ( |
| 43 | + <div> |
| 44 | + {/* Back link */} |
| 45 | + <Link |
| 46 | + href="/" |
| 47 | + className="text-sm text-[var(--color-text-dim)] hover:text-white mb-6 inline-block" |
| 48 | + > |
| 49 | + ← Back to rankings |
| 50 | + </Link> |
| 51 | + |
| 52 | + {/* Header */} |
| 53 | + <div className="flex flex-col md:flex-row md:items-start gap-6 mb-8"> |
| 54 | + <div className="flex-1"> |
| 55 | + <h1 className="text-3xl font-bold mb-2">{meta.agentName}</h1> |
| 56 | + <div className="flex flex-wrap gap-3 text-sm text-[var(--color-text-dim)]"> |
| 57 | + <span className="px-2 py-0.5 rounded bg-[var(--color-surface)] border border-[var(--color-border)]"> |
| 58 | + {meta.protocol.toUpperCase()} |
| 59 | + </span> |
| 60 | + {meta.capabilities.map((cap) => ( |
| 61 | + <span |
| 62 | + key={cap} |
| 63 | + className="px-2 py-0.5 rounded bg-[var(--color-surface)] border border-[var(--color-border)]" |
| 64 | + > |
| 65 | + {cap} |
| 66 | + </span> |
| 67 | + ))} |
| 68 | + </div> |
| 69 | + <p className="mt-3 text-sm text-[var(--color-text-dim)] font-mono"> |
| 70 | + {meta.endpoint} |
| 71 | + </p> |
| 72 | + <p className="mt-1 text-xs text-[var(--color-text-dim)]"> |
| 73 | + Evaluated {new Date(meta.evaluatedAt).toLocaleDateString()} with |
| 74 | + agent-eval v{meta.evalFrameworkVersion} |
| 75 | + {meta.judgeModel && ` (judge: ${meta.judgeModel})`} |
| 76 | + </p> |
| 77 | + </div> |
| 78 | + <div className="text-center"> |
| 79 | + <ScoreBadge score={scores.overall} size="lg" /> |
| 80 | + <p className="text-xs text-[var(--color-text-dim)] mt-1"> |
| 81 | + Overall Score |
| 82 | + </p> |
| 83 | + </div> |
| 84 | + </div> |
| 85 | + |
| 86 | + {/* Scores section */} |
| 87 | + <div className="grid md:grid-cols-2 gap-8 mb-8"> |
| 88 | + {/* Radar chart */} |
| 89 | + <div className="flex justify-center items-center p-6 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)]"> |
| 90 | + <RadarChart |
| 91 | + scores={{ |
| 92 | + capability: scores.capability, |
| 93 | + reliability: scores.reliability, |
| 94 | + efficiency: scores.efficiency, |
| 95 | + safety: scores.safety, |
| 96 | + dx: scores.developerExperience, |
| 97 | + }} |
| 98 | + /> |
| 99 | + </div> |
| 100 | + |
| 101 | + {/* Score bars */} |
| 102 | + <div className="space-y-4 p-6 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)]"> |
| 103 | + <ScoreBar |
| 104 | + label="Capability" |
| 105 | + score={scores.capability} |
| 106 | + weight="30%" |
| 107 | + /> |
| 108 | + <ScoreBar |
| 109 | + label="Reliability" |
| 110 | + score={scores.reliability} |
| 111 | + weight="25%" |
| 112 | + /> |
| 113 | + <ScoreBar |
| 114 | + label="Efficiency" |
| 115 | + score={scores.efficiency} |
| 116 | + weight="20%" |
| 117 | + /> |
| 118 | + <ScoreBar label="Safety" score={scores.safety} weight="15%" /> |
| 119 | + <ScoreBar |
| 120 | + label="Dev Experience" |
| 121 | + score={scores.developerExperience} |
| 122 | + weight="10%" |
| 123 | + /> |
| 124 | + </div> |
| 125 | + </div> |
| 126 | + |
| 127 | + {/* Execution stats */} |
| 128 | + <div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8"> |
| 129 | + {[ |
| 130 | + { label: "Tools", value: tools.length }, |
| 131 | + { label: "Tasks", value: execution.totalTasks }, |
| 132 | + { label: "Success Rate", value: `${Math.round(execution.overallSuccessRate * 100)}%` }, |
| 133 | + { label: "Avg Latency", value: `${execution.latency.avgMs}ms` }, |
| 134 | + ].map((stat) => ( |
| 135 | + <div |
| 136 | + key={stat.label} |
| 137 | + className="p-4 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] text-center" |
| 138 | + > |
| 139 | + <div className="text-2xl font-bold">{stat.value}</div> |
| 140 | + <div className="text-xs text-[var(--color-text-dim)]"> |
| 141 | + {stat.label} |
| 142 | + </div> |
| 143 | + </div> |
| 144 | + ))} |
| 145 | + </div> |
| 146 | + |
| 147 | + {/* Tools */} |
| 148 | + <section className="mb-8"> |
| 149 | + <h2 className="text-xl font-semibold mb-4"> |
| 150 | + Tools ({tools.length}) |
| 151 | + </h2> |
| 152 | + <div className="grid md:grid-cols-2 gap-3"> |
| 153 | + {tools.map((tool) => ( |
| 154 | + <ToolCard key={tool.name} tool={tool} /> |
| 155 | + ))} |
| 156 | + </div> |
| 157 | + </section> |
| 158 | + |
| 159 | + {/* Task Scores */} |
| 160 | + {scores.taskScores.length > 0 && ( |
| 161 | + <section> |
| 162 | + <h2 className="text-xl font-semibold mb-4"> |
| 163 | + Task Scores ({scores.taskScores.length}) |
| 164 | + </h2> |
| 165 | + <div className="rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] overflow-x-auto"> |
| 166 | + <table className="w-full text-sm"> |
| 167 | + <thead> |
| 168 | + <tr className="border-b border-[var(--color-border)] text-[var(--color-text-dim)]"> |
| 169 | + <th className="py-3 px-4 text-left">Tool</th> |
| 170 | + <th className="py-3 px-4 text-left">Difficulty</th> |
| 171 | + <th className="py-3 px-4 text-left">Capability</th> |
| 172 | + <th className="py-3 px-4 text-left">Safety</th> |
| 173 | + <th className="py-3 px-4 text-left hidden md:table-cell"> |
| 174 | + Reasoning |
| 175 | + </th> |
| 176 | + </tr> |
| 177 | + </thead> |
| 178 | + <tbody> |
| 179 | + {scores.taskScores.map((ts, i) => ( |
| 180 | + <tr |
| 181 | + key={i} |
| 182 | + className="border-b border-[var(--color-border)]/50" |
| 183 | + > |
| 184 | + <td className="py-2 px-4 font-mono text-xs"> |
| 185 | + {ts.toolName} |
| 186 | + </td> |
| 187 | + <td className="py-2 px-4"> |
| 188 | + <span |
| 189 | + className={`text-xs px-1.5 py-0.5 rounded ${ |
| 190 | + ts.difficulty === "adversarial" |
| 191 | + ? "bg-red-500/20 text-red-400" |
| 192 | + : ts.difficulty === "advanced" |
| 193 | + ? "bg-amber-500/20 text-amber-400" |
| 194 | + : "bg-[var(--color-border)] text-[var(--color-text-dim)]" |
| 195 | + }`} |
| 196 | + > |
| 197 | + {ts.difficulty} |
| 198 | + </span> |
| 199 | + </td> |
| 200 | + <td className="py-2 px-4"> |
| 201 | + {(ts.capabilityScore * 100).toFixed(0)}% |
| 202 | + </td> |
| 203 | + <td className="py-2 px-4"> |
| 204 | + {(ts.safetyScore * 100).toFixed(0)}% |
| 205 | + </td> |
| 206 | + <td className="py-2 px-4 text-xs text-[var(--color-text-dim)] max-w-xs truncate hidden md:table-cell"> |
| 207 | + {ts.reasoning} |
| 208 | + </td> |
| 209 | + </tr> |
| 210 | + ))} |
| 211 | + </tbody> |
| 212 | + </table> |
| 213 | + </div> |
| 214 | + </section> |
| 215 | + )} |
| 216 | + </div> |
| 217 | + ); |
| 218 | +} |
0 commit comments