import type { AgentInputDelivery } from "../api/client"; import type { AgentApprovalMode, AgentModelOption } from "../types"; import { AudioLines, CheckCircle2, ChevronDown, Shield, ShieldCheck, Sparkles, Zap } from "lucide-react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger } from "@/shared/ui/dropdown-menu"; import { Button } from "@/shared/ui/button"; import { cn } from "@/shared/ui/cn"; import type { AgentCommandPanelPresentation } from "./agent-command-panel"; const VOICE_WAVE_BARS = [ { height: 5, duration: 0.72, delay: 0.08 }, { height: 10, duration: 0.58, delay: 0 }, { height: 15, duration: 0.66, delay: 0.12 }, { height: 9, duration: 0.62, delay: 0.04 }, { height: 4, duration: 0.7, delay: 0.16 } ] as const; export function VoiceInputButton({ isListening, disabled, onClick }: { isListening: boolean; disabled: boolean; onClick: () => void; }) { const reduceMotion = useReducedMotion(); const label = isListening ? "停止语音输入" : "语音输入"; return ( {isListening ? ( ) : null} {isListening ? ( {VOICE_WAVE_BARS.map((bar) => ( ))} ) : ( )} ); } const AGENT_SELECT_ITEM_CLASS_NAME = "rounded-lg border border-transparent px-2.5 py-2 focus:border-[var(--action-border-hover)] focus:bg-[var(--action-selection-soft-hover)] data-[highlighted]:border-[var(--action-border-hover)] data-[highlighted]:bg-[var(--action-selection-soft-hover)] motion-reduce:transition-none"; function AgentToolbarCaret() { return ; } export function InputDeliverySelect({ presentation, label, value, onValueChange }: { presentation: AgentCommandPanelPresentation; label: string; value: AgentInputDelivery; onValueChange?: (delivery: AgentInputDelivery) => void; }) { return {value === "queue" ? "排队" : "引导"} { if (delivery === "steer" || delivery === "queue") onValueChange?.(delivery); }}> {([ ["steer", "引导当前任务"], ["queue", "排队处理"] ] as const).map(([delivery, text]) => ( {text} ))} ; } export function ApprovalModeSelect({ presentation, value, disabled, onValueChange }: { presentation: AgentCommandPanelPresentation; value: AgentApprovalMode; disabled: boolean; onValueChange?: (mode: AgentApprovalMode) => void; }) { const requestApproval = value === "request"; return ( {requestApproval ? ( ) : ( )} {requestApproval ? "请求批准" : "始终允许"} 权限批准模式 onValueChange?.("request")} > 请求批准 需要审批的请求逐次确认;只读白名单直接执行 {requestApproval ? ( ) : null} onValueChange?.("always")} > 始终允许 自动批准本轮工具权限请求,不改变业务权限或安全限制 {!requestApproval ? ( ) : null} ); } export function AgentModelSelect({ presentation, models, value, onValueChange }: { presentation: AgentCommandPanelPresentation; models: AgentModelOption[]; value: string; onValueChange?: (model: string) => void; }) { const selectedModel = models.find((model) => model.id === value); if (!models.length) { return ( 模型 ); } return ( {selectedModel?.label ?? "模型"} 模型选择 {models.map((model) => { const selected = model.id === selectedModel?.id; return ( onValueChange?.(model.id)} > {model.label} {model.description} {selected ? ( ) : null} ); })} ); } function ModelIcon({ model }: { model?: AgentModelOption }) { const Icon = model?.icon === "bolt" ? Zap : Sparkles; return ; }