diff --git a/apps/agent/DESIGN.md b/apps/agent/DESIGN.md index 8eb504c4..9cf72120 100644 --- a/apps/agent/DESIGN.md +++ b/apps/agent/DESIGN.md @@ -251,6 +251,7 @@ SSE 事件:`token`(正文,可落库)/ `tool`(`{phase,name,label}` 状 - 聊天:`/agent/chat`,菜单「智能助手」(仅 `agent:chat`) - 模型管理:`/agent/llm-settings`,一级菜单「模型管理」(仅 `agent:llm-settings`) +- 我的记忆:`/agent/memories`,头像下拉入口(有 `agent:chat` 时显示;静态路由) - 聊天顶栏:`Select` 切换当前会话模型(PATCH `llmModel`);新对话草稿本地暂存,创建时带上 - 布局:**左会话列表 + 右消息区 + 底输入**;全页 `flex` + `min-h-0` 滚动(遵守现有 Spin/滚动规范) @@ -261,7 +262,9 @@ views/agent/chat/ index.vue # 聊天:会话列表 + 消息 + 顶栏选模型 catalog-cite*.vue/ts # 店铺/商品引用输入 views/agent/llm-settings/ - index.vue # 模型管理:凭证 / 启用列表 / 记忆 + index.vue # 模型管理:凭证 / 启用列表 +views/agent/memories/ + index.vue # 我的记忆:列表 / 删除(用户中心入口) api/agent/ # 调 Agent + Server 公司 LLM API ``` diff --git a/apps/web/apps/web-antd/src/layouts/basic.vue b/apps/web/apps/web-antd/src/layouts/basic.vue index 00fa6d50..2150dafc 100644 --- a/apps/web/apps/web-antd/src/layouts/basic.vue +++ b/apps/web/apps/web-antd/src/layouts/basic.vue @@ -18,10 +18,12 @@ import { useAccessStore, useUserStore } from '@vben/stores'; import SwitchAccountModal from '#/components/SwitchAccountModal.vue'; import SwitchCompanyModal from '#/components/SwitchCompanyModal.vue'; +import { usePermission } from '#/composables/use-permission'; import { useAuthStore, useRealtimeStore } from '#/store'; import LoginForm from '#/views/_core/authentication/login.vue'; const router = useRouter(); +const { hasPermission } = usePermission(); const notifications = ref([ { @@ -81,11 +83,16 @@ const SwitchCompanyIcon = createIconifyIcon('lucide:building-2'); const SwitchAccountIcon = createIconifyIcon('lucide:arrow-left-right'); // 用户图标 const UserIcon = createIconifyIcon('lucide:user'); +// 记忆图标 +const MemoryIcon = createIconifyIcon('lucide:brain'); // 意见反馈图标 const FeedbackIcon = createIconifyIcon('lucide:message-square-plus'); // 锁图标 const LockIcon = createIconifyIcon('lucide:lock'); +/** 是否具备智能助手聊天权限(用于「我的记忆」入口;含超管) */ +const canUseAgentChat = computed(() => hasPermission('agent:chat')); + /** 当前用户可切换的可用公司数 */ const companyCount = computed(() => { const info = userStore.userInfo as null | { companyCount?: number }; @@ -103,6 +110,16 @@ const menus = computed(() => { icon: UserIcon, text: '个人信息', }); + // 我的记忆(有助手聊天权才显示) + if (canUseAgentChat.value) { + menuItems.push({ + handler: () => { + router.push('/agent/memories'); + }, + icon: MemoryIcon, + text: '我的记忆', + }); + } // 意见反馈 menuItems.push({ handler: () => { diff --git a/apps/web/apps/web-antd/src/router/routes/static/memories.ts b/apps/web/apps/web-antd/src/router/routes/static/memories.ts new file mode 100644 index 00000000..87c177e0 --- /dev/null +++ b/apps/web/apps/web-antd/src/router/routes/static/memories.ts @@ -0,0 +1,20 @@ +import type { RouteRecordRaw } from 'vue-router'; + +/** + * 用户记忆管理(头像下拉入口;不进侧栏菜单) + */ +const staticRoutes: RouteRecordRaw[] = [ + { + name: 'AgentMemories', + path: '/agent/memories', + component: () => import('#/views/agent/memories/index.vue'), + meta: { + icon: 'lucide:brain', + title: '我的记忆', + hideInMenu: true, + ignoreAccess: true, + }, + }, +]; + +export default staticRoutes; diff --git a/apps/web/apps/web-antd/src/views/agent/llm-settings/index.vue b/apps/web/apps/web-antd/src/views/agent/llm-settings/index.vue index 18856855..dbd0395b 100644 --- a/apps/web/apps/web-antd/src/views/agent/llm-settings/index.vue +++ b/apps/web/apps/web-antd/src/views/agent/llm-settings/index.vue @@ -17,9 +17,7 @@ import { } from 'ant-design-vue'; import { - deleteAgentMemoryApi, getAgentLlmSettingsApi, - listAgentMemoriesApi, probeAgentLlmModelsApi, type AgentVO, updateAgentLlmSettingsApi, @@ -30,7 +28,6 @@ defineOptions({ name: 'AgentLlmSettings' }); const loading = ref(true); const saving = ref(false); const probingModels = ref(false); -const memories = ref([]); const probedModels = ref([]); const manualModelId = ref(''); @@ -54,10 +51,7 @@ async function loadAll() { probedModels.value = []; manualModelId.value = ''; try { - const [s, mem] = await Promise.all([ - getAgentLlmSettingsApi(), - listAgentMemoriesApi().catch(() => ({ items: [] as AgentVO.Memory[] })), - ]); + const s = await getAgentLlmSettingsApi(); llmForm.value = { baseUrl: s.baseUrl || '', apiKey: '', @@ -73,7 +67,6 @@ async function loadAll() { : '', isDefault: !!m.isDefault, })); - memories.value = mem.items || []; } catch (e: any) { message.error(e?.message || '加载模型配置失败'); } finally { @@ -175,16 +168,6 @@ async function probeModels() { } } -async function removeMemory(id: string) { - try { - await deleteAgentMemoryApi(id); - memories.value = memories.value.filter((m) => m.id !== id); - message.success('已删除记忆'); - } catch (e: any) { - message.error(e?.message || '删除失败'); - } -} - async function saveSettings() { if (!llmForm.value.baseUrl.trim()) { message.warning('请填写 Base URL'); @@ -379,27 +362,6 @@ onMounted(() => { - - -

- 对话中发送「记住:…」可写入;助手按需检索,不会默认注入全部记忆。 -

-
- 暂无记忆 -
-
- {{ - m.summary || m.text - }} - -
-
diff --git a/apps/web/apps/web-antd/src/views/agent/memories/index.vue b/apps/web/apps/web-antd/src/views/agent/memories/index.vue new file mode 100644 index 00000000..a74297c5 --- /dev/null +++ b/apps/web/apps/web-antd/src/views/agent/memories/index.vue @@ -0,0 +1,91 @@ + + +