Просмотр исходного кода

feat(ai): 收紧记忆数据权限并统一工作台交互细节

- 长期记忆移除用户选择,后端所有记忆接口强制当前登录用户
- 工作台默认按钮高度统一为 30px,发送按钮改为 30×30 圆形
- 修复切换菜单时的视口抖动与画布背景闪白
- 技能表单补充「技能用途」标签,知识库新增默认向量维度 1024
- 精简技能/场景包搜索文案,表格说明移入悬浮提示
cc 5 дней назад
Родитель
Сommit
b95dfea935

+ 7 - 0
.zcode/config.json

@@ -0,0 +1,7 @@
+{
+  "plugins": {
+    "enabledPlugins": {
+      "design@zcode-plugins-official": true
+    }
+  }
+}

+ 25 - 34
ai-electron/frontend/src/workbench/api/memory.ts

@@ -2,63 +2,54 @@ import { aiDelete, aiGet, aiPost, aiPut } from './http';
 
 export type Id = string | number;
 
+/**
+ * 长期记忆接口:记忆归属用户由后端取当前登录用户,前端不再传 userId。
+ */
 export function getMemoryConfig(): Promise<any> {
   return aiGet<any>('/ai/memory/config');
 }
 export function updateMemoryConfig(data: any): Promise<void> {
   return aiPut<void>('/ai/memory/config', data);
 }
-export function listMemoryFiles(caseId: Id, agentId: Id, userId: Id): Promise<any[]> {
-  return aiGet<any[]>('/ai/memory/files', { caseId, agentId, userId });
+export function listMemoryFiles(caseId: Id, agentId: Id): Promise<any[]> {
+  return aiGet<any[]>('/ai/memory/files', { caseId, agentId });
 }
-export function getMemoryContent(caseId: Id, agentId: Id, userId: Id, path: string): Promise<any> {
-  return aiGet<any>('/ai/memory/content', { caseId, agentId, userId, path });
+export function getMemoryContent(caseId: Id, agentId: Id, path: string): Promise<any> {
+  return aiGet<any>('/ai/memory/content', { caseId, agentId, path });
 }
 export function updateMemoryContent(data: any): Promise<void> {
   return aiPut<void>('/ai/memory/content', data);
 }
-export function consolidateMemory(caseId: Id, agentId: Id, userId: Id): Promise<void> {
-  return aiPost<void>(
-    `/ai/memory/consolidate?caseId=${caseId}&agentId=${agentId}&userId=${userId}`,
-  );
+export function consolidateMemory(caseId: Id, agentId: Id): Promise<void> {
+  return aiPost<void>(`/ai/memory/consolidate?caseId=${caseId}&agentId=${agentId}`);
 }
-export function archiveMemory(caseId: Id, agentId: Id, userId: Id): Promise<number> {
-  return aiPost<number>(`/ai/memory/archive?caseId=${caseId}&agentId=${agentId}&userId=${userId}`);
+export function archiveMemory(caseId: Id, agentId: Id): Promise<number> {
+  return aiPost<number>(`/ai/memory/archive?caseId=${caseId}&agentId=${agentId}`);
 }
-export function cleanupMemory(caseId: Id, agentId: Id, userId: Id): Promise<number> {
-  return aiPost<number>(`/ai/memory/cleanup?caseId=${caseId}&agentId=${agentId}&userId=${userId}`);
+export function cleanupMemory(caseId: Id, agentId: Id): Promise<number> {
+  return aiPost<number>(`/ai/memory/cleanup?caseId=${caseId}&agentId=${agentId}`);
 }
-export function getMemoryQuality(caseId: Id, agentId: Id, userId: Id, days = 1): Promise<any> {
-  return aiGet<any>('/ai/memory/quality', { caseId, agentId, userId, days });
+export function getMemoryQuality(caseId: Id, agentId: Id, days = 1): Promise<any> {
+  return aiGet<any>('/ai/memory/quality', { caseId, agentId, days });
 }
-export function listMemoryVersions(caseId: Id, agentId: Id, userId: Id): Promise<any[]> {
-  return aiGet<any[]>('/ai/memory/versions', { caseId, agentId, userId });
+export function listMemoryVersions(caseId: Id, agentId: Id): Promise<any[]> {
+  return aiGet<any[]>('/ai/memory/versions', { caseId, agentId });
 }
-export function getMemoryVersion(
-  versionId: Id,
-  caseId: Id,
-  agentId: Id,
-  userId: Id,
-): Promise<any> {
-  return aiGet<any>(`/ai/memory/versions/${versionId}`, { caseId, agentId, userId });
+export function getMemoryVersion(versionId: Id, caseId: Id, agentId: Id): Promise<any> {
+  return aiGet<any>(`/ai/memory/versions/${versionId}`, { caseId, agentId });
 }
 export function restoreMemoryVersion(versionId: Id, data: any): Promise<any> {
   return aiPost<any>(`/ai/memory/versions/${versionId}/restore`, data);
 }
-export function listDeclaredMemories(caseId: Id, agentId: Id, userId: Id): Promise<any[]> {
-  return aiGet<any[]>('/ai/memory/declared', { caseId, agentId, userId });
+export function listDeclaredMemories(caseId: Id, agentId: Id): Promise<any[]> {
+  return aiGet<any[]>('/ai/memory/declared', { caseId, agentId });
 }
 export function addDeclaredMemory(data: any): Promise<any> {
   return aiPost<any>('/ai/memory/declared', data);
 }
-export function revokeDeclaredMemory(
-  entryId: Id,
-  caseId: Id,
-  agentId: Id,
-  userId: Id,
-): Promise<boolean> {
-  return aiDelete<boolean>(`/ai/memory/declared/${entryId}`, { caseId, agentId, userId });
+export function revokeDeclaredMemory(entryId: Id, caseId: Id, agentId: Id): Promise<boolean> {
+  return aiDelete<boolean>(`/ai/memory/declared/${entryId}`, { caseId, agentId });
 }
-export function removeMemory(caseId: Id, agentId: Id, userId: Id): Promise<void> {
-  return aiDelete<void>(`/ai/memory/${agentId}/${userId}`, { caseId });
+export function removeMemory(caseId: Id, agentId: Id): Promise<void> {
+  return aiDelete<void>(`/ai/memory/${agentId}`, { caseId });
 }

+ 9 - 0
ai-electron/frontend/src/workbench/layouts/WorkbenchLayout.vue

@@ -69,9 +69,12 @@
   };
   onMounted(() => {
     shellHeight.value = window.innerHeight;
+    // 工作台画布底色:内嵌浏览器切换路由时会短暂拉高视口,页面外露出的区域需与 shell 同色
+    document.body.classList.add('wb-active');
     window.addEventListener('resize', handleWindowResize, { passive: true });
   });
   onBeforeUnmount(() => {
+    document.body.classList.remove('wb-active');
     if (resizeTimer !== undefined) {
       window.clearTimeout(resizeTimer);
     }
@@ -111,6 +114,12 @@
 <style lang="less">
   @import '../styles/workbench.less';
 
+  /* 工作台画布与 shell 同色:内嵌浏览器瞬时拉高视口时,底部多出的区域不可见。
+     内嵌浏览器会注入 html,body{background:transparent!important},这里用更高优先级压住。 */
+  body.wb-active {
+    background: #f4f6fa !important;
+  }
+
   .wb-shell {
     display: flex;
     flex-direction: column;

+ 17 - 9
ai-electron/frontend/src/workbench/styles/workbench.less

@@ -46,6 +46,8 @@
   border-radius: var(--wb-radius);
 
   .ant-card-head {
+    /* 卡片作为 flex 列容器时表头不得被内容挤压,否则双行标题会溢出、看起来像没有 padding */
+    flex: 0 0 auto;
     min-height: 46px;
     padding: 0 16px;
     border-bottom: 1px solid var(--wb-border);
@@ -279,7 +281,7 @@
     }
 
     .ant-card-extra .ant-btn {
-      height: 32px;
+      height: 30px;
       padding: 0 14px;
       border-radius: 8px;
       font-size: 12px;
@@ -448,7 +450,7 @@
     }
 
     .ant-btn {
-      height: 32px;
+      height: 30px;
       padding: 0 14px;
       border-radius: 8px;
       font-size: 12px;
@@ -495,13 +497,13 @@
     }
   }
 
-  .wb-toolbar__actions .ant-btn {
-    height: 32px;
-    padding: 0 14px;
-    border-radius: 8px;
-    font-size: 12px;
-    font-weight: 500;
-  }
+.wb-toolbar__actions .ant-btn {
+  height: 30px;
+  padding: 0 14px;
+  border-radius: 8px;
+  font-size: 12px;
+  font-weight: 500;
+}
 
   .ant-btn.ant-btn-primary.ant-btn-background-ghost {
     color: #2a50ec !important;
@@ -687,6 +689,12 @@
   }
 }
 
+// 统一工作台内容区按钮高度:Ant 默认 32px → 30px;小 / 大尺寸按钮保持自身高度。
+// :where() 不增加优先级,便于入口页底部 34px 按钮用更高优先级的 !important 保留。
+.wb-page .ant-btn:where(:not(.ant-btn-sm, .ant-btn-lg)) {
+  height: 30px !important;
+}
+
 // 统一工作台内容区按钮圆角:使用紧凑的 6px,不使用大圆角
 .wb-page .ant-btn,
 .chat-workbench .ant-btn {

+ 1 - 1
ai-electron/frontend/src/workbench/views/agent/entry/index.vue

@@ -476,7 +476,7 @@
   }
 
   .entry-footer :deep(.ant-btn) {
-    height: 34px;
+    height: 34px !important;
     padding: 0 16px;
     border-radius: 8px;
     font-size: 12px;

+ 91 - 143
ai-electron/frontend/src/workbench/views/agent/memory/index.vue

@@ -22,15 +22,14 @@
                   <div class="memory-card-heading">
                     <h3 class="memory-card-title">长期记忆</h3>
                     <p class="memory-card-sub">
-                      记忆按用户隔离存放于智能体工作区:MEMORY.md 为合并后的长期记忆,memory/YYYY-MM-DD.md 为每日事实流水。
+                      记忆按用户隔离存放于智能体工作区:MEMORY.md 为合并后的长期记忆,memory/YYYY-MM-DD.md
+                      为每日事实流水。
                       保存后写入运行期配置,下一轮对话即按新策略重新装配生效。默认开启;关闭后保留已有记忆文件,但不再产生新的抽取与合并调用。
                     </p>
                   </div>
                   <div class="memory-card-actions">
                     <a-button @click="loadConfig">刷新</a-button>
-                    <a-button type="primary" :loading="configSaving" @click="handleSaveConfig">
-                      保存
-                    </a-button>
+                    <a-button type="primary" :loading="configSaving" @click="handleSaveConfig"> 保存 </a-button>
                   </div>
                 </div>
               </template>
@@ -42,7 +41,9 @@
                     <template #label>
                       <span class="wb-label-tip">
                         启用长期记忆
-                        <a-tooltip title="开启后每轮对话结束异步抽取事实写入当日流水,并按节流策略合并进 MEMORY.md(会产生额外模型调用)。">
+                        <a-tooltip
+                          title="开启后每轮对话结束异步抽取事实写入当日流水,并按节流策略合并进 MEMORY.md(会产生额外模型调用)。"
+                        >
                           <Icon icon="i-mdi:information-outline" class="wb-label-tip__icon" tabindex="0" />
                         </a-tooltip>
                       </span>
@@ -56,7 +57,9 @@
                     <template #label>
                       <span class="wb-label-tip">
                         记忆注入上限(Token)
-                        <a-tooltip title="MEMORY.md 等记忆内容注入 system prompt 的 Token 预算,超出时截断(框架默认 8000)。">
+                        <a-tooltip
+                          title="MEMORY.md 等记忆内容注入 system prompt 的 Token 预算,超出时截断(框架默认 8000)。"
+                        >
                           <Icon icon="i-mdi:information-outline" class="wb-label-tip__icon" tabindex="0" />
                         </a-tooltip>
                       </span>
@@ -151,7 +154,9 @@
                     <template #label>
                       <span class="wb-label-tip">
                         每日流水保留天数
-                        <a-tooltip title="超过该天数的每日流水会移入 memory/archive/ 归档目录(默认 90 天),归档文件再按「归档保留天数」清理。">
+                        <a-tooltip
+                          title="超过该天数的每日流水会移入 memory/archive/ 归档目录(默认 90 天),归档文件再按「归档保留天数」清理。"
+                        >
                           <Icon icon="i-mdi:information-outline" class="wb-label-tip__icon" tabindex="0" />
                         </a-tooltip>
                       </span>
@@ -212,28 +217,18 @@
               <div class="memory-card-heading">
                 <h3 class="memory-card-title">记忆内容</h3>
                 <p class="memory-card-sub">
-                  按智能体与用户查看、编辑记忆文件;「触发合并」立即把当日流水合并进 MEMORY.md(人工干预自动节流)。
+                  按智能体查看、编辑当前登录用户的记忆文件;「触发合并」立即把当日流水合并进
+                  MEMORY.md(人工干预自动节流)。
                 </p>
               </div>
               <div class="memory-card-actions">
-                <a-button
-                  :disabled="!currentCaseId || !query.agentId || !query.userId"
-                  @click="handleOpenVersions"
-                >
-                  版本历史
-                </a-button>
+                <a-button :disabled="!currentCaseId || !query.agentId" @click="handleOpenVersions"> 版本历史 </a-button>
                 <a-button class="wb-btn-warning" :loading="consolidating" @click="handleConsolidate">
                   触发合并
                 </a-button>
-                <a-button :loading="archiving" @click="handleArchive">
-                  归档
-                </a-button>
-                <a-button :loading="cleaning" @click="handleCleanup">
-                  清理
-                </a-button>
-                <a-button danger ghost :loading="removing" @click="handleRemove">
-                  删除记忆
-                </a-button>
+                <a-button :loading="archiving" @click="handleArchive"> 归档 </a-button>
+                <a-button :loading="cleaning" @click="handleCleanup"> 清理 </a-button>
+                <a-button danger ghost :loading="removing" @click="handleRemove"> 删除记忆 </a-button>
               </div>
             </div>
           </template>
@@ -249,18 +244,7 @@
             >
               <a-select-option v-for="item in agentOptions" :key="item.id" :label="item.agentName" :value="item.id" />
             </a-select>
-            <a-select
-              v-model:value="query.userId"
-              class="memory-scope-select memory-scope-select--user"
-              placeholder="选择用户"
-              show-search
-              option-filter-prop="label"
-              :options="userSelectOptions"
-              @change="handleScopeChange"
-            />
-            <a-button @click="handleScopeChange">
-              刷新文件
-            </a-button>
+            <a-button @click="handleScopeChange"> 刷新文件 </a-button>
             <span v-if="!form.enabled" class="filter-tip">长期记忆当前为关闭状态,以下为已落盘的历史记忆。</span>
           </div>
 
@@ -336,11 +320,7 @@
               </div>
               <div class="memory-card-actions">
                 <a-button @click="loadDeclared">刷新</a-button>
-                <a-button
-                  type="primary"
-                  :disabled="!currentCaseId || !query.agentId || !query.userId"
-                  @click="handleOpenDeclared"
-                >
+                <a-button type="primary" :disabled="!currentCaseId || !query.agentId" @click="handleOpenDeclared">
                   新增
                 </a-button>
               </div>
@@ -364,7 +344,13 @@
                 </a-tag>
               </template>
               <template v-else-if="column.key === 'action'">
-                <a-button type="link" danger size="small" :disabled="record.revoked" @click="handleRevokeDeclared(record)">
+                <a-button
+                  type="link"
+                  danger
+                  size="small"
+                  :disabled="record.revoked"
+                  @click="handleRevokeDeclared(record)"
+                >
                   撤销
                 </a-button>
               </template>
@@ -550,9 +536,7 @@
             <a-radio value="CONTENT">只恢复内容</a-radio>
             <a-radio value="CONTENT_AND_WATERMARK">内容 + 合并水位</a-radio>
           </a-radio-group>
-          <div class="restore-tip">
-            只恢复内容时水位不变;同时恢复水位后,仍在 memory/ 的流水可能被重新合并。
-          </div>
+          <div class="restore-tip"> 只恢复内容时水位不变;同时恢复水位后,仍在 memory/ 的流水可能被重新合并。 </div>
         </a-form-item>
         <a-form-item label="备注">
           <a-input v-model:value="restoreForm.note" :maxlength="200" show-count placeholder="可选,记录本次恢复原因" />
@@ -569,24 +553,53 @@
 <script lang="ts" setup name="WorkbenchAgentMemory">
   import { computed, onMounted, reactive, ref, watch } from 'vue';
   import {
-    AAlert, AButton, ACard, AForm, AFormItem, AInput, AInputNumber, ARadio,
-    ARadioButton, ARadioGroup, ASelect, ASelectOption, ASpin, ASwitch, ATabPane, ATable, ATabs, ATag,
-    ATextarea, ATooltip, message, Modal,
+    AAlert,
+    AButton,
+    ACard,
+    AForm,
+    AFormItem,
+    AInput,
+    AInputNumber,
+    ARadio,
+    ARadioButton,
+    ARadioGroup,
+    ASelect,
+    ASelectOption,
+    ASpin,
+    ASwitch,
+    ATabPane,
+    ATable,
+    ATabs,
+    ATag,
+    ATextarea,
+    ATooltip,
+    message,
+    Modal,
   } from '@/workbench/components/ant';
   import { Icon } from '@/core/components/Icon';
   import { BasicModal } from '@/core/components/Modal';
-  import { useAccountStore } from '@/core/store/modules/account';
   import { useUserStore } from '@/core/store/modules/case';
   import { optionAgent } from '@/workbench/api/agent';
   import {
-    addDeclaredMemory, archiveMemory, cleanupMemory, consolidateMemory, getMemoryConfig, getMemoryContent,
-    getMemoryQuality, getMemoryVersion, listDeclaredMemories, listMemoryFiles, listMemoryVersions,
-    removeMemory, restoreMemoryVersion, revokeDeclaredMemory, updateMemoryConfig, updateMemoryContent,
+    addDeclaredMemory,
+    archiveMemory,
+    cleanupMemory,
+    consolidateMemory,
+    getMemoryConfig,
+    getMemoryContent,
+    getMemoryQuality,
+    getMemoryVersion,
+    listDeclaredMemories,
+    listMemoryFiles,
+    listMemoryVersions,
+    removeMemory,
+    restoreMemoryVersion,
+    revokeDeclaredMemory,
+    updateMemoryConfig,
+    updateMemoryContent,
   } from '@/workbench/api/memory';
-  import { listUser } from '@/workbench/api/user';
 
-  const accountStore = useAccountStore();
-  /** 案件上下文:长期记忆按案件隔离,所有读写都带当前案件 */
+  /** 案件上下文:长期记忆按案件隔离,所有读写都带当前案件;记忆归属用户由后端取当前登录用户 */
   const userStore = useUserStore();
   const currentCaseId = computed(() => String(userStore.getCaseInfo?.id || '').trim());
   const caseName = computed(() => String(userStore.getCaseInfo?.name || '').trim());
@@ -626,8 +639,7 @@
   };
 
   const agentOptions = ref<any[]>([]);
-  const userOptions = ref<any[]>([]);
-  const query = reactive<{ agentId?: any; userId?: any }>({});
+  const query = reactive<{ agentId?: any }>({});
   const files = ref<any[]>([]);
   const fileLoading = ref(false);
   const current = ref<{ path: string }>({ path: '' });
@@ -697,35 +709,6 @@
     { title: '操作', key: 'action', width: 150, align: 'center' },
   ];
 
-  const userLabelOf = (item: any) => {
-    const name = item.displayName || item.username || String(item.id ?? '');
-    return item.username ? `${name}(${item.username})` : name;
-  };
-  const userSelectOptions = computed(() =>
-    userOptions.value.map((item) => ({ label: userLabelOf(item), value: item.id })),
-  );
-
-  /** 用户下拉:系统用户列表接口仅管理员可用,失败时至少保留当前登录用户 */
-  const loadUserOptions = async () => {
-    const self = accountStore.getUserInfo;
-    const selfOption = self?.id
-      ? [{ id: self.id, username: self.username, displayName: self.displayName }]
-      : [];
-    try {
-      const res: any = await listUser(undefined, 1, 500);
-      const rows: any[] = res?.rows ?? res?.records ?? [];
-      const merged = [...selfOption];
-      rows.forEach((row) => {
-        if (!merged.some((item) => String(item.id) === String(row.id))) {
-          merged.push(row);
-        }
-      });
-      userOptions.value = merged;
-    } catch {
-      userOptions.value = selfOption;
-    }
-  };
-
   const customRow = (record: any) => ({
     onClick: () => handleSelectFile(record),
   });
@@ -749,8 +732,8 @@
       message.warning('请先打开案件');
       return false;
     }
-    if (!query.agentId || !query.userId) {
-      message.warning('请先选择智能体与用户');
+    if (!query.agentId) {
+      message.warning('请先选择智能体');
       return false;
     }
     return true;
@@ -765,13 +748,13 @@
 
   /** 加载版本列表 */
   const loadVersions = async () => {
-    if (!currentCaseId.value || !query.agentId || !query.userId) {
+    if (!currentCaseId.value || !query.agentId) {
       versions.value = [];
       return;
     }
     versionLoading.value = true;
     try {
-      const res = await listMemoryVersions(currentCaseId.value, query.agentId, query.userId);
+      const res = await listMemoryVersions(currentCaseId.value, query.agentId);
       versions.value = res ?? [];
     } finally {
       versionLoading.value = false;
@@ -781,13 +764,7 @@
   /** 查看版本正文 */
   const handleViewVersion = async (row: any) => {
     if (!requireScope()) return;
-    versionDetail.value =
-      (await getMemoryVersion(
-        row.versionId,
-        currentCaseId.value,
-        query.agentId,
-        query.userId,
-      )) ?? null;
+    versionDetail.value = (await getMemoryVersion(row.versionId, currentCaseId.value, query.agentId)) ?? null;
     versionDetailVisible.value = true;
   };
 
@@ -807,7 +784,6 @@
       const payload = {
         caseId: currentCaseId.value,
         agentId: query.agentId,
-        userId: query.userId,
         mode: restoreForm.value.mode,
         note: restoreForm.value.note,
       };
@@ -854,54 +830,45 @@
     }
   };
 
-  /** 加载智能体与用户下拉(用户列表复用系统用户接口) */
+  /** 加载智能体下拉,并把查看用户固定为当前登录用户(记忆只允许本人查看) */
   const loadOptions = async () => {
     const res = await optionAgent();
     agentOptions.value = res ?? [];
     if (agentOptions.value.length) {
       query.agentId = agentOptions.value[0].id;
     }
-    await loadUserOptions();
-    if (userOptions.value.length) {
-      query.userId = userOptions.value[0].id;
-    }
   };
 
-  /** 加载记忆文件清单(切换智能体 / 用户后调用) */
+  /** 加载记忆文件清单(切换智能体后调用) */
   const loadFiles = async () => {
     current.value = { path: '' };
     content.value = '';
-    if (!currentCaseId.value || !query.agentId || !query.userId) {
+    if (!currentCaseId.value || !query.agentId) {
       files.value = [];
       return;
     }
     fileLoading.value = true;
     try {
-      const res = await listMemoryFiles(currentCaseId.value, query.agentId, query.userId);
+      const res = await listMemoryFiles(currentCaseId.value, query.agentId);
       files.value = res ?? [];
     } finally {
       fileLoading.value = false;
     }
   };
 
-  /** 切换智能体或用户 */
+  /** 切换智能体 */
   const handleScopeChange = async () => {
     await Promise.all([loadFiles(), loadDeclared(), loadQuality()]);
   };
 
   /** 加载运行健康指标(按天窗口) */
   const loadQuality = async () => {
-    if (!currentCaseId.value || !query.userId) {
+    if (!currentCaseId.value) {
       return;
     }
     qualityLoading.value = true;
     try {
-      const res = await getMemoryQuality(
-        currentCaseId.value,
-        query.agentId,
-        query.userId,
-        qualityDays.value,
-      );
+      const res = await getMemoryQuality(currentCaseId.value, query.agentId, qualityDays.value);
       if (res) {
         quality.value = res;
       }
@@ -925,17 +892,13 @@
 
   /** 加载显式记忆(含已撤销条目,便于审计) */
   const loadDeclared = async () => {
-    if (!currentCaseId.value || !query.agentId || !query.userId) {
+    if (!currentCaseId.value || !query.agentId) {
       declared.value = [];
       return;
     }
     declaredLoading.value = true;
     try {
-      const res = await listDeclaredMemories(
-        currentCaseId.value,
-        query.agentId,
-        query.userId,
-      );
+      const res = await listDeclaredMemories(currentCaseId.value, query.agentId);
       declared.value = res ?? [];
     } finally {
       declaredLoading.value = false;
@@ -961,7 +924,6 @@
       await addDeclaredMemory({
         caseId: currentCaseId.value,
         agentId: query.agentId,
-        userId: query.userId,
         fact: declaredForm.value.fact.trim(),
         evidence: declaredForm.value.evidence.trim(),
       });
@@ -989,28 +951,18 @@
     if (!ok) {
       return;
     }
-    await revokeDeclaredMemory(
-      row.id,
-      currentCaseId.value,
-      query.agentId,
-      query.userId,
-    );
+    await revokeDeclaredMemory(row.id, currentCaseId.value, query.agentId);
     message.success('已撤销');
     await loadDeclared();
   };
 
   /** 选中文件并加载内容 */
   const handleSelectFile = async (row?: any) => {
-    if (!row?.path || !currentCaseId.value || !query.agentId || !query.userId) {
+    if (!row?.path || !currentCaseId.value || !query.agentId) {
       return;
     }
     current.value = { path: row.path };
-    const res = await getMemoryContent(
-      currentCaseId.value,
-      query.agentId,
-      query.userId,
-      row.path,
-    );
+    const res = await getMemoryContent(currentCaseId.value, query.agentId, row.path);
     content.value = res?.content ?? '';
   };
 
@@ -1024,7 +976,6 @@
       await updateMemoryContent({
         caseId: currentCaseId.value,
         agentId: query.agentId,
-        userId: query.userId,
         path: current.value.path,
         content: content.value,
       });
@@ -1045,7 +996,7 @@
     }
     consolidating.value = true;
     try {
-      await consolidateMemory(currentCaseId.value, query.agentId, query.userId);
+      await consolidateMemory(currentCaseId.value, query.agentId);
       message.success('记忆合并已完成');
       await Promise.all([loadFiles(), loadQuality()]);
     } finally {
@@ -1062,7 +1013,7 @@
     if (!requireScope()) return;
     archiving.value = true;
     try {
-      const res = await archiveMemory(currentCaseId.value, query.agentId, query.userId);
+      const res = await archiveMemory(currentCaseId.value, query.agentId);
       message.success(`已归档 ${res ?? 0} 个流水文件`);
       await loadFiles();
     } finally {
@@ -1075,7 +1026,7 @@
     if (!requireScope()) return;
     cleaning.value = true;
     try {
-      const res = await cleanupMemory(currentCaseId.value, query.agentId, query.userId);
+      const res = await cleanupMemory(currentCaseId.value, query.agentId);
       message.success(`已清理 ${res ?? 0} 个文件`);
       await loadFiles();
     } finally {
@@ -1089,7 +1040,8 @@
     const ok = await new Promise<boolean>((resolve) => {
       Modal.confirm({
         title: '提示',
-        content: '将删除该用户在小Z 与专家侧共用的全部长期记忆(MEMORY.md 与每日流水),且不可恢复。确认继续?',
+        content:
+          '将删除你(当前登录用户)在小Z 与专家侧共用的全部长期记忆(MEMORY.md 与每日流水),且不可恢复。确认继续?',
         okText: '确定',
         cancelText: '取消',
         onOk: () => resolve(true),
@@ -1101,7 +1053,7 @@
     }
     removing.value = true;
     try {
-      await removeMemory(currentCaseId.value, query.agentId, query.userId);
+      await removeMemory(currentCaseId.value, query.agentId);
       message.success('长期记忆已删除');
       await Promise.all([loadFiles(), loadDeclared()]);
     } finally {
@@ -1351,10 +1303,6 @@
     width: 220px;
   }
 
-  .memory-scope-select--user {
-    width: 260px;
-  }
-
   .memory-scope-bar :deep(.ant-select-selector) {
     height: 32px !important;
     padding: 0 10px;

+ 52 - 29
ai-electron/frontend/src/workbench/views/agent/pack/index.vue

@@ -5,11 +5,7 @@
         <div class="pack-panel__heading">
           <div class="pack-panel__title-row">
             <h3 class="pack-panel__title">场景包</h3>
-            <a-tooltip
-              :title="packPanelTip"
-              placement="bottomLeft"
-              :overlay-style="{ maxWidth: '460px' }"
-            >
+            <a-tooltip :title="packPanelTip" placement="bottomLeft" :overlay-style="{ maxWidth: '460px' }">
               <Icon icon="i-mdi:information-outline" class="pack-panel__tip" tabindex="0" />
             </a-tooltip>
             <span class="pack-panel__count">共 {{ packList.length }} 个</span>
@@ -19,7 +15,7 @@
           <a-input
             v-model:value="queryParams.keyword"
             class="pack-search"
-            placeholder="搜索场景包编码 / 名称 / 用途说明"
+            placeholder="搜索场景包名称"
             allow-clear
             @press-enter="handleQuery"
           >
@@ -27,20 +23,13 @@
               <Icon icon="i-mdi:magnify" class="pack-search__icon" />
             </template>
           </a-input>
-          <a-select
-            v-model:value="queryParams.status"
-            class="pack-status-select"
-            placeholder="全部状态"
-            allow-clear
-          >
+          <a-select v-model:value="queryParams.status" class="pack-status-select" placeholder="全部状态" allow-clear>
             <a-select-option value="0">启用</a-select-option>
             <a-select-option value="1">停用</a-select-option>
           </a-select>
           <a-button type="primary" @click="handleQuery">查询</a-button>
           <a-button @click="resetQuery">重置</a-button>
-          <a-button type="primary" @click="handleAdd">
-            新增
-          </a-button>
+          <a-button type="primary" @click="handleAdd"> 新增 </a-button>
         </div>
       </header>
 
@@ -145,8 +134,19 @@
               </a-tooltip>
             </span>
           </template>
-          <a-select v-model:value="selectedToolCodes" mode="multiple" allow-clear placeholder="请选择包内业务工具" style="width: 100%">
-            <a-select-option v-for="item in toolOptions" :key="item.toolCode" :label="item.toolName" :value="item.toolCode">
+          <a-select
+            v-model:value="selectedToolCodes"
+            mode="multiple"
+            allow-clear
+            placeholder="请选择包内业务工具"
+            style="width: 100%"
+          >
+            <a-select-option
+              v-for="item in toolOptions"
+              :key="item.toolCode"
+              :label="item.toolName"
+              :value="item.toolCode"
+            >
               <span>{{ item.toolName }}</span>
               <span class="option-suffix">{{ item.toolType === '0' ? '只读' : '写入' }}</span>
             </a-select-option>
@@ -211,9 +211,7 @@
               :key="mcpKey(bind.mcpClientId, bind.toolName)"
               class="binding-row"
             >
-              <span class="binding-name">
-                {{ serverNameOf(bind.mcpClientId) }} · {{ bind.toolName }}
-              </span>
+              <span class="binding-name"> {{ serverNameOf(bind.mcpClientId) }} · {{ bind.toolName }} </span>
               <a-select v-model:value="bind.decision" size="small" style="width: 150px">
                 <a-select-option v-for="item in DECISION_OPTIONS" :key="item.value" :value="item.value">
                   {{ item.label }}
@@ -226,12 +224,20 @@
           <template #label>
             <span class="wb-label-tip">
               技能
-              <a-tooltip title="叠加到智能体既有技能绑定之上;仍按提问用户的技能生效范围过滤(仅列当前用户可见的技能)。">
+              <a-tooltip
+                title="叠加到智能体既有技能绑定之上;仍按提问用户的技能生效范围过滤(仅列当前用户可见的技能)。"
+              >
                 <Icon icon="i-mdi:information-outline" class="wb-label-tip__icon" tabindex="0" />
               </a-tooltip>
             </span>
           </template>
-          <a-select v-model:value="form.skillIds" mode="multiple" allow-clear placeholder="请选择包内技能" style="width: 100%">
+          <a-select
+            v-model:value="form.skillIds"
+            mode="multiple"
+            allow-clear
+            placeholder="请选择包内技能"
+            style="width: 100%"
+          >
             <a-select-option v-for="item in skillOptions" :key="item.id" :label="item.name" :value="item.id" />
           </a-select>
         </a-form-item>
@@ -318,13 +324,32 @@
 <script lang="ts" setup name="WorkbenchAgentPack">
   import { computed, onMounted, reactive, ref } from 'vue';
   import {
-    AButton, ADescriptions, ADescriptionsItem, AEmpty, AForm, AFormItem, AInput, ARadio,
-    ARadioGroup, ASelect, ASelectOption, ASpin, ATag, ATextarea, ATooltip, Modal, message,
+    AButton,
+    ADescriptions,
+    ADescriptionsItem,
+    AEmpty,
+    AForm,
+    AFormItem,
+    AInput,
+    ARadio,
+    ARadioGroup,
+    ASelect,
+    ASelectOption,
+    ASpin,
+    ATag,
+    ATextarea,
+    ATooltip,
+    Modal,
+    message,
   } from '@/workbench/components/ant';
   import { Icon } from '@/core/components/Icon';
   import { BasicModal } from '@/core/components/Modal';
   import {
-    addScenarioPack, delScenarioPack, getScenarioPack, listScenarioPack, scenarioPackMcpOptions,
+    addScenarioPack,
+    delScenarioPack,
+    getScenarioPack,
+    listScenarioPack,
+    scenarioPackMcpOptions,
     updateScenarioPack,
   } from '@/workbench/api/pack';
   import { visibleSkillOptions } from '@/workbench/api/skill';
@@ -561,9 +586,7 @@
         ...form.value,
         toolBindings: (form.value.toolBindings ?? []).filter((bind: any) => !!bind.toolCode),
         mcpToolBindings: (form.value.mcpToolBindings ?? []).filter((bind: any) => !!bind.toolName),
-        skillIds: (form.value.skillIds ?? []).filter(
-          (id: any) => id !== undefined && id !== null && id !== '',
-        ),
+        skillIds: (form.value.skillIds ?? []).filter((id: any) => id !== undefined && id !== null && id !== ''),
       };
       if (payload.id) {
         await updateScenarioPack(payload);
@@ -704,7 +727,7 @@
   }
 
   .pack-panel__tools :deep(.ant-btn) {
-    height: 32px;
+    height: 30px;
     padding: 0 14px;
     border-radius: 8px;
     font-size: 12px;

+ 139 - 50
ai-electron/frontend/src/workbench/views/agent/skill/index.vue

@@ -5,11 +5,7 @@
         <div class="skill-panel__heading">
           <div class="skill-panel__title-row">
             <h3 class="skill-panel__title">技能仓库</h3>
-            <a-tooltip
-              :title="skillPanelTip"
-              placement="bottomLeft"
-              :overlay-style="{ maxWidth: '440px' }"
-            >
+            <a-tooltip :title="skillPanelTip" placement="bottomLeft" :overlay-style="{ maxWidth: '440px' }">
               <Icon icon="i-mdi:information-outline" class="skill-panel__tip" tabindex="0" />
             </a-tooltip>
             <span class="skill-panel__count">共 {{ skillList.length }} 个</span>
@@ -19,7 +15,7 @@
           <a-input
             v-model:value="queryParams.keyword"
             class="skill-search"
-            placeholder="搜索技能标识 / 用途说明"
+            placeholder="搜索技能标识"
             allow-clear
             @press-enter="handleQuery"
           >
@@ -27,20 +23,13 @@
               <Icon icon="i-mdi:magnify" class="skill-search__icon" />
             </template>
           </a-input>
-          <a-select
-            v-model:value="queryParams.status"
-            class="skill-status-select"
-            placeholder="全部状态"
-            allow-clear
-          >
+          <a-select v-model:value="queryParams.status" class="skill-status-select" placeholder="全部状态" allow-clear>
             <a-select-option value="0">启用</a-select-option>
             <a-select-option value="1">停用</a-select-option>
           </a-select>
           <a-button type="primary" @click="handleQuery">查询</a-button>
           <a-button @click="resetQuery">重置</a-button>
-          <a-button type="primary" @click="handleAdd">
-            新增
-          </a-button>
+          <a-button type="primary" @click="handleAdd"> 新增 </a-button>
         </div>
       </header>
 
@@ -109,24 +98,49 @@
     >
       <a-form ref="formRef" :model="form" :rules="rules" :label-col="{ style: { width: '140px' } }">
         <a-form-item name="name">
-          <template #label><span class="wb-label-tip">技能标识
-            <a-tooltip v-if="form.id" title="技能标识创建后不可修改(已作为 AgentScope 的 skillId 使用)。"><Icon icon="i-mdi:information-outline" class="wb-label-tip__icon" /></a-tooltip>
-          </span></template>
-          <a-input v-model:value="form.name" :disabled="!!form.id" placeholder="如:weekly-report(小写字母开头,可含数字、下划线、短横线)" />
+          <template #label
+            ><span class="wb-label-tip"
+              >技能标识
+              <a-tooltip v-if="form.id" title="技能标识创建后不可修改(已作为 AgentScope 的 skillId 使用)。"
+                ><Icon icon="i-mdi:information-outline" class="wb-label-tip__icon"
+              /></a-tooltip> </span
+          ></template>
+          <a-input
+            v-model:value="form.name"
+            :disabled="!!form.id"
+            placeholder="如:weekly-report(小写字母开头,可含数字、下划线、短横线)"
+          />
         </a-form-item>
-        <a-form-item name="description">
-          <a-input v-model:value="form.description" placeholder="一句话说明该技能解决什么问题、何时使用——模型据此判断是否加载该技能" />
+        <a-form-item name="description" label="技能用途">
+          <a-input
+            v-model:value="form.description"
+            placeholder="一句话说明该技能解决什么问题、何时使用——模型据此判断是否加载该技能"
+          />
         </a-form-item>
         <a-form-item name="skillBody">
-          <template #label><span class="wb-label-tip">SKILL.md 正文
-            <a-tooltip title="frontmatter(name / description)由后端按上面的字段自动拼装,此处只写 Markdown 正文(步骤、约束、示例等)。"><Icon icon="i-mdi:information-outline" class="wb-label-tip__icon" /></a-tooltip>
-          </span></template>
-          <a-textarea v-model:value="form.skillBody" :rows="10" class="mono-textarea" :placeholder="skillBodyPlaceholder" />
+          <template #label
+            ><span class="wb-label-tip"
+              >SKILL.md 正文
+              <a-tooltip
+                title="frontmatter(name / description)由后端按上面的字段自动拼装,此处只写 Markdown 正文(步骤、约束、示例等)。"
+                ><Icon icon="i-mdi:information-outline" class="wb-label-tip__icon"
+              /></a-tooltip> </span
+          ></template>
+          <a-textarea
+            v-model:value="form.skillBody"
+            :rows="10"
+            class="mono-textarea"
+            :placeholder="skillBodyPlaceholder"
+          />
         </a-form-item>
         <a-form-item label="参考资料">
           <div class="resource-list">
             <div v-for="(item, index) in form.resources" :key="index" class="resource-item">
-              <a-input v-model:value="item.resourcePath" placeholder="相对路径,如 references/faq.md" style="width: 280px" />
+              <a-input
+                v-model:value="item.resourcePath"
+                placeholder="相对路径,如 references/faq.md"
+                style="width: 280px"
+              />
               <a-input v-model:value="item.resourceContent" placeholder="文件内容" class="resource-content" />
               <a-button danger type="link" @click="removeResource(index)">删除</a-button>
             </div>
@@ -177,9 +191,25 @@
 <script lang="ts" setup name="WorkbenchAgentSkill">
   import { onMounted, reactive, ref } from 'vue';
   import {
-    AButton, ACollapse, ACollapsePanel, ADescriptions, ADescriptionsItem, AEmpty, AForm,
-    AFormItem, AInput, ARadio, ARadioGroup, ASelect, ASelectOption, ASpin,
-    ATag, ATooltip, ATextarea, Modal, message,
+    AButton,
+    ACollapse,
+    ACollapsePanel,
+    ADescriptions,
+    ADescriptionsItem,
+    AEmpty,
+    AForm,
+    AFormItem,
+    AInput,
+    ARadio,
+    ARadioGroup,
+    ASelect,
+    ASelectOption,
+    ASpin,
+    ATag,
+    ATooltip,
+    ATextarea,
+    Modal,
+    message,
   } from '@/workbench/components/ant';
   import { Icon } from '@/core/components/Icon';
   import { BasicModal } from '@/core/components/Modal';
@@ -202,15 +232,30 @@
   const queryParams = reactive({ keyword: undefined as string | undefined, status: undefined as string | undefined });
   const dialog = reactive({ visible: false, title: '' });
   const preview = reactive<{ visible: boolean; row?: any; content: string; resources: any[] }>({
-    visible: false, row: undefined, content: '', resources: [],
+    visible: false,
+    row: undefined,
+    content: '',
+    resources: [],
   });
   const formRef = ref<any>();
   const form = ref<any>({});
-  const initFormData = { id: undefined, name: undefined, description: undefined, skillBody: undefined, status: '0', remark: undefined, resources: [] };
+  const initFormData = {
+    id: undefined,
+    name: undefined,
+    description: undefined,
+    skillBody: undefined,
+    status: '0',
+    remark: undefined,
+    resources: [],
+  };
   const rules: any = {
     name: [
       { required: true, message: '技能标识不能为空', trigger: 'blur' },
-      { pattern: /^[a-z][a-z0-9_-]{1,60}$/, message: '小写字母开头,仅含小写字母、数字、下划线或短横线,长度 2~61 位', trigger: 'blur' },
+      {
+        pattern: /^[a-z][a-z0-9_-]{1,60}$/,
+        message: '小写字母开头,仅含小写字母、数字、下划线或短横线,长度 2~61 位',
+        trigger: 'blur',
+      },
     ],
     description: [{ required: true, message: '用途说明不能为空', trigger: 'blur' }],
   };
@@ -223,26 +268,56 @@
     try {
       const res = await listSkill(queryParams);
       skillList.value = res?.rows ?? [];
-    } finally { loading.value = false; }
+    } finally {
+      loading.value = false;
+    }
+  };
+  const handleQuery = () => {
+    getList();
+  };
+  const resetQuery = () => {
+    queryParams.keyword = undefined;
+    queryParams.status = undefined;
+    getList();
+  };
+  const reset = () => {
+    form.value = { ...initFormData, resources: [] };
+    formRef.value?.resetFields?.();
+  };
+  const cancel = () => {
+    reset();
+    dialog.visible = false;
+  };
+  const handleAdd = () => {
+    reset();
+    dialog.title = '新增技能';
+    dialog.visible = true;
   };
-  const handleQuery = () => { getList(); };
-  const resetQuery = () => { queryParams.keyword = undefined; queryParams.status = undefined; getList(); };
-  const reset = () => { form.value = { ...initFormData, resources: [] }; formRef.value?.resetFields?.(); };
-  const cancel = () => { reset(); dialog.visible = false; };
-  const handleAdd = () => { reset(); dialog.title = '新增技能'; dialog.visible = true; };
   const handleUpdate = async (row: any) => {
     reset();
     const detail = await getSkill(row.id);
     form.value = {
-      id: detail?.id, name: detail?.name, description: detail?.description, skillBody: detail?.skillBody,
-      status: detail?.status ?? '0', remark: detail?.remark,
-      resources: (detail?.resources ?? []).map((item: any) => ({ resourcePath: item.resourcePath, resourceContent: item.resourceContent })),
+      id: detail?.id,
+      name: detail?.name,
+      description: detail?.description,
+      skillBody: detail?.skillBody,
+      status: detail?.status ?? '0',
+      remark: detail?.remark,
+      resources: (detail?.resources ?? []).map((item: any) => ({
+        resourcePath: item.resourcePath,
+        resourceContent: item.resourceContent,
+      })),
     };
     dialog.title = '修改技能';
     dialog.visible = true;
   };
-  const addResource = () => { form.value.resources = form.value.resources ?? []; form.value.resources.push({ resourcePath: '', resourceContent: '' }); };
-  const removeResource = (index: number) => { form.value.resources?.splice(index, 1); };
+  const addResource = () => {
+    form.value.resources = form.value.resources ?? [];
+    form.value.resources.push({ resourcePath: '', resourceContent: '' });
+  };
+  const removeResource = (index: number) => {
+    form.value.resources?.splice(index, 1);
+  };
   const handlePreview = async (row: any) => {
     if (row.id === undefined || row.id === null) return;
     const detail = await getSkill(row.id);
@@ -252,24 +327,38 @@
     preview.visible = true;
   };
   const submitForm = async () => {
-    try { await formRef.value?.validate(); } catch { return; }
+    try {
+      await formRef.value?.validate();
+    } catch {
+      return;
+    }
     buttonLoading.value = true;
     try {
       const payload = { ...form.value };
       payload.resources = (payload.resources ?? []).filter((item: any) => item.resourcePath);
-      if (payload.id) { await updateSkill(payload); message.success('修改成功'); }
-      else { delete payload.id; await addSkill(payload); message.success('新增成功'); }
+      if (payload.id) {
+        await updateSkill(payload);
+        message.success('修改成功');
+      } else {
+        delete payload.id;
+        await addSkill(payload);
+        message.success('新增成功');
+      }
       dialog.visible = false;
       await getList();
-    } finally { buttonLoading.value = false; }
+    } finally {
+      buttonLoading.value = false;
+    }
   };
   const handleDelete = async (row: any) => {
     const ok = await new Promise<boolean>((resolve) => {
       Modal.confirm({
         title: '提示',
         content: `是否确认删除技能「${row.name || row.id}」?参考资料将一并清理。`,
-        okText: '确定', cancelText: '取消',
-        onOk: () => resolve(true), onCancel: () => resolve(false),
+        okText: '确定',
+        cancelText: '取消',
+        onOk: () => resolve(true),
+        onCancel: () => resolve(false),
       });
     });
     if (!ok) return;
@@ -379,7 +468,7 @@
   }
 
   .skill-panel__tools :deep(.ant-btn) {
-    height: 32px;
+    height: 30px;
     padding: 0 14px;
     border-radius: 8px;
     font-size: 12px;

+ 23 - 9
ai-electron/frontend/src/workbench/views/audit/toolCall/index.vue

@@ -102,8 +102,16 @@
       <template #title>
         <div class="wb-toolbar">
           <div class="wb-table-heading">
-            <h3>工具调用明细</h3>
-            <p>逐个记录智能体对业务工具的调用过程,可按工具维度统计失败率,辅助判断工具定义是否合理。</p>
+            <div class="wb-table-heading__title-row">
+              <h3>工具调用明细</h3>
+              <a-tooltip
+                title="逐个记录智能体对业务工具的调用过程,可按工具维度统计失败率,辅助判断工具定义是否合理。"
+                placement="bottomLeft"
+                :overlay-style="{ maxWidth: '460px' }"
+              >
+                <Icon icon="i-mdi:information-outline" class="wb-table-heading__tip" tabindex="0" />
+              </a-tooltip>
+            </div>
           </div>
           <div class="wb-toolbar__actions">
             <a-button @click="getList">刷新</a-button>
@@ -239,6 +247,7 @@
     ASelectOption,
     ATable,
     ATag,
+    ATooltip,
   } from '@/workbench/components/ant';
   import BasicModal from '@/core/components/Modal/src/BasicModal.vue';
   import { Icon } from '@/core/components/Icon';
@@ -450,19 +459,24 @@
     }
   }
 
+  .wb-table-heading__title-row {
+    display: flex;
+    align-items: center;
+    gap: 6px;
+  }
+
+  .wb-table-heading__tip {
+    color: #98a2b3;
+    font-size: 16px;
+    cursor: help;
+  }
+
   .wb-table-heading h3 {
     margin: 0;
     font-size: 15px;
     font-weight: 600;
   }
 
-  .wb-table-heading p {
-    margin: 4px 0 0;
-    color: var(--wb-text-2);
-    font-size: 13px;
-    line-height: 1.6;
-  }
-
   .text-danger {
     color: var(--wb-error);
   }

+ 4 - 3
ai-electron/frontend/src/workbench/views/chat/index.vue

@@ -4687,7 +4687,7 @@
 
   .composer-actions-right {
     :deep(.ant-btn) {
-      height: 32px;
+      height: 30px;
       padding: 0 16px;
       border-radius: 10px;
       font-size: 13px;
@@ -4699,10 +4699,11 @@
       display: inline-flex;
       align-items: center;
       justify-content: center;
-      width: 32px;
+      width: 30px;
+      height: 30px;
       padding: 0;
       border-radius: 50% !important;
-      font-size: 16px;
+      font-size: 15px;
     }
 
     :deep(.ant-btn-primary) {

+ 14 - 23
ai-electron/frontend/src/workbench/views/kb/base/index.vue

@@ -5,11 +5,7 @@
         <div class="kb-panel__heading">
           <div class="kb-panel__title-row">
             <h3 class="kb-panel__title">知识库</h3>
-            <a-tooltip
-              :title="kbPanelTip"
-              placement="bottomLeft"
-              :overlay-style="{ maxWidth: '460px' }"
-            >
+            <a-tooltip :title="kbPanelTip" placement="bottomLeft" :overlay-style="{ maxWidth: '460px' }">
               <Icon icon="i-mdi:information-outline" class="kb-panel__tip" tabindex="0" />
             </a-tooltip>
             <span class="kb-panel__count">共 {{ kbList.length }} 个</span>
@@ -27,20 +23,13 @@
               <Icon icon="i-mdi:magnify" class="kb-search__icon" />
             </template>
           </a-input>
-          <a-select
-            v-model:value="queryParams.status"
-            class="kb-status-select"
-            placeholder="全部状态"
-            allow-clear
-          >
+          <a-select v-model:value="queryParams.status" class="kb-status-select" placeholder="全部状态" allow-clear>
             <a-select-option value="0">正常</a-select-option>
             <a-select-option value="1">停用</a-select-option>
           </a-select>
           <a-button type="primary" @click="handleQuery">查询</a-button>
           <a-button @click="resetQuery">重置</a-button>
-          <a-button type="primary" @click="handleAdd">
-            新增
-          </a-button>
+          <a-button type="primary" @click="handleAdd"> 新增 </a-button>
         </div>
       </header>
 
@@ -82,23 +71,25 @@
                     <a-tag :color="record.retrievalMode === 'hybrid' ? 'warning' : 'default'">
                       {{ record.retrievalMode === 'hybrid' ? '向量 + BM25' : '向量' }}
                     </a-tag>
-                    <a-tag
-                      v-if="record.retrievalMode === 'hybrid'"
-                      :color="bm25StatusType(record.bm25IndexStatus)"
-                    >
+                    <a-tag v-if="record.retrievalMode === 'hybrid'" :color="bm25StatusType(record.bm25IndexStatus)">
                       {{ bm25StatusLabel(record.bm25IndexStatus) }}
                     </a-tag>
                   </span>
                 </div>
                 <div class="kb-card__meta-item">
                   <span class="kb-card__meta-label">检索重排</span>
-                  <span class="kb-card__meta-value" :title="record.rerankEnabled === '1' ? record.rerankModelName || '' : ''">
+                  <span
+                    class="kb-card__meta-value"
+                    :title="record.rerankEnabled === '1' ? record.rerankModelName || '' : ''"
+                  >
                     {{ record.rerankEnabled === '1' ? record.rerankModelName || '已启用(未绑模型)' : '未启用' }}
                   </span>
                 </div>
                 <div class="kb-card__meta-item">
                   <span class="kb-card__meta-label">切片 / 重叠</span>
-                  <span class="kb-card__meta-value">{{ record.chunkSize ?? '-' }} / {{ record.chunkOverlap ?? '-' }}</span>
+                  <span class="kb-card__meta-value"
+                    >{{ record.chunkSize ?? '-' }} / {{ record.chunkOverlap ?? '-' }}</span
+                  >
                 </div>
                 <div class="kb-card__meta-item">
                   <span class="kb-card__meta-label">召回 TopK</span>
@@ -189,7 +180,7 @@
           <template #label>
             <span class="wb-label-tip">
               向量维度
-              <a-tooltip title="留空则取向量模型配置的维度">
+              <a-tooltip title="默认 1024;选择向量模型后自动带出模型维度,留空则由后端取模型配置维度">
                 <Icon icon="i-mdi:information-outline" class="wb-label-tip__icon" tabindex="0" />
               </a-tooltip>
             </span>
@@ -395,7 +386,7 @@
     kbCode: undefined,
     description: undefined,
     embeddingModelId: undefined,
-    dimension: undefined,
+    dimension: 1024,
     chunkSize: 500,
     chunkOverlap: 50,
     retrievalTopK: 5,
@@ -713,7 +704,7 @@
   }
 
   .kb-panel__tools :deep(.ant-btn) {
-    height: 32px;
+    height: 30px;
     padding: 0 14px;
     border-radius: 8px;
     font-size: 12px;

+ 4 - 10
ai-electron/frontend/src/workbench/views/kb/doc/index.vue

@@ -97,9 +97,7 @@
               :custom-request="handleCustomUpload"
               :disabled="!queryParams.kbId"
             >
-              <a-button type="primary" :disabled="!queryParams.kbId">
-                上传文档
-              </a-button>
+              <a-button type="primary" :disabled="!queryParams.kbId"> 上传文档 </a-button>
             </a-upload>
             <a-dropdown :trigger="['click']" :disabled="!selectedRowKeys.length">
               <a-button :disabled="!selectedRowKeys.length">批量处理</a-button>
@@ -115,9 +113,7 @@
                 </a-menu>
               </template>
             </a-dropdown>
-            <a-button danger :disabled="!selectedRowKeys.length" @click="handleDelete()">
-              删除
-            </a-button>
+            <a-button danger :disabled="!selectedRowKeys.length" @click="handleDelete()"> 删除 </a-button>
           </div>
         </div>
       </template>
@@ -183,9 +179,7 @@
                   </a-button>
                 </a-tooltip>
                 <a-tooltip title="删除">
-                  <a-button danger type="link" size="small" @click="handleDelete(record)">
-                    删除
-                  </a-button>
+                  <a-button danger type="link" size="small" @click="handleDelete(record)"> 删除 </a-button>
                 </a-tooltip>
               </div>
             </template>
@@ -1002,7 +996,7 @@
   }
 
   .kb-doc-card-actions :deep(.ant-btn) {
-    height: 32px;
+    height: 30px;
     padding: 0 14px;
     border-radius: 8px;
     font-size: 12px;

+ 1 - 1
ai-electron/frontend/src/workbench/views/kb/retrieval/index.vue

@@ -372,7 +372,7 @@
   }
 
   .kb-retrieval-card-actions :deep(.ant-btn) {
-    height: 32px;
+    height: 30px;
     padding: 0 14px;
     border-radius: 8px;
     font-size: 12px;

+ 32 - 17
ai-electron/frontend/src/workbench/views/model/config/index.vue

@@ -5,11 +5,7 @@
         <div class="model-panel__heading">
           <div class="model-panel__title-row">
             <h3 class="model-panel__title">模型配置</h3>
-            <a-tooltip
-              :title="modelPanelTip"
-              placement="bottomLeft"
-              :overlay-style="{ maxWidth: '440px' }"
-            >
+            <a-tooltip :title="modelPanelTip" placement="bottomLeft" :overlay-style="{ maxWidth: '440px' }">
               <Icon icon="i-mdi:information-outline" class="model-panel__tip" tabindex="0" />
             </a-tooltip>
             <span class="model-panel__count">共 {{ configList.length }} 个</span>
@@ -29,9 +25,7 @@
           </a-input>
           <a-button type="primary" @click="handleQuery">查询</a-button>
           <a-button @click="resetQuery">重置</a-button>
-          <a-button type="primary" @click="handleAdd">
-            新增
-          </a-button>
+          <a-button type="primary" @click="handleAdd"> 新增 </a-button>
         </div>
       </header>
 
@@ -124,8 +118,15 @@
           <a-input v-model:value="form.configName" placeholder="如:通义千问 Plus" />
         </a-form-item>
         <a-form-item label="提供商" name="provider">
-          <a-select v-model:value="form.provider" placeholder="请选择提供商" style="width: 100%" @change="handleProviderChange">
-            <a-select-option v-for="item in providerOptions" :key="item.value" :value="item.value">{{ item.label }}</a-select-option>
+          <a-select
+            v-model:value="form.provider"
+            placeholder="请选择提供商"
+            style="width: 100%"
+            @change="handleProviderChange"
+          >
+            <a-select-option v-for="item in providerOptions" :key="item.value" :value="item.value">{{
+              item.label
+            }}</a-select-option>
           </a-select>
         </a-form-item>
         <a-form-item label="模型类型" name="modelType">
@@ -147,7 +148,10 @@
           <a-input v-model:value="form.baseUrl" :placeholder="'OpenAI 兼容根地址,如 https://api.deepseek.com/v1'" />
         </a-form-item>
         <a-form-item label="API 密钥">
-          <a-input-password v-model:value="form.apiKey" :placeholder="form.id ? '留空表示不修改已保存的密钥' : '请输入 API 密钥,本地 Ollama 可留空'" />
+          <a-input-password
+            v-model:value="form.apiKey"
+            :placeholder="form.id ? '留空表示不修改已保存的密钥' : '请输入 API 密钥,本地 Ollama 可留空'"
+          />
         </a-form-item>
         <a-form-item v-if="isEmbeddingForm" label="向量维度">
           <a-input-number v-model:value="form.dimension" :min="1" :max="65536" />
@@ -203,13 +207,18 @@
           <a-descriptions-item label="提供商">{{ providerLabel(detail.record.provider) }}</a-descriptions-item>
           <a-descriptions-item label="模型类型">{{ modelTypeLabel(detail.record.modelType) }}</a-descriptions-item>
           <a-descriptions-item label="模型标识">{{ detail.record.modelCode || '-' }}</a-descriptions-item>
-          <a-descriptions-item label="支持视觉">{{ detail.record.modelType !== 'chat' ? '-' : detail.record.supportsVision === '0' ? '否' : '是' }}</a-descriptions-item>
+          <a-descriptions-item label="支持视觉">{{
+            detail.record.modelType !== 'chat' ? '-' : detail.record.supportsVision === '0' ? '否' : '是'
+          }}</a-descriptions-item>
           <a-descriptions-item label="密钥">{{ detail.record.apiKeyMask || '未配置' }}</a-descriptions-item>
           <a-descriptions-item label="服务地址" :span="2">{{ detail.record.baseUrl || '-' }}</a-descriptions-item>
           <a-descriptions-item label="向量维度">{{ detail.record.dimension ?? '-' }}</a-descriptions-item>
           <a-descriptions-item label="超时(秒)">{{ detail.record.timeoutSeconds ?? '-' }}</a-descriptions-item>
           <a-descriptions-item label="重试次数">{{ detail.record.maxRetries ?? '-' }}</a-descriptions-item>
-          <a-descriptions-item label="单价">输入:{{ detail.record.inputPrice ?? '-' }};输出:{{ detail.record.outputPrice ?? '-' }}(元 / 千 Token)</a-descriptions-item>
+          <a-descriptions-item label="单价"
+            >输入:{{ detail.record.inputPrice ?? '-' }};输出:{{ detail.record.outputPrice ?? '-' }}(元 / 千
+            Token)</a-descriptions-item
+          >
           <a-descriptions-item label="备注" :span="2">{{ detail.record.remark || '-' }}</a-descriptions-item>
           <a-descriptions-item label="创建时间">{{ detail.record.createTime || '-' }}</a-descriptions-item>
           <a-descriptions-item label="更新时间">{{ detail.record.updateTime || '-' }}</a-descriptions-item>
@@ -257,7 +266,11 @@
 
   const PROVIDER_OPTIONS = [
     { label: 'OpenAI', value: 'openai', baseUrl: 'https://api.openai.com/v1' },
-    { label: '阿里云百炼(DashScope)', value: 'dashscope', baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1' },
+    {
+      label: '阿里云百炼(DashScope)',
+      value: 'dashscope',
+      baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
+    },
     { label: 'DeepSeek', value: 'deepseek', baseUrl: 'https://api.deepseek.com/v1' },
     { label: '智谱 GLM', value: 'glm', baseUrl: 'https://open.bigmodel.cn/api/paas/v4' },
     { label: '本地 Ollama', value: 'ollama', baseUrl: 'http://127.0.0.1:11434/v1' },
@@ -315,8 +328,10 @@
     dimension: isEmbeddingForm.value ? [{ required: true, message: '向量模型必须填写向量维度', trigger: 'blur' }] : [],
   }));
 
-  const providerLabel = (value?: string) => PROVIDER_OPTIONS.find((item) => item.value === value)?.label ?? value ?? '-';
-  const modelTypeLabel = (value?: string) => MODEL_TYPE_OPTIONS.find((item) => item.value === value)?.label ?? value ?? '-';
+  const providerLabel = (value?: string) =>
+    PROVIDER_OPTIONS.find((item) => item.value === value)?.label ?? value ?? '-';
+  const modelTypeLabel = (value?: string) =>
+    MODEL_TYPE_OPTIONS.find((item) => item.value === value)?.label ?? value ?? '-';
   const modelTypeTag = (value?: string) =>
     value === 'embedding' ? 'warning' : value === 'rerank' ? 'purple' : 'success';
 
@@ -534,7 +549,7 @@
   }
 
   .model-panel__tools :deep(.ant-btn) {
-    height: 32px;
+    height: 30px;
     padding: 0 14px;
     border-radius: 8px;
     font-size: 12px;

+ 52 - 53
ai-server/src/main/java/com/zsjz/ai/module/ai/controller/AiMemoryController.java

@@ -17,6 +17,7 @@ import com.zsjz.ai.module.ai.domain.vo.AiMemoryVersionVo;
 import com.zsjz.ai.module.ai.service.IAiMemoryService;
 import com.zsjz.ai.common.compat.R;
 import com.zsjz.ai.common.compat.BaseController;
+import com.zsjz.ai.common.compat.LoginHelper;
 import com.zsjz.ai.common.compat.ServiceException;
 import com.zsjz.ai.common.context.CaseContextHolder;
 import org.springframework.validation.annotation.Validated;
@@ -69,128 +70,114 @@ public class AiMemoryController extends BaseController {
     }
 
     /**
-     * 查询指定案件、智能体与用户下的记忆文件清单
+     * 查询当前登录用户在当前案件、指定智能体下的记忆文件清单
      *
      * @param caseId  案件主键(缺省取当前打开的案件)
      * @param agentId 智能体主键
-     * @param userId  记忆归属用户主键
      */
         @GetMapping("/files")
     public R<List<AiMemoryFileVo>> listFiles(@RequestParam(required = false) Long caseId,
-                                             @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                                             @NotNull(message = "用户不能为空") @RequestParam Long userId) {
-        return R.ok(memoryService.listFiles(resolveCaseId(caseId), agentId, userId));
+                                             @NotNull(message = "智能体不能为空") @RequestParam Long agentId) {
+        return R.ok(memoryService.listFiles(resolveCaseId(caseId), agentId, currentUserId()));
     }
 
     /**
-     * 读取记忆文件内容
+     * 读取当前登录用户的记忆文件内容
      *
      * @param caseId  案件主键(缺省取当前打开的案件)
      * @param agentId 智能体主键
-     * @param userId  记忆归属用户主键
      * @param path    工作区相对路径
      */
         @GetMapping("/content")
     public R<AiMemoryContentVo> readContent(@RequestParam(required = false) Long caseId,
                                             @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                                            @NotNull(message = "用户不能为空") @RequestParam Long userId,
                                             @NotNull(message = "文件路径不能为空") @RequestParam String path) {
-        return R.ok(memoryService.readContent(resolveCaseId(caseId), agentId, userId, path));
+        return R.ok(memoryService.readContent(resolveCaseId(caseId), agentId, currentUserId(), path));
     }
 
     /**
-     * 保存记忆文件内容(人工编辑)
+     * 保存当前登录用户的记忆文件内容(人工编辑)
      */
             @PutMapping("/content")
     public R<Void> writeContent(@Validated @RequestBody AiMemoryContentBo bo) {
         bo.setCaseId(resolveCaseId(bo.getCaseId()));
+        // 记忆只允许本人读写:忽略请求体中的 userId,强制使用当前登录用户
+        bo.setUserId(currentUserId());
         memoryService.writeContent(bo);
         return R.ok();
     }
 
     /**
-     * 手动触发记忆合并(把每日流水合并进 MEMORY.md)
+     * 手动触发当前登录用户的记忆合并(把每日流水合并进 MEMORY.md)
      *
      * @param caseId  案件主键(缺省取当前打开的案件)
      * @param agentId 智能体主键
-     * @param userId  记忆归属用户主键
      */
             @PostMapping("/consolidate")
     public R<Void> consolidate(@RequestParam(required = false) Long caseId,
-                               @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                               @NotNull(message = "用户不能为空") @RequestParam Long userId) {
-        memoryService.consolidate(resolveCaseId(caseId), agentId, userId);
+                               @NotNull(message = "智能体不能为空") @RequestParam Long agentId) {
+        memoryService.consolidate(resolveCaseId(caseId), agentId, currentUserId());
         return R.ok();
     }
 
     /**
-     * 归档超期流水(移动到记忆目录下的 archive/ 子目录)
+     * 归档当前登录用户的超期流水(移动到记忆目录下的 archive/ 子目录)
      *
      * @param caseId  案件主键(缺省取当前打开的案件)
      * @param agentId 智能体主键
-     * @param userId  记忆归属用户主键
      */
             @PostMapping("/archive")
     public R<Integer> archive(@RequestParam(required = false) Long caseId,
-                              @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                              @NotNull(message = "用户不能为空") @RequestParam Long userId) {
-        return R.ok(memoryService.archiveDaily(resolveCaseId(caseId), agentId, userId));
+                              @NotNull(message = "智能体不能为空") @RequestParam Long agentId) {
+        return R.ok(memoryService.archiveDaily(resolveCaseId(caseId), agentId, currentUserId()));
     }
 
     /**
-     * 清理超期记忆文件与会话日志
+     * 清理当前登录用户的超期记忆文件与会话日志
      *
      * @param caseId  案件主键(缺省取当前打开的案件)
      * @param agentId 智能体主键
-     * @param userId  记忆归属用户主键
      */
             @PostMapping("/cleanup")
     public R<Integer> cleanup(@RequestParam(required = false) Long caseId,
-                              @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                              @NotNull(message = "用户不能为空") @RequestParam Long userId) {
-        return R.ok(memoryService.cleanup(resolveCaseId(caseId), agentId, userId));
+                              @NotNull(message = "智能体不能为空") @RequestParam Long agentId) {
+        return R.ok(memoryService.cleanup(resolveCaseId(caseId), agentId, currentUserId()));
     }
 
     /**
-     * 查询某用户的记忆规模与维护状态(记忆后端不可用时返回空统计,不影响页面)
+     * 查询当前登录用户的记忆规模与维护状态(记忆后端不可用时返回空统计,不影响页面)
      *
      * @param caseId 案件主键(缺省取当前打开的案件)
-     * @param userId 记忆归属用户主键
      */
         @GetMapping("/stats")
-    public R<MemoryBackendStats> stats(@RequestParam(required = false) Long caseId,
-                                       @NotNull(message = "用户不能为空") @RequestParam Long userId) {
-        return R.ok(memoryBackend.stats(resolveCaseId(caseId), userId));
+    public R<MemoryBackendStats> stats(@RequestParam(required = false) Long caseId) {
+        return R.ok(memoryBackend.stats(resolveCaseId(caseId), currentUserId()));
     }
 
     /**
-     * 查询近 N 天的记忆运行健康指标(抽取、合并、失败数)
+     * 查询当前登录用户近 N 天的记忆运行健康指标(抽取、合并、失败数)
      *
      * @param caseId  案件主键(缺省取当前打开的案件)
      * @param agentId 工作区归属智能体主键(缺省为当前入口智能体)
-     * @param userId  记忆归属用户主键
      * @param days    统计窗口(天,默认 1,最大 30)
      */
         @GetMapping("/quality")
     public R<AiMemoryQualityVo> quality(@RequestParam(required = false) Long caseId,
                                         @RequestParam(required = false) Long agentId,
-                                        @NotNull(message = "用户不能为空") @RequestParam Long userId,
                                         @RequestParam(defaultValue = "1") Integer days) {
-        return R.ok(memoryService.quality(resolveCaseId(caseId), agentId, userId, days));
+        return R.ok(memoryService.quality(resolveCaseId(caseId), agentId, currentUserId(), days));
     }
 
     /**
-     * 查询用户的显式记忆(用户明确要求记住的条目)
+     * 查询当前登录用户的显式记忆(用户明确要求记住的条目)
      *
      * @param caseId  案件主键(缺省取当前打开的案件)
      * @param agentId 智能体主键
-     * @param userId  记忆归属用户主键
      */
         @GetMapping("/declared")
     public R<List<AiMemoryDeclaredVo>> listDeclared(@RequestParam(required = false) Long caseId,
-                                                    @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                                                    @NotNull(message = "用户不能为空") @RequestParam Long userId) {
-        return R.ok(memoryService.listDeclared(resolveCaseId(caseId), agentId, userId));
+                                                    @NotNull(message = "智能体不能为空") @RequestParam Long agentId) {
+        return R.ok(memoryService.listDeclared(resolveCaseId(caseId), agentId, currentUserId()));
     }
 
     /**
@@ -199,28 +186,28 @@ public class AiMemoryController extends BaseController {
             @PostMapping("/declared")
     public R<AiMemoryDeclaredVo> addDeclared(@Validated @RequestBody AiMemoryDeclaredBo bo) {
         bo.setCaseId(resolveCaseId(bo.getCaseId()));
+        // 显式记忆同样只归属于当前登录用户
+        bo.setUserId(currentUserId());
         return R.ok(memoryService.addDeclared(bo));
     }
 
     /**
-     * 撤销一条显式记忆
+     * 撤销当前登录用户的一条显式记忆
      */
             @DeleteMapping("/declared/{entryId}")
     public R<Boolean> revokeDeclared(@RequestParam(required = false) Long caseId,
                                      @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                                     @NotNull(message = "用户不能为空") @RequestParam Long userId,
                                      @PathVariable String entryId) {
-        return R.ok(memoryService.revokeDeclared(resolveCaseId(caseId), agentId, userId, entryId));
+        return R.ok(memoryService.revokeDeclared(resolveCaseId(caseId), agentId, currentUserId(), entryId));
     }
 
     /**
-     * 列出 MEMORY.md 历史版本
+     * 列出当前登录用户的 MEMORY.md 历史版本
      */
         @GetMapping("/versions")
     public R<List<AiMemoryVersionVo>> listVersions(@RequestParam(required = false) Long caseId,
-                                                   @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                                                   @NotNull(message = "用户不能为空") @RequestParam Long userId) {
-        return R.ok(memoryService.listVersions(resolveCaseId(caseId), agentId, userId));
+                                                   @NotNull(message = "智能体不能为空") @RequestParam Long agentId) {
+        return R.ok(memoryService.listVersions(resolveCaseId(caseId), agentId, currentUserId()));
     }
 
     /**
@@ -229,9 +216,8 @@ public class AiMemoryController extends BaseController {
         @GetMapping("/versions/{versionId}")
     public R<AiMemoryVersionVo> readVersion(@RequestParam(required = false) Long caseId,
                                             @NotNull(message = "智能体不能为空") @RequestParam Long agentId,
-                                            @NotNull(message = "用户不能为空") @RequestParam Long userId,
                                             @PathVariable String versionId) {
-        return R.ok(memoryService.readVersion(resolveCaseId(caseId), agentId, userId, versionId));
+        return R.ok(memoryService.readVersion(resolveCaseId(caseId), agentId, currentUserId(), versionId));
     }
 
     /**
@@ -241,24 +227,37 @@ public class AiMemoryController extends BaseController {
     public R<AiMemoryVersionVo> restoreVersion(@PathVariable String versionId,
                                                @Validated @RequestBody AiMemoryRestoreBo bo) {
         bo.setCaseId(resolveCaseId(bo.getCaseId()));
+        bo.setUserId(currentUserId());
         return R.ok(memoryService.restoreVersion(bo.getCaseId(), bo.getAgentId(), bo.getUserId(), versionId,
             bo.getMode(), bo.getNote()));
     }
 
     /**
-     * 删除某用户的全部长期记忆(回滚 / 合规删除)
+     * 删除当前登录用户的全部长期记忆(回滚 / 合规删除)
      *
      * @param caseId  案件主键(缺省取当前打开的案件)
      * @param agentId 智能体主键
-     * @param userId  记忆归属用户主键
      */
-            @DeleteMapping("/{agentId}/{userId}")
+            @DeleteMapping("/{agentId}")
     public R<Void> remove(@RequestParam(required = false) Long caseId,
-                          @PathVariable Long agentId, @PathVariable Long userId) {
-        memoryService.deleteAll(resolveCaseId(caseId), agentId, userId);
+                          @PathVariable Long agentId) {
+        memoryService.deleteAll(resolveCaseId(caseId), agentId, currentUserId());
         return R.ok();
     }
 
+    /**
+     * 当前登录用户:长期记忆只允许本人访问,请求参数中的 userId 一律不作为授权依据。
+     *
+     * @return 当前登录用户主键
+     */
+    private Long currentUserId() {
+        Long userId = LoginHelper.getUserId();
+        if (userId == null) {
+            throw new ServiceException("未登录或登录已过期");
+        }
+        return userId;
+    }
+
     /**
      * 解析记忆查询的案件:显式参数优先,用户侧缺省取当前打开的案件。
      *

+ 1 - 2
ai-server/src/main/java/com/zsjz/ai/module/ai/domain/bo/AiMemoryContentBo.java

@@ -30,9 +30,8 @@ public class AiMemoryContentBo implements Serializable {
     private Long agentId;
 
     /**
-     * 记忆归属用户主键(记忆按用户隔离)
+     * 记忆归属用户主键(服务端强制为当前登录用户,请求值不参与授权)
      */
-    @NotNull(message = "用户不能为空")
     private Long userId;
 
     /**

+ 1 - 2
ai-server/src/main/java/com/zsjz/ai/module/ai/domain/bo/AiMemoryDeclaredBo.java

@@ -31,9 +31,8 @@ public class AiMemoryDeclaredBo implements Serializable {
     private Long agentId;
 
     /**
-     * 记忆归属用户主键
+     * 记忆归属用户主键(服务端强制为当前登录用户,请求值不参与授权)
      */
-    @NotNull(message = "用户不能为空")
     private Long userId;
 
     /**

+ 3 - 1
ai-server/src/main/java/com/zsjz/ai/module/ai/domain/bo/AiMemoryRestoreBo.java

@@ -28,7 +28,9 @@ public class AiMemoryRestoreBo implements Serializable {
     @NotNull(message = "智能体不能为空")
     private Long agentId;
 
-    @NotNull(message = "用户不能为空")
+    /**
+     * 记忆归属用户主键(服务端强制为当前登录用户,请求值不参与授权)
+     */
     private Long userId;
 
     /**