dsh-mnemon 0.1.0
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.en.md +169 -0
- package/README.md +169 -0
- package/cordis.patch.yml +15 -0
- package/docs/README.md +8 -0
- package/docs/en/README.md +39 -0
- package/docs/en/architecture.md +129 -0
- package/docs/en/assets/project-architecture.svg +182 -0
- package/docs/en/configuration.md +204 -0
- package/docs/en/development.md +178 -0
- package/docs/en/getting-started.md +147 -0
- package/docs/en/interfaces.md +159 -0
- package/docs/en/operations.md +151 -0
- package/docs/en/project-overview.md +247 -0
- package/docs/en/roadmap.md +41 -0
- package/docs/en/storage-model.md +179 -0
- package/docs/en/workflows.md +290 -0
- package/docs/zh-CN/README.md +39 -0
- package/docs/zh-CN/architecture.md +129 -0
- package/docs/zh-CN/assets/project-architecture.svg +182 -0
- package/docs/zh-CN/assets/screenshots/conversation-recall.png +0 -0
- package/docs/zh-CN/assets/screenshots/conversation-writeback.png +0 -0
- package/docs/zh-CN/assets/screenshots/documents-markdown.png +0 -0
- package/docs/zh-CN/assets/screenshots/entities-context.png +0 -0
- package/docs/zh-CN/assets/screenshots/memory-content.png +0 -0
- package/docs/zh-CN/assets/screenshots/overview-memory-graph.png +0 -0
- package/docs/zh-CN/assets/screenshots/recall-agent-answer.png +0 -0
- package/docs/zh-CN/assets/screenshots/runtime-memory.png +0 -0
- package/docs/zh-CN/configuration.md +204 -0
- package/docs/zh-CN/development.md +178 -0
- package/docs/zh-CN/getting-started.md +147 -0
- package/docs/zh-CN/interfaces.md +159 -0
- package/docs/zh-CN/operations.md +151 -0
- package/docs/zh-CN/project-overview.md +247 -0
- package/docs/zh-CN/roadmap.md +41 -0
- package/docs/zh-CN/storage-model.md +179 -0
- package/docs/zh-CN/workflows.md +290 -0
- package/lib/client.js +6288 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +4453 -0
- package/lib/types/client/MnemonLogo.d.ts +7 -0
- package/lib/types/client/MnemonLogo.d.ts.map +1 -0
- package/lib/types/client/MnemonLogo.js +6 -0
- package/lib/types/client/MnemonLogo.js.map +1 -0
- package/lib/types/client/MnemonSettingsCard.d.ts +9 -0
- package/lib/types/client/MnemonSettingsCard.d.ts.map +1 -0
- package/lib/types/client/MnemonSettingsCard.js +109 -0
- package/lib/types/client/MnemonSettingsCard.js.map +1 -0
- package/lib/types/client/MnemonView.d.ts +11 -0
- package/lib/types/client/MnemonView.d.ts.map +1 -0
- package/lib/types/client/MnemonView.js +1239 -0
- package/lib/types/client/MnemonView.js.map +1 -0
- package/lib/types/client/api.d.ts +68 -0
- package/lib/types/client/api.d.ts.map +1 -0
- package/lib/types/client/api.js +80 -0
- package/lib/types/client/api.js.map +1 -0
- package/lib/types/client/index.d.ts +4 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/index.js +36 -0
- package/lib/types/client/index.js.map +1 -0
- package/lib/types/client/locales.d.ts +1054 -0
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/locales.js +1062 -0
- package/lib/types/client/locales.js.map +1 -0
- package/lib/types/client/settings.d.ts +17 -0
- package/lib/types/client/settings.d.ts.map +1 -0
- package/lib/types/client/settings.js +49 -0
- package/lib/types/client/settings.js.map +1 -0
- package/lib/types/commands.d.ts +6 -0
- package/lib/types/commands.d.ts.map +1 -0
- package/lib/types/commands.js +100 -0
- package/lib/types/commands.js.map +1 -0
- package/lib/types/config-values.d.ts +4 -0
- package/lib/types/config-values.d.ts.map +1 -0
- package/lib/types/config-values.js +4 -0
- package/lib/types/config-values.js.map +1 -0
- package/lib/types/config.d.ts +49 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +55 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/contracts.d.ts +272 -0
- package/lib/types/contracts.d.ts.map +1 -0
- package/lib/types/contracts.js +2 -0
- package/lib/types/contracts.js.map +1 -0
- package/lib/types/documents.d.ts +149 -0
- package/lib/types/documents.d.ts.map +1 -0
- package/lib/types/documents.js +503 -0
- package/lib/types/documents.js.map +1 -0
- package/lib/types/guidance.d.ts +9 -0
- package/lib/types/guidance.d.ts.map +1 -0
- package/lib/types/guidance.js +18 -0
- package/lib/types/guidance.js.map +1 -0
- package/lib/types/index.d.ts +15 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +45 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/lifecycle.d.ts +75 -0
- package/lib/types/lifecycle.d.ts.map +1 -0
- package/lib/types/lifecycle.js +380 -0
- package/lib/types/lifecycle.js.map +1 -0
- package/lib/types/memory-bodies.d.ts +47 -0
- package/lib/types/memory-bodies.d.ts.map +1 -0
- package/lib/types/memory-bodies.js +160 -0
- package/lib/types/memory-bodies.js.map +1 -0
- package/lib/types/process.d.ts +14 -0
- package/lib/types/process.d.ts.map +1 -0
- package/lib/types/process.js +65 -0
- package/lib/types/process.js.map +1 -0
- package/lib/types/review-activity.d.ts +33 -0
- package/lib/types/review-activity.d.ts.map +1 -0
- package/lib/types/review-activity.js +37 -0
- package/lib/types/review-activity.js.map +1 -0
- package/lib/types/rpc.d.ts +12 -0
- package/lib/types/rpc.d.ts.map +1 -0
- package/lib/types/rpc.js +225 -0
- package/lib/types/rpc.js.map +1 -0
- package/lib/types/runner.d.ts +29 -0
- package/lib/types/runner.d.ts.map +1 -0
- package/lib/types/runner.js +150 -0
- package/lib/types/runner.js.map +1 -0
- package/lib/types/runtime-memory.d.ts +104 -0
- package/lib/types/runtime-memory.d.ts.map +1 -0
- package/lib/types/runtime-memory.js +415 -0
- package/lib/types/runtime-memory.js.map +1 -0
- package/lib/types/service.d.ts +173 -0
- package/lib/types/service.d.ts.map +1 -0
- package/lib/types/service.js +508 -0
- package/lib/types/service.js.map +1 -0
- package/lib/types/settings.d.ts +6 -0
- package/lib/types/settings.d.ts.map +1 -0
- package/lib/types/settings.js +75 -0
- package/lib/types/settings.js.map +1 -0
- package/lib/types/storage-scope.d.ts +39 -0
- package/lib/types/storage-scope.d.ts.map +1 -0
- package/lib/types/storage-scope.js +179 -0
- package/lib/types/storage-scope.js.map +1 -0
- package/lib/types/subagent.d.ts +97 -0
- package/lib/types/subagent.d.ts.map +1 -0
- package/lib/types/subagent.js +619 -0
- package/lib/types/subagent.js.map +1 -0
- package/lib/types/tools.d.ts +8 -0
- package/lib/types/tools.d.ts.map +1 -0
- package/lib/types/tools.js +328 -0
- package/lib/types/tools.js.map +1 -0
- package/package.json +111 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# 生命周期与核心流程
|
|
2
|
+
|
|
3
|
+
**简体中文** | [English](../en/workflows.md) | [文档中心](./README.md)
|
|
4
|
+
|
|
5
|
+
## 每轮上下文
|
|
6
|
+
|
|
7
|
+
插件注册两个 system prompt section:
|
|
8
|
+
|
|
9
|
+
- `mnemon:routing`:当 `routingGuidance=true` 时提供简短的分层查询边界;
|
|
10
|
+
- `mnemon:runtime-memory`:每次组装 prompt 时读取最新 `USER.md` 和 `MEMORY.md`,并附带保存准入规则。
|
|
11
|
+
|
|
12
|
+
生命周期 hook 不会在每轮开始无条件读取记忆体目录或执行 recall:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
agent/session-start
|
|
16
|
+
-> mark primePending
|
|
17
|
+
|
|
18
|
+
agent/pre-step(step=1)
|
|
19
|
+
-> cancel pending/running background review for a new turn
|
|
20
|
+
-> mark Prime once
|
|
21
|
+
-> optionally append one short recall/writeback cue
|
|
22
|
+
-> main Agent decides whether to call a memory tool
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Prime 只初始化路由状态,不执行异步 CLI 状态查询。
|
|
26
|
+
|
|
27
|
+
## 主 Agent 召回
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
Root Agent calls mnemon_recall(query)
|
|
31
|
+
|
|
|
32
|
+
v
|
|
33
|
+
MnemonSubagentCoordinator
|
|
34
|
+
|
|
|
35
|
+
| spawn + recall persona
|
|
36
|
+
| allow: memory_bodies, recall, related
|
|
37
|
+
v
|
|
38
|
+
Recall worker lists the catalog
|
|
39
|
+
|
|
|
40
|
+
v
|
|
41
|
+
select active Memory Space(s) by name + description
|
|
42
|
+
|
|
|
43
|
+
v
|
|
44
|
+
call mnemon_recall from the worker
|
|
45
|
+
|
|
|
46
|
+
v
|
|
47
|
+
MnemonService searches selected Store(s)
|
|
48
|
+
|
|
|
49
|
+
v
|
|
50
|
+
normalize and attach memoryBodyId / memoryBodyName
|
|
51
|
+
|
|
|
52
|
+
v
|
|
53
|
+
structured output, Host caps results at 12
|
|
54
|
+
|
|
|
55
|
+
v
|
|
56
|
+
Root Agent receives evidence, not the raw routing trace
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
如果用户已经提供当前事实,或仓库可以直接回答,Agent 不应为了“展示记忆”而召回。需要关系解释时,先使用 recall 返回的完整 `memoryBodyId + id`,再执行 related。
|
|
60
|
+
|
|
61
|
+
## Web 检索和 Agent 查询
|
|
62
|
+
|
|
63
|
+
Web “检索”页与模型工具路径不同:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
Direct search
|
|
67
|
+
-> RPC read channel
|
|
68
|
+
-> MnemonService.search directly
|
|
69
|
+
-> raw evidence
|
|
70
|
+
|
|
71
|
+
Agent search
|
|
72
|
+
-> the same deterministic direct search
|
|
73
|
+
-> spawn a worker with no Mnemon tools
|
|
74
|
+
-> answer only from supplied evidence
|
|
75
|
+
-> Host filters citations to actual memoryBodyId/id pairs
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
“实体”和“内容”页也直接读取确定性服务,不启动 recall worker。“内容”使用图谱快照,不增加 Mnemon recall 访问计数。
|
|
79
|
+
|
|
80
|
+
## 显式长期写入
|
|
81
|
+
|
|
82
|
+
根 Agent 或 `/mnemon remember` 的长期写入流程:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
durable candidate
|
|
86
|
+
|
|
|
87
|
+
v
|
|
88
|
+
spawn write worker
|
|
89
|
+
|
|
|
90
|
+
+-- list Memory Spaces
|
|
91
|
+
+-- choose the narrowest suitable scope
|
|
92
|
+
+-- recall when duplicate/conflict checking is useful
|
|
93
|
+
+-- create a new scope only for a recurring distinct domain
|
|
94
|
+
+-- remember / link / forget / merge as requested
|
|
95
|
+
v
|
|
96
|
+
structured receipt
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
新建 Memory Space 的 ID 由 Host 生成。向 inactive 目标写入成功后会激活它。来源数据库的合并是非破坏性的。
|
|
100
|
+
|
|
101
|
+
运行时 `add` / `replace` / `remove` 和 Document `create` / `update` 不需要模型做存储 I/O;它们通过 coordinator 进入确定性控制层。容量维护和归档才启动专用 worker。
|
|
102
|
+
|
|
103
|
+
## Runtime add:正常路径
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
request
|
|
107
|
+
-> normalize content
|
|
108
|
+
-> acquire in-process queue and file lock
|
|
109
|
+
-> reload memories.json
|
|
110
|
+
-> validate unique match / duplicate / capacity
|
|
111
|
+
-> write temporary JSON and Markdown projections
|
|
112
|
+
-> rename projections
|
|
113
|
+
-> rename memories.json as the commit marker
|
|
114
|
+
-> return compact receipt
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`replace` 和 `remove` 必须通过 `old_text` 唯一命中一条。容量维护只在 `add` 溢出时自动触发。
|
|
118
|
+
|
|
119
|
+
## USER.md 容量整理
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
USER add exceeds 4 KiB
|
|
123
|
+
|
|
|
124
|
+
v
|
|
125
|
+
snapshot revision + committed entries
|
|
126
|
+
|
|
|
127
|
+
v
|
|
128
|
+
spawn no-tool local compactor
|
|
129
|
+
|
|
|
130
|
+
v
|
|
131
|
+
return compacted entries + sourceIndexes
|
|
132
|
+
|
|
|
133
|
+
v
|
|
134
|
+
Host validates:
|
|
135
|
+
- every source index appears exactly once
|
|
136
|
+
- no duplicate or out-of-range index
|
|
137
|
+
- importance is not lowered
|
|
138
|
+
- candidate fits the Host byte budget
|
|
139
|
+
- revision is still current
|
|
140
|
+
|
|
|
141
|
+
+-- invalid/conflict -> preserve original data
|
|
142
|
+
|
|
|
143
|
+
v
|
|
144
|
+
deterministic UTF-8 packing
|
|
145
|
+
|
|
|
146
|
+
v
|
|
147
|
+
retry pending add
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
用户画像不会被发送到 Memory Spaces。worker 没有任何工具权限。
|
|
151
|
+
|
|
152
|
+
## MEMORY.md 归档与压缩
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
MEMORY add exceeds 10 KiB
|
|
156
|
+
|
|
|
157
|
+
v
|
|
158
|
+
snapshot revision + committed entries
|
|
159
|
+
|
|
|
160
|
+
v
|
|
161
|
+
spawn archive worker
|
|
162
|
+
allow: memory_bodies, recall, remember, body_create
|
|
163
|
+
|
|
|
164
|
+
v
|
|
165
|
+
route semantic clusters and archive or duplicate-check them
|
|
166
|
+
|
|
|
167
|
+
v
|
|
168
|
+
return action + target spaces + compacted candidates
|
|
169
|
+
|
|
|
170
|
+
v
|
|
171
|
+
Host validates structure, action, revision and byte budget
|
|
172
|
+
|
|
|
173
|
+
+-- failure/conflict -> preserve hot memory
|
|
174
|
+
|
|
|
175
|
+
v
|
|
176
|
+
pack candidates by importance
|
|
177
|
+
|
|
|
178
|
+
v
|
|
179
|
+
retry pending add
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
worker persona 要求每条已提交 entry 都被长期表示或验证为重复;这是 LLM 监督策略。Host 的硬保证是结构、revision 和容量验证,不应把语义覆盖描述成数据库级证明。
|
|
183
|
+
|
|
184
|
+
如果长期写入成功后发生 revision 冲突,热记忆会保留,长期层可能同时已有副本。插件优先避免丢失,不尝试跨数据库和文件系统回滚已完成的 Mnemon 写入。
|
|
185
|
+
|
|
186
|
+
## Documents 创建、更新和归档
|
|
187
|
+
|
|
188
|
+
```text
|
|
189
|
+
create/update request
|
|
190
|
+
|
|
|
191
|
+
v
|
|
192
|
+
capacityPlan using rendered UTF-8 bytes
|
|
193
|
+
|
|
|
194
|
+
+----+----+
|
|
195
|
+
| |
|
|
196
|
+
fits overflow
|
|
197
|
+
| |
|
|
198
|
+
v v
|
|
199
|
+
commit select least-recently-used active Document
|
|
200
|
+
|
|
|
201
|
+
v
|
|
202
|
+
snapshot document + revision
|
|
203
|
+
|
|
|
204
|
+
v
|
|
205
|
+
spawn archive worker
|
|
206
|
+
|
|
|
207
|
+
v
|
|
208
|
+
write/verify concise Mnemon cold reference
|
|
209
|
+
with title, summary, planned path, SHA-256
|
|
210
|
+
|
|
|
211
|
+
+----+----+
|
|
212
|
+
| |
|
|
213
|
+
failed receipt ok
|
|
214
|
+
| |
|
|
215
|
+
v v
|
|
216
|
+
keep active revision check
|
|
217
|
+
|
|
|
218
|
+
+----+----+
|
|
219
|
+
| |
|
|
220
|
+
conflict current
|
|
221
|
+
| |
|
|
222
|
+
v v
|
|
223
|
+
keep active move file to archived
|
|
224
|
+
|
|
|
225
|
+
v
|
|
226
|
+
retry original mutation
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
人工归档使用同一条“先索引、后迁移”路径。Mnemon 索引已经成功但 revision 冲突时不会回滚索引,因此可能出现安全的重复引用,而不会丢失 active 原文。
|
|
230
|
+
|
|
231
|
+
## 确定性活动评分和后台审查
|
|
232
|
+
|
|
233
|
+
完成的 turn 累计四种信号:
|
|
234
|
+
|
|
235
|
+
```text
|
|
236
|
+
score =
|
|
237
|
+
min(floor(totalUserCharacters / 50), 3)
|
|
238
|
+
+ completedTurnCount
|
|
239
|
+
+ min(floor(completedToolResults / 5), 2)
|
|
240
|
+
+ toolDiversityScore
|
|
241
|
+
|
|
242
|
+
toolDiversityScore:
|
|
243
|
+
unique tools < 3 -> 0
|
|
244
|
+
unique tools = 3 -> 1
|
|
245
|
+
unique tools >= 4 -> 2
|
|
246
|
+
|
|
247
|
+
eligible when score >= 5
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
达到门槛并不代表一定写入:
|
|
251
|
+
|
|
252
|
+
```text
|
|
253
|
+
completed turn
|
|
254
|
+
|
|
|
255
|
+
v
|
|
256
|
+
score >= 5 ? -- no --> retain activity for later turns
|
|
257
|
+
|
|
|
258
|
+
yes
|
|
259
|
+
|
|
|
260
|
+
v
|
|
261
|
+
wait idleReviewMs (default 30 s)
|
|
262
|
+
|
|
|
263
|
+
+-- new turn --> cancel timer/worker, retain activity
|
|
264
|
+
|
|
|
265
|
+
v
|
|
266
|
+
confirm Agent is idle and turn/end exists
|
|
267
|
+
|
|
|
268
|
+
v
|
|
269
|
+
fork completed parent checkpoint
|
|
270
|
+
|
|
|
271
|
+
v
|
|
272
|
+
conservative maintenance decision
|
|
273
|
+
- at most one hot-memory mutation by persona
|
|
274
|
+
- at most one Document create/update by persona
|
|
275
|
+
- no direct long-term remember/forget tools
|
|
276
|
+
|
|
|
277
|
+
+-- completed, including skip -> clear activity
|
|
278
|
+
|
|
|
279
|
+
+-- failed/aborted ------------> retain activity
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
“最多一次”当前由 worker persona 约束,不是 Host mutation counter。后台水位尚未持久化,Host 重启会丢失未处理的累计信号。
|
|
283
|
+
|
|
284
|
+
## 配置开关的关系
|
|
285
|
+
|
|
286
|
+
- `recallMode=off`:不再注入 recall cue,显式 `mnemon_recall` 仍可用。
|
|
287
|
+
- `writebackMode=off`:关闭写回 cue 和评分后台审查,显式写入仍由 `writeEnabled` 决定。
|
|
288
|
+
- `lifecycleEnabled=false`:关闭生命周期提醒和审查,不移除显式工具或 Web 入口。
|
|
289
|
+
- `routingGuidance=false`:只移除额外路由 section;Runtime Memory section 仍注册。
|
|
290
|
+
- `writeEnabled=false`:移除语义写工具和写 RPC,拒绝写命令;它不是文件系统只读挂载保证。
|