Commit Graph
12 Commits
Author SHA1 Message Date
thzxx d9e9416d35 feat: 工作空间与 AI Tool Calling 深度集成
核心变更:
- 新增 execWorkspaceCommand() 无超时进程执行(workspace.ts)
- 新增 workspace:execTool IPC 通道(无超时,5MB 输出上限)
- run_command 工具改用 workspace IPC,移除 30s 超时限制
- run_command 默认启用(需用户确认),AI 上下文注入工作空间目录
- Agent Loop 工具执行:run_command 无超时,其他工具保持 30s
- Agent 系统提示词新增工作空间规则(userTerminated/truncated 反馈)

UI 修复:
- Header z-index 提升至 50,Model Bar 提升至 40,Input Area 提升至 30
- 工作空间面板 top 调整为 90px(header + model-bar),不再遮挡菜单
- Input Area 增加 position: relative 确保 z-index 生效

其他:
- 新增 docs/DEVELOPMENT.md 开发规范文档
- 设置面板 run_command 开关文案优化,默认值改为 true
2026-04-07 22:24:58 +08:00
thzxx 0e1f216aa4 feat: 添加工作空间面板 - 右侧终端/文件浏览器
- 新增主进程 workspace.ts:spawn 进程管理,流式输出,安全检查
- IPC 双向通信:workspace:exec(on/send 模式,无超时限制)
- preload 暴露 workspace API
- 渲染进程 workspace-panel.ts:多终端 Tab、ANSI 颜色渲染、文件浏览器
- 设置面板添加工作空间目录配置
- 启动时自动创建 workspace 目录
- 窗口关闭时自动清理所有子进程
- 帮助文档更新
2026-04-07 18:30:45 +08:00
thzxx 4dcbb4f1e9 fix: 修复 importSessions 中 result 变量重复声明导致编译失败 2026-04-07 02:10:01 +08:00
thzxx 60152fb443 refactor: 清理渲染进程全部 58 处 console.log/warn/error
- 所有错误日志统一走 logService(logError/logWarn/logInfo)
- 无 logService 的地方补上对应调用
- 纯调试 trace 直接删除(桌面应用看不到 console)
- ollama.ts 流式解析错误改为静默跳过(非关键)
- 执行日志面板信息量不变
2026-04-07 01:42:56 +08:00
thzxx 02d5ff19c7 feat: 文件对话框全部改用 Electron 原生对话框
- input-area.ts: 图片/文件上传改用 dialog.showOpenDialog(通过 IPC)
- settings-modal.ts: 导入改用原生打开对话框,导出改用原生保存对话框
- kb-modal.ts: 知识库文档上传改用原生打开对话框
- ipc.ts/preload.ts/types.d.ts: writeFile 增加 encoding 参数支持二进制写入
- index.html: 移除 4 个无用的 <input type="file"> 元素
- 清理死代码: fileToBase64, fileToText, isMetonaFile
2026-04-07 01:33:51 +08:00
Metona Dev c516755a5c fix: 修复三个启动相关 Bug
Bug 1: prompt()/confirm() 在 Electron contextIsolation 下不可用
- 新增 prompt-modal.ts 自定义弹窗组件
- 替换 memory-panel.ts、kb-modal.ts、settings-modal.ts、history-modal.ts 中所有 prompt()/confirm() 调用

Bug 2: 日志面板重启后无日志
- log-service.ts 新增 earlyBuffer 缓冲 initLogPanel() 之前的日志
- initLogPanel() 初始化时 flush earlyBuffer 到 DOM
- main.ts 中 initLogPanel() 移至最先初始化

Bug 3: 首次启动输入框可能被禁用
- main.ts init() 中防御性重置 IS_STREAMING/IS_HISTORY_VIEW/toolCallingEnabled 等状态
- catch 块也重置关键状态并初始化日志面板
2026-04-06 20:11:41 +08:00
Metona Fix af70054875 feat: 全量日志接入 + 日志服务重构(非阻塞)
log-service 重构:
- DOM 渲染改用 requestAnimationFrame 批量队列
- 全程 try-catch,任何异常都不阻塞主流程
- 新增 logConnection/logModel/logSession/logMemory/logRAG/logSetting/logIPC/logInit 便捷方法

全量接入(12 个文件):
- header.ts: 连接状态变化(connected/disconnected/error)
- model-bar.ts: 模型列表加载、模型切换、能力检测结果
- settings-modal.ts: 所有设置变更(系统提示词/上下文/温度/工具调用/命令执行/记忆)、显存释放、导出/导入
- tool-confirm-modal.ts: 工具确认弹窗、确认/取消操作
- memory-manager.ts: 记忆初始化、新增/删除、自动提取
- tool-registry.ts: 工具执行异常
- rag.ts: 文档分块、向量检索
- kb-modal.ts: 知识库创建、文档上传、批量上传
- history-modal.ts: 会话加载、会话删除
- main.ts: 应用初始化各阶段、桌面集成、菜单/托盘操作、新建会话
- input-area.ts: 消息发送、流式完成/错误、文件/图片添加、Agent Loop 错误
2026-04-06 19:23:03 +08:00
Metona Fix 0f25921fb9 fix: 修复工具调用确认后卡死问题
根本原因:
1. 模型能力检测缺少 tools 检查 — gemma4 等模型不支持 Tool Calling 但代码允许启用
2. 流式调用无超时保护 — 模型无限思考时无法自动恢复
3. AbortController 竞态 — 确认对话框后状态同步问题

修复内容:
- 模型能力检测增加 tools 字段检查,模型栏显示 🔧 Tools 标签
- Agent Loop 流式调用增加 2 分钟单次超时保护
- 开启 Tool Calling 时自动检测模型兼容性并警告
- 设置面板开启 Tool Calling 时检查并提示不兼容模型
- 输入区域 Agent Loop 分支增加模型支持检测和用户提示
2026-04-06 19:02:34 +08:00
thzxx 18a24a2a59 refactor: remove Agent preset system, fix run_command enable bug
- Delete preset-manager.ts and preset-bar.ts
- Clean up all preset references from main.ts, types.d.ts, state.ts
- Remove preset modal HTML and CSS, rename temp-slider/modal-actions classes
- Fix run_command tool not being enabled (missing setToolEnabled call)
2026-04-06 15:44:27 +08:00
thzxx dc43db7d9c 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,新对话自动召回相关记忆
2026-04-06 13:44:45 +08:00
thzxx 5bfb137a8a feat: v3.0 Tool Calling — AI 本地文件操作系统
新增文件:
- src/main/tool-security.ts: 路径白名单/黑名单、命令安全检查
- src/main/tool-handlers.ts: 7个工具实现(read/write/list/search/create/delete/run)
- src/renderer/services/tool-registry.ts: 工具注册调度中心
- src/renderer/services/agent-engine.ts: Agent Loop 流式多轮工具调用引擎
- src/renderer/components/tool-confirm-modal.ts: 高风险操作确认对话框

修改文件:
- types.d.ts: 新增 ToolCall/ToolResult/ToolCallRecord 等类型
- ollama.ts: chatStream 支持 tools 参数
- ipc.ts: 新增 tool:execute/getConfig/setAllowedDirs IPC
- preload.ts: 暴露 tool API
- chat-area.ts: 渲染工具调用卡片
- input-area.ts: 集成 Agent Loop 引擎
- settings-modal.ts: 工具调用开关设置
- index.html: 工具调用设置面板 + 确认对话框 HTML
- style.css: 工具调用卡片、确认对话框样式
- main.ts: 初始化工具调用配置
2026-04-06 13:29:43 +08:00
thzxx 7ca0e33d77 feat: TypeScript + Electron v2 重构 - 纯桌面版
- 全面迁移到 TypeScript,严格类型定义
- 放弃 Web 版,专注 Electron 桌面应用
- 主进程模块化:main.ts, preload.ts, menu.ts, tray.ts, ipc.ts, utils.ts
- 渲染进程完整迁移所有功能组件
- 删除 PWA 相关文件 (sw.js, manifest.json)
- 删除 Web 版降级逻辑
- 保留所有核心功能:流式对话、多模型、Think推理、多模态、RAG知识库、Agent预设、历史管理
- 保留 Windows 11 Fluent Design 暗色主题样式
2026-04-06 03:04:20 +08:00