From c806eaf7f9cda8bea71553ed218286e02daf93eb Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 5 Feb 2026 16:29:56 +0800 Subject: [PATCH] feat(agent): enhance agent and skill management features - Updated the API to include disabled agent IDs for better management of user-specific agent visibility. - Introduced a new function to set the disabled state for shared agents, allowing users to manage their shared agent preferences. - Added a new Skills API to retrieve available skills, enhancing the overall agent capabilities. - Improved the AgentSelector and related components to filter out disabled agents, ensuring a cleaner user experience. - Updated localization strings to reflect new features and improve clarity in agent and skill management. This update enhances the user experience by providing better control over agent visibility and introducing new skill management functionalities. --- frontend/src/api/agent/index.ts | 3 +- frontend/src/api/organization/index.ts | 18 + frontend/src/components/AgentSelector.vue | 10 +- frontend/src/components/Input-field.vue | 19 +- frontend/src/components/ListSpaceSidebar.vue | 320 ++++++++++++ frontend/src/i18n/locales/en-US.ts | 18 + frontend/src/i18n/locales/zh-CN.ts | 18 + frontend/src/views/agent/AgentList.vue | 479 ++++++++++++------ .../src/views/knowledge/KnowledgeBase.vue | 353 ++++++------- .../src/views/knowledge/KnowledgeBaseList.vue | 251 +++++---- .../knowledge/components/FAQEntryManager.vue | 430 ++++++++-------- .../views/organization/OrganizationList.vue | 476 +++++++++-------- .../tenant_disabled_shared_agent.go | 47 ++ internal/application/service/agent_share.go | 48 +- internal/container/container.go | 1 + internal/handler/custom_agent.go | 25 +- internal/handler/organization.go | 67 ++- internal/router/router.go | 1 + internal/types/interfaces/organization.go | 13 + internal/types/organization.go | 15 + .../versioned/000012_organizations.down.sql | 5 + .../versioned/000012_organizations.up.sql | 15 +- 22 files changed, 1668 insertions(+), 964 deletions(-) create mode 100644 frontend/src/components/ListSpaceSidebar.vue create mode 100644 internal/application/repository/tenant_disabled_shared_agent.go diff --git a/frontend/src/api/agent/index.ts b/frontend/src/api/agent/index.ts index 66d428d3..9aba699f 100644 --- a/frontend/src/api/agent/index.ts +++ b/frontend/src/api/agent/index.ts @@ -113,8 +113,9 @@ export const BUILTIN_AGENT_NORMAL_ID = BUILTIN_QUICK_ANSWER_ID; export const BUILTIN_AGENT_AGENT_ID = BUILTIN_SMART_REASONING_ID; // 获取智能体列表(包括内置智能体) +// disabled_own_agent_ids: 当前租户在对话下拉中停用的「我的」智能体 ID,仅影响本租户 export function listAgents() { - return get<{ data: CustomAgent[] }>('/api/v1/agents'); + return get<{ data: CustomAgent[]; disabled_own_agent_ids?: string[] }>('/api/v1/agents'); } // 获取智能体详情 diff --git a/frontend/src/api/organization/index.ts b/frontend/src/api/organization/index.ts index e8523a36..41baf4e5 100644 --- a/frontend/src/api/organization/index.ts +++ b/frontend/src/api/organization/index.ts @@ -241,6 +241,8 @@ export interface SharedAgentInfo { shared_at: string shared_by_user_id?: string shared_by_username?: string + /** 当前用户是否已停用该共享智能体(仅影响本人对话下拉显示) */ + disabled_by_me?: boolean } export interface ListAgentSharesResponse { @@ -610,6 +612,22 @@ export async function listSharedAgents(): Promise } } +/** 设置当前用户对某共享智能体的停用状态(仅影响本人对话下拉显示) */ +export async function setSharedAgentDisabledByMe( + agentId: string, + disabled: boolean +): Promise> { + try { + const response = await post('/api/v1/shared-agents/disabled', { + agent_id: agentId, + disabled + }) + return response as unknown as ApiResponse + } catch (error: any) { + return { success: false, message: error.message || 'Failed to update preference' } + } +} + export async function listOrgAgentShares(orgId: string): Promise> { try { const response = await get(`/api/v1/organizations/${orgId}/agent-shares`) diff --git a/frontend/src/components/AgentSelector.vue b/frontend/src/components/AgentSelector.vue index 397e0007..4f0c3a99 100644 --- a/frontend/src/components/AgentSelector.vue +++ b/frontend/src/components/AgentSelector.vue @@ -301,12 +301,12 @@ const emit = defineEmits<{ const dropdownStyle = ref>({}); -// 使用父组件传入的 agents,避免与父组件重复请求 +// 父组件已按「当前租户停用」过滤,此处直接使用 const agentsList = computed(() => props.agents ?? []); // 内置智能体(从 API 获取,对特定 ID 使用本地化名称) const builtinAgents = computed(() => { - // 从 API 获取的内置智能体 + // 从 API 获取的内置智能体(内置无 disabled 概念,全部展示) const apiBuiltins = agentsList.value.filter(a => a.is_builtin); // 对特定内置智能体使用本地化名称和描述 @@ -334,8 +334,10 @@ const customAgents = computed(() => { return agentsList.value.filter(a => !a.is_builtin); }); -// 共享给我的智能体 -const sharedAgentsList = computed(() => orgStore.sharedAgents || []); +// 共享给我的智能体(仅展示当前用户未停用的) +const sharedAgentsList = computed(() => + (orgStore.sharedAgents || []).filter(shared => !shared.disabled_by_me) +); // 当前选中的来源租户(共享智能体时) const currentAgentSourceTenantId = computed(() => settingsStore.selectedAgentSourceTenantId ?? null); diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vue index 1817aca0..0ce304a4 100644 --- a/frontend/src/components/Input-field.vue +++ b/frontend/src/components/Input-field.vue @@ -32,8 +32,10 @@ const showAgentModeSelector = ref(false); const agentModeButtonRef = ref(); const agentModeDropdownStyle = ref>({}); -// 智能体相关状态 +// 智能体相关状态(完整列表供选中态解析;对话下拉用 enabledAgents) const agents = ref([]); +/** 当前租户在对话下拉中停用的「我的」智能体 ID(仅影响本租户) */ +const disabledOwnAgentIds = ref([]); const selectedAgentId = computed({ get: () => settingsStore.selectedAgentId || BUILTIN_QUICK_ANSWER_ID, set: (val: string) => settingsStore.selectAgent(val) @@ -478,11 +480,18 @@ const loadAgents = async () => { listAgents(), orgStore.fetchSharedAgents(), ]); - agents.value = agentsRes.data || []; + const res = agentsRes as { data?: CustomAgent[]; disabled_own_agent_ids?: string[] } + agents.value = res.data || [] + disabledOwnAgentIds.value = res.disabled_own_agent_ids || [] } catch (error) { - console.error('Failed to load agents:', error); + console.error('Failed to load agents:', error) } -}; +} + +// 对话下拉中展示的「我的」智能体(排除当前租户已停用的) +const enabledAgents = computed(() => + agents.value.filter(a => !disabledOwnAgentIds.value.includes(a.id)) +); const loadConversationConfig = async () => { try { @@ -1791,7 +1800,7 @@ onBeforeRouteUpdate((to, from, next) => { :visible="showAgentModeSelector" :anchorEl="agentModeButtonRef" :currentAgentId="selectedAgentId" - :agents="agents" + :agents="enabledAgents" @close="closeAgentModeSelector" @select="handleSelectAgent" /> diff --git a/frontend/src/components/ListSpaceSidebar.vue b/frontend/src/components/ListSpaceSidebar.vue new file mode 100644 index 00000000..72a50258 --- /dev/null +++ b/frontend/src/components/ListSpaceSidebar.vue @@ -0,0 +1,320 @@ + + + + + diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 43963dbc..470c3138 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -14,6 +14,12 @@ export default { confirmLogout: 'Are you sure you want to logout?', systemInfo: 'System Information' }, + listSpaceSidebar: { + title: 'Filter', + all: 'All', + mine: 'Mine', + spaces: 'Spaces' + }, knowledgeBase: { title: 'Knowledge Base', list: 'Knowledge Base List', @@ -224,7 +230,11 @@ export default { title: 'Agents', subtitle: 'Configure and manage your agents to customize conversation behavior and capabilities', createAgent: 'Create Agent', + createAgentShort: 'New', builtin: 'Built-in', + disabled: 'Disabled', + disable: 'Disable', + enable: 'Enable', noDescription: 'No description', selectAgent: 'Select Agent', noAgents: 'No agents', @@ -309,6 +319,8 @@ export default { builtinReadonly: 'Built-in agents cannot be edited', copied: 'Agent copied successfully', copyFailed: 'Copy failed', + disabled: 'Agent disabled', + enabled: 'Agent enabled', }, editor: { createTitle: 'Create Agent', @@ -329,6 +341,8 @@ export default { name: 'Name', namePlaceholder: 'Enter agent name', nameRequired: 'Agent name is required', + disabled: 'Disable', + disabledDesc: 'When disabled, this agent will not appear in the conversation agent dropdown', systemPromptRequired: 'System prompt is required', modelRequired: 'Please select a model', rerankModelRequired: 'ReRank model is required when using knowledge bases', @@ -1090,6 +1104,7 @@ export default { }, knowledgeList: { create: 'Create Knowledge Base', + createShort: 'New', createFAQ: 'Create FAQ Knowledge Base', subtitle: 'Manage and organize your knowledge bases, supporting document-based and FAQ-based knowledge bases', myKnowledgeBases: 'My Knowledge Bases', @@ -1253,6 +1268,7 @@ export default { searchTest: 'Search Test', addFaq: 'Add FAQ', manageFaq: 'FAQ Actions', + createGroup: 'New', searchTestTitle: 'FAQ Search Test', queryLabel: 'Query', queryPlaceholder: 'Enter a question to search', @@ -2377,7 +2393,9 @@ export default { title: 'Shared Spaces', subtitle: 'Create or join shared spaces to share knowledge bases and agents with your team', createOrg: 'Create Space', + createOrgShort: 'New', joinOrg: 'Join Space', + joinOrgShort: 'Join', name: 'Space Name', namePlaceholder: 'Enter space name', nameRequired: 'Please enter space name', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index bebc0f0f..c7cdcf7d 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -14,6 +14,12 @@ export default { confirmLogout: "确定要退出登录吗?", systemInfo: "系统信息", }, + listSpaceSidebar: { + title: "筛选", + all: "全部", + mine: "我的", + spaces: "空间", + }, knowledgeBase: { title: "知识库", list: "知识库列表", @@ -762,7 +768,11 @@ export default { title: "智能体", subtitle: "配置和管理您的智能体,自定义对话行为和能力", createAgent: "创建智能体", + createAgentShort: "新建", builtin: "内置", + disabled: "已停用", + disable: "停用", + enable: "启用", noDescription: "暂无描述", selectAgent: "选择智能体", noAgents: "暂无智能体", @@ -847,6 +857,8 @@ export default { builtinReadonly: "内置智能体不可编辑", copied: "智能体复制成功", copyFailed: "复制失败", + disabled: "已停用", + enabled: "已启用", }, editor: { createTitle: "创建智能体", @@ -867,6 +879,8 @@ export default { name: "名称", namePlaceholder: "请输入智能体名称", nameRequired: "请输入智能体名称", + disabled: "停用", + disabledDesc: "停用后该智能体将不会在对话窗口的智能体下拉列表中显示", systemPromptRequired: "请输入系统提示词", modelRequired: "请选择模型", rerankModelRequired: "使用知识库时请选择 ReRank 模型", @@ -1482,6 +1496,7 @@ export default { }, knowledgeList: { create: "新建知识库", + createShort: "新建", createFAQ: "新建 FAQ 知识库", subtitle: "管理和组织您的知识库,支持文档型和问答型知识库", myKnowledgeBases: "我的知识库", @@ -1653,6 +1668,7 @@ export default { searchTest: "检索测试", addFaq: "添加FAQ", manageFaq: "FAQ操作", + createGroup: "新建", searchTestTitle: "FAQ 检索测试", queryLabel: "查询内容", queryPlaceholder: "请输入要检索的问题", @@ -2382,7 +2398,9 @@ export default { title: "共享空间", subtitle: "创建或加入共享空间,与团队成员共享知识库与智能体", createOrg: "创建空间", + createOrgShort: "新建", joinOrg: "加入空间", + joinOrgShort: "加入", name: "空间名称", namePlaceholder: "请输入空间名称", nameRequired: "请输入空间名称", diff --git a/frontend/src/views/agent/AgentList.vue b/frontend/src/views/agent/AgentList.vue index 497c5793..a79aaf6e 100644 --- a/frontend/src/views/agent/AgentList.vue +++ b/frontend/src/views/agent/AgentList.vue @@ -1,54 +1,47 @@ + +
+ +
+ +
{{ agent.description || $t('agent.noDescription') }}
@@ -107,6 +125,8 @@
+ {{ $t('agent.disabled') }} + {{ $t('agent.disabled') }}
@@ -156,7 +176,7 @@
-
+
{{ agent.avatar }}
- + {{ agent.name }}
{{ $t('common.copy') }}
+