'use client'; import { useState } from 'react'; import { AgentSystemPrompts, PromptKind, updateAgentPrompt } from '@/lib/agent-dashboard'; interface AgentSystemPromptsCardProps { agentId: string; systemPrompts?: AgentSystemPrompts; canEdit?: boolean; onUpdated?: () => void; } const PROMPT_KINDS: { id: PromptKind; label: string; icon: string; description: string }[] = [ { id: 'core', label: 'Core', icon: '🧬', description: 'Основна особистість і стиль агента' }, { id: 'safety', label: 'Safety', icon: '🛡️', description: 'Обмеження безпеки та заборонені дії' }, { id: 'governance', label: 'Governance', icon: '⚖️', description: 'Правила взаємодії з DAO та іншими агентами' }, { id: 'tools', label: 'Tools', icon: '🔧', description: 'Налаштування використання інструментів' } ]; export function AgentSystemPromptsCard({ agentId, systemPrompts, canEdit = false, onUpdated }: AgentSystemPromptsCardProps) { const [activeTab, setActiveTab] = useState('core'); const [editedContent, setEditedContent] = useState>({ core: systemPrompts?.core?.content || '', safety: systemPrompts?.safety?.content || '', governance: systemPrompts?.governance?.content || '', tools: systemPrompts?.tools?.content || '' }); const [saving, setSaving] = useState(false); const [saveStatus, setSaveStatus] = useState<'idle' | 'success' | 'error'>('idle'); const [error, setError] = useState(null); const currentPrompt = systemPrompts?.[activeTab]; const currentContent = editedContent[activeTab]; const hasChanges = currentContent !== (currentPrompt?.content || ''); const handleSave = async () => { if (!hasChanges || saving) return; setSaving(true); setSaveStatus('idle'); setError(null); try { await updateAgentPrompt(agentId, activeTab, currentContent); setSaveStatus('success'); onUpdated?.(); // Reset success status after 3 seconds setTimeout(() => setSaveStatus('idle'), 3000); } catch (err) { setSaveStatus('error'); setError(err instanceof Error ? err.message : 'Failed to save'); } finally { setSaving(false); } }; return (

📝 System Prompts

Системні промти визначають базову поведінку агента у DAARION City

{/* Tabs */}
{PROMPT_KINDS.map(kind => { const prompt = systemPrompts?.[kind.id]; const isActive = activeTab === kind.id; const hasContent = !!prompt?.content; return ( ); })}
{/* Active Tab Description */}

{PROMPT_KINDS.find(k => k.id === activeTab)?.description}

{/* Content */}
{/* Version info */} {currentPrompt && (
v{currentPrompt.version} {new Date(currentPrompt.updated_at).toLocaleString()} {currentPrompt.updated_by && ( <> by {currentPrompt.updated_by} )}
)} {/* Textarea */}