openclaw-cortex-memory 0.1.0-Alpha.3 → 0.1.0-Alpha.31
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.
- package/LICENSE +21 -0
- package/README.md +296 -203
- package/SIGNATURE.md +7 -0
- package/SKILL.md +92 -268
- package/dist/index.d.ts +100 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1249 -1252
- package/dist/index.js.map +1 -1
- package/dist/openclaw.plugin.json +501 -16
- package/dist/src/dedup/three_stage_deduplicator.d.ts +25 -0
- package/dist/src/dedup/three_stage_deduplicator.d.ts.map +1 -0
- package/dist/src/dedup/three_stage_deduplicator.js +224 -0
- package/dist/src/dedup/three_stage_deduplicator.js.map +1 -0
- package/dist/src/engine/memory_engine.d.ts +6 -1
- package/dist/src/engine/memory_engine.d.ts.map +1 -1
- package/dist/src/engine/ts_engine.d.ts +242 -0
- package/dist/src/engine/ts_engine.d.ts.map +1 -1
- package/dist/src/engine/ts_engine.js +1468 -52
- package/dist/src/engine/ts_engine.js.map +1 -1
- package/dist/src/engine/types.d.ts +29 -0
- package/dist/src/engine/types.d.ts.map +1 -1
- package/dist/src/graph/ontology.d.ts +125 -0
- package/dist/src/graph/ontology.d.ts.map +1 -0
- package/dist/src/graph/ontology.js +1237 -0
- package/dist/src/graph/ontology.js.map +1 -0
- package/dist/src/net/http_post.d.ts +17 -0
- package/dist/src/net/http_post.d.ts.map +1 -0
- package/dist/src/net/http_post.js +56 -0
- package/dist/src/net/http_post.js.map +1 -0
- package/dist/src/quality/llm_output_validator.d.ts +66 -0
- package/dist/src/quality/llm_output_validator.d.ts.map +1 -0
- package/dist/src/quality/llm_output_validator.js +659 -0
- package/dist/src/quality/llm_output_validator.js.map +1 -0
- package/dist/src/reflect/reflector.d.ts +7 -0
- package/dist/src/reflect/reflector.d.ts.map +1 -1
- package/dist/src/reflect/reflector.js +352 -8
- package/dist/src/reflect/reflector.js.map +1 -1
- package/dist/src/rules/rule_store.d.ts.map +1 -1
- package/dist/src/rules/rule_store.js +75 -16
- package/dist/src/rules/rule_store.js.map +1 -1
- package/dist/src/session/session_end.d.ts +33 -0
- package/dist/src/session/session_end.d.ts.map +1 -1
- package/dist/src/session/session_end.js +67 -64
- package/dist/src/session/session_end.js.map +1 -1
- package/dist/src/store/archive_store.d.ts +136 -0
- package/dist/src/store/archive_store.d.ts.map +1 -0
- package/dist/src/store/archive_store.js +635 -0
- package/dist/src/store/archive_store.js.map +1 -0
- package/dist/src/store/embedding_utils.d.ts +32 -0
- package/dist/src/store/embedding_utils.d.ts.map +1 -0
- package/dist/src/store/embedding_utils.js +173 -0
- package/dist/src/store/embedding_utils.js.map +1 -0
- package/dist/src/store/graph_memory_store.d.ts +114 -0
- package/dist/src/store/graph_memory_store.d.ts.map +1 -0
- package/dist/src/store/graph_memory_store.js +841 -0
- package/dist/src/store/graph_memory_store.js.map +1 -0
- package/dist/src/store/read_store.d.ts +89 -0
- package/dist/src/store/read_store.d.ts.map +1 -1
- package/dist/src/store/read_store.js +2459 -28
- package/dist/src/store/read_store.js.map +1 -1
- package/dist/src/store/vector_store.d.ts +45 -0
- package/dist/src/store/vector_store.d.ts.map +1 -0
- package/dist/src/store/vector_store.js +202 -0
- package/dist/src/store/vector_store.js.map +1 -0
- package/dist/src/store/write_store.d.ts +54 -0
- package/dist/src/store/write_store.d.ts.map +1 -1
- package/dist/src/store/write_store.js +284 -6
- package/dist/src/store/write_store.js.map +1 -1
- package/dist/src/sync/session_sync.d.ts +119 -2
- package/dist/src/sync/session_sync.d.ts.map +1 -1
- package/dist/src/sync/session_sync.js +2377 -31
- package/dist/src/sync/session_sync.js.map +1 -1
- package/dist/src/utils/runtime_env.d.ts +4 -0
- package/dist/src/utils/runtime_env.d.ts.map +1 -0
- package/dist/src/utils/runtime_env.js +51 -0
- package/dist/src/utils/runtime_env.js.map +1 -0
- package/dist/src/wiki/wiki_linter.d.ts +25 -0
- package/dist/src/wiki/wiki_linter.d.ts.map +1 -0
- package/dist/src/wiki/wiki_linter.js +268 -0
- package/dist/src/wiki/wiki_linter.js.map +1 -0
- package/dist/src/wiki/wiki_logger.d.ts +10 -0
- package/dist/src/wiki/wiki_logger.d.ts.map +1 -0
- package/dist/src/wiki/wiki_logger.js +78 -0
- package/dist/src/wiki/wiki_logger.js.map +1 -0
- package/dist/src/wiki/wiki_maintainer.d.ts +36 -0
- package/dist/src/wiki/wiki_maintainer.d.ts.map +1 -0
- package/dist/src/wiki/wiki_maintainer.js +38 -0
- package/dist/src/wiki/wiki_maintainer.js.map +1 -0
- package/dist/src/wiki/wiki_projector.d.ts +33 -0
- package/dist/src/wiki/wiki_projector.d.ts.map +1 -0
- package/dist/src/wiki/wiki_projector.js +633 -0
- package/dist/src/wiki/wiki_projector.js.map +1 -0
- package/dist/src/wiki/wiki_queue.d.ts +29 -0
- package/dist/src/wiki/wiki_queue.d.ts.map +1 -0
- package/dist/src/wiki/wiki_queue.js +137 -0
- package/dist/src/wiki/wiki_queue.js.map +1 -0
- package/openclaw.plugin.json +501 -16
- package/package.json +58 -7
- package/schema/graph.schema.yaml +330 -0
- package/scripts/cli.js +19 -14
- package/scripts/repair-memory.js +321 -0
- package/scripts/uninstall.js +22 -5
- package/skills/cortex-memory/SKILL.md +49 -0
- package/skills/cortex-memory/references/agent-manual.md +115 -0
- package/skills/cortex-memory/references/configuration.md +92 -0
- package/skills/cortex-memory/references/publish-checklist.md +46 -0
- package/skills/cortex-memory/references/system-prompt-template.md +27 -0
- package/skills/cortex-memory/references/tools.md +181 -0
- package/skills/cortex-memory/scripts/smoke-check.ps1 +56 -0
- package/index.ts +0 -2142
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 deki18
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,204 +1,297 @@
|
|
|
1
|
-
# OpenClaw Cortex Memory
|
|
2
|
-
|
|
3
|
-
OpenClaw
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
1
|
+
# OpenClaw Cortex Memory
|
|
2
|
+
|
|
3
|
+
OpenClaw 长期记忆插件 - 专为 OpenClaw AI 助手设计的智能记忆系统
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](https://github.com/openclaw)
|
|
8
|
+
|
|
9
|
+
面向 OpenClaw 的长期记忆插件,集成多路检索、事件归档、图谱关系、向量化与反衰减排序,支持历史增量导入、规则反思和可观测诊断,帮助 Agent 在跨会话中持续积累并稳定调用高价值记忆。
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 核心能力
|
|
14
|
+
|
|
15
|
+
### 1) 语义检索
|
|
16
|
+
- 多路召回:`keyword / BM25 / vector / graph` 混合检索
|
|
17
|
+
- 排序融合:加权打分 + RRF + 可选 reranker
|
|
18
|
+
- 结果融合:可选 `readFusion`,支持权威融合返回
|
|
19
|
+
- 时序建模:`memoryDecay` + 命中反衰减(anti-decay)
|
|
20
|
+
|
|
21
|
+
### 2) 事件存储
|
|
22
|
+
- 分层写入:`active`(会话)与 `archive`(结构化事件)
|
|
23
|
+
- 摘要优先:归档记录保留 `summary` 与 `source_text`
|
|
24
|
+
- 向量分块:支持 summary/evidence 双通道向量记录
|
|
25
|
+
- 增量同步:按状态文件增量导入历史会话
|
|
26
|
+
|
|
27
|
+
### 3) 图谱关系
|
|
28
|
+
- 图谱独立层:`graph/memory.jsonl` 独立于 archive 文本层
|
|
29
|
+
- 关系追溯:每条关系可追溯 `source_event_id`
|
|
30
|
+
- 关系查询:`query_graph` 支持方向、关系类型、路径搜索
|
|
31
|
+
- 冲突治理:单值事实冲突进入队列,支持人工 `accept/reject` 闭环
|
|
32
|
+
- 可视化导出:`export_graph_view` 输出状态化图谱快照(含来源证据)
|
|
33
|
+
- 质量门禁:`graphQualityMode` 支持 `off/warn/strict`
|
|
34
|
+
|
|
35
|
+
### 4) 规则演进
|
|
36
|
+
- 反思沉淀:`reflect_memory` 将事件抽象为规则
|
|
37
|
+
- 去重治理:规则与事件均有去重控制,避免污染
|
|
38
|
+
- 规则复用:规则写入 `CORTEX_RULES.md` 供后续任务复用
|
|
39
|
+
|
|
40
|
+
### 5) 运维诊断
|
|
41
|
+
- `diagnostics`:模型连通、层级状态、字段对齐检查
|
|
42
|
+
- `backfill_embeddings`:支持 `incremental / vector_only / full`
|
|
43
|
+
- `lint_memory_wiki`:Wiki/图谱一致性巡检与修复建议
|
|
44
|
+
- 完整状态文件:便于快速定位同步、回填、质量问题
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 已注册工具(与当前代码一致)
|
|
49
|
+
|
|
50
|
+
- `search_memory`
|
|
51
|
+
- `store_event`
|
|
52
|
+
- `query_graph`
|
|
53
|
+
- `export_graph_view`
|
|
54
|
+
- `lint_memory_wiki`
|
|
55
|
+
- `list_graph_conflicts`
|
|
56
|
+
- `resolve_graph_conflict`
|
|
57
|
+
- `get_hot_context`
|
|
58
|
+
- `get_auto_context`
|
|
59
|
+
- `reflect_memory`
|
|
60
|
+
- `sync_memory`
|
|
61
|
+
- `backfill_embeddings`
|
|
62
|
+
- `delete_memory`
|
|
63
|
+
- `diagnostics`
|
|
64
|
+
|
|
65
|
+
### 工具参数速览
|
|
66
|
+
|
|
67
|
+
| 工具 | 关键参数 |
|
|
68
|
+
|------|------|
|
|
69
|
+
| `search_memory` | `query`, `top_k` |
|
|
70
|
+
| `store_event` | `summary`, `entities`, `entity_types`, `outcome`, `relations` |
|
|
71
|
+
| `query_graph` | `entity`, `rel`, `dir`, `path_to`, `max_depth` |
|
|
72
|
+
| `export_graph_view` | `write_snapshot` |
|
|
73
|
+
| `lint_memory_wiki` | 无 |
|
|
74
|
+
| `list_graph_conflicts` | `status`, `limit` |
|
|
75
|
+
| `resolve_graph_conflict` | `conflict_id`, `action`, `note` |
|
|
76
|
+
| `get_hot_context` | `limit` |
|
|
77
|
+
| `get_auto_context` | `include_hot` |
|
|
78
|
+
| `reflect_memory` | 无 |
|
|
79
|
+
| `sync_memory` | 无 |
|
|
80
|
+
| `backfill_embeddings` | `layer`, `batch_size`, `max_retries`, `retry_failed_only`, `rebuild_mode` |
|
|
81
|
+
| `diagnostics` | 无 |
|
|
82
|
+
| `delete_memory` | `memory_id` |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Agent 使用手册(系统提示词)
|
|
87
|
+
|
|
88
|
+
> 可直接粘贴到 Agent 的系统提示词中使用
|
|
89
|
+
|
|
90
|
+
**Cortex Memory 记忆插件使用规则(核心规则,不允许删除)**
|
|
91
|
+
|
|
92
|
+
你已接入 Cortex Memory。必须遵循以下规则:
|
|
93
|
+
|
|
94
|
+
1. 禁止臆造历史事实;凡涉及历史对话、用户偏好、项目既有决策,先检索再回答。
|
|
95
|
+
2. 单个任务内避免重复写入:`store_event` / `reflect_memory` 仅在关键节点或收尾触发一次。
|
|
96
|
+
3. 用户询问历史信息、偏好、项目上下文时:先调用 `search_memory`,再回答。
|
|
97
|
+
4. 需要当前会话热上下文时:调用 `get_hot_context`。
|
|
98
|
+
5. 需要自动召回相关记忆时:调用 `get_auto_context`。
|
|
99
|
+
6. 需要实体关系、依赖链路或路径关系时:调用 `query_graph`。
|
|
100
|
+
7. 仅在“重要事项已结束且结论明确”后调用 `store_event` 记录结果(过程进行中不频繁记录)。
|
|
101
|
+
8. 当任务经历“失败 -> 调整 -> 成功”时:先用 `store_event` 记录失败原因与成功方案,再调用 `reflect_memory` 沉淀可复用规则。
|
|
102
|
+
9. 需要导入历史会话时:调用 `sync_memory`。
|
|
103
|
+
10. 当 `diagnostics` 显示 active/archive 有未向量化记录,或迁移后需重建向量层时:调用 `backfill_embeddings`(按需选择 `incremental` / `vector_only` / `full`)。
|
|
104
|
+
11. 出现配置校验失败、记忆读写异常、检索结果异常或数据目录问题时:优先调用 `diagnostics`。
|
|
105
|
+
12. 仅在用户明确要求删除记忆,且已确认 `memory_id` 时,才调用 `delete_memory`;禁止在未确认情况下自动删除。
|
|
106
|
+
13. 任一工具调用失败时,先重试一次;仍失败则明确告知用户,并基于当前可得上下文继续完成任务。
|
|
107
|
+
14. 调用任意 Cortex Memory 工具前,先确认当前运行环境可见该工具;若工具不可见,必须立即报告“当前 lane 不可用”,不得虚构执行结果。
|
|
108
|
+
15. `sync_memory` 属于关键路径任务:执行前后应避免并发重复触发;若已有同任务进行中,复用当前结果或等待完成。
|
|
109
|
+
16. 当用户明确请求 Cortex Memory 任务(如 `sync_memory` / `search_memory` / `store_event`)时,禁止切换到无关流程(如心跳巡检、日报、闲聊任务);若被系统任务打断,先完成用户请求再处理后台任务。
|
|
110
|
+
17. 当 `query_graph` 返回 `conflict_hint` 时,不得静默覆盖冲突事实;应先调用 `list_graph_conflicts`,并与用户确认后再 `resolve_graph_conflict`。
|
|
111
|
+
18. 需要解释图谱状态分布或排查投影异常时,优先调用 `export_graph_view` 与 `lint_memory_wiki`。
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 快速开始
|
|
116
|
+
|
|
117
|
+
### 安装
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
cd ~/openclaw
|
|
121
|
+
openclaw plugins install clawhub:openclaw-cortex-memory
|
|
122
|
+
openclaw plugins enable openclaw-cortex-memory
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
如果 `clawhub:` 安装出现 `fetch failed`,可改用 npm 包本地安装(推荐兜底):
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npm pack openclaw-cortex-memory@0.1.0-Alpha.30
|
|
129
|
+
openclaw plugins install ./openclaw-cortex-memory-0.1.0-Alpha.30.tgz
|
|
130
|
+
openclaw plugins enable openclaw-cortex-memory
|
|
131
|
+
rm ./openclaw-cortex-memory-0.1.0-Alpha.30.tgz
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
完成安装后,请先按下方“最小配置”示例配置 `openclaw.json`,确认配置无误后再启动 gateway。
|
|
135
|
+
|
|
136
|
+
### 更新
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
rm -r ~/.openclaw/extensions/openclaw-cortex-memory
|
|
140
|
+
npm pack openclaw-cortex-memory@0.1.0-Alpha.30
|
|
141
|
+
openclaw plugins install ./openclaw-cortex-memory-0.1.0-Alpha.30.tgz
|
|
142
|
+
openclaw plugins enable openclaw-cortex-memory
|
|
143
|
+
rm ./openclaw-cortex-memory-0.1.0-Alpha.30.tgz
|
|
144
|
+
openclaw plugins list --enabled
|
|
145
|
+
openclaw gateway restart
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 卸载
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
cd ~/openclaw
|
|
152
|
+
openclaw plugins disable openclaw-cortex-memory
|
|
153
|
+
openclaw plugins uninstall openclaw-cortex-memory
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
如需卸载插件但保留记忆数据:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
cd ~/openclaw
|
|
160
|
+
openclaw plugins disable openclaw-cortex-memory
|
|
161
|
+
openclaw plugins uninstall openclaw-cortex-memory --keep-data
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 最小配置(推荐先跑起来)
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"plugins": {
|
|
169
|
+
"allow": ["openclaw-cortex-memory"],
|
|
170
|
+
"slots": { "memory": "none" },
|
|
171
|
+
"entries": {
|
|
172
|
+
"openclaw-cortex-memory": {
|
|
173
|
+
"enabled": true,
|
|
174
|
+
"config": {
|
|
175
|
+
"autoSync": true,
|
|
176
|
+
"autoReflect": false,
|
|
177
|
+
"graphQualityMode": "warn",
|
|
178
|
+
"wikiProjection": {
|
|
179
|
+
"enabled": true,
|
|
180
|
+
"mode": "incremental",
|
|
181
|
+
"maxBatch": 100
|
|
182
|
+
},
|
|
183
|
+
"embedding": {
|
|
184
|
+
"provider": "api",
|
|
185
|
+
"model": "text-embedding-3-large",
|
|
186
|
+
"apiKey": "${EMBEDDING_API_KEY}",
|
|
187
|
+
"baseURL": "https://your-embedding-endpoint/v1",
|
|
188
|
+
"dimensions": 3072
|
|
189
|
+
},
|
|
190
|
+
"llm": {
|
|
191
|
+
"provider": "api",
|
|
192
|
+
"model": "gpt-4",
|
|
193
|
+
"apiKey": "${LLM_API_KEY}",
|
|
194
|
+
"baseURL": "https://your-llm-endpoint/v1"
|
|
195
|
+
},
|
|
196
|
+
"reranker": {
|
|
197
|
+
"provider": "api",
|
|
198
|
+
"model": "BAAI/bge-reranker-v2-m3",
|
|
199
|
+
"apiKey": "${RERANKER_API_KEY}",
|
|
200
|
+
"baseURL": "https://your-reranker-endpoint/v1/rerank"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 外部端点与凭证声明(审查说明)
|
|
210
|
+
|
|
211
|
+
本插件是本地长期记忆系统,但以下能力依赖用户自配置的外部模型端点:
|
|
212
|
+
|
|
213
|
+
- `embedding`:向量化(`/embeddings`)
|
|
214
|
+
- `llm`:写入门控、规则反思、读融合(`/chat/completions`)
|
|
215
|
+
- `reranker`:候选重排序(`/rerank`)
|
|
216
|
+
|
|
217
|
+
对应凭证要求:
|
|
218
|
+
|
|
219
|
+
- 环境变量(可选):`EMBEDDING_API_KEY`、`LLM_API_KEY`、`RERANKER_API_KEY`
|
|
220
|
+
- 插件配置(常用):`embedding.apiKey`、`llm.apiKey`、`reranker.apiKey`
|
|
221
|
+
- 端点配置:`embedding.baseURL`、`llm.baseURL`、`reranker.baseURL`
|
|
222
|
+
|
|
223
|
+
### 网络发送的数据边界
|
|
224
|
+
|
|
225
|
+
- 会发送:用于模型推理的文本片段(如 query、候选摘要、转写片段、待向量化文本)
|
|
226
|
+
- 不会主动发送:本地配置文件原文、系统环境变量全集、插件状态文件全集
|
|
227
|
+
- 凭证使用方式:仅作为 `Authorization: Bearer` 请求头调用你配置的端点
|
|
228
|
+
|
|
229
|
+
### 风险与建议
|
|
230
|
+
|
|
231
|
+
- 你应只配置可信模型网关,密钥权限最小化(建议专用 key)
|
|
232
|
+
- 生产环境建议启用网关审计与请求日志脱敏
|
|
233
|
+
- 如不希望联网推理,不要配置外部端点/密钥(相关能力将降级或跳过)
|
|
234
|
+
|
|
235
|
+
<details>
|
|
236
|
+
<summary>高级配置(默认已内置,不懂可以不改)</summary>
|
|
237
|
+
|
|
238
|
+
- `readFusion`:融合候选数、通道权重、通道 TopK、最小 lexical/semantic 命中、长度归一
|
|
239
|
+
- `memoryDecay`:最小衰减地板、默认半衰期、事件类型半衰期、anti-decay 参数
|
|
240
|
+
- `vectorChunking`:分块大小、重叠、evidence 最大分块数
|
|
241
|
+
- `writePolicy`:archive/active 质量阈值与文本长度限制
|
|
242
|
+
- `readTuning`:打分权重、RRF 参数、recency 分桶、auto-context 轻量检索
|
|
243
|
+
|
|
244
|
+
</details>
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 数据目录
|
|
249
|
+
|
|
250
|
+
默认情况下(未配置 `dbPath`),数据目录为 OpenClaw workspace 下:
|
|
251
|
+
|
|
252
|
+
- Linux/macOS: `~/.openclaw/workspace/memory/openclaw-cortex-memory`
|
|
253
|
+
- Windows: `%USERPROFILE%\\.openclaw\\workspace\\memory\\openclaw-cortex-memory`
|
|
254
|
+
|
|
255
|
+
如果当前进程无法识别 OpenClaw 基础目录(例如离线脚本直接运行且无相关环境变量),会回退到项目目录:
|
|
256
|
+
|
|
257
|
+
- `<projectRoot>/data/memory`
|
|
258
|
+
|
|
259
|
+
如果在插件配置里设置了 `dbPath`,则以下文件都会写到你指定的 `dbPath` 下:
|
|
260
|
+
|
|
261
|
+
- `<memoryRoot>/MEMORY.md`
|
|
262
|
+
- `<memoryRoot>/CORTEX_RULES.md`
|
|
263
|
+
- `<memoryRoot>/sessions/active/sessions.jsonl`
|
|
264
|
+
- `<memoryRoot>/sessions/archive/sessions.jsonl`
|
|
265
|
+
- `<memoryRoot>/graph/memory.jsonl`
|
|
266
|
+
- `<memoryRoot>/graph/mutation_log.jsonl`
|
|
267
|
+
- `<memoryRoot>/graph/conflict_queue.jsonl`
|
|
268
|
+
- `<memoryRoot>/graph/superseded_relations.jsonl`
|
|
269
|
+
- `<memoryRoot>/wiki/index.md`
|
|
270
|
+
- `<memoryRoot>/wiki/log.md`
|
|
271
|
+
- `<memoryRoot>/wiki/entities/*.md`
|
|
272
|
+
- `<memoryRoot>/wiki/topics/*.md`
|
|
273
|
+
- `<memoryRoot>/wiki/graph/view.json`
|
|
274
|
+
- `<memoryRoot>/wiki/graph/timeline.jsonl`
|
|
275
|
+
- `<memoryRoot>/wiki/.projection_index.json`
|
|
276
|
+
- `<memoryRoot>/wiki/.rebuild_queue.jsonl`
|
|
277
|
+
- `<memoryRoot>/vector/lancedb`
|
|
278
|
+
- `<memoryRoot>/vector/lancedb_events.jsonl`
|
|
279
|
+
- `<memoryRoot>/.sync_state.json`
|
|
280
|
+
- `<memoryRoot>/.session_end_state.json`
|
|
281
|
+
- `<memoryRoot>/.rule_store_state.json`
|
|
282
|
+
- `<memoryRoot>/.dedup_index.json`
|
|
283
|
+
- `<memoryRoot>/.read_hit_stats.json`
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 常用命令
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
npm run typecheck
|
|
291
|
+
npm run test:graph-quality
|
|
292
|
+
npm run test:graph-quality-zh
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
204
297
|
MIT License
|
package/SIGNATURE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Publisher Signature
|
|
2
|
+
|
|
3
|
+
- Maintainer: deki18
|
|
4
|
+
- Repository: https://github.com/deki18/openclaw-cortex-memory
|
|
5
|
+
- npm Package: https://www.npmjs.com/package/openclaw-cortex-memory
|
|
6
|
+
- ClawHub ID: openclaw-cortex-memory
|
|
7
|
+
- Signature Intent: This repository and published artifacts are maintained and released by deki18.
|