qlogicagent 2.12.7 → 2.12.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +91 -157
  2. package/dist/agent.js +6 -6
  3. package/dist/cli.js +411 -426
  4. package/dist/index.js +410 -425
  5. package/dist/orchestration.js +6 -6
  6. package/dist/protocol.js +1 -1
  7. package/dist/types/agent/memory-recall-injection.d.ts +34 -0
  8. package/dist/types/agent/tool-loop/budget-continuation-policy.d.ts +22 -0
  9. package/dist/types/agent/tool-loop/completion-action-policy.d.ts +19 -0
  10. package/dist/types/agent/tool-loop/completion-stop-policy.d.ts +19 -0
  11. package/dist/types/agent/tool-loop/compression-pipeline.d.ts +44 -0
  12. package/dist/types/agent/tool-loop/skill-instruction-policy.d.ts +7 -0
  13. package/dist/types/agent/tool-loop/stream-error-recovery.d.ts +59 -0
  14. package/dist/types/agent/tool-loop/tool-failure-policy.d.ts +22 -0
  15. package/dist/types/agent/types.d.ts +2 -2
  16. package/dist/types/cli/acp-message-router.d.ts +8 -0
  17. package/dist/types/cli/acp-session-host.d.ts +20 -4
  18. package/dist/types/cli/cli-agent-builder.d.ts +1 -1
  19. package/dist/types/cli/core-tool-coordinator.d.ts +1 -0
  20. package/dist/types/cli/core-tools/config-tool-bootstrap.d.ts +1 -5
  21. package/dist/types/cli/core-tools/config-tool-service.d.ts +9 -5
  22. package/dist/types/cli/core-tools/registry.d.ts +1 -2
  23. package/dist/types/cli/core-tools/session-tool-manifest.d.ts +11 -0
  24. package/dist/types/cli/core-tools/team-registry.d.ts +8 -8
  25. package/dist/types/cli/core-tools/team-tool-service.d.ts +6 -3
  26. package/dist/types/cli/dev-tools/dev-tool-registry.d.ts +1 -2
  27. package/dist/types/cli/gateway-rpc-connection.d.ts +50 -0
  28. package/dist/types/cli/handlers/session-handler.d.ts +2 -1
  29. package/dist/types/cli/handlers/workflow-handler.d.ts +10 -0
  30. package/dist/types/cli/model-client-resolver.d.ts +12 -3
  31. package/dist/types/cli/resolved-agent-cache.d.ts +47 -0
  32. package/dist/types/cli/rpc-registry.d.ts +59 -5
  33. package/dist/types/cli/session-context.d.ts +32 -0
  34. package/dist/types/cli/skill-meta-tool-bootstrap.d.ts +7 -0
  35. package/dist/types/cli/stdio-acp-protocol-coordinator.d.ts +18 -0
  36. package/dist/types/cli/stdio-acp-request-host.d.ts +3 -0
  37. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +50 -0
  38. package/dist/types/cli/stdio-server.d.ts +103 -178
  39. package/dist/types/cli/stdio-session-runtime-coordinator.d.ts +19 -0
  40. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +30 -0
  41. package/dist/types/cli/tool-bootstrap-media-registration.d.ts +8 -0
  42. package/dist/types/cli/tool-bootstrap-paths.d.ts +7 -0
  43. package/dist/types/cli/tool-bootstrap-web-registration.d.ts +13 -0
  44. package/dist/types/cli/tool-bootstrap-workflow-registration.d.ts +7 -0
  45. package/dist/types/cli/tool-bootstrap.d.ts +5 -22
  46. package/dist/types/cli/tunable-store.d.ts +26 -0
  47. package/dist/types/cli/workflow-host-adapter.d.ts +29 -0
  48. package/dist/types/contracts/hooks.d.ts +6 -0
  49. package/dist/types/orchestration/workflow/run-history-store.d.ts +58 -0
  50. package/dist/types/orchestration/workflow/workflow-controller.d.ts +23 -1
  51. package/dist/types/orchestration/workflow/workflow-store.d.ts +24 -0
  52. package/dist/types/protocol/wire/acp-protocol.d.ts +1 -2
  53. package/dist/types/protocol/wire/gateway-rpc.d.ts +0 -112
  54. package/dist/types/runtime/config/tunable-defaults.d.ts +6 -0
  55. package/dist/types/runtime/infra/agent-paths.d.ts +0 -2
  56. package/dist/types/runtime/infra/agent-process.d.ts +12 -9
  57. package/dist/types/runtime/infra/default-path-service.d.ts +0 -1
  58. package/dist/types/runtime/infra/index.d.ts +1 -1
  59. package/dist/types/runtime/infra/key-pool.d.ts +1 -0
  60. package/dist/types/runtime/infra/llmrouter-catalog.d.ts +8 -0
  61. package/dist/types/runtime/ports/path-service.d.ts +0 -1
  62. package/dist/types/runtime/ports/tool-contracts.d.ts +1 -1
  63. package/dist/types/runtime/prompt/environment-context.d.ts +13 -0
  64. package/dist/types/runtime/prompt/index.d.ts +1 -0
  65. package/dist/types/runtime/prompt/prompt-policy.d.ts +2 -0
  66. package/dist/types/runtime/prompt/system-prompt-sections.d.ts +2 -0
  67. package/dist/types/runtime/session/session-catalog.d.ts +4 -0
  68. package/dist/types/runtime/session/session-metadata-store.d.ts +8 -0
  69. package/dist/types/runtime/session/session-paths.d.ts +9 -0
  70. package/dist/types/runtime/session/session-persistence.d.ts +14 -159
  71. package/dist/types/runtime/session/session-resume.d.ts +4 -0
  72. package/dist/types/runtime/session/session-schema.d.ts +10 -0
  73. package/dist/types/runtime/session/session-summary.d.ts +5 -0
  74. package/dist/types/runtime/session/session-transcript-store.d.ts +13 -0
  75. package/dist/types/runtime/session/session-types.d.ts +77 -0
  76. package/dist/types/runtime/session/session-write-queue.d.ts +2 -0
  77. package/dist/types/runtime/tasks/task-types.d.ts +1 -1
  78. package/dist/types/skills/mcp/index.d.ts +1 -3
  79. package/dist/types/skills/mcp/mcp-manager.d.ts +14 -38
  80. package/dist/types/skills/permissions/rule-engine.d.ts +1 -0
  81. package/dist/types/skills/plugins/plugin-api.d.ts +0 -1
  82. package/dist/types/skills/plugins/plugin-loader.d.ts +0 -4
  83. package/dist/types/skills/portable-tool.d.ts +2 -2
  84. package/dist/types/skills/tools/config-tool.d.ts +1 -3
  85. package/dist/types/skills/tools/skill-tool.d.ts +2 -2
  86. package/dist/types/skills/tools/team-tool.d.ts +44 -4
  87. package/dist/types/skills/tools/tool-search-tool.d.ts +11 -0
  88. package/package.json +3 -2
  89. package/dist/types/assistants/assistant-registry.d.ts +0 -4
  90. package/dist/types/assistants/assistant-store.d.ts +0 -23
  91. package/dist/types/assistants/assistant-turn-context.d.ts +0 -20
  92. package/dist/types/assistants/assistant-types.d.ts +0 -38
  93. package/dist/types/assistants/plugin-assistant-registry.d.ts +0 -16
  94. package/dist/types/cli/core-tools/utility-tool-bootstrap.d.ts +0 -12
  95. package/dist/types/cli/dev-tools/repl-tool-service.d.ts +0 -5
  96. package/dist/types/cli/handlers/assistants-handler.d.ts +0 -13
  97. package/dist/types/skills/mcp/mcp-http-client.d.ts +0 -68
  98. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +0 -86
  99. package/dist/types/skills/think-tool.d.ts +0 -16
  100. package/dist/types/skills/tools/apply-patch-tool.d.ts +0 -29
  101. package/dist/types/skills/tools/mcp-client-types.d.ts +0 -269
  102. package/dist/types/skills/tools/mcp-resource-tools.d.ts +0 -14
  103. package/dist/types/skills/tools/mcp-tool.d.ts +0 -249
  104. package/dist/types/skills/tools/project-switch-tool.d.ts +0 -24
  105. package/dist/types/skills/tools/repl-tool.d.ts +0 -70
  106. package/dist/types/skills/tools/send-message-tool.d.ts +0 -57
package/README.md CHANGED
@@ -1,31 +1,31 @@
1
- # qlogicagent
2
-
3
- ## Community Red-Team Reports
4
-
5
- Generate the v0.15 community red-team reports from the same detectors and permission checker used by local community flows:
6
-
7
- ```bash
8
- pnpm redteam:community-desensitization -- --out=../qlogicagent-hub/reports/community-go-live/red-team/desensitization.json
9
- pnpm redteam:community-sandbox -- --out=../qlogicagent-hub/reports/community-go-live/red-team/sandbox.json
10
- ```
11
-
12
- The reports contain case ids, rule/finding ids, counts, and failures only; they do not store raw emails, secrets, paths, phone numbers, memories, skill text, tool commands, or file paths.
13
-
14
- Installed community skills are marked from their lifecycle registry provenance. Non-official installed skills execute as `community-skill:*` subturns, and `PermissionChecker` applies the L1 sandbox overlay only while that subturn is active.
15
-
16
- The generic `skill` meta-tool no longer exposes raw URL installation. New community skills must enter through the v0.15 registry install flow so manifest kind, source tier, risk tier, dependencies, checksum, and local `SKILL.md` rescan all run on the same path.
17
-
18
- Community skill installation also rescans the downloaded `SKILL.md` entry after checksum verification and before moving it into the owner profile. Prompt-injection hits fail closed, leave no installed skill or lifecycle record, and return only a generic scan failure.
19
-
20
- At runtime, the community sandbox overlay also blocks host side-effect tools such as `send_message`, `agent`, `team`, `cron`, and `monitor` from community skill subturns, so injected instructions cannot escape through delegation, team control, or scheduled work.
21
-
22
- Community skill subturns also treat local file upload as tainted data egress. A `file_upload` call from `community-skill:*` requires explicit per-call approval before any provider Files API upload can proceed; auto-mode classifiers cannot replace that approval, and denied approvals leave no raw file path in the sandbox red-team report.
23
-
24
- Community skill subturns also treat provider prompt/media tools as tainted external egress. Calls such as `image_generate`, `video_generate`, `music_generate`, `tts`, `three_d_generate`, `video_edit`, `video_merge`, `video_upscale`, `voice_clone`, and `stt` require explicit per-call approval from `community-skill:*`; worker/coordinator roles fail closed, and auto-mode classifiers cannot replace that approval.
25
-
26
- Pet/Soul data is display-only. Runtime load/save sanitization strips fields and Chinese/English text that claim the pet is a desktop agent, execution actor, decision layer, permission subject, or can alter agent tools, permissions, memory, retrieval, planning, security policy, or system prompts.
27
-
28
- 小智 Claw 的本地 AI Agent 运行时。作为独立进程运行,通过 **ACP (Agent Client Protocol) + Native JSON-RPC over stdio** 对外提供 Agent 能力。openclaw 智能网关作为 ACP Client 连接本进程。
1
+ # qlogicagent
2
+
3
+ ## Community Red-Team Reports
4
+
5
+ Generate the v0.15 community red-team reports from the same detectors and permission checker used by local community flows:
6
+
7
+ ```bash
8
+ pnpm redteam:community-desensitization -- --out=../qlogicagent-hub/reports/community-go-live/red-team/desensitization.json
9
+ pnpm redteam:community-sandbox -- --out=../qlogicagent-hub/reports/community-go-live/red-team/sandbox.json
10
+ ```
11
+
12
+ The reports contain case ids, rule/finding ids, counts, and failures only; they do not store raw emails, secrets, paths, phone numbers, memories, skill text, tool commands, or file paths.
13
+
14
+ Installed community skills are marked from their lifecycle registry provenance. Non-official installed skills execute as `community-skill:*` subturns, and `PermissionChecker` applies the L1 sandbox overlay only while that subturn is active.
15
+
16
+ The generic `skill` meta-tool no longer exposes raw URL installation. New community skills must enter through the v0.15 registry install flow so manifest kind, source tier, risk tier, dependencies, checksum, and local `SKILL.md` rescan all run on the same path.
17
+
18
+ Community skill installation also rescans the downloaded `SKILL.md` entry after checksum verification and before moving it into the owner profile. Prompt-injection hits fail closed, leave no installed skill or lifecycle record, and return only a generic scan failure.
19
+
20
+ At runtime, the community sandbox overlay also blocks host side-effect tools such as `send_message`, `agent`, `team`, `cron`, and `monitor` from community skill subturns, so injected instructions cannot escape through delegation, team control, or scheduled work.
21
+
22
+ Community skill subturns also treat local file upload as tainted data egress. A `file_upload` call from `community-skill:*` requires explicit per-call approval before any provider Files API upload can proceed; auto-mode classifiers cannot replace that approval, and denied approvals leave no raw file path in the sandbox red-team report.
23
+
24
+ Community skill subturns also treat provider prompt/media tools as tainted external egress. Calls such as `image_generate`, `video_generate`, `music_generate`, `tts`, `three_d_generate`, `video_edit`, `video_merge`, `video_upscale`, `voice_clone`, and `stt` require explicit per-call approval from `community-skill:*`; worker/coordinator roles fail closed, and auto-mode classifiers cannot replace that approval.
25
+
26
+ Pet/Soul data is display-only. Runtime load/save sanitization strips fields and Chinese/English text that claim the pet is a desktop agent, execution actor, decision layer, permission subject, or can alter agent tools, permissions, memory, retrieval, planning, security policy, or system prompts.
27
+
28
+ 小智 Claw 的本地 AI Agent 运行时。作为独立进程运行,通过 **ACP (Agent Client Protocol) + Native JSON-RPC over stdio** 对外提供 Agent 能力。openclaw 智能网关作为 ACP Client 连接本进程。
29
29
 
30
30
  ## 功能概览
31
31
 
@@ -33,7 +33,7 @@ Pet/Soul data is display-only. Runtime load/save sanitization strips fields and
33
33
  - **多 LLM Provider**: OpenAI、Anthropic、DeepSeek 等,通过统一 `LLMTransport` 接口切换
34
34
  - **编排策略**: failover 降级、指数退避重试、并行工具执行、14+ 上下文压缩策略、多代理团队协作
35
35
  - **权限系统**: 命令安全分类、规则引擎、用户审批、破坏性命令警告
36
- - **记忆系统**: 本地 memory.json (2200 char, 始终注入 systemPrompt) + QMemory 语义长期记忆 (recall-on-demand) + Dream 整合
36
+ - **记忆系统**: 进程内分层记忆 memdir 文件记忆 (L1 项目级,INDEX.md + 主题文件) + 本地 SQLite 语义长期记忆 (L2,本地 embedding,recall-on-demand) + Dream 整合,无外部服务依赖
37
37
  - **会话持久化**: JSONL 对话转录 + 状态快照 + 会话恢复
38
38
  - **MCP 协议**: stdio/HTTP 传输、动态工具注入、资源发现
39
39
  - **插件系统**: 用户级/项目级插件加载、插件 API
@@ -66,36 +66,11 @@ cp .env.example .env
66
66
  ```bash
67
67
  # 日志级别
68
68
  LOG_LEVEL=info
69
-
70
- # QMemory 服务地址(启用长期记忆)
71
- QMEMORY_BASE_URL=http://127.0.0.1:18800
72
-
73
- # QMemory API Key(可选)
74
- # QMEMORY_API_KEY=your-key
75
69
  ```
76
70
 
77
- ### 3. 启动 QMemory(推荐)
71
+ 记忆系统为进程内(memdir 文件记忆 + 本地 SQLite 语义记忆 + 本地 embedding),无需启动任何外部服务,开箱即用。
78
72
 
79
- qlogicagent 的完整功能依赖本地 QMemory 服务提供语义记忆:
80
-
81
- ```bash
82
- # 方式一:直接运行(需 Python 3.11+)
83
- cd ../qmemory
84
- pip install -e .
85
- python -m qmemory --port 18800
86
-
87
- # 方式二:Docker
88
- docker run -d -p 18800:18800 qmemory:latest
89
- ```
90
-
91
- 验证 QMemory 运行:
92
-
93
- ```bash
94
- curl http://127.0.0.1:18800/health
95
- # {"status":"ok","version":"..."}
96
- ```
97
-
98
- ### 4. 运行
73
+ ### 3. 运行
99
74
 
100
75
  qlogicagent 作为独立进程运行,由 Electron 桌面壳管理生命周期,openclaw 通过 ACP 协议连接:
101
76
 
@@ -184,112 +159,81 @@ node dist/cli.js --acp
184
159
 
185
160
  ## 模块结构
186
161
 
162
+ > LLM 通信不在本仓:Provider 实现来自外部包 `@xiaozhiclaw/provider-core`,仓内仅保留传输端口
163
+ > (`runtime/ports/model-transport-contracts.ts`) 与门面 (`cli/provider-core-facade.ts`)。记忆同样进程内,无独立 HTTP 服务。
164
+
187
165
  ```
188
166
  src/
189
- ├── cli/ # 组合根:JSON-RPC 协议 + 全模块装配
190
- │ ├── main.ts # 进程入口
191
- │ ├── stdio-server.ts # StdioServer (JSON-RPC handler, 工具注册, 配置解析)
192
- └── tool-bootstrap.ts# 工具注册初始化
167
+ ├── cli/ # 组合根:JSON-RPC + ACP 协议 + 全模块装配
168
+ │ ├── main.ts # 进程入口
169
+ │ ├── stdio-server.ts # StdioServer (JSON-RPC 派发 + 运行时状态容器)
170
+ ├── rpc-registry.ts # RPC 方法 → handler 注册表
171
+ │ ├── handlers/ # 各域 RPC handler (session/memory/pet/agents/...)
172
+ │ ├── provider-core-facade.ts # LLMTransport / 媒体客户端门面 (provider-core 边界)
173
+ │ └── *-coordinator / *-bootstrap.ts # 会话/记忆/工具/权限/MCP 等装配
193
174
 
194
175
  ├── agent/ # Agent 核心:推理 + 工具循环
195
- │ ├── agent.ts # Agent 类 (async generator run())
196
- │ ├── tool-loop.ts # 工具调用循环
197
- │ ├── types.ts # 核心类型 (ChatMessage, TurnEvent, ToolInvoker...)
198
- └── constants.ts # 运行参数常量
199
-
200
- ├── llm/ # LLM 通信层(完全隔离)
201
- ├── transport.ts # LLMTransport 接口
202
- │ ├── transports/ # OpenAI / Anthropic 实现
203
- │ ├── provider-registry.ts # Provider 注册表
204
- │ ├── model-catalog.ts # 模型能力目录
205
- │ └── llm-client.ts # 一站式客户端工厂
176
+ │ ├── agent.ts # Agent 类 (async generator run() — turn 生命周期薄壳)
177
+ │ ├── tool-loop.ts # 工具调用循环状态机 (CC query loop 对齐)
178
+ │ ├── tool-loop/ # 循环子阶段 (loop/recovery/single-round/事件 helpers)
179
+ ├── memory-recall-context.ts # 召回记忆 → 系统提示 (纯函数 + 冲突检测)
180
+ ├── memory-recall-injection.ts # 召回编排 (hook + 字节封顶 + after_recall)
181
+ ├── tunable-defaults.ts # 运行参数默认/上限
182
+ └── types.ts # 核心类型 (ChatMessage, TurnEvent, ToolInvoker, LLMTransport...)
206
183
 
207
184
  ├── orchestration/ # 编排策略层(纯函数,零外部依赖)
208
- │ ├── tool-loop-state.ts # 工具循环 FSM
209
- │ ├── context-compression.ts # 14+ 压缩策略
210
- │ ├── error-classification.ts # 错误分类
211
- │ ├── retry-loop.ts # 重试策略
212
- ├── agent-registry.ts # 内置代理类型
213
- │ ├── fork-subagent.ts # 子代理 fork
214
- │ ├── team-orchestration.ts # 多代理团队
215
- │ └── ... # 23 个策略文件
185
+ │ ├── tool-loop/ # tool-loop-state / conversation-repair / tool-choice-policy / tool-schema
186
+ │ ├── context/ # context-collapse 等上下文压缩策略
187
+ │ ├── subagent/ # agent-registry / fork-subagent (内置代理 + 子代理 fork)
188
+ │ ├── workflow/ # 工作流引擎 / 调度 / 预算门控
189
+ └── ... # 错误分类、重试、团队编排、solo/product
216
190
 
217
191
  ├── runtime/ # 运行时服务层
218
- │ ├── session-state.ts # 会话成本追踪
219
- │ ├── session-persistence.ts # JSONL 对话持久化
220
- │ ├── session-memory.ts # 会话记忆提取
221
- │ ├── hook-registry.ts # Hook 系统实现
222
- │ ├── forked-agent.ts # 子代理执行
223
- │ ├── dream-agent.ts # 记忆整合 (Dream)
224
- ├── secure-storage.ts # 凭据安全存储
225
- │ ├── token-budget.ts # Token 预算管理
226
- │ ├── instruction-loader.ts # INSTRUCTIONS.md 与 .qlogicagent/rules 加载
227
- │ └── ... # 21 个运行时文件
192
+ │ ├── session/ # session-state / session-persistence / session-memory / locator
193
+ │ ├── hooks/ # hook-registry / memory-hooks / 上下文压缩 hooks
194
+ │ ├── execution/ # forked-agent / streaming-tool-executor
195
+ │ ├── prompt/ # instruction-loader / system-prompt-sections / task-domain
196
+ │ ├── infra/ # model-registry / task-runtime / background-tasks / agent-paths
197
+ │ ├── ports/ # 端口契约 (memory / model-transport / permission ...)
198
+ └── config/ # tunable-defaults 等运行时配置
228
199
 
229
200
  ├── skills/ # 工具与技能层
230
- │ ├── portable-tool.ts # PortableTool 契约接口
231
- │ ├── tools.ts # CC-aligned 工具池 (setToolPool/findTool/getToolManifest)
232
- │ ├── tools/ # 44 个内置工具
233
- ├── shell/ # 命令执行子系统 (11 文件)
234
- ├── exec-tool.ts # Shell 执行
235
- │ ├── read-tool.ts # 文件读取
236
- │ │ ├── write-tool.ts # 文件写入
237
- │ │ ├── edit-tool.ts # 文件编辑
238
- │ │ ├── search-tool.ts # 文件搜索
239
- │ │ ├── web-search-tool.ts # Web 搜索
240
- │ │ ├── agent-tool.ts # 子代理调用
241
- │ │ ├── team-tool.ts # 团队管理
242
- │ │ ├── mcp-tool.ts # MCP 服务器管理
243
- │ │ └── ... # 其他工具
244
- │ ├── mcp/ # MCP 桥接 (4 文件)
245
- │ ├── permissions/ # 权限系统 (9 文件)
246
- │ ├── plugins/ # 插件系统 (4 文件)
247
- │ ├── memory-tool.ts # 记忆工具 (MD + QMemory)
248
- │ ├── qmemory-adapter.ts # QMemory HTTP 适配器
249
- │ └── skill-loader.ts # 技能发现/加载
250
-
251
- ├── contracts/ # 纯类型契约(零依赖)
252
- │ ├── hooks.ts # 30+ Hook 点定义
253
- │ ├── planner.ts # 规划器类型
254
- │ ├── todo.ts # 待办类型
255
- │ └── skill-candidate.ts # 技能候选类型
201
+ │ ├── tools/ # 内置工具 (shell / read / write / edit / search / web / agent / team / mcp ...)
202
+ │ ├── memory/ # memdir (文件记忆) + 本地 SQLite store + 本地 embedding + 整合/召回
203
+ │ ├── mcp/ # MCP 桥接
204
+ │ ├── permissions/ # 权限规则引擎 / 设置 / sandbox overlay
205
+ │ ├── plugins/ # 插件系统
206
+ └── skill-system/ # SKILL.md 发现 / 生命周期 / 校验
256
207
 
257
- └── config/ # 配置管理
258
- └── config.ts # CLI 参数解析
208
+ ├── protocol/ # 线协议:wire/ (Gateway RPC 契约) + notifications + methods
209
+ ├── transport/ # ACP server + 事件映射
210
+ ├── contracts/ # 纯类型契约(hooks 等,零依赖)
211
+ └── config/ # CLI 参数解析
259
212
  ```
260
213
 
261
214
  ---
262
215
 
263
- ## QMemory 集成
216
+ ## 记忆系统
264
217
 
265
- qlogicagent 通过 HTTP 连接本地 QMemory 服务实现语义长期记忆。
218
+ qlogicagent 的记忆全部进程内,无外部服务依赖,开箱即用。
266
219
 
267
220
  ### 记忆层次
268
221
 
269
222
  | 层 | 说明 | 存储 |
270
223
  |----|------|------|
271
- | **MD 记忆** | Agent 主动管理的笔记 (add/replace/remove) | `~/.qlogicagent/session-memory.md` |
272
- | **QMemory** | 语义向量记忆,自动提取 + 语义召回 | QMemory 服务 (SQLite + embedding) |
224
+ | **L1 memdir** | 项目级文件记忆,Agent 主动管理 (INDEX.md + 主题文件) | `<project>/.qlogicagent/memory/` |
225
+ | **L2 长期记忆** | 语义向量记忆,自动提取 + 语义召回 | 本地 SQLite + 本地 embedding(进程内) |
273
226
  | **会话转录** | JSONL 对话记录,用于会话恢复 | `~/.qlogicagent/sessions/<id>/` |
274
227
 
275
- ### 启用步骤
228
+ ### 工作方式
276
229
 
277
- 1. 启动 QMemory 服务(见上方"快速开始")
278
- 2. 设置环境变量:`QMEMORY_BASE_URL=http://127.0.0.1:18800`
279
- 3. Agent 自动:
280
- - `memory.before_recall` hook 预取相关记忆
281
- - 通过 `memory` 工具的 `search` action 查询语义记忆
282
- - 会话结束时自动提取关键信息写入 QMemory
283
- - 达到阈值后触发 Dream 整合(4 阶段:Orient → Gather → Consolidate → Prune)
230
+ 无需任何配置或外部服务。Agent 自动:
231
+ - 在 `memory.before_recall` hook 预取相关长期记忆(按 category 过滤 + 每轮字节封顶后注入系统提示)
232
+ - 通过 `memory` 工具查询 / 写入语义记忆
233
+ - 会话过程中自动提取关键信息写入 L2
234
+ - 空闲或达到阈值后触发 Dream 整合(4 阶段:Orient Gather → Consolidate → Prune)
284
235
 
285
- ### 不启用 QMemory
286
-
287
- 如果不设置 `QMEMORY_BASE_URL`,Agent 仍可运行,但:
288
- - ❌ 无语义记忆召回
289
- - ❌ 无自动记忆提取
290
- - ❌ 无 Dream 整合
291
- - ✅ MD 本地记忆仍可用
292
- - ✅ 会话转录仍正常
236
+ L1/L2 冲突时不静默合并:召回上下文会标注冲突并提示向用户确认(见 `agent/memory-recall-context.ts`)。
293
237
 
294
238
  ---
295
239
 
@@ -300,9 +244,6 @@ qlogicagent 通过 HTTP 连接本地 QMemory 服务实现语义长期记忆。
300
244
  | 变量 | 说明 | 默认值 |
301
245
  |------|------|--------|
302
246
  | `LOG_LEVEL` | 日志级别 (debug/info/warn/error) | `info` |
303
- | `QMEMORY_BASE_URL` | QMemory 服务地址 | 不设则禁用 |
304
- | `QMEMORY_API_KEY` | QMemory 认证 Key | — |
305
- | `QLOGICAGENT_QMEMORY_BASE_URL` | QMemory 地址 (备选变量名) | — |
306
247
  | `QLOGICAGENT_HOME` | Agent 数据根目录(覆盖默认 `~/.qlogicagent/`)| `~/.qlogicagent/` |
307
248
  | `QLOGICAGENT_IDLE_DREAM_MS` | 空闲多久后自动触发 Dream 整合(毫秒)| `300000` (5 min) |
308
249
  | `QLOGICAGENT_DREAM_COOLDOWN_MS` | 两次 Dream 之间的最短间隔(毫秒)| `1800000` (30 min) |
@@ -329,7 +270,7 @@ qlogicagent 内置 idle dream 机制:当用户空闲超过 `QLOGICAGENT_IDLE_D
329
270
  - **冷却保护**:两次 Dream 之间必须间隔 `QLOGICAGENT_DREAM_COOLDOWN_MS`,防止频繁触发
330
271
  - **用户活动中止**:Dream 执行中如果收到新的 `thread.turn`,自动中止 Dream
331
272
  - **最大时长限制**:单次 Dream 最长 120 秒,超时自动终止
332
- - **触发门控**:需满足记忆数据充足、QMemory 可用等前置条件才会真正执行
273
+ - **触发门控**:需满足记忆数据充足等前置条件才会真正执行
333
274
 
334
275
  ### 用户级配置(`~/.qlogicagent/`)
335
276
 
@@ -398,22 +339,15 @@ MCP 工具自动注入到 Agent 工具列表,前缀格式:`mcp__servername__
398
339
 
399
340
  ```json
400
341
  {
401
- "permissionMode": "default",
402
- "defaultBehavior": "ask",
403
- "permissionRules": [
404
- {
405
- "pattern": "read",
406
- "behavior": "allow"
407
- },
408
- {
409
- "pattern": "exec",
410
- "behavior": "ask"
411
- },
412
- {
413
- "pattern": "write:**/node_modules/**",
414
- "behavior": "deny"
415
- }
416
- ]
342
+ "permissions": {
343
+ "mode": "default",
344
+ "defaultBehavior": "ask",
345
+ "rules": [
346
+ { "pattern": "read", "behavior": "allow" },
347
+ { "pattern": "exec", "behavior": "ask" },
348
+ { "pattern": "write:**/node_modules/**", "behavior": "deny" }
349
+ ]
350
+ }
417
351
  }
418
352
  ```
419
353