"use client"; import { IconPencil, IconPlus, IconTrash } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Label } from "@kandev/ui/label"; import { Separator } from "@kandev/ui/separator"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@kandev/ui/select"; import type { UtilityAgent, InferenceAgent } from "@/lib/api/domains/utility-api"; const USE_DEFAULT = "__USE_DEFAULT__"; export type ModelOption = { value: string; label: string; agentName: string; modelName: string }; // Default model selector section type DefaultModelSectionProps = { inferenceAgents: InferenceAgent[]; defaultAgentId: string; defaultModel: string; onDefaultChange: (agentId: string, model: string) => void; }; export function DefaultModelSection({ inferenceAgents, defaultAgentId, defaultModel, onDefaultChange, }: DefaultModelSectionProps) { const selectedAgent = inferenceAgents.find((a) => a.id === defaultAgentId); const modelOptions = selectedAgent?.models ?? []; return (

Default utility agent model

Select the default model used by all built-in utility actions.

); } // Builtin action row type BuiltinActionRowProps = { agent: UtilityAgent; allModels: ModelOption[]; defaultLabel: string; onModelChange: (agent: UtilityAgent, value: string) => void; onEdit: (agent: UtilityAgent) => void; }; export function BuiltinActionRow({ agent, allModels, defaultLabel, onModelChange, onEdit, }: BuiltinActionRowProps) { const currentValue = agent.agent_id && agent.model ? `${agent.agent_id}|${agent.model}` : USE_DEFAULT; return (
onEdit(agent)}>
{agent.name}

{agent.description}

); } // Custom agent row type CustomAgentRowProps = { agent: UtilityAgent; onEdit: (agent: UtilityAgent) => void; onDelete: (agent: UtilityAgent) => void; }; export function CustomAgentRow({ agent, onEdit, onDelete }: CustomAgentRowProps) { return (
{agent.name}

{agent.description}

{agent.model || "Not configured"}
); } // Per-action overrides section type PerActionOverridesSectionProps = { builtins: UtilityAgent[]; allModels: ModelOption[]; defaultModel: string; onModelChange: (agent: UtilityAgent, value: string) => void; onEdit: (agent: UtilityAgent) => void; }; export function PerActionOverridesSection({ builtins, allModels, defaultModel, onModelChange, onEdit, }: PerActionOverridesSectionProps) { if (builtins.length === 0) return null; const defaultLabel = defaultModel ? `Default (${defaultModel})` : "Default"; return (

Actions

{builtins.map((agent) => ( ))}
); } // Custom agents section type CustomAgentsSectionProps = { agents: UtilityAgent[]; onAdd: () => void; onEdit: (agent: UtilityAgent) => void; onDelete: (agent: UtilityAgent) => void; }; export function CustomAgentsSection({ agents, onAdd, onEdit, onDelete }: CustomAgentsSectionProps) { return (

Custom utility agents

Create your own utility agents with custom prompts.

{agents.length === 0 && (

No custom utility agents.

)} {agents.length > 0 && (
{agents.map((agent) => ( ))}
)}
); } // Export the USE_DEFAULT constant export { USE_DEFAULT };