"use client"; import { useCallback, useState } from "react"; import { IconAlertTriangle, IconCheck, IconClipboard, IconChevronDown, IconLoader2, IconDownload, IconExternalLink, IconLock, } from "@tabler/icons-react"; import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@kandev/ui/collapsible"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import { AgentLogo } from "@/components/agent-logo"; import { ProfileFormFields, type ProfileFormData } from "@/components/settings/profile-form-fields"; import type { AvailableAgent, ToolStatus } from "@/lib/types/http"; export type AgentSetting = { profileId: string; formData: ProfileFormData; dirty: boolean; }; function CopyButton({ text }: { text: string }) { const [copied, setCopied] = useState(false); const handleCopy = useCallback(async () => { try { await navigator.clipboard.writeText(text); } catch { const ta = document.createElement("textarea"); ta.value = text; ta.style.position = "fixed"; ta.style.opacity = "0"; document.body.appendChild(ta); ta.select(); document.execCommand("copy"); document.body.removeChild(ta); } setCopied(true); setTimeout(() => setCopied(false), 2000); }, [text]); return ( ); } function StatusPill({ status, error }: { status: string; error?: string }) { switch (status) { case "auth_required": { const pill = ( No auth ); if (!error) return pill; return ( {pill} {error} ); } case "not_installed": return ( Not installed ); case "failed": { const pill = ( Error ); if (!error) return pill; return ( {pill} {error} ); } case "probing": return ( Probing ); case "not_configured": return Pending; default: return ( Installed ); } } function InstalledAgentRow({ agent, settings, isOpen, onToggle, onUpdateSetting, }: { agent: AvailableAgent; settings: AgentSetting | undefined; isOpen: boolean; onToggle: (open: boolean) => void; onUpdateSetting: (agentName: string, formPatch: Partial) => void; }) { const currentModel = settings?.formData.model || agent.model_config.default_model; const modelName = agent.model_config.available_models.find((m) => m.id === currentModel)?.name ?? currentModel; const status = agent.model_config.status ?? "ok"; const showModelPill = status === "ok" && !!modelName; return (
{settings && ( onUpdateSetting(agent.name, patch)} modelConfig={agent.model_config} permissionSettings={agent.permission_settings ?? {}} passthroughConfig={agent.passthrough_config ?? null} agentName={agent.name} /> )}
); } function NotInstalledItems({ agents, tools, showLabel, }: { agents: AvailableAgent[]; tools: ToolStatus[]; showLabel: boolean; }) { if (agents.length === 0 && tools.length === 0) return null; return ( <> {showLabel &&

Not yet installed

} {agents.map((agent) => (

{agent.display_name}

{agent.install_script && (
{agent.install_script}
)}
))} {tools.map((tool) => (

{tool.display_name}

{tool.description}

{tool.install_script && (
{tool.install_script}
)}
{tool.info_url && ( )}
))} ); } export function StepAgents({ availableAgents, tools, agentSettings, loading, onUpdateSetting, }: { availableAgents: AvailableAgent[]; tools: ToolStatus[]; agentSettings: Record; loading: boolean; onUpdateSetting: (agentName: string, formPatch: Partial) => void; }) { const [openAgent, setOpenAgent] = useState(null); if (loading) { return (
Discovering agents...
); } const installedAgents = availableAgents.filter((a) => a.available); const notInstalledAgents = availableAgents.filter((a) => !a.available && a.install_script); const notInstalledTools = tools.filter((t) => !t.available); return (
{installedAgents.map((agent) => ( setOpenAgent(isOpen ? agent.name : null)} onUpdateSetting={onUpdateSetting} /> ))} 0} />

Expand an agent to configure its model and permissions. Changes are saved when you proceed. You can also add custom TUI agents later in Settings > Agents.

Careful: The default Agent Profiles run with Auto Approve enabled (YOLO mode).

); }