From 5f947b4d6472a990e02114678388e71eaa114dd8 Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Wed, 22 Jul 2026 14:23:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=9B=86=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20API=20=E7=BA=A7=E5=88=AB=E5=A4=8D=E5=88=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ExternalToolEditor.tsx | 31 ++++++++++--- .../components/CapabilitySettings.tsx | 3 -- .../capability/KnowledgeSettingsPanel.tsx | 7 +-- src/pages/AgentEditor/hooks/useAgentEditor.ts | 44 ------------------- src/pages/AgentEditor/index.tsx | 10 ----- 5 files changed, 26 insertions(+), 69 deletions(-) diff --git a/src/components/ExternalToolEditor.tsx b/src/components/ExternalToolEditor.tsx index b6069fc..3b6bec2 100644 --- a/src/components/ExternalToolEditor.tsx +++ b/src/components/ExternalToolEditor.tsx @@ -1,4 +1,4 @@ -import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; +import { CopyOutlined, MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import { App as AntApp, Button, Card, Form, Input, Modal, Select, Space } from 'antd'; import { AgentAPI, ExternalToolApi, ExternalToolPlugin, ExternalToolPluginPayload } from '../api'; @@ -107,7 +107,7 @@ export default function ExternalToolEditor({ open, agentId, plugin, onClose, onS })), }; - if (plugin && !plugin.id.startsWith('temp_')) { + if (plugin) { await AgentAPI.updatePlugin(agentId, plugin.id, payload); message.success('外部工具更新成功'); } else { @@ -215,11 +215,30 @@ export default function ExternalToolEditor({ open, agentId, plugin, onClose, onS title={`API ${index + 1}`} className="agent-editor-tool-card" extra={ - fields.length > 1 ? ( - - ) : null + {fields.length > 1 ? ( + + ) : null} + } >
diff --git a/src/pages/AgentEditor/components/CapabilitySettings.tsx b/src/pages/AgentEditor/components/CapabilitySettings.tsx index 7564f01..666379e 100644 --- a/src/pages/AgentEditor/components/CapabilitySettings.tsx +++ b/src/pages/AgentEditor/components/CapabilitySettings.tsx @@ -21,7 +21,6 @@ interface CapabilitySettingsProps { onEditSkill: (skillId: string) => void; onDeleteSkill: (skillId: string) => Promise; onCreateExternalTool: () => void; - onCopyExternalTool: (pluginId: string) => void; onEditExternalTool: (pluginId: string) => void; onDeleteExternalTool: (pluginId: string) => Promise; markDirty: () => void; @@ -43,7 +42,6 @@ export default function CapabilitySettings({ onEditSkill, onDeleteSkill, onCreateExternalTool, - onCopyExternalTool, onEditExternalTool, onDeleteExternalTool, markDirty, @@ -80,7 +78,6 @@ export default function CapabilitySettings({ onEditSkill={onEditSkill} onDeleteSkill={onDeleteSkill} onCreateExternalTool={onCreateExternalTool} - onCopyExternalTool={onCopyExternalTool} onEditExternalTool={onEditExternalTool} onDeleteExternalTool={onDeleteExternalTool} /> diff --git a/src/pages/AgentEditor/components/capability/KnowledgeSettingsPanel.tsx b/src/pages/AgentEditor/components/capability/KnowledgeSettingsPanel.tsx index 5356001..5675b16 100644 --- a/src/pages/AgentEditor/components/capability/KnowledgeSettingsPanel.tsx +++ b/src/pages/AgentEditor/components/capability/KnowledgeSettingsPanel.tsx @@ -1,4 +1,4 @@ -import { ApiOutlined, CopyOutlined, DatabaseOutlined, DeleteOutlined, EditOutlined, PlusOutlined, ToolOutlined } from '@ant-design/icons'; +import { ApiOutlined, DatabaseOutlined, DeleteOutlined, EditOutlined, PlusOutlined, ToolOutlined } from '@ant-design/icons'; import { Button, Card, Collapse, Input, List, Popconfirm, Space, Tag } from 'antd'; import { Agent } from '../../../../api'; import { STATUS_TAG } from '../../constants'; @@ -11,7 +11,6 @@ interface KnowledgeSettingsPanelProps { onEditSkill: (skillId: string) => void; onDeleteSkill: (skillId: string) => Promise; onCreateExternalTool: () => void; - onCopyExternalTool: (pluginId: string) => void; onEditExternalTool: (pluginId: string) => void; onDeleteExternalTool: (pluginId: string) => Promise; } @@ -24,7 +23,6 @@ export default function KnowledgeSettingsPanel({ onEditSkill, onDeleteSkill, onCreateExternalTool, - onCopyExternalTool, onEditExternalTool, onDeleteExternalTool, }: KnowledgeSettingsPanelProps) { @@ -195,9 +193,6 @@ export default function KnowledgeSettingsPanel({ } extra={ - diff --git a/src/pages/AgentEditor/hooks/useAgentEditor.ts b/src/pages/AgentEditor/hooks/useAgentEditor.ts index a3f5ebf..3d0c4a1 100644 --- a/src/pages/AgentEditor/hooks/useAgentEditor.ts +++ b/src/pages/AgentEditor/hooks/useAgentEditor.ts @@ -236,10 +236,6 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE const handleDeletePlugin = async (pluginId: string) => { if (!id) return; - if (pluginId.startsWith('temp_')) { - setAgent((prev) => prev ? { ...prev, plugins: (prev.plugins || []).filter((plugin) => plugin.id !== pluginId) } : prev); - return; - } try { await AgentAPI.deletePlugin(id, pluginId); setAgent((prev) => prev ? { ...prev, plugins: (prev.plugins || []).filter((plugin) => plugin.id !== pluginId) } : prev); @@ -249,44 +245,6 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE } }; - const handleCopyPlugin = (pluginId: string) => { - if (!id || !agent) return; - const plugin = agent.plugins?.find((p) => p.id === pluginId); - if (!plugin) return; - - const newPlugin = { - ...plugin, - id: `temp_${Date.now()}`, - name: `${plugin.name}-copy`, - apis: plugin.apis?.map((api) => ({ - ...api, - name: `${api.name}-copy`, - id: undefined, - })) || [], - isTemp: true, - }; - - setAgent((prev) => { - if (!prev) return prev; - return { - ...prev, - plugins: [...(prev.plugins || []), newPlugin], - }; - }); - - return newPlugin; - }; - - const cleanupTempPlugins = () => { - setAgent((prev) => { - if (!prev) return prev; - return { - ...prev, - plugins: (prev.plugins || []).filter((p) => !p.id.startsWith('temp_')), - }; - }); - }; - const beforeUploadKnowledge = async (file: any) => { if (!id) { message.warning('请先保存智能体基础信息后再上传'); @@ -394,8 +352,6 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE handleDeleteKnowledge, handleDeleteSkill, handleDeletePlugin, - handleCopyPlugin, - cleanupTempPlugins, liveAgent, currentName, markDirty, diff --git a/src/pages/AgentEditor/index.tsx b/src/pages/AgentEditor/index.tsx index 0c90c63..5dfaed5 100644 --- a/src/pages/AgentEditor/index.tsx +++ b/src/pages/AgentEditor/index.tsx @@ -57,8 +57,6 @@ export default function AgentEditor() { handleDeleteKnowledge, handleDeleteSkill, handleDeletePlugin, - handleCopyPlugin, - cleanupTempPlugins, liveAgent, currentName, markDirty, @@ -105,13 +103,6 @@ export default function AgentEditor() { setEditingPluginId(null); setExternalToolEditorOpen(true); }} - onCopyExternalTool={(pluginId) => { - const newPlugin = handleCopyPlugin(pluginId); - if (newPlugin) { - setEditingPluginId(newPlugin.id); - setExternalToolEditorOpen(true); - } - }} onEditExternalTool={(pluginId) => { setEditingPluginId(pluginId); setExternalToolEditorOpen(true); @@ -170,7 +161,6 @@ export default function AgentEditor() { onClose={() => { setExternalToolEditorOpen(false); setEditingPluginId(null); - cleanupTempPlugins(); }} onSaved={refresh} />