"use client"; import { useTranslation } from "react-i18next"; import { IconAlertTriangle, IconInfoCircle } from "@tabler/icons-react"; import { Alert, AlertDescription, AlertTitle } from "@kandev/ui/alert"; import { Button } from "@kandev/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@kandev/ui/card"; import { Separator } from "@kandev/ui/separator"; import { Switch } from "@kandev/ui/switch"; import { AgentLogo } from "@/components/agent-logo"; import { DynamicAgentCandidateList } from "@/components/settings/dynamic-agent-candidate-list"; import { ProfileEnabledHelp } from "@/components/settings/profile-enabled-help"; import { ProfileNameField } from "@/components/settings/profile-form-fields"; import { useDynamicAgentProfileEditorState } from "@/components/settings/dynamic-agent-profile-editor-state"; import type { Agent, AgentProfile } from "@/lib/types/http"; type DynamicAgentProfileEditorProps = { agent: Agent; profile: AgentProfile; isCreating?: boolean; /** When supplied, render as a draft editor owned by the parent save flow. */ onDraftChange?: (patch: Pick) => void; }; function DynamicRoutingPolicyHelp() { const { t } = useTranslation(); return (

{t("agents:dynamicRoutingPolicyTitle")}

{t("agents:dynamicRoutingPolicySwitchable")}

{t("agents:dynamicRoutingPolicyExcluded")}

{t("agents:dynamicRoutingPolicyRecovery")}

{t("agents:dynamicPolicyWaitExplanation")}

); } function DynamicProfileEditorHeader({ agent, profile, name, enabled, onEnabledChange, }: { agent: Agent; profile: AgentProfile; name: string; enabled: boolean; onEnabledChange: (enabled: boolean) => void; }) { const { t } = useTranslation(); return ( <>

{profile.agentDisplayName} • {name}

{t("agents:dynamicProfileDescription")}

{t("agents:enabled")}

); } export function DynamicAgentProfileEditor({ agent, profile, isCreating = false, onDraftChange, }: DynamicAgentProfileEditorProps) { const { t } = useTranslation(); const state = useDynamicAgentProfileEditorState({ agent, profile, onDraftChange }); if (!state.routingEnabled) { return (

{t("agents:dynamicProfileDisabled")}

); } const editorContent = ( <> ); return (
{state.standalone && !isCreating && ( )} {state.hasExternalConflict ? ( {t("agents:profileExternalChangeTitle")} {t("agents:profileExternalChangeDescription")} ) : null} {state.standalone ? ( {t("agents:dynamicProfileSettings")} {editorContent} ) : (
{editorContent}
)}
); }