import * as React from "react"; import { Bot, CheckCircle2, AlertTriangle, XCircle } from "lucide-react"; import { toast } from "sonner"; import { cn } from "@/lib/utils"; import { Badge } from "@/components/ui/badge"; /** * AgentEvaluationToast — WealthX DS (L3 Molecule) * * Displays an agent's self-evaluation result after a task is assigned in the * AI pipeline stage flow. The agent reasons against the task description + * expectation and returns a confidence percentage plus a result: * - **Accepted** (≥70%) — agent has all inputs and will proceed autonomously * - **Partial** (40–69%) — agent will attempt but flagged uncertainty; may need * broker review when done * - **Declined** (<40%) — agent lacks required context; task stays with broker * * ### Usage — as a Sonner toast * ```tsx * import { showAgentEvaluationToast } from "@wealthx/shadcn/agent-evaluation-toast"; * * showAgentEvaluationToast({ * agentName: "Ledger Agent", * taskName: "Run serviceability check", * confidence: 84, * result: "accepted", * reasoning: "I have all required inputs to complete this task.", * }); * ``` * * ### Usage — as a standalone card (stories / inline display) * ```tsx * import { AgentEvaluationCard } from "@wealthx/shadcn/agent-evaluation-toast"; * * * ``` */ // --------------------------------------------------------------------------- // Types // --------------------------------------------------------------------------- export type AgentEvaluationResult = "accepted" | "partial" | "declined"; export interface AgentEvaluationData { agentName: string; taskName: string; /** Agent confidence — 0 to 100. */ confidence: number; result: AgentEvaluationResult; /** Brief agent reasoning shown below the headline. */ reasoning: string; } // --------------------------------------------------------------------------- // Helpers // --------------------------------------------------------------------------- const RESULT_CONFIG: Record< AgentEvaluationResult, { label: string; icon: React.ElementType; badgeClass: string; borderClass: string; } > = { accepted: { label: "Accepted", icon: CheckCircle2, badgeClass: "border-success/40 bg-success/10 text-success-text gap-1", borderClass: "border-success/30", }, partial: { label: "Partial match", icon: AlertTriangle, badgeClass: "border-warning/40 bg-warning/10 text-warning-text gap-1", borderClass: "border-warning/30", }, declined: { label: "Declined", icon: XCircle, badgeClass: "border-destructive/40 bg-destructive/10 text-destructive-text gap-1", borderClass: "border-destructive/30", }, }; // --------------------------------------------------------------------------- // AgentEvaluationCard (standalone / inline) // --------------------------------------------------------------------------- export interface AgentEvaluationCardProps extends AgentEvaluationData { className?: string; } export function AgentEvaluationCard({ agentName, taskName, confidence, result, reasoning, className, }: AgentEvaluationCardProps) { const cfg = RESULT_CONFIG[result]; const Icon = cfg.icon; return (
{/* Header row */}

{agentName}

evaluated “{taskName}”

{cfg.label}
{/* Confidence bar */}
{confidence}%
{/* Reasoning */}

“{reasoning}”

); } // --------------------------------------------------------------------------- // showAgentEvaluationToast (Sonner integration) // --------------------------------------------------------------------------- /** * Fire a Sonner toast showing the agent's evaluation result. * Requires `` to be mounted in the app. */ export function showAgentEvaluationToast(data: AgentEvaluationData): void { toast.custom( () => (
), { duration: 6000 }, ); }