peppa/apps/web/components/AgentBadge.tsx
Асель 03cc2191fd PEP-96: agents get nicknames and are always shown as «ИИ-агент»
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:03:45 +05:00

23 lines
1.3 KiB
TypeScript

import { Bot } from "lucide-react";
import { cn } from "@/lib/utils";
const TONES = ["bg-sky-500/20 text-sky-300", "bg-emerald-500/20 text-emerald-300", "bg-amber-500/20 text-amber-300", "bg-fuchsia-500/20 text-fuchsia-300", "bg-rose-500/20 text-rose-300", "bg-violet-500/20 text-violet-300", "bg-teal-500/20 text-teal-300", "bg-orange-500/20 text-orange-300"];
/**
* PEP-75/96: an AI agent — a robot in its own colour and «агент <кличка>», so a product manager
* never takes it for a person.
*/
export function AgentBadge({ name, className, large = false }: { name: string; className?: string; large?: boolean }) {
const tone = TONES[[...name].reduce((a, c) => a + c.codePointAt(0)!, 0) % TONES.length];
return (
<span className={cn("inline-flex min-w-0 items-center gap-1.5", large ? "text-base font-medium" : "text-xs", className)} title={`ИИ-агент ${name}`}>
<span aria-hidden className={cn("grid shrink-0 place-items-center rounded-full font-semibold", large ? "size-8 text-sm" : "size-4.5 text-[10px]", tone)}>
<Bot className={large ? "size-4.5" : "size-3"} />
</span>
<span className="truncate">
<span className="text-muted-foreground">{large ? "ИИ-агент" : "агент"}</span> {name}
</span>
</span>
);
}