'use client'; import { useState } from 'react'; import type { AgentFormData, AgentInfo } from '@/lib/types'; const MODELS = ['sonnet', 'opus', 'haiku']; const COLORS = ['blue', 'green', 'red', 'purple', 'orange', 'yellow', 'pink']; const COMMON_TOOLS = ['Read', 'Write', 'Edit', 'MultiEdit', 'Bash', 'Grep', 'Glob', 'WebFetch', 'WebSearch', 'TodoWrite']; interface AgentFormProps { initial?: AgentInfo; onSave: (data: AgentFormData, originalName?: string) => Promise; onCancel: () => void; } export function AgentForm({ initial, onSave, onCancel }: AgentFormProps) { const [form, setForm] = useState({ name: initial?.name ?? '', description: initial?.description ?? '', model: initial?.model ?? 'sonnet', tools: initial?.tools ?? 'Read, Write, Edit, Bash, Grep', color: initial?.color ?? 'blue', prompt: initial?.prompt ?? '', }); const [saving, setSaving] = useState(false); const set = (key: keyof AgentFormData, val: string) => setForm((f) => ({ ...f, [key]: val })); const toggleTool = (tool: string) => { const current = form.tools.split(',').map((t) => t.trim()).filter(Boolean); const next = current.includes(tool) ? current.filter((t) => t !== tool) : [...current, tool]; set('tools', next.join(', ')); }; const hasTools = (tool: string) => form.tools.split(',').map((t) => t.trim()).includes(tool); const handleSave = async () => { if (!form.name.trim() || !form.description.trim()) return; setSaving(true); try { await onSave(form, initial?.name); } finally { setSaving(false); } }; const inputStyle = { backgroundColor: 'rgba(0,0,0,0.4)', border: '1px solid var(--sf-border)', color: 'rgba(255,255,255,0.85)', outline: 'none', fontFamily: 'inherit', fontSize: '11px', padding: '4px 8px', width: '100%', } as const; const labelStyle = { fontSize: '9px', color: 'var(--sf-cyan)', opacity: 0.6, textTransform: 'uppercase' as const, letterSpacing: '0.1em', marginBottom: '3px', display: 'block', }; return (
{initial ? 'EDIT UNIT' : 'DEPLOY NEW UNIT'}
{/* Name */}
set('name', e.target.value.toLowerCase().replace(/\s+/g, '-'))} placeholder="my-specialist" disabled={!!initial} />
{/* Description */}