import React, { useState } from 'react'; import { useTheme } from '../contexts/ThemeContext'; import { ArrowLeft, Save, RotateCcw, Power, Trash2, Copy, ChevronDown, ChevronRight, Bot, Target, Brain, Database, Box, Route, FileOutput, Sparkles, Lightbulb, MessageSquare, Play, Send, Plus, X, Check, AlertCircle, Wrench, Layers, Zap, Clock, } from 'lucide-react'; interface AgentDetailProps { agentId: string | null; onBack: () => void; } interface ExpandedSection { basic: boolean; responsibility: boolean; skills: boolean; datasource: boolean; function: boolean; thinking: boolean; output: boolean; } const AgentDetail: React.FC = ({ agentId, onBack }) => { const { theme } = useTheme(); const isDark = theme === 'dark'; // 主题颜色类 const cardBg = isDark ? 'bg-slate-800/30' : 'bg-white'; const cardBorder = isDark ? 'border-blue-800/30' : 'border-red-200'; const textPrimary = isDark ? 'text-white' : 'text-gray-900'; const textSecondary = isDark ? 'text-slate-400' : 'text-gray-600'; const textMuted = isDark ? 'text-slate-500' : 'text-gray-500'; const btnSecondary = isDark ? 'bg-slate-700/50 hover:bg-slate-600/50 border-blue-800/30 text-slate-300' : 'bg-gray-100 hover:bg-gray-200 border-gray-300 text-gray-700'; const btnPrimary = isDark ? 'bg-blue-600 hover:bg-blue-500' : 'bg-red-600 hover:bg-red-500'; const inputBg = isDark ? 'bg-slate-900/50' : 'bg-gray-50'; const inputBorder = isDark ? 'border-blue-800/30' : 'border-gray-300'; const [isEnabled, setIsEnabled] = useState(true); const [expandedSections, setExpandedSections] = useState({ basic: true, responsibility: true, skills: true, datasource: true, function: true, thinking: true, output: true, }); const [chatMessages, setChatMessages] = useState<{role: 'user' | 'agent'; content: string}[]>([ { role: 'agent', content: '核心受众应聚焦18-25岁基层青年群体,原因是该群体社交媒体活跃度高、注重性价比、偏好真实有态度的品牌叙事。' } ]); const [chatInput, setChatInput] = useState(''); const [aiSuggestion, setAiSuggestion] = useState(''); const [showGeneratedConfig, setShowGeneratedConfig] = useState(false); const toggleSection = (section: keyof ExpandedSection) => { setExpandedSections(prev => ({ ...prev, [section]: !prev[section] })); }; const skills = [ { name: '受众分层', type: '分析类', enabled: true, trigger: '自动', priority: 1 }, { name: '核心受众识别', type: '推断类', enabled: true, trigger: '自动', priority: 1 }, { name: '受众画像抽取', type: '抽取类', enabled: true, trigger: '条件触发', priority: 2 }, { name: '阻力因素提炼', type: '分析类', enabled: true, trigger: '手动', priority: 3 }, ]; const dataSources = [ { name: '宣传知识库', type: '知识库', status: 'connected', permission: '只读', trigger: '自动', access: '品牌案例、活动方法论、历史策略' }, { name: 'Y系统', type: '业务系统', status: 'connected', permission: '只读', trigger: '条件触发', access: '用户标签、传播数据' }, { name: 'A系统', type: '业务系统', status: 'disconnected', permission: '无', trigger: '不可用', access: '—' }, { name: '市场数据库', type: '外部数据源', status: 'connected', permission: '只读', trigger: '手动', access: '市场报告、用户研究摘要' }, ]; const functions = [ { name: '信息抽取器', type: '抽取', enabled: true, trigger: '自动', usage: '提取任务中的受众相关信息' }, { name: '标签聚类器', type: '分析', enabled: true, trigger: '条件触发', usage: '辅助进行受众分层' }, { name: '案例检索器', type: '检索', enabled: true, trigger: '手动', usage: '调用历史案例进行参照' }, { name: '结构化输出器', type: '格式化', enabled: true, trigger: '自动', usage: '输出标准JSON字段' }, ]; const thinkingSteps = [ { step: 1, name: '识别任务中的目标对象', desc: '提取任务中明确或隐含的目标受众信息', required: true, skill: '受众分层', func: '信息抽取器', ds: '无' }, { step: 2, name: '判断是否需要分层', desc: '根据任务目标判断是否区分核心/次级/影响者受众', required: true, skill: '核心受众识别', func: '标签聚类器', ds: 'Y系统' }, { step: 3, name: '提取核心受众特征', desc: '分析年龄、身份、关切与行为特征', required: true, skill: '画像抽取', func: '结构化输出器', ds: '宣传知识库' }, { step: 4, name: '输出结构化结果', desc: '形成标准受众分析输出', required: true, skill: '—', func: '结构化输出器', ds: '—' }, ]; const outputFields = [ { name: 'core_audience', type: '文本', required: true }, { name: 'secondary_audience', type: '文本', required: false }, { name: 'key_traits', type: '数组', required: true }, { name: 'concerns', type: '数组', required: false }, { name: 'barriers', type: '数组', required: false }, { name: 'trust_sources', type: '数组', required: false }, ]; const aiOptimizations = [ { issue: '当前已配置"受众画像抽取"技能,但未配置对应输出字段', canFix: true }, { issue: '思考路径中"判断是否需要分层"步骤未绑定功能调用', canFix: true }, { issue: '已绑定A系统,但当前无任何步骤使用该数据源', canFix: false }, ]; const executionDetails = { dataSources: ['宣传知识库', 'Y系统'], skills: ['受众分层', '核心受众识别', '画像抽取'], functions: ['信息抽取器', '标签聚类器', '结构化输出器'], outputs: ['core_audience', 'key_traits', 'barriers'], }; const handleSendMessage = () => { if (chatInput.trim()) { setChatMessages([...chatMessages, { role: 'user', content: chatInput }]); setChatInput(''); setTimeout(() => { setChatMessages(prev => [...prev, { role: 'agent', content: '核心受众应聚焦18-25岁基层青年群体,原因是该群体社交媒体活跃度高、注重性价比、偏好真实有态度的品牌叙事。' }]); }, 1000); } }; const handleGenerateConfig = () => { setAiSuggestion('正在分析职责、技能、数据源...'); setTimeout(() => { setShowGeneratedConfig(true); setAiSuggestion(''); }, 1500); }; const SectionHeader = ({ title, subtitle, icon: Icon, section, children }: { title: string; subtitle: string; icon: React.ElementType; section: keyof ExpandedSection; children: React.ReactNode; }) => (
{expandedSections[section] && (
{children}
)}
); return (
{/* 顶部操作栏 */}

智能体能力配置

AudienceAgent {isEnabled ? '启用' : '停用'}
{/* 主内容区:三栏布局 */}
{/* 左侧主配置区 (65%) - 带自定义滚动条 */}
{/* 模块1:基本信息 */}