feat: Agent 记忆系统替代预设功能,全功能协调运作
核心改造: - 取消 Agent 预设(保留兼容),新增 AI Agent 记忆系统 - 自动提取 → 存储 → 检索 → 注入上下文的完整记忆闭环 - 记忆类型:事实/偏好/规则/事件,支持重要性评分和标签 新增文件: - services/memory-manager.ts: 记忆管理核心 - 关键词+标签+重要性加权检索 - 会话结束自动提取(LLM 驱动) - 去重检测、使用频率追踪 - components/memory-panel.ts: 记忆管理面板 UI 修改文件: - types.d.ts: 新增 MemoryEntry/MemorySearchResult 类型 - db/chat-db.ts: 升级 v2,新增 memories 存储 - input-area.ts: 对话流集成记忆检索+自动提取 - agent-engine.ts: Agent Loop 注入记忆上下文 - settings-modal.ts: 记忆开关设置 - main.ts: 记忆系统初始化 - index.html: 记忆设置面板 HTML - style.css: 记忆面板完整样式 功能协调: - 对话流: 记忆检索 → RAG 检索 → 系统提示词组合 → 流式对话 - Agent Loop: 记忆检索 → 系统提示词注入 → 工具调用循环 - 会话结束: 自动提取关键信息 → 存入记忆库 - 跨会话: 记忆持久化 IndexedDB,新对话自动召回相关记忆
This commit is contained in:
@@ -23,7 +23,9 @@ import { initKBModal } from './components/kb-modal.js';
|
||||
import { initPresetBar, initPresetModal } from './components/preset-bar.js';
|
||||
import { initPresetManager } from './services/preset-manager.js';
|
||||
import { initVectorStore } from './services/rag.js';
|
||||
import { initMemoryManager } from './services/memory-manager.js';
|
||||
import { initToolConfirmModal } from './components/tool-confirm-modal.js';
|
||||
import { initMemoryPanel } from './components/memory-panel.js';
|
||||
import type { ChatSession } from './types.js';
|
||||
|
||||
function initHelpModal(): void {
|
||||
@@ -157,6 +159,7 @@ async function init(): Promise<void> {
|
||||
initPresetModal();
|
||||
initHelpModal();
|
||||
initToolConfirmModal();
|
||||
initMemoryPanel();
|
||||
setupDesktopIntegration();
|
||||
|
||||
bindGlobalEvents();
|
||||
@@ -165,6 +168,7 @@ async function init(): Promise<void> {
|
||||
await loadModels();
|
||||
await initVectorStore();
|
||||
await initPresetManager();
|
||||
await initMemoryManager();
|
||||
|
||||
const savedModel = await db.getSetting('selectedModel', '');
|
||||
if (savedModel) {
|
||||
@@ -200,6 +204,10 @@ async function init(): Promise<void> {
|
||||
const toggleRC = document.querySelector<HTMLInputElement>('#toggleRunCommand');
|
||||
if (toggleRC) toggleRC.checked = runCommandEnabled;
|
||||
|
||||
// ── Agent 记忆设置 ──
|
||||
const memoryEnabled = await db.getSetting('memoryEnabled', true);
|
||||
state.set('memoryEnabled', memoryEnabled);
|
||||
|
||||
(document.querySelector('#chatInput') as HTMLElement)?.focus();
|
||||
|
||||
console.log('[App] 初始化完成');
|
||||
|
||||
Reference in New Issue
Block a user