diff --git a/README.md b/README.md index 903fafd..9ae5ffa 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@
-
+
@@ -45,7 +45,7 @@
| 🌏 | **浏览器控制** | 打开网页 · 截图 · 执行 JS · 提取内容 · 点击 · 输入 · 滚动 · 关闭 |
| 🖥️ | **工作空间面板** | 终端(增量流式输出)+ 文件浏览器,命令安全检查 |
| 🔢 | **上下文长度手动控制** | 设置面板下拉选择(128K / 256K / 512K / 1M),默认 128K,模型栏显示当前配置值,下拉框中显示每个模型自身的上下文长度 |
-| 🗜️ | **智能上下文管理** | 滑动窗口 + Token 自动校准 + 消息重要性评分 + LLM 结构化 JSON 压缩,智能触发(120 条增量压缩 + 200 条硬上限) |
+| 🗜️ | **智能上下文管理** | 滑动窗口 + Token 自动校准 + 消息重要性评分 + LLM 结构化 JSON 压缩,智能触发(120 条增量压缩 + 300 条硬上限) |
| ⏱️ | **智能超时保护** | Agent Loop 看门狗(可配,默认 30min)+ 流式总超时(可配,默认 300s)+ 工具 HTTP/MCP 超时可配 |
| 🪝 | **Hook 系统** | 4 阶段生命周期钩子(pre_tool / post_tool / post_iteration / pre_completion),内置安全检查、文件去重、自动计划追踪、变更审计、结果校验 |
| 👥 | **子代理委派** | spawn_task 工具,独立上下文 + 超时保护 |
@@ -245,7 +245,7 @@ npm start
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ npm run dist
```
-产出:`release/Metona Ollama Setup v0.16.14.exe`
+产出:`release/Metona Ollama Setup v0.16.15.exe`
## 🛠️ 常用命令
@@ -286,7 +286,7 @@ npm run dist # 构建 Windows 安装包
| 🌏 | **Browser Control** | Open pages · Screenshot · JS execution · Content extraction · Click · Type · Scroll · Close |
| 🖥️ | **Workspace Panel** | Terminal (incremental streaming) + file browser, command security checks |
| 🔢 | **Manual Context Length** | Settings dropdown (128K / 256K / 512K / 1M), default 128K. Model bar shows configured value, dropdown shows per-model context length |
-| 🗜️ | **Smart Context Manager** | Sliding window + Token auto-calibration + message importance scoring + LLM structured JSON compression, smart triggers (120 msg incremental + 200 msg hard limit) |
+| 🗜️ | **Smart Context Manager** | Sliding window + Token auto-calibration + message importance scoring + LLM structured JSON compression, smart triggers (120 msg incremental + 300 msg hard limit) |
| ⏱️ | **Smart Timeout Protection** | Agent Loop watchdog (configurable, default 30min) + stream total timeout (configurable, default 300s) + configurable HTTP/MCP timeouts |
| 🪝 | **Hook System** | 4-phase lifecycle hooks (pre_tool / post_tool / post_iteration / pre_completion), built-in security check, file dedup, auto plan tracking, change audit, result validation |
| 👥 | **Sub-agent Delegation** | spawn_task tool, isolated context + timeout protection |
@@ -485,7 +485,7 @@ npm start
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ npm run dist
```
-Output: `release/Metona Ollama Setup v0.16.14.exe`
+Output: `release/Metona Ollama Setup v0.16.15.exe`
## 🛠️ Common Commands
diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md
index 6ecab69..e7c6666 100644
--- a/docs/DEVELOPMENT.md
+++ b/docs/DEVELOPMENT.md
@@ -205,7 +205,7 @@ INIT → THINKING → PARSING → EXECUTING → OBSERVING → REFLECTING → (CO
- 最大轮次:85(默认,设置面板可调)
- 自动重试:2 次(MAX_RETRIES)
- 看门狗超时:30 分钟(默认,可配)
-- 上下文硬上限:500 条消息
+- 上下文硬上限:300 条消息
- 流式超时:可配(默认 300s,0=禁用)
- HTTP 超时:可配(默认 30s)
- MCP 超时:可配(默认 60s)
diff --git a/package-lock.json b/package-lock.json
index fc73143..1e2e71a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "metona-ollama-desktop",
- "version": "0.16.14",
+ "version": "0.16.15",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "metona-ollama-desktop",
- "version": "0.16.14",
+ "version": "0.16.15",
"license": "MIT",
"dependencies": {
"ffmpeg-static": "^5.2.0",
diff --git a/package.json b/package.json
index 47652f5..f8debae 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "metona-ollama-desktop",
- "version": "0.16.14",
+ "version": "0.16.15",
"description": "Metona Ollama - TypeScript + Electron 桌面 AI 聊天客户端",
"main": "dist/main/main.js",
"author": "thzxx",
diff --git a/src/main/db/sqlite.ts b/src/main/db/sqlite.ts
index 83d54e0..e8b79c9 100644
--- a/src/main/db/sqlite.ts
+++ b/src/main/db/sqlite.ts
@@ -365,6 +365,22 @@ export function saveTrace(trace: TraceRow): string {
return trace.id;
}
+/** 批量保存轨迹 — 只触发一次 persist,避免逐条写盘 */
+export function saveTracesBatch(traces: TraceRow[]): number {
+ if (!traces.length) return 0;
+ const d = getDb();
+ runTransaction(d, () => {
+ for (const trace of traces) {
+ runExec(d, `INSERT OR REPLACE INTO traces (id, session_id, step_index, thought, action, action_input, observation, loop_count, error_pattern, created_at)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
+ [trace.id, trace.session_id, trace.step_index, trace.thought, trace.action, trace.action_input, trace.observation, trace.loop_count, trace.error_pattern, trace.created_at]
+ );
+ }
+ });
+ persist(); // 只写盘一次
+ return traces.length;
+}
+
export function getTracesBySession(sessionId: string): TraceRow[] {
return queryAll(getDb(), 'SELECT * FROM traces WHERE session_id = ? ORDER BY step_index ASC', [sessionId]) as unknown as TraceRow[];
}
diff --git a/src/main/ipc.ts b/src/main/ipc.ts
index 41e6949..fa21a29 100644
--- a/src/main/ipc.ts
+++ b/src/main/ipc.ts
@@ -12,7 +12,7 @@ import {
initDatabase, saveSession, getSession, getAllSessions, deleteSession, clearAllSessions,
saveMessage, getMessagesBySession,
saveSetting, getSetting, saveSettingsBatch,
- saveTrace, getTracesBySession,
+ saveTrace, saveTracesBatch, getTracesBySession,
exportAllSessions, importSessions,
getAllSessionsTokenStats
} from './db/sqlite.js';
@@ -383,6 +383,10 @@ export async function setupIPC(): Promise
Metona Ollama
- v0.16.14
+ v0.16.15