import { CircleCheck, CircleAlert, Loader2, Play, ChevronRight, } from "lucide-react"; import type { AdapterEnvironmentTestResult } from "@paperclipai/shared"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; export type TestState = "idle" | "running" | "pass" | "fail"; const copy = { idle: { title: "Test your agent", description: "Check that your runtime and model can respond.", action: "Run test", }, running: { title: "Testing connection", description: "Checking the runtime and waiting for a model response…", action: "Testing…", }, pass: { title: "Connection successful", description: "Your runtime checks passed. Review the details below.", action: "Test again", }, warn: { title: "Connection needs attention", description: "Review the test details before running your agent.", action: "Test again", }, fail: { title: "Couldn't connect", description: "Check your model and provider connection, then try again.", action: "Retry test", }, } as const; const prerequisiteCopy = { idle: { title: "Check prerequisites", description: "Check instance settings and public connection configuration.", action: "Check setup" }, running: { title: "Checking prerequisites", description: "Checking instance settings and public connection configuration…", action: "Checking…" }, pass: { title: "Setup checks passed", description: "Review the setup details before assigning work.", action: "Check again" }, warn: { title: "Pairing required", description: "Create this agent, then pair it and verify event delivery.", action: "Check again" }, fail: { title: "Prerequisite check failed", description: "Review the setup details and retry.", action: "Retry check" }, } as const; export function RuntimeTestCard({ state, result, error, onTest, disabled = false, variant = "connection", }: { state: TestState | "warn"; result: AdapterEnvironmentTestResult | null; error?: string | null; onTest: () => void; disabled?: boolean; variant?: "connection" | "prerequisites"; }) { const content = (variant === "prerequisites" ? prerequisiteCopy : copy)[state]; const Icon = state === "running" ? Loader2 : state === "pass" ? CircleCheck : state === "fail" || state === "warn" ? CircleAlert : Play; return (

{content.title}

{state === "fail" && error ? error : content.description}

{result && result.checks.length > 0 && (
)}
); }